Skip to content

Commit

Permalink
feat: add preserve arg to sqlness runner (#3724)
Browse files Browse the repository at this point in the history
* feat: add preserve arg to sqlness runner

Signed-off-by: Ruihang Xia <[email protected]>

* replace tempdir with tempfile

Signed-off-by: Ruihang Xia <[email protected]>

---------

Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia authored Apr 22, 2024
1 parent 54432df commit d0b2a11
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 15 additions & 4 deletions tests/runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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());
}
}

0 comments on commit d0b2a11

Please sign in to comment.