-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from HewlettPackard/cicd-acc
Include IaC testing for cicd
- Loading branch information
Showing
7 changed files
with
293 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python | ||
# (C) Copyright 2024 Hewlett Packard Enterprise Development LP | ||
|
||
import os | ||
import sys | ||
|
||
|
||
def main(args): | ||
n = len(args) | ||
if n != 2: | ||
print("Pass the log directory or txt file path") | ||
return 1 | ||
log_path = args[1] | ||
file_content = '' | ||
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}; \n" | ||
f"Testcases Passed: {pass_count}; \n" | ||
f"Testcases Failed: {fail_count}; \n") | ||
return 0 | ||
|
||
if __name__ == "__main__": | ||
exit(main(sys.argv)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,73 @@ | ||
name: Dev Acceptance Tests for CI CD | ||
name: IaC Tests for CI CD Gating Job | ||
# This workflow runs all the acc-dev-testcases | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test-provider: | ||
uses: ./.github/workflows/dev-acc.yml | ||
uses: ./.github/workflows/reusable-dev-acc.yml | ||
with: | ||
test_case: TestProvider | ||
test_description: Check for valid terraform provider | ||
secrets: inherit | ||
|
||
test-datasouces: | ||
needs: | ||
- test-provider | ||
if: "${{ always() && needs.test-provider.result != 'failed' }}" | ||
uses: ./.github/workflows/dev-acc.yml | ||
needs: [test-provider] | ||
if: "always() && ${{ needs.test-provider.result == 'success' }}" | ||
uses: ./.github/workflows/reusable-dev-acc.yml | ||
with: | ||
test_case: TestAccDataSource | ||
test_description: GET call usecase validations | ||
secrets: inherit | ||
|
||
test-vmaas-instance: | ||
uses: ./.github/workflows/dev-acc.yml | ||
uses: ./.github/workflows/reusable-dev-acc.yml | ||
needs: [test-datasouces] | ||
if: "always()" | ||
with: | ||
test_case: TestVmaasInstance | ||
test_case: TestVmaasInstance TestAccResourceInstance | ||
test_description: Instance usecase validations | ||
secrets: inherit | ||
|
||
test-vmaas-lb: | ||
uses: ./.github/workflows/reusable-dev-acc.yml | ||
needs: [test-vmaas-instance] | ||
if: "always()" | ||
with: | ||
test_case: TestVmaasLB TestAccResourceLB TestVmaasLoadBalancerPlan TestAccResourceLoadBalancerCreate | ||
test_description: Loadbalancer usecase validations | ||
secrets: inherit | ||
|
||
test-vmaas-network: | ||
uses: ./.github/workflows/reusable-dev-acc.yml | ||
needs: [test-vmaas-lb] | ||
if: "always()" | ||
with: | ||
test_case: TestVmaasNetworkPlan TestAccResourceNetworkCreate TestAccResourceRouter TestVmaasRouter TestAccResourceTier TestVmaasRouteBGPNeighborPlan | ||
test_description: NSX Network usecase validations | ||
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 | ||
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 }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: IaC Tests for CI CD Solution Job | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
acc-test: | ||
uses: ./.github/workflows/reusable-dev-acc.yml | ||
with: | ||
test_description: IaC Terraform Testcase | ||
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 | ||
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 }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.