Skip to content

test(continuous): per-instance trigger-miss hook#542

Open
julio4 wants to merge 3 commits into
mainfrom
fix/continuous-test-hook-isolation
Open

test(continuous): per-instance trigger-miss hook#542
julio4 wants to merge 3 commits into
mainfrom
fix/continuous-test-hook-isolation

Conversation

@julio4

@julio4 julio4 commented Jun 16, 2026

Copy link
Copy Markdown
Member

Fallback test was flaky with the force trigger-miss hook, that relied on a process-global count that any concurrent test could consume. Replaced with per-builder Arc.

Comment thread crates/op-rbuilder/src/args/op.rs Outdated
/// Number of forced `SharedBest::take()` misses for test isolation.
/// Consumed only under `#[cfg(test)]`; else always 0.
#[arg(skip)]
pub initial_force_take_miss_count: u64,

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 this not be refactored such that the test instance can be configured with a test SharedBest instance with test config?

… process global

The previous `FORCE_TAKE_MISS_COUNT` static in `shared_best.rs` was a
process-global AtomicU64, so under `cargo test` (all tests in one process,
parallel threads) any other continuous-mode test calling `SharedBest::take()`
in its build loop could consume the forced miss intended for
`smoke_continuous_trigger_miss_fallback_publishes_candidate`, causing the
fallback test to pass vacuously or perturbing a sibling test.

Replace the global with a per-builder `Arc<AtomicU64>` seeded from a new
`initial_force_take_miss_count` field on `FlashblocksConfig` (and
`FlashblocksArgs`, `#[arg(skip)]`).  `OpPayloadBuilderInner` holds the Arc
(`#[cfg(test)]`), clones it into every `SharedBest` via
`start_flashblock_interval`, and `SharedBest::take()` does the decrement on
`self.force_take_miss` rather than the global.  The test sets
`initial_force_take_miss_count: 1` in its `OpRbuilderArgs` literal; all
global hook infrastructure (`ForceTakeMissGuard`, `force_next_take_misses`,
`should_force_take_miss`, and the `continuous_test_hooks` re-exports) is
deleted.  Verified with both `cargo nextest run` and `cargo test`.
Copilot AI review requested due to automatic review settings July 6, 2026 09:30
@julio4 julio4 force-pushed the fix/continuous-test-hook-isolation branch from 69f8ca3 to c2da710 Compare July 6, 2026 09:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces flakiness in continuous-build tests by replacing a process-global “force trigger-miss” hook with a per-builder counter (Arc<AtomicU64>) that’s injected through test-only configuration.

Changes:

  • Introduces ContinuousTestHooks (test-only) and threads it through BuilderConfig and the test harness (LocalInstance) to configure continuous-build behavior per instance.
  • Reworks SharedBest’s forced take() miss behavior to use a per-builder atomic counter rather than a global static.
  • Extends the #[rb_test] proc-macro to accept a new test_hooks = ... parameter for tests that need hook injection.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/op-rbuilder/src/tests/framework/instance.rs Adds new_with_test_hooks / new_with_config_and_hooks to inject ContinuousTestHooks into the builder config for tests.
crates/op-rbuilder/src/tests/flashblocks.rs Updates the trigger-miss fallback test to use test_hooks instead of a global hook.
crates/op-rbuilder/src/builder/payload.rs Stores a per-builder force_take_miss_counter initialized from test hooks (test-only).
crates/op-rbuilder/src/builder/mod.rs Adds a test-only continuous_test_hooks field to BuilderConfig and re-exports ContinuousTestHooks for tests.
crates/op-rbuilder/src/builder/continuous/shared_best.rs Refactors SharedBest into a struct and replaces global forced-miss logic with an injected per-builder counter.
crates/op-rbuilder/src/builder/continuous/mod.rs Defines the ContinuousTestHooks struct (test-only).
crates/op-rbuilder/src/builder/continuous/interval.rs Wires the per-builder counter into each SharedBest created for a flashblock interval (test-only).
crates/op-rbuilder-test-macros/src/lib.rs Adds test_hooks support to #[rb_test] and routes initialization through the new LocalInstance constructors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/op-rbuilder/src/tests/framework/instance.rs Outdated
Comment thread crates/op-rbuilder/src/tests/framework/instance.rs Outdated
Comment thread crates/op-rbuilder/src/tests/flashblocks.rs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 6, 2026 09:49
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

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.

3 participants