From 044eb160af5bbc09c3160a78f2413d309a689689 Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Thu, 20 Oct 2022 13:55:12 +0100 Subject: [PATCH] chore: tidy up capsule restart variables (#1800) * chore: tidy up capsule restart variables * chore: add flow for manually triggering all tests * chore: fix if statement * chore: revert flow change --- .github/workflows/capsule-cypress-manual-trigger.yml | 2 +- .github/workflows/capsule-cypress-night-run.yml | 4 ++-- apps/explorer-e2e/cypress.config.js | 1 - apps/explorer-e2e/src/integration/parties.cy.js | 2 +- apps/token-e2e/src/integration/flow/governance-flow.cy.js | 2 +- apps/token-e2e/src/integration/flow/staking-flow.cy.js | 2 +- .../src/integration/flow/token-association-flow.cy.js | 2 +- apps/token-e2e/src/integration/view/wallet-vega.cy.js | 2 +- .../src/lib/commands/restart-vegacapsule-network.ts | 7 ++++++- 9 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/capsule-cypress-manual-trigger.yml b/.github/workflows/capsule-cypress-manual-trigger.yml index e85aa8785..d40060fcb 100644 --- a/.github/workflows/capsule-cypress-manual-trigger.yml +++ b/.github/workflows/capsule-cypress-manual-trigger.yml @@ -49,7 +49,7 @@ jobs: # See if we capsule is needed for this project - name: Set capsule flag - if: ${{ github.event.inputs.project == 'explorer-e2e' || github.event.inputs.project == 'token-e2e' }} + if: ${{ github.event.inputs.project == 'explorer-e2e' || github.event.inputs.project == 'token-e2e'}} run: echo RUN_CAPSULE=true >> $GITHUB_ENV ####### diff --git a/.github/workflows/capsule-cypress-night-run.yml b/.github/workflows/capsule-cypress-night-run.yml index 6078b7cf7..bcfa53a2e 100644 --- a/.github/workflows/capsule-cypress-night-run.yml +++ b/.github/workflows/capsule-cypress-night-run.yml @@ -101,14 +101,14 @@ jobs: working-directory: frontend-monorepo - name: Run Cypress tests - run: yarn nx run-many --skip-nx-cache --target=e2e --all --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --browser chrome + run: yarn nx run-many --skip-nx-cache --target=e2e --all --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --browser chrome --parallel=1 working-directory: frontend-monorepo env: CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }} CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }} CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPRESS_ETH_WALLET_MNEMONIC }} CYPRESS_NIGHTLY_RUN: true - CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS: false + CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS: true ###### ## Upload logs diff --git a/apps/explorer-e2e/cypress.config.js b/apps/explorer-e2e/cypress.config.js index 007eaa048..0ad8c33b8 100644 --- a/apps/explorer-e2e/cypress.config.js +++ b/apps/explorer-e2e/cypress.config.js @@ -27,7 +27,6 @@ module.exports = defineConfig({ networkQueryUrl: 'http://localhost:3028/query', ethUrl: 'https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8', commitHash: 'dev', - CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS: true, tsConfig: 'tsconfig.json', grepTags: '@regression @smoke @slow', grepFilterSpecs: true, diff --git a/apps/explorer-e2e/src/integration/parties.cy.js b/apps/explorer-e2e/src/integration/parties.cy.js index c402dc592..4cc56962d 100644 --- a/apps/explorer-e2e/src/integration/parties.cy.js +++ b/apps/explorer-e2e/src/integration/parties.cy.js @@ -192,7 +192,7 @@ context('Parties page', { tags: '@regression' }, function () { after( 'teardown environment to prevent test data bleeding into other tests', function () { - if (Cypress.env('CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS')) { + if (Cypress.env('TEARDOWN_NETWORK_AFTER_FLOWS')) { cy.restart_vegacapsule_network(); } } diff --git a/apps/token-e2e/src/integration/flow/governance-flow.cy.js b/apps/token-e2e/src/integration/flow/governance-flow.cy.js index 90825de91..a2c00c55b 100644 --- a/apps/token-e2e/src/integration/flow/governance-flow.cy.js +++ b/apps/token-e2e/src/integration/flow/governance-flow.cy.js @@ -812,7 +812,7 @@ context( after( 'teardown environment to prevent test data bleeding into other tests', function () { - if (Cypress.env('CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS')) { + if (Cypress.env('TEARDOWN_NETWORK_AFTER_FLOWS')) { cy.restart_vegacapsule_network(); } } diff --git a/apps/token-e2e/src/integration/flow/staking-flow.cy.js b/apps/token-e2e/src/integration/flow/staking-flow.cy.js index 1e7b2b19b..3a89a8584 100644 --- a/apps/token-e2e/src/integration/flow/staking-flow.cy.js +++ b/apps/token-e2e/src/integration/flow/staking-flow.cy.js @@ -875,7 +875,7 @@ context( after( 'teardown environment to prevent test data bleeding into other tests', function () { - if (Cypress.env('CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS')) { + if (Cypress.env('TEARDOWN_NETWORK_AFTER_FLOWS')) { cy.restart_vegacapsule_network(); } } diff --git a/apps/token-e2e/src/integration/flow/token-association-flow.cy.js b/apps/token-e2e/src/integration/flow/token-association-flow.cy.js index e23351140..33dc92310 100644 --- a/apps/token-e2e/src/integration/flow/token-association-flow.cy.js +++ b/apps/token-e2e/src/integration/flow/token-association-flow.cy.js @@ -314,7 +314,7 @@ context( after( 'teardown environment to prevent test data bleeding into other tests', function () { - if (Cypress.env('CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS')) { + if (Cypress.env('TEARDOWN_NETWORK_AFTER_FLOWS')) { cy.restart_vegacapsule_network(); } } diff --git a/apps/token-e2e/src/integration/view/wallet-vega.cy.js b/apps/token-e2e/src/integration/view/wallet-vega.cy.js index 5ccfc294e..696b4181d 100644 --- a/apps/token-e2e/src/integration/view/wallet-vega.cy.js +++ b/apps/token-e2e/src/integration/view/wallet-vega.cy.js @@ -404,7 +404,7 @@ context( after( 'teardown environment to prevent test data bleeding into other tests', function () { - if (Cypress.env('CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS')) { + if (Cypress.env('TEARDOWN_NETWORK_AFTER_FLOWS')) { cy.restart_vegacapsule_network(); } } diff --git a/libs/cypress/src/lib/commands/restart-vegacapsule-network.ts b/libs/cypress/src/lib/commands/restart-vegacapsule-network.ts index 13b457a08..3ffcf5b73 100644 --- a/libs/cypress/src/lib/commands/restart-vegacapsule-network.ts +++ b/libs/cypress/src/lib/commands/restart-vegacapsule-network.ts @@ -15,12 +15,14 @@ export function addRestartVegacapsuleNetwork() { // This stops those errors from preventing the teardown return false; }); + cy.log('Destroying capsule network'); // We stop the network twice - since it does not always shutdown correctly on first attempt cy.exec('vegacapsule network destroy', { failOnNonZeroExit: false }); cy.exec('vegacapsule network destroy', { failOnNonZeroExit: false }) .its('stderr') .should('contain', 'Network has been successfully cleaned up'); + cy.log('Bootstrapping network'); cy.exec( 'vegacapsule network bootstrap --config-path=../../vegacapsule/config.hcl --force', { failOnNonZeroExit: false, timeout: 100000 } @@ -28,7 +30,10 @@ export function addRestartVegacapsuleNetwork() { .its('stderr') .then((response) => { if (!response.includes('Network successfully started')) { - cy.exec('vegacapsule network destroy', { failOnNonZeroExit: false }); + cy.log('Bootstrapping network second time'); + cy.exec('vegacapsule network destroy', { failOnNonZeroExit: false }) + .its('stderr') + .should('contain', 'Network has been successfully cleaned up'); cy.exec( 'vegacapsule network bootstrap --config-path=../../vegacapsule/config.hcl --force', { failOnNonZeroExit: false, timeout: 100000 }