From b17f7272540df6281843baa232ba0c9faebb635b Mon Sep 17 00:00:00 2001 From: Mahad Janjua Date: Tue, 16 Apr 2024 10:18:57 -0700 Subject: [PATCH] [E2E] Metric Schema Changes --- ...pplication-signals-python-e2e-ec2-test.yml | 40 +++++++++++-------- ...pplication-signals-python-e2e-eks-test.yml | 38 +++++++++++------- .github/workflows/test.yml | 32 +++++++++++++++ 3 files changed, 79 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/application-signals-python-e2e-ec2-test.yml b/.github/workflows/application-signals-python-e2e-ec2-test.yml index c446f1594..3151c6f22 100644 --- a/.github/workflows/application-signals-python-e2e-ec2-test.yml +++ b/.github/workflows/application-signals-python-e2e-ec2-test.yml @@ -24,14 +24,16 @@ permissions: contents: read env: - # The precense of this env var is required for use by terraform and AWS CLI commands + # The presence of this env var is required for use by terraform and AWS CLI commands # It is not redundant AWS_DEFAULT_REGION: ${{ inputs.aws-region }} TEST_ACCOUNT: ${{ secrets.APP_SIGNALS_E2E_TEST_ACC }} SAMPLE_APP_ZIP: s3://${{ secrets.E2E_TEST_BUCKET }}-prod-${{ inputs.aws-region }}/python-sample-app.zip - METRIC_NAMESPACE: AppSignals - LOG_GROUP_NAME: /aws/appsignals/generic + METRIC_NAMESPACE: ApplicationSignals + LOG_GROUP_NAME: /aws/application-signals/data ADOT_WHEEL_NAME: ${{ inputs.staging_wheel_name }} + GET_ADOT_JAR_COMMAND: "aws s3api get-object --bucket metric-schema-changes --key aws-opentelemetry-agent.jar adot.jar" + GET_CW_AGENT_RPM_COMMAND: "aws s3api get-object --bucket private-cloudwatch-agent-apm-beta --key linux_amd64/amazon-cloudwatch-agent.rpm cw-agent.rpm" jobs: python-e2e-ec2-test: @@ -43,10 +45,11 @@ jobs: uses: actions/checkout@v4 with: repository: aws-observability/aws-application-signals-test-framework - ref: main + ref: ga-python - name: Set CW Agent RPM environment variable - run: echo GET_CW_AGENT_RPM_COMMAND="wget -O cw-agent.rpm https://amazoncloudwatch-agent-${{ inputs.aws-region }}.s3.${{ inputs.aws-region }}.amazonaws.com/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm" >> $GITHUB_ENV + run: echo GET_CW_AGENT_RPM_COMMAND="aws s3api get-object --bucket private-cloudwatch-agent-apm-beta --key linux_amd64/amazon-cloudwatch-agent.rpm cw-agent.rpm" >> $GITHUB_ENV +# run: echo GET_CW_AGENT_RPM_COMMAND="wget -O cw-agent.rpm https://amazoncloudwatch-agent-${{ inputs.aws-region }}.s3.${{ inputs.aws-region }}.amazonaws.com/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm" >> $GITHUB_ENV - name: Generate testing id run: echo TESTING_ID="${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV @@ -81,12 +84,13 @@ jobs: - name: Set Get ADOT Wheel command environment variable working-directory: terraform/python/ec2 run: | - if [ ${{ inputs.caller-workflow-name }} == "main-build" ]; then - # Reusing the adot-main-build-staging-jar bucket to store the python wheel file - echo GET_ADOT_WHEEL_COMMAND="aws s3 cp s3://adot-main-build-staging-jar/${{ env.ADOT_WHEEL_NAME }} ./${{ env.ADOT_WHEEL_NAME }} && python3.9 -m pip install ${{ env.ADOT_WHEEL_NAME }}" >> $GITHUB_ENV - else - echo GET_ADOT_WHEEL_COMMAND="python3.9 -m pip install aws-opentelemetry-distro" >> $GITHUB_ENV - fi + echo GET_ADOT_WHEEL_COMMAND="aws s3api get-object --bucket metric-schema-changes --key aws_opentelemetry_distro-0.0.1.dev0-py3-none-any.whl aws_opentelemetry_distro-0.0.1.dev0-py3-none-any.whl && python3.9 -m pip install aws_opentelemetry_distro-0.0.1.dev0-py3-none-any.whl" >> $GITHUB_ENV +# if [ ${{ inputs.caller-workflow-name }} == "main-build" ]; then +# # Reusing the adot-main-build-staging-jar bucket to store the python wheel file +# echo GET_ADOT_WHEEL_COMMAND="aws s3 cp s3://adot-main-build-staging-jar/${{ env.ADOT_WHEEL_NAME }} ./${{ env.ADOT_WHEEL_NAME }} && python3.9 -m pip install ${{ env.ADOT_WHEEL_NAME }}" >> $GITHUB_ENV +# else +# echo GET_ADOT_WHEEL_COMMAND="python3.9 -m pip install aws-opentelemetry-distro" >> $GITHUB_ENV +# fi - name: Initiate Terraform uses: ./.github/workflows/actions/execute_and_retry @@ -163,19 +167,20 @@ jobs: working-directory: terraform/python/ec2 - name: Get the sample app endpoint + working-directory: terraform/python/ec2 run: | echo "MAIN_SERVICE_ENDPOINT=$(terraform output sample_app_main_service_public_dns):8000" >> $GITHUB_ENV echo "REMOTE_SERVICE_IP=$(terraform output sample_app_remote_service_public_ip)" >> $GITHUB_ENV - working-directory: terraform/python/ec2 + echo "MAIN_SERVICE_INSTANCE_ID=$(terraform output main_service_instance_id)" >> $GITHUB_ENV # This steps increases the speed of the validation by creating the telemetry data in advance - name: Call all test APIs continue-on-error: true run: | - curl -S -s -o /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/outgoing-http-call - curl -S -s -o /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call - curl -S -s -o /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_IP }} - curl -S -s -o /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/client-call + curl -S -s /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/outgoing-http-call; echo + curl -S -s /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call; echo + curl -S -s /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_IP }}; echo + curl -S -s /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/client-call # Validation for pulse telemetry data - name: Validate generated EMF logs @@ -192,6 +197,7 @@ jobs: --remote-service-name python-sample-remote-application-${{ env.TESTING_ID }} --request-body ip=${{ env.REMOTE_SERVICE_IP }} --instance-ami ${{ env.EC2_INSTANCE_AMI }} + --instance-id ${{ env.MAIN_SERVICE_INSTANCE_ID }} --rollup' - name: Validate generated metrics @@ -209,6 +215,7 @@ jobs: --remote-service-name python-sample-remote-application-${{ env.TESTING_ID }} --request-body ip=${{ env.REMOTE_SERVICE_IP }} --instance-ami ${{ env.EC2_INSTANCE_AMI }} + --instance-id ${{ env.MAIN_SERVICE_INSTANCE_ID }} --rollup' - name: Validate generated traces @@ -226,6 +233,7 @@ jobs: --remote-service-name python-sample-remote-application-${{ env.TESTING_ID }} --request-body ip=${{ env.REMOTE_SERVICE_IP }} --instance-ami ${{ env.EC2_INSTANCE_AMI }} + --instance-id ${{ env.MAIN_SERVICE_INSTANCE_ID }} --rollup' - name: Publish metric on test result diff --git a/.github/workflows/application-signals-python-e2e-eks-test.yml b/.github/workflows/application-signals-python-e2e-eks-test.yml index 77695a17c..cd08a43e6 100644 --- a/.github/workflows/application-signals-python-e2e-eks-test.yml +++ b/.github/workflows/application-signals-python-e2e-eks-test.yml @@ -29,11 +29,11 @@ permissions: contents: read env: - # The precense of this env var is required for use by terraform and AWS CLI commands + # The presence of this env var is required for use by terraform and AWS CLI commands # It is not redundant AWS_DEFAULT_REGION: ${{ inputs.aws-region }} - METRIC_NAMESPACE: AppSignals - LOG_GROUP_NAME: /aws/appsignals/eks + METRIC_NAMESPACE: ApplicationSignals + LOG_GROUP_NAME: /aws/application-signals/data jobs: python-e2e-eks-test: @@ -44,7 +44,7 @@ jobs: - uses: actions/checkout@v4 with: repository: aws-observability/aws-application-signals-test-framework - ref: main + ref: ga-python fetch-depth: 0 - name: Download enablement script @@ -159,13 +159,21 @@ jobs: ${{ env.PYTHON_SAMPLE_APP_NAMESPACE }} && \ aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ inputs.aws-region }}" - if [ "${{ inputs.caller-workflow-name }}" == "main-build" ]; then - echo "Patching staging adot image for main build:" - execute_and_retry 2 "kubectl patch deploy -namazon-cloudwatch amazon-cloudwatch-observability-controller-manager --type='json' \ - -p='[{"op": \"replace\", \"path\": \"/spec/template/spec/containers/0/args/0\", \"value\": \"--auto-instrumentation-python-image=${{ inputs.application-signals-adot-image }}:${{ inputs.application-signals-adot-image-tag }}\"}]'" - execute_and_retry 2 "kubectl delete pods --all -n amazon-cloudwatch" - execute_and_retry 2 "kubectl wait --for=condition=Ready pod --all -n amazon-cloudwatch" - fi + # if [ "${{ inputs.caller-workflow-name }}" == "main-build" ]; then + # echo "Patching staging adot image for main build:" + # execute_and_retry 2 "kubectl patch deploy -namazon-cloudwatch amazon-cloudwatch-observability-controller-manager --type='json' \ + # -p='[{"op": \"replace\", \"path\": \"/spec/template/spec/containers/0/args/0\", \"value\": \"--auto-instrumentation-python-image=${{ inputs.application-signals-adot-image }}:${{ inputs.application-signals-adot-image-tag }}\"}]'" + # execute_and_retry 2 "kubectl delete pods --all -n amazon-cloudwatch" + # execute_and_retry 2 "kubectl wait --for=condition=Ready pod --all -n amazon-cloudwatch" + # fi + + echo "Patching staging adot image for main build" + execute_and_retry 2 "kubectl patch deploy -namazon-cloudwatch amazon-cloudwatch-observability-controller-manager --type='json' \ + -p='[{"op": \"replace\", \"path\": \"/spec/template/spec/containers/0/args/2\", \"value\": \"--auto-instrumentation-python-image=${{ inputs.application-signals-adot-image }}:${{ inputs.application-signals-adot-image-tag }}\"}]'" + + execute_and_retry 2 "kubectl patch amazoncloudwatchagents -n amazon-cloudwatch cloudwatch-agent --type='json' -p='[{"op": "replace", "path": "/spec/image", "value": "public.ecr.aws/y8s3a7r9/cloudwatch-agent:latest"}]'" + execute_and_retry 2 "kubectl delete pods --all -n amazon-cloudwatch" + execute_and_retry 2 "kubectl wait --for=condition=Ready pod --all -n amazon-cloudwatch" execute_and_retry 2 "kubectl delete pods --all -n ${{ env.PYTHON_SAMPLE_APP_NAMESPACE }}" execute_and_retry 2 "kubectl wait --for=condition=Ready --request-timeout '5m' pod --all -n ${{ env.PYTHON_SAMPLE_APP_NAMESPACE }}" @@ -246,10 +254,10 @@ jobs: - name: Call all test APIs continue-on-error: true run: | - curl -S -s -o /dev/null http://${{ env.APP_ENDPOINT }}/outgoing-http-call - curl -S -s -o /dev/null http://${{ env.APP_ENDPOINT }}/aws-sdk-call - curl -S -s -o /dev/null http://${{ env.APP_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_POD_IP }} - curl -S -s -o /dev/null http://${{ env.APP_ENDPOINT }}/client-call + curl -S -s /dev/null http://${{ env.APP_ENDPOINT }}/outgoing-http-call + curl -S -s /dev/null http://${{ env.APP_ENDPOINT }}/aws-sdk-call + curl -S -s /dev/null http://${{ env.APP_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_POD_IP }} + curl -S -s /dev/null http://${{ env.APP_ENDPOINT }}/client-call # Validation for application signals telemetry data - name: Call endpoint and validate generated EMF logs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..95af5cf57 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,32 @@ +## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +## SPDX-License-Identifier: Apache-2.0 + +## This workflow aims to run the Application Signals end-to-end tests as a canary to +## test the artifacts for App Signals enablement. It will deploy a sample app and remote +## service on two EC2 instances, call the APIs, and validate the generated telemetry, +## including logs, metrics, and traces. +name: Test +on: + push: + +permissions: + id-token: write + contents: read + +jobs: + e2e-ec2-test: + uses: ./.github/workflows/application-signals-python-e2e-ec2-test.yml + secrets: inherit + with: + aws-region: us-east-1 + caller-workflow-name: 'test' + +# e2e-eks-test-1: +# uses: ./.github/workflows/application-signals-python-e2e-eks-test.yml +# secrets: inherit +# with: +# aws-region: 'us-east-1' +# test-cluster-name: 'e2e-playground' +# caller-workflow-name: "test" +# application-signals-adot-image: '417921506511.dkr.ecr.us-east-1.amazonaws.com/aws-opentelemetry-distro/metric-schema-changes' +# application-signals-adot-image-tag: 'latest' \ No newline at end of file