@@ -5,9 +5,6 @@ name: App Signals Enablement E2E Testing - EC2 Use Case
5
5
on :
6
6
workflow_call :
7
7
inputs :
8
- aws-region :
9
- required : true
10
- type : string
11
8
caller-workflow-name :
12
9
required : true
13
10
type : string
@@ -17,10 +14,11 @@ permissions:
17
14
contents : read
18
15
19
16
env :
20
- AWS_DEFAULT_REGION : ${{ inputs.aws-region }} # Used by terraform and AWS CLI commands
17
+ AWS_DEFAULT_REGION : us-east-1
21
18
TEST_ACCOUNT : ${{ secrets.APP_SIGNALS_E2E_TEST_ACC }}
22
19
SAMPLE_APP_FRONTEND_SERVICE_JAR : " s3://aws-appsignals-sample-app/main-service.jar"
23
20
SAMPLE_APP_REMOTE_SERVICE_JAR : " s3://aws-appsignals-sample-app/remote-service.jar"
21
+ APP_SIGNALS_CW_AGENT_RPM : " https://amazoncloudwatch-agent-us-east-1.s3.amazonaws.com/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm"
24
22
APP_SIGNALS_ADOT_JAR : " https://github.com/aws-observability/aws-otel-java-instrumentation/releases/latest/download/aws-opentelemetry-agent.jar"
25
23
METRIC_NAMESPACE : AppSignals
26
24
LOG_GROUP_NAME : /aws/appsignals/generic
33
31
with :
34
32
fetch-depth : 0
35
33
36
- - name : Set CW Agent RPM environment variable
37
- run : |
38
- if [ ${{ env.AWS_DEFAULT_REGION }} == "us-east-1" ]; then
39
- echo APP_SIGNALS_CW_AGENT_RPM="https://amazoncloudwatch-agent-us-east-1.s3.amazonaws.com/amazon_linux/amd64/1.300031.0b313/amazon-cloudwatch-agent.rpm" >> $GITHUB_ENV
40
- else
41
- echo APP_SIGNALS_CW_AGENT_RPM="https://amazoncloudwatch-agent-${{ env.AWS_DEFAULT_REGION }}.s3.${{ env.AWS_DEFAULT_REGION }}.amazonaws.com/amazon_linux/amd64/1.300031.0b313/amazon-cloudwatch-agent.rpm" >> $GITHUB_ENV
42
- fi
43
-
44
-
45
34
- name : Generate testing id
46
35
run : echo TESTING_ID="${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV
47
36
@@ -52,88 +41,45 @@ jobs:
52
41
aws-region : ${{ env.AWS_DEFAULT_REGION }}
53
42
54
43
- name : Set up terraform
55
- uses : hashicorp/setup-terraform@v3
44
+ uses : hashicorp/setup-terraform@v2
56
45
with :
57
46
terraform_wrapper : false
58
47
59
- - name : Deploy sample app via terraform and wait for endpoint to come online
48
+ - name : Deploy sample app via terraform
60
49
working-directory : testing/terraform/ec2
61
50
run : |
62
51
terraform init
63
52
terraform validate
64
-
65
- # Attempt to deploy the sample app on an EC2 instance and wait for its endpoint to come online.
66
- # There may be occasional failures due to transitivity issues, so try up to 2 times.
67
- # deployment_failed of 0 indicates that both the terraform deployment and the endpoint are running, while 1 indicates
68
- # that it failed at some point
69
- retry_counter=0
70
- max_retry=2
71
- while [ $retry_counter -lt $max_retry ]; do
72
- echo "Attempt $retry_counter"
73
- deployment_failed=0
74
- terraform apply -auto-approve \
75
- -var="aws_region=${{ env.AWS_DEFAULT_REGION }}" \
76
- -var="test_id=${{ env.TESTING_ID }}" \
77
- -var="sample_app_jar=${{ env.SAMPLE_APP_FRONTEND_SERVICE_JAR }}" \
78
- -var="sample_remote_app_jar=${{ env.SAMPLE_APP_REMOTE_SERVICE_JAR }}" \
79
- -var="cw_agent_rpm=${{ env.APP_SIGNALS_CW_AGENT_RPM }}" \
80
- -var="adot_jar=${{ env.APP_SIGNALS_ADOT_JAR }}" \
81
- || deployment_failed=$?
82
-
83
- if [ $deployment_failed -eq 1 ]; then
84
- echo "Terraform deployment was unsuccessful. Will attempt to retry deployment."
85
- fi
86
-
87
- # If the deployment_failed is still 0, then the terraform deployment succeeded and now try to connect to the endpoint.
88
- # Attempts to connect will be made for up to 10 minutes
89
- if [ $deployment_failed -eq 0 ]; then
90
- echo "Attempting to connect to the endpoint"
91
- sample_app_endpoint=http://$(terraform output sample_app_main_service_public_dns):8080
92
- attempt_counter=0
93
- max_attempts=60
94
- until $(curl --output /dev/null --silent --head --fail $(echo "$sample_app_endpoint" | tr -d '"')); do
95
- if [ ${attempt_counter} -eq ${max_attempts} ];then
96
- echo "Failed to connect to endpoint. Will attempt to redeploy sample app."
97
- deployment_failed=1
98
- break
99
- fi
100
-
101
- printf '.'
102
- attempt_counter=$(($attempt_counter+1))
103
- sleep 10
104
- done
105
- fi
106
-
107
- # If the success is 1 then either the terraform deployment or the endpoint connection failed, so first destroy the
108
- # resources created from terraform and try again.
109
- if [ $deployment_failed -eq 1 ]; then
110
- echo "Destroying terraform"
111
- terraform destroy -auto-approve \
112
- -var="test_id=${{ env.TESTING_ID }}"
113
-
114
- retry_counter=$(($retry_counter+1))
115
- else
116
- # If deployment succeeded, then exit the loop
117
- break
118
- fi
119
-
120
- if [ $retry_counter -eq $max_retry ]; then
121
- echo "Max retry reached, failed to deploy terraform and connect to the endpoint. Exiting code"
122
- exit 1
123
- fi
124
- done
125
-
126
- - name : Get the ec2 instance ami id
127
- run : |
128
- echo "EC2_INSTANCE_AMI=$(terraform output ec2_instance_ami)" >> $GITHUB_ENV
129
- working-directory : testing/terraform/ec2
53
+ terraform apply -auto-approve \
54
+ -var="aws_region=${{ env.AWS_DEFAULT_REGION }}" \
55
+ -var="test_id=${{ env.TESTING_ID }}" \
56
+ -var="sample_app_jar=${{ env.SAMPLE_APP_FRONTEND_SERVICE_JAR }}" \
57
+ -var="sample_remote_app_jar=${{ env.SAMPLE_APP_REMOTE_SERVICE_JAR }}" \
58
+ -var="cw_agent_rpm=${{ env.APP_SIGNALS_CW_AGENT_RPM }}" \
59
+ -var="adot_jar=${{ env.APP_SIGNALS_ADOT_JAR }}"
130
60
131
61
- name : Get the sample app endpoint
132
62
run : |
133
63
echo "MAIN_SERVICE_ENDPOINT=$(terraform output sample_app_main_service_public_dns):8080" >> $GITHUB_ENV
134
64
echo "REMOTE_SERVICE_IP=$(terraform output sample_app_remote_service_public_ip)" >> $GITHUB_ENV
135
65
working-directory : testing/terraform/ec2
136
66
67
+ - name : Wait for app endpoint to come online
68
+ id : endpoint-check
69
+ run : |
70
+ attempt_counter=0
71
+ max_attempts=30
72
+ until $(curl --output /dev/null --silent --head --fail http://${{ env.MAIN_SERVICE_ENDPOINT }}); do
73
+ if [ ${attempt_counter} -eq ${max_attempts} ];then
74
+ echo "Max attempts reached"
75
+ exit 1
76
+ fi
77
+
78
+ printf '.'
79
+ attempt_counter=$(($attempt_counter+1))
80
+ sleep 10
81
+ done
82
+
137
83
# This steps increases the speed of the validation by creating the telemetry data in advance
138
84
- name : Call all test APIs
139
85
continue-on-error : true
@@ -157,7 +103,6 @@ jobs:
157
103
--service-name sample-application-${{ env.TESTING_ID }}
158
104
--remote-service-name sample-remote-application-${{ env.TESTING_ID }}
159
105
--request-body ip=${{ env.REMOTE_SERVICE_IP }}
160
- --instance-ami ${{ env.EC2_INSTANCE_AMI }}
161
106
--rollup'
162
107
163
108
- name : Validate generated metrics
@@ -174,7 +119,6 @@ jobs:
174
119
--service-name sample-application-${{ env.TESTING_ID }}
175
120
--remote-service-name sample-remote-application-${{ env.TESTING_ID }}
176
121
--request-body ip=${{ env.REMOTE_SERVICE_IP }}
177
- --instance-ami ${{ env.EC2_INSTANCE_AMI }}
178
122
--rollup'
179
123
180
124
- name : Validate generated traces
@@ -191,7 +135,6 @@ jobs:
191
135
--service-name sample-application-${{ env.TESTING_ID }}
192
136
--remote-service-name sample-remote-application-${{ env.TESTING_ID }}
193
137
--request-body ip=${{ env.REMOTE_SERVICE_IP }}
194
- --instance-ami ${{ env.EC2_INSTANCE_AMI }}
195
138
--rollup'
196
139
197
140
- name : Publish metric on test result
@@ -220,4 +163,4 @@ jobs:
220
163
working-directory : testing/terraform/ec2
221
164
run : |
222
165
terraform destroy -auto-approve \
223
- -var="test_id=${{ env.TESTING_ID }}"
166
+ -var="test_id=${{ env.TESTING_ID }}"
0 commit comments