Skip to content

api, cluster-controller: tidy the Direct-fixture test sort (tests only) - #428

Merged
ac-pplx merged 1 commit into
mainfrom
ac/resort-direct-fixture-tests
Oct 14, 2026
Merged

ac-pplx merged 1 commit into
mainfrom
ac/resort-direct-fixture-tests

Conversation

@ac-pplx

@ac-pplx ac-pplx commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #402's review.

  • direct_substrate and enabled_config move into the api crate's
    test_support module. lifecycle/characterization_tests.rs had an
    identical copy of direct_substrate, which is removed. The test
    stale_heartbeat_direct_worker_is_not_empty_cluster in
    substrate::direct::cluster_admission_tests now builds its admission
    with ClusterSandboxAdmission::with_config directly. That drops the
    local admission stand-in and its unused bucket parameter, and lets
    cluster_admission::tests go back to a private module. Only the
    fixture-construction line of the test body changes; its assertions
    are the same.
  • rejected_admission_blocks_pod_recreation_for_started_sandbox_with_lost_pod
    gets the same placeholder comment as its siblings, merged with the
    comment that was already there.
  • The direct_sink comment names both guards that would decide
    differently for a Kubernetes label: the converge CAS and the
    failed-active repair CAS.
  • The direct_sandbox_controller comment adds that the admitted
    re-execution test also reaches admitted_pool_cleanup_pending.
    Direct answers it with the trait default false. Kubernetes reads the
    reserved slot, and returns workflow progress when that slot's cleanup
    is pending.

No production code changes. The test count is unchanged.

Addresses the non-blocking review findings on #402, which merged before they were applied.

🤖 Generated with Claude Code

Follow-up to #402's review.

- `direct_substrate` and `enabled_config` move into the api crate's
  `test_support` module. `lifecycle/characterization_tests.rs` had an
  identical copy of `direct_substrate`, which is removed. The test
  `stale_heartbeat_direct_worker_is_not_empty_cluster` in
  `substrate::direct::cluster_admission_tests` now builds its admission
  with `ClusterSandboxAdmission::with_config` directly. That drops the
  local `admission` stand-in and its unused bucket parameter, and lets
  `cluster_admission::tests` go back to a private module. Only the
  fixture-construction line of the test body changes; its assertions
  are the same.
- `rejected_admission_blocks_pod_recreation_for_started_sandbox_with_lost_pod`
  gets the same placeholder comment as its siblings, merged with the
  comment that was already there.
- The `direct_sink` comment names both guards that would decide
  differently for a Kubernetes label: the converge CAS and the
  failed-active repair CAS.
- The `direct_sandbox_controller` comment adds that the admitted
  re-execution test also reaches `admitted_pool_cleanup_pending`.
  Direct answers it with the trait default `false`. Kubernetes reads the
  reserved slot, and returns workflow progress when that slot's cleanup
  is pending.

No production code changes. The test count is unchanged.
@ac-pplx
ac-pplx marked this pull request as ready for review October 14, 2026 01:41
@the-gigi-pplx

Copy link
Copy Markdown
Collaborator

Review — 3 findings

Medium

  1. crates/libs/api/src/public_sandbox_operations/tests.rs:61 — the new comment says the admitted re-execution test "differs on Kubernetes in two places", but the second place can't differ for this fixture.
    admitted_create_re_execution_after_success_does_not_create_again (line 1047) seeds a sandbox row and a pool_claim with a fresh random pool_slot_id, but no kubernetes_pool_slots row. On Kubernetes, admitted_pool_cleanup_pending goes through WarmPoolStore::reserved_slot_cleanup_pending (crates/libs/cluster/pool/src/store.rs:1390), which is an EXISTS over kubernetes_pool_slots and so returns false with no slot (kubernetes/pool/tests.rs:1148 pins exactly that). Both substrates answer false, and both reach Succeeded. Only the sandbox_k8s_executions check really depends on the substrate.
    Suggest wording along the lines of "its pool claim also makes the executor ask admitted_pool_cleanup_pending; Direct answers with the trait default, and Kubernetes would answer the same here because the test seeds no slot". The alternative is to seed a cleanup_pending slot in a Kubernetes variant, if that branch is meant to be covered.

Low

  1. crates/libs/api/src/cluster_admission/tests.rs:17 — the "Direct is only a placeholder capacity source…" comment used to document the local direct_substrate fn. Now it sits between two use lines, above an import that also brings in enabled_config. It fits better as a //! module note, or on capacity_probe_failure_fails_open, the test that needs Direct's failing count.

  2. Leftover copies of the fixtures this PR centralizes, in files the PR touches:

    • controllers/sandbox/lifecycle/characterization_tests.rs:136: controller_with_empty_cluster_admission now calls the shared direct_substrate but still spells out the same ClusterSandboxAdmissionConfig { enabled: true, refill_rps: 6.0, burst: 60.0, redis_url: None } that test_support::enabled_config() returns.
    • public_sandbox_operations/tests.rs:67 and :639 still build Substrate::Direct(Box::new(DirectSubstrate::new(pool.clone()))) inline.
    • controllers/substrate/kubernetes/tests.rs has five copies of the Direct-placeholder admission (lines 9413, 9477, 9555, 9622 and 9685), each with the full config literal. Only the one at 9555 got the placeholder comment. A small local helper (e.g. empty_direct_admission(pool)) carrying that comment once would cover all five.

    None of this changes behavior. It's only the copies that will need hand-syncing if enabled_config changes.

Everything else checks out:

  • direct_sink (lifecycle_writer_tests.rs:49): the converge CAS embeds routable_execution_or_non_k8s (transient_lifecycle_sweeper/store.rs:524-534), and the failed-active repair CAS hard-codes managed_by = 'k8s' (store.rs:92). These are the two guards the module doc names.
  • The placeholder comment in the Kubernetes test (kubernetes/tests.rs:9552): a nodes-ready, empty cache returns Some(0) (kubernetes/mod.rs:947-968, pinned at kubernetes/tests.rs:9318).
  • The trait default for admitted_pool_cleanup_pending is Ok(false) (substrate/mod.rs:2541), and Direct doesn't override it.
  • test_support is #[cfg(test)] (lib.rs:54), so the new imports don't reach non-test builds.

Verified against d363c7f86feedbd91aff29534c1b2b11fa663977. I traced each claim to source by hand and didn't run cargo locally; CI's Rust tests, clippy and fmt are green on this head. No file this PR touches has changed on main since its base.

@the-gigi-pplx the-gigi-pplx left a comment

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.

Approved. 3 non-blocking findings in the review comment above.

@ac-pplx
ac-pplx added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit e1e6ed3 Oct 14, 2026
20 checks passed
@ac-pplx
ac-pplx deleted the ac/resort-direct-fixture-tests branch October 14, 2026 03:29
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.

2 participants