Skip to content

Commit

Permalink
Improve Python E2E tests and align with Java. (#157)
Browse files Browse the repository at this point in the history
*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.
  • Loading branch information
zzhlogin authored Apr 12, 2024
1 parent 5586e87 commit 821af32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 37 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/application-signals-python-e2e-ec2-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ env:
METRIC_NAMESPACE: AppSignals
LOG_GROUP_NAME: /aws/appsignals/generic
ADOT_WHEEL_NAME: ${{ inputs.staging_wheel_name }}
TEST_RESOURCES_FOLDER: /home/runner/work/aws-application-signals-test-framework/aws-application-signals-test-framework

jobs:
python-e2e-ec2-test:
runs-on: ubuntu-latest
container:
image: public.ecr.aws/h6o3z5z9/aws-application-signals-test-framework-workflow-container:latest
steps:
- name: Get testing resources from aws-application-signals-test-framework
uses: actions/checkout@v4
Expand Down Expand Up @@ -87,13 +88,6 @@ jobs:
echo GET_ADOT_WHEEL_COMMAND="python3.9 -m pip install aws-opentelemetry-distro" >> $GITHUB_ENV
fi
- name: Set up terraform
uses: ./.github/workflows/actions/execute_and_retry
with:
command: "wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg"
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
&& sudo apt update && sudo apt install terraform'

- name: Initiate Terraform
uses: ./.github/workflows/actions/execute_and_retry
with:
Expand Down Expand Up @@ -237,7 +231,7 @@ jobs:
- name: Publish metric on test result
if: always()
run: |
if [[ "${{ steps.log-validation.outcome }}" == "success" && "${{ steps.metric-validation.outcome }}" == "success" && "${{ steps.trace-validation.outcome }}" == "success" ]]; then
if [ "${{ steps.log-validation.outcome }}" = "success" ] && [ "${{ steps.metric-validation.outcome }}" = "success" ] && [ "${{ steps.trace-validation.outcome }}" = "success" ]; then
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \
Expand Down
37 changes: 9 additions & 28 deletions .github/workflows/application-signals-python-e2e-eks-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ env:
# The precense of this env var is required for use by terraform and AWS CLI commands
# It is not redundant
AWS_DEFAULT_REGION: ${{ inputs.aws-region }}
PYTHON_SAMPLE_APP_NAMESPACE: python-app-namespace
METRIC_NAMESPACE: AppSignals
LOG_GROUP_NAME: /aws/appsignals/eks
TEST_RESOURCES_FOLDER: /home/runner/work/aws-application-signals-test-framework/aws-application-signals-test-framework

jobs:
python-e2e-eks-test:
runs-on: ubuntu-latest
container:
image: public.ecr.aws/h6o3z5z9/aws-application-signals-test-framework-workflow-container:latest
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -63,8 +63,10 @@ jobs:
delete_log_group="aws logs delete-log-group --log-group-name '${{ env.LOG_GROUP_NAME }}' --region \$REGION"
sed -i "s#$delete_log_group##g" clean-app-signals.sh
- name: Generate testing id
run: echo TESTING_ID="${{ inputs.aws-region }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV
- name: Generate testing id and python sample app namespace
run: |
echo TESTING_ID="${{ inputs.aws-region }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV
echo PYTHON_SAMPLE_APP_NAMESPACE="ns-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -86,24 +88,9 @@ jobs:
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 }}
aws-region: ${{ inputs.aws-region }}

# local directory to store the kubernetes config
- name: Create kubeconfig directory
run: mkdir -p ${{ github.workspace }}/.kube

- name: Set KUBECONFIG environment variable
run: echo KUBECONFIG="${{ github.workspace }}/.kube/config" >> $GITHUB_ENV

- name: Set up kubeconfig
run: aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ inputs.aws-region }}

- name: Install eksctl
uses: ./.github/workflows/actions/execute_and_retry
with:
pre-command: 'mkdir ${{ github.workspace }}/eksctl'
command: 'curl -sLO "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_Linux_amd64.tar.gz"
&& tar -xzf eksctl_Linux_amd64.tar.gz -C ${{ github.workspace }}/eksctl && rm eksctl_Linux_amd64.tar.gz'
cleanup: 'rm -f eksctl_Linux_amd64.tar.gz'

- name: Add eksctl to Github Path
run: |
echo "${{ github.workspace }}/eksctl" >> $GITHUB_PATH
Expand All @@ -121,13 +108,6 @@ jobs:
--region ${{ inputs.aws-region }} \
--approve"

- name: Set up terraform
uses: ./.github/workflows/actions/execute_and_retry
with:
command: "wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg"
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
&& sudo apt update && sudo apt install terraform'

- name: Initiate Terraform
uses: ./.github/workflows/actions/execute_and_retry
with:
Expand Down Expand Up @@ -167,7 +147,7 @@ jobs:
# after installing Application Signals. Attempts to connect will be made for up to 10 minutes
if [ $deployment_failed -eq 0 ]; then
echo "Installing application signals to the sample app"
source ${GITHUB_WORKSPACE}/.github/workflows/util/execute_and_retry.sh
. ${GITHUB_WORKSPACE}/.github/workflows/util/execute_and_retry.sh
execute_and_retry 2 \
"${GITHUB_WORKSPACE}/enablement-script/enable-app-signals.sh \
${{ inputs.test-cluster-name }} \
Expand Down Expand Up @@ -327,7 +307,7 @@ jobs:
- name: Publish metric on test result
if: always()
run: |
if [[ "${{ steps.log-validation.outcome }}" == "success" && "${{ steps.metric-validation.outcome }}" == "success" && "${{ steps.trace-validation.outcome }}" == "success" ]]; then
if [ "${{ steps.log-validation.outcome }}" = "success" ] && [ "${{ steps.metric-validation.outcome }}" = "success" ] && [ "${{ steps.trace-validation.outcome }}" = "success" ]; then
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \
Expand Down Expand Up @@ -363,6 +343,7 @@ jobs:
- name: Terraform destroy
if: always()
continue-on-error: true
timeout-minutes: 5
working-directory: terraform/python/eks
run: |
terraform destroy -auto-approve \
Expand Down

0 comments on commit 821af32

Please sign in to comment.