Repository navigation
test: Add a shared framework for reproducible fuzz tests #27048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
cbacc83
9bec86e
2b56ad9
dd6f892
e205a1b
1d48f36
620c25e
00019d3
a35deb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership | ||
| # SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements | ||
|
|
||
| # A private crate providing a single entry point for all fuzz tests. | ||
|
alamb marked this conversation as resolved.
Resolved
|
||
|
|
||
| [package] | ||
| name = "datafusion-fuzz" | ||
| version = "0.1.0" | ||
| edition = { workspace = true } | ||
| # Ensure this crate is private | ||
| publish = false | ||
| autotests = false | ||
|
|
||
| [lints] | ||
| workspace = true | ||
|
|
||
| [features] | ||
| extended_tests = [] | ||
|
|
||
| [dev-dependencies] | ||
| arrow = { workspace = true } | ||
| bytes = { workspace = true } | ||
| datafusion-common = { workspace = true } | ||
| datafusion-execution = { workspace = true } | ||
| datafusion-physical-plan = { workspace = true } | ||
| futures = { workspace = true } | ||
| parking_lot = { workspace = true } | ||
| rand = { workspace = true } | ||
| test-utils = { path = "../../test-utils" } | ||
| tokio = { workspace = true, features = ["rt-multi-thread", "time"] } | ||
|
|
||
| [[test]] | ||
| name = "fuzz" | ||
| path = "tests/fuzz.rs" | ||
| required-features = ["extended_tests"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership | ||
| // SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements | ||
|
|
||
| //! One integration entrypoint for DataFusion's registered fuzz suites. | ||
|
|
||
| use std::future::Future; | ||
| use std::pin::Pin; | ||
|
|
||
| use datafusion_common::Result; | ||
| use test_utils::fuzz::{FuzzTest, RunConfig, run}; | ||
|
|
||
| mod suites; | ||
|
|
||
| /// The single registration point for project-wide fuzz campaigns. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is a fuzz campaign? I am not familar with the campaign terminology
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renamed it to |
||
| /// | ||
| /// Migration of the remaining fuzz tests is tracked in [#27082]. | ||
| /// | ||
| /// [#27082]: https://github.com/apache/datafusion/issues/27082 | ||
| #[tokio::test(flavor = "multi_thread")] | ||
| async fn fuzz_tests() -> Result<()> { | ||
| let spill_pool = suites::spill_pool::SpillPoolFuzzer; | ||
| let suites = [Suite::new( | ||
| &spill_pool, | ||
| RunConfig { | ||
| run_seed: Some(0), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the existing fuzz config, probably we can use rotating seed (timestamp), and time limit instead of 1000 cases. |
||
| max_cases: Some(1000), | ||
| time_limit: None, | ||
| cases_per_dataset: 1000, | ||
| }, | ||
| )]; | ||
| run_suites(suites).await | ||
| } | ||
|
|
||
| async fn run_suites<'a>(suites: impl IntoIterator<Item = Suite<'a>>) -> Result<()> { | ||
| for suite in suites { | ||
| eprintln!("Running fuzz suite: {}", suite.name); | ||
| suite.run.await?; | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| /// Wrapper for one fuzzing test suite | ||
| struct Suite<'a> { | ||
| name: &'a str, | ||
| /// Run the test suite. Report an error on failure or execution statistics on success. | ||
| run: Pin<Box<dyn Future<Output = Result<()>> + 'a>>, | ||
| } | ||
|
|
||
| impl<'a> Suite<'a> { | ||
| fn new<T: FuzzTest>(test: &'a T, config: RunConfig) -> Self { | ||
| Self { | ||
| name: test.name(), | ||
| run: Box::pin(async move { | ||
| let stats = run(test, config).await?; | ||
| eprintln!( | ||
| "Fuzz suite {}: {} cases, {} datasets, {:?}", | ||
| test.name(), | ||
| stats.cases_passed, | ||
| stats.datasets_prepared, | ||
| stats.elapsed | ||
| ); | ||
| Ok(()) | ||
| }), | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership | ||
| // SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements | ||
|
|
||
| //! Implementation for fuzz test cases. | ||
|
|
||
| pub(crate) mod spill_pool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please file a ticket that explains the migration plan and has a checklist of tests to run and link it here? So we have the context in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, done in e205a1b