Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
harrryr committed Aug 18, 2024
2 parents 2d7e11c + 09d5672 commit 9e00d1f
Show file tree
Hide file tree
Showing 28 changed files with 997 additions and 183 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/e2e-test-publish-result.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Application Signals Enablement E2E Testing - Publish Result
on:
workflow_call:
inputs:
aws-region:
required: true
type: string
caller-workflow-name:
required: true
type: string
validation-result:
required: true
type: string

permissions:
id-token: write
contents: read

env:
E2E_TEST_AWS_REGION: ${{ inputs.aws-region }}
CALLER_WORKFLOW_NAME: ${{ inputs.caller-workflow-name }}
VALIDATION_RESULT: ${{ inputs.validation-result }}
E2E_TEST_ACCOUNT_ID: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ACCOUNT_ID }}
E2E_TEST_ROLE_NAME: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ROLE_NAME }}

jobs:
publish-result:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ env.E2E_TEST_ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}
aws-region: us-east-1

- name: Retrieve account
uses: aws-actions/aws-secretsmanager-get-secrets@v1
with:
secret-ids:
ACCOUNT_ID, region-account/${{ env.E2E_TEST_AWS_REGION }}

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}
aws-region: ${{ env.E2E_TEST_AWS_REGION }}

- name: Publish metric on test result
run: |
if [ "${{ env.VALIDATION_RESULT }}" = "success" ]; then
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 0.0 \
--region ${{ env.E2E_TEST_AWS_REGION }}
else
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 1.0 \
--region ${{ env.E2E_TEST_AWS_REGION }}
fi
31 changes: 18 additions & 13 deletions .github/workflows/java-ec2-asg-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ env:
jobs:
java-ec2-asg:
runs-on: ubuntu-latest
outputs:
validation-result: ${{ steps.validation-result.outputs.validation-result }}
steps:
- name: Generate testing id
run: echo TESTING_ID="${{ github.job }}-${{ github.run_id }}-${{ github.run_number }}-$(date +%s)" >> $GITHUB_ENV
Expand Down Expand Up @@ -241,26 +243,29 @@ jobs:
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}
aws-region: ${{ env.E2E_TEST_AWS_REGION }}

- name: Publish metric on test result
- name: Save test results
if: always()
id: validation-result
run: |
if [ "${{ steps.log-validation.outcome }}" = "success" ] && [ "${{ steps.metric-validation.outcome }}" = "success" ] && [ "${{ steps.trace-validation.outcome }}" = "success" ]; then
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 0.0 \
--region ${{ env.E2E_TEST_AWS_REGION }}
echo "validation-result=success" >> $GITHUB_OUTPUT
else
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 1.0 \
--region ${{ env.E2E_TEST_AWS_REGION }}
fi
echo "validation-result=failure" >> $GITHUB_OUTPUT
fi
# Clean up Procedures
- name: Terraform destroy
working-directory: terraform/java/ec2/asg
run: |
terraform destroy -auto-approve \
-var="test_id=${{ env.TESTING_ID }}"
-var="test_id=${{ env.TESTING_ID }}"
emit-metric:
needs: java-ec2-asg
if: always()
uses: ./.github/workflows/e2e-test-publish-result.yml
secrets: inherit
with:
aws-region: ${{ inputs.aws-region }}
caller-workflow-name: ${{ inputs.caller-workflow-name }}
validation-result: ${{ needs.java-ec2-asg.outputs.validation-result }}
29 changes: 17 additions & 12 deletions .github/workflows/java-ec2-default-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ env:
jobs:
java-ec2-default:
runs-on: ubuntu-latest
outputs:
validation-result: ${{ steps.validation-result.outputs.validation-result }}
steps:
- name: Generate testing id
run: echo TESTING_ID="${{ github.job }}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}" >> $GITHUB_ENV
Expand Down Expand Up @@ -236,21 +238,14 @@ jobs:
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}
aws-region: ${{ env.E2E_TEST_AWS_REGION }}

