Reusable EKS E2E Test #1
This file contains hidden or 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
| name: Generate EKS Performance Test Cluster | |
| env: | |
| TERRAFORM_AWS_ASSUME_ROLE: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE }} | |
| TERRAFORM_AWS_ASSUME_ROLE_DURATION: 14400 # 4 hours | |
| 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: "scale-testing" | |
| TERRAFORM_AWS_ASSUME_ROLE_ITAR: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE_ITAR }} | |
| TERRAFORM_AWS_ASSUME_ROLE_CN: ${{ vars.TERRAFORM_AWS_ASSUME_ROLE_CN }} | |
| OPERATOR_GITHUB_REPO_NAME: "aws/amazon-cloudwatch-agent-operator" | |
| on: | |
| schedule: | |
| - cron: '0 17 * * 1' | |
| workflow_dispatch: | |
| inputs: | |
| cluster_name: | |
| required: true | |
| type: string | |
| cloudwatch_agent_operator_repository: | |
| required: true | |
| type: string | |
| cloudwatch_agent_operator_tag: | |
| required: true | |
| type: string | |
| cloudwatch_agent_repository: | |
| required: true | |
| type: string | |
| cloudwatch_agent_tag: | |
| required: true | |
| type: string | |
| helm-charts-branch: | |
| required: false | |
| type: string | |
| description: 'Branch of the helm charts to test' | |
| default: 'main' | |
| operator-branch: | |
| required: false | |
| type: string | |
| description: 'Branch of the operator to test' | |
| default: 'main' | |
| region: | |
| required: false | |
| type: string | |
| description: 'AWS Region to run tests in' | |
| default: 'us-west-2' | |
| jobs: | |
| GetLatestOperatorCommitSHA: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| operator_commit_sha: ${{steps.get_latest_sha.outputs.operator_sha}} | |
| operator_repo_name: ${{env.OPERATOR_GITHUB_REPO_NAME}} | |
| steps: | |
| - name: Checkout the target repo | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: ${{env.OPERATOR_GITHUB_REPO_NAME}} | |
| ref: ${{ inputs.operator-branch || 'main' }} | |
| path: operator-repo | |
| - name: Get latest commit SHA | |
| id: get_latest_sha | |
| run: | | |
| cd operator-repo | |
| latest_sha=$(git rev-parse HEAD) | |
| echo "::set-output name=operator_sha::$latest_sha" | |
| BuildAgent: | |
| uses: ./.github/workflows/build-test-artifacts.yml | |
| concurrency: | |
| group: "Build-Test-Artifacts-${{github.ref_name}}" | |
| cancel-in-progress: true | |
| secrets: inherit | |
| permissions: | |
| id-token: write | |
| contents: read | |
| with: | |
| test-image-before-upload: false | |
| BuildOperator: | |
| needs: [GetLatestOperatorCommitSHA] | |
| uses: aws/amazon-cloudwatch-agent-operator/.github/workflows/build-and-upload.yml@main | |
| concurrency: | |
| group: ${{ github.workflow }}-operator-${{ inputs.operator-branch || 'main' }} | |
| cancel-in-progress: true | |
| secrets: inherit | |
| with: | |
| tag: ${{needs.GetLatestOperatorCommitSHA.outputs.operator_commit_sha}} | |
| target-sha: ${{needs.GetLatestOperatorCommitSHA.outputs.operator_commit_sha}} | |
| repository: ${{needs.GetLatestOperatorCommitSHA.outputs.operator_repo_name}} | |
| test-image-before-upload: false | |
| OutputEnvVariables: | |
| needs: [ BuildAgent, BuildOperator ] | |
| name: 'OutputEnvVariables' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| CWA_GITHUB_TEST_REPO_NAME: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_NAME }} | |
| CWA_GITHUB_TEST_REPO_URL: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_URL }} | |
| CWA_GITHUB_TEST_REPO_BRANCH: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_BRANCH }} | |
| ECR_INTEGRATION_TEST_REPO: ${{ steps.set-outputs.outputs.ECR_INTEGRATION_TEST_REPO }} | |
| ECR_OPERATOR_REPO: ${{ steps.set-outputs.outputs.ECR_OPERATOR_REPO }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| repository: ${{env.CWA_GITHUB_TEST_REPO_NAME}} | |
| ref: ${{env.CWA_GITHUB_TEST_REPO_BRANCH}} | |
| - name: Set up Go 1.x | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: ~1.22.2 | |
| - name: SetOutputs | |
| id: set-outputs | |
| run: | | |
| echo "::set-output name=CWA_GITHUB_TEST_REPO_NAME::${{ env.CWA_GITHUB_TEST_REPO_NAME }}" | |
| echo "::set-output name=CWA_GITHUB_TEST_REPO_URL::${{ env.CWA_GITHUB_TEST_REPO_URL }}" | |
| echo "::set-output name=CWA_GITHUB_TEST_REPO_BRANCH::${{ env.CWA_GITHUB_TEST_REPO_BRANCH }}" | |
| echo "::set-output name=ECR_INTEGRATION_TEST_REPO::cwagent-integration-test" | |
| echo "::set-output name=ECR_OPERATOR_REPO::$(echo "${{ vars.ECR_OPERATOR_STAGING_REPO }}" | awk -F'/' '{print $NF}')" | |
| - name: Echo test variables | |
| run: | | |
| echo "CWA_GITHUB_TEST_REPO_NAME: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_NAME }}" | |
| echo "CWA_GITHUB_TEST_REPO_URL: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_URL }}" | |
| echo "CWA_GITHUB_TEST_REPO_BRANCH: ${{ steps.set-outputs.outputs.CWA_GITHUB_TEST_REPO_BRANCH }}" | |
| echo "ECR_INTEGRATION_TEST_REPO: ${{ steps.set-outputs.outputs.ECR_INTEGRATION_TEST_REPO }}" | |
| echo "ECR_OPERATOR_REPO: ${{ steps.set-outputs.outputs.ECR_OPERATOR_REPO }}" | |
| GenerateEKSPerformanceCluster: | |
| needs: [OutputEnvVariables] | |
| name: GenerateEKSPerformanceCluster | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| repository: ${{inputs.test_repo_name}} | |
| ref: ${{inputs.test_repo_branch}} | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ inputs.terraform_assume_role }} | |
| aws-region: ${{ inputs.region }} | |
| 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 | |
| with: | |
| terraform_version: 1.12.0 | |
| - name: Verify Terraform version | |
| run: terraform --version | |
| - name: Terraform Init | |
| run: terraform init | |
| - name: Terraform apply | |
| uses: nick-fields/retry@v2 | |
| with: | |
| max_attempts: 3 | |
| timeout_minutes: 60 | |
| retry_wait_seconds: 5 | |
| command: | | |
| if [ "${{ inputs.terraform_dir }}" != "" ]; then | |
| cd "${{ inputs.terraform_dir }}" | |
| else | |
| cd terraform/eks/performance | |
| fi | |
| if terraform apply --auto-approve \ | |
| -var="region=${{ inputs.region }}" \ | |
| -var="var.cluster_name=${{ inputs.cluster_name }}" \ | |
| -var="helm_charts_branch=${{ inputs.helm_charts_branch }}" \ | |
| -var="cloudwatch_agent_repository_url=${{ steps.login-ecr.outputs.registry }}" \ | |
| -var="cloudwatch_agent_repository=${{ inputs.cloudwatch_agent_repository }}" \ | |
| -var="cloudwatch_agent_tag=${{ inputs.cloudwatch_agent_tag }}" \ | |
| -var="cloudwatch_agent_operator_repository_url=${{ steps.login-ecr.outputs.registry }}" \ | |
| -var="cloudwatch_agent_operator_repository=${{ inputs.cloudwatch_agent_operator_repository }}" \ | |
| -var="cloudwatch_agent_operator_tag=${{ inputs.cloudwatch_agent_operator_tag }}" \ | |
| -var="cloudwatch_agent_target_allocator_repository_url=${{ steps.login-ecr.outputs.registry }}" \ | |
| -var="cloudwatch_agent_target_allocator_tag=${{ inputs.cloudwatch_agent_operator_tag }}" \ | |
| fi | |
| # CleanupEKSPerformanceCluster: | |
| # needs: [ GenerateEKSPerformanceCluster ] | |
| # runs-on: ubuntu-latest | |
| # steps: | |
| # - name: Checkout Repository | |
| # uses: actions/checkout@v3 | |
| # | |
| # - name: Configure AWS Credentials | |
| # uses: aws-actions/configure-aws-credentials@v4 | |
| # with: | |
| # role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }} | |
| # aws-region: ${{ inputs.region || 'us-west-2' }} | |
| # role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} | |
| # | |
| # - name: Setup Terraform | |
| # uses: hashicorp/setup-terraform@v3 | |
| # with: | |
| # terraform_version: 1.12.0 | |
| # | |
| # - name: Terraform Init | |
| # run: terraform init | |
| # | |
| # | |
| # - name: Terraform destroy | |
| # run: terraform destroy --auto-approve \ | |
| # -var="region=${{ inputs.region || 'us-west-2' }}" \ | |
| # -var="cluster_name=${{ inputs.cluster_name }}" \ | |
| # -var="eks_deployment_strategy=DAEMON" | |