Skip to content

Commit a3f726a

Browse files
committed
Test
1 parent 963170d commit a3f726a

22 files changed

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

.github/workflows/python-ec2-adot-sigv4-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ jobs:
220220
--rollup'
221221

222222
- name: Refresh AWS Credentials
223+
if: always()
223224
uses: aws-actions/configure-aws-credentials@v4
224225
with:
225226
role-to-assume: arn:aws:iam::${{ env.E2E_TEST_ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
- dotnet-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+
dotnet-ec2-adot-sigv4:
20+
uses: ./.github/workflows/dotnet-ec2-adot-sigv4-test.yml
21+
secrets: inherit
22+
with:
23+
caller-workflow-name: 'test'
24+
staging_distro_name: 'aws-distro-opentelemetry-dotnet-instrumentation-linux-glibc-x64.zip'

0 commit comments

Comments
 (0)