- name: Publish metric on test result
- name: Save test results
if: always()
id: validation-result
run: |
if [ "${{ steps.log-validation.outcome }}" = "success" ] && [ "${{ steps.metric-validation.outcome }}" = "success" ] && [ "${{ steps.trace-validation.outcome }}" = "success" ]; then
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 0.0 \
--region ${{ inputs.aws-region }}
echo "validation-result=success" >> $GITHUB_OUTPUT
else
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 1.0 \
--region ${{ inputs.aws-region }}
echo "validation-result=failure" >> $GITHUB_OUTPUT
fi
# Clean up Procedures
Expand All @@ -260,4 +255,14 @@ jobs:
working-directory: terraform/java/ec2/default
run: |
terraform destroy -auto-approve \
-var="test_id=${{ env.TESTING_ID }}"
-var="test_id=${{ env.TESTING_ID }}"
emit-metric:
needs: java-ec2-default
if: always()
uses: ./.github/workflows/e2e-test-publish-result.yml
secrets: inherit
with:
aws-region: ${{ inputs.aws-region }}
caller-workflow-name: ${{ inputs.caller-workflow-name }}
validation-result: ${{ needs.java-ec2-default.outputs.validation-result }}
37 changes: 24 additions & 13 deletions .github/workflows/java-eks-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ env:
jobs:
java-eks:
runs-on: ubuntu-latest
outputs:
validation-result: ${{ steps.validation-result.outputs.validation-result }}
steps:
- name: Generate testing id and sample app namespace
run: |
Expand Down Expand Up @@ -94,7 +96,7 @@ jobs:
aws-region: us-east-1

- name: Retrieve account
uses: aws-actions/aws-secretsmanager-get-secrets@v1
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
ACCOUNT_ID, region-account/${{ env.E2E_TEST_AWS_REGION }}
Expand Down Expand Up @@ -184,7 +186,9 @@ jobs:
- name: Get RDS database credentials from SecretsManager
continue-on-error: true
uses: aws-actions/aws-secretsmanager-get-secrets@v1
uses: aws-actions/aws-secretsmanager-get-secrets@v2
env:
NODE_OPTIONS: "--network-family-autoselection-attempt-timeout=1000"
with:
secret-ids:
RDS_MYSQL_CLUSTER_SECRETS, ${{env.RDS_MYSQL_CLUSTER_CREDENTIAL_SECRET_NAME}}
Expand Down Expand Up @@ -356,6 +360,7 @@ jobs:
--service-name sample-application-${{ env.TESTING_ID }}
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_DEPLOYMENT_NAME }}
--remote-resource-identifier "information_schema|${{env.RDS_MYSQL_CLUSTER_ENDPOINT}}|3306"
--remote-db-user ${{ env.RDS_MYSQL_CLUSTER_SECRETS_USERNAME }}
--query-string ip=${{ env.REMOTE_SERVICE_POD_IP }}&testingId=${{ env.TESTING_ID }}
--rollup'

Expand Down Expand Up @@ -403,21 +408,14 @@ jobs:
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}
aws-region: ${{ env.E2E_TEST_AWS_REGION }}

- name: Publish metric on test result
- name: Save test results
if: always()
id: validation-result
run: |
if [ "${{ steps.log-validation.outcome }}" = "success" ] && [ "${{ steps.metric-validation.outcome }}" = "success" ] && [ "${{ steps.trace-validation.outcome }}" = "success" ]; then
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 0.0 \
--region ${{ env.E2E_TEST_AWS_REGION }}
echo "validation-result=success" >> $GITHUB_OUTPUT
else
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 1.0 \
--region ${{ env.E2E_TEST_AWS_REGION }}
echo "validation-result=failure" >> $GITHUB_OUTPUT
fi
# Clean up Procedures
Expand Down Expand Up @@ -464,3 +462,16 @@ jobs:
--namespace ${{ env.SAMPLE_APP_NAMESPACE }} \
--cluster ${{ env.CLUSTER_NAME }} \
--region ${{ env.E2E_TEST_AWS_REGION }}
emit-metric:
needs: java-eks
if: always()
uses: ./.github/workflows/e2e-test-publish-result.yml
secrets: inherit
with:
aws-region: ${{ inputs.aws-region }}
caller-workflow-name: ${{ inputs.caller-workflow-name }}
validation-result: ${{ needs.java-eks.outputs.validation-result }}



29 changes: 17 additions & 12 deletions .github/workflows/java-k8s-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ env:
jobs:
java-k8s:
runs-on: ubuntu-latest
outputs:
validation-result: ${{ steps.validation-result.outputs.validation-result }}
steps:
- name: Generate testing id
run: echo TESTING_ID="${{ env.E2E_TEST_AWS_REGION }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV
Expand Down Expand Up @@ -205,21 +207,14 @@ jobs:
role-to-assume: arn:aws:iam::${{ env.E2E_TEST_ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}
aws-region: us-east-1

- name: Publish metric on test result
- name: Save test results
if: always()
id: validation-result
run: |
if [ "${{ steps.log-validation.outcome }}" = "success" ] && [ "${{ steps.metric-validation.outcome }}" = "success" ] && [ "${{ steps.trace-validation.outcome }}" = "success" ]; then
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 0.0 \
--region ${{ env.E2E_TEST_AWS_REGION }}
echo "validation-result=success" >> $GITHUB_OUTPUT
else
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 1.0 \
--region ${{ env.E2E_TEST_AWS_REGION }}
echo "validation-result=failure" >> $GITHUB_OUTPUT
fi
# Clean up Procedures
Expand Down Expand Up @@ -254,4 +249,14 @@ jobs:
working-directory: terraform/java/k8s/cleanup
run: |
terraform destroy -auto-approve \
-var="test_id=${{ env.TESTING_ID }}"
-var="test_id=${{ env.TESTING_ID }}"
emit-metric:
needs: java-k8s
if: always()
uses: ./.github/workflows/e2e-test-publish-result.yml
secrets: inherit
with:
aws-region: ${{ inputs.aws-region }}
caller-workflow-name: ${{ inputs.caller-workflow-name }}
validation-result: ${{ needs.java-k8s.outputs.validation-result }}
45 changes: 27 additions & 18 deletions .github/workflows/java-metric-limiter-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ env:
jobs:
java-metric-limiter:
runs-on: ubuntu-latest
outputs:
validation-result: ${{ steps.validation-result.outputs.validation-result }}
steps:
- name: Generate testing id and sample app namespace
run: |
Expand Down Expand Up @@ -218,12 +220,6 @@ jobs:
${{ env.SAMPLE_APP_NAMESPACE }} && \
aws eks update-kubeconfig --name ${{ env.CLUSTER_NAME }} --region ${{ env.E2E_TEST_AWS_REGION }}" \
60
aws eks update-addon \
--cluster-name ${{ env.CLUSTER_NAME }} \
--addon-name amazon-cloudwatch-observability \
--region ${{ env.E2E_TEST_AWS_REGION }} \
--configuration-values '{"agent":{"config":{"logs":{"metrics_collected":{"app_signals":{"limiter":{"drop_threshold":2}}}}}}}'
execute_and_retry 2 "kubectl delete pods --all -n ${{ env.SAMPLE_APP_NAMESPACE }}" "" 60
execute_and_retry 2 "kubectl wait --for=condition=Ready --request-timeout '5m' pod --all -n ${{ env.SAMPLE_APP_NAMESPACE }}" "" 10
Expand Down Expand Up @@ -304,6 +300,15 @@ jobs:
kubectl get pods -n amazon-cloudwatch --output json | \
jq '.items[0].status.containerStatuses[0].imageID'
- name: Update metric limiter threshold
run: |
aws eks update-addon \
--cluster-name ${{ env.CLUSTER_NAME }} \
--addon-name amazon-cloudwatch-observability \
--region ${{ env.E2E_TEST_AWS_REGION }} \
--configuration-values '{"agent":{"config":{"logs":{"metrics_collected":{"app_signals":{"limiter":{"drop_threshold":2}}}}}}}' \
--resolve-conflicts OVERWRITE
- name: Get the sample app endpoint
run: echo "APP_ENDPOINT=$(kubectl get pods -n ${{ env.SAMPLE_APP_NAMESPACE }} --selector=app=sample-app -o jsonpath='{.items[0].status.podIP}'):8080" >> $GITHUB_ENV

Expand Down Expand Up @@ -341,21 +346,14 @@ jobs:
--query-string ip=${{ env.REMOTE_SERVICE_POD_IP }}&testingId=${{ env.TESTING_ID }}
--rollup'

- name: Publish metric on test result
- name: Output validation result
if: always()
id: validation-result
run: |
if [ "${{ steps.other-operation-metric-validation.outcome }}" = "success" ]; then
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 0.0 \
--region ${{ env.E2E_TEST_AWS_REGION }}
echo "validation-result=success" >> $GITHUB_OUTPUT
else
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 1.0 \
--region ${{ env.E2E_TEST_AWS_REGION }}
echo "validation-result=failure" >> $GITHUB_OUTPUT
fi
# Clean up Procedures
Expand Down Expand Up @@ -401,4 +399,15 @@ jobs:
--name sa-${{ env.TESTING_ID }} \
--namespace ${{ env.SAMPLE_APP_NAMESPACE }} \
--cluster ${{ env.CLUSTER_NAME }} \
--region ${{ env.E2E_TEST_AWS_REGION }}
--region ${{ env.E2E_TEST_AWS_REGION }}
emit-metric:
needs: java-metric-limiter
if: always()
uses: ./.github/workflows/e2e-test-publish-result.yml
secrets: inherit
with:
aws-region: ${{ inputs.aws-region }}
caller-workflow-name: ${{ inputs.caller-workflow-name }}
validation-result: ${{ needs.java-metric-limiter.outputs.validation-result }}

Loading

0 comments on commit 9e00d1f

Please sign in to comment.