Skip to content

Commit f51aa54

Browse files
committed
Test
1 parent 217cda8 commit f51aa54

21 files changed

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

.github/workflows/test.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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: Test
8+
on:
9+
push:
10+
branches:
11+
- java-sigv4
12+
13+
permissions:
14+
id-token: write
15+
contents: read
16+
17+
jobs:
18+
# Runs in us-west-1 using us-east-1 account
19+
java-ec2-adot-sigv4:
20+
uses: ./.github/workflows/java-ec2-adot-sigv4-test.yml
21+
secrets: inherit
22+
with:
23+
caller-workflow-name: 'test'
24+
java-version: 11
25+
cpu-architecture: x86_64
26+
27+
# publish-metric:
28+
# needs: [ java-ec2-adot-sigv4 ]
29+
# if: ${{ always() }}
30+
# uses: ./.github/workflows/enablement-test-publish-result.yml
31+
# secrets: inherit
32+
# with:
33+
# aws-region: ${{ inputs.aws-region }}
34+
# caller-workflow-name: ${{ inputs.caller-workflow-name }}
35+
# validation-result: ${{ needs.java-ec2-default-attempt-1.outputs.validation-result || needs.java-ec2-default-attempt-2.outputs.validation-result }}

0 commit comments

Comments
 (0)