11//! Integration tests for Ledger storage backend in Control
22//!
3- //! These tests require a running Ledger server. They are skipped unless the
4- //! `RUN_LEDGER_INTEGRATION_TESTS` environment variable is set .
3+ //! These tests require a running Ledger server. They are gated behind the
4+ //! `integration` feature flag and excluded from default `cargo nextest run` .
55//!
6- //! Run with: cargo test --test ledger_integration_tests
7- //!
8- //! Or using Docker Compose:
6+ //! Run with:
97//! ```bash
10- //! cd docker/ledger-integration-tests && ./run-tests.sh
8+ //! cargo nextest run -p inferadb-control-storage --features integration --test ledger_integration_tests
119//! ```
1210
1311#![ allow( clippy:: unwrap_used, clippy:: expect_used, clippy:: panic) ]
@@ -45,10 +43,6 @@ static VAULT_COUNTER: LazyLock<AtomicU64> = LazyLock::new(|| {
4543/// Organization slug created once per process via the Ledger admin API.
4644static TEST_ORG : OnceCell < OrganizationSlug > = OnceCell :: const_new ( ) ;
4745
48- fn should_run ( ) -> bool {
49- env:: var ( "RUN_LEDGER_INTEGRATION_TESTS" ) . is_ok ( )
50- }
51-
5246fn ledger_endpoint ( ) -> String {
5347 env:: var ( "LEDGER_ENDPOINT" ) . unwrap_or_else ( |_| "http://localhost:50051" . to_string ( ) )
5448}
@@ -99,11 +93,6 @@ async fn create_ledger_backend() -> LedgerBackend {
9993
10094#[ tokio:: test]
10195async fn test_ledger_basic_operations ( ) {
102- if !should_run ( ) {
103- eprintln ! ( "Skipping Ledger integration test (RUN_LEDGER_INTEGRATION_TESTS not set)" ) ;
104- return ;
105- }
106-
10796 let backend = create_ledger_backend ( ) . await ;
10897
10998 // Test set and get
@@ -126,11 +115,6 @@ async fn test_ledger_basic_operations() {
126115
127116#[ tokio:: test]
128117async fn test_ledger_range_operations ( ) {
129- if !should_run ( ) {
130- eprintln ! ( "Skipping Ledger integration test (RUN_LEDGER_INTEGRATION_TESTS not set)" ) ;
131- return ;
132- }
133-
134118 let backend = create_ledger_backend ( ) . await ;
135119
136120 // Insert test data
@@ -169,11 +153,6 @@ async fn test_ledger_range_operations() {
169153
170154#[ tokio:: test]
171155async fn test_ledger_ttl_expiration ( ) {
172- if !should_run ( ) {
173- eprintln ! ( "Skipping Ledger integration test (RUN_LEDGER_INTEGRATION_TESTS not set)" ) ;
174- return ;
175- }
176-
177156 let backend = create_ledger_backend ( ) . await ;
178157
179158 // Set a key with 2 second TTL
@@ -198,11 +177,6 @@ async fn test_ledger_ttl_expiration() {
198177
199178#[ tokio:: test]
200179async fn test_ledger_transaction ( ) {
201- if !should_run ( ) {
202- eprintln ! ( "Skipping Ledger integration test (RUN_LEDGER_INTEGRATION_TESTS not set)" ) ;
203- return ;
204- }
205-
206180 let backend = create_ledger_backend ( ) . await ;
207181
208182 // Start a transaction
@@ -226,11 +200,6 @@ async fn test_ledger_transaction() {
226200
227201#[ tokio:: test]
228202async fn test_ledger_transaction_delete ( ) {
229- if !should_run ( ) {
230- eprintln ! ( "Skipping Ledger integration test (RUN_LEDGER_INTEGRATION_TESTS not set)" ) ;
231- return ;
232- }
233-
234203 let backend = create_ledger_backend ( ) . await ;
235204
236205 // Pre-populate
@@ -251,11 +220,6 @@ async fn test_ledger_transaction_delete() {
251220
252221#[ tokio:: test]
253222async fn test_ledger_health_check ( ) {
254- if !should_run ( ) {
255- eprintln ! ( "Skipping Ledger integration test (RUN_LEDGER_INTEGRATION_TESTS not set)" ) ;
256- return ;
257- }
258-
259223 let backend = create_ledger_backend ( ) . await ;
260224
261225 let result =
@@ -269,11 +233,6 @@ async fn test_ledger_health_check() {
269233
270234#[ tokio:: test]
271235async fn test_ledger_concurrent_writes ( ) {
272- if !should_run ( ) {
273- eprintln ! ( "Skipping Ledger integration test (RUN_LEDGER_INTEGRATION_TESTS not set)" ) ;
274- return ;
275- }
276-
277236 // Spawn concurrent writers (each gets its own backend with unique vault)
278237 let org = ensure_organization ( ) . await ;
279238 let mut handles = Vec :: new ( ) ;
@@ -313,11 +272,6 @@ async fn test_ledger_concurrent_writes() {
313272
314273#[ tokio:: test]
315274async fn test_ledger_vault_isolation ( ) {
316- if !should_run ( ) {
317- eprintln ! ( "Skipping Ledger integration test (RUN_LEDGER_INTEGRATION_TESTS not set)" ) ;
318- return ;
319- }
320-
321275 let vault_a = unique_vault ( ) ;
322276 let vault_b = unique_vault ( ) ;
323277 let org = ensure_organization ( ) . await ;
@@ -375,11 +329,6 @@ async fn test_ledger_vault_isolation() {
375329
376330#[ tokio:: test]
377331async fn test_ledger_reconnection_after_idle ( ) {
378- if !should_run ( ) {
379- eprintln ! ( "Skipping Ledger integration test (RUN_LEDGER_INTEGRATION_TESTS not set)" ) ;
380- return ;
381- }
382-
383332 let backend = create_ledger_backend ( ) . await ;
384333
385334 // First operation
0 commit comments