Skip to content

Commit

Permalink
chore: reduce size of fuzz test
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu committed Jul 2, 2024
1 parent e531326 commit 6d0a979
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests-fuzz/targets/fuzz_insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Arbitrary<'_> for FuzzInput {
let seed = u.int_in_range(u64::MIN..=u64::MAX)?;
let mut rng = ChaChaRng::seed_from_u64(seed);
let columns = rng.gen_range(2..30);
let rows = rng.gen_range(1..4096);
let rows = rng.gen_range(1..1024);
Ok(FuzzInput {
columns,
rows,
Expand Down
11 changes: 7 additions & 4 deletions tests-fuzz/targets/fuzz_insert_logical_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ impl FuzzContext {
struct FuzzInput {
seed: u64,
tables: usize,
rows: usize,
}

impl Arbitrary<'_> for FuzzInput {
fn arbitrary(u: &mut Unstructured<'_>) -> arbitrary::Result<Self> {
let seed = u.int_in_range(u64::MIN..=u64::MAX)?;
let mut rng = ChaChaRng::seed_from_u64(seed);
let tables = rng.gen_range(1..256);
Ok(FuzzInput { tables, seed })
let tables = rng.gen_range(1..32);
let rows = rng.gen_range(1..1024);
Ok(FuzzInput { tables, seed, rows })
}
}

Expand Down Expand Up @@ -204,11 +206,11 @@ async fn validate_values(
}

async fn insert_values<R: Rng + 'static>(
rows: usize,
ctx: &FuzzContext,
rng: &mut R,
logical_table_ctx: TableContextRef,
) -> Result<InsertIntoExpr> {
let rows = rng.gen_range(1..2048);
let insert_expr = generate_insert_expr(rows, rng, logical_table_ctx.clone())?;
let translator = InsertIntoExprTranslator;
let sql = translator.translate(&insert_expr)?;
Expand Down Expand Up @@ -257,7 +259,8 @@ async fn execute_insert(ctx: FuzzContext, input: FuzzInput) -> Result<()> {
info!("Create logical table: {sql}, result: {result:?}");
let logical_table_ctx = Arc::new(TableContext::from(&create_logical_table_expr));

let insert_expr = insert_values(&ctx, &mut rng, logical_table_ctx.clone()).await?;
let insert_expr =
insert_values(input.rows, &ctx, &mut rng, logical_table_ctx.clone()).await?;
validate_values(&ctx, logical_table_ctx.clone(), &insert_expr).await?;
tables.insert(logical_table_ctx.name.clone(), logical_table_ctx.clone());
if rng.gen_bool(0.1) {
Expand Down

0 comments on commit 6d0a979

Please sign in to comment.