From aa55f109bd4b745b237fcf72769bb9c02f2d5732 Mon Sep 17 00:00:00 2001 From: Javier Viola <363911+pepoviola@users.noreply.github.com> Date: Mon, 26 Feb 2024 09:54:39 -0300 Subject: [PATCH] chore(ci): fix coverage (#172) - Add clean disk space action. --- .github/workflows/ci.yml | 6 ++++++ .gitlab-ci.yml | 2 +- crates/provider/src/kubernetes/namespace.rs | 10 +++++++--- .../src/kubernetes/scripts/zombie-wrapper.sh | 13 ++++++++++++- crates/sdk/tests/smoke.rs | 4 +++- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 462290b..2a7cf88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,6 +59,12 @@ jobs: steps: - uses: actions/checkout@v3 + # https://github.com/jlumbroso/free-disk-space + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + - name: Fetch cache uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 with: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bf5ddb3..7118e4b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,7 +31,7 @@ k8s-integration-test-smoke: tags: - zombienet-polkadot-integration-test script: - - RUST_LOG=zombienet_orchestrator=debug cargo test --features ci-k8s --test smoke -- --nocapture + - RUST_LOG=zombienet_orchestrator=debug,zombienet_provider=debug cargo test --features ci-k8s --test smoke -- --nocapture variables: CI_IMAGE: !reference [.ci-unified, variables, CI_IMAGE] RUN_IN_CI: "1" diff --git a/crates/provider/src/kubernetes/namespace.rs b/crates/provider/src/kubernetes/namespace.rs index fa952f1..4ba5822 100644 --- a/crates/provider/src/kubernetes/namespace.rs +++ b/crates/provider/src/kubernetes/namespace.rs @@ -3,6 +3,7 @@ use std::{ env, path::PathBuf, sync::{Arc, Weak}, + time::Duration, }; use anyhow::anyhow; @@ -202,9 +203,9 @@ where port: IntOrString::Int(80), ..Default::default() }), - initial_delay_seconds: Some(5), - period_seconds: Some(3), - failure_threshold: Some(15), + initial_delay_seconds: Some(1), + period_seconds: Some(2), + failure_threshold: Some(3), ..Default::default() }), ..Default::default() @@ -381,6 +382,9 @@ where .await?; debug!("temp ready!"); + trace!("adding 500ms sleep as workaround!"); + tokio::time::sleep(Duration::from_millis(500)).await; + for GenerateFileCommand { program, args, diff --git a/crates/provider/src/kubernetes/scripts/zombie-wrapper.sh b/crates/provider/src/kubernetes/scripts/zombie-wrapper.sh index ab262ff..6b46d87 100755 --- a/crates/provider/src/kubernetes/scripts/zombie-wrapper.sh +++ b/crates/provider/src/kubernetes/scripts/zombie-wrapper.sh @@ -8,6 +8,7 @@ if [ -f /cfg/coreutils ]; then LS="/cfg/coreutils ls" KILL="/cfg/coreutils kill" SLEEP="/cfg/coreutils sleep" + ECHO="/cfg/coreutils echo" else RM="rm" MKFIFO="mkfifo" @@ -15,6 +16,7 @@ else LS="ls" KILL="kill" SLEEP="sleep" + ECHO="echo" fi echo "COMMANDS DEFINED" @@ -52,8 +54,17 @@ CMD=($@) echo "COMMAND TO RUN IS: $CMD" start() { - "${CMD[@]}" & + # redirect the output to be expored to loki + "${CMD[@]}" >> /proc/1/fd/1 2 >> /proc/1/fd/2 & child_pid="$!" + + # store pid + $ECHO ${child_pid} > /cfg/zombie.pid + + # check if the process is running + if ! $LS /proc/$child_pid > /dev/null 2>&1 ; then + exit 1 + fi; } restart() { diff --git a/crates/sdk/tests/smoke.rs b/crates/sdk/tests/smoke.rs index 77844d8..303de4e 100644 --- a/crates/sdk/tests/smoke.rs +++ b/crates/sdk/tests/smoke.rs @@ -1,4 +1,4 @@ -use std::{panic, pin::Pin}; +use std::{panic, pin::Pin, time::Duration}; use configuration::{NetworkConfig, NetworkConfigBuilder}; use futures::{stream::StreamExt, Future}; @@ -83,6 +83,8 @@ fn basic_functionalities_should_works() { let config = small_network(); run_k8s_test(config, |network| { Box::pin(async move { + // give some time to node bootstrap + tokio::time::sleep(Duration::from_secs(3)).await; // Get a ref to the node let alice = network.get_node("alice").unwrap(); -- GitLab