Skip to content

Commit

Permalink
fix: generate unique timestamp for inserting tests (#4472)
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu authored Jul 31, 2024
1 parent c66d309 commit 90301a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions tests-fuzz/targets/fuzz_insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use std::sync::Arc;

use common_telemetry::info;
use common_time::util::current_time_millis;
use libfuzzer_sys::arbitrary::{Arbitrary, Unstructured};
use libfuzzer_sys::fuzz_target;
use rand::{Rng, SeedableRng};
Expand All @@ -33,7 +34,7 @@ use tests_fuzz::generator::create_expr::CreateTableExprGeneratorBuilder;
use tests_fuzz::generator::insert_expr::InsertExprGeneratorBuilder;
use tests_fuzz::generator::Generator;
use tests_fuzz::ir::{
generate_random_timestamp_for_mysql, generate_random_value, replace_default,
generate_random_value, generate_unique_timestamp_for_mysql, replace_default,
sort_by_primary_keys, CreateTableExpr, InsertIntoExpr, MySQLTsColumnTypeGenerator,
};
use tests_fuzz::translator::mysql::create_expr::CreateTableExprTranslator;
Expand Down Expand Up @@ -107,7 +108,7 @@ fn generate_insert_expr<R: Rng + 'static>(
.omit_column_list(omit_column_list)
.rows(input.rows)
.value_generator(Box::new(generate_random_value))
.ts_value_generator(Box::new(generate_random_timestamp_for_mysql))
.ts_value_generator(generate_unique_timestamp_for_mysql(current_time_millis()))
.build()
.unwrap();
insert_generator.generate(rng)
Expand Down
5 changes: 3 additions & 2 deletions tests-fuzz/targets/fuzz_insert_logical_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::collections::HashMap;
use std::sync::Arc;

use common_telemetry::info;
use common_time::util::current_time_millis;
use libfuzzer_sys::arbitrary::{Arbitrary, Unstructured};
use libfuzzer_sys::fuzz_target;
use rand::{Rng, SeedableRng};
Expand All @@ -36,7 +37,7 @@ use tests_fuzz::generator::create_expr::{
use tests_fuzz::generator::insert_expr::InsertExprGeneratorBuilder;
use tests_fuzz::generator::Generator;
use tests_fuzz::ir::{
generate_random_timestamp_for_mysql, generate_random_value, replace_default,
generate_random_value, generate_unique_timestamp_for_mysql, replace_default,
sort_by_primary_keys, CreateTableExpr, InsertIntoExpr,
};
use tests_fuzz::translator::mysql::create_expr::CreateTableExprTranslator;
Expand Down Expand Up @@ -119,7 +120,7 @@ fn generate_insert_expr<R: Rng + 'static>(
.table_ctx(table_ctx)
.rows(rows)
.value_generator(Box::new(generate_random_value))
.ts_value_generator(Box::new(generate_random_timestamp_for_mysql))
.ts_value_generator(generate_unique_timestamp_for_mysql(current_time_millis()))
.build()
.unwrap();
insert_generator.generate(rng)
Expand Down

0 comments on commit 90301a6

Please sign in to comment.