Skip to content

Commit 0568902

Browse files
committed
[Java/EKS] Add OTLP/OCB test case
1 parent dcc40b1 commit 0568902

File tree

7 files changed

+1251
-0
lines changed

7 files changed

+1251
-0
lines changed
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+
# TODO: Add comment
5+
name: Java EKS OTLP/OCB Enablement Canary Test
6+
on:
7+
# schedule:
8+
# - cron: '12,37 * * * *' # run the workflow at 12th and 37th minute of every hour
9+
workflow_dispatch: # be able to run the workflow on demand
10+
push:
11+
branches:
12+
- otlp-ocb
13+
14+
permissions:
15+
id-token: write
16+
contents: read
17+
18+
jobs:
19+
eks:
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
aws-region: ['us-east-1']
24+
# aws-region: ['af-south-1','ap-east-1','ap-northeast-1','ap-northeast-2','ap-northeast-3','ap-south-1','ap-south-2','ap-southeast-1',
25+
# 'ap-southeast-2','ap-southeast-3','ap-southeast-4','ca-central-1','eu-central-1','eu-central-2','eu-north-1',
26+
# 'eu-south-1','eu-south-2','eu-west-1','eu-west-2','eu-west-3','il-central-1','me-central-1','me-south-1', 'sa-east-1',
27+
# 'us-east-1','us-east-2','us-west-1','us-west-2']
28+
uses: ./.github/workflows/java-eks-otlp-ocb-retry.yml
29+
secrets: inherit
30+
with:
31+
aws-region: ${{ matrix.aws-region }}
32+
test-cluster-name: 'e2e-playground'
33+
# test-cluster-name: 'e2e-java-otlp-ocb-canary-test'
34+
caller-workflow-name: 'appsignals-java-e2e-eks-otlp-ocb-canary-test'
35+
java-version: '11'
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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: Java EKS OTLP/OCB Retry
8+
on:
9+
workflow_call:
10+
inputs:
11+
aws-region:
12+
required: true
13+
type: string
14+
test-cluster-name:
15+
required: true
16+
type: string
17+
caller-workflow-name:
18+
required: true
19+
type: string
20+
java-version:
21+
required: true
22+
type: string
23+
24+
concurrency:
25+
group: 'java-eks-otlp-ocb-${{ inputs.aws-region }}-${{ github.ref_name }}'
26+
cancel-in-progress: false
27+
28+
permissions:
29+
id-token: write
30+
contents: read
31+
32+
jobs:
33+
java-eks-otlp-ocb-attempt-1:
34+
uses: ./.github/workflows/java-eks-otlp-ocb-test.yml
35+
secrets: inherit
36+
with:
37+
aws-region: ${{ inputs.aws-region }}
38+
test-cluster-name: ${{ inputs.test-cluster-name }}
39+
caller-workflow-name: ${{ inputs.caller-workflow-name }}
40+
java-version: ${{ inputs.java-version }}
41+
42+
# java-eks-otlp-ocb-attempt-2:
43+
# needs: [ java-eks-otlp-ocb-attempt-1 ]
44+
# if: ${{ needs.java-eks-otlp-ocb-attempt-1.outputs.job-started != 'true' }}
45+
# uses: ./.github/workflows/java-eks-otlp-ocb-test.yml
46+
# secrets: inherit
47+
# with:
48+
# aws-region: ${{ inputs.aws-region }}
49+
# test-cluster-name: ${{ inputs.test-cluster-name }}
50+
# caller-workflow-name: ${{ inputs.caller-workflow-name }}
51+
# java-version: ${{ inputs.java-version }}
52+
53+
# publish-metric-attempt-1:
54+
# needs: [ java-eks-otlp-ocb-attempt-1, java-eks-otlp-ocb-attempt-2 ]
55+
# if: always()
56+
# uses: ./.github/workflows/enablement-test-publish-result.yml
57+
# secrets: inherit
58+
# with:
59+
# aws-region: ${{ inputs.aws-region }}
60+
# caller-workflow-name: ${{ inputs.caller-workflow-name }}
61+
# validation-result: ${{ needs.java-eks-otlp-ocb-attempt-1.outputs.validation-result || needs.java-eks-otlp-ocb-attempt-2.outputs.validation-result }}
62+
63+
# publish-metric-attempt-2:
64+
# needs: [ java-eks-otlp-ocb-attempt-1, java-eks-otlp-ocb-attempt-2, publish-metric-attempt-1 ]
65+
# if: ${{ always() && needs.publish-metric-attempt-1.outputs.job-started != 'true' }}
66+
# uses: ./.github/workflows/enablement-test-publish-result.yml
67+
# secrets: inherit
68+
# with:
69+
# aws-region: ${{ inputs.aws-region }}
70+
# caller-workflow-name: ${{ inputs.caller-workflow-name }}
71+
# validation-result: ${{ needs.java-eks-otlp-ocb-attempt-1.outputs.validation-result || needs.java-eks-otlp-ocb-attempt-2.outputs.validation-result }}
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
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: Java EKS OTLP/OCB Use Case
8+
on:
9+
workflow_call:
10+
inputs:
11+
aws-region:
12+
required: true
13+
type: string
14+
test-cluster-name:
15+
required: true
16+
type: string
17+
caller-workflow-name:
18+
required: true
19+
type: string
20+
java-version:
21+
description: "Currently support version 8, 11, 17, 21, 22"
22+
required: false
23+
type: string
24+
default: '11'
25+
adot-image-name:
26+
required: false
27+
type: string
28+
cw-agent-operator-tag:
29+
required: false
30+
type: string
31+
outputs:
32+
job-started:
33+
value: ${{ jobs.metric-limiter.outputs.job-started }}
34+
validation-result:
35+
value: ${{ jobs.metric-limiter.outputs.validation-result }}
36+
37+
permissions:
38+
id-token: write
39+
contents: read
40+
41+
env:
42+
# The precense of this env var is required for use by terraform and AWS CLI commands
43+
# It is not redundant
44+
E2E_TEST_AWS_REGION: ${{ inputs.aws-region }}
45+
CLUSTER_NAME: ${{ inputs.test-cluster-name }}
46+
CALLER_WORKFLOW_NAME: ${{ inputs.caller-workflow-name }}
47+
JAVA_VERSION: ${{ inputs.java-version }}
48+
ADOT_IMAGE_NAME: ${{ inputs.adot-image-name }}
49+
CW_AGENT_OPERATOR_TAG: ${{ inputs.cw-agent-operator-tag }}
50+
E2E_TEST_ACCOUNT_ID: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ACCOUNT_ID }}
51+
E2E_TEST_ROLE_NAME: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ROLE_NAME }}
52+
METRIC_NAMESPACE: ApplicationSignals
53+
LOG_GROUP_NAME: /aws/application-signals/data
54+
TEST_RESOURCES_FOLDER: ${GITHUB_WORKSPACE}
55+
56+
jobs:
57+
otlp-ocb:
58+
runs-on: ubuntu-latest
59+
timeout-minutes: 30
60+
outputs:
61+
job-started: ${{ steps.job-started.outputs.job-started }}
62+
validation-result: ${{ steps.validation-result.outputs.validation-result }}
63+
steps:
64+
- name: Check if the job started
65+
id: job-started
66+
run: echo "job-started=true" >> $GITHUB_OUTPUT
67+
68+
- name: Generate testing id and sample app namespace
69+
run: |
70+
echo TESTING_ID="${{ github.job }}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}" >> $GITHUB_ENV
71+
echo SAMPLE_APP_NAMESPACE="ns-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV
72+
73+
- uses: actions/checkout@v4
74+
with:
75+
repository: 'aws-observability/aws-application-signals-test-framework'
76+
ref: ${{ env.CALLER_WORKFLOW_NAME == 'main-build' && 'main' || github.ref }}
77+
fetch-depth: 0
78+
79+
# We initialize Gradlew Daemon early on during the workflow because sometimes initialization
80+
# fails due to transient issues. If it fails here, then we will try again later before the validators
81+
# - name: Initiate Gradlew Daemon
82+
# id: initiate-gradlew
83+
# uses: ./.github/workflows/actions/execute_and_retry
84+
# continue-on-error: true
85+
# with:
86+
# command: "./gradlew :validator:build"
87+
# cleanup: "./gradlew clean"
88+
# max_retry: 3
89+
# sleep_time: 60
90+
91+
- name: Download enablement script
92+
uses: ./.github/workflows/actions/execute_and_retry
93+
with:
94+
pre-command: "mkdir enablement-script && cd enablement-script"
95+
command: "wget https://raw.githubusercontent.com/aws-observability/application-signals-demo/refs/heads/ocb/scripts/eks/appsignals/enable-app-signals-ocb.sh"
96+
cleanup: "rm -f enable-app-signals-ocb.sh"
97+
post-command: "chmod +x enable-app-signals-ocb.sh"
98+
99+
- name: Configure AWS Credentials
100+
uses: aws-actions/configure-aws-credentials@v4
101+
with:
102+
role-to-assume: arn:aws:iam::${{ env.E2E_TEST_ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}
103+
aws-region: us-east-1
104+
105+
- name: Retrieve account
106+
uses: aws-actions/aws-secretsmanager-get-secrets@v2
107+
with:
108+
secret-ids: |
109+
ACCOUNT_ID, region-account/${{ env.E2E_TEST_AWS_REGION }}
110+
JAVA_MAIN_SAMPLE_APP_IMAGE, e2e-test/java-main-sample-app-image
111+
JAVA_REMOTE_SAMPLE_APP_IMAGE, e2e-test/java-remote-sample-app-image
112+
113+
# If the workflow is running as a canary, then we want to log in to the aws account in the appropriate region
114+
- name: Configure AWS Credentials
115+
if: ${{ github.event.repository.name == 'aws-application-signals-test-framework' }}
116+
uses: aws-actions/configure-aws-credentials@v4
117+
with:
118+
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}
119+
aws-region: ${{ env.E2E_TEST_AWS_REGION }}
120+
121+
# local directory to store the kubernetes config
122+
- name: Create kubeconfig directory
123+
run: mkdir -p ${{ github.workspace }}/.kube
124+
125+
- name: Set KUBECONFIG environment variable
126+
run: echo KUBECONFIG="${{ github.workspace }}/.kube/config" >> $GITHUB_ENV
127+
128+
- name: Set up kubeconfig
129+
run: aws eks update-kubeconfig --name ${{ env.CLUSTER_NAME }} --region ${{ env.E2E_TEST_AWS_REGION }}
130+
131+
- name: Download and install eksctl
132+
uses: ./.github/workflows/actions/execute_and_retry
133+
with:
134+
pre-command: 'mkdir ${{ github.workspace }}/eksctl'
135+
command: 'curl -sLO "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
136+
&& tar -xzf eksctl_Linux_amd64.tar.gz -C ${{ github.workspace }}/eksctl && rm eksctl_Linux_amd64.tar.gz'
137+
cleanup: 'rm -f eksctl_Linux_amd64.tar.gz'
138+
139+
- name: Add eksctl to Github Path
140+
run: |
141+
echo "${{ github.workspace }}/eksctl" >> $GITHUB_PATH
142+
143+
# This step deletes lingering resources from previous test runs
144+
- name: Delete all sample app namespaces
145+
continue-on-error: true
146+
timeout-minutes: 5
147+
run: kubectl get namespace | awk '/^ns-[0-9]+-[0-9]+/{print $1}' | xargs kubectl delete namespace
148+
149+
# Set up App Signals permissions and resources
150+
- name: Create role for AWS access from the sample app
151+
id: create_service_account
152+
uses: ./.github/workflows/actions/execute_and_retry
153+
with:
154+
command: "eksctl create iamserviceaccount \
155+
--name service-account-${{ env.TESTING_ID }} \
156+
--namespace ${{ env.SAMPLE_APP_NAMESPACE }} \
157+
--cluster ${{ env.CLUSTER_NAME }} \
158+
--role-name eks-s3-access-${{ env.TESTING_ID }} \
159+
--attach-policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess \
160+
--region ${{ env.E2E_TEST_AWS_REGION }} \
161+
--approve"
162+
cleanup: "eksctl delete iamserviceaccount \
163+
--name service-account-${{ env.TESTING_ID }} \
164+
--namespace ${{ env.SAMPLE_APP_NAMESPACE }} \
165+
--cluster ${{ env.CLUSTER_NAME }} \
166+
--region ${{ env.E2E_TEST_AWS_REGION }}"
167+
sleep_time: 60
168+
169+
- name: Set up terraform
170+
uses: ./.github/workflows/actions/execute_and_retry
171+
with:
172+
command: "wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg"
173+
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
174+
&& sudo apt update && sudo apt install terraform'
175+
sleep_time: 60
176+
177+
- name: Initiate Terraform
178+
uses: ./.github/workflows/actions/execute_and_retry
179+
with:
180+
command: "cd ${{ env.TEST_RESOURCES_FOLDER }}/terraform/java/eks-otlp-ocb && terraform init && terraform validate"
181+
cleanup: "rm -rf .terraform && rm -rf .terraform.lock.hcl"
182+
max_retry: 6
183+
sleep_time: 60
184+
185+
- name: Set Sample App Image
186+
run: |
187+
echo MAIN_SAMPLE_APP_IMAGE_ARN="${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.E2E_TEST_AWS_REGION }}.amazonaws.com/${{ env.JAVA_MAIN_SAMPLE_APP_IMAGE }}:v${{ env.JAVA_VERSION }}" >> $GITHUB_ENV
188+
echo REMOTE_SAMPLE_APP_IMAGE_ARN="${{ env.ACCOUNT_ID }}.dkr.ecr.${{ env.E2E_TEST_AWS_REGION }}.amazonaws.com/${{ env.JAVA_REMOTE_SAMPLE_APP_IMAGE }}:v${{ env.JAVA_VERSION }}" >> $GITHUB_ENV
189+
190+
# TODO: Fix retry, clean-app-signals doesn't work for enable-app-signals-ocb.sh
191+
- name: Install OTel Operator using enablement script
192+
uses: ./.github/workflows/actions/execute_and_retry
193+
with:
194+
command: "${{ env.TEST_RESOURCES_FOLDER }}/enablement-script/enable-app-signals-ocb.sh \
195+
${{ env.CLUSTER_NAME }} \
196+
${{ env.E2E_TEST_AWS_REGION }} \
197+
${{ env.SAMPLE_APP_NAMESPACE }}"
198+
max_retry: 1
199+
sleep_time: 60
200+
# TODO: cleanup and increase retries
201+
# cleanup: "TODO"
202+
203+
- name: Install OTel Collector
204+
uses: ./.github/workflows/actions/execute_and_retry
205+
with:
206+
command: "cd ${{ env.TEST_RESOURCES_FOLDER }}/terraform/java/eks-otlp-ocb/util && kubectl apply -f ./appsignals-collector.yaml -n ${{ env.SAMPLE_APP_NAMESPACE }}"
207+
cleanup: "kubectl delete -f ./appsignals-collector.yaml -n ${{ env.SAMPLE_APP_NAMESPACE }} && \
208+
aws eks update-kubeconfig --name ${{ env.CLUSTER_NAME }} --region ${{ env.E2E_TEST_AWS_REGION }}"
209+
210+
- name: Deploy sample app via terraform and wait for the endpoint to come online
211+
id: deploy-sample-app
212+
uses: ./.github/workflows/actions/execute_and_retry
213+
with:
214+
command: "cd ${{ env.TEST_RESOURCES_FOLDER }}/terraform/java/eks-otlp-ocb && \
215+
terraform apply -auto-approve \
216+
-var=\"test_id=${{ env.TESTING_ID }}\" \
217+
-var=\"aws_region=${{ env.E2E_TEST_AWS_REGION }}\" \
218+
-var=\"kube_directory_path=${{ github.workspace }}/.kube\" \
219+
-var=\"eks_cluster_name=${{ env.CLUSTER_NAME }}\" \
220+
-var=\"eks_cluster_context_name=$(kubectl config current-context)\" \
221+
-var=\"test_namespace=${{ env.SAMPLE_APP_NAMESPACE }}\" \
222+
-var=\"service_account_aws_access=service-account-${{ env.TESTING_ID }}\" \
223+
-var=\"sample_app_image=${{ env.MAIN_SAMPLE_APP_IMAGE_ARN }}\" \
224+
-var=\"sample_remote_app_image=${{ env.REMOTE_SAMPLE_APP_IMAGE_ARN }}\" \
225+
-var='account_id=${{ env.ACCOUNT_ID }}'"
226+
cleanup: "terraform destroy -auto-approve \
227+
-var=\"test_id=${{ env.TESTING_ID }}\" \
228+
-var=\"aws_region=${{ env.E2E_TEST_AWS_REGION }}\" \
229+
-var=\"kube_directory_path=${{ github.workspace }}/.kube\" \
230+
-var=\"eks_cluster_name=${{ env.CLUSTER_NAME }}\" \
231+
-var=\"test_namespace=${{ env.SAMPLE_APP_NAMESPACE }}\" \
232+
-var=\"service_account_aws_access=service-account-${{ env.TESTING_ID }}\" \
233+
-var=\"sample_app_image=${{ env.MAIN_SAMPLE_APP_IMAGE_ARN }}\" \
234+
-var=\"sample_remote_app_image=${{ env.REMOTE_SAMPLE_APP_IMAGE_ARN }}\""
235+
max_retry: 2
236+
sleep_time: 60
237+
238+
- name: Validate traces
239+
id: trace-validation
240+
run: echo "TEST"
241+
242+
- name: Refresh AWS Credentials
243+
if: ${{ github.event.repository.name == 'aws-application-signals-test-framework' }}
244+
uses: aws-actions/configure-aws-credentials@v4
245+
with:
246+
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}
247+
aws-region: ${{ env.E2E_TEST_AWS_REGION }}
248+
249+
- name: Save test results
250+
if: always()
251+
id: validation-result
252+
run: |
253+
if [ "${{ steps.trace-validation.outcome }}" = "success" ]; then
254+
echo "validation-result=success" >> $GITHUB_OUTPUT
255+
else
256+
echo "validation-result=failure" >> $GITHUB_OUTPUT
257+
fi
258+
259+
# TODO: Cleanup
260+
- name: Clean up
261+
run: echo "TODO"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
clusters:
3+
- cluster:
4+
certificate-authority-data: ${CA_DATA}
5+
server: ${SERVER_ENDPOINT}
6+
name: ${CLUSTER_NAME}
7+
contexts:
8+
- context:
9+
cluster: ${CLUSTER_NAME}
10+
user: terraform_user
11+
name: ${CLUSTER_NAME}
12+
current-context: ${CLUSTER_NAME}
13+
kind: Config
14+
preferences: {}
15+
users:
16+
- name: terraform_user
17+
user:
18+
token: ${TOKEN}

0 commit comments

Comments
 (0)