Use 2x timeout for integration tests in Codecov CI (#533)
This commit is contained in:
parent
ab68d3e16e
commit
2e6365bb95
|
@ -64,11 +64,23 @@ jobs:
|
||||||
- name: Setup build environment (Windows)
|
- name: Setup build environment (Windows)
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
uses: ./.github/actions/mingw-env
|
uses: ./.github/actions/mingw-env
|
||||||
- uses: actions-rs/cargo@v1
|
- name: Cargo build
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
args: --all --no-default-features --features ${{ matrix.feature }}
|
args: --all --no-default-features --features ${{ matrix.feature }}
|
||||||
- uses: actions-rs/cargo@v1
|
- name: Cargo test (Other OSes)
|
||||||
|
if: matrix.os != 'windows-latest'
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --all --no-default-features --features ${{ matrix.feature }}
|
||||||
|
- name: Cargo test (Windows)
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
env:
|
||||||
|
# Because Windows runners in Github Actions tend to be slow.
|
||||||
|
SLOW_TEST_ENV: true
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
args: --all --no-default-features --features ${{ matrix.feature }}
|
args: --all --no-default-features --features ${{ matrix.feature }}
|
||||||
|
|
|
@ -35,6 +35,8 @@ jobs:
|
||||||
cargo test --no-default-features --features libp2p
|
cargo test --no-default-features --features libp2p
|
||||||
mkdir /tmp/cov;
|
mkdir /tmp/cov;
|
||||||
grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o /tmp/cov/tests.lcov;
|
grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o /tmp/cov/tests.lcov;
|
||||||
|
env:
|
||||||
|
SLOW_TEST_ENV: true
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -5,8 +5,10 @@ pub use nodes::MixNode;
|
||||||
pub use nodes::NomosNode;
|
pub use nodes::NomosNode;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
|
use std::env;
|
||||||
// std
|
// std
|
||||||
use std::net::TcpListener;
|
use std::net::TcpListener;
|
||||||
|
use std::ops::Mul;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::{fmt::Debug, sync::Mutex};
|
use std::{fmt::Debug, sync::Mutex};
|
||||||
|
|
||||||
|
@ -15,6 +17,8 @@ use fraction::{Fraction, One};
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
|
|
||||||
static NET_PORT: Lazy<Mutex<u16>> = Lazy::new(|| Mutex::new(thread_rng().gen_range(8000, 10000)));
|
static NET_PORT: Lazy<Mutex<u16>> = Lazy::new(|| Mutex::new(thread_rng().gen_range(8000, 10000)));
|
||||||
|
static IS_SLOW_TEST_ENV: Lazy<bool> =
|
||||||
|
Lazy::new(|| env::var("SLOW_TEST_ENV").is_ok_and(|s| s == "true"));
|
||||||
|
|
||||||
pub fn get_available_port() -> u16 {
|
pub fn get_available_port() -> u16 {
|
||||||
let mut port = NET_PORT.lock().unwrap();
|
let mut port = NET_PORT.lock().unwrap();
|
||||||
|
@ -25,6 +29,15 @@ pub fn get_available_port() -> u16 {
|
||||||
*port
|
*port
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// In slow test environments like Codecov, use 2x timeout.
|
||||||
|
pub fn adjust_timeout(d: Duration) -> Duration {
|
||||||
|
if *IS_SLOW_TEST_ENV {
|
||||||
|
d.mul(2)
|
||||||
|
} else {
|
||||||
|
d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
pub trait Node: Sized {
|
pub trait Node: Sized {
|
||||||
type ConsensusInfo: Debug + Clone + PartialEq;
|
type ConsensusInfo: Debug + Clone + PartialEq;
|
||||||
|
@ -58,7 +71,7 @@ impl SpawnConfig {
|
||||||
// Set the timeout conservatively
|
// Set the timeout conservatively
|
||||||
// since nodes should be spawned sequentially in the chain topology
|
// since nodes should be spawned sequentially in the chain topology
|
||||||
// and it takes 1+ secs for each nomos-node to be started.
|
// and it takes 1+ secs for each nomos-node to be started.
|
||||||
timeout: Duration::from_millis(n_participants as u64 * 2500),
|
timeout: adjust_timeout(Duration::from_millis(n_participants as u64 * 2500)),
|
||||||
},
|
},
|
||||||
mixnet: mixnet_config,
|
mixnet: mixnet_config,
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::net::SocketAddr;
|
||||||
use std::process::{Child, Command, Stdio};
|
use std::process::{Child, Command, Stdio};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
// internal
|
// internal
|
||||||
use crate::{get_available_port, ConsensusConfig, MixnetConfig, Node, SpawnConfig};
|
use crate::{adjust_timeout, get_available_port, ConsensusConfig, MixnetConfig, Node, SpawnConfig};
|
||||||
use consensus_engine::overlay::{RandomBeaconState, RoundRobin, TreeOverlay, TreeOverlaySettings};
|
use consensus_engine::overlay::{RandomBeaconState, RoundRobin, TreeOverlay, TreeOverlaySettings};
|
||||||
use consensus_engine::{BlockId, NodeId, Overlay};
|
use consensus_engine::{BlockId, NodeId, Overlay};
|
||||||
use full_replication::Certificate;
|
use full_replication::Certificate;
|
||||||
|
@ -89,7 +89,7 @@ impl NomosNode {
|
||||||
_tempdir: dir,
|
_tempdir: dir,
|
||||||
config,
|
config,
|
||||||
};
|
};
|
||||||
tokio::time::timeout(std::time::Duration::from_secs(10), async {
|
tokio::time::timeout(adjust_timeout(Duration::from_secs(10)), async {
|
||||||
node.wait_online().await
|
node.wait_online().await
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
|
|
|
@ -4,7 +4,9 @@ use nomos_cli::{
|
||||||
};
|
};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
use tests::{get_available_port, nodes::nomos::Pool, MixNode, Node, NomosNode, SpawnConfig};
|
use tests::{
|
||||||
|
adjust_timeout, get_available_port, nodes::nomos::Pool, MixNode, Node, NomosNode, SpawnConfig,
|
||||||
|
};
|
||||||
|
|
||||||
const TIMEOUT_SECS: u64 = 20;
|
const TIMEOUT_SECS: u64 = 20;
|
||||||
|
|
||||||
|
@ -50,7 +52,7 @@ async fn disseminate_blob() {
|
||||||
let thread = std::thread::spawn(move || cmd.run().unwrap());
|
let thread = std::thread::spawn(move || cmd.run().unwrap());
|
||||||
|
|
||||||
tokio::time::timeout(
|
tokio::time::timeout(
|
||||||
Duration::from_secs(TIMEOUT_SECS),
|
adjust_timeout(Duration::from_secs(TIMEOUT_SECS)),
|
||||||
wait_for_cert_in_mempool(&nodes[0]),
|
wait_for_cert_in_mempool(&nodes[0]),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
|
@ -2,7 +2,7 @@ use consensus_engine::{Qc, View};
|
||||||
use futures::stream::{self, StreamExt};
|
use futures::stream::{self, StreamExt};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tests::{MixNode, Node, NomosNode, SpawnConfig};
|
use tests::{adjust_timeout, MixNode, Node, NomosNode, SpawnConfig};
|
||||||
|
|
||||||
const TARGET_VIEW: View = View::new(20);
|
const TARGET_VIEW: View = View::new(20);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ struct Info {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn happy_test(nodes: &[NomosNode]) {
|
async fn happy_test(nodes: &[NomosNode]) {
|
||||||
let timeout = std::time::Duration::from_secs(30);
|
let timeout = adjust_timeout(Duration::from_secs(30));
|
||||||
let timeout = tokio::time::sleep(timeout);
|
let timeout = tokio::time::sleep(timeout);
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
_ = timeout => panic!("timed out waiting for nodes to reach view {}", TARGET_VIEW),
|
_ = timeout => panic!("timed out waiting for nodes to reach view {}", TARGET_VIEW),
|
||||||
|
|
|
@ -2,8 +2,8 @@ use consensus_engine::{Block, NodeId, TimeoutQc, View};
|
||||||
use fraction::Fraction;
|
use fraction::Fraction;
|
||||||
use futures::stream::{self, StreamExt};
|
use futures::stream::{self, StreamExt};
|
||||||
use nomos_consensus::CarnotInfo;
|
use nomos_consensus::CarnotInfo;
|
||||||
use std::collections::HashSet;
|
use std::{collections::HashSet, time::Duration};
|
||||||
use tests::{ConsensusConfig, MixNode, Node, NomosNode, SpawnConfig};
|
use tests::{adjust_timeout, ConsensusConfig, MixNode, Node, NomosNode, SpawnConfig};
|
||||||
|
|
||||||
const TARGET_VIEW: View = View::new(20);
|
const TARGET_VIEW: View = View::new(20);
|
||||||
const DUMMY_NODE_ID: NodeId = NodeId::new([0u8; 32]);
|
const DUMMY_NODE_ID: NodeId = NodeId::new([0u8; 32]);
|
||||||
|
@ -22,7 +22,7 @@ async fn ten_nodes_one_down() {
|
||||||
.await;
|
.await;
|
||||||
let mut failed_node = nodes.pop().unwrap();
|
let mut failed_node = nodes.pop().unwrap();
|
||||||
failed_node.stop();
|
failed_node.stop();
|
||||||
let timeout = std::time::Duration::from_secs(120);
|
let timeout = adjust_timeout(Duration::from_secs(120));
|
||||||
let timeout = tokio::time::sleep(timeout);
|
let timeout = tokio::time::sleep(timeout);
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
_ = timeout => panic!("timed out waiting for nodes to reach view {}", TARGET_VIEW),
|
_ = timeout => panic!("timed out waiting for nodes to reach view {}", TARGET_VIEW),
|
||||||
|
|
Loading…
Reference in New Issue