Skip to content

Add local server state machine subprocess tests - #562

Open
sdairs wants to merge 2 commits into
stack/478-lifecycle-helpfrom
stack/479-server-state-machine-tests
Open

Add local server state machine subprocess tests#562
sdairs wants to merge 2 commits into
stack/478-lifecycle-helpfrom
stack/479-server-state-machine-tests

Conversation

@sdairs

@sdairs sdairs commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add one table-driven, isolated subprocess suite for the local ClickHouse server state machine
  • cover fresh, default, custom, omitted/explicit selection, exact-CWD, explicit global project, and generated-name transitions
  • exercise bare starts through a selected fake latest default without network resolution
  • assert exact output contracts, metadata, process liveness, data persistence/removal, telemetry isolation, update-cache isolation, and no project server state under HOME

Tests

  • cargo test -p clickhousectl --test local_server_state_machine_test (3 runs, including 2 concurrent runs)
  • cargo build --workspace
  • cargo check --workspace --all-targets
  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace (blocked by two inherited parent-owned help-text assertions in local::cli::tests; those files are outside this PR diff)

Closes #479

Supersedes #521.

@sdairs

sdairs commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

Carry-over review from PR #521 (old PR for #479). This PR is strictly better than #521: CI green where #521 is red; it fixes #521's fatal exec sleep × managed-identity-inspection interaction by construction (the new base uses plain kill(pid, 0) liveness, and all pgrep/lsof/ps discovery is shimmed at the front of PATH keyed off a recorded pid file, so global-discovery scenarios are deterministic); stronger isolation (env_clear() + per-scenario fixtures + ProcessGuard + no-recorded-PID-alive check); exact full-JSON equality for responses and structured errors plus exact-string human output; full metadata-file equality; data-marker persistence across restart; and explicit --global --project <root> stop from a child CWD. Verified: suite passes locally (1 passed). No sdairs over-engineering/test-design comments existed on #521. Three items before merge:

  1. Honor sdairs' one substantive review comment on Add local server state machine subprocess tests #521: "always use latest". On Add local server state machine subprocess tests #521, sdairs' comment was "always use latest" (addressed there by installing and selecting a fake latest default and starting without --version, keeping determinism without network resolution). This PR does the opposite: const VERSION: &str = "25.12.9.61" and every start appends --version 25.12.9.61 --no-wait. Determinism is preserved (local-first install finds the pre-seeded version) so the spirit is honored, but the bare-start / default-version-resolution path (get_default_version() → bare start) is never exercised, and the literal instruction is not followed. Either add a bare-start case backed by a fake latest default (write .clickhouse/default + a versions/latest copy of the fake binary), or document in the PR description why pinning the version is intentional.

  2. Add the omitted-repeated-start → generated-name transition. Add local server state machine subprocess tests #521 covered it ("omitted repeated start generates a name"); this PR does not exercise resolve_name_locked's random adjective-noun generation anywhere. That is a real state-machine transition named in the acceptance criteria ("repeated start"). Add a case asserting a generated name is produced and usable for subsequent stop/remove.

  3. Seed the update-check cache to prevent a latent flake. This PR's exact human-stderr assertions don't account for the cached update notice. Add local server state machine subprocess tests #521 seeded last_update_check; this PR does not. Today latest release (v0.4.1) == CARGO_PKG_VERSION so is_newer is false and nothing prints — but once v0.4.2 ships, every HumanSuccess/HumanFailure case gains a stderr suffix and fails. Seed the cache as Add local server state machine subprocess tests #521 did.

Minor: #521 also asserted project server state is never written under HOME; consider adding that assertion here.

Supersede/close #521 when this merges.

@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch from fa70153 to 370698f Compare August 26, 2026 18:58
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch from 370698f to 2cb8d3f Compare August 26, 2026 19:01
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch from 2cb8d3f to 8f8888c Compare August 26, 2026 19:03
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch from 8f8888c to 552ed85 Compare August 26, 2026 19:07
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch 2 times, most recently from 83ababc to da5ff90 Compare August 26, 2026 19:12
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch from da5ff90 to 467d28c Compare August 26, 2026 19:20
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch 2 times, most recently from 7ef8d65 to 4febe10 Compare August 26, 2026 19:28
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch from 4febe10 to f218da1 Compare August 26, 2026 19:31
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch 2 times, most recently from d0e46ae to 8ece30a Compare August 26, 2026 19:36
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch 2 times, most recently from 077bdf0 to 800fe6a Compare August 26, 2026 20:30
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch from 800fe6a to 57754f9 Compare August 26, 2026 20:35
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch from 01c1e91 to 2ad6ffb Compare August 27, 2026 06:44
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch 2 times, most recently from 7d458c1 to ece7e43 Compare August 27, 2026 06:53
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch 2 times, most recently from 25c8587 to 6e87f62 Compare August 27, 2026 07:06
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch 2 times, most recently from 1a8cc45 to 51daae7 Compare August 27, 2026 07:17
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch from 51daae7 to 99dafcf Compare August 27, 2026 07:24
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch 2 times, most recently from a05fbae to b4059a5 Compare August 27, 2026 07:37
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch 2 times, most recently from 77e957e to a60ca3f Compare August 27, 2026 07:50
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch from a60ca3f to eecd069 Compare August 27, 2026 09:19
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch from eecd069 to 72203f9 Compare August 27, 2026 10:13
@sdairs
sdairs force-pushed the stack/479-server-state-machine-tests branch from 72203f9 to fa96bfd Compare August 27, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add table-driven subprocess test suite for local server state machine

1 participant