Skip to content

Add skip_localhost mark, skip shutdown on local#614

Open
PatersonProjects wants to merge 15 commits into
documentdb:mainfrom
PatersonProjects:shutdown_smoke_fix
Open

Add skip_localhost mark, skip shutdown on local#614
PatersonProjects wants to merge 15 commits into
documentdb:mainfrom
PatersonProjects:shutdown_smoke_fix

Conversation

@PatersonProjects

Copy link
Copy Markdown
Contributor

This PR changes the contest and ini to add the needed mark to prevent the shutdown command from running on localhost devices (determined by checking the uri connected to mongo), helping prevent the destructive shutdown failing local test runs.

…own command

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
@PatersonProjects PatersonProjects requested a review from a team as a code owner June 16, 2026 20:52
@documentdb-triage-tool

Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: compatibility test, enhancement
Project fields suggested: Component test-coverage · Priority P2 · Effort M · Status Needs Review
Confidence: 0.75 (mixed)

Reasoning

component from path globs (test-coverage); effort from diff stats (20+1 LOC, 3 files); LLM: Adds a pytest mark to skip destructive shutdown commands on localhost, improving local developer experience in the test framework (conftest/ini changes).

If a label is wrong, remove it manually and ping @patty-chow so the rules can be tuned. The bot will not re-label items that already have component labels.

@documentdb-triage-tool documentdb-triage-tool Bot added compatibility test Compatibility test related enhancement New feature or request labels Jun 16, 2026
PatersonProjects and others added 7 commits June 24, 2026 16:25
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>

# Conflicts:
#	documentdb_tests/conftest.py
#	documentdb_tests/pytest.ini
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
This reverts commit 014f2bc.

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
This reverts commit 51a482a.

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
…-tests

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Comment thread documentdb_tests/conftest.py Outdated

Tests marked 'skip_localhost' are skipped when their target connects to a
localhost server -- a safety guard for destructive commands (e.g. shutdown)
that behave differently from a local client.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remind me what's the behavior on local host what is behavior on remove host?
CI also skips it:

skip_localhost:
  Total:   1
  Passed:  0 (0.0%)
  Failed:  0
  Skipped: 1

Then when will we run this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this came about as a misunderstanding on my part of how Docker was being run in CI, thank you for catching this. The goal is that it is skipped on local runs and passes on remote runs, as if the test ever fails it kills the connection and ruins the whole test run. I have made this earlier change to be a fallback and introduced a new check that allows CI to run the test.

PatersonProjects and others added 4 commits July 2, 2026 12:40
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
…cts/functional-tests into shutdown_smoke_fix

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
@PatersonProjects PatersonProjects requested a review from eerxuan July 2, 2026 20:27
@ramgokul-14

Copy link
Copy Markdown
  • [Required] Fail-open on a destructive gate. In conftest.py, except Exception: nodes = [] makes an unparseable URI resolve to not localhost → the destructive shutdown runs. A safety guard must fail safe: on parse failure, treat as localhost and skip. This is the most important fix.

  • [Required] Missing docs update (§9 of docs/REVIEW.md). The guideline explicitly requires TEST_FORMAT.md to be updated when a PR introduces a new mark. skip_localhost is a new mark; no doc change is included.

  • [Suggestion] Reuse the existing requires(...)/preconditions gate instead of a bespoke loop. The new code even comments that it "mirrors the requires(...) gate" — modeling this as a capability (e.g. requires(remote_target=True)) would deselect rather than skip, reuse per-target resolution and auto-registration, and avoid a parallel mechanism. §6 of the guide leans toward requires(...) for environment-gated tests.

  • [Suggestion] Host-matching edge cases: {localhost, 127.0.0.1, ::1} misses 0.0.0.0 (common in Docker/dev) and hostnames that resolve to loopback. Add 0.0.0.0 at minimum.

  • pytest.ini marker description could state the purpose (safety guard for destructive commands), not just the mechanic.

  • Consider co-locating the parse_uri import with its usage or commenting why it's module-level.

…-tests

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
@PatersonProjects

Copy link
Copy Markdown
Contributor Author
  • [Required] Fail-open on a destructive gate. In conftest.py, except Exception: nodes = [] makes an unparseable URI resolve to not localhost → the destructive shutdown runs. A safety guard must fail safe: on parse failure, treat as localhost and skip. This is the most important fix.
  • [Required] Missing docs update (§9 of docs/REVIEW.md). The guideline explicitly requires TEST_FORMAT.md to be updated when a PR introduces a new mark. skip_localhost is a new mark; no doc change is included.
  • [Suggestion] Reuse the existing requires(...)/preconditions gate instead of a bespoke loop. The new code even comments that it "mirrors the requires(...) gate" — modeling this as a capability (e.g. requires(remote_target=True)) would deselect rather than skip, reuse per-target resolution and auto-registration, and avoid a parallel mechanism. §6 of the guide leans toward requires(...) for environment-gated tests.
  • [Suggestion] Host-matching edge cases: {localhost, 127.0.0.1, ::1} misses 0.0.0.0 (common in Docker/dev) and hostnames that resolve to loopback. Add 0.0.0.0 at minimum.
  • pytest.ini marker description could state the purpose (safety guard for destructive commands), not just the mechanic.
  • Consider co-locating the parse_uri import with its usage or commenting why it's module-level.

Updated to use the new preconditions, which also helps fix the open gate. Updated documentation and descriptions

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were subtract related files unintentionally added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compatibility test Compatibility test related enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants