From c0f80db43516effd05a220b8e9a28ddae358247a Mon Sep 17 00:00:00 2001 From: librelois <elois@ifee.fr> Date: Fri, 31 Jan 2020 22:21:57 +0100 Subject: [PATCH] [tests] ws2p: TI must be run in serial --- Cargo.lock | 1 + lib/modules/ws2p/ws2p/Cargo.toml | 1 + lib/modules/ws2p/ws2p/tests/connection_negociation.rs | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 0ccece6f..a18f5f9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1239,6 +1239,7 @@ dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "once_cell 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/lib/modules/ws2p/ws2p/Cargo.toml b/lib/modules/ws2p/ws2p/Cargo.toml index f692491c..b7084cd7 100644 --- a/lib/modules/ws2p/ws2p/Cargo.toml +++ b/lib/modules/ws2p/ws2p/Cargo.toml @@ -35,6 +35,7 @@ ws = { version = "0.9.*", features = ["permessage-deflate"] } [dev-dependencies] durs-common-tests-tools = { path = "../../../tests-tools/common-tests-tools" } +once_cell = "1.3.1" [features] ssl = ["ws/ssl"] diff --git a/lib/modules/ws2p/ws2p/tests/connection_negociation.rs b/lib/modules/ws2p/ws2p/tests/connection_negociation.rs index 576912cd..417cc0d4 100644 --- a/lib/modules/ws2p/ws2p/tests/connection_negociation.rs +++ b/lib/modules/ws2p/ws2p/tests/connection_negociation.rs @@ -27,13 +27,18 @@ use durs_ws2p_protocol::connection_state::WS2PConnectionState; use durs_ws2p_protocol::controller::{WS2PControllerEvent, WebsocketActionOrder}; use durs_ws2p_protocol::orchestrator::OrchestratorMsg; use durs_ws2p_protocol::MySelfWs2pNode; +use once_cell::sync::Lazy; use std::sync::mpsc; +use std::sync::Mutex; use std::thread; use std::time::Duration; static PORT: &'static u16 = &10899; static TIMEOUT_IN_MS: &'static u64 = &30_000; +// Empty mutex used to ensure that only one test runs at a time +static MUTEX: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(())); + pub fn currency() -> CurrencyName { CurrencyName(String::from("g1")) } @@ -75,6 +80,7 @@ fn client_node() -> MySelfWs2pNode { #[cfg(unix)] fn test_connection_negociation_denial() { durs_common_tests_tools::logger::init_logger_stdout(vec!["ws"]); + let _lock = MUTEX.lock().expect("MUTEX poisoned"); // ===== initialization ===== // client and server are initialized and launched in separate threads @@ -152,6 +158,7 @@ fn test_connection_negociation_denial() { #[cfg(unix)] fn test_connection_negociation_success() { durs_common_tests_tools::logger::init_logger_stdout(vec!["ws"]); + let _lock = MUTEX.lock().expect("MUTEX poisoned"); // ===== initialization ===== // client and server are initialized and launched in separate threads -- GitLab