test: make async tests use only 1 thread

Signed-off-by: ljedrz <ljedrz@gmail.com>
This commit is contained in:
ljedrz 2020-08-13 13:05:55 +02:00
parent 4001e01a44
commit c930f651fd
21 changed files with 57 additions and 57 deletions

View File

@ -175,7 +175,7 @@ mod tests {
routes(&ipfs, shutdown_tx)
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn not_found_as_plaintext() {
let routes = testing_routes().await;
let resp = warp::test::request()
@ -189,7 +189,7 @@ mod tests {
assert_eq!(resp.body(), "404 page not found");
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn invalid_peer_id_as_messageresponse() {
let routes = testing_routes().await;
let resp = warp::test::request()

View File

@ -536,7 +536,7 @@ mod tests {
})
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn url_hacked_args() {
let response = request()
.path("/pubsub/pub?arg=some_channel&arg=foobar")
@ -546,7 +546,7 @@ mod tests {
assert_eq!(body, r#"{"message":"foobar","topic":"some_channel"}"#);
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn message_in_body() {
let response = request()
.path("/pubsub/pub?arg=some_channel")

View File

@ -626,7 +626,7 @@ mod tests {
use std::collections::HashSet;
use std::convert::TryFrom;
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_inner_local() {
let filter = local(&*preloaded_testing_ipfs().await);
@ -673,7 +673,7 @@ mod tests {
assert!(diff.is_empty(), "{:?}", diff);
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn all_refs_from_root() {
let Node { ipfs, bg_task: _bt } = preloaded_testing_ipfs().await;
@ -714,7 +714,7 @@ mod tests {
assert_edges(&expected, all_edges.as_slice());
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn all_unique_refs_from_root() {
let Node { ipfs, bg_task: _bt } = preloaded_testing_ipfs().await;
@ -757,7 +757,7 @@ mod tests {
assert!(diff.is_empty(), "{:?}", diff);
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn refs_with_path() {
let ipfs = preloaded_testing_ipfs().await;

View File

@ -316,7 +316,7 @@ mod tests {
}
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn very_long_file_and_symlink_names() {
let ipfs = Node::new("test_node").await;
@ -372,7 +372,7 @@ mod tests {
assert_eq!(found, expected);
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn get_multiblock_file() {
let ipfs = Node::new("test_node").await;

View File

@ -377,7 +377,7 @@ impl<D: fmt::Display> serde::Serialize for Quoted<D> {
mod tests {
use crate::v0::root_files::add;
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn add_single_block_file() {
let ipfs = tokio_ipfs().await;

View File

@ -95,7 +95,7 @@ mod tests {
use super::*;
use crate::{make_ipld, Node};
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_resolve_root_cid() {
let Node { ipfs, bg_task: _bt } = Node::new("test_node").await;
let dag = IpldDag::new(ipfs);
@ -105,7 +105,7 @@ mod tests {
assert_eq!(res, data);
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_resolve_array_elem() {
let Node { ipfs, bg_task: _bt } = Node::new("test_node").await;
let dag = IpldDag::new(ipfs);
@ -118,7 +118,7 @@ mod tests {
assert_eq!(res, make_ipld!(2));
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_resolve_nested_array_elem() {
let Node { ipfs, bg_task: _bt } = Node::new("test_node").await;
let dag = IpldDag::new(ipfs);
@ -131,7 +131,7 @@ mod tests {
assert_eq!(res, make_ipld!(2));
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_resolve_object_elem() {
let Node { ipfs, bg_task: _bt } = Node::new("test_node").await;
let dag = IpldDag::new(ipfs);
@ -146,7 +146,7 @@ mod tests {
assert_eq!(res, make_ipld!(false));
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_resolve_cid_elem() {
let Node { ipfs, bg_task: _bt } = Node::new("test_node").await;
let dag = IpldDag::new(ipfs);

View File

@ -79,13 +79,13 @@ pub async fn resolve(domain: &str) -> Result<IpfsPath, Error> {
mod tests {
use super::*;
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_resolve1() {
let res = resolve("ipfs.io").await.unwrap().to_string();
assert_eq!(res, "/ipns/website.ipfs.io");
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_resolve2() {
let res = resolve("website.ipfs.io").await.unwrap().to_string();
assert_eq!(

View File

@ -1260,7 +1260,7 @@ mod tests {
));
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_put_and_get_block() {
let ipfs = Node::new("test_node").await;
@ -1273,7 +1273,7 @@ mod tests {
assert_eq!(block, new_block);
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_put_and_get_dag() {
let ipfs = Node::new("test_node").await;
@ -1283,7 +1283,7 @@ mod tests {
assert_eq!(data, new_data);
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_pin_and_unpin() {
let ipfs = Node::new("test_node").await;

View File

@ -339,7 +339,7 @@ mod tests {
));
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn swarm_api() {
let (peer1_id, trans) = mk_transport();
let mut swarm1 = Swarm::new(trans, SwarmApi::default(), peer1_id);

View File

@ -147,7 +147,7 @@ mod tests {
use multihash::Sha2_256;
use std::env::temp_dir;
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_fs_blockstore() {
let mut tmp = temp_dir();
tmp.push("blockstore1");
@ -185,7 +185,7 @@ mod tests {
std::fs::remove_dir_all(tmp).ok();
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_fs_blockstore_open() {
let mut tmp = temp_dir();
tmp.push("blockstore2");
@ -210,7 +210,7 @@ mod tests {
std::fs::remove_dir_all(&tmp).ok();
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_fs_blockstore_list() {
let mut tmp = temp_dir();
tmp.push("blockstore_list");

View File

@ -154,7 +154,7 @@ mod tests {
use multihash::Sha2_256;
use std::env::temp_dir;
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_mem_blockstore() {
let tmp = temp_dir();
let store = MemBlockStore::new(tmp);
@ -187,7 +187,7 @@ mod tests {
assert_eq!(get.await.unwrap(), None);
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_mem_blockstore_list() {
let tmp = temp_dir();
let mem_store = MemBlockStore::new(tmp);
@ -210,7 +210,7 @@ mod tests {
}
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_mem_datastore() {
let tmp = temp_dir();
let store = MemDataStore::new(tmp);

View File

@ -370,7 +370,7 @@ pub(crate) mod tests {
Repo::new(options)
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn test_repo() {
let (repo, _) = create_mock_repo();
repo.init().await.unwrap();

View File

@ -443,7 +443,7 @@ mod tests {
}
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn subscription_basics() {
let registry = SubscriptionRegistry::<u32, ()>::default();
let s1 = registry.create_subscription(0.into(), None);
@ -455,7 +455,7 @@ mod tests {
assert_eq!(s3.await.unwrap(), 10);
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn subscription_cancelled_on_dropping_registry() {
let registry = SubscriptionRegistry::<u32, ()>::default();
let s1 = registry.create_subscription(0.into(), None);
@ -463,7 +463,7 @@ mod tests {
assert_eq!(s1.await, Err(SubscriptionErr::Cancelled));
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn subscription_cancelled_on_shutdown() {
let registry = SubscriptionRegistry::<u32, ()>::default();
let s1 = registry.create_subscription(0.into(), None);
@ -471,7 +471,7 @@ mod tests {
assert_eq!(s1.await, Err(SubscriptionErr::Cancelled));
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn new_subscriptions_cancelled_after_shutdown() {
let registry = SubscriptionRegistry::<u32, ()>::default();
registry.shutdown();
@ -479,7 +479,7 @@ mod tests {
assert_eq!(s1.await, Err(SubscriptionErr::Cancelled));
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn dropping_subscription_future_after_registering() {
use std::time::Duration;
use tokio::time::timeout;

View File

@ -6,7 +6,7 @@ async fn wait(millis: u64) {
}
// Ensure that the Bitswap object doesn't leak.
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn check_bitswap_cleanups() {
// create a few nodes
let node_a = Node::new("a").await;

View File

@ -12,7 +12,7 @@ fn filter(i: usize) -> bool {
// testing the bitswap protocol (though it would be advised to uncomment
// the tracing_subscriber for stress-testing purposes)
#[ignore]
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn bitswap_stress_test() {
tracing_subscriber::fmt::init();

View File

@ -3,7 +3,7 @@ use std::time::Duration;
use tokio::time::timeout;
// Make sure two instances of ipfs can be connected by `Multiaddr`.
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn connect_two_nodes_by_addr() {
let node_a = Node::new("a").await;
let node_b = Node::new("b").await;
@ -22,7 +22,7 @@ async fn connect_two_nodes_by_addr() {
// order to connect by PeerId) already performs a dial to the
// given peer within Pubsub::add_node_to_partial_view it calls
#[ignore]
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn connect_two_nodes_by_peer_id() {
let node_a = Node::new("a").await;
let node_b = Node::new("b").await;
@ -40,7 +40,7 @@ async fn connect_two_nodes_by_peer_id() {
}
// Make sure two instances of ipfs can be connected with a multiaddr+peer combo.
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn connect_two_nodes_by_addr_and_peer() {
let node_a = Node::new("a").await;
let node_b = Node::new("b").await;
@ -59,7 +59,7 @@ async fn connect_two_nodes_by_addr_and_peer() {
}
// Ensure that duplicate connection attempts don't cause hangs.
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn connect_duplicate_multiaddr() {
let node_a = Node::new("a").await;
let node_b = Node::new("b").await;
@ -77,7 +77,7 @@ async fn connect_duplicate_multiaddr() {
}
// Ensure that duplicate connection attempts don't cause hangs.
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn connect_duplicate_peer_id() {
let node_a = Node::new("a").await;
let node_b = Node::new("b").await;
@ -98,7 +98,7 @@ async fn connect_duplicate_peer_id() {
// More complicated one to the above; first node will have two listening addresses and the second
// one should dial both of the addresses, resulting in two connections.
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn connect_two_nodes_with_two_connections_doesnt_panic() {
let node_a = Node::new("a").await;
let node_b = Node::new("b").await;

View File

@ -4,7 +4,7 @@ use multihash::Sha2_256;
use std::time::Duration;
use tokio::time::timeout;
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn exchange_block() {
tracing_subscriber::fmt::init();

View File

@ -4,7 +4,7 @@ use libp2p::{Multiaddr, PeerId};
use std::time::Duration;
use tokio::time::timeout;
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn kademlia_local_peer_discovery() {
const BOOTSTRAPPER_COUNT: usize = 20;
@ -54,7 +54,7 @@ async fn kademlia_local_peer_discovery() {
}
#[ignore = "targets an actual bootstrapper, so random failures can happen"]
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn kademlia_popular_content_discovery() {
let (bootstrapper_id, bootstrapper_addr): (PeerId, Multiaddr) = (
"QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"

View File

@ -1,4 +1,4 @@
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn multiple_consecutive_ephemeral_listening_addresses() {
let node = ipfs::Node::new("test_node").await;
@ -12,7 +12,7 @@ async fn multiple_consecutive_ephemeral_listening_addresses() {
assert_ne!(first, second);
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn multiple_concurrent_ephemeral_listening_addresses_on_same_ip() {
let node = ipfs::Node::new("test_node").await;
@ -41,7 +41,7 @@ async fn multiple_concurrent_ephemeral_listening_addresses_on_same_ip() {
);
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
#[cfg(not(target_os = "macos"))]
async fn multiple_concurrent_ephemeral_listening_addresses_on_different_ip() {
let node = ipfs::Node::new("test_node").await;
@ -59,7 +59,7 @@ async fn multiple_concurrent_ephemeral_listening_addresses_on_different_ip() {
second.unwrap();
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn adding_unspecified_addr_resolves_with_first() {
let node = ipfs::Node::new("test_node").await;
// there is no test in trying to match this with others as ... that would be quite
@ -69,7 +69,7 @@ async fn adding_unspecified_addr_resolves_with_first() {
.unwrap();
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn listening_for_multiple_unspecified_addresses() {
let node = ipfs::Node::new("test_node").await;
// there is no test in trying to match this with others as ... that would be quite
@ -93,7 +93,7 @@ async fn listening_for_multiple_unspecified_addresses() {
);
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn remove_listening_address() {
let node = ipfs::Node::new("test_node").await;

View File

@ -4,14 +4,14 @@ use ipfs::{Node, PeerId};
use std::time::Duration;
use tokio::time::timeout;
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn subscribe_only_once() {
let a = Node::new("test_node").await;
let _stream = a.pubsub_subscribe("some_topic".into()).await.unwrap();
a.pubsub_subscribe("some_topic".into()).await.unwrap_err();
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn resubscribe_after_unsubscribe() {
let a = Node::new("test_node").await;
@ -23,7 +23,7 @@ async fn resubscribe_after_unsubscribe() {
drop(a.pubsub_subscribe("topic".into()).await.unwrap());
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn unsubscribe_via_drop() {
let a = Node::new("test_node").await;
@ -36,7 +36,7 @@ async fn unsubscribe_via_drop() {
assert_eq!(a.pubsub_subscribed().await.unwrap(), empty);
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn can_publish_without_subscribing() {
let a = Node::new("test_node").await;
a.pubsub_publish("topic".into(), b"foobar".to_vec())
@ -44,7 +44,7 @@ async fn can_publish_without_subscribing() {
.unwrap()
}
#[tokio::test]
#[tokio::test(max_threads = 1)]
#[allow(clippy::mutable_key_type)] // clippy doesn't like Vec inside HashSet
async fn publish_between_two_nodes() {
use futures::stream::StreamExt;

View File

@ -47,7 +47,7 @@ async fn check_cid_subscriptions(ipfs: &Node, cid: &Cid, expected_count: usize)
}
/// Check if canceling a Cid affects the wantlist.
#[tokio::test]
#[tokio::test(max_threads = 1)]
async fn wantlist_cancellation() {
tracing_subscriber::fmt::init();