Skip to content

Commit 05cd404

Browse files
authored
Adding e2e integ test workflow (#447)
* Adding e2e integ test workflow
1 parent 996a3b2 commit 05cd404

File tree

5 files changed

+284
-7
lines changed

5 files changed

+284
-7
lines changed

.github/workflows/main-build.yml

Lines changed: 213 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
env:
88
AWS_DEFAULT_REGION: us-east-1
99
TEST_TAG: public.ecr.aws/aws-observability/adot-autoinstrumentation-java:test
10+
STAGING_ECR: 611364707713.dkr.ecr.us-west-2.amazonaws.com/adot-autoinstrumentation-java-operator-staging
11+
TESTING_FRAMEWORK_REPO: aws-observability/aws-otel-test-framework
12+
NUM_BATCHES: 2
13+
DDB_TABLE_NAME: BatchTestCache
1014

1115
permissions:
1216
id-token: write
@@ -33,6 +37,8 @@ jobs:
3337

3438
build:
3539
runs-on: ubuntu-latest
40+
outputs:
41+
java_agent_tag: ${{ steps.java_agent_versioning.outputs.STAGING_TAG}}
3642
steps:
3743
- uses: actions/checkout@v3
3844
with:
@@ -51,11 +57,13 @@ jobs:
5157
gpg_password: ${{ secrets.GPG_PASSPHRASE }}
5258

5359
- uses: gradle/wrapper-validation-action@v1
60+
5461
- name: Configure AWS Credentials
5562
uses: aws-actions/configure-aws-credentials@v2
5663
with:
5764
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
5865
aws-region: ${{ env.AWS_DEFAULT_REGION }}
66+
5967
- name: Log in to AWS ECR
6068
uses: docker/login-action@v2
6169
with:
@@ -76,6 +84,13 @@ jobs:
7684
run: |
7785
echo "ADOT_JAVA_VERSION=$(./gradlew printVersion -q )" >> $GITHUB_ENV
7886
87+
- name: Build and push Sample-Apps without Auto-Instrumentation Agent
88+
uses: gradle/gradle-build-action@v2
89+
with:
90+
arguments: jibBuildWithoutAgent
91+
env:
92+
COMMIT_HASH: ${{ github.sha }}
93+
7994
- name: Set up QEMU
8095
uses: docker/setup-qemu-action@v2
8196

@@ -102,17 +117,212 @@ jobs:
102117
name: aws-opentelemetry-agent.jar
103118
path: otelagent/build/libs/aws-opentelemetry-agent-*.jar
104119

120+
- name: Get ADOT_JAVA_AGENT Image Tag
121+
id: java_agent_versioning
122+
working-directory: aws-otel-java-instrumentation
123+
run: |
124+
shortsha="$(git rev-parse --short HEAD)"
125+
java_agent_tag=${{ env.ADOT_JAVA_VERSION }}-$shortsha
126+
echo "STAGING_TAG=$java_agent_tag" >> $GITHUB_OUTPUT
127+
128+
- name: Configure AWS Credentials
129+
uses: aws-actions/[email protected]
130+
with:
131+
role-to-assume: ${{ secrets.JAVA_INSTRUMENTATION_SNAPSHOT_ECR }}
132+
aws-region: us-west-2
133+
134+
- name: Login to private staging ecr
135+
uses: docker/login-action@v2
136+
with:
137+
registry: ${{ env.STAGING_ECR }}
138+
env:
139+
AWS_REGION: us-west-2
140+
141+
- name: Build and push staging image for e2e integration test
142+
uses: docker/build-push-action@v4
143+
with:
144+
push: true
145+
build-args: "ADOT_JAVA_VERSION=${{ env.ADOT_JAVA_VERSION }}"
146+
context: .
147+
platforms: linux/amd64,linux/arm64
148+
tags: |
149+
${{ env.STAGING_ECR }}:${{ steps.java_agent_versioning.outputs.STAGING_TAG }}
150+
151+
create-test-ref:
152+
runs-on: ubuntu-latest
153+
outputs:
154+
testRef: ${{ steps.setRef.outputs.ref }}
155+
steps:
156+
- name: Set testRef output
157+
id: setRef
158+
run: |
159+
if [[ ${{ github.ref_name }} == release/v* ]]; then
160+
release_version = $(echo ${{ github.ref_name }} | cut -f 2 -d /)
161+
major_minor = $(echo ${ release_version } | cut -f 1,2 -d .)
162+
echo "ref = java-release/${major_minor}.x" >> $GITHUB_OUTPUT
163+
else
164+
echo "ref=terraform" >> $GITHUB_OUTPUT
165+
fi
166+
167+
# job to build testbatches for e2e integration test
168+
get-testing-suites:
169+
runs-on: ubuntu-latest
170+
needs: [build, create-test-ref]
171+
outputs:
172+
test-case-batch-key: ${{ steps.set-batches.outputs.batch-keys }}
173+
test-case-batch-value: ${{ steps.set-batches.outputs.batch-values }}
174+
steps:
175+
- name: Checkout
176+
uses: actions/checkout@v3
177+
with:
178+
repository: ${{ env.TESTING_FRAMEWORK_REPO }}
179+
path: testing-framework
180+
ref: ${{ needs.create-test-ref.outputs.testRef }}
181+
182+
- name: Checkout
183+
uses: actions/checkout@v3
184+
with:
185+
fetch-depth: 0
186+
path: aws-otel-java-instrumentation
187+
188+
- name: Set up Go 1.x
189+
uses: actions/setup-go@v3
190+
with:
191+
go-version: '~1.18.9'
192+
193+
- name: Create test batch key values
194+
id: set-batches
195+
run: |
196+
cd testing-framework/tools/batchTestGenerator
197+
go build
198+
./batchTestGenerator github --testCaseFilePath=$GITHUB_WORKSPACE/aws-otel-java-instrumentation/.github/workflows/testcases.json --maxBatch=${{ env.NUM_BATCHES }} \
199+
--include=EKS_ADOT_OPERATOR,EKS_ADOT_OPERATOR_ARM64
200+
201+
- name: List testing suites
202+
run: |
203+
echo ${{ steps.set-batches.outputs.batch-keys }}
204+
echo ${{ steps.set-batches.outputs.batch-values }}
205+
206+
# job to run the e2e integration tests
207+
run-batch-job:
208+
runs-on: ubuntu-latest
209+
needs: [build, create-test-ref, get-testing-suites]
210+
strategy:
211+
fail-fast: false
212+
matrix: ${{ fromJson(needs.get-testing-suites.outputs.test-case-batch-key) }}
213+
214+
steps:
215+
# required for versioning
216+
- name: Checkout
217+
uses: actions/checkout@v3
218+
with:
219+
fetch-depth: 0
220+
path: aws-otel-java-instrumentation
221+
222+
- name: Set up JDK 11
223+
uses: actions/setup-java@v3
224+
with:
225+
distribution: 'zulu'
226+
java-version: '11'
227+
228+
- name: Set up terraform
229+
uses: hashicorp/setup-terraform@v2
230+
with:
231+
terraform_version: "~1.4"
232+
233+
- name: Configure AWS Credentials
234+
uses: aws-actions/configure-aws-credentials@v2
235+
with:
236+
role-to-assume: ${{ secrets.JAVA_INSTRUMENTATION_INTEG_TEST_ARN}}
237+
aws-region: us-west-2
238+
# 4 hours
239+
role-duration-seconds: 14400
240+
241+
- name: Checkout testing framework
242+
uses: actions/checkout@v3
243+
with:
244+
repository: ${{ env.TESTING_FRAMEWORK_REPO }}
245+
path: testing-framework
246+
ref: ${{ needs.create-test-ref.outputs.testRef }}
247+
248+
- name: create test-case-batch file
249+
run: |
250+
jsonStr='${{ needs.get-testing-suites.outputs.test-case-batch-value }}'
251+
jsonStr="$(jq -r '.${{ matrix.BatchKey }} | join("\n")' <<< "${jsonStr}")"
252+
echo "$jsonStr" >> testing-framework/terraform/test-case-batch
253+
cat testing-framework/terraform/test-case-batch
254+
255+
- name: Get TTL_DATE for cache
256+
id: date
257+
run: echo "ttldate=$(date -u -d "+7 days" +%s)" >> $GITHUB_OUTPUT
258+
259+
- name: run tests
260+
run: |
261+
export TTL_DATE=${{ steps.date.outputs.ttldate }}
262+
export TF_VAR_JAVA_AUTO_INSTRUMENTATION_TAG=${{ needs.build.outputs.java_agent_tag }}
263+
export TF_VAR_JAVA_AUTO_INSTRUMENTATION_REPOSITORY=${{ env.STAGING_ECR }}
264+
export DDB_BATCH_CACHE_SK=${{ needs.build.outputs.java_agent_tag }}
265+
cd testing-framework/terraform
266+
make execute-batch-test
267+
268+
- name: output cache misses
269+
if: ${{ failure() }}
270+
run: |
271+
export DDB_BATCH_CACHE_SK=${{ needs.build.outputs.java_agent_tag }}
272+
cd testing-framework/terraform
273+
make checkCacheHits
274+
275+
# This is here just in case workflow cancel
276+
# We first kill terraform processes to ensure that no state
277+
# file locks are being held from SIGTERMS dispatched in previous
278+
# steps.
279+
- name: Destroy resources
280+
if: ${{ cancelled() }}
281+
shell: bash {0}
282+
run: |
283+
ps -ef | grep terraform | grep -v grep | awk '{print $2}' | xargs -n 1 kill
284+
cd testing-framework/terraform
285+
make terraformCleanup
286+
287+
288+
build_Images_For_Testing_Sample_App_With_Java_Agent:
289+
runs-on: ubuntu-latest
290+
needs: build
291+
steps:
292+
- uses: actions/checkout@v3
293+
with:
294+
fetch-depth: 0
295+
296+
- uses: actions/setup-java@v3
297+
with:
298+
java-version: 17
299+
distribution: temurin
300+
301+
- uses: gradle/wrapper-validation-action@v1
302+
303+
- name: Configure AWS Credentials
304+
uses: aws-actions/configure-aws-credentials@v2
305+
with:
306+
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
307+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
308+
309+
- name: Log in to AWS ECR
310+
uses: docker/login-action@v2
311+
with:
312+
registry: public.ecr.aws
313+
105314
- name: Build and push agent and testing docker images with Gradle
106315
uses: gradle/gradle-build-action@v2
107316
with:
108317
arguments: jib
109318
env:
110319
COMMIT_HASH: ${{ github.sha }}
320+
111321
- uses: codecov/codecov-action@v3
112322

113323
test_Spring_App_With_Java_Agent:
114324
name: Test Spring App with AWS OTel Java agent
115-
needs: build
325+
needs: build_Images_For_Testing_Sample_App_With_Java_Agent
116326
runs-on: ubuntu-latest
117327

118328
steps:
@@ -143,7 +353,7 @@ jobs:
143353

144354
test_Spark_App_With_Java_Agent:
145355
name: Test Spark App with AWS OTel Java agent
146-
needs: build
356+
needs: build_Images_For_Testing_Sample_App_With_Java_Agent
147357
runs-on: ubuntu-latest
148358

149359
steps:
@@ -174,7 +384,7 @@ jobs:
174384

175385
test_Spark_AWS_SDK_V1_App_With_Java_Agent:
176386
name: Test Spark App (AWS SDK v1) with AWS OTel Java agent
177-
needs: build
387+
needs: build_Images_For_Testing_Sample_App_With_Java_Agent
178388
runs-on: ubuntu-latest
179389

180390
steps:

.github/workflows/nightly-upstream-snapshot-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ jobs:
4949
- name: Configure AWS Credentials
5050
uses: aws-actions/configure-aws-credentials@v2
5151
with:
52-
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN_NIGHTLY }}
52+
role-to-assume: ${{ secrets.JAVA_INSTRUMENTATION_SNAPSHOT_ECR }}
5353
aws-region: us-west-2
5454

55-
- name: Log in to AWS ECR
55+
- name: Login to private aws ecr
5656
uses: docker/login-action@v2
5757
with:
5858
registry: 611364707713.dkr.ecr.us-west-2.amazonaws.com

.github/workflows/testcases.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"clustertargets": [
3+
{
4+
"type": "EKS_ADOT_OPERATOR",
5+
"targets": [
6+
{
7+
"name": "java-instrumentation-operator-ci-amd64-1-23",
8+
"region": "us-west-2"
9+
},
10+
{
11+
"name": "java-instrumentation-operator-ci-amd64-1-26",
12+
"region": "us-west-2"
13+
}
14+
]
15+
},
16+
{
17+
"type": "EKS_ADOT_OPERATOR_ARM64",
18+
"targets": [
19+
{
20+
"name": "java-instrumentation-operator-ci-arm64-1-23",
21+
"region": "us-west-2"
22+
},
23+
{
24+
"name": "java-instrumentation-operator-ci-arm64-1-26",
25+
"region": "us-west-2"
26+
}
27+
]
28+
}
29+
],
30+
"tests": [
31+
{
32+
"case_name": "otlp_metric_auto_instrumentation_adot_operator",
33+
"platforms": [
34+
"EKS_ADOT_OPERATOR",
35+
"EKS_ADOT_OPERATOR_ARM64"
36+
]
37+
},
38+
{
39+
"case_name": "otlp_trace_auto_instrumentation_adot_operator",
40+
"platforms": [
41+
"EKS_ADOT_OPERATOR",
42+
"EKS_ADOT_OPERATOR_ARM64"
43+
]
44+
}
45+
]
46+
}

RELEASING.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,18 @@ and merge.
1212

1313
## Starting the Release
1414

15-
If you are creating a new major/minor release, you first need to create a branch with the following convention: `release/v<major>.<minor>.x`. E.g.: `release/v1.21.x`.
15+
If you are creating a new major/minor release, you first need to create a branch in this repository with the following convention: `release/v<major>.<minor>.x`. E.g.: `release/v1.21.x`.
1616
It is not possible to release from the `main` branch, so this step cannot be skipped.
1717

18-
Open the release build workflow in your browser [here](https://github.com/aws-observability/aws-otel-java-instrumentation/actions?query=workflow%3A%22Release+Build%22).
18+
Additionally, create and push a release branch to the [aws-otel-test-framework](https://github.com/aws-observability/aws-otel-test-framework) repository using the following command:
19+
20+
`git fetch origin && git checkout origin/terraform -b java-release/<version> && git push origin java-release/<version>`
21+
22+
NOTE: *The naming convention for the branch is java-release/<version> with the patch number replaced with x. So, if your release version is v0.1.0, then the branch should be java-release/v0.1.x.*
23+
24+
NOTE: *origin refers to the remote for https://github.com/aws-observability/aws-otel-test-framework.git. If the name of your remote ref is different adjust the command.*
25+
26+
After the release branches have been created in this repository and the [aws-otel-test-framework](https://github.com/aws-observability/aws-otel-test-framework) repository, open the release build workflow in your browser [here](https://github.com/aws-observability/aws-otel-java-instrumentation/actions?query=workflow%3A%22Release+Build%22).
1927

2028
You will see a button that says "Run workflow". Press the button, enter the version number you want
2129
to release in the input field that pops up, and then press "Run workflow".

sample-apps/spark/build.gradle.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import com.google.cloud.tools.jib.gradle.BuildImageTask
2+
import com.google.cloud.tools.jib.gradle.JibExtension
13
import software.amazon.adot.configureImages
24

35
plugins {
@@ -40,4 +42,15 @@ tasks {
4042
named("jibDockerBuild") {
4143
dependsOn(":otelagent:jibDockerBuild")
4244
}
45+
register<BuildImageTask>("jibBuildWithoutAgent") {
46+
val j = JibExtension(project)
47+
j.configureImages(
48+
"eclipse-temurin:17",
49+
"public.ecr.aws/aws-otel-test/aws-otel-java-spark-without-auto-instrumentation-agent",
50+
localDocker = false,
51+
multiPlatform = !rootProject.property("localDocker")!!.equals("true"),
52+
tags = setOf("latest", "${System.getenv("COMMIT_HASH")}")
53+
)
54+
setJibExtension(j)
55+
}
4356
}

0 commit comments

Comments
 (0)