diff --git a/.github/workflows/bdd.yml b/.github/workflows/bdd.yml new file mode 100644 index 000000000..c0a8dc080 --- /dev/null +++ b/.github/workflows/bdd.yml @@ -0,0 +1,53 @@ +name: BDD CI +on: + workflow_call: + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + +jobs: + bdd-tests: + runs-on: ubuntu-latest-16-cores + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: 'recursive' + - uses: DeterminateSystems/nix-installer-action@v14 + - uses: DeterminateSystems/magic-nix-cache-action@v8 + - name: Pre-populate nix-shell + run: | + export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r) + echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV + nix-shell --run "echo" shell.nix + - name: Handle Rust dependencies caching + uses: Swatinem/rust-cache@v2 + - name: Build binaries + run: nix-shell --run "cargo build --bins" + - name: Setup Test Pre-Requisites + run: | + sudo sysctl -w vm.nr_hugepages=3072 + sudo apt-get install linux-modules-extra-$(uname -r) + sudo modprobe nvme_tcp + - name: Run BDD Tests + run: | + nix-shell --run "deployer start --image-pull-policy always -w 60s && deployer stop" + nix-shell --run "./scripts/python/test.sh" + - name: Cleanup + if: always() + run: nix-shell --run "./scripts/python/test-residue-cleanup.sh" + - name: Surface failing tests + if: always() + uses: pmeier/pytest-results-action@main + with: + path: report.xml + summary: true + display-options: a + fail-on-empty: true + title: Test results +# debugging + - name: Setup tmate session + if: ${{ failure() }} + timeout-minutes: 120 + uses: mxschmitt/action-tmate@v3 diff --git a/.github/workflows/image-pr.yml b/.github/workflows/image-pr.yml new file mode 100644 index 000000000..ac13554fb --- /dev/null +++ b/.github/workflows/image-pr.yml @@ -0,0 +1,19 @@ +name: ImageBuild CI +on: + workflow_call: + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + +jobs: + image-build-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - uses: DeterminateSystems/nix-installer-action@v14 + - uses: DeterminateSystems/magic-nix-cache-action@v8 + - name: Test building the release images + run: ./scripts/release.sh --skip-publish --build-bins diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml new file mode 100644 index 000000000..81f4553fd --- /dev/null +++ b/.github/workflows/image.yml @@ -0,0 +1,24 @@ +name: Image Push +on: + push: + branches: + - develop + - 'release/**' + tags: + - 'v[0-9]+.[0-9]+.[0-9]+**' + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + +jobs: + image-build-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - uses: DeterminateSystems/nix-installer-action@v14 + - uses: DeterminateSystems/magic-nix-cache-action@v8 + - name: Test building the release images + run: ./scripts/release.sh diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..b89ae3611 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,26 @@ +name: Unit/Int CI +on: + workflow_call: + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + +jobs: + rust-linter: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + - uses: DeterminateSystems/nix-installer-action@v14 + - uses: DeterminateSystems/magic-nix-cache-action@v8 + - name: Pre-populate nix-shell + run: | + export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r) + echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV + nix-shell --run "echo" shell.nix + - name: Handle Rust dependencies caching + uses: Swatinem/rust-cache@v2 + - name: Lint rust code + run: nix-shell --run "./scripts/rust/linter.sh" \ No newline at end of file diff --git a/.github/workflows/nightly-ci.yml b/.github/workflows/nightly-ci.yml new file mode 100644 index 000000000..1aa54a635 --- /dev/null +++ b/.github/workflows/nightly-ci.yml @@ -0,0 +1,24 @@ +name: Nightly CI +on: + workflow_dispatch: + +jobs: + lint-ci: + uses: ./.github/workflows/lint.yml + int-ci: + uses: ./.github/workflows/unit-int.yml + bdd-ci: + uses: ./.github/workflows/bdd.yml + image-ci: + uses: ./.github/workflows/image-pr.yml + bors-ci: + if: ${{ success() }} + needs: + - lint-ci + - int-ci + - bdd-ci + - image-ci + runs-on: ubuntu-latest + steps: + - name: CI succeeded + run: exit 0 diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml new file mode 100644 index 000000000..68a4c0a4a --- /dev/null +++ b/.github/workflows/pr-ci.yml @@ -0,0 +1,28 @@ +name: Bors CI +on: + push: + branches: + - staging + - trying + - ci + +jobs: + # lint-ci: + # uses: ./.github/workflows/lint.yml + int-ci: + uses: ./.github/workflows/unit-int.yml + bdd-ci: + uses: ./.github/workflows/bdd.yml + # image-ci: + # uses: ./.github/workflows/image-pr.yml + bors-ci: + if: ${{ success() }} + needs: + # - lint-ci + - int-ci + - bdd-ci + # - image-ci + runs-on: ubuntu-latest + steps: + - name: CI succeeded + run: exit 0 diff --git a/.github/workflows/unit-int.yml b/.github/workflows/unit-int.yml new file mode 100644 index 000000000..706f770f4 --- /dev/null +++ b/.github/workflows/unit-int.yml @@ -0,0 +1,50 @@ +name: Integration CI +on: + workflow_call: + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + +jobs: + int-tests: + runs-on: ubuntu-latest-16-cores + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: 'recursive' + - uses: DeterminateSystems/nix-installer-action@v14 + - uses: DeterminateSystems/magic-nix-cache-action@v8 + - name: Pre-populate nix-shell + run: | + export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r) + echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV + nix-shell --run "echo" shell.nix + - name: Handle Rust dependencies caching + uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ startsWith(github.ref_name, 'release/') || github.ref_name == 'develop' || github.ref_name == 'ci' }} + - name: Build rust binaries + run: nix-shell --run "cargo build --bins" + - name: Build the tests + run: nix-shell --run "./scripts/rust/test.sh --no-run" + - name: Setup Test Pre-Requisites + run: | + sudo sysctl -w vm.nr_hugepages=2560 + sudo apt-get install linux-modules-extra-$(uname -r) + sudo modprobe nvme_tcp + - name: Run Tests + run: | + # pre-pull the required container images + deployer start --image-pull-policy always -w 60s && deployer stop + # includes both unit and integration tests + nix-shell --run "./scripts/rust/test.sh" + - name: Cleanup + if: always() + run: nix-shell --run "./scripts/rust/deployer-cleanup.sh" +# debugging + - name: Setup tmate session + if: ${{ failure() }} + timeout-minutes: 120 + uses: mxschmitt/action-tmate@v3 diff --git a/control-plane/agents/src/bin/core/tests/controller/mod.rs b/control-plane/agents/src/bin/core/tests/controller/mod.rs index 9c825aec0..4aec75dc4 100644 --- a/control-plane/agents/src/bin/core/tests/controller/mod.rs +++ b/control-plane/agents/src/bin/core/tests/controller/mod.rs @@ -81,6 +81,7 @@ async fn store_lease_lock() { .await .unwrap(); + tokio::time::sleep(std::time::Duration::from_secs(1)).await; let lease_ttl = std::time::Duration::from_secs(2); let _core_agent = Etcd::new_leased( ["0.0.0.0:2379"], diff --git a/scripts/rust/test.sh b/scripts/rust/test.sh index 81eeaaaef..e7152dfb1 100755 --- a/scripts/rust/test.sh +++ b/scripts/rust/test.sh @@ -27,7 +27,7 @@ cleanup_handler() { } cleanup_handler >/dev/null -trap cleanup_handler INT QUIT TERM HUP EXIT +#trap cleanup_handler INT QUIT TERM HUP EXIT set -euxo pipefail diff --git a/shell.nix b/shell.nix index bc176b407..de769737c 100644 --- a/shell.nix +++ b/shell.nix @@ -40,7 +40,6 @@ mkShell { pre-commit python3 utillinux - rdma-core which paperclip ] ++ pkgs.lib.optional (!norust) rust @@ -54,6 +53,7 @@ mkShell { tini udev lvm2 + rdma-core ] ++ pkgs.lib.optional (system == "aarch64-darwin") darwin.apple_sdk.frameworks.Security; LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib"; diff --git a/tests/bdd/features/health_probes/test_readiness_probe.py b/tests/bdd/features/health_probes/test_readiness_probe.py index c7572a006..e8480d418 100644 --- a/tests/bdd/features/health_probes/test_readiness_probe.py +++ b/tests/bdd/features/health_probes/test_readiness_probe.py @@ -15,15 +15,18 @@ def ready_http_get(context_msg_prefix: str): try: - response = requests.get("http://localhost:8081/ready", timeout=(0.003, 0.010)) + response = requests.get("http://localhost:8081/ready", timeout=(0.1, 0.1)) logger.info( f"{context_msg_prefix}: response.status_code: {response.status_code}" ) return response - except requests.exceptions.Timeout: + except requests.exceptions.Timeout as e: logger.error(f"{context_msg_prefix}: the request timed out") + raise e + except requests.exceptions.RequestException as e: logger.error(f"{context_msg_prefix}: an error occurred: {e}") + raise e @pytest.fixture(scope="module")