Skip to content

Flowtable concurrent fuzz - #1581

Merged
sergeymatov merged 7 commits into
mainfrom
flowtable-concurrent-fuzz
Jun 9, 2026
Merged

Flowtable concurrent fuzz#1581
sergeymatov merged 7 commits into
mainfrom
flowtable-concurrent-fuzz

Conversation

@daniel-noland

@daniel-noland daniel-noland commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

This is a temp placeholder while I discuss with @sergeymatov. Ignore for now if you aren't @sergeymatov

This PR is a temporary placeholder while the author discusses changes with @sergeymatov; reviewers other than @sergeymatov are asked to ignore it for now. It adds a FlowTable concurrency fuzz test and supporting concurrency-harness adjustments, and removes a FlowTable API incompatible with shuttle-based testing.

Summary

  • New bolero-driven concurrent fuzz test for FlowTable (cfg(test) and cfg(not(feature = "loom"))):

    • Adds flow-entry/src/flow_table/concurrent_fuzz.rs: generates Scenario { seed_key, ops: [Vec; 3] } via bolero, normalizes generation so at least two worker streams include Insert, and implements bolero::TypeGenerator for Scenario.
    • Runs three concurrent worker threads via concurrency::thread::scope (one per op stream). Uses a shared Arc stored in a StubItem inside flow nat_state to exercise racing updates and asserts per-entry status after workers finish.
    • Selects either a current-thread Tokio runtime for the std backend or no runtime when running under shuttle.
    • Adds a test function stress_test_concurrency_model() that drives generation through concurrency::stress.
  • Concurrency harness changes and exports:

    • concurrency/src/stress.rs: adds a public helper pub fn shuttle_config() -> shuttle::Config (cfg(all(not(feature = "loom"), feature = "shuttle"))) returning a Config with 4 MiB stack size; refactors the shuttle branch of stress to use shuttle_config().
    • concurrency/src/lib.rs: documents and publicly re-exports stress::stress (removed #[doc(hidden)]), and conditionally re-exports stress::shuttle_config when shuttle is enabled and loom is not.
    • concurrency/tests/quiescent_shuttle.rs: replaces shuttle::check_random / check_pct helper calls with explicit shuttle::Runner construction (RandomScheduler / PctScheduler) and runner.run, using the shared shuttle_config where applicable.
  • FlowTable API and tests:

    • flow-entry/src/flow_table/table.rs: removes the public pub fn drain_stale(&self) -> usize method; related concurrent test assertions were tightened to assert_eq! where appropriate.
  • Bolero test utilities for FlowInfo:

    • net/src/flows/flow_info.rs: under cfg(any(test, feature = "bolero")), adds pub fn new_with_status(...) to construct FlowInfo with an explicit FlowStatus, and a bolero::TypeGenerator for FlowStatus that maps sampled u8 % 8 into Active/Cancelled/Expired/Detached with Active weighted higher.

Notes, testing, and metadata

  • The PR is explicitly a discussion placeholder; author notes enabling the [bolero] feature in a non-dev context was accidental (IDE assistance) and should be treated as a test/dev-only concern.
  • The new fuzz test is excluded from loom builds (FlowTable uses DashMap-like concurrency not suitable for loom).
  • Backends supported by the stress harness: std (current-thread Tokio runtime) and shuttle (portfolio runners with Random / PCT schedulers).
  • Lines changed: large additions in flow-entry/src/flow_table/concurrent_fuzz.rs (+~322), medium changes in concurrency and flow_info files; estimated review effort: Medium–High.

Conventional commits

  • Commits follow conventional-style messages; no merge commits present.

Comment thread net/src/flows/flow_info.rs
Comment thread flow-entry/src/flow_table/concurrent_fuzz.rs
Comment thread flow-entry/src/flow_table/table.rs
@sergeymatov
sergeymatov force-pushed the flowtable-concurrent-fuzz branch 2 times, most recently from 0ba4a4f to 714addf Compare June 8, 2026 09:59
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 26ccd14c-80b5-4f26-a1fe-cbf3ea6d361a

📥 Commits

Reviewing files that changed from the base of the PR and between c13f66f and 97eeb5f.

📒 Files selected for processing (1)
  • flow-entry/src/flow_table/concurrent_fuzz.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • flow-entry/src/flow_table/concurrent_fuzz.rs

📝 Walkthrough

Walkthrough

Exposes concurrency::stress (with module docs) and a shuttle_config helper; updates shuttle tests to use explicit shuttle::Runner; adds bolero generators and FlowInfo test constructor; introduces a bolero-driven concurrent FlowTable fuzz test; removes FlowTable::drain_stale.

Changes

Concurrency Testing & FlowTable Fuzz Coverage

Layer / File(s) Summary
Shuttle configuration extraction and re-export
concurrency/src/stress.rs, concurrency/src/lib.rs
New shuttle_config() helper sets 4 MiB stack size; stress dispatcher uses it; public re-export with documentation exposes stress and shuttle_config (shuttle-only).
Bolero property generators for test data
net/src/flows/flow_info.rs
Adds FlowInfo::new_with_status() constructor and FlowStatus bolero generator that biases toward Active while producing terminal states.
Migrate quiescent_shuttle tests to explicit Runner API
concurrency/tests/quiescent_shuttle.rs
Both protocol_under_shuttle and protocol_under_shuttle_pct construct shuttle::Runner explicitly with RandomScheduler / PctScheduler and call runner.run instead of helper functions.
Comprehensive concurrent fuzz test for FlowTable
flow-entry/src/flow_table/concurrent_fuzz.rs, flow-entry/src/flow_table/mod.rs
Bolero-driven scenario generator creates three concurrent workers performing Insert/Lookup/Invalidate/Extend on derived key sets with a shared Arc<AtomicU8> in locked nat_state; scenarios run via concurrency::stress with runtime selection based on backend.
FlowTable API cleanup and test assertions
flow-entry/src/flow_table/table.rs
Removes public drain_stale() method; updates test_flow_table_reshard assertions to use assert_eq!.

🎯 3 (Moderate) | ⏱️ ~25 minutes

"🐰 I hop through stacks and configs bright,
Bolero seeds tumble into concurrent night,
Three workers race, atoms blink and spin,
Stress runs the plan — let the fuzzing begin,
A carrot for tests, chaos trimmed thin."

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Flowtable concurrent fuzz' is clear and directly describes the main change: adding a concurrent fuzzing test for FlowTable using bolero and the concurrency module.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch flowtable-concurrent-fuzz

Comment @coderabbitai help to get the list of available commands and usage tips.

@sergeymatov
sergeymatov force-pushed the flowtable-concurrent-fuzz branch 2 times, most recently from a311161 to d24fc00 Compare June 8, 2026 10:57
@sergeymatov
sergeymatov marked this pull request as ready for review June 8, 2026 11:18
Copilot AI review requested due to automatic review settings June 8, 2026 11:18
@sergeymatov
sergeymatov requested a review from a team as a code owner June 8, 2026 11:18
@sergeymatov
sergeymatov requested review from sergeymatov and removed request for a team June 8, 2026 11:18

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 adds bolero-driven concurrent fuzz coverage for FlowTable and refactors shuttle runner configuration so bolero+shuttle suites can share the same “standard” shuttle Config (notably the increased stack size).

Changes:

  • Add a new concurrent bolero stress test module for FlowTable (flow-entry/src/flow_table/concurrent_fuzz.rs) and wire it into the test build.
  • Add bolero::TypeGenerator support for net::flows::FlowStatus behind cfg(test) / feature = "bolero".
  • Introduce and re-export concurrency::shuttle_config() and update an existing shuttle fuzz test to use it.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
net/src/flows/flow_info.rs Adds a bolero TypeGenerator impl for FlowStatus under test/feature gating.
net/Cargo.toml Changes dataplane-net default features to include bolero.
flow-entry/src/flow_table/table.rs Removes drain_stale and tweaks assertions in a concurrency test.
flow-entry/src/flow_table/mod.rs Registers the new concurrent_fuzz test module.
flow-entry/src/flow_table/concurrent_fuzz.rs Adds a new bolero + concurrency::stress concurrent fuzz/stress test for FlowTable.
concurrency/tests/quiescent_shuttle.rs Switches shuttle fuzz tests to use an explicit Runner with shared config.
concurrency/src/stress.rs Adds shuttle_config() and reuses it inside stress()’s shuttle backend.
concurrency/src/lib.rs Re-exports stress as supported API and exposes shuttle_config() under shuttle cfg.
Cargo.lock Dependency lockfile updates (crate version bumps).
Comments suppressed due to low confidence (1)

flow-entry/src/flow_table/table.rs:262

confidence: 8
tags: [docs]

`drain_stale` was removed, but `insert_common` still documents a safety argument in terms of “drain_stale’s stale condition …” (see the comment around `table.insert(...)`). That reference is now misleading and should be updated to describe the behavior without mentioning the deleted method.
/// Lookup a flow in the table.
///
/// # Panics
///
/// Panics if this thread already holds the read lock on the table.
pub fn lookup<Q>(&self, flow_key: &Q) -> Option<Arc<FlowInfo>>
</details>

Comment thread net/Cargo.toml Outdated

@sergeymatov sergeymatov 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.

For me LGTM, we need to address [bolero] as non-dev dependency

@daniel-noland
daniel-noland force-pushed the flowtable-concurrent-fuzz branch 2 times, most recently from 80f0e39 to 155ff5f Compare June 9, 2026 03:47
sergeymatov and others added 6 commits June 8, 2026 21:48
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Sergey Matov <sergey.matov@githedgehog.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>
So bolero x model-checker suites can drive the same scheduler portfolio
and 4 MiB-stack config as #[concurrency::test] instead of hand-rolling a
Runner with shuttle's defaults.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>
One source of truth for the stack size; the per-shape Runner was
silently using shuttle's ~60 KiB default.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>
A single harness covers both the thread sanitizer and the shuttle
portfolio. Normalizing at generation keeps two threads inserting, so
PCT always sees real concurrency and no shape is skipped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>
Only the fuzz harness ever called it, and it cannot run under shuttle
(DashMap::retain holds a real shard lock across a yield point). Also
switches two reshard-test asserts to assert_eq! for clippy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>
new_with_status delegates to new instead of duplicating fields; the
FlowStatus generator rejects out-of-range bytes rather than aliasing
them to Detached.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>
@daniel-noland
daniel-noland force-pushed the flowtable-concurrent-fuzz branch from 155ff5f to d291dc6 Compare June 9, 2026 03:48
@daniel-noland

Copy link
Copy Markdown
Collaborator Author

For me LGTM, we need to address [bolero] as non-dev dependency

yup, that was just me committing by accident. I only enabled it to help my IDE and never intended that for merge

@daniel-noland
daniel-noland enabled auto-merge June 9, 2026 03:49
@daniel-noland
daniel-noland disabled auto-merge June 9, 2026 03:50
Keep state machine to change NAT status for flows for
`FlowTable` scenario.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Sergey Matov <sergey.matov@githedgehog.com>
@sergeymatov
sergeymatov added this pull request to the merge queue Jun 9, 2026
Merged via the queue into main with commit 06bff1d Jun 9, 2026
35 checks passed
@sergeymatov
sergeymatov deleted the flowtable-concurrent-fuzz branch June 9, 2026 15:24
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