Skip to content

Commit

Permalink
remove duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
mahesh-hpe committed Jan 3, 2024
1 parent 286e0a7 commit 540381e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 103 deletions.
65 changes: 26 additions & 39 deletions .github/workflows/acc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 }}
14 changes: 5 additions & 9 deletions .github/workflows/cicd-dev-acc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Dev Acceptance Tests for CI CD
name: IaC Acceptance Tests for CI CD Dev Environment

on:
workflow_dispatch:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
70 changes: 20 additions & 50 deletions .github/workflows/dev-acc.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 }}
12 changes: 7 additions & 5 deletions .github/workflows/reusable-dev-acc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Reusable Dev Acceptance Tests
name: Reusable Worflow for running Acceptance Tests. By default handles dev testing.

on:
workflow_call:
Expand All @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 540381e

Please sign in to comment.