From 6d0a979d2912e089e3d9bdaf6fa56a31bfa65831 Mon Sep 17 00:00:00 2001 From: WenyXu Date: Tue, 2 Jul 2024 02:53:29 +0000 Subject: [PATCH] chore: reduce size of fuzz test --- tests-fuzz/targets/fuzz_insert.rs | 2 +- tests-fuzz/targets/fuzz_insert_logical_table.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests-fuzz/targets/fuzz_insert.rs b/tests-fuzz/targets/fuzz_insert.rs index fdb258775187..49e8fda962ee 100644 --- a/tests-fuzz/targets/fuzz_insert.rs +++ b/tests-fuzz/targets/fuzz_insert.rs @@ -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, diff --git a/tests-fuzz/targets/fuzz_insert_logical_table.rs b/tests-fuzz/targets/fuzz_insert_logical_table.rs index de518f284ac0..a4be9bc35c85 100644 --- a/tests-fuzz/targets/fuzz_insert_logical_table.rs +++ b/tests-fuzz/targets/fuzz_insert_logical_table.rs @@ -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 { 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 }) } } @@ -204,11 +206,11 @@ async fn validate_values( } async fn insert_values( + rows: usize, ctx: &FuzzContext, rng: &mut R, logical_table_ctx: TableContextRef, ) -> Result { - 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)?; @@ -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) {