diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 994fc001ed..cb1cd4f705 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -210,8 +210,22 @@ jobs: github_sha: ${{github.sha}} s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET_CN }} - - + LinuxOnPremIntegrationTest: + needs: [StartLocalStack, GenerateTestMatrix, OutputEnvVariables] + name: 'OnpremLinux' + uses: ./.github/workflows/ec2-integration-test.yml + with: + github_sha: ${{github.sha}} + test_dir: terraform/ec2/linux_onprem + job_id: linux-onprem-integration-test + test_props: ${{needs.GenerateTestMatrix.outputs.ec2_linux_onprem_matrix}} + test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }} + test_repo_url: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }} + test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }} + localstack_host: ${{needs.StartLocalStack.outputs.local_stack_host_name}} + region: us-west-2 + secrets: inherit + EC2NvidiaGPUIntegrationTest: needs: [ StartLocalStack, GenerateTestMatrix ] name: 'EC2NVIDIAGPUIntegrationTest' @@ -356,113 +370,103 @@ jobs: echo "CWA_GITHUB_TEST_REPO_BRANCH: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}" EC2LinuxIntegrationTest: - needs: [ StartLocalStack, GenerateTestMatrix, OutputEnvVariables ] - name: 'EC2Linux' - uses: ./.github/workflows/ec2-integration-test.yml + needs: [StartLocalStack, GenerateTestMatrix] + uses: ./.github/workflows/terraform-test-execution.yml with: - github_sha: ${{github.sha}} - test_dir: terraform/ec2/linux - job_id: ec2-linux-integration-test - test_props: ${{needs.GenerateTestMatrix.outputs.ec2_linux_matrix}} - test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }} - test_repo_url: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }} - test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }} - localstack_host: ${{needs.StartLocalStack.outputs.local_stack_host_name}} - region: us-west-2 - terraform_assume_role: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }} - s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET }} - secrets: inherit + terraform_vars: ${{needs.GenerateTestMatrix.outputs.ec2_linux_matrix}} + terraform_dir: 'terraform/ec2/linux' + needs_ecr: false + timeout_minutes: 30 - EC2LinuxIntegrationTestITAR: - needs: [ StartLocalStackITAR, GenerateTestMatrix, OutputEnvVariables ] - name: 'EC2LinuxITAR' - uses: ./.github/workflows/ec2-integration-test.yml + EC2WindowsIntegrationTest: + needs: [GenerateTestMatrix] + uses: ./.github/workflows/terraform-test-execution.yml with: - github_sha: ${{github.sha}} - test_dir: terraform/ec2/linux - job_id: ec2-linux-integration-test - test_props: ${{needs.GenerateTestMatrix.outputs.ec2_linux_itar_matrix}} - test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }} - test_repo_url: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }} - test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }} - localstack_host: ${{needs.StartLocalStackITAR.outputs.local_stack_host_name}} - region: us-gov-east-1 - terraform_assume_role: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE_ITAR }} - s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET_ITAR }} - secrets: inherit + terraform_vars: ${{needs.GenerateTestMatrix.outputs.ec2_windows_matrix}} + terraform_dir: 'terraform/ec2/win' + needs_ecr: false + timeout_minutes: 30 - EC2LinuxIntegrationTestCN: - needs: [ StartLocalStackCN, GenerateTestMatrix, OutputEnvVariables ] - name: 'EC2LinuxCN' - uses: ./.github/workflows/ec2-integration-test.yml + EC2DarwinIntegrationTest: + needs: [GenerateTestMatrix] + uses: ./.github/workflows/terraform-test-execution.yml with: - github_sha: ${{github.sha}} - test_dir: terraform/ec2/linux - job_id: ec2-linux-integration-test - test_props: ${{needs.GenerateTestMatrix.outputs.ec2_linux_china_matrix}} - test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }} - test_repo_url: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }} - test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }} - localstack_host: ${{needs.StartLocalStackCN.outputs.local_stack_host_name}} - region: cn-north-1 - terraform_assume_role: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE_CN }} - s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET_CN }} - secrets: inherit + terraform_vars: ${{needs.GenerateTestMatrix.outputs.ec2_mac_matrix}} + terraform_dir: 'terraform/ec2/mac' + needs_ecr: false + timeout_minutes: 30 + ECSEC2IntegrationTest: + needs: [GenerateTestMatrix] + uses: ./.github/workflows/terraform-test-execution.yml + with: + terraform_vars: ${{needs.GenerateTestMatrix.outputs.ecs_ec2_launch_daemon_matrix}} + terraform_dir: 'terraform/ecs_ec2/daemon' + needs_ecr: true + timeout_minutes: 15 - LinuxOnPremIntegrationTest: - needs: [StartLocalStack, GenerateTestMatrix, OutputEnvVariables] - name: 'OnpremLinux' - uses: ./.github/workflows/ec2-integration-test.yml + ECSFargateIntegrationTest: + needs: [GenerateTestMatrix] + uses: ./.github/workflows/terraform-test-execution.yml with: - github_sha: ${{github.sha}} - test_dir: terraform/ec2/linux_onprem - job_id: linux-onprem-integration-test - test_props: ${{needs.GenerateTestMatrix.outputs.ec2_linux_onprem_matrix}} - test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }} - test_repo_url: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }} - test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }} - localstack_host: ${{needs.StartLocalStack.outputs.local_stack_host_name}} - region: us-west-2 - secrets: inherit + terraform_vars: ${{needs.GenerateTestMatrix.outputs.ecs_fargate_matrix}} + terraform_dir: 'terraform/ecs_fargate/linux' + needs_ecr: true + timeout_minutes: 15 - EC2WinIntegrationTest: - needs: [GenerateTestMatrix, OutputEnvVariables] - name: 'EC2Win' - uses: ./.github/workflows/ec2-integration-test.yml + EC2LinuxIntegrationTestITAR: + needs: [StartLocalStackITAR, GenerateTestMatrix] + uses: ./.github/workflows/terraform-test-execution.yml with: - github_sha: ${{ github.sha }} - test_dir: terraform/ec2/win - job_id: ec2-windows-integration-test - test_props: ${{ needs.GenerateTestMatrix.outputs.ec2_windows_matrix }} - test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }} - test_repo_url: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }} - test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }} - localstack_host: "" - region: us-west-2 - terraform_assume_role: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }} - s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET }} - secrets: inherit - - EC2DarwinIntegrationTest: - needs: [GenerateTestMatrix, OutputEnvVariables] - name: 'EC2Darwin' - uses: ./.github/workflows/ec2-integration-test.yml + terraform_vars: ${{needs.GenerateTestMatrix.outputs.ec2_linux_itar_matrix}} + terraform_dir: 'terraform/ec2/linux' + needs_ecr: false + timeout_minutes: 30 + + EC2LinuxIntegrationTestCN: + needs: [StartLocalStackCN, GenerateTestMatrix] + uses: ./.github/workflows/terraform-test-execution.yml with: - github_sha: ${{ github.sha }} - test_dir: terraform/ec2/mac - job_id: ec2-mac-integration-test - test_props: ${{ needs.GenerateTestMatrix.outputs.ec2_mac_matrix }} - test_repo_name: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_NAME }} - test_repo_url: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_URL }} - test_repo_branch: ${{ needs.OutputEnvVariables.outputs.CWA_GITHUB_TEST_REPO_BRANCH }} - localstack_host: "" - region: us-west-2 - terraform_assume_role: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }} - s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET }} - secrets: inherit + terraform_vars: ${{needs.GenerateTestMatrix.outputs.ec2_linux_china_matrix}} + terraform_dir: 'terraform/ec2/linux' + needs_ecr: false + timeout_minutes: 30 + + PerformanceTrackingTest: + needs: [GenerateTestMatrix] + uses: ./.github/workflows/terraform-test-execution.yml + with: + terraform_vars: ${{needs.GenerateTestMatrix.outputs.ec2_performance_matrix}} + terraform_dir: 'terraform/performance' + needs_ecr: false + timeout_minutes: 60 + + EC2WinPerformanceTest: + needs: [GenerateTestMatrix] + uses: ./.github/workflows/terraform-test-execution.yml + with: + terraform_vars: ${{needs.GenerateTestMatrix.outputs.ec2_windows_performance_matrix}} + terraform_dir: 'terraform/performance' + needs_ecr: false + timeout_minutes: 60 + StressTrackingTest: + needs: [GenerateTestMatrix] + uses: ./.github/workflows/terraform-test-execution.yml + with: + terraform_vars: ${{needs.GenerateTestMatrix.outputs.ec2_stress_matrix}} + terraform_dir: 'terraform/stress' + needs_ecr: false + timeout_minutes: 60 + EC2WinStressTrackingTest: + needs: [GenerateTestMatrix] + uses: ./.github/workflows/terraform-test-execution.yml + with: + terraform_vars: ${{needs.GenerateTestMatrix.outputs.ec2_windows_stress_matrix}} + terraform_dir: 'terraform/stress' + needs_ecr: false + timeout_minutes: 60 StopLocalStack: name: 'StopLocalStack' @@ -515,554 +519,6 @@ jobs: github_sha: ${{github.sha}} s3_integration_bucket: ${{ vars.S3_INTEGRATION_BUCKET_CN }} - ECSEC2IntegrationTest: - name: 'ECSEC2IntegrationTest' - runs-on: ubuntu-latest - needs: [ GenerateTestMatrix ] - strategy: - fail-fast: false - matrix: - arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.ecs_ec2_launch_daemon_matrix) }} - permissions: - id-token: write - contents: read - steps: - - uses: actions/checkout@v3 - with: - repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}} - ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}} - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }} - aws-region: us-west-2 - role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} - - - name: Login ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v2 - - - name: Install Terraform - uses: hashicorp/setup-terraform@v3 - - - name: Verify Terraform version - run: terraform --version - - - name: Terraform apply - uses: nick-fields/retry@v2 - with: - max_attempts: 3 - timeout_minutes: 15 - retry_wait_seconds: 5 - command: | - if [ "${{ matrix.arrays.terraform_dir }}" != "" ]; then - cd "${{ matrix.arrays.terraform_dir }}" - else - cd terraform/ecs_ec2/daemon - fi - - terraform init - if terraform apply --auto-approve\ - -var="test_dir=${{ matrix.arrays.test_dir }}"\ - -var="ec2_instance_type=${{ matrix.arrays.instanceType }}" \ - -var="cwagent_image_repo=${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_INTEGRATION_TEST_REPO }}"\ - -var="cwagent_image_tag=${{ github.sha }}"\ - -var="ec2_instance_type=${{ matrix.arrays.instanceType }}" \ - -var="metadataEnabled=${{ matrix.arrays.metadataEnabled }}" \ - -var="ami=${{ matrix.arrays.ami }}" ; then - terraform destroy -auto-approve - else - terraform destroy -auto-approve && exit 1 - fi - - - name: Terraform destroy - if: ${{ cancelled() || failure() }} - uses: nick-fields/retry@v2 - with: - max_attempts: 3 - timeout_minutes: 8 - retry_wait_seconds: 5 - command: | - if [ "${{ matrix.arrays.terraform_dir }}" != "" ]; then - cd "${{ matrix.arrays.terraform_dir }}" - else - cd terraform/ecs_ec2/daemon - fi - terraform destroy --auto-approve - - ECSFargateIntegrationTest: - name: 'ECSFargateIntegrationTest' - runs-on: ubuntu-latest - needs: [GenerateTestMatrix] - strategy: - fail-fast: false - matrix: - arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.ecs_fargate_matrix) }} - permissions: - id-token: write - contents: read - steps: - - uses: actions/checkout@v3 - with: - repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}} - ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}} - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }} - aws-region: us-west-2 - role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} - - - name: Login ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v2 - - - name: Install Terraform - uses: hashicorp/setup-terraform@v3 - - - name: Verify Terraform version - run: terraform --version - - - name: Terraform apply - uses: nick-fields/retry@v2 - with: - max_attempts: 3 - timeout_minutes: 15 - retry_wait_seconds: 5 - command: | - if [ "${{ matrix.arrays.terraform_dir }}" != "" ]; then - cd "${{ matrix.arrays.terraform_dir }}" - else - cd terraform/ecs_fargate/linux - fi - - terraform init - if terraform apply --auto-approve\ - -var="test_dir=${{ matrix.arrays.test_dir }}"\ - -var="cwagent_image_repo=${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_INTEGRATION_TEST_REPO }}"\ - -var="cwagent_image_tag=${{ github.sha }}"; then - terraform destroy -auto-approve - else - terraform destroy -auto-approve && exit 1 - fi - - name: Terraform destroy - if: ${{ cancelled() || failure() }} - uses: nick-fields/retry@v2 - with: - max_attempts: 3 - timeout_minutes: 8 - retry_wait_seconds: 5 - command: | - if [ "${{ matrix.arrays.terraform_dir }}" != "" ]; then - cd "${{ matrix.arrays.terraform_dir }}" - else - cd terraform/ecs_fargate/linux - fi - terraform destroy --auto-approve - - EKSIntegrationTest: - name: 'EKSIntegrationTest' - runs-on: ubuntu-latest - needs: [ GenerateTestMatrix ] - strategy: - fail-fast: false - matrix: - arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.eks_daemon_matrix) }} - permissions: - id-token: write - contents: read - steps: - - uses: actions/checkout@v3 - with: - repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}} - ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}} - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }} - aws-region: us-west-2 - role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} - - - name: Login ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v2 - - - name: Install Terraform - uses: hashicorp/setup-terraform@v3 - - - name: Verify Terraform version - run: terraform --version - - - name: Terraform apply - uses: nick-fields/retry@v2 - with: - max_attempts: 2 - timeout_minutes: 90 # EKS takes about 20 minutes to spin up a cluster and service on the cluster - retry_wait_seconds: 5 - command: | - if [ "${{ matrix.arrays.terraform_dir }}" != "" ]; then - cd "${{ matrix.arrays.terraform_dir }}" - else - cd terraform/eks/daemon - fi - - terraform init - if terraform apply --auto-approve \ - -var="test_dir=${{ matrix.arrays.test_dir }}"\ - -var="cwagent_image_repo=${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_INTEGRATION_TEST_REPO }}" \ - -var="cwagent_image_tag=${{ github.sha }}" \ - -var="ami_type=${{ matrix.arrays.ami }}" \ - -var="instance_type=${{ matrix.arrays.instanceType }}" \ - -var="k8s_version=${{ matrix.arrays.k8sVersion }}"; then - terraform destroy -auto-approve - else - terraform destroy -auto-approve && exit 1 - fi - - - name: Terraform destroy - if: ${{ cancelled() || failure() }} - uses: nick-fields/retry@v2 - with: - max_attempts: 3 - timeout_minutes: 8 - retry_wait_seconds: 5 - command: | - if [ "${{ matrix.arrays.terraform_dir }}" != "" ]; then - cd "${{ matrix.arrays.terraform_dir }}" - else - cd terraform/eks/daemon - fi - terraform destroy --auto-approve - - EKSPrometheusIntegrationTest: - name: 'EKSPrometheusIntegrationTest' - runs-on: ubuntu-latest - needs: [ GenerateTestMatrix ] - strategy: - fail-fast: false - matrix: - arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.eks_deployment_matrix) }} - permissions: - id-token: write - contents: read - steps: - - uses: actions/checkout@v3 - with: - repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}} - ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}} - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }} - aws-region: us-west-2 - role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} - - - name: Login ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v2 - - - name: Install Terraform - uses: hashicorp/setup-terraform@v3 - - - name: Verify Terraform version - run: terraform --version - - - name: Terraform apply - uses: nick-fields/retry@v2 - with: - max_attempts: 3 - timeout_minutes: 60 # EKS takes about 20 minutes to spin up a cluster and service on the cluster - retry_wait_seconds: 5 - command: | - if [ "${{ matrix.arrays.terraform_dir }}" != "" ]; then - cd "${{ matrix.arrays.terraform_dir }}" - else - cd terraform/eks/deployment - fi - - terraform init - if terraform apply --auto-approve \ - -var="test_dir=${{ matrix.arrays.test_dir }}"\ - -var="cwagent_image_repo=${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_INTEGRATION_TEST_REPO }}" \ - -var="cwagent_image_tag=${{ github.sha }}" \ - -var="k8s_version=${{ matrix.arrays.k8s_version }}"; then - terraform destroy -auto-approve - else - terraform destroy -auto-approve && exit 1 - fi - - - name: Terraform destroy - if: ${{ cancelled() || failure() }} - uses: nick-fields/retry@v2 - with: - max_attempts: 3 - timeout_minutes: 8 - retry_wait_seconds: 5 - command: | - if [ "${{ matrix.arrays.terraform_dir }}" != "" ]; then - cd "${{ matrix.arrays.terraform_dir }}" - else - cd terraform/eks/deployment - fi - terraform destroy --auto-approve - - PerformanceTrackingTest: - name: "PerformanceTrackingTest" - needs: [GenerateTestMatrix] - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.ec2_performance_matrix) }} - permissions: - id-token: write - contents: read - steps: - - uses: actions/checkout@v3 - with: - repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}} - ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}} - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }} - aws-region: us-west-2 - role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} - - - name: Install Terraform - uses: hashicorp/setup-terraform@v3 - - - name: Verify Terraform version - run: terraform --version - - - name: Terraform apply - uses: nick-fields/retry@v2 - with: - max_attempts: 1 - timeout_minutes: 60 - retry_wait_seconds: 5 - command: | - cd terraform/performance - terraform init - if terraform apply --auto-approve \ - -var="ssh_key_value=${PRIVATE_KEY}" \ - -var="cwa_github_sha=${GITHUB_SHA}" \ - -var="ami=${{ matrix.arrays.ami }}" \ - -var="arc=${{ matrix.arrays.arc }}" \ - -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \ - -var="ssh_key_name=${KEY_NAME}" \ - -var="values_per_minute=${{ matrix.arrays.values_per_minute}}"\ - -var="family=${{ matrix.arrays.family}}"\ - -var="test_dir=${{ matrix.arrays.test_dir }}" ; then terraform destroy -auto-approve - else - terraform destroy -auto-approve && exit 1 - fi - - - name: Terraform destroy - if: ${{ cancelled() || failure() }} - uses: nick-fields/retry@v2 - with: - max_attempts: 3 - timeout_minutes: 8 - retry_wait_seconds: 5 - command: cd terraform/performance && terraform destroy --auto-approve - - EC2WinPerformanceTest: - name: "EC2WinPerformanceTest" - needs: [ GenerateTestMatrix ] - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.ec2_windows_performance_matrix) }} - permissions: - id-token: write - contents: read - steps: - - uses: actions/checkout@v3 - with: - repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}} - ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}} - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }} - aws-region: us-west-2 - role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} - - - name: Install Terraform - uses: hashicorp/setup-terraform@v3 - - - name: Verify Terraform version - run: terraform --version - - - name: Terraform apply - uses: nick-fields/retry@v2 - with: - max_attempts: 1 - timeout_minutes: 60 - retry_wait_seconds: 5 - command: | - cd terraform/performance - terraform init - if terraform apply --auto-approve \ - -var="ssh_key_value=${PRIVATE_KEY}" \ - -var="cwa_github_sha=${GITHUB_SHA}" \ - -var="ami=${{ matrix.arrays.ami }}" \ - -var="arc=${{ matrix.arrays.arc }}" \ - -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \ - -var="ssh_key_name=${KEY_NAME}" \ - -var="values_per_minute=${{ matrix.arrays.values_per_minute}}"\ - -var="family=${{ matrix.arrays.family}}"\ - -var="test_dir=${{ matrix.arrays.test_dir }}" ; then terraform destroy -auto-approve - else - terraform destroy -auto-approve && exit 1 - fi - - - name: Terraform destroy - if: ${{ cancelled() || failure() }} - uses: nick-fields/retry@v2 - with: - max_attempts: 3 - timeout_minutes: 8 - retry_wait_seconds: 5 - command: cd terraform/performance && terraform destroy --auto-approve - - StressTrackingTest: - name: "StressTrackingTest" - needs: [GenerateTestMatrix] - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.ec2_stress_matrix) }} - permissions: - id-token: write - contents: read - steps: - - uses: actions/checkout@v3 - with: - repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}} - ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}} - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }} - aws-region: us-west-2 - role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} - - - name: Install Terraform - uses: hashicorp/setup-terraform@v3 - - - name: Verify Terraform version - run: terraform --version - - - name: Echo Test Info - run: echo run on ec2 instance os ${{ matrix.arrays.os }} arc ${{ matrix.arrays.arc }} test dir ${{ matrix.arrays.test_dir }} values per minute ${{ matrix.arrays.values_per_minute }} - - - name: Terraform apply - uses: nick-fields/retry@v2 - with: - max_attempts: 1 - timeout_minutes: 60 - retry_wait_seconds: 5 - command: | - cd terraform/stress - terraform init - if terraform apply --auto-approve \ - -var="ssh_key_value=${PRIVATE_KEY}" \ - -var="cwa_github_sha=${GITHUB_SHA}" \ - -var="ami=${{ matrix.arrays.ami }}" \ - -var="arc=${{ matrix.arrays.arc }}" \ - -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \ - -var="ssh_key_name=${KEY_NAME}" \ - -var="values_per_minute=${{ matrix.arrays.values_per_minute}}"\ - -var="test_dir=${{ matrix.arrays.test_dir }}" ; then terraform destroy -auto-approve - else - terraform destroy -auto-approve && exit 1 - fi - - - name: Terraform destroy - if: ${{ cancelled() || failure() }} - uses: nick-fields/retry@v2 - with: - max_attempts: 3 - timeout_minutes: 8 - retry_wait_seconds: 5 - command: cd terraform/stress && terraform destroy --auto-approve - - EC2WinStressTrackingTest: - name: "EC2WinStressTrackingTest" - needs: [GenerateTestMatrix] - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - arrays: ${{ fromJson(needs.GenerateTestMatrix.outputs.ec2_windows_stress_matrix) }} - permissions: - id-token: write - contents: read - steps: - - uses: actions/checkout@v3 - with: - repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}} - ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}} - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }} - aws-region: us-west-2 - role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} - - - name: Install Terraform - uses: hashicorp/setup-terraform@v3 - - - name: Verify Terraform version - run: terraform --version - - - name: Echo Test Info - run: echo run on ec2 instance os ${{ matrix.arrays.os }} arc ${{ matrix.arrays.arc }} test dir ${{ matrix.arrays.test_dir }} values per minute ${{ matrix.arrays.values_per_minute }} - - - name: Terraform apply - uses: nick-fields/retry@v2 - with: - max_attempts: 1 - timeout_minutes: 60 - retry_wait_seconds: 5 - command: | - cd terraform/stress - terraform init - if terraform apply --auto-approve \ - -var="ssh_key_value=${PRIVATE_KEY}" \ - -var="cwa_github_sha=${GITHUB_SHA}" \ - -var="ami=${{ matrix.arrays.ami }}" \ - -var="arc=${{ matrix.arrays.arc }}" \ - -var="s3_bucket=${S3_INTEGRATION_BUCKET}" \ - -var="ssh_key_name=${KEY_NAME}" \ - -var="values_per_minute=${{ matrix.arrays.values_per_minute}}"\ - -var="family=${{ matrix.arrays.family}}"\ - -var="test_dir=${{ matrix.arrays.test_dir }}" ; then terraform destroy -auto-approve - else - terraform destroy -auto-approve && exit 1 - fi - - - name: Terraform destroy - if: ${{ cancelled() || failure() }} - uses: nick-fields/retry@v2 - with: - max_attempts: 3 - timeout_minutes: 8 - retry_wait_seconds: 5 - command: cd terraform/stress && terraform destroy --auto-approve - GPUEndToEndTest: name: "GPU E2E Test" needs: [ GenerateTestMatrix, OutputEnvVariables ] diff --git a/.github/workflows/terraform-test-execution.yml b/.github/workflows/terraform-test-execution.yml new file mode 100644 index 0000000000..26e0570734 --- /dev/null +++ b/.github/workflows/terraform-test-execution.yml @@ -0,0 +1,112 @@ +name: Terraform Test Execution +env: + PRIVATE_KEY: ${{ secrets.AWS_PRIVATE_KEY }} + TERRAFORM_AWS_ASSUME_ROLE: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }} + TERRAFORM_AWS_ASSUME_ROLE_DURATION: 14400 # 4 hours + S3_INTEGRATION_BUCKET: ${{ vars.S3_INTEGRATION_BUCKET }} + KEY_NAME: ${{ secrets.KEY_NAME }} + ECR_INTEGRATION_TEST_REPO: "cwagent-integration-test" + CWA_GITHUB_TEST_REPO_NAME: "aws/amazon-cloudwatch-agent-test" + CWA_GITHUB_TEST_REPO_URL: "https://github.com/aws/amazon-cloudwatch-agent-test.git" + CWA_GITHUB_TEST_REPO_BRANCH: "main" + TERRAFORM_AWS_ASSUME_ROLE_ITAR: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE_ITAR }} + S3_INTEGRATION_BUCKET_ITAR: ${{ vars.S3_INTEGRATION_BUCKET_ITAR }} + TERRAFORM_AWS_ASSUME_ROLE_CN: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE_CN }} + S3_INTEGRATION_BUCKET_CN: ${{ vars.S3_INTEGRATION_BUCKET_CN }} +on: + workflow_call: + inputs: + terraform_vars: + required: true + type: string + description: 'JSON string of terraform variables from GenerateTestMatrix' + terraform_dir: + required: false + type: string + description: 'Override path to terraform directory. If not set, uses terraform_dir from matrix' + needs_ecr: + required: false + type: boolean + default: false + description: 'Whether ECR login is needed' + max_attempts: + required: false + type: number + default: 3 + description: 'Maximum number of retry attempts' + timeout_minutes: + required: false + type: number + default: 30 + description: 'Timeout in minutes' + retry_wait_seconds: + required: false + type: number + default: 5 + description: 'Wait time between retries in seconds' + +jobs: + run-test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + arrays: ${{ fromJson(inputs.terraform_vars) }} + + steps: + - uses: actions/checkout@v3 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }} + aws-region: us-west-2 + role-duration-seconds: 14400 + + - name: Setup ECR + if: inputs.needs_ecr + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Install Terraform + uses: hashicorp/setup-terraform@v3 + + - name: Terraform Operations + uses: nick-fields/retry@v2 + with: + max_attempts: ${{ inputs.max_attempts }} + timeout_minutes: ${{ inputs.timeout_minutes }} + retry_wait_seconds: ${{ inputs.retry_wait_seconds }} + command: | + # Use terraform_dir from input if provided, otherwise from matrix + if [ "${{ inputs.terraform_dir }}" != "" ]; then + cd "${{ inputs.terraform_dir }}" + elif [ "${{ matrix.arrays.terraform_dir }}" != "" ]; then + cd "${{ matrix.arrays.terraform_dir }}" + else + cd terraform/eks/deployment + fi + + terraform init + + # Build all vars from matrix + VARS=$(echo '${{ toJSON(matrix.arrays) }}' | jq -r 'to_entries | map("-var=\"\(.key)=\(.value)\"") | join(" ")') + + if terraform apply --auto-approve $VARS; then + terraform destroy -auto-approve + else + terraform destroy -auto-approve + exit 1 + fi + + - name: Cleanup on failure + if: failure() || cancelled() + run: | + if [ "${{ inputs.terraform_dir }}" != "" ]; then + cd "${{ inputs.terraform_dir }}" + elif [ "${{ matrix.arrays.terraform_dir }}" != "" ]; then + cd "${{ matrix.arrays.terraform_dir }}" + else + cd terraform/eks/deployment + fi + terraform destroy --auto-approve