From 08b30560757cae4944851559a15deba3ece73832 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Thu, 9 Jan 2025 17:38:38 -0600 Subject: [PATCH] add new e2e test Signed-off-by: Jeffrey Tang --- .github/workflows/autogen/README.md | 8 +- .github/workflows/flow-build-application.yaml | 5 + .../workflows/flow-pull-request-checks.yaml | 9 ++ .github/workflows/templates/config.yaml | 3 + .../templates/template.zxc-code-analysis.yaml | 11 +- .../templates/template.zxc-env-vars.yaml | 8 ++ .github/workflows/zxc-code-analysis.yaml | 17 +++ .github/workflows/zxc-env-vars.yaml | 8 ++ package.json | 11 +- src/commands/flags.ts | 2 +- src/commands/node/configs.ts | 6 - src/commands/node/handlers.ts | 3 +- src/commands/node/helper.ts | 2 - test/e2e/commands/node_upgrade.test.ts | 21 ++-- .../commands/separate_node_upgrade.test.ts | 104 ++++++++++++++++++ 15 files changed, 185 insertions(+), 33 deletions(-) create mode 100644 test/e2e/commands/separate_node_upgrade.test.ts diff --git a/.github/workflows/autogen/README.md b/.github/workflows/autogen/README.md index fff07f01e..5e843aac9 100644 --- a/.github/workflows/autogen/README.md +++ b/.github/workflows/autogen/README.md @@ -6,7 +6,13 @@ The Solo autogen tool is used to add e2e test cases that need to be ran independ ## Usage -from solo root directory: +After a new e2e test is created, update the below file first: + +```bash +.github/workflows/templates/config.yaml +``` + +Next, from solo root directory: ```bash cd .github/workflows/autogen diff --git a/.github/workflows/flow-build-application.yaml b/.github/workflows/flow-build-application.yaml index 404622268..8c359dce0 100644 --- a/.github/workflows/flow-build-application.yaml +++ b/.github/workflows/flow-build-application.yaml @@ -90,6 +90,7 @@ jobs: - { name: "Node Delete", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-delete-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-delete-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-delete-coverage-report }}" } - { name: "Node Delete - Separate commands", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-coverage-report }}" } - { name: "Node Upgrade", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-upgrade-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-upgrade-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-upgrade-coverage-report }}" } + - { name: "Node Upgrade - Separate commands", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-upgrade-separate-commands-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-upgrade-separate-commands-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-upgrade-separate-commands-coverage-report }}" } - { name: "Relay", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-relay-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-relay-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-relay-coverage-report }}" } max-parallel: 3 with: @@ -123,9 +124,11 @@ jobs: e2e-node-add-local-test-subdir: ${{ needs.env-vars.outputs.e2e-node-add-local-test-subdir }} e2e-node-add-separate-commands-test-subdir: ${{ needs.env-vars.outputs.e2e-node-add-separate-commands-test-subdir }} e2e-node-update-test-subdir: ${{ needs.env-vars.outputs.e2e-node-update-test-subdir }} + e2e-node-update-separate-commands-test-subdir: ${{ needs.env-vars.outputs.e2e-node-update-separate-commands-test-subdir }} e2e-node-delete-test-subdir: ${{ needs.env-vars.outputs.e2e-node-delete-test-subdir }} e2e-node-delete-separate-commands-test-subdir: ${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-test-subdir }} e2e-node-upgrade-test-subdir: ${{ needs.env-vars.outputs.e2e-node-upgrade-test-subdir }} + e2e-node-upgrade-separate-commands-test-subdir: ${{ needs.env-vars.outputs.e2e-node-upgrade-separate-commands-test-subdir }} e2e-relay-test-subdir: ${{ needs.env-vars.outputs.e2e-relay-test-subdir }} e2e-integration-coverage-report: ${{ needs.env-vars.outputs.e2e-integration-coverage-report }} e2e-standard-coverage-report: ${{ needs.env-vars.outputs.e2e-standard-coverage-report }} @@ -138,9 +141,11 @@ jobs: e2e-node-add-local-coverage-report: ${{ needs.env-vars.outputs.e2e-node-add-local-coverage-report }} e2e-node-add-separate-commands-coverage-report: ${{ needs.env-vars.outputs.e2e-node-add-separate-commands-coverage-report }} e2e-node-update-coverage-report: ${{ needs.env-vars.outputs.e2e-node-update-coverage-report }} + e2e-node-update-separate-commands-coverage-report: ${{ needs.env-vars.outputs.e2e-node-update-separate-commands-coverage-report }} e2e-node-delete-coverage-report: ${{ needs.env-vars.outputs.e2e-node-delete-coverage-report }} e2e-node-delete-separate-commands-coverage-report: ${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-coverage-report }} e2e-node-upgrade-coverage-report: ${{ needs.env-vars.outputs.e2e-node-upgrade-coverage-report }} + e2e-node-upgrade-separate-commands-coverage-report: ${{ needs.env-vars.outputs.e2e-node-upgrade-separate-commands-coverage-report }} e2e-relay-coverage-report: ${{ needs.env-vars.outputs.e2e-relay-coverage-report }} secrets: snyk-token: ${{ secrets.SNYK_TOKEN }} diff --git a/.github/workflows/flow-pull-request-checks.yaml b/.github/workflows/flow-pull-request-checks.yaml index bf2b38add..c4c578b29 100644 --- a/.github/workflows/flow-pull-request-checks.yaml +++ b/.github/workflows/flow-pull-request-checks.yaml @@ -89,6 +89,7 @@ jobs: - { name: "Node Delete", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-delete-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-delete-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-delete-coverage-report }}" } - { name: "Node Delete - Separate commands", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-coverage-report }}" } - { name: "Node Upgrade", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-upgrade-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-upgrade-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-upgrade-coverage-report }}" } + - { name: "Node Upgrade - Separate commands", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-node-upgrade-separate-commands-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-node-upgrade-separate-commands-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-node-upgrade-separate-commands-coverage-report }}" } - { name: "Relay", npm-test-script: "test-${{ needs.env-vars.outputs.e2e-relay-test-subdir }}", coverage-subdirectory: "${{ needs.env-vars.outputs.e2e-relay-test-subdir }}", coverage-report-name: "${{ needs.env-vars.outputs.e2e-relay-coverage-report }}" } max-parallel: 3 with: @@ -120,9 +121,11 @@ jobs: e2e-node-add-local-test-subdir: ${{ needs.env-vars.outputs.e2e-node-add-local-test-subdir }} e2e-node-add-separate-commands-test-subdir: ${{ needs.env-vars.outputs.e2e-node-add-separate-commands-test-subdir }} e2e-node-update-test-subdir: ${{ needs.env-vars.outputs.e2e-node-update-test-subdir }} + e2e-node-update-separate-commands-test-subdir: ${{ needs.env-vars.outputs.e2e-node-update-separate-commands-test-subdir }} e2e-node-delete-test-subdir: ${{ needs.env-vars.outputs.e2e-node-delete-test-subdir }} e2e-node-delete-separate-commands-test-subdir: ${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-test-subdir }} e2e-node-upgrade-test-subdir: ${{ needs.env-vars.outputs.e2e-node-upgrade-test-subdir }} + e2e-node-upgrade-separate-commands-test-subdir: ${{ needs.env-vars.outputs.e2e-node-upgrade-separate-commands-test-subdir }} e2e-relay-test-subdir: ${{ needs.env-vars.outputs.e2e-relay-test-subdir }} e2e-integration-coverage-report: ${{ needs.env-vars.outputs.e2e-integration-coverage-report }} e2e-standard-coverage-report: ${{ needs.env-vars.outputs.e2e-standard-coverage-report }} @@ -135,9 +138,11 @@ jobs: e2e-node-add-local-coverage-report: ${{ needs.env-vars.outputs.e2e-node-add-local-coverage-report }} e2e-node-add-separate-commands-coverage-report: ${{ needs.env-vars.outputs.e2e-node-add-separate-commands-coverage-report }} e2e-node-update-coverage-report: ${{ needs.env-vars.outputs.e2e-node-update-coverage-report }} + e2e-node-update-separate-commands-coverage-report: ${{ needs.env-vars.outputs.e2e-node-update-separate-commands-coverage-report }} e2e-node-delete-coverage-report: ${{ needs.env-vars.outputs.e2e-node-delete-coverage-report }} e2e-node-delete-separate-commands-coverage-report: ${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-coverage-report }} e2e-node-upgrade-coverage-report: ${{ needs.env-vars.outputs.e2e-node-upgrade-coverage-report }} + e2e-node-upgrade-separate-commands-coverage-report: ${{ needs.env-vars.outputs.e2e-node-upgrade-separate-commands-coverage-report }} e2e-relay-coverage-report: ${{ needs.env-vars.outputs.e2e-relay-coverage-report }} secrets: codecov-token: ${{ secrets.CODECOV_TOKEN }} @@ -165,9 +170,11 @@ jobs: e2e-node-add-local-test-subdir: ${{ needs.env-vars.outputs.e2e-node-add-local-test-subdir }} e2e-node-add-separate-commands-test-subdir: ${{ needs.env-vars.outputs.e2e-node-add-separate-commands-test-subdir }} e2e-node-update-test-subdir: ${{ needs.env-vars.outputs.e2e-node-update-test-subdir }} + e2e-node-update-separate-commands-test-subdir: ${{ needs.env-vars.outputs.e2e-node-update-separate-commands-test-subdir }} e2e-node-delete-test-subdir: ${{ needs.env-vars.outputs.e2e-node-delete-test-subdir }} e2e-node-delete-separate-commands-test-subdir: ${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-test-subdir }} e2e-node-upgrade-test-subdir: ${{ needs.env-vars.outputs.e2e-node-upgrade-test-subdir }} + e2e-node-upgrade-separate-commands-test-subdir: ${{ needs.env-vars.outputs.e2e-node-upgrade-separate-commands-test-subdir }} e2e-relay-test-subdir: ${{ needs.env-vars.outputs.e2e-relay-test-subdir }} e2e-integration-coverage-report: ${{ needs.env-vars.outputs.e2e-integration-coverage-report }} e2e-standard-coverage-report: ${{ needs.env-vars.outputs.e2e-standard-coverage-report }} @@ -180,9 +187,11 @@ jobs: e2e-node-add-local-coverage-report: ${{ needs.env-vars.outputs.e2e-node-add-local-coverage-report }} e2e-node-add-separate-commands-coverage-report: ${{ needs.env-vars.outputs.e2e-node-add-separate-commands-coverage-report }} e2e-node-update-coverage-report: ${{ needs.env-vars.outputs.e2e-node-update-coverage-report }} + e2e-node-update-separate-commands-coverage-report: ${{ needs.env-vars.outputs.e2e-node-update-separate-commands-coverage-report }} e2e-node-delete-coverage-report: ${{ needs.env-vars.outputs.e2e-node-delete-coverage-report }} e2e-node-delete-separate-commands-coverage-report: ${{ needs.env-vars.outputs.e2e-node-delete-separate-commands-coverage-report }} e2e-node-upgrade-coverage-report: ${{ needs.env-vars.outputs.e2e-node-upgrade-coverage-report }} + e2e-node-upgrade-separate-commands-coverage-report: ${{ needs.env-vars.outputs.e2e-node-upgrade-separate-commands-coverage-report }} e2e-relay-coverage-report: ${{ needs.env-vars.outputs.e2e-relay-coverage-report }} secrets: codacy-project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} diff --git a/.github/workflows/templates/config.yaml b/.github/workflows/templates/config.yaml index ea6f0e369..e995b494a 100644 --- a/.github/workflows/templates/config.yaml +++ b/.github/workflows/templates/config.yaml @@ -49,5 +49,8 @@ tests: - name: Node Upgrade mochaPostfix: "'test/e2e/commands/node_upgrade.test.ts'" + - name: Node Upgrade - Separate commands + mochaPostfix: "'test/e2e/commands/separate_node_upgrade.test.ts'" + - name: Relay mochaPostfix: "'test/e2e/commands/relay.test.ts'" diff --git a/.github/workflows/templates/template.zxc-code-analysis.yaml b/.github/workflows/templates/template.zxc-code-analysis.yaml index af222cd89..b4ad384e5 100644 --- a/.github/workflows/templates/template.zxc-code-analysis.yaml +++ b/.github/workflows/templates/template.zxc-code-analysis.yaml @@ -84,8 +84,13 @@ jobs: name: ${{ inputs.custom-job-label || 'Analyze' }} runs-on: solo-linux-medium steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + - name: Checkout Code - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ github.event.workflow_run.head_branch }} fetch-depth: ${{ inputs.enable-sonar-analysis && '0' || '' }} @@ -112,7 +117,7 @@ jobs: path: "e2e_test_report" - name: Publish E2E Test Report - uses: EnricoMi/publish-unit-test-result-action@82082dac68ad6a19d980f8ce817e108b9f496c2a # v2.17.1 + uses: EnricoMi/publish-unit-test-result-action@170bf24d20d201b842d7a52403b73ed297e6645b # v2.18.0 if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }} with: check_name: "E2E Test Report" @@ -185,7 +190,7 @@ jobs: echo "::endgroup::" - name: Publish Snyk Reports - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 if: ${{ inputs.enable-snyk-scan && !cancelled() && !failure() }} with: name: Snyk Reports diff --git a/.github/workflows/templates/template.zxc-env-vars.yaml b/.github/workflows/templates/template.zxc-env-vars.yaml index d2b3b27c8..fad4f54fe 100644 --- a/.github/workflows/templates/template.zxc-env-vars.yaml +++ b/.github/workflows/templates/template.zxc-env-vars.yaml @@ -33,6 +33,9 @@ defaults: run: shell: bash +permissions: + contents: read + jobs: env-vars: name: ${{ inputs.custom-job-label || 'Set Environment Variables' }} @@ -41,4 +44,9 @@ jobs: # {AUTOGENERATE-JOB-OUTPUTS-SUB-DIRS} # {AUTOGENERATE-JOB-OUTPUTS-COVERAGE-REPORTS} steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + - run: echo "Exposing environment variables to reusable workflows" diff --git a/.github/workflows/zxc-code-analysis.yaml b/.github/workflows/zxc-code-analysis.yaml index c49f1a8a9..d3f5532df 100644 --- a/.github/workflows/zxc-code-analysis.yaml +++ b/.github/workflows/zxc-code-analysis.yaml @@ -130,6 +130,11 @@ on: type: string required: false default: "e2e-node-upgrade" + e2e-node-upgrade-separate-commands-test-subdir: + description: "E2E Node Upgrade - Separate commands Test Subdirectory:" + type: string + required: false + default: "e2e-node-upgrade-separate-commands" e2e-relay-test-subdir: description: "E2E Relay Test Subdirectory:" type: string @@ -210,6 +215,11 @@ on: type: string required: false default: "E2E Node Upgrade Tests Coverage Report" + e2e-node-upgrade-separate-commands-coverage-report: + description: "E2E Node Upgrade - Separate commands Coverage Report:" + type: string + required: false + default: "E2E Node Upgrade - Separate commands Tests Coverage Report" e2e-relay-coverage-report: description: "E2E Relay Coverage Report:" type: string @@ -370,6 +380,13 @@ jobs: name: ${{ inputs.e2e-node-upgrade-coverage-report }} path: 'coverage/${{ inputs.e2e-node-upgrade-test-subdir }}' + - name: Download E2E Node Upgrade - Separate commands Coverage Report + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }} + with: + name: ${{ inputs.e2e-node-upgrade-separate-commands-coverage-report }} + path: 'coverage/${{ inputs.e2e-node-upgrade-separate-commands-test-subdir }}' + - name: Download E2E Relay Coverage Report uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 if: ${{ (inputs.enable-codecov-analysis || inputs.enable-codacy-coverage) && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }} diff --git a/.github/workflows/zxc-env-vars.yaml b/.github/workflows/zxc-env-vars.yaml index f9be3c72b..0ffd56cb5 100644 --- a/.github/workflows/zxc-env-vars.yaml +++ b/.github/workflows/zxc-env-vars.yaml @@ -71,6 +71,9 @@ on: e2e-node-upgrade-test-subdir: description: "E2E Node Upgrade Test Subdirectory" value: ${{ jobs.env-vars.outputs.e2e_node_upgrade_test_subdir }} + e2e-node-upgrade-separate-commands-test-subdir: + description: "E2E Node Upgrade - Separate commands Test Subdirectory" + value: ${{ jobs.env-vars.outputs.e2e_node_upgrade_separate_commands_test_subdir }} e2e-relay-test-subdir: description: "E2E Relay Test Subdirectory" value: ${{ jobs.env-vars.outputs.e2e_relay_test_subdir }} @@ -119,6 +122,9 @@ on: e2e-node-upgrade-coverage-report: description: "E2E Node Upgrade Tests Coverage Report" value: ${{ jobs.env-vars.outputs.e2e_node_upgrade_coverage_report }} + e2e-node-upgrade-separate-commands-coverage-report: + description: "E2E Node Upgrade - Separate commands Tests Coverage Report" + value: ${{ jobs.env-vars.outputs.e2e_node_upgrade_separate_commands_coverage_report }} e2e-relay-coverage-report: description: "E2E Relay Tests Coverage Report" value: ${{ jobs.env-vars.outputs.e2e_relay_coverage_report }} @@ -150,6 +156,7 @@ jobs: e2e_node_delete_test_subdir: e2e-node-delete e2e_node_delete_separate_commands_test_subdir: e2e-node-delete-separate-commands e2e_node_upgrade_test_subdir: e2e-node-upgrade + e2e_node_upgrade_separate_commands_test_subdir: e2e-node-upgrade-separate-commands e2e_relay_test_subdir: e2e-relay e2e_integration_coverage_report: "E2E Integration Tests Coverage Report" e2e_standard_coverage_report: "E2E Standard Tests Coverage Report" @@ -166,6 +173,7 @@ jobs: e2e_node_delete_coverage_report: "E2E Node Delete Tests Coverage Report" e2e_node_delete_separate_commands_coverage_report: "E2E Node Delete - Separate commands Tests Coverage Report" e2e_node_upgrade_coverage_report: "E2E Node Upgrade Tests Coverage Report" + e2e_node_upgrade_separate_commands_coverage_report: "E2E Node Upgrade - Separate commands Tests Coverage Report" e2e_relay_coverage_report: "E2E Relay Tests Coverage Report" steps: - name: Harden Runner diff --git a/package.json b/package.json index 72b73686f..414aaae4f 100644 --- a/package.json +++ b/package.json @@ -24,12 +24,13 @@ "test-e2e-node-local-ptt": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Local PTT Tests\" c8 --report-dir='coverage/e2e-node-local-ptt' mocha 'test/e2e/commands/node_local_ptt.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-local-ptt.xml", "test-e2e-node-add": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Add Tests\" c8 --report-dir='coverage/e2e-node-add' mocha 'test/e2e/commands/node_add.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-add.xml", "test-e2e-node-add-local": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Add Local Tests\" c8 --report-dir='coverage/e2e-node-add-local' mocha 'test/e2e/commands/node_add_local.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-add-local.xml", - "test-e2e-node-add-separate-commands": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Add - Separate commands Tests\" c8 --report-dir='coverage/e2e-node-add-separate-commands' mocha 'test/e2e/commands/separate_node_add*.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-add-separate-commands.xml", - "test-e2e-node-update": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Update Tests\" c8 --report-dir='coverage/e2e-node-update' mocha 'test/e2e/commands/node_update*.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-update.xml", + "test-e2e-node-add-separate-commands": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Add - Separate commands Tests\" c8 --report-dir='coverage/e2e-node-add-separate-commands' mocha 'test/e2e/commands/separate_node_add.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-add-separate-commands.xml", + "test-e2e-node-update": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Update Tests\" c8 --report-dir='coverage/e2e-node-update' mocha 'test/e2e/commands/node_update.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-update.xml", "test-e2e-node-update-separate-commands": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Update - Separate commands Tests\" c8 --report-dir='coverage/e2e-node-update-separate-commands' mocha 'test/e2e/commands/separate_node_update.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-update-separate-commands.xml", - "test-e2e-node-delete": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Delete Tests\" c8 --report-dir='coverage/e2e-node-delete' mocha 'test/e2e/commands/node_delete*.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-delete.xml", - "test-e2e-node-delete-separate-commands": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Delete - Separate commands Tests\" c8 --report-dir='coverage/e2e-node-delete-separate-commands' mocha 'test/e2e/commands/separate_node_delete*.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-delete-separate-commands.xml", - "test-e2e-node-upgrade": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Upgrade Tests\" c8 --report-dir='coverage/e2e-node-upgrade' mocha 'test/e2e/commands/node_upgrade*.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-upgrade.xml", + "test-e2e-node-delete": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Delete Tests\" c8 --report-dir='coverage/e2e-node-delete' mocha 'test/e2e/commands/node_delete.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-delete.xml", + "test-e2e-node-delete-separate-commands": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Delete - Separate commands Tests\" c8 --report-dir='coverage/e2e-node-delete-separate-commands' mocha 'test/e2e/commands/separate_node_delete.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-delete-separate-commands.xml", + "test-e2e-node-upgrade": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Upgrade Tests\" c8 --report-dir='coverage/e2e-node-upgrade' mocha 'test/e2e/commands/node_upgrade.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-upgrade.xml", + "test-e2e-node-upgrade-separate-commands": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Node Upgrade - Separate commands Tests\" c8 --report-dir='coverage/e2e-node-upgrade-separate-commands' mocha 'test/e2e/commands/separate_node_upgrade.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-node-upgrade-separate-commands.xml", "test-e2e-relay": "cross-env MOCHA_SUITE_NAME=\"Mocha E2E Relay Tests\" c8 --report-dir='coverage/e2e-relay' mocha 'test/e2e/commands/relay.test.ts' --reporter-options configFile=mocha-multi-reporter.json,cmrOutput=mocha-junit-reporter+mochaFile+junit-e2e-relay.xml", "solo-test": "tsx --no-deprecation --no-warnings solo.ts", "solo": "node --no-deprecation --no-warnings dist/solo.js", diff --git a/src/commands/flags.ts b/src/commands/flags.ts index a3c41bb88..e78d2be75 100644 --- a/src/commands/flags.ts +++ b/src/commands/flags.ts @@ -427,7 +427,7 @@ export class Flags { constName: 'upgradeZipFile', name: 'upgrade-zip-file', definition: { - describe: 'A zipped state used for network upgrade', + describe: 'A zipped file used for network upgrade', defaultValue: '', type: 'string', }, diff --git a/src/commands/node/configs.ts b/src/commands/node/configs.ts index b7ad0cae5..553df29ea 100644 --- a/src/commands/node/configs.ts +++ b/src/commands/node/configs.ts @@ -97,7 +97,6 @@ export const upgradeConfigBuilder = async function (argv, ctx, task, shouldLoadN 'podNames', 'stagingDir', 'stagingKeysDir', - 'treasuryKey', ]) as NodeUpgradeConfigClass; config.curDate = new Date(); @@ -120,11 +119,6 @@ export const upgradeConfigBuilder = async function (argv, ctx, task, shouldLoadN const accountKeys = await this.accountManager.getAccountKeysFromSecret(FREEZE_ADMIN_ACCOUNT, config.namespace); config.freezeAdminPrivateKey = accountKeys.privateKey; - - const treasuryAccount = await this.accountManager.getTreasuryAccountKeys(config.namespace); - const treasuryAccountPrivateKey = treasuryAccount.privateKey; - config.treasuryKey = PrivateKey.fromStringED25519(treasuryAccountPrivateKey); - return config; }; diff --git a/src/commands/node/handlers.ts b/src/commands/node/handlers.ts index f1b2a42c4..3367e7353 100644 --- a/src/commands/node/handlers.ts +++ b/src/commands/node/handlers.ts @@ -268,7 +268,6 @@ export class NodeCommandHandlers implements CommandHandlers { this.tasks.enablePortForwarding(), this.tasks.checkAllNodesAreActive('allNodeAliases'), this.tasks.checkAllNodeProxiesAreActive(), - this.tasks.triggerStakeWeightCalculate(NodeSubcommandType.UPDATE), this.tasks.finalize(), ]; } @@ -425,7 +424,7 @@ export class NodeCommandHandlers implements CommandHandlers { concurrent: false, rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION, }, - 'Error in executing node update', + 'Error in executing network upgrade', lease, ); diff --git a/src/commands/node/helper.ts b/src/commands/node/helper.ts index ef7cabfaa..a09d399ff 100644 --- a/src/commands/node/helper.ts +++ b/src/commands/node/helper.ts @@ -112,7 +112,6 @@ export class NodeHelper { const config = /** @type {NodeUpgradeConfigClass} **/ ctx.config; exportedCtx.adminKey = config.adminKey.toString(); exportedCtx.freezeAdminPrivateKey = config.freezeAdminPrivateKey.toString(); - exportedCtx.treasuryKey = config.treasuryKey.toString(); exportedCtx.existingNodeAliases = config.existingNodeAliases; exportedCtx.upgradeZipHash = ctx.upgradeZipHash; exportedCtx.allNodeAliases = config.allNodeAliases; @@ -131,7 +130,6 @@ export class NodeHelper { const config = ctx.config; config.freezeAdminPrivateKey = PrivateKey.fromStringED25519(ctxData.freezeAdminPrivateKey); - config.treasuryKey = PrivateKey.fromStringED25519(ctxData.treasuryKey); config.adminKey = PrivateKey.fromStringED25519(ctxData.adminKey); config.existingNodeAliases = ctxData.existingNodeAliases; config.allNodeAliases = ctxData.allNodeAliases; diff --git a/test/e2e/commands/node_upgrade.test.ts b/test/e2e/commands/node_upgrade.test.ts index 501c165eb..07467bfc3 100644 --- a/test/e2e/commands/node_upgrade.test.ts +++ b/test/e2e/commands/node_upgrade.test.ts @@ -28,7 +28,7 @@ import {Zippy} from '../../../src/core/zippy.js'; const namespace = 'node-upgrade'; const argv = getDefaultArgv(); -argv[flags.nodeAliasesUnparsed.name] = 'node1,node2,node3'; +argv[flags.nodeAliasesUnparsed.name] = 'node1'; argv[flags.generateGossipKeys.name] = true; argv[flags.generateTlsKeys.name] = true; argv[flags.persistentVolumeClaims.name] = true; @@ -51,7 +51,7 @@ e2eTestSuite(namespace, argv, undefined, undefined, undefined, undefined, undefi this.timeout(Duration.ofMinutes(10).toMillis()); await k8.getNodeLogs(namespace); - await k8.deleteNamespace(namespace); + // await k8.deleteNamespace(namespace); }); it('should succeed with init command', async () => { @@ -69,16 +69,11 @@ e2eTestSuite(namespace, argv, undefined, undefined, undefined, undefined, undefi await zipper.zip(tmpDir, zipFile); const tempDir = 'contextDir'; - const argvPrepare = Object.assign({}, argv); - argvPrepare[flags.upgradeZipFile.name] = zipFile; - argvPrepare[flags.outputDir.name] = tempDir; - const argvExecute = Object.assign({}, getDefaultArgv()); - argvExecute[flags.inputDir.name] = tempDir; - - await nodeCmd.handlers.upgradePrepare(argvPrepare); - await nodeCmd.handlers.upgradeSubmitTransactions(argvExecute); - await nodeCmd.handlers.upgradeExecute(argvExecute); + argv[flags.upgradeZipFile.name] = zipFile; + argv[flags.outputDir.name] = tempDir; + argv[flags.inputDir.name] = tempDir; + await nodeCmd.handlers.upgrade(argv); expect(nodeCmd.getUnusedConfigs(UPGRADE_CONFIGS_NAME)).to.deep.equal([ flags.devMode.constName, @@ -89,13 +84,13 @@ e2eTestSuite(namespace, argv, undefined, undefined, undefined, undefined, undefi }).timeout(Duration.ofMinutes(5).toMillis()); it('should restart all nodes on the network successfully', async () => { - // copy the VERSION.txt file from the pod data/upgrade/current directory + // copy the version.txt file from the pod data/upgrade/current directory const tmpDir = getTmpDir(); const pods = await k8.getPodsByLabel(['solo.hedera.com/type=network-node']); const podName = pods[0].metadata.name as PodName; await k8.copyFrom(podName, ROOT_CONTAINER, `${HEDERA_HAPI_PATH}/data/upgrade/current/version.txt`, tmpDir); - // compare the VERSION.txt + // compare the version.txt const version = fs.readFileSync(`${tmpDir}/version.txt`, 'utf8'); expect(version).to.equal(TEST_VERSION_STRING); }).timeout(Duration.ofMinutes(5).toMillis()); diff --git a/test/e2e/commands/separate_node_upgrade.test.ts b/test/e2e/commands/separate_node_upgrade.test.ts new file mode 100644 index 000000000..f465b7c6f --- /dev/null +++ b/test/e2e/commands/separate_node_upgrade.test.ts @@ -0,0 +1,104 @@ +/** + * Copyright (C) 2024 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the ""License""); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an ""AS IS"" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +import {it, describe, after} from 'mocha'; +import {expect} from 'chai'; + +import {Flags as flags} from '../../../src/commands/flags.js'; +import {e2eTestSuite, getDefaultArgv, getTmpDir, HEDERA_PLATFORM_VERSION_TAG} from '../../test_util.js'; +import {PREPARE_UPGRADE_CONFIGS_NAME, UPGRADE_CONFIGS_NAME} from '../../../src/commands/node/configs.js'; +import {Duration} from '../../../src/core/time/duration.js'; +import {HEDERA_HAPI_PATH, ROOT_CONTAINER} from '../../../src/core/constants.js'; +import type {PodName} from '../../../src/types/aliases.js'; +import fs from 'fs'; +import {Zippy} from '../../../src/core/zippy.js'; + +const namespace = 'node-upgrade'; +const argv = getDefaultArgv(); +argv[flags.nodeAliasesUnparsed.name] = 'node1'; +argv[flags.generateGossipKeys.name] = true; +argv[flags.generateTlsKeys.name] = true; +argv[flags.persistentVolumeClaims.name] = true; +// set the env variable SOLO_CHARTS_DIR if developer wants to use local solo charts +argv[flags.chartDirectory.name] = process.env.SOLO_CHARTS_DIR ? process.env.SOLO_CHARTS_DIR : undefined; +argv[flags.releaseTag.name] = HEDERA_PLATFORM_VERSION_TAG; +argv[flags.namespace.name] = namespace; + +const zipFile = 'upgrade.zip'; + +const TEST_VERSION_STRING = '0.100.0'; + +e2eTestSuite(namespace, argv, undefined, undefined, undefined, undefined, undefined, undefined, true, bootstrapResp => { + describe('Node upgrade', async () => { + const nodeCmd = bootstrapResp.cmd.nodeCmd; + const accountCmd = bootstrapResp.cmd.accountCmd; + const k8 = bootstrapResp.opts.k8; + + after(async function () { + this.timeout(Duration.ofMinutes(10).toMillis()); + + await k8.getNodeLogs(namespace); + // await k8.deleteNamespace(namespace); + }); + + it('should succeed with init command', async () => { + const status = await accountCmd.init(argv); + expect(status).to.be.ok; + }).timeout(Duration.ofMinutes(8).toMillis()); + + it('should prepare network upgrade successfully', async () => { + // create file version.txt at tmp directory + const tmpDir = getTmpDir(); + fs.writeFileSync(`${tmpDir}/version.txt`, TEST_VERSION_STRING); + + // create upgrade.zip file from tmp directory using zippy.ts + const zipper = new Zippy(nodeCmd.logger); + await zipper.zip(tmpDir, zipFile); + + const tempDir = 'contextDir'; + + const argvPrepare = Object.assign({}, argv); + argvPrepare[flags.upgradeZipFile.name] = zipFile; + argvPrepare[flags.outputDir.name] = tempDir; + const argvExecute = Object.assign({}, getDefaultArgv()); + argvExecute[flags.inputDir.name] = tempDir; + + await nodeCmd.handlers.upgradePrepare(argvPrepare); + await nodeCmd.handlers.upgradeSubmitTransactions(argvExecute); + await nodeCmd.handlers.upgradeExecute(argvExecute); + + expect(nodeCmd.getUnusedConfigs(UPGRADE_CONFIGS_NAME)).to.deep.equal([ + flags.devMode.constName, + flags.quiet.constName, + flags.localBuildPath.constName, + flags.force.constName, + 'nodeClient', + ]); + }).timeout(Duration.ofMinutes(5).toMillis()); + + it('should restart all nodes on the network successfully', async () => { + // copy the version.txt file from the pod data/upgrade/current directory + const tmpDir = getTmpDir(); + const pods = await k8.getPodsByLabel(['solo.hedera.com/type=network-node']); + const podName = pods[0].metadata.name as PodName; + await k8.copyFrom(podName, ROOT_CONTAINER, `${HEDERA_HAPI_PATH}/data/upgrade/current/version.txt`, tmpDir); + + // compare the version.txt + const version = fs.readFileSync(`${tmpDir}/version.txt`, 'utf8'); + expect(version).to.equal(TEST_VERSION_STRING); + }).timeout(Duration.ofMinutes(5).toMillis()); + }); +});