sfackler/r2d2

[Bug] CI test failure on arm

werdahias opened this issue · 4 comments

Hi,
I packaged r2d2 for debian recently. The automated CI test fail on arm64 and armel:

running 18 tests
test test::test_is_send_sync ... ok
test test::test_acquire_release ... ok
test test::test_drop_on_broken ... ok
test test::test_issue_2_unlocked_during_is_valid ... ok
test test::conns_drop_on_pool_drop ... ok
test test::test_max_size_ok ... ok
test test::extensions ... ok
test test::try_get ... ok
test test::events ... ok
test test::get_timeout ... ok
test test::test_connection_customizer ... ok
test test::test_get_global_timeout ... ok
test test::test_initialization_failure ... ok
test test::test_lazy_initialization_failure ... ok
test test::idle_timeout_partial_use ... ok
test test::min_idle ... ok
test test::test_idle_timeout ... ok
test test::test_max_lifetime ... FAILED

failures:

---- test::test_max_lifetime stdout ----
thread 'test::test_max_lifetime' panicked at 'assertion failed: `(left == right)`
  left: `4`,
 right: `1`', src/test.rs:490:5
stack backtrace:
   0: rust_begin_unwind
             at /usr/src/rustc-1.63.0/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:142:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
             at /usr/src/rustc-1.63.0/library/core/src/panicking.rs:181:5
   4: r2d2::test::test_max_lifetime
             at ./src/test.rs:490:5
   5: r2d2::test::test_max_lifetime::{{closure}}
             at ./src/test.rs:447:1
   6: core::ops::function::FnOnce::call_once
             at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
   7: core::ops::function::FnOnce::call_once
             at /usr/src/rustc-1.63.0/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    test::test_max_lifetime

test result: FAILED. 17 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.07s

For now I can skip them with a #[cfg(not(target_arch = "arm"))]

What kind of hardware is your CI running? I cannot reproduce this failure on an M1 macbook (either in macOS or Linux via Docker).

The CI is running on this debian kernel: Linux 5.10.0-20-arm64 #1 SMP Debian 5.10.158-2 (2022-12-13). I also noticed this test prevents r2d2 from being built on arm64, armel and i386 (x86 arch). I patched it for now so the test gets skipped on those arches.

This is likely a timing issue: the patch below addressed all that expect for the i386 arch.

Index: r2d2/src/test.rs
===================================================================
--- r2d2.orig/src/test.rs
+++ r2d2/src/test.rs
@@ -486,10 +486,10 @@ fn test_max_lifetime() {
         .build(Handler(AtomicIsize::new(5)))
         .unwrap();
     let conn = pool.get().unwrap();
-    thread::sleep(Duration::from_secs(2));
+    thread::sleep(Duration::from_secs(3));
     assert_eq!(4, DROPPED.load(Ordering::SeqCst));
     drop(conn);
-    thread::sleep(Duration::from_secs(2));
+    thread::sleep(Duration::from_secs(3));
     assert_eq!(5, DROPPED.load(Ordering::SeqCst));
     assert!(pool.get().is_err());
 }

Maybe you can find a more elegant solution.