Skip to content

Commit 821af32

Browse files
authored
Improve Python E2E tests and align with Java. (#157)
*Issue #, if available:* Improve Python E2E tests with following changes and align with Java: 1. Run E2E in docker contianer, matching with Java PR: aws-observability/aws-application-signals-test-framework#36 2. Append testing id to sample-app-namespace, matching with Java PR: aws-observability/aws-application-signals-test-framework#38 Test workflow run: 1. EC2:https://github.com/aws-observability/aws-otel-python-instrumentation/actions/runs/8666582644 2. EKS: https://github.com/aws-observability/aws-otel-python-instrumentation/actions/runs/8667061312 By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 5586e87 commit 821af32

File tree

2 files changed

+12
-37
lines changed

2 files changed

+12
-37
lines changed

.github/workflows/application-signals-python-e2e-ec2-test.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ env:
3232
METRIC_NAMESPACE: AppSignals
3333
LOG_GROUP_NAME: /aws/appsignals/generic
3434
ADOT_WHEEL_NAME: ${{ inputs.staging_wheel_name }}
35-
TEST_RESOURCES_FOLDER: /home/runner/work/aws-application-signals-test-framework/aws-application-signals-test-framework
3635

3736
jobs:
3837
python-e2e-ec2-test:
3938
runs-on: ubuntu-latest
39+
container:
40+
image: public.ecr.aws/h6o3z5z9/aws-application-signals-test-framework-workflow-container:latest
4041
steps:
4142
- name: Get testing resources from aws-application-signals-test-framework
4243
uses: actions/checkout@v4
@@ -87,13 +88,6 @@ jobs:
8788
echo GET_ADOT_WHEEL_COMMAND="python3.9 -m pip install aws-opentelemetry-distro" >> $GITHUB_ENV
8889
fi
8990
90-
- name: Set up terraform
91-
uses: ./.github/workflows/actions/execute_and_retry
92-
with:
93-
command: "wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg"
94-
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
95-
&& sudo apt update && sudo apt install terraform'
96-
9791
- name: Initiate Terraform
9892
uses: ./.github/workflows/actions/execute_and_retry
9993
with:
@@ -237,7 +231,7 @@ jobs:
237231
- name: Publish metric on test result
238232
if: always()
239233
run: |
240-
if [[ "${{ steps.log-validation.outcome }}" == "success" && "${{ steps.metric-validation.outcome }}" == "success" && "${{ steps.trace-validation.outcome }}" == "success" ]]; then
234+
if [ "${{ steps.log-validation.outcome }}" = "success" ] && [ "${{ steps.metric-validation.outcome }}" = "success" ] && [ "${{ steps.trace-validation.outcome }}" = "success" ]; then
241235
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
242236
--metric-name Failure \
243237
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \

.github/workflows/application-signals-python-e2e-eks-test.yml

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ env:
3232
# The precense of this env var is required for use by terraform and AWS CLI commands
3333
# It is not redundant
3434
AWS_DEFAULT_REGION: ${{ inputs.aws-region }}
35-
PYTHON_SAMPLE_APP_NAMESPACE: python-app-namespace
3635
METRIC_NAMESPACE: AppSignals
3736
LOG_GROUP_NAME: /aws/appsignals/eks
38-
TEST_RESOURCES_FOLDER: /home/runner/work/aws-application-signals-test-framework/aws-application-signals-test-framework
3937

4038
jobs:
4139
python-e2e-eks-test:
4240
runs-on: ubuntu-latest
41+
container:
42+
image: public.ecr.aws/h6o3z5z9/aws-application-signals-test-framework-workflow-container:latest
4343
steps:
4444
- uses: actions/checkout@v4
4545
with:
@@ -63,8 +63,10 @@ jobs:
6363
delete_log_group="aws logs delete-log-group --log-group-name '${{ env.LOG_GROUP_NAME }}' --region \$REGION"
6464
sed -i "s#$delete_log_group##g" clean-app-signals.sh
6565
66-
- name: Generate testing id
67-
run: echo TESTING_ID="${{ inputs.aws-region }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV
66+
- name: Generate testing id and python sample app namespace
67+
run: |
68+
echo TESTING_ID="${{ inputs.aws-region }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV
69+
echo PYTHON_SAMPLE_APP_NAMESPACE="ns-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV
6870
6971
- name: Configure AWS Credentials
7072
uses: aws-actions/configure-aws-credentials@v4
@@ -86,24 +88,9 @@ jobs:
8688
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ inputs['caller-workflow-name'] == 'main-build' && secrets.ADOT_E2E_TEST_ROLE_ARN || secrets.E2E_TEST_ROLE_ARN }}
8789
aws-region: ${{ inputs.aws-region }}
8890

89-
# local directory to store the kubernetes config
90-
- name: Create kubeconfig directory
91-
run: mkdir -p ${{ github.workspace }}/.kube
92-
93-
- name: Set KUBECONFIG environment variable
94-
run: echo KUBECONFIG="${{ github.workspace }}/.kube/config" >> $GITHUB_ENV
95-
9691
- name: Set up kubeconfig
9792
run: aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ inputs.aws-region }}
9893

99-
- name: Install eksctl
100-
uses: ./.github/workflows/actions/execute_and_retry
101-
with:
102-
pre-command: 'mkdir ${{ github.workspace }}/eksctl'
103-
command: 'curl -sLO "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
104-
&& tar -xzf eksctl_Linux_amd64.tar.gz -C ${{ github.workspace }}/eksctl && rm eksctl_Linux_amd64.tar.gz'
105-
cleanup: 'rm -f eksctl_Linux_amd64.tar.gz'
106-
10794
- name: Add eksctl to Github Path
10895
run: |
10996
echo "${{ github.workspace }}/eksctl" >> $GITHUB_PATH
@@ -121,13 +108,6 @@ jobs:
121108
--region ${{ inputs.aws-region }} \
122109
--approve"
123110

124-
- name: Set up terraform
125-
uses: ./.github/workflows/actions/execute_and_retry
126-
with:
127-
command: "wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg"
128-
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
129-
&& sudo apt update && sudo apt install terraform'
130-
131111
- name: Initiate Terraform
132112
uses: ./.github/workflows/actions/execute_and_retry
133113
with:
@@ -167,7 +147,7 @@ jobs:
167147
# after installing Application Signals. Attempts to connect will be made for up to 10 minutes
168148
if [ $deployment_failed -eq 0 ]; then
169149
echo "Installing application signals to the sample app"
170-
source ${GITHUB_WORKSPACE}/.github/workflows/util/execute_and_retry.sh
150+
. ${GITHUB_WORKSPACE}/.github/workflows/util/execute_and_retry.sh
171151
execute_and_retry 2 \
172152
"${GITHUB_WORKSPACE}/enablement-script/enable-app-signals.sh \
173153
${{ inputs.test-cluster-name }} \
@@ -327,7 +307,7 @@ jobs:
327307
- name: Publish metric on test result
328308
if: always()
329309
run: |
330-
if [[ "${{ steps.log-validation.outcome }}" == "success" && "${{ steps.metric-validation.outcome }}" == "success" && "${{ steps.trace-validation.outcome }}" == "success" ]]; then
310+
if [ "${{ steps.log-validation.outcome }}" = "success" ] && [ "${{ steps.metric-validation.outcome }}" = "success" ] && [ "${{ steps.trace-validation.outcome }}" = "success" ]; then
331311
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
332312
--metric-name Failure \
333313
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \
@@ -363,6 +343,7 @@ jobs:
363343
- name: Terraform destroy
364344
if: always()
365345
continue-on-error: true
346+
timeout-minutes: 5
366347
working-directory: terraform/python/eks
367348
run: |
368349
terraform destroy -auto-approve \

0 commit comments

Comments
 (0)