Skip to content

Commit

Permalink
Consolidate release for K8s (#118)
Browse files Browse the repository at this point in the history
*Issue description:*
Separating this
[PR](#109)
into two to make it easier for review:

Test run:
https://github.com/aws-observability/aws-application-signals-test-framework/actions/runs/9963325687

*Ensure you've run the following tests on your changes and include the
link below:*
To do so, create a `test.yml` file with `name: Test` and workflow
description to test your changes, then remove the file for your PR. Link
your test run in your PR description. This process is a short term
solution while we work on creating a staging environment for testing.

NOTE: TESTS RUNNING ON A SINGLE EKS CLUSTER CANNOT BE RUN IN PARALLEL.
See the
[needs](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idneeds)
keyword to run tests in succession.
- Run Java EKS on `e2e-playground` in us-east-1 and eu-central-2
- Run Python EKS on `e2e-playground` in us-east-1 and eu-central-2
- Run metric limiter on EKS cluster `e2e-playground` in us-east-1 and
eu-central-2
- Run EC2 tests in all regions
- Run K8s on a separate K8s cluster (check IAD test account for master
node endpoints; these will change as we create and destroy clusters for
OS patching)

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
  • Loading branch information
harrryr authored Jul 19, 2024
1 parent 1612117 commit 5154fbc
Show file tree
Hide file tree
Showing 10 changed files with 276 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## Operator and our sample app and remote service onto a native K8s cluster, call the
## APIs, and validate the generated telemetry, including logs, metrics, and traces.
## It will then clean up the cluster and EC2 instance it runs on for the next test run.
name: Application Signals Enablement - Java E2E K8s Canary Testing
name: Java K8s E2E Canary Testing
on:
schedule:
- cron: '*/15 * * * *' # run the workflow every 15 minutes
Expand All @@ -17,8 +17,8 @@ permissions:
contents: read

jobs:
e2e-k8s-test:
uses: ./.github/workflows/application-signals-java-e2e-k8s-test.yml
k8s:
uses: ./.github/workflows/java-k8s-e2e-test.yml
secrets: inherit
with:
# To run in more regions, a cluster must be provisioned manually on EC2 instances in that region
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This is a reusable workflow for running the E2E test for App Signals.
# It is meant to be called from another workflow.
# Read more about reusable workflows: https://docs.github.com/en/actions/using-workflows/reusing-workflows#overview
name: Application Signals Enablement E2E Testing - Java E2E K8s on EC2 Use Case
name: Java K8s on EC2 Use Case
on:
workflow_call:
inputs:
Expand All @@ -14,6 +14,12 @@ on:
caller-workflow-name:
required: true
type: string
adot-image-name:
required: false
type: string
cw-agent-operator-tag:
required: false
type: string

concurrency:
group: '${{ github.workflow }} @ ${{ inputs.aws-region }}'
Expand All @@ -24,26 +30,34 @@ permissions:
contents: read

env:
# The presence of this env var is required for use by terraform and AWS CLI commands
# It is not redundant
TEST_ACCOUNT: ${{ secrets.APP_SIGNALS_E2E_TEST_ACC }}
E2E_TEST_AWS_REGION: ${{ inputs.aws-region }}
CALLER_WORKFLOW_NAME: ${{ inputs.caller-workflow-name }}
ADOT_IMAGE_NAME: ${{ inputs.adot-image-name }}
CW_AGENT_OPERATOR_TAG: ${{ inputs.cw-agent-operator-tag }}
E2E_TEST_ACCOUNT_ID: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ACCOUNT_ID }}
E2E_TEST_ROLE_NAME: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ROLE_NAME }}
SAMPLE_APP_NAMESPACE: sample-app-namespace
METRIC_NAMESPACE: ApplicationSignals
LOG_GROUP_NAME: /aws/application-signals/data
MASTER_NODE_SSH_KEY: ${{ secrets.APP_SIGNALS_E2E_K8S_SSH_KEY_IAD }}
MAIN_SERVICE_ENDPOINT: ${{ secrets.APP_SIGNALS_E2E_K8S_MASTER_NODE_ENDPOINT }}
SAMPLE_APP_NAMESPACE: sample-app-namespace
TEST_RESOURCES_FOLDER: /__w/aws-application-signals-test-framework/aws-application-signals-test-framework
TEST_RESOURCES_FOLDER: ${GITHUB_WORKSPACE}

jobs:
e2e-k8s-test:
java-k8s:
runs-on: ubuntu-latest
container:
image: public.ecr.aws/h6o3z5z9/aws-application-signals-test-framework-workflow-container:latest
steps:
- name: Generate testing id
run: echo TESTING_ID="${{ env.E2E_TEST_AWS_REGION }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV

- uses: actions/checkout@v4
with:
repository: 'aws-observability/aws-application-signals-test-framework'
ref: ${{ env.CALLER_WORKFLOW_NAME == 'main-build' && 'main' || github.ref }}
fetch-depth: 0

# We initialize Gradlew Daemon early on during the workflow because sometimes initialization
# fails due to transient issues. If it fails here, then we will try again later before the validators
- name: Initiate Gradlew Daemon
id: initiate-gradlew
uses: ./.github/workflows/actions/execute_and_retry
Expand All @@ -54,36 +68,32 @@ jobs:
max_retry: 3
sleep_time: 60

- name: Generate testing id
run: echo TESTING_ID="${{ inputs.aws-region }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.E2E_IAD_TEST_ACCOUNT_ARN }}
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/${{ inputs.aws-region }}

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ secrets.E2E_TEST_ROLE_ARN }}
aws-region: ${{ inputs.aws-region }}
secret-ids: |
ACCOUNT_ID, region-account/${{ env.E2E_TEST_AWS_REGION }}
JAVA_MAIN_SAMPLE_APP_IMAGE, e2e-test/java-main-sample-app-image
JAVA_REMOTE_SAMPLE_APP_IMAGE, e2e-test/java-remote-sample-app-image
RELEASE_TESTING_ECR_ACCOUNT, e2e-test/${{ github.event.repository.name }}/java-k8s-release-testing-account
MAIN_SERVICE_ENDPOINT, e2e-test/${{ github.event.repository.name }}/java-k8s-master-node-endpoint
MASTER_NODE_SSH_KEY, e2e-test/${{ github.event.repository.name }}/java-k8s-ssh-key
- name: Prepare and upload sample app deployment files
working-directory: terraform/java/k8s/deploy/resources
run: |
sed -i 's#\${TESTING_ID}#${{ env.TESTING_ID }}#' frontend-service-depl.yaml
sed -i 's#\${IMAGE}#${{ env.ACCOUNT_ID }}.dkr.ecr.${{ inputs.aws-region }}.amazonaws.com/${{ secrets.APP_SIGNALS_E2E_FE_SA_IMG }}#' frontend-service-depl.yaml
sed -i 's#\${IMAGE}#${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.E2E_TEST_AWS_REGION }}.amazonaws.com/${{ env.JAVA_MAIN_SAMPLE_APP_IMAGE }}#' frontend-service-depl.yaml
sed -i 's#\${TESTING_ID}#${{ env.TESTING_ID }}#' remote-service-depl.yaml
sed -i 's#\${IMAGE}#${{ env.ACCOUNT_ID }}.dkr.ecr.${{ inputs.aws-region }}.amazonaws.com/${{ secrets.APP_SIGNALS_E2E_RE_SA_IMG }}#' remote-service-depl.yaml
aws s3api put-object --bucket ${{ secrets.APP_SIGNALS_E2E_EC2_JAR }}-prod-${{ inputs.aws-region }} --key frontend-service-depl.yaml --body frontend-service-depl.yaml
aws s3api put-object --bucket ${{ secrets.APP_SIGNALS_E2E_EC2_JAR }}-prod-${{ inputs.aws-region }} --key remote-service-depl.yaml --body remote-service-depl.yaml
sed -i 's#\${IMAGE}#${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.E2E_TEST_AWS_REGION }}.amazonaws.com/${{ env.JAVA_REMOTE_SAMPLE_APP_IMAGE }}#' remote-service-depl.yaml
aws s3api put-object --bucket aws-appsignals-sample-app-prod-${{ env.E2E_TEST_AWS_REGION }} --key frontend-service-depl-${{ github.event.repository.name }}.yaml --body frontend-service-depl.yaml
aws s3api put-object --bucket aws-appsignals-sample-app-prod-${{ env.E2E_TEST_AWS_REGION }} --key remote-service-depl-${{ github.event.repository.name }}.yaml --body remote-service-depl.yaml
- name: Initiate Terraform
uses: ./.github/workflows/actions/execute_and_retry
Expand All @@ -93,18 +103,31 @@ jobs:
max_retry: 6
sleep_time: 60

- name: Get ECR to Patch
run: |
if [ "${{ github.event.repository.name }}" = "amazon-cloudwatch-agent" ]; then
echo PATCH_IMAGE_ARN="${{ secrets.AWS_ECR_PRIVATE_REGISTRY }}/cwagent-integration-test:${{ github.sha }}" >> $GITHUB_ENV
elif [ "${{ github.event.repository.name }}" = "amazon-cloudwatch-agent-operator" ]; then
echo PATCH_IMAGE_ARN="${{ vars.ECR_OPERATOR_STAGING_REPO }}:${{ env.CW_AGENT_OPERATOR_TAG }}" >> $GITHUB_ENV
elif [ "${{ github.event.repository.name }}" = "aws-otel-java-instrumentation" ]; then
echo PATCH_IMAGE_ARN="${{ env.ADOT_IMAGE_NAME }}" >> $GITHUB_ENV
fi
- name: Deploy Operator and Sample App using Terraform
working-directory: terraform/java/k8s/deploy
run: |
terraform apply -auto-approve \
-var="aws_region=${{ inputs.aws-region }}" \
-var="aws_region=${{ env.E2E_TEST_AWS_REGION }}" \
-var="test_id=${{ env.TESTING_ID }}" \
-var="ssh_key=${{ env.MASTER_NODE_SSH_KEY }}" \
-var="host=${{ env.MAIN_SERVICE_ENDPOINT }}"
-var="host=${{ env.MAIN_SERVICE_ENDPOINT }}" \
-var="repository=${{ github.event.repository.name }}" \
-var="patch_image_arn=${{ env.PATCH_IMAGE_ARN }}" \
-var="release_testing_ecr_account=${{ env.RELEASE_TESTING_ECR_ACCOUNT }}"
- name: Get Remote Service IP
run: |
echo REMOTE_SERVICE_IP="$(aws ssm get-parameter --region ${{ inputs.aws-region }} --name remote-service-ip | jq -r '.Parameter.Value')" >> $GITHUB_ENV
echo REMOTE_SERVICE_IP="$(aws ssm get-parameter --region ${{ env.E2E_TEST_AWS_REGION }} --name remote-service-ip-${{ env.TESTING_ID }} | jq -r '.Parameter.Value')" >> $GITHUB_ENV
- name: Wait for app endpoint to come online
id: endpoint-check
Expand Down Expand Up @@ -147,7 +170,7 @@ jobs:
run: ./gradlew validator:run --args='-c java/k8s/log-validation.yml
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}:30100
--region ${{ inputs.aws-region }}
--region ${{ env.E2E_TEST_AWS_REGION }}
--account-id ${{ env.ACCOUNT_ID }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -164,7 +187,7 @@ jobs:
run: ./gradlew validator:run --args='-c java/k8s/metric-validation.yml
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}:30100
--region ${{ inputs.aws-region }}
--region ${{ env.E2E_TEST_AWS_REGION }}
--account-id ${{ env.ACCOUNT_ID }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -182,7 +205,7 @@ jobs:
run: ./gradlew validator:run --args='-c java/k8s/trace-validation.yml
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}:30100
--region ${{ inputs.aws-region }}
--region ${{ env.E2E_TEST_AWS_REGION }}
--account-id ${{ env.ACCOUNT_ID }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -200,15 +223,15 @@ jobs:
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=${{ inputs.caller-workflow-name }} \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 0.0 \
--region ${{ inputs.aws-region }}
--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=${{ inputs.caller-workflow-name }} \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ env.CALLER_WORKFLOW_NAME }} \
--value 1.0 \
--region ${{ inputs.aws-region }}
--region ${{ env.E2E_TEST_AWS_REGION }}
fi
# Clean up Procedures
Expand All @@ -224,7 +247,7 @@ jobs:
working-directory: terraform/java/k8s/cleanup
run: |
terraform apply -auto-approve \
-var="aws_region=${{ inputs.aws-region }}" \
-var="aws_region=${{ env.E2E_TEST_AWS_REGION }}" \
-var="test_id=${{ env.TESTING_ID }}" \
-var="ssh_key=${{ env.MASTER_NODE_SSH_KEY }}" \
-var="host=${{ env.MAIN_SERVICE_ENDPOINT }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Operator and our sample app and remote service onto a native K8s cluster, call the
## APIs, and validate the generated telemetry, including logs, metrics, and traces.
## It will then clean up the cluster and EC2 instance it runs on for the next test run.
name: Application Signals Enablement - Python E2E K8s Canary Testing
name: Python K8s E2E Canary Testing
on:
schedule:
- cron: '*/15 * * * *' # run the workflow every 15 minutes
Expand All @@ -15,8 +15,8 @@ permissions:
contents: read

jobs:
e2e-k8s-test:
uses: ./.github/workflows/application-signals-python-e2e-k8s-test.yml
k8s:
uses: ./.github/workflows/python-k8s-e2e-test.yml
secrets: inherit
with:
# To run in more regions, a cluster must be provisioned manually on EC2 instances in that region
Expand Down
Loading

0 comments on commit 5154fbc

Please sign in to comment.