Skip to content

Commit

Permalink
Test: fix CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveLauC committed Aug 5, 2024
1 parent 5d73a7c commit 445fccb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cluster_benchmark/tests/benchmark/store/test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use openraft::testing::StoreBuilder;
use openraft::testing::Suite;
use openraft::testing::log::StoreBuilder;
use openraft::testing::log::Suite;
use openraft::StorageError;

use crate::store::LogStore;
Expand Down
4 changes: 2 additions & 2 deletions examples/raft-kv-memstore/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use openraft::testing::StoreBuilder;
use openraft::testing::Suite;
use openraft::testing::log::StoreBuilder;
use openraft::testing::log::Suite;
use openraft::StorageError;

use crate::store::LogStore;
Expand Down
4 changes: 2 additions & 2 deletions openraft/src/testing/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl<Rt: AsyncRuntime> Suite<Rt> {
for idx in 0..n_senders {
let tx = Arc::clone(&tx);
// no need to wait for senders here, we wait by recv()ing
let _ = Rt::spawn(async move {
let _handle = Rt::spawn(async move {
tx.send(idx).unwrap();
});
}
Expand Down Expand Up @@ -292,7 +292,7 @@ impl<Rt: AsyncRuntime> Suite<Rt> {
let number_to_send = 1;
let (tx, rx) = Rt::Oneshot::channel::<i32>();
// no need to join the task, this test only works iff the sender task finishes its job
let _ = Rt::spawn(async move {
let _handle = Rt::spawn(async move {
tx.send(number_to_send).unwrap();
});
let number_received = rx.await.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ mod tests {
use crate::testing::runtime::Suite;

#[test]
fn test_tokio_rt() {
#[cfg(not(feature = "singlethreaded"))]
fn test_tokio_rt_not_singlethreaded() {
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(8)
.enable_all()
Expand All @@ -231,4 +232,18 @@ mod tests {

rt.block_on(Suite::<TokioRuntime>::test_all());
}

#[test]
#[cfg(feature = "singlethreaded")]
fn test_tokio_rt_singlethreaded() {
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(8)
.enable_all()
.build()
.expect("Failed building the runtime");
// `spawn_local` needs to be called called from inside of a `task::LocalSet`
let local = tokio::task::LocalSet::new();

local.block_on(&rt, Suite::<TokioRuntime>::test_all());
}
}

0 comments on commit 445fccb

Please sign in to comment.