From 4b73813bc4025b9cf8a4b6a2fa570c86ecb4ab57 Mon Sep 17 00:00:00 2001 From: Manuel Carrer Date: Fri, 28 Jun 2024 15:04:09 +0200 Subject: [PATCH] Make database clean up conditional for debugging --- integration_tests/Cargo.toml | 3 +++ integration_tests/Makefile | 4 ++++ integration_tests/tests/end_to_end.rs | 6 ++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml index 699ebcbc..6c45d033 100644 --- a/integration_tests/Cargo.toml +++ b/integration_tests/Cargo.toml @@ -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"] } diff --git a/integration_tests/Makefile b/integration_tests/Makefile index 4b6d8a30..a03d5b42 100644 --- a/integration_tests/Makefile +++ b/integration_tests/Makefile @@ -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 diff --git a/integration_tests/tests/end_to_end.rs b/integration_tests/tests/end_to_end.rs index 0a6d74ba..cafd7641 100644 --- a/integration_tests/tests/end_to_end.rs +++ b/integration_tests/tests/end_to_end.rs @@ -204,10 +204,12 @@ async fn e2e_test_wrapper>(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()) }