test: skip CLI parser tests that execute the full pipeline in CI - #727
Merged
Merged
Conversation
test_force_missing_dependencies_cli.py and test_drop_unresolvable_principals_cli.py use CliRunner.invoke() to assert click recognizes a flag (exit_code != 2 is click's "unknown option" usage error). But invoke() does not stop after parsing — it executes the whole command. In CI, tox.ini's `passenv = DD_SOURCE_*,DD_DESTINATION_*` lets the real workflow secrets reach the unit tests, so sync/migrate/diffs/import actually run the full pipeline against live Datadog orgs, retrying up to DD_HTTP_CLIENT_RETRY_TIMEOUT (300s) per call. Measured wall-clock from recent runs (timestamp-gap analysis of completed job logs): the suite swings from 10 min to 134 min across identical runs on the same OS, with three tests accounting for ~95-130 min of every run: test_sync_accepts_force_missing_deps 50-65 min test_migrate_accepts_drop_unresolvable_principals 12-55 min test_migrate_accepts_force_missing_deps 2-10 min This flakiness blocks PRs (jobs appear stuck for up to 6h, the GitHub default timeout) without any code change being responsible. Skip these tests until they are rewritten to short-circuit after parsing (e.g. CliRunner with fake creds via env, or a parser-only assertion). Kept test_import_rejects_drop_unresolvable_principals running: it asserts exit_code == 2 (click parse error), which returns immediately without executing anything.
michael-richey
marked this pull request as ready for review
September 28, 2026 19:27
riyazsh
approved these changes
Sep 28, 2026
michael-richey
deleted the
michael-richey/skip-slow-cli-parser-tests
branch
September 28, 2026 19:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CI runs are taking 10–134 min for the unit suite and blocking PRs (jobs appear "stuck" up to the 6h GitHub default timeout). This is not caused by any recent code change — it's pre-existing flakiness.
Root cause
Three "flag accepted" parser tests use
CliRunner.invoke()to assert click recognizes a flag (exit_code != 2is click's "unknown option" usage error). Butinvoke()does not stop after parsing — it executes the whole command. In CI,tox.ini'spassenv = DD_SOURCE_*,DD_DESTINATION_*lets the real workflow secrets reach the unit tests, sosync/migrate/diffs/importactually run the full pipeline against live Datadog orgs, retrying up toDD_HTTP_CLIENT_RETRY_TIMEOUT(300s) per call.Timestamp-gap analysis of completed job logs names the same culprits across independent runs (macos 09-28, ubuntu 09-25):
test_force_missing_dependencies_cli.py::test_sync_accepts_force_missing_depstest_drop_unresolvable_principals_cli.py::test_migrate_accepts_drop_unresolvable_principalstest_force_missing_dependencies_cli.py::test_migrate_accepts_force_missing_depsThe wide variance (10–134 min for the identical suite across runs) is just how long those real network calls happen to take — classic flakiness, not a deterministic hang. Locally the suite runs in ~13s because the
fakeAPI-key defaults 403 immediately.Change
Skip the affected tests with
pytest.mark.skipand a pointer to the root cause, so CI is unblocked while a proper fix is designed.tests/unit/test_force_missing_dependencies_cli.py— module-level skip (all 3 tests execute the pipeline)tests/unit/test_drop_unresolvable_principals_cli.py— per-test skip on the 3exit_code != 2teststest_import_rejects_drop_unresolvable_principalsrunning: it assertsexit_code == 2(click parse error), which returns immediately without executing anything.Follow-up (not in this PR)
A proper fix would rewrite these to short-circuit after parsing — e.g.
CliRunner(env={...})with fake creds, or a parser-only assertion — and optionally dropDD_SOURCE_*,DD_DESTINATION_*fromtox.ini'spassenvfor the plain[testenv]so real secrets never reach unit tests. Addingtimeout-minutes: 30to thetestjob intest.ymlwould also make a future genuine hang fail loudly instead of lingering up to 6h.Verification
tox -e py311 -- tests/unit/test_force_missing_dependencies_cli.py tests/unit/test_drop_unresolvable_principals_cli.py -v→1 passed, 6 skipped in 0.08sruffandblackclean on the two changed files.