Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Oct 9, 2024
1 parent addd225 commit 61ab262
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 27 deletions.
33 changes: 8 additions & 25 deletions datafusion/core/tests/fuzz_cases/aggregate_fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ async fn test_basic_prim_aggr_no_group() {
.table_name("fuzz_table")
.build();

let res = fuzzer.run().await;
unwrap_and_report(res)
fuzzer.run().await
}

/// Fuzz test for `basic prim aggr(sum/sum distinct/max/min/count/avg)` + `group by single int64`
Expand Down Expand Up @@ -122,8 +121,7 @@ async fn test_basic_prim_aggr_group_by_single_int64() {
.table_name("fuzz_table")
.build();

let res = fuzzer.run().await;
unwrap_and_report(res);
fuzzer.run().await;
}

/// Fuzz test for `basic prim aggr(sum/sum distinct/max/min/count/avg)` + `group by single string`
Expand Down Expand Up @@ -161,8 +159,7 @@ async fn test_basic_prim_aggr_group_by_single_string() {
.table_name("fuzz_table")
.build();

let res = fuzzer.run().await;
unwrap_and_report(res);
fuzzer.run().await;
}

/// Fuzz test for `basic prim aggr(sum/sum distinct/max/min/count/avg)` + `group by string + int64`
Expand Down Expand Up @@ -201,8 +198,7 @@ async fn test_basic_prim_aggr_group_by_mixed_string_int64() {
.table_name("fuzz_table")
.build();

let res = fuzzer.run().await;
unwrap_and_report(res);
fuzzer.run().await;
}

/// Fuzz test for `basic string aggr(count/count distinct/min/max)` + `no group by`
Expand Down Expand Up @@ -230,8 +226,7 @@ async fn test_basic_string_aggr_no_group() {
.table_name("fuzz_table")
.build();

let res = fuzzer.run().await;
unwrap_and_report(res);
fuzzer.run().await;
}

/// Fuzz test for `basic string aggr(count/count distinct/min/max)` + `group by single int64`
Expand Down Expand Up @@ -268,8 +263,7 @@ async fn test_basic_string_aggr_group_by_single_int64() {
.table_name("fuzz_table")
.build();

let res = fuzzer.run().await;
unwrap_and_report(res);
fuzzer.run().await;
}

/// Fuzz test for `basic string aggr(count/count distinct/min/max)` + `group by single string`
Expand Down Expand Up @@ -306,8 +300,7 @@ async fn test_basic_string_aggr_group_by_single_string() {
.table_name("fuzz_table")
.build();

let res = fuzzer.run().await;
unwrap_and_report(res);
fuzzer.run().await;
}

/// Fuzz test for `basic string aggr(count/count distinct/min/max)` + `group by string + int64`
Expand Down Expand Up @@ -345,8 +338,7 @@ async fn test_basic_string_aggr_group_by_mixed_string_int64() {
.table_name("fuzz_table")
.build();

let res = fuzzer.run().await;
unwrap_and_report(res);
fuzzer.run().await;
}

// ========================================================================
Expand Down Expand Up @@ -714,12 +706,3 @@ fn extract_result_counts(results: Vec<RecordBatch>) -> HashMap<Option<String>, i
}
output
}

/// if res is an error, prints the erorr message neatly (e.g. with newlines
/// expanded) before panic'ing
fn unwrap_and_report(res: Result<()>) {
if let Err(e) = res {
println!("{e}");
panic!("Error!");
}
}
13 changes: 11 additions & 2 deletions datafusion/core/tests/fuzz_cases/aggregation_fuzzer/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,17 @@ struct QueryGroup {
}

impl AggregationFuzzer {
/// Run the fuzzer, returning error if any inconsistency found
pub async fn run(&self) -> Result<()> {
/// Run the fuzzer, printing an error and panicking if any of the tasks fail
pub async fn run(&self) {
let res = self.run_inner().await;

if let Err(e) = res {
println!("{e}");
panic!("Error!");
}
}

async fn run_inner(&self) -> Result<()> {
let mut join_set = JoinSet::new();
let mut rng = thread_rng();

Expand Down

0 comments on commit 61ab262

Please sign in to comment.