feat: add preserve arg to sqlness runner (#3724)

* feat: add preserve arg to sqlness runner

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* replace tempdir with tempfile

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2024-04-22 17:21:37 +08:00
committed by GitHub
parent 54432df92f
commit d0b2a11f2b
4 changed files with 21 additions and 8 deletions

View File

@@ -184,13 +184,13 @@ jobs:
- name: Unzip binaries
run: tar -xvf ./bins.tar.gz
- name: Run sqlness
run: RUST_BACKTRACE=1 ./bins/sqlness-runner -c ./tests/cases --bins-dir ./bins
run: RUST_BACKTRACE=1 ./bins/sqlness-runner -c ./tests/cases --bins-dir ./bins --preserve-state
- name: Upload sqlness logs
if: always()
uses: actions/upload-artifact@v4
with:
name: sqlness-logs
path: /tmp/greptime-*.log
path: /tmp/sqlness-*
retention-days: 3
sqlness-kafka-wal:
@@ -214,13 +214,13 @@ jobs:
working-directory: tests-integration/fixtures/kafka
run: docker compose -f docker-compose-standalone.yml up -d --wait
- name: Run sqlness
run: RUST_BACKTRACE=1 ./bins/sqlness-runner -w kafka -k 127.0.0.1:9092 -c ./tests/cases --bins-dir ./bins
run: RUST_BACKTRACE=1 ./bins/sqlness-runner -w kafka -k 127.0.0.1:9092 -c ./tests/cases --bins-dir ./bins --preserve-state
- name: Upload sqlness logs
if: always()
uses: actions/upload-artifact@v4
with:
name: sqlness-logs-with-kafka-wal
path: /tmp/greptime-*.log
path: /tmp/sqlness-*
retention-days: 3
fmt:

1
Cargo.lock generated
View File

@@ -9539,6 +9539,7 @@ dependencies = [
"serde",
"serde_json",
"sqlness",
"tempfile",
"tinytemplate",
"tokio",
]

View File

@@ -18,5 +18,6 @@ common-time.workspace = true
serde.workspace = true
serde_json.workspace = true
sqlness = { version = "0.5" }
tempfile.workspace = true
tinytemplate = "1.2"
tokio.workspace = true

View File

@@ -67,16 +67,22 @@ struct Args {
/// If not set, sqlness will build GreptimeDB on the fly.
#[clap(long)]
bins_dir: Option<PathBuf>,
/// Preserve persistent state in the temporary directory.
/// This may affect future test runs.
#[clap(long)]
preserve_state: bool,
}
#[tokio::main]
async fn main() {
let args = Args::parse();
#[cfg(windows)]
let data_home = std::env::temp_dir();
#[cfg(not(windows))]
let data_home = std::path::PathBuf::from("/tmp");
let temp_dir = tempfile::Builder::new()
.prefix("sqlness")
.tempdir()
.unwrap();
let data_home = temp_dir.path().to_path_buf();
let config = ConfigBuilder::default()
.case_dir(util::get_case_dir(args.case_dir))
@@ -104,4 +110,9 @@ async fn main() {
Env::new(data_home, args.server_addr, wal, args.bins_dir),
);
runner.run().await.unwrap();
// skip clean up and exit
if args.preserve_state {
println!("Preserving state in {:?}", temp_dir.into_path());
}
}