Skip to content

Commit

Permalink
Make database clean up conditional for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Lun4m committed Jun 28, 2024
1 parent 6048f58 commit 4b73813
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "lard_tests"
version = "0.1.0"
edition.workspace = true

[features]
debug = []

[dependencies]
lard_api = { path = "../api" }
lard_ingestion = { path = "../ingestion", features = ["integration_tests"] }
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ end_to_end: _end_to_end clean
_end_to_end: setup
cargo test --test end_to_end --no-fail-fast -- --nocapture --test-threads=1

# pass TEST=... make debug_test
debug_test: setup
cargo test "$(TEST)" --features debug --no-fail-fast -- --nocapture --test-threads=1

setup:
@echo "Starting Postgres docker container..."
docker run --name lard_tests -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres
Expand Down
6 changes: 4 additions & 2 deletions integration_tests/tests/end_to_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ async fn e2e_test_wrapper<T: Future<Output = ()>>(test: T) {
));

tokio::select! {
_ = api_server => { panic!("API server task terminated first") },
_ = ingestor => { panic!("Ingestor server task terminated first") },
_ = api_server => panic!("API server task terminated first"),
_ = ingestor => panic!("Ingestor server task terminated first"),
// Clean up database even if test panics, to avoid test poisoning
test_result = AssertUnwindSafe(test).catch_unwind() => {
// For debugging a specific test, it might be useful to avoid cleaning up
#[cfg(not(feature = "debug"))]
cleanup().await;
assert!(test_result.is_ok())
}
Expand Down

0 comments on commit 4b73813

Please sign in to comment.