|
| 1 | +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +name: "EKS Performance Cluster Tests" |
| 4 | +on: |
| 5 | + # Use workflow_run to trigger this workflow after the scaling workflow completes |
| 6 | + workflow_run: |
| 7 | + workflows: [ "EKS Performance Test Run" ] |
| 8 | + types: |
| 9 | + - completed |
| 10 | + branches: |
| 11 | + - main # Adjust this if your default branch is different |
| 12 | + |
| 13 | + # Keep the manual trigger option |
| 14 | + workflow_dispatch: |
| 15 | + inputs: |
| 16 | + # Required Core Settings |
| 17 | + cluster_name: |
| 18 | + description: 'EKS Cluster Name' |
| 19 | + required: true |
| 20 | + type: string |
| 21 | + default: 'eks-performance' |
| 22 | + region: |
| 23 | + description: 'AWS Region' |
| 24 | + required: true |
| 25 | + type: string |
| 26 | + default: 'us-west-2' |
| 27 | + metric_map: |
| 28 | + description: 'Map containing metrics to validate' |
| 29 | + type: string |
| 30 | + |
| 31 | + # Optional Settings |
| 32 | + terraform_assume_role: |
| 33 | + description: 'AWS IAM Role to assume' |
| 34 | + type: string |
| 35 | + test_repo_name: |
| 36 | + description: 'Agent test repo' |
| 37 | + type: string |
| 38 | + test_repo_branch: |
| 39 | + description: 'Agent test repo branch' |
| 40 | + type: string |
| 41 | + test_dir: |
| 42 | + description: 'Agent test directory' |
| 43 | + type: string |
| 44 | + |
| 45 | + |
| 46 | +concurrency: |
| 47 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 48 | + cancel-in-progress: true |
| 49 | + |
| 50 | +env: |
| 51 | + # Cluster environment variables |
| 52 | + AWS_REGION: ${{ inputs.region || 'us-west-2' }} |
| 53 | + CLUSTER_NAME: ${{ inputs.cluster_name || 'eks-performance' }} |
| 54 | + TERRAFORM_AWS_ASSUME_ROLE: ${{ inputs.terraform_assume_role || vars.TERRAFORM_AWS_ASSUME_ROLE }} |
| 55 | + TERRAFORM_AWS_ASSUME_ROLE_DURATION: 14400 # 4 hour duration |
| 56 | + |
| 57 | + # Agent test repo environment variables |
| 58 | + CWA_GITHUB_TEST_REPO_NAME: ${{ inputs.test_repo_name || 'aws/amazon-cloudwatch-agent-test' }} |
| 59 | + CWA_GITHUB_TEST_REPO_BRANCH: ${{ inputs.test_repo_branch || 'main' }} |
| 60 | + CWA_TEST_DIRECTORY: ${{ inputs.test_dir || './test/performance/eks' }} |
| 61 | + |
| 62 | +jobs: |
| 63 | + # Check if this workflow should run, doesn't need to run test if no nodes exist |
| 64 | + check-trigger: |
| 65 | + runs-on: ubuntu-latest |
| 66 | + if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'schedule') }} |
| 67 | + permissions: |
| 68 | + id-token: write |
| 69 | + contents: read |
| 70 | + steps: |
| 71 | + - name: Check trigger type |
| 72 | + id: check-trigger |
| 73 | + run: | |
| 74 | + if [ "${{ github.event_name }}" == "workflow_run" ]; then |
| 75 | + echo "Triggered by workflow_run from a scheduled event" |
| 76 | + else |
| 77 | + echo "Triggered manually via workflow_dispatch" |
| 78 | + fi |
| 79 | +
|
| 80 | + - name: Configure AWS Credentials |
| 81 | + uses: aws-actions/configure-aws-credentials@v4 |
| 82 | + with: |
| 83 | + role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE}} |
| 84 | + aws-region: ${{ env.AWS_REGION}} |
| 85 | + role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} |
| 86 | + |
| 87 | + - name: Install kubectl |
| 88 | + uses: azure/setup-kubectl@v3 |
| 89 | + with: |
| 90 | + version: 'latest' |
| 91 | + |
| 92 | + - name: Update kubeconfig |
| 93 | + run: | |
| 94 | + aws eks update-kubeconfig --name $CLUSTER_NAME --region $AWS_REGION |
| 95 | +
|
| 96 | + - name: Override should_continue based on node count |
| 97 | + id: final-check |
| 98 | + run: | |
| 99 | + NODE_COUNT=$(kubectl get nodes --no-headers | wc -l) |
| 100 | + echo "Node count: $NODE_COUNT" |
| 101 | +
|
| 102 | + if [ "$NODE_COUNT" -eq 0 ]; then |
| 103 | + echo "No nodes available, setting should_continue to false" |
| 104 | + echo "should_continue=false" >> "$GITHUB_OUTPUT" |
| 105 | + else |
| 106 | + echo "Nodes available, setting should_continue as true" |
| 107 | + echo "should_continue=true" >> "$GITHUB_OUTPUT" |
| 108 | + fi |
| 109 | +
|
| 110 | + outputs: |
| 111 | + should_continue: ${{ steps.final-check.outputs.should_continue }} |
| 112 | + |
| 113 | + EKSPerformanceBaseTest: |
| 114 | + name: EKSPerformanceBaseTest |
| 115 | + needs: [ check-trigger ] |
| 116 | + if: ${{ needs.check-trigger.outputs.should_continue == 'true' }} |
| 117 | + runs-on: ubuntu-latest |
| 118 | + permissions: |
| 119 | + id-token: write |
| 120 | + contents: read |
| 121 | + steps: |
| 122 | + - name: Set up Go 1.x |
| 123 | + uses: actions/setup-go@v4 |
| 124 | + with: |
| 125 | + go-version: ~1.24.4 |
| 126 | + |
| 127 | + - uses: actions/checkout@v4 |
| 128 | + with: |
| 129 | + repository: ${{ env.CWA_GITHUB_TEST_REPO_NAME }} |
| 130 | + ref: ${{ env.CWA_GITHUB_TEST_REPO_BRANCH }} |
| 131 | + |
| 132 | + - name: Configure AWS Credentials |
| 133 | + uses: aws-actions/configure-aws-credentials@v4 |
| 134 | + with: |
| 135 | + role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE}} |
| 136 | + aws-region: ${{ env.AWS_REGION}} |
| 137 | + role-duration-seconds: ${{ env.TERRAFORM_AWS_ASSUME_ROLE_DURATION }} |
| 138 | + |
| 139 | + - name: Login ECR |
| 140 | + id: login-ecr |
| 141 | + uses: aws-actions/amazon-ecr-login@v2 |
| 142 | + |
| 143 | + - name: Install kubectl |
| 144 | + uses: azure/setup-kubectl@v3 |
| 145 | + with: |
| 146 | + version: 'latest' |
| 147 | + |
| 148 | + - name: Update kubeconfig |
| 149 | + run: | |
| 150 | + aws eks update-kubeconfig --name $CLUSTER_NAME --region $AWS_REGION |
| 151 | +
|
| 152 | + - name: Install Sample Application |
| 153 | + uses: nick-fields/retry@v2 |
| 154 | + with: |
| 155 | + max_attempts: 2 |
| 156 | + timeout_minutes: 20 |
| 157 | + command: | |
| 158 | + cd test/performance/eks/resources |
| 159 | + kubectl apply -f petclinic-sample-app |
| 160 | + echo "Waiting 15 minutes for the application to initialize..." |
| 161 | + sleep 900 |
| 162 | +
|
| 163 | + - name: Run Performance Test |
| 164 | + uses: nick-fields/retry@v2 |
| 165 | + with: |
| 166 | + max_attempts: 2 |
| 167 | + timeout_minutes: 20 |
| 168 | + command: | |
| 169 | + go test -timeout 30m -v $CWA_TEST_DIRECTORY \ |
| 170 | + -computeType=EKS \ |
| 171 | + -eksClusterName=$CLUSTER_NAME \ |
| 172 | + -performanceMetricMapName=${{ inputs.metric_map || 'base-performance-metrics-map.json' }} \ |
| 173 | + -performanceTestName=EKSPerformanceBaseTest |
| 174 | +
|
| 175 | + - name: Cleanup Sample Application |
| 176 | + if: always() |
| 177 | + run: | |
| 178 | + cd test/performance/eks/resources |
| 179 | + kubectl delete -f petclinic-sample-app |
| 180 | + echo "Sample application resources have been deleted" |
| 181 | +
|
0 commit comments