From 21c00098e1c45bba35535908d673d0313477f305 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 20 Dec 2023 13:30:14 +0530 Subject: [PATCH 01/37] dev-acc fix --- .github/workflows/dev-acc.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dev-acc.yml b/.github/workflows/dev-acc.yml index 8316ea06..ba5ec318 100644 --- a/.github/workflows/dev-acc.yml +++ b/.github/workflows/dev-acc.yml @@ -1,17 +1,17 @@ name: Dev Acceptance Tests -on: - # Runs every 2 days once at 3AM - # schedule: - # - cron: '0 21 */2 * *' - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - inputs: - test_case: - description: 'Enter testcase' - required: false - default: '' - type: string +# on: +# # Runs every 2 days once at 3AM +# # schedule: +# # - cron: '0 21 */2 * *' +# # Allows you to run this workflow manually from the Actions tab +# workflow_dispatch: +inputs: + test_case: + description: 'Enter testcase' + required: false + default: '' + type: string # release: # types: [published] From e68fc8b46477238af880018da1f3940952d7acad Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 20 Dec 2023 13:36:05 +0530 Subject: [PATCH 02/37] dev-acc fix --- .github/workflows/dev-acc.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dev-acc.yml b/.github/workflows/dev-acc.yml index ba5ec318..9cb94f23 100644 --- a/.github/workflows/dev-acc.yml +++ b/.github/workflows/dev-acc.yml @@ -1,17 +1,17 @@ name: Dev Acceptance Tests -# on: -# # Runs every 2 days once at 3AM -# # schedule: -# # - cron: '0 21 */2 * *' -# # Allows you to run this workflow manually from the Actions tab -# workflow_dispatch: -inputs: - test_case: - description: 'Enter testcase' - required: false - default: '' - type: string +on: + # Runs every 2 days once at 3AM + # schedule: + # - cron: '0 21 */2 * *' + # Allows you to run this workflow manually from the Actions tab + workflow_call: + inputs: + test_case: + description: 'Enter testcase' + required: false + default: '' + type: string # release: # types: [published] From 5e7255b7e13aeb42f8279c05840fccda90d4b701 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 20 Dec 2023 13:55:53 +0530 Subject: [PATCH 03/37] fix --- .github/workflows/cicd-dev-acc.yml | 2 +- .github/workflows/dev-acc.yml | 2 +- .github/workflows/reusable-dev-acc.yml | 81 ++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/reusable-dev-acc.yml diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index 962477da..9558d792 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -13,7 +13,7 @@ jobs: test-datasouces: needs: - test-provider - if: "${{ always() && needs.test-provider.result != 'failed' }}" + if: "${{ needs.test-provider.result != 'success' }}" uses: ./.github/workflows/dev-acc.yml with: test_case: TestAccDataSource diff --git a/.github/workflows/dev-acc.yml b/.github/workflows/dev-acc.yml index 9cb94f23..8316ea06 100644 --- a/.github/workflows/dev-acc.yml +++ b/.github/workflows/dev-acc.yml @@ -5,7 +5,7 @@ on: # schedule: # - cron: '0 21 */2 * *' # Allows you to run this workflow manually from the Actions tab - workflow_call: + workflow_dispatch: inputs: test_case: description: 'Enter testcase' diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml new file mode 100644 index 00000000..c3302eb2 --- /dev/null +++ b/.github/workflows/reusable-dev-acc.yml @@ -0,0 +1,81 @@ +name: Reusable Dev Acceptance Tests + +on: + # Runs every 2 days once at 3AM + # schedule: + # - cron: '0 21 */2 * *' + # Allows you to run this workflow manually from the Actions tab + workflow_call: + inputs: + test_case: + description: 'Enter testcase' + required: false + default: '' + type: string + secrets: + DEV_HPEGL_IAM_SERVICE_URL: + required: true + DEV_HPEGL_TENANT_ID: + required: true + DEV_HPEGL_USER_SECRET: + required: true + DEV_HPEGL_USER_ID: + required: true + DEV_HPEGL_VMAAS_API_URL: + required: true + DEV_HPEGL_VMAAS_LOCATION: + required: true + DEV_HPEGL_VMAAS_SPACE_NAME: + required: true + TF_ACC: + required: true + + + # release: + # types: [published] +env: + HPEGL_IAM_SERVICE_URL: ${{ secrets.DEV_HPEGL_IAM_SERVICE_URL }} + HPEGL_TENANT_ID: ${{ secrets.DEV_HPEGL_TENANT_ID }} + HPEGL_USER_SECRET: ${{ secrets.DEV_HPEGL_USER_SECRET }} + HPEGL_USER_ID: ${{ secrets.DEV_HPEGL_USER_ID }} + HPEGL_VMAAS_API_URL: ${{ secrets.DEV_HPEGL_VMAAS_API_URL }} + HPEGL_VMAAS_LOCATION: ${{ secrets.DEV_HPEGL_VMAAS_LOCATION }} + HPEGL_VMAAS_SPACE_NAME: ${{ secrets.DEV_HPEGL_VMAAS_SPACE_NAME}} + TF_ACC: ${{ secrets.TF_ACC }} + LOG_FILE: "${{ inputs.test_case }}Logs.txt" +jobs: + acc: + runs-on: ubuntu-20.04 + strategy: + matrix: + go: [ '1.17' ] + name: Dev Acceptance Tests + steps: + - name: Checkout workspace + uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.17 + - name: Install dependencies + run: | + sudo apt-get install -y wget jq + wget https://releases.hashicorp.com/terraform/1.0.0/terraform_1.0.0_linux_amd64.zip + sudo unzip -fo terraform_1.0.0_linux_amd64.zip -d /usr/local/bin + + - name: Install necessary tools + run: make tools + + - name: Run Acceptance test + run: | + echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> $LOG_FILE + export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case='${{ inputs.test_case }}' >> $LOG_FILE + + - name: Print testcases output + run: cat $LOG_FILE + + - name: Push the report to github artifacts + uses: actions/upload-artifact@v3 + with: + name: "Terraform Test report: ${{ inputs.test_case }}" + path: ${{ env.LOG_FILE }} From 6a7a7aa37800a8488fbd3d83d7d51dbc209a4d75 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 20 Dec 2023 13:57:38 +0530 Subject: [PATCH 04/37] fix --- .github/workflows/cicd-dev-acc.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index 9558d792..bfb3eec0 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -5,7 +5,7 @@ on: jobs: test-provider: - uses: ./.github/workflows/dev-acc.yml + uses: ./.github/workflows/reusable-dev-acc.yml with: test_case: TestProvider secrets: inherit @@ -14,13 +14,13 @@ jobs: needs: - test-provider if: "${{ needs.test-provider.result != 'success' }}" - uses: ./.github/workflows/dev-acc.yml + uses: ./.github/workflows/reusable-dev-acc.yml with: test_case: TestAccDataSource secrets: inherit test-vmaas-instance: - uses: ./.github/workflows/dev-acc.yml + uses: ./.github/workflows/reusable-dev-acc.yml with: test_case: TestVmaasInstance secrets: inherit From 0adcfdb44c91512772c6883ff9986d2283f7e7a5 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 20 Dec 2023 16:02:34 +0530 Subject: [PATCH 05/37] improvement --- .github/workflows/cicd-dev-acc.yml | 41 +++++++++++++++++++++++++- .github/workflows/dev-acc.yml | 4 +-- .github/workflows/reusable-dev-acc.yml | 5 ++-- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index bfb3eec0..9d057098 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -13,7 +13,7 @@ jobs: test-datasouces: needs: - test-provider - if: "${{ needs.test-provider.result != 'success' }}" + if: "${{ needs.test-provider.result == 'success' }}" uses: ./.github/workflows/reusable-dev-acc.yml with: test_case: TestAccDataSource @@ -21,6 +21,45 @@ jobs: test-vmaas-instance: uses: ./.github/workflows/reusable-dev-acc.yml + needs: + - test-datasouces + if: always() with: test_case: TestVmaasInstance secrets: inherit + + test-vmaas-resource-instance: + uses: ./.github/workflows/reusable-dev-acc.yml + needs: + - test-vmaas-instance + if: always() + with: + test_case: TestAccResourceInstance + secrets: inherit + + test-vmaas-lb: + uses: ./.github/workflows/reusable-dev-acc.yml + needs: + - test-vmaas-resource-instance + if: always() + with: + test_case: TestVmaasLB + secrets: inherit + + test-vmaas-resource-lb: + uses: ./.github/workflows/reusable-dev-acc.yml + needs: + - test-vmaas-lb + if: always() + with: + test_case: TestAccResourceLB + secrets: inherit + + test-vmaas-lb-plan: + uses: ./.github/workflows/reusable-dev-acc.yml + needs: + - test-vmaas-resource-lb + if: always() + with: + test_case: "TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate" + secrets: inherit diff --git a/.github/workflows/dev-acc.yml b/.github/workflows/dev-acc.yml index 8316ea06..bc1ec47e 100644 --- a/.github/workflows/dev-acc.yml +++ b/.github/workflows/dev-acc.yml @@ -51,7 +51,7 @@ jobs: - name: Run Acceptance test run: | echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> $LOG_FILE - export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case='${{ github.event.inputs.test_case }}' >> $LOG_FILE + for t in ${{ github.event.inputs.test_case }}; do export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case="$t" >> $LOG_FILE; done - name: Print testcases output run: cat $LOG_FILE @@ -59,5 +59,5 @@ jobs: - name: Push the report to github artifacts uses: actions/upload-artifact@v3 with: - name: "Terraform Test report: ${{ github.event.inputs.test_case }}" + name: "Terraform Test report- ${{ github.event.inputs.test_case }}" path: ${{ env.LOG_FILE }} diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index c3302eb2..8499e8d7 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -69,7 +69,8 @@ jobs: - name: Run Acceptance test run: | echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> $LOG_FILE - export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case='${{ inputs.test_case }}' >> $LOG_FILE + for t in ${{ inputs.test_case }}; do export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case="$t" >> $LOG_FILE; done + - name: Print testcases output run: cat $LOG_FILE @@ -77,5 +78,5 @@ jobs: - name: Push the report to github artifacts uses: actions/upload-artifact@v3 with: - name: "Terraform Test report: ${{ inputs.test_case }}" + name: "Terraform Test report- ${{ inputs.test_case }}" path: ${{ env.LOG_FILE }} From fae8a387848c5f932a1195966585e5fbe256cea7 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 20 Dec 2023 16:09:54 +0530 Subject: [PATCH 06/37] fix --- .github/workflows/dev-acc.yml | 4 ++-- .github/workflows/reusable-dev-acc.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dev-acc.yml b/.github/workflows/dev-acc.yml index bc1ec47e..65c8eba4 100644 --- a/.github/workflows/dev-acc.yml +++ b/.github/workflows/dev-acc.yml @@ -50,8 +50,8 @@ jobs: - name: Run Acceptance test run: | - echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> $LOG_FILE - for t in ${{ github.event.inputs.test_case }}; do export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case="$t" >> $LOG_FILE; done + echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> "$LOG_FILE" + for t in ${{ github.event.inputs.test_case }}; do export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case="$t" >> "$LOG_FILE"; done - name: Print testcases output run: cat $LOG_FILE diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 8499e8d7..5efc1137 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -68,8 +68,8 @@ jobs: - name: Run Acceptance test run: | - echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> $LOG_FILE - for t in ${{ inputs.test_case }}; do export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case="$t" >> $LOG_FILE; done + echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> "$LOG_FILE" + for t in ${{ inputs.test_case }}; do export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case="$t" >> "$LOG_FILE"; done - name: Print testcases output From 4cc650c69c2cc1a453cc873e24375f8d44e75c0d Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 20 Dec 2023 16:13:50 +0530 Subject: [PATCH 07/37] fix --- .github/workflows/dev-acc.yml | 2 +- .github/workflows/reusable-dev-acc.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev-acc.yml b/.github/workflows/dev-acc.yml index 65c8eba4..578ec8a8 100644 --- a/.github/workflows/dev-acc.yml +++ b/.github/workflows/dev-acc.yml @@ -24,7 +24,7 @@ env: HPEGL_VMAAS_LOCATION: ${{ secrets.DEV_HPEGL_VMAAS_LOCATION }} HPEGL_VMAAS_SPACE_NAME: ${{ secrets.DEV_HPEGL_VMAAS_SPACE_NAME}} TF_ACC: ${{ secrets.TF_ACC }} - LOG_FILE: "${{ github.event.inputs.test_case }}Logs.txt" + LOG_FILE: "Terraform_Logs.txt" jobs: acc: runs-on: ubuntu-20.04 diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 5efc1137..6d65f386 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -42,7 +42,7 @@ env: HPEGL_VMAAS_LOCATION: ${{ secrets.DEV_HPEGL_VMAAS_LOCATION }} HPEGL_VMAAS_SPACE_NAME: ${{ secrets.DEV_HPEGL_VMAAS_SPACE_NAME}} TF_ACC: ${{ secrets.TF_ACC }} - LOG_FILE: "${{ inputs.test_case }}Logs.txt" + LOG_FILE: "Terraform_Logs.txt" jobs: acc: runs-on: ubuntu-20.04 From bc55ea6d1bb18d03b37294f04c4997eb03db001b Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 20 Dec 2023 16:23:06 +0530 Subject: [PATCH 08/37] fix --- .github/workflows/cicd-dev-acc.yml | 28 +++++--------------------- .github/workflows/dev-acc.yml | 2 +- .github/workflows/reusable-dev-acc.yml | 2 +- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index 9d057098..98369ba3 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -25,41 +25,23 @@ jobs: - test-datasouces if: always() with: - test_case: TestVmaasInstance + test_case: TestVmaasInstance TestAccResourceInstance secrets: inherit - test-vmaas-resource-instance: - uses: ./.github/workflows/reusable-dev-acc.yml - needs: - - test-vmaas-instance - if: always() - with: - test_case: TestAccResourceInstance - secrets: inherit - test-vmaas-lb: uses: ./.github/workflows/reusable-dev-acc.yml needs: - - test-vmaas-resource-instance + - test-vmaas-instance if: always() with: - test_case: TestVmaasLB + test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate secrets: inherit - test-vmaas-resource-lb: + test-vmaas-network: uses: ./.github/workflows/reusable-dev-acc.yml needs: - test-vmaas-lb if: always() with: - test_case: TestAccResourceLB - secrets: inherit - - test-vmaas-lb-plan: - uses: ./.github/workflows/reusable-dev-acc.yml - needs: - - test-vmaas-resource-lb - if: always() - with: - test_case: "TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate" + test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier secrets: inherit diff --git a/.github/workflows/dev-acc.yml b/.github/workflows/dev-acc.yml index 578ec8a8..98f1746d 100644 --- a/.github/workflows/dev-acc.yml +++ b/.github/workflows/dev-acc.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: inputs: test_case: - description: 'Enter testcase' + description: 'Enter testcases sperated by space' required: false default: '' type: string diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 6d65f386..ce0ffd7d 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -8,7 +8,7 @@ on: workflow_call: inputs: test_case: - description: 'Enter testcase' + description: 'Enter testcases sperated by space' required: false default: '' type: string From f2d064c311d815ed3fc178c5e7242637afa94762 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 20 Dec 2023 18:31:00 +0530 Subject: [PATCH 09/37] fix --- .github/workflows/dev-acc.yml | 2 ++ .github/workflows/reusable-dev-acc.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/dev-acc.yml b/.github/workflows/dev-acc.yml index 98f1746d..cb2192ef 100644 --- a/.github/workflows/dev-acc.yml +++ b/.github/workflows/dev-acc.yml @@ -54,9 +54,11 @@ jobs: for t in ${{ github.event.inputs.test_case }}; do export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case="$t" >> "$LOG_FILE"; done - name: Print testcases output + if: always() run: cat $LOG_FILE - name: Push the report to github artifacts + if: always() uses: actions/upload-artifact@v3 with: name: "Terraform Test report- ${{ github.event.inputs.test_case }}" diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index ce0ffd7d..ece60f86 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -73,9 +73,11 @@ jobs: - name: Print testcases output + if: always() run: cat $LOG_FILE - name: Push the report to github artifacts + if: always() uses: actions/upload-artifact@v3 with: name: "Terraform Test report- ${{ inputs.test_case }}" From 7a3d88135957e85d0302dca03f9d709a0c543326 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 20 Dec 2023 19:36:17 +0530 Subject: [PATCH 10/37] fix --- .github/workflows/cicd-dev-acc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index 98369ba3..728d465f 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -13,7 +13,7 @@ jobs: test-datasouces: needs: - test-provider - if: "${{ needs.test-provider.result == 'success' }}" + if: "always() && ${{ needs.test-provider.result == 'success' }}" uses: ./.github/workflows/reusable-dev-acc.yml with: test_case: TestAccDataSource From 22883b404761fc765aceea120c235e3958c5df13 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 20 Dec 2023 19:37:07 +0530 Subject: [PATCH 11/37] nit --- .github/workflows/dev-acc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev-acc.yml b/.github/workflows/dev-acc.yml index cb2192ef..076ef9c3 100644 --- a/.github/workflows/dev-acc.yml +++ b/.github/workflows/dev-acc.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: inputs: test_case: - description: 'Enter testcases sperated by space' + description: 'Enter testcases sperated by space. Leave empty for all' required: false default: '' type: string From 15e104a51f998759819ae9d17e35d600b8851b74 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Thu, 21 Dec 2023 10:50:42 +0530 Subject: [PATCH 12/37] increase timeout --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 66bc022f..9c728d73 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,7 @@ coverage: vendor ACC_TEST_FILE_LOCATION=github.com/HewlettPackard/hpegl-vmaas-terraform-resources/internal/acceptance_test acceptance: @if [ "${case}" != "" ]; then \ - TF_ACC=true go test -run $(case) -v -timeout=2000s -cover $(ACC_TEST_FILE_LOCATION); \ + TF_ACC=true go test -run $(case) -v -timeout=20000s -cover $(ACC_TEST_FILE_LOCATION); \ else \ TF_ACC=true go test -v -timeout=50000s -cover $(ACC_TEST_FILE_LOCATION) -parallel 1;\ fi From 257f562763ed48fab41f65b2b4ec69bffd021dd5 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Thu, 21 Dec 2023 14:23:29 +0530 Subject: [PATCH 13/37] network --- .github/workflows/cicd-dev-acc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index 728d465f..a945f4e0 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -43,5 +43,5 @@ jobs: - test-vmaas-lb if: always() with: - test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier + test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan secrets: inherit From c1d4e3bc94e916713bc2e24610722ed6417bb6fc Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Tue, 2 Jan 2024 15:42:49 +0530 Subject: [PATCH 14/37] improvement --- .github/workflows/reusable-dev-acc.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index ece60f86..9436fdfb 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -69,7 +69,15 @@ jobs: - name: Run Acceptance test run: | echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> "$LOG_FILE" - for t in ${{ inputs.test_case }}; do export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case="$t" >> "$LOG_FILE"; done + JOB_FAILED=false + for t in ${{ inputs.test_case }}; do + if ! export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case="$t" >> "$LOG_FILE" + then + JOB_FAILED=true + continue + fi + done + if $JOB_FAILED; then exit 1; fi - name: Print testcases output @@ -80,5 +88,5 @@ jobs: if: always() uses: actions/upload-artifact@v3 with: - name: "Terraform Test report- ${{ inputs.test_case }}" + name: "Terraform Test report ${{ github.run_id }} - ${{ inputs.test_case }}" path: ${{ env.LOG_FILE }} From 7b9b70f29322cd16249641f5a190f4b12d1ca37e Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Tue, 2 Jan 2024 15:50:04 +0530 Subject: [PATCH 15/37] fix --- .github/workflows/reusable-dev-acc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 9436fdfb..1f40bc6f 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -71,7 +71,7 @@ jobs: echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> "$LOG_FILE" JOB_FAILED=false for t in ${{ inputs.test_case }}; do - if ! export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case="$t" >> "$LOG_FILE" + if ! (export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case="$t" >> "$LOG_FILE") then JOB_FAILED=true continue From 42769ed774064dbeec5f0247e45f706881230a56 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 10:12:27 +0530 Subject: [PATCH 16/37] artifact name improvement --- .github/workflows/cicd-dev-acc.yml | 5 +++++ .github/workflows/reusable-dev-acc.yml | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index a945f4e0..e2b3ea26 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -8,6 +8,7 @@ jobs: uses: ./.github/workflows/reusable-dev-acc.yml with: test_case: TestProvider + test_description: Check for valid terraform provider secrets: inherit test-datasouces: @@ -17,6 +18,7 @@ jobs: uses: ./.github/workflows/reusable-dev-acc.yml with: test_case: TestAccDataSource + test_description: All data source test secrets: inherit test-vmaas-instance: @@ -26,6 +28,7 @@ jobs: if: always() with: test_case: TestVmaasInstance TestAccResourceInstance + test_description: Instance test secrets: inherit test-vmaas-lb: @@ -35,6 +38,7 @@ jobs: if: always() with: test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate + test_description: Loadbalancer test secrets: inherit test-vmaas-network: @@ -44,4 +48,5 @@ jobs: if: always() with: test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan + test_description: Network test secrets: inherit diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 1f40bc6f..601c78ef 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -12,6 +12,11 @@ on: required: false default: '' type: string + test_description: + description: 'Enter description for the testcases' + required: true + default: '' + type: string secrets: DEV_HPEGL_IAM_SERVICE_URL: required: true @@ -42,7 +47,7 @@ env: HPEGL_VMAAS_LOCATION: ${{ secrets.DEV_HPEGL_VMAAS_LOCATION }} HPEGL_VMAAS_SPACE_NAME: ${{ secrets.DEV_HPEGL_VMAAS_SPACE_NAME}} TF_ACC: ${{ secrets.TF_ACC }} - LOG_FILE: "Terraform_Logs.txt" + LOG_FILE: "Terraform Log.txt" jobs: acc: runs-on: ubuntu-20.04 @@ -88,5 +93,5 @@ jobs: if: always() uses: actions/upload-artifact@v3 with: - name: "Terraform Test report ${{ github.run_id }} - ${{ inputs.test_case }}" + name: "IaC Test Report - ${{ inputs.test_description }}" path: ${{ env.LOG_FILE }} From 82a565c073c284eb7b910d666c91e84549ae92ec Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 10:25:30 +0530 Subject: [PATCH 17/37] test --- .github/workflows/reusable-dev-acc.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 601c78ef..f91aa649 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -1,10 +1,6 @@ name: Reusable Dev Acceptance Tests on: - # Runs every 2 days once at 3AM - # schedule: - # - cron: '0 21 */2 * *' - # Allows you to run this workflow manually from the Actions tab workflow_call: inputs: test_case: @@ -47,7 +43,7 @@ env: HPEGL_VMAAS_LOCATION: ${{ secrets.DEV_HPEGL_VMAAS_LOCATION }} HPEGL_VMAAS_SPACE_NAME: ${{ secrets.DEV_HPEGL_VMAAS_SPACE_NAME}} TF_ACC: ${{ secrets.TF_ACC }} - LOG_FILE: "Terraform Log.txt" + LOG_FILE: "${{ github.event.inputs.test_case }}Terraform Log.txt" jobs: acc: runs-on: ubuntu-20.04 @@ -73,6 +69,7 @@ jobs: - name: Run Acceptance test run: | + echo $LOG_FILE echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> "$LOG_FILE" JOB_FAILED=false for t in ${{ inputs.test_case }}; do From 41b71a97d27d504c46a410ba9ce5d6a2600e2473 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 10:30:05 +0530 Subject: [PATCH 18/37] improvement --- .github/workflows/cicd-dev-acc.yml | 6 +++--- .github/workflows/reusable-dev-acc.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index e2b3ea26..26e73226 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -25,7 +25,7 @@ jobs: uses: ./.github/workflows/reusable-dev-acc.yml needs: - test-datasouces - if: always() + if: "always() && ${{ needs.test-provider.result == 'success' }}" with: test_case: TestVmaasInstance TestAccResourceInstance test_description: Instance test @@ -35,7 +35,7 @@ jobs: uses: ./.github/workflows/reusable-dev-acc.yml needs: - test-vmaas-instance - if: always() + if: "always() && ${{ needs.test-provider.result == 'success' }}" with: test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate test_description: Loadbalancer test @@ -45,7 +45,7 @@ jobs: uses: ./.github/workflows/reusable-dev-acc.yml needs: - test-vmaas-lb - if: always() + if: "always() && ${{ needs.test-provider.result == 'success' }}" with: test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan test_description: Network test diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index f91aa649..758d201d 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -43,7 +43,7 @@ env: HPEGL_VMAAS_LOCATION: ${{ secrets.DEV_HPEGL_VMAAS_LOCATION }} HPEGL_VMAAS_SPACE_NAME: ${{ secrets.DEV_HPEGL_VMAAS_SPACE_NAME}} TF_ACC: ${{ secrets.TF_ACC }} - LOG_FILE: "${{ github.event.inputs.test_case }}Terraform Log.txt" + LOG_FILE: "${{ inputs.test_case }}Terraform Log.txt" jobs: acc: runs-on: ubuntu-20.04 From 6203318b13ca45c7a984754da61d52d8a8753c6d Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 10:33:56 +0530 Subject: [PATCH 19/37] improvement --- .github/workflows/reusable-dev-acc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 758d201d..338fc5f7 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -43,7 +43,7 @@ env: HPEGL_VMAAS_LOCATION: ${{ secrets.DEV_HPEGL_VMAAS_LOCATION }} HPEGL_VMAAS_SPACE_NAME: ${{ secrets.DEV_HPEGL_VMAAS_SPACE_NAME}} TF_ACC: ${{ secrets.TF_ACC }} - LOG_FILE: "${{ inputs.test_case }}Terraform Log.txt" + LOG_FILE: "Terraform Log - ${{ inputs.test_description }}.txt" jobs: acc: runs-on: ubuntu-20.04 From 15391c79a493021010d998428c5734a34b84a225 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 10:44:40 +0530 Subject: [PATCH 20/37] update versions --- .github/workflows/cicd-dev-acc.yml | 8 ++++---- .github/workflows/reusable-dev-acc.yml | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index 26e73226..41004ebb 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -14,7 +14,7 @@ jobs: test-datasouces: needs: - test-provider - if: "always() && ${{ needs.test-provider.result == 'success' }}" + if: "${{ needs.test-provider.result == 'success' }}" uses: ./.github/workflows/reusable-dev-acc.yml with: test_case: TestAccDataSource @@ -25,7 +25,7 @@ jobs: uses: ./.github/workflows/reusable-dev-acc.yml needs: - test-datasouces - if: "always() && ${{ needs.test-provider.result == 'success' }}" + if: "${{ needs.test-provider.result == 'success' }}" with: test_case: TestVmaasInstance TestAccResourceInstance test_description: Instance test @@ -35,7 +35,7 @@ jobs: uses: ./.github/workflows/reusable-dev-acc.yml needs: - test-vmaas-instance - if: "always() && ${{ needs.test-provider.result == 'success' }}" + if: "${{ needs.test-provider.result == 'success' }}" with: test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate test_description: Loadbalancer test @@ -45,7 +45,7 @@ jobs: uses: ./.github/workflows/reusable-dev-acc.yml needs: - test-vmaas-lb - if: "always() && ${{ needs.test-provider.result == 'success' }}" + if: "${{ needs.test-provider.result == 'success' }}" with: test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan test_description: Network test diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 338fc5f7..13f90aba 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -9,7 +9,7 @@ on: default: '' type: string test_description: - description: 'Enter description for the testcases' + description: 'Enter description for the test' required: true default: '' type: string @@ -53,9 +53,9 @@ jobs: name: Dev Acceptance Tests steps: - name: Checkout workspace - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: 1.17 - name: Install dependencies @@ -69,7 +69,6 @@ jobs: - name: Run Acceptance test run: | - echo $LOG_FILE echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> "$LOG_FILE" JOB_FAILED=false for t in ${{ inputs.test_case }}; do @@ -88,7 +87,7 @@ jobs: - name: Push the report to github artifacts if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: "IaC Test Report - ${{ inputs.test_description }}" path: ${{ env.LOG_FILE }} From 4edc258fffef41576d6f9a789c9628e7353ab712 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 10:47:14 +0530 Subject: [PATCH 21/37] fix --- .github/workflows/reusable-dev-acc.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 13f90aba..e66ba038 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -83,11 +83,11 @@ jobs: - name: Print testcases output if: always() - run: cat $LOG_FILE + run: cat "$LOG_FILE" - name: Push the report to github artifacts if: always() uses: actions/upload-artifact@v4 with: name: "IaC Test Report - ${{ inputs.test_description }}" - path: ${{ env.LOG_FILE }} + path: "${{ env.LOG_FILE }}" From 74127d7a5be9055411ff5b8af584d73e8c30057a Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 13:41:40 +0530 Subject: [PATCH 22/37] parse logs --- .github/parse_logs.py | 30 ++++++++++++++++++++++++++++++ .github/workflows/cicd-dev-acc.yml | 23 +++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 .github/parse_logs.py diff --git a/.github/parse_logs.py b/.github/parse_logs.py new file mode 100644 index 00000000..dc57ac1d --- /dev/null +++ b/.github/parse_logs.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +# (C) Copyright 2024 Hewlett Packard Enterprise Development LP + +import os +import sys + + +def main(args): + n = len(args) + print(args) + if n != 2: + print("Pass the log directory") + return 1 + log_path = args[1] + file_content = '' + for x in os.listdir(log_path): + if x.endswith(".txt"): + with open(os.path.join(log_path, x)) as f: + file_content += (f.read()) + test_count = file_content.count('RUN') + pass_count = file_content.count('PASS:') + fail_count = file_content.count('FAIL:') + print( + f"\nTestcases Ran: {test_count}\n" + f"Testcases Passed: {pass_count}\n" + f"Testcases Failed: {fail_count}\n") + return 0 + +if __name__ == "__main__": + exit(main(sys.argv)) diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index 41004ebb..3854db81 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -50,3 +50,26 @@ jobs: test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan test_description: Network test secrets: inherit + + process-logs: + runs-on: ubuntu-20.04 + needs: + - test-vmaas-network + if: "always()" + steps: + - name: Checkout workspace + uses: actions/checkout@v4 + - name: Download logs + id: logs + uses: actions/download-artifact@v4 + with: + path: tmp/artifacts + merge-multiple: true + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Print Result and Publish + run: | + LOG_RESULT=$(python .github/parse_logs.py '${{ steps.logs.outputs.download-path }}') + echo $LOG_RESULT From a442f55c2e549cc6cc01e4239b146ff545c1432f Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 13:42:31 +0530 Subject: [PATCH 23/37] testing --- .github/workflows/cicd-dev-acc.yml | 74 +++++++++++++++--------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index 3854db81..b376afa7 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -11,50 +11,50 @@ jobs: test_description: Check for valid terraform provider secrets: inherit - test-datasouces: - needs: - - test-provider - if: "${{ needs.test-provider.result == 'success' }}" - uses: ./.github/workflows/reusable-dev-acc.yml - with: - test_case: TestAccDataSource - test_description: All data source test - secrets: inherit + # test-datasouces: + # needs: + # - test-provider + # if: "${{ needs.test-provider.result == 'success' }}" + # uses: ./.github/workflows/reusable-dev-acc.yml + # with: + # test_case: TestAccDataSource + # test_description: All data source test + # secrets: inherit - test-vmaas-instance: - uses: ./.github/workflows/reusable-dev-acc.yml - needs: - - test-datasouces - if: "${{ needs.test-provider.result == 'success' }}" - with: - test_case: TestVmaasInstance TestAccResourceInstance - test_description: Instance test - secrets: inherit + # test-vmaas-instance: + # uses: ./.github/workflows/reusable-dev-acc.yml + # needs: + # - test-datasouces + # if: "${{ needs.test-provider.result == 'success' }}" + # with: + # test_case: TestVmaasInstance TestAccResourceInstance + # test_description: Instance test + # secrets: inherit - test-vmaas-lb: - uses: ./.github/workflows/reusable-dev-acc.yml - needs: - - test-vmaas-instance - if: "${{ needs.test-provider.result == 'success' }}" - with: - test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate - test_description: Loadbalancer test - secrets: inherit + # test-vmaas-lb: + # uses: ./.github/workflows/reusable-dev-acc.yml + # needs: + # - test-vmaas-instance + # if: "${{ needs.test-provider.result == 'success' }}" + # with: + # test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate + # test_description: Loadbalancer test + # secrets: inherit - test-vmaas-network: - uses: ./.github/workflows/reusable-dev-acc.yml - needs: - - test-vmaas-lb - if: "${{ needs.test-provider.result == 'success' }}" - with: - test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan - test_description: Network test - secrets: inherit + # test-vmaas-network: + # uses: ./.github/workflows/reusable-dev-acc.yml + # needs: + # - test-vmaas-lb + # if: "${{ needs.test-provider.result == 'success' }}" + # with: + # test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan + # test_description: Network test + # secrets: inherit process-logs: runs-on: ubuntu-20.04 needs: - - test-vmaas-network + - test-provider if: "always()" steps: - name: Checkout workspace From 59327f67f9663e0dce2f380825578f0dfd96cbd8 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 13:56:28 +0530 Subject: [PATCH 24/37] undo test --- .github/parse_logs.py | 7 ++- .github/workflows/cicd-dev-acc.yml | 74 +++++++++++++++--------------- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/.github/parse_logs.py b/.github/parse_logs.py index dc57ac1d..992e2b6a 100644 --- a/.github/parse_logs.py +++ b/.github/parse_logs.py @@ -7,7 +7,6 @@ def main(args): n = len(args) - print(args) if n != 2: print("Pass the log directory") return 1 @@ -21,9 +20,9 @@ def main(args): pass_count = file_content.count('PASS:') fail_count = file_content.count('FAIL:') print( - f"\nTestcases Ran: {test_count}\n" - f"Testcases Passed: {pass_count}\n" - f"Testcases Failed: {fail_count}\n") + f"\nTestcases Ran: {test_count}; " + f"Testcases Passed: {pass_count}; " + f"Testcases Failed: {fail_count}; ") return 0 if __name__ == "__main__": diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index b376afa7..3d0d093e 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -11,50 +11,50 @@ jobs: test_description: Check for valid terraform provider secrets: inherit - # test-datasouces: - # needs: - # - test-provider - # if: "${{ needs.test-provider.result == 'success' }}" - # uses: ./.github/workflows/reusable-dev-acc.yml - # with: - # test_case: TestAccDataSource - # test_description: All data source test - # secrets: inherit + test-datasouces: + needs: + - test-provider + if: "always() && ${{ needs.test-provider.result == 'success' }}" + uses: ./.github/workflows/reusable-dev-acc.yml + with: + test_case: TestAccDataSource + test_description: All data source test + secrets: inherit - # test-vmaas-instance: - # uses: ./.github/workflows/reusable-dev-acc.yml - # needs: - # - test-datasouces - # if: "${{ needs.test-provider.result == 'success' }}" - # with: - # test_case: TestVmaasInstance TestAccResourceInstance - # test_description: Instance test - # secrets: inherit + test-vmaas-instance: + uses: ./.github/workflows/reusable-dev-acc.yml + needs: + - test-datasouces + if: "always() && ${{ needs.test-provider.result == 'success' }}" + with: + test_case: TestVmaasInstance TestAccResourceInstance + test_description: Instance test + secrets: inherit - # test-vmaas-lb: - # uses: ./.github/workflows/reusable-dev-acc.yml - # needs: - # - test-vmaas-instance - # if: "${{ needs.test-provider.result == 'success' }}" - # with: - # test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate - # test_description: Loadbalancer test - # secrets: inherit + test-vmaas-lb: + uses: ./.github/workflows/reusable-dev-acc.yml + needs: + - test-vmaas-instance + if: "always() && ${{ needs.test-provider.result == 'success' }}" + with: + test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate + test_description: Loadbalancer test + secrets: inherit - # test-vmaas-network: - # uses: ./.github/workflows/reusable-dev-acc.yml - # needs: - # - test-vmaas-lb - # if: "${{ needs.test-provider.result == 'success' }}" - # with: - # test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan - # test_description: Network test - # secrets: inherit + test-vmaas-network: + uses: ./.github/workflows/reusable-dev-acc.yml + needs: + - test-vmaas-lb + if: "always() && ${{ needs.test-provider.result == 'success' }}" + with: + test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan + test_description: Network test + secrets: inherit process-logs: runs-on: ubuntu-20.04 needs: - - test-provider + - test-vmaas-network if: "always()" steps: - name: Checkout workspace From c015abb5df2c38065b9915a7d5464d06891c09c5 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 15:42:42 +0530 Subject: [PATCH 25/37] remove duplication --- .github/workflows/acc.yml | 65 ++++++++++-------------- .github/workflows/cicd-dev-acc.yml | 14 ++---- .github/workflows/dev-acc.yml | 70 ++++++++------------------ .github/workflows/reusable-dev-acc.yml | 12 +++-- 4 files changed, 58 insertions(+), 103 deletions(-) diff --git a/.github/workflows/acc.yml b/.github/workflows/acc.yml index f7edd6a6..b861ae4f 100644 --- a/.github/workflows/acc.yml +++ b/.github/workflows/acc.yml @@ -7,46 +7,33 @@ on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: inputs: - logLevel: - description: 'Log level' + test_case: + description: 'Enter testcases sperated by space. Leave empty for all' + required: false + default: '' + type: string + test_description: + description: 'Enter description for the test' required: true - default: 'warning' - tags: - description: 'Test scenario tags' + default: 'Check all Terraform Testcases' + type: string + release: types: [published] -env: - HPEGL_IAM_SERVICE_URL: ${{ secrets.HPEGL_IAM_SERVICE_URL }} - HPEGL_TENANT_ID: ${{ secrets.HPEGL_TENANT_ID }} - HPEGL_USER_SECRET: ${{ secrets.HPEGL_USER_SECRET }} - HPEGL_USER_ID: ${{ secrets.HPEGL_USER_ID }} - HPEGL_VMAAS_API_URL: ${{ secrets.HPEGL_VMAAS_API_URL }} - HPEGL_VMAAS_LOCATION: ${{ secrets.HPEGL_VMAAS_LOCATION }} - HPEGL_VMAAS_SPACE_NAME: ${{ secrets.HPEGL_VMAAS_SPACE_NAME}} - TF_ACC: ${{ secrets.TF_ACC }} -jobs: - acc: - runs-on: ubuntu-20.04 - strategy: - matrix: - go: [ '1.17' ] - name: Acceptance Tests - steps: - - name: Checkout workspace - uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.17 - - name: Install dependencies - run: | - sudo apt-get install -y wget jq - wget https://releases.hashicorp.com/terraform/1.0.0/terraform_1.0.0_linux_amd64.zip - sudo unzip -fo terraform_1.0.0_linux_amd64.zip -d /usr/local/bin - - name: Install necessary tools - run: make tools - - - name: Run Acceptance test - run: | - make acceptance \ No newline at end of file +jobs: + acc-test: + uses: ./.github/workflows/reusable-dev-acc.yml + with: + test_case: ${{ inputs.test_case }} + test_description: ${{ inputs.test_description }} + test_case_folder: 'acc-testcases' + secrets: + DEV_HPEGL_IAM_SERVICE_URL: ${{ secrets.HPEGL_IAM_SERVICE_URL }} + DEV_HPEGL_TENANT_ID: ${{ secrets.HPEGL_TENANT_ID }} + DEV_HPEGL_USER_SECRET: ${{ secrets.HPEGL_USER_SECRET }} + DEV_HPEGL_USER_ID: ${{ secrets.HPEGL_USER_ID }} + DEV_HPEGL_VMAAS_API_URL: ${{ secrets.HPEGL_VMAAS_API_URL }} + DEV_HPEGL_VMAAS_LOCATION: ${{ secrets.HPEGL_VMAAS_LOCATION }} + DEV_HPEGL_VMAAS_SPACE_NAME: ${{ secrets.HPEGL_VMAAS_SPACE_NAME}} + TF_ACC: ${{ secrets.TF_ACC }} diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index 3d0d093e..fcbe6a6b 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -1,4 +1,4 @@ -name: Dev Acceptance Tests for CI CD +name: IaC Acceptance Tests for CI CD Dev Environment on: workflow_dispatch: @@ -12,8 +12,7 @@ jobs: secrets: inherit test-datasouces: - needs: - - test-provider + needs: [test-provider] if: "always() && ${{ needs.test-provider.result == 'success' }}" uses: ./.github/workflows/reusable-dev-acc.yml with: @@ -23,8 +22,7 @@ jobs: test-vmaas-instance: uses: ./.github/workflows/reusable-dev-acc.yml - needs: - - test-datasouces + needs: [test-provider, test-datasouces] if: "always() && ${{ needs.test-provider.result == 'success' }}" with: test_case: TestVmaasInstance TestAccResourceInstance @@ -33,8 +31,7 @@ jobs: test-vmaas-lb: uses: ./.github/workflows/reusable-dev-acc.yml - needs: - - test-vmaas-instance + needs: [test-provider, test-vmaas-instance] if: "always() && ${{ needs.test-provider.result == 'success' }}" with: test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate @@ -43,8 +40,7 @@ jobs: test-vmaas-network: uses: ./.github/workflows/reusable-dev-acc.yml - needs: - - test-vmaas-lb + needs: [test-provider, test-vmaas-lb] if: "always() && ${{ needs.test-provider.result == 'success' }}" with: test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan diff --git a/.github/workflows/dev-acc.yml b/.github/workflows/dev-acc.yml index 076ef9c3..c3264d27 100644 --- a/.github/workflows/dev-acc.yml +++ b/.github/workflows/dev-acc.yml @@ -1,4 +1,4 @@ -name: Dev Acceptance Tests +name: Dev Acceptance Testing for running an individual or all tests on: # Runs every 2 days once at 3AM @@ -12,54 +12,24 @@ on: required: false default: '' type: string + test_description: + description: 'Enter description for the test' + required: true + default: 'Check all Terraform Dev Testcases' + type: string - # release: - # types: [published] -env: - HPEGL_IAM_SERVICE_URL: ${{ secrets.DEV_HPEGL_IAM_SERVICE_URL }} - HPEGL_TENANT_ID: ${{ secrets.DEV_HPEGL_TENANT_ID }} - HPEGL_USER_SECRET: ${{ secrets.DEV_HPEGL_USER_SECRET }} - HPEGL_USER_ID: ${{ secrets.DEV_HPEGL_USER_ID }} - HPEGL_VMAAS_API_URL: ${{ secrets.DEV_HPEGL_VMAAS_API_URL }} - HPEGL_VMAAS_LOCATION: ${{ secrets.DEV_HPEGL_VMAAS_LOCATION }} - HPEGL_VMAAS_SPACE_NAME: ${{ secrets.DEV_HPEGL_VMAAS_SPACE_NAME}} - TF_ACC: ${{ secrets.TF_ACC }} - LOG_FILE: "Terraform_Logs.txt" jobs: - acc: - runs-on: ubuntu-20.04 - strategy: - matrix: - go: [ '1.17' ] - name: Dev Acceptance Tests - steps: - - name: Checkout workspace - uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.17 - - name: Install dependencies - run: | - sudo apt-get install -y wget jq - wget https://releases.hashicorp.com/terraform/1.0.0/terraform_1.0.0_linux_amd64.zip - sudo unzip -fo terraform_1.0.0_linux_amd64.zip -d /usr/local/bin - - - name: Install necessary tools - run: make tools - - - name: Run Acceptance test - run: | - echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> "$LOG_FILE" - for t in ${{ github.event.inputs.test_case }}; do export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case="$t" >> "$LOG_FILE"; done - - - name: Print testcases output - if: always() - run: cat $LOG_FILE - - - name: Push the report to github artifacts - if: always() - uses: actions/upload-artifact@v3 - with: - name: "Terraform Test report- ${{ github.event.inputs.test_case }}" - path: ${{ env.LOG_FILE }} + acc-test: + uses: ./.github/workflows/reusable-dev-acc.yml + with: + test_case: ${{ inputs.test_case }} + test_description: ${{ inputs.test_description }} + secrets: + DEV_HPEGL_IAM_SERVICE_URL: ${{ secrets.DEV_HPEGL_IAM_SERVICE_URL }} + DEV_HPEGL_TENANT_ID: ${{ secrets.DEV_HPEGL_TENANT_ID }} + DEV_HPEGL_USER_SECRET: ${{ secrets.DEV_HPEGL_USER_SECRET }} + DEV_HPEGL_USER_ID: ${{ secrets.DEV_HPEGL_USER_ID }} + DEV_HPEGL_VMAAS_API_URL: ${{ secrets.DEV_HPEGL_VMAAS_API_URL }} + DEV_HPEGL_VMAAS_LOCATION: ${{ secrets.DEV_HPEGL_VMAAS_LOCATION }} + DEV_HPEGL_VMAAS_SPACE_NAME: ${{ secrets.DEV_HPEGL_VMAAS_SPACE_NAME}} + TF_ACC: ${{ secrets.TF_ACC }} diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index e66ba038..373e4e09 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -1,4 +1,4 @@ -name: Reusable Dev Acceptance Tests +name: Reusable Worflow for running Acceptance Tests. By default handles dev testing. on: workflow_call: @@ -13,6 +13,11 @@ on: required: true default: '' type: string + test_case_folder: + description: 'Enter folder for test suite' + required: false + default: 'acc-dev-testcases' + type: string secrets: DEV_HPEGL_IAM_SERVICE_URL: required: true @@ -31,9 +36,6 @@ on: TF_ACC: required: true - - # release: - # types: [published] env: HPEGL_IAM_SERVICE_URL: ${{ secrets.DEV_HPEGL_IAM_SERVICE_URL }} HPEGL_TENANT_ID: ${{ secrets.DEV_HPEGL_TENANT_ID }} @@ -72,7 +74,7 @@ jobs: echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> "$LOG_FILE" JOB_FAILED=false for t in ${{ inputs.test_case }}; do - if ! (export TF_ACC_TEST_PATH="$(pwd)/acc-dev-testcases" && make acceptance case="$t" >> "$LOG_FILE") + if ! (export TF_ACC_TEST_PATH="$(pwd)/${{ inputs.test_case_folder }}" && make acceptance case="$t" >> "$LOG_FILE") then JOB_FAILED=true continue From a7dbb2a2ae7df755dcd88add38295d0177ef31ed Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Tue, 2 Jan 2024 15:42:49 +0530 Subject: [PATCH 26/37] improvement --- .github/workflows/reusable-dev-acc.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 373e4e09..ba33f79e 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -91,5 +91,10 @@ jobs: if: always() uses: actions/upload-artifact@v4 with: +<<<<<<< HEAD name: "IaC Test Report - ${{ inputs.test_description }}" path: "${{ env.LOG_FILE }}" +======= + name: "Terraform Test report ${{ github.run_id }} - ${{ inputs.test_case }}" + path: ${{ env.LOG_FILE }} +>>>>>>> b0396e9 (improvement) From 6bc75e5bda53c751cf93f5d4629a658fe39a8d89 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 15:48:37 +0530 Subject: [PATCH 27/37] name fix --- .github/workflows/reusable-dev-acc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index ba33f79e..2be70618 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -52,7 +52,7 @@ jobs: strategy: matrix: go: [ '1.17' ] - name: Dev Acceptance Tests + name: Acceptance Test Job steps: - name: Checkout workspace uses: actions/checkout@v4 From b7f87acd989e8deddfebaec951033e43dea312fa Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 15:52:00 +0530 Subject: [PATCH 28/37] improvement --- .github/workflows/reusable-dev-acc.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 2be70618..295d607e 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -91,10 +91,5 @@ jobs: if: always() uses: actions/upload-artifact@v4 with: -<<<<<<< HEAD name: "IaC Test Report - ${{ inputs.test_description }}" path: "${{ env.LOG_FILE }}" -======= - name: "Terraform Test report ${{ github.run_id }} - ${{ inputs.test_case }}" - path: ${{ env.LOG_FILE }} ->>>>>>> b0396e9 (improvement) From e0c13d1460e2c50841e667ad5fd83eef9876ce6d Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 16:04:55 +0530 Subject: [PATCH 29/37] network type --- acc-testcases/data-sources/network_type.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acc-testcases/data-sources/network_type.yaml b/acc-testcases/data-sources/network_type.yaml index 2352509b..733a3ef0 100644 --- a/acc-testcases/data-sources/network_type.yaml +++ b/acc-testcases/data-sources/network_type.yaml @@ -1,3 +1,3 @@ acc: - config: | - name = "NSX Segment" + name = "NSX-T Segment" From ef484404bad4c7543b319b94e83420cd5d977031 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 16:11:52 +0530 Subject: [PATCH 30/37] undo network type --- acc-testcases/data-sources/network_type.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acc-testcases/data-sources/network_type.yaml b/acc-testcases/data-sources/network_type.yaml index 733a3ef0..2352509b 100644 --- a/acc-testcases/data-sources/network_type.yaml +++ b/acc-testcases/data-sources/network_type.yaml @@ -1,3 +1,3 @@ acc: - config: | - name = "NSX-T Segment" + name = "NSX Segment" From 99ea557137fc9c836b50125f20c9bc617d0facd7 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 16:35:23 +0530 Subject: [PATCH 31/37] added ci job for prod --- .github/workflows/cicd-prod-acc.yml | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/cicd-prod-acc.yml diff --git a/.github/workflows/cicd-prod-acc.yml b/.github/workflows/cicd-prod-acc.yml new file mode 100644 index 00000000..5d1f86dc --- /dev/null +++ b/.github/workflows/cicd-prod-acc.yml @@ -0,0 +1,43 @@ +name: IaC Acceptance Tests for CI CD Prod Environment + +on: + workflow_dispatch: + +jobs: + acc-test: + uses: ./.github/workflows/reusable-dev-acc.yml + with: + test_description: Check all Terraform Testcases + test_case_folder: 'acc-testcases' + secrets: + DEV_HPEGL_IAM_SERVICE_URL: ${{ secrets.HPEGL_IAM_SERVICE_URL }} + DEV_HPEGL_TENANT_ID: ${{ secrets.HPEGL_TENANT_ID }} + DEV_HPEGL_USER_SECRET: ${{ secrets.HPEGL_USER_SECRET }} + DEV_HPEGL_USER_ID: ${{ secrets.HPEGL_USER_ID }} + DEV_HPEGL_VMAAS_API_URL: ${{ secrets.HPEGL_VMAAS_API_URL }} + DEV_HPEGL_VMAAS_LOCATION: ${{ secrets.HPEGL_VMAAS_LOCATION }} + DEV_HPEGL_VMAAS_SPACE_NAME: ${{ secrets.HPEGL_VMAAS_SPACE_NAME}} + TF_ACC: ${{ secrets.TF_ACC }} + + process-logs: + runs-on: ubuntu-20.04 + needs: + - acc-test + if: "always()" + steps: + - name: Checkout workspace + uses: actions/checkout@v4 + - name: Download logs + id: logs + uses: actions/download-artifact@v4 + with: + path: tmp/artifacts + merge-multiple: true + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Print Result and Publish + run: | + LOG_RESULT=$(python .github/parse_logs.py '${{ steps.logs.outputs.download-path }}') + echo $LOG_RESULT \ No newline at end of file From 79a24a6a5ba01abdaf9b61156ca139b5ba0790d1 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 17:01:16 +0530 Subject: [PATCH 32/37] improvement --- .github/workflows/cicd-dev-acc.yml | 1 + .github/workflows/dev-acc.yml | 12 +++++++----- .github/workflows/reusable-dev-acc.yml | 20 ++++++++++++-------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index fcbe6a6b..f6d2e9b0 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -1,4 +1,5 @@ name: IaC Acceptance Tests for CI CD Dev Environment +# This workflow runs all the acc-dev-testcases on: workflow_dispatch: diff --git a/.github/workflows/dev-acc.yml b/.github/workflows/dev-acc.yml index c3264d27..2a695e35 100644 --- a/.github/workflows/dev-acc.yml +++ b/.github/workflows/dev-acc.yml @@ -1,4 +1,6 @@ -name: Dev Acceptance Testing for running an individual or all tests +name: Dev Acceptance Testing +# This workflow is intended to run a particular set of testcases +# If want to execute all test, consider running cicd-dev-acc.yml on: # Runs every 2 days once at 3AM @@ -8,14 +10,14 @@ on: workflow_dispatch: inputs: test_case: - description: 'Enter testcases sperated by space. Leave empty for all' - required: false - default: '' + description: 'Enter testcases sperated by space' + required: true + default: 'TestProvider' type: string test_description: description: 'Enter description for the test' required: true - default: 'Check all Terraform Dev Testcases' + default: 'Check Terraform Dev Testcase' type: string jobs: diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 295d607e..f202b0d7 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -73,14 +73,18 @@ jobs: run: | echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> "$LOG_FILE" JOB_FAILED=false - for t in ${{ inputs.test_case }}; do - if ! (export TF_ACC_TEST_PATH="$(pwd)/${{ inputs.test_case_folder }}" && make acceptance case="$t" >> "$LOG_FILE") - then - JOB_FAILED=true - continue - fi - done - if $JOB_FAILED; then exit 1; fi + if [ ${{ inputs.test_case }} != "" ]; then + for t in ${{ inputs.test_case }}; do + if ! (export TF_ACC_TEST_PATH="$(pwd)/${{ inputs.test_case_folder }}" && make acceptance case="$t" >> "$LOG_FILE") + then + JOB_FAILED=true + continue + fi + done + if $JOB_FAILED; then exit 1; fi + else + export TF_ACC_TEST_PATH="$(pwd)/${{ inputs.test_case_folder }}" && make acceptance >> "$LOG_FILE" + fi - name: Print testcases output From b016658ce15773b6ccee89457708d4828d118d1f Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 17:09:37 +0530 Subject: [PATCH 33/37] fix --- .github/workflows/reusable-dev-acc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index f202b0d7..1e3d8926 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -73,7 +73,7 @@ jobs: run: | echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> "$LOG_FILE" JOB_FAILED=false - if [ ${{ inputs.test_case }} != "" ]; then + if [[ -z "${{ inputs.test_case }}" ]]; then for t in ${{ inputs.test_case }}; do if ! (export TF_ACC_TEST_PATH="$(pwd)/${{ inputs.test_case_folder }}" && make acceptance case="$t" >> "$LOG_FILE") then From 0fb4c9652baae5e87afd60e76897c888fd8a57b9 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Wed, 3 Jan 2024 17:13:04 +0530 Subject: [PATCH 34/37] fix --- .github/workflows/reusable-dev-acc.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 1e3d8926..917f315d 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -73,7 +73,11 @@ jobs: run: | echo "Run Date: $(date +'%Y-%m-%d Time: %H:%M:%S %z' )" >> "$LOG_FILE" JOB_FAILED=false + if [[ -z "${{ inputs.test_case }}" ]]; then + export TF_ACC_TEST_PATH="$(pwd)/${{ inputs.test_case_folder }}" && make acceptance >> "$LOG_FILE" + + else for t in ${{ inputs.test_case }}; do if ! (export TF_ACC_TEST_PATH="$(pwd)/${{ inputs.test_case_folder }}" && make acceptance case="$t" >> "$LOG_FILE") then @@ -82,8 +86,6 @@ jobs: fi done if $JOB_FAILED; then exit 1; fi - else - export TF_ACC_TEST_PATH="$(pwd)/${{ inputs.test_case_folder }}" && make acceptance >> "$LOG_FILE" fi From 491d9085f6d31fe1ba54323fdf25b49ebed97055 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Thu, 4 Jan 2024 08:53:35 +0530 Subject: [PATCH 35/37] improvement --- .github/parse_logs.py | 22 +++++++++++++--------- .github/workflows/cicd-dev-acc.yml | 6 +++--- .github/workflows/reusable-dev-acc.yml | 8 ++++++++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/parse_logs.py b/.github/parse_logs.py index 992e2b6a..f373e5d7 100644 --- a/.github/parse_logs.py +++ b/.github/parse_logs.py @@ -8,21 +8,25 @@ def main(args): n = len(args) if n != 2: - print("Pass the log directory") + print("Pass the log directory or txt file path") return 1 log_path = args[1] file_content = '' - for x in os.listdir(log_path): - if x.endswith(".txt"): - with open(os.path.join(log_path, x)) as f: - file_content += (f.read()) - test_count = file_content.count('RUN') + if log_path.endswith(".txt"): + with open(log_path) as f: + file_content += (f.read()) + else: + for x in os.listdir(log_path): + if x.endswith(".txt"): + with open(os.path.join(log_path, x)) as f: + file_content += (f.read()) + test_count = file_content.count('RUN') - file_content.count('SKIP:') pass_count = file_content.count('PASS:') fail_count = file_content.count('FAIL:') print( - f"\nTestcases Ran: {test_count}; " - f"Testcases Passed: {pass_count}; " - f"Testcases Failed: {fail_count}; ") + f"\nTestcases Ran: {test_count}; \n" + f"Testcases Passed: {pass_count}; \n" + f"Testcases Failed: {fail_count}; \n") return 0 if __name__ == "__main__": diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index f6d2e9b0..7e69962f 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -24,7 +24,7 @@ jobs: test-vmaas-instance: uses: ./.github/workflows/reusable-dev-acc.yml needs: [test-provider, test-datasouces] - if: "always() && ${{ needs.test-provider.result == 'success' }}" + if: "failure() || ${{ needs.test-provider.result == 'success' }}" with: test_case: TestVmaasInstance TestAccResourceInstance test_description: Instance test @@ -33,7 +33,7 @@ jobs: test-vmaas-lb: uses: ./.github/workflows/reusable-dev-acc.yml needs: [test-provider, test-vmaas-instance] - if: "always() && ${{ needs.test-provider.result == 'success' }}" + if: "failure() || ${{ needs.test-provider.result == 'success' }}" with: test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate test_description: Loadbalancer test @@ -42,7 +42,7 @@ jobs: test-vmaas-network: uses: ./.github/workflows/reusable-dev-acc.yml needs: [test-provider, test-vmaas-lb] - if: "always() && ${{ needs.test-provider.result == 'success' }}" + if: "failure() || ${{ needs.test-provider.result == 'success' }}" with: test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan test_description: Network test diff --git a/.github/workflows/reusable-dev-acc.yml b/.github/workflows/reusable-dev-acc.yml index 917f315d..0976c472 100644 --- a/.github/workflows/reusable-dev-acc.yml +++ b/.github/workflows/reusable-dev-acc.yml @@ -56,6 +56,10 @@ jobs: steps: - name: Checkout workspace uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' - name: Set up Go uses: actions/setup-go@v5 with: @@ -92,6 +96,10 @@ jobs: - name: Print testcases output if: always() run: cat "$LOG_FILE" + + - name: Print testcases count + if: always() + run: python .github/parse_logs.py "$LOG_FILE" - name: Push the report to github artifacts if: always() From 85c171b47b779a9cbe26c32ba6da807717979e64 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Thu, 4 Jan 2024 10:26:59 +0530 Subject: [PATCH 36/37] always run --- .github/workflows/cicd-dev-acc.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index 7e69962f..a8ddaa0a 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -23,8 +23,8 @@ jobs: test-vmaas-instance: uses: ./.github/workflows/reusable-dev-acc.yml - needs: [test-provider, test-datasouces] - if: "failure() || ${{ needs.test-provider.result == 'success' }}" + needs: [test-datasouces] + if: "always()" with: test_case: TestVmaasInstance TestAccResourceInstance test_description: Instance test @@ -32,8 +32,8 @@ jobs: test-vmaas-lb: uses: ./.github/workflows/reusable-dev-acc.yml - needs: [test-provider, test-vmaas-instance] - if: "failure() || ${{ needs.test-provider.result == 'success' }}" + needs: [test-vmaas-instance] + if: "always()" with: test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate test_description: Loadbalancer test @@ -41,8 +41,8 @@ jobs: test-vmaas-network: uses: ./.github/workflows/reusable-dev-acc.yml - needs: [test-provider, test-vmaas-lb] - if: "failure() || ${{ needs.test-provider.result == 'success' }}" + needs: [test-vmaas-lb] + if: "always()" with: test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan test_description: Network test From 4d2d994b4da4df6e5105b4c06fda448eb3820323 Mon Sep 17 00:00:00 2001 From: Mahesh N Date: Thu, 4 Jan 2024 11:56:23 +0530 Subject: [PATCH 37/37] improvement --- .github/workflows/cicd-dev-acc.yml | 11 ++++++----- .github/workflows/cicd-prod-acc.yml | 7 ++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cicd-dev-acc.yml b/.github/workflows/cicd-dev-acc.yml index a8ddaa0a..769fa775 100644 --- a/.github/workflows/cicd-dev-acc.yml +++ b/.github/workflows/cicd-dev-acc.yml @@ -1,4 +1,4 @@ -name: IaC Acceptance Tests for CI CD Dev Environment +name: IaC Tests for CI CD Gating Job # This workflow runs all the acc-dev-testcases on: @@ -18,7 +18,7 @@ jobs: uses: ./.github/workflows/reusable-dev-acc.yml with: test_case: TestAccDataSource - test_description: All data source test + test_description: GET call usecase validations secrets: inherit test-vmaas-instance: @@ -27,7 +27,7 @@ jobs: if: "always()" with: test_case: TestVmaasInstance TestAccResourceInstance - test_description: Instance test + test_description: Instance usecase validations secrets: inherit test-vmaas-lb: @@ -36,7 +36,7 @@ jobs: if: "always()" with: test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate - test_description: Loadbalancer test + test_description: Loadbalancer usecase validations secrets: inherit test-vmaas-network: @@ -45,7 +45,7 @@ jobs: if: "always()" with: test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan - test_description: Network test + test_description: NSX Network usecase validations secrets: inherit process-logs: @@ -70,3 +70,4 @@ jobs: run: | LOG_RESULT=$(python .github/parse_logs.py '${{ steps.logs.outputs.download-path }}') echo $LOG_RESULT + curl -X POST -H 'Content-type: application/json' --data "{'text':'CICD Terraform IaC Test results $LOG_RESULT and report link - https://github.com/HewlettPackard/hpegl-vmaas-terraform-resources/actions/runs/${{ github.run_id }}'}" '${{ secrets.TEAMS_URL_CICD }}' diff --git a/.github/workflows/cicd-prod-acc.yml b/.github/workflows/cicd-prod-acc.yml index 5d1f86dc..6a1cd9ec 100644 --- a/.github/workflows/cicd-prod-acc.yml +++ b/.github/workflows/cicd-prod-acc.yml @@ -1,4 +1,4 @@ -name: IaC Acceptance Tests for CI CD Prod Environment +name: IaC Tests for CI CD Solution Job on: workflow_dispatch: @@ -7,7 +7,7 @@ jobs: acc-test: uses: ./.github/workflows/reusable-dev-acc.yml with: - test_description: Check all Terraform Testcases + test_description: IaC Terraform Testcase test_case_folder: 'acc-testcases' secrets: DEV_HPEGL_IAM_SERVICE_URL: ${{ secrets.HPEGL_IAM_SERVICE_URL }} @@ -40,4 +40,5 @@ jobs: - name: Print Result and Publish run: | LOG_RESULT=$(python .github/parse_logs.py '${{ steps.logs.outputs.download-path }}') - echo $LOG_RESULT \ No newline at end of file + echo $LOG_RESULT + curl -X POST -H 'Content-type: application/json' --data "{'text':'CICD Terraform IaC Test results $LOG_RESULT and report link - https://github.com/HewlettPackard/hpegl-vmaas-terraform-resources/actions/runs/${{ github.run_id }}'}" '${{ secrets.SLACK_URL_CICD }}' \ No newline at end of file