Skip to content

Commit

Permalink
test: enable node man integration tests
Browse files Browse the repository at this point in the history
These tests are enabled again, along with some changes to the setup.

Here are the important points:

* The tests now run against an isolated local network and binary built during CI is supplied.
* The workflow runs the e2e tests for both system-wide and user-mode services.
* The test definitions are moved to a new workflow file, but it has the same conditions as the merge
  workflow. The reason is just because the merge workflow file is already large and difficult to
  navigate.
* The upgrade integration tests are removed because since the service management refactor, unit
  tests cover the upgrade scenarios well. What we are more concerned with in the upgrade process is
  the logic of how different upgrade scenarios are handled.
* The daemon integration tests are removed. The test that was setup was really trying to cover the
  scenario where peer retention was specified for restart commands, but we have agreed that the
  semantics of this command is wrong and that it needs to be broken down. In general, the daemon
  commands will correspond to the operations of the node manager, and the node manager operations
  should already be quite well tested.
* Some documentation.
  • Loading branch information
jacderida authored and joshuef committed May 22, 2024
1 parent 2d233a7 commit 537f224
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 631 deletions.
201 changes: 0 additions & 201 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,207 +141,6 @@ jobs:
# we do many more runs on the nightly run
PROPTEST_CASES: 50

node-manager-unit-tests:
name: node manager unit tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

- name: cargo cache registry, index and build
uses: actions/[email protected]
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-cache-${{ hashFiles('**/Cargo.lock') }}
- shell: bash
run: cargo test --lib --package sn-node-manager

#
# Temporarily disable node manager integration tests until they can be made more isolated.
#
# node-manager-e2e-tests:
# name: node manager e2e tests
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# include:
# - { os: ubuntu-latest, elevated: sudo env PATH="$PATH" }
# - { os: macos-latest, elevated: sudo }
# - { os: windows-latest }
# steps:
# - uses: actions/checkout@v4
#
# - name: Install Rust
# uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
#
# - shell: bash
# if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
# run: |
# ${{ matrix.elevated }} rustup default stable
# ${{ matrix.elevated }} cargo test --package sn-node-manager --release --test e2e -- --nocapture
#
# # Powershell step runs as admin by default.
# - name: run integration test in powershell
# if: matrix.os == 'windows-latest'
# shell: pwsh
# run: |
# curl -L -o WinSW.exe $env:WINSW_URL
#
# New-Item -ItemType Directory -Force -Path "$env:GITHUB_WORKSPACE\bin"
# Move-Item -Path WinSW.exe -Destination "$env:GITHUB_WORKSPACE\bin"
# $env:PATH += ";$env:GITHUB_WORKSPACE\bin"
#
# cargo test --release --package sn-node-manager --test e2e -- --nocapture

# Each upgrade test needs its own VM, otherwise they will interfere with each other.
# node-manager-upgrade-tests:
# name: node manager upgrade tests
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# include:
# - {
# os: ubuntu-latest,
# elevated: sudo env PATH="$PATH",
# test: upgrade_to_latest_version,
# }
# - {
# os: ubuntu-latest,
# elevated: sudo env PATH="$PATH",
# test: force_upgrade_when_two_binaries_have_the_same_version,
# }
# - {
# os: ubuntu-latest,
# elevated: sudo env PATH="$PATH",
# test: force_downgrade_to_a_previous_version,
# }
# - {
# os: ubuntu-latest,
# elevated: sudo env PATH="$PATH",
# test: upgrade_from_older_version_to_specific_version,
# }
# - {
# os: macos-latest,
# elevated: sudo,
# test: upgrade_to_latest_version,
# }
# - {
# os: macos-latest,
# elevated: sudo,
# test: force_upgrade_when_two_binaries_have_the_same_version,
# }
# - {
# os: macos-latest,
# elevated: sudo,
# test: force_downgrade_to_a_previous_version,
# }
# - {
# os: macos-latest,
# elevated: sudo,
# test: upgrade_from_older_version_to_specific_version,
# }
# - { os: windows-latest, test: upgrade_to_latest_version }
# - {
# os: windows-latest,
# test: force_upgrade_when_two_binaries_have_the_same_version,
# }
# - { os: windows-latest, test: force_downgrade_to_a_previous_version }
# - {
# os: windows-latest,
# test: upgrade_from_older_version_to_specific_version,
# }
# steps:
# - uses: actions/checkout@v4
#
# - name: Install Rust
# uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
#
# - shell: bash
# if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
# run: |
# ${{ matrix.elevated }} rustup default stable
# ${{ matrix.elevated }} cargo test --package sn-node-manager --release \
# --test upgrades ${{ matrix.test }} -- --nocapture
#
# # Powershell step runs as admin by default.
# - name: run integration test in powershell
# if: matrix.os == 'windows-latest'
# shell: pwsh
# run: |
# curl -L -o WinSW.exe $env:WINSW_URL
#
# New-Item -ItemType Directory -Force -Path "$env:GITHUB_WORKSPACE\bin"
# Move-Item -Path WinSW.exe -Destination "$env:GITHUB_WORKSPACE\bin"
# $env:PATH += ";$env:GITHUB_WORKSPACE\bin"
#
# cargo test --package sn-node-manager --release `
# --test upgrades ${{ matrix.test }} -- --nocapture
#
# # Each daemon test needs its own VM, otherwise they will interfere with each other.
# node-manager-daemon-tests:
# name: node manager daemon tests
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# include:
# - {
# os: ubuntu-latest,
# elevated: sudo env PATH="$PATH",
# test: restart_node,
# }
# # todo: enable once url/version has been implemented for Daemon subcmd.
# # - {
# # os: macos-latest,
# # elevated: sudo,
# # test: restart_node,
# # }
# # - {
# # os: windows-latest,
# # test: restart_node,
# # }
# steps:
# - uses: actions/checkout@v4
#
# - name: Install Rust
# uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
#
# - name: run integration test
# shell: bash
# if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
# run: |
# ${{ matrix.elevated }} rustup default stable
# ${{ matrix.elevated }} cargo test --package sn-node-manager --release \
# --test daemon ${{ matrix.test }} -- --nocapture
#
# # Powershell step runs as admin by default.
# - name: run integration test in powershell
# if: matrix.os == 'windows-latest'
# shell: pwsh
# run: |
# curl -L -o WinSW.exe $env:WINSW_URL
#
# New-Item -ItemType Directory -Force -Path "$env:GITHUB_WORKSPACE\bin"
# Move-Item -Path WinSW.exe -Destination "$env:GITHUB_WORKSPACE\bin"
# $env:PATH += ";$env:GITHUB_WORKSPACE\bin"
#
# cargo test --package sn-node-manager --release `
# --test daemon ${{ matrix.test }} -- --nocapture

e2e:
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
name: E2E tests
Expand Down
156 changes: 156 additions & 0 deletions .github/workflows/node_man_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: Node Manager Tests

on:
merge_group:
branches: [main, alpha*, beta*, rc*]
pull_request:
branches: ["*"]

env:
CARGO_INCREMENTAL: 0 # bookkeeping for incremental builds has overhead, not useful in CI.
WINSW_URL: https://github.com/winsw/winsw/releases/download/v3.0.0-alpha.11/WinSW-x64.exe

jobs:
node-manager-unit-tests:
name: node manager unit tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

- name: cargo cache registry, index and build
uses: actions/[email protected]
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-cache-${{ hashFiles('**/Cargo.lock') }}
- shell: bash
run: cargo test --lib --package sn-node-manager

node-manager-user-mode-e2e-tests:
name: user-mode e2e
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest }
- { os: macos-latest }
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

- name: Build binaries
run: cargo build --release --bin safenode --bin faucet
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
with:
action: start
interval: 2000
node-path: target/release/safenode
faucet-path: target/release/faucet
platform: ${{ matrix.os }}
build: true

- name: Check SAFE_PEERS was set
shell: bash
run: |
if [[ -z "$SAFE_PEERS" ]]; then
echo "The SAFE_PEERS variable has not been set"
exit 1
else
echo "SAFE_PEERS has been set to $SAFE_PEERS"
fi
- shell: bash
run: |
cargo test --package sn-node-manager --release --test e2e -- --nocapture
- name: Stop the local network and upload logs
if: always()
uses: maidsafe/sn-local-testnet-action@main
with:
action: stop
log_file_prefix: node_man_tests_user_mode
platform: ${{ matrix.os }}

node-manager-e2e-tests:
name: system-wide e2e
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, elevated: sudo -E env PATH="$PATH" }
- { os: macos-latest, elevated: sudo -E }
- { os: windows-latest }
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

- name: Build binaries
run: cargo build --release --bin safenode --bin faucet
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
with:
action: start
interval: 2000
node-path: target/release/safenode
faucet-path: target/release/faucet
platform: ${{ matrix.os }}
build: true

- name: Check SAFE_PEERS was set
shell: bash
run: |
if [[ -z "$SAFE_PEERS" ]]; then
echo "The SAFE_PEERS variable has not been set"
exit 1
else
echo "SAFE_PEERS has been set to $SAFE_PEERS"
fi
- shell: bash
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: |
${{ matrix.elevated }} rustup default stable
${{ matrix.elevated }} cargo test --package sn-node-manager --release --test e2e -- --nocapture
# Powershell step runs as admin by default.
- name: run integration test in powershell
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
curl -L -o WinSW.exe $env:WINSW_URL
New-Item -ItemType Directory -Force -Path "$env:GITHUB_WORKSPACE\bin"
Move-Item -Path WinSW.exe -Destination "$env:GITHUB_WORKSPACE\bin"
$env:PATH += ";$env:GITHUB_WORKSPACE\bin"
cargo test --release --package sn-node-manager --test e2e -- --nocapture
- name: Stop the local network and upload logs
if: always()
uses: maidsafe/sn-local-testnet-action@main
with:
action: stop
log_file_prefix: node_man_tests_system_wide
platform: ${{ matrix.os }}
16 changes: 14 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,17 @@ upload-release-assets-to-s3 bin_name:

cd deploy/{{bin_name}}
for file in *.zip *.tar.gz; do
aws s3 cp "$file" "s3://$bucket/$file" --acl public-read
done
aws s3 cp "$file" "s3://$bucket/$file" --acl public-read done

node-man-integration-tests:
#!/usr/bin/env bash
set -e
cargo build --release --bin safenode --bin faucet --bin safenode-manager
cargo run --release --bin safenode-manager -- local run \
--node-path target/release/safenode \
--faucet-path target/release/faucet
peer=$(cargo run --release --bin safenode-manager -- local status \
--json | jq -r .nodes[-1].listen_addr[0])
export SAFE_PEERS=$peer
cargo test --release --package sn-node-manager --test e2e -- --nocapture
Loading

0 comments on commit 537f224

Please sign in to comment.