From 757b07a4e291073d7ede43241d170627d78b97cb Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Fri, 21 Feb 2025 18:03:43 +0100 Subject: [PATCH] [ci] Simplify tmpnet monitoring action Incorporate the following into the action to simplify usage: - Configure network shutdown delay to ensure a final metrics scrape - Save tmpnet dir as a github artifact --- .../run-monitored-tmpnet-cmd/action.yml | 8 +++++++ .github/workflows/ci.yml | 22 +++++-------------- tests/fixture/e2e/flags.go | 14 ++++++++---- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.github/actions/run-monitored-tmpnet-cmd/action.yml b/.github/actions/run-monitored-tmpnet-cmd/action.yml index 3a3bc911efbc..a1e85a2836bf 100644 --- a/.github/actions/run-monitored-tmpnet-cmd/action.yml +++ b/.github/actions/run-monitored-tmpnet-cmd/action.yml @@ -7,6 +7,8 @@ inputs: required: true filter_by_owner: default: '' + artifact_name: + default: 'tmpnet-data' prometheus_username: required: true prometheus_password: @@ -65,9 +67,15 @@ runs: shell: bash run: ${{ inputs.run }} env: + TMPNET_DELAY_NETWORK_SHUTDOWN: true # Ensure shutdown waits for a final metrics scrape GH_REPO: ${{ inputs.repository_owner }}/${{ inputs.repository_name }} GH_WORKFLOW: ${{ inputs.workflow }} GH_RUN_ID: ${{ inputs.run_id }} GH_RUN_NUMBER: ${{ inputs.run_number }} GH_RUN_ATTEMPT: ${{ inputs.run_attempt }} GH_JOB_ID: ${{ inputs.job }} + - name: Upload tmpnet network dir + uses: ./.github/actions/upload-tmpnet-artifact + if: always() + with: + name: ${{ inputs.artifact_name }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d0f6eaa9044..0fd9a786a44a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,17 +62,13 @@ jobs: - name: Run e2e tests uses: ./.github/actions/run-monitored-tmpnet-cmd with: - run: E2E_SERIAL=1 ./scripts/tests.e2e.sh --delay-network-shutdown + run: E2E_SERIAL=1 ./scripts/tests.e2e.sh + artifact_name: e2e-tmpnet-data filter_by_owner: avalanchego-e2e prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }} prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }} loki_username: ${{ secrets.LOKI_ID || '' }} loki_password: ${{ secrets.LOKI_PASSWORD || '' }} - - name: Upload tmpnet network dir - uses: ./.github/actions/upload-tmpnet-artifact - if: always() - with: - name: e2e-tmpnet-data e2e_existing_network: runs-on: ubuntu-latest steps: @@ -88,16 +84,12 @@ jobs: - name: Run e2e tests with existing network uses: ./.github/actions/run-monitored-tmpnet-cmd with: - run: E2E_SERIAL=1 ./scripts/tests.e2e.existing.sh --delay-network-shutdown + run: E2E_SERIAL=1 ./scripts/tests.e2e.existing.sh + artifact_name: e2e-existing-network-tmpnet-data prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }} prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }} loki_username: ${{ secrets.LOKI_ID || '' }} loki_password: ${{ secrets.LOKI_PASSWORD || '' }} - - name: Upload tmpnet network dir - uses: ./.github/actions/upload-tmpnet-artifact - if: always() - with: - name: e2e-existing-network-tmpnet-data Upgrade: runs-on: ubuntu-latest steps: @@ -114,15 +106,11 @@ jobs: uses: ./.github/actions/run-monitored-tmpnet-cmd with: run: ./scripts/tests.upgrade.sh + artifact_name: upgrade-tmpnet-data prometheus_username: ${{ secrets.PROMETHEUS_ID || '' }} prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }} loki_username: ${{ secrets.LOKI_ID || '' }} loki_password: ${{ secrets.LOKI_PASSWORD || '' }} - - name: Upload tmpnet network dir - uses: ./.github/actions/upload-tmpnet-artifact - if: always() - with: - name: upgrade-tmpnet-data Lint: runs-on: ubuntu-latest steps: diff --git a/tests/fixture/e2e/flags.go b/tests/fixture/e2e/flags.go index 629db51ce6f0..ef15d43e3ec7 100644 --- a/tests/fixture/e2e/flags.go +++ b/tests/fixture/e2e/flags.go @@ -10,12 +10,18 @@ import ( "path/filepath" "time" + "github.com/spf13/cast" + "github.com/ava-labs/avalanchego/tests/fixture/tmpnet" ) -// Ensure that this value takes into account the scrape_interval -// defined in scripts/run_prometheus.sh. -const networkShutdownDelay = 12 * time.Second +const ( + // Ensure that this value takes into account the scrape_interval + // defined in scripts/run_prometheus.sh. + networkShutdownDelay = 12 * time.Second + + delayNetworkShutdownEnvName = "TMPNET_DELAY_NETWORK_SHUTDOWN" +) type FlagVars struct { avalancheGoExecPath string @@ -143,7 +149,7 @@ func RegisterFlags() *FlagVars { flag.BoolVar( &vars.delayNetworkShutdown, "delay-network-shutdown", - false, + cast.ToBool(GetEnvWithDefault(delayNetworkShutdownEnvName, "false")), "[optional] whether to delay network shutdown to allow a final metrics scrape.", ) flag.BoolVar(