Skip to content

Commit 125d5c9

Browse files
[Node] Add ADOT SigV4 Release Test (#379)
1 parent 963170d commit 125d5c9

20 files changed

+2197
-0
lines changed
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
4+
# This is a reusable workflow for running the Enablement test for App Signals.
5+
# It is meant to be called from another workflow.
6+
# Read more about reusable workflows: https://docs.github.com/en/actions/using-workflows/reusing-workflows#overview
7+
name: Node EC2 ADOT SigV4 Use Case
8+
on:
9+
workflow_call:
10+
inputs:
11+
caller-workflow-name:
12+
required: true
13+
type: string
14+
node-version:
15+
description: "Currently support version 14, 16, 18, 20, 22"
16+
required: false
17+
type: string
18+
# 'none' means to use the node version come with the OS
19+
default: 'none'
20+
cpu-architecture:
21+
description: "Permitted values: x86_64 or arm64"
22+
required: false
23+
type: string
24+
default: "x86_64"
25+
staging-instrumentation-name:
26+
required: false
27+
default: '@aws/aws-distro-opentelemetry-node-autoinstrumentation'
28+
type: string
29+
30+
permissions:
31+
id-token: write
32+
contents: read
33+
34+
env:
35+
E2E_TEST_AWS_REGION: 'us-west-2'
36+
CALLER_WORKFLOW_NAME: ${{ inputs.caller-workflow-name }}
37+
NODE_VERSION: ${{ inputs.node-version }}
38+
CPU_ARCHITECTURE: ${{ inputs.cpu-architecture }}
39+
ADOT_INSTRUMENTATION_NAME: ${{ inputs.staging-instrumentation-name }}
40+
E2E_TEST_ACCOUNT_ID: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ACCOUNT_ID }}
41+
E2E_TEST_ROLE_NAME: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ROLE_NAME }}
42+
METRIC_NAMESPACE: ApplicationSignals
43+
LOG_GROUP_NAME: aws/spans
44+
TEST_RESOURCES_FOLDER: ${GITHUB_WORKSPACE}
45+
46+
jobs:
47+
node-ec2-adot-sigv4:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Check if the job started
51+
id: job-started
52+
run: echo "job-started=true" >> $GITHUB_OUTPUT
53+
54+
- name: Generate testing id
55+
run: echo TESTING_ID="${{ github.run_id }}-${{ github.run_number }}-${RANDOM}" >> $GITHUB_ENV
56+
57+
- uses: actions/checkout@v4
58+
with:
59+
repository: 'aws-observability/aws-application-signals-test-framework'
60+
ref: ${{ env.CALLER_WORKFLOW_NAME == 'main-build' && 'main' || github.ref }}
61+
fetch-depth: 0
62+
63+
# We initialize Gradlew Daemon early on during the workflow because sometimes initialization
64+
# fails due to transient issues. If it fails here, then we will try again later before the validators
65+
- name: Initiate Gradlew Daemon
66+
id: initiate-gradlew
67+
uses: ./.github/workflows/actions/execute_and_retry
68+
continue-on-error: true
69+
with:
70+
command: "./gradlew :validator:build"
71+
cleanup: "./gradlew clean"
72+
max_retry: 3
73+
sleep_time: 60
74+
75+
- name: Configure AWS Credentials
76+
uses: aws-actions/configure-aws-credentials@v4
77+
with:
78+
role-to-assume: arn:aws:iam::${{ env.E2E_TEST_ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}
79+
aws-region: ${{ env.E2E_TEST_AWS_REGION }}
80+
81+
- name: Set Get ADOT Instrumentation command environment variable
82+
run: |
83+
if [ "${{ github.event.repository.name }}" = "aws-otel-js-instrumentation" ]; then
84+
echo GET_ADOT_INSTRUMENTATION_COMMAND="aws s3 cp s3://adot-autoinstrumentation-node-staging/${{ env.ADOT_INSTRUMENTATION_NAME }} ./${{ env.ADOT_INSTRUMENTATION_NAME }} --region us-east-1 && npm install ${{ env.ADOT_INSTRUMENTATION_NAME }}" >> $GITHUB_ENV
85+
else
86+
echo GET_ADOT_INSTRUMENTATION_COMMAND="npm install ${{ env.ADOT_INSTRUMENTATION_NAME }}" >> $GITHUB_ENV
87+
fi
88+
89+
- name: Set up terraform
90+
uses: ./.github/workflows/actions/execute_and_retry
91+
with:
92+
command: "wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg"
93+
post-command: 'echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
94+
&& sudo apt update && sudo apt install terraform'
95+
sleep_time: 60
96+
97+
- name: Initiate Terraform
98+
uses: ./.github/workflows/actions/execute_and_retry
99+
with:
100+
command: "cd ${{ env.TEST_RESOURCES_FOLDER }}/terraform/node/ec2/adot-sigv4 && terraform init && terraform validate"
101+
cleanup: "rm -rf .terraform && rm -rf .terraform.lock.hcl"
102+
max_retry: 6
103+
sleep_time: 60
104+
105+
- name: Deploy sample app via terraform and wait for endpoint to come online
106+
working-directory: terraform/node/ec2/adot-sigv4
107+
run: |
108+
# Attempt to deploy the sample app on an EC2 instance and wait for its endpoint to come online.
109+
# There may be occasional failures due to transitivity issues, so try up to 2 times.
110+
# deployment_failed of 0 indicates that both the terraform deployment and the endpoint are running, while 1 indicates
111+
# that it failed at some point
112+
retry_counter=0
113+
max_retry=2
114+
while [ $retry_counter -lt $max_retry ]; do
115+
echo "Attempt $retry_counter"
116+
deployment_failed=0
117+
terraform apply -auto-approve \
118+
-var="aws_region=${{ env.E2E_TEST_AWS_REGION }}" \
119+
-var="test_id=${{ env.TESTING_ID }}" \
120+
-var="sample_app_zip=s3://aws-appsignals-sample-app-prod-us-east-1/node-sample-app.zip" \
121+
-var="get_adot_instrumentation_command=${{ env.GET_ADOT_INSTRUMENTATION_COMMAND }}" \
122+
-var="language_version=${{ env.NODE_VERSION }}" \
123+
-var="cpu_architecture=${{ env.CPU_ARCHITECTURE }}" \
124+
|| deployment_failed=$?
125+
126+
if [ $deployment_failed -eq 1 ]; then
127+
echo "Terraform deployment was unsuccessful. Will attempt to retry deployment."
128+
fi
129+
130+
# If the success is 1 then either the terraform deployment or the endpoint connection failed, so first destroy the
131+
# resources created from terraform and try again.
132+
if [ $deployment_failed -eq 1 ]; then
133+
echo "Destroying terraform"
134+
terraform destroy -auto-approve \
135+
-var="test_id=${{ env.TESTING_ID }}"
136+
137+
retry_counter=$(($retry_counter+1))
138+
else
139+
# If deployment succeeded, then exit the loop
140+
break
141+
fi
142+
143+
if [ $retry_counter -eq $max_retry ]; then
144+
echo "Max retry reached, failed to deploy terraform and connect to the endpoint. Exiting code"
145+
exit 1
146+
fi
147+
done
148+
149+
- name: Get the ec2 instance ami id
150+
working-directory: terraform/node/ec2/adot-sigv4
151+
run: |
152+
echo "EC2_INSTANCE_AMI=$(terraform output ec2_instance_ami)" >> $GITHUB_ENV
153+
154+
- name: Get the sample app and EC2 instance information
155+
working-directory: terraform/node/ec2/adot-sigv4
156+
run: |
157+
echo "MAIN_SERVICE_ENDPOINT=localhost:8000" >> $GITHUB_ENV
158+
echo "REMOTE_SERVICE_IP=$(terraform output sample_app_remote_service_private_ip)" >> $GITHUB_ENV
159+
echo "MAIN_SERVICE_INSTANCE_ID=$(terraform output main_service_instance_id)" >> $GITHUB_ENV
160+
161+
- name: Initiate Gradlew Daemon
162+
if: steps.initiate-gradlew == 'failure'
163+
uses: ./.github/workflows/actions/execute_and_retry
164+
continue-on-error: true
165+
with:
166+
command: "./gradlew :validator:build"
167+
cleanup: "./gradlew clean"
168+
max_retry: 3
169+
sleep_time: 60
170+
171+
# Validation for pulse telemetry data
172+
- name: Validate generated EMF logs
173+
id: log-validation
174+
run: ./gradlew validator:run --args='-c node/ec2/adot-sigv4/log-validation.yml
175+
--testing-id ${{ env.TESTING_ID }}
176+
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}
177+
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8001
178+
--region ${{ env.E2E_TEST_AWS_REGION }}
179+
--account-id ${{ env.E2E_TEST_ACCOUNT_ID }}
180+
--metric-namespace ${{ env.METRIC_NAMESPACE }}
181+
--log-group ${{ env.LOG_GROUP_NAME }}
182+
--service-name node-sample-application-${{ env.TESTING_ID }}
183+
--remote-service-name node-sample-remote-application-${{ env.TESTING_ID }}
184+
--query-string ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}
185+
--instance-ami ${{ env.EC2_INSTANCE_AMI }}
186+
--instance-id ${{ env.MAIN_SERVICE_INSTANCE_ID }}
187+
--rollup'
188+
189+
- name: Validate generated metrics
190+
id: metric-validation
191+
if: (success() || steps.log-validation.outcome == 'failure') && !cancelled()
192+
run: ./gradlew validator:run --args='-c node/ec2/adot-sigv4/metric-validation.yml
193+
--testing-id ${{ env.TESTING_ID }}
194+
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}
195+
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8001
196+
--region ${{ env.E2E_TEST_AWS_REGION }}
197+
--account-id ${{ env.E2E_TEST_ACCOUNT_ID }}
198+
--metric-namespace ${{ env.METRIC_NAMESPACE }}
199+
--log-group ${{ env.LOG_GROUP_NAME }}
200+
--service-name node-sample-application-${{ env.TESTING_ID }}
201+
--remote-service-name node-sample-remote-application-${{ env.TESTING_ID }}
202+
--query-string ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}
203+
--instance-ami ${{ env.EC2_INSTANCE_AMI }}
204+
--instance-id ${{ env.MAIN_SERVICE_INSTANCE_ID }}
205+
--rollup'
206+
207+
- name: Validate generated traces
208+
id: trace-validation
209+
if: (success() || steps.log-validation.outcome == 'failure' || steps.metric-validation.outcome == 'failure') && !cancelled()
210+
run: ./gradlew validator:run --args='-c node/ec2/adot-sigv4/trace-validation.yml
211+
--testing-id ${{ env.TESTING_ID }}
212+
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}
213+
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8001
214+
--region ${{ env.E2E_TEST_AWS_REGION }}
215+
--account-id ${{ env.E2E_TEST_ACCOUNT_ID }}
216+
--metric-namespace ${{ env.METRIC_NAMESPACE }}
217+
--log-group ${{ env.LOG_GROUP_NAME }}
218+
--service-name node-sample-application-${{ env.TESTING_ID }}
219+
--remote-service-name node-sample-remote-application-${{ env.TESTING_ID }}
220+
--query-string ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}
221+
--instance-ami ${{ env.EC2_INSTANCE_AMI }}
222+
--instance-id ${{ env.MAIN_SERVICE_INSTANCE_ID }}
223+
--rollup'
224+
225+
- name: Refresh AWS Credentials
226+
if: ${{ always() }}
227+
uses: aws-actions/configure-aws-credentials@v4
228+
with:
229+
role-to-assume: arn:aws:iam::${{ env.E2E_TEST_ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}
230+
aws-region: ${{ env.E2E_TEST_AWS_REGION }}
231+
232+
# Clean up Procedures
233+
- name: Terraform destroy
234+
if: always()
235+
continue-on-error: true
236+
working-directory: terraform/node/ec2/adot-sigv4
237+
run: |
238+
terraform destroy -auto-approve \
239+
-var="test_id=${{ env.TESTING_ID }}"

0 commit comments

Comments
 (0)