diff --git a/tests-fuzz/targets/unstable/fuzz_create_table_standalone.rs b/tests-fuzz/targets/unstable/fuzz_create_table_standalone.rs index ad0a64f7d28c..46123fe772d0 100644 --- a/tests-fuzz/targets/unstable/fuzz_create_table_standalone.rs +++ b/tests-fuzz/targets/unstable/fuzz_create_table_standalone.rs @@ -94,11 +94,11 @@ fn generate_create_table_expr(rng: &mut R) -> CreateTableExpr create_table_generator.generate(rng).unwrap() } -async fn connect_mysql(addr: &str) -> Pool { +async fn connect_mysql(addr: &str, database: &str) -> Pool { loop { match MySqlPoolOptions::new() .acquire_timeout(Duration::from_secs(30)) - .connect(&format!("mysql://{addr}/public")) + .connect(&format!("mysql://{addr}/{database}")) .await { Ok(mysql) => return mysql, @@ -114,13 +114,17 @@ async fn execute_unstable_create_table( rx: watch::Receiver, input: FuzzInput, ) -> Result<()> { + let mysql_public = connect_mysql(DEFAULT_MYSQL_URL, "public").await; + let mysql = sqlx::query("CREATE DATABASE fuzz_tests") + .execute(&mysql_public) + .await + .expect("Failed to create database 'fuzz_tests'"); + // Starts the unstable process. let moved_unstable_process_controller = unstable_process_controller.clone(); let handler = tokio::spawn(async move { moved_unstable_process_controller.start().await }); let mut rng = ChaChaRng::seed_from_u64(input.seed); - let mysql = connect_mysql(DEFAULT_MYSQL_URL).await; let ctx = FuzzContext { greptime: mysql }; - let mut table_states = HashMap::new(); for _ in 0..input.num { @@ -163,13 +167,13 @@ async fn execute_unstable_create_table( } loop { - let sql = "DROP DATABASE IF EXISTS public"; - match sqlx::query(sql).execute(&ctx.greptime).await { + let sql = "DROP DATABASE IF EXISTS fuzz_tests"; + match sqlx::query(sql).execute(&mysql_public).await { Ok(result) => { - info!("Drop table: {}, result: {result:?}", sql); + info!("Drop database: {}, result: {result:?}", sql); break; } - Err(err) => warn!("Failed to drop table: {}, error: {err}", sql), + Err(err) => warn!("Failed to drop database: {}, error: {err}", sql), } } // Cleans up