From e32c7fa66e013a417937eb52a07d12cb7545870c Mon Sep 17 00:00:00 2001 From: Bugen Zhao Date: Thu, 20 Jun 2024 12:49:59 +0800 Subject: [PATCH 1/4] fix: reuse configuration in `run_parallel` Signed-off-by: Bugen Zhao --- sqllogictest/src/connection.rs | 1 + sqllogictest/src/runner.rs | 21 ++++++++++++++++++--- sqllogictest/src/substitution.rs | 6 +++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/sqllogictest/src/connection.rs b/sqllogictest/src/connection.rs index 22bc6eb..d33a254 100644 --- a/sqllogictest/src/connection.rs +++ b/sqllogictest/src/connection.rs @@ -34,6 +34,7 @@ where } /// Connections established in a [`Runner`](crate::Runner). +#[derive(Clone)] pub(crate) struct Connections { make_conn: M, conns: HashMap, diff --git a/sqllogictest/src/runner.rs b/sqllogictest/src/runner.rs index 4cc5221..2fa9f49 100644 --- a/sqllogictest/src/runner.rs +++ b/sqllogictest/src/runner.rs @@ -649,7 +649,8 @@ impl> Runner { }; if is_background { - // Spawn a new process, but don't wait for stdout, otherwise it will block until the process exits. + // Spawn a new process, but don't wait for stdout, otherwise it will block until + // the process exits. let error: Option = match cmd.spawn() { Ok(_) => None, Err(e) => Some(Arc::new(e)), @@ -1090,6 +1091,9 @@ impl> Runner { /// accept the tasks, spawn jobs task to run slt test. the tasks are (AsyncDB, slt filename) /// pairs. + // TODO: This is not a good interface, as the `make_conn` passed to `new` is unused but we + // accept a new `conn_builder` here. May change `MakeConnection` to support specifying the + // database name in the future. pub async fn run_parallel_async( &mut self, glob: &str, @@ -1115,9 +1119,20 @@ impl> Runner { .await .expect("create db failed"); let target = hosts[idx % hosts.len()].clone(); + + let mut tester = Runner { + conn: Connections::new(move || { + conn_builder(target.clone(), db_name.clone()).map(Ok) + }), + validator: self.validator, + column_type_validator: self.column_type_validator, + substitution: self.substitution.clone(), + sort_mode: self.sort_mode, + hash_threshold: self.hash_threshold, + labels: self.labels.clone(), + }; + tasks.push(async move { - let mut tester = - Runner::new(move || conn_builder(target.clone(), db_name.clone()).map(Ok)); let filename = file.to_string_lossy().to_string(); tester.run_file_async(filename).await }) diff --git a/sqllogictest/src/substitution.rs b/sqllogictest/src/substitution.rs index 7ca27da..f350163 100644 --- a/sqllogictest/src/substitution.rs +++ b/sqllogictest/src/substitution.rs @@ -1,14 +1,14 @@ -use std::sync::OnceLock; +use std::sync::{Arc, OnceLock}; use subst::Env; use tempfile::{tempdir, TempDir}; /// Substitute environment variables and special variables like `__TEST_DIR__` in SQL. -#[derive(Default)] +#[derive(Default, Clone)] pub(crate) struct Substitution { /// The temporary directory for `__TEST_DIR__`. /// Lazily initialized and cleaned up when dropped. - test_dir: OnceLock, + test_dir: Arc>, } impl<'a> subst::VariableMap<'a> for Substitution { From 91ee11fd9e3c20f62fc54034dc36abff9c92c934 Mon Sep 17 00:00:00 2001 From: Bugen Zhao Date: Thu, 20 Jun 2024 12:56:48 +0800 Subject: [PATCH 2/4] add change log Signed-off-by: Bugen Zhao --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35253b2..3ca408a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +* fix(runner): when running in parallel, the runner will correctly inherit configuration like `sort_mode` and `labels` from the main runner. + ## [0.20.4] - 2024-06-06 * bump dependencies From c593237358353ebc5881f0a9f683d9c02951146b Mon Sep 17 00:00:00 2001 From: Bugen Zhao Date: Thu, 20 Jun 2024 15:07:26 +0800 Subject: [PATCH 3/4] address comment and bump version Signed-off-by: Bugen Zhao --- CHANGELOG.md | 2 ++ Cargo.lock | 6 +++--- Cargo.toml | 2 +- sqllogictest/src/connection.rs | 1 - 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ca408a..7298d1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## [0.20.5] - 2024-06-20 + * fix(runner): when running in parallel, the runner will correctly inherit configuration like `sort_mode` and `labels` from the main runner. ## [0.20.4] - 2024-06-06 diff --git a/Cargo.lock b/Cargo.lock index 08157c9..df2b6eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1414,7 +1414,7 @@ dependencies = [ [[package]] name = "sqllogictest" -version = "0.20.4" +version = "0.20.5" dependencies = [ "async-trait", "educe", @@ -1437,7 +1437,7 @@ dependencies = [ [[package]] name = "sqllogictest-bin" -version = "0.20.4" +version = "0.20.5" dependencies = [ "anyhow", "async-trait", @@ -1459,7 +1459,7 @@ dependencies = [ [[package]] name = "sqllogictest-engines" -version = "0.20.4" +version = "0.20.5" dependencies = [ "async-trait", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 4a6718b..5d28fb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "2" members = ["sqllogictest", "sqllogictest-bin", "sqllogictest-engines", "tests"] [workspace.package] -version = "0.20.4" +version = "0.20.5" edition = "2021" homepage = "https://github.com/risinglightdb/sqllogictest-rs" keywords = ["sql", "database", "parser", "cli"] diff --git a/sqllogictest/src/connection.rs b/sqllogictest/src/connection.rs index d33a254..22bc6eb 100644 --- a/sqllogictest/src/connection.rs +++ b/sqllogictest/src/connection.rs @@ -34,7 +34,6 @@ where } /// Connections established in a [`Runner`](crate::Runner). -#[derive(Clone)] pub(crate) struct Connections { make_conn: M, conns: HashMap, From 7e8a53547f80b705ae53854784e1f171a21d0391 Mon Sep 17 00:00:00 2001 From: Bugen Zhao Date: Thu, 20 Jun 2024 15:39:44 +0800 Subject: [PATCH 4/4] bump semver check version Signed-off-by: Bugen Zhao --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcc49ac..06cca21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: install - args: cargo-semver-checks --version ^0.27 --locked + args: cargo-semver-checks --version ^0.32 --locked - name: Check semver run: | cargo semver-checks check-release -p sqllogictest