test(continuous): per-instance trigger-miss hook#542
Open
julio4 wants to merge 3 commits into
Open
Conversation
avalonche
reviewed
Jun 16, 2026
| /// 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, |
Collaborator
There was a problem hiding this comment.
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`.
69f8ca3 to
c2da710
Compare
Contributor
There was a problem hiding this comment.
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 throughBuilderConfigand the test harness (LocalInstance) to configure continuous-build behavior per instance. - Reworks
SharedBest’s forcedtake()miss behavior to use a per-builder atomic counter rather than a global static. - Extends the
#[rb_test]proc-macro to accept a newtest_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.
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.
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.