Skip to content

Commit

Permalink
E2E Test: Add failure if Operator image hasn't changed
Browse files Browse the repository at this point in the history
  • Loading branch information
majanjua-amzn committed Dec 18, 2023
1 parent e76c2e0 commit 0931fce
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/appsignals-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ env:
SAMPLE_APP_REMOTE_SERVICE_IMAGE: ${{ secrets.APP_SIGNALS_E2E_SAMPLE_APP_REMOTE_SERVICE_IMAGE }}
METRIC_NAMESPACE: AppSignals
LOG_GROUP: /aws/appsignals/eks
ECR_OPERATOR_STAGING_IMAGE: ${{ secrets.ECR_OPERATOR_STAGING_IMAGE }}
ECR_OPERATOR_STAGING_IMAGE: public.ecr.aws/cloudwatch-agent/cloudwatch-agent-operator:1.0.2

jobs:
appsignals-e2e-test:
Expand Down Expand Up @@ -115,6 +115,11 @@ jobs:
${{ env.AWS_DEFAULT_REGION }} \
${{ env.SAMPLE_APP_NAMESPACE }}
- name: Save CloudWatch Agent Operator image to environment before patching
run: |
echo "OLD_CW_AGENT_OPERATOR_IMAGE"=$(kubectl get pods -n amazon-cloudwatch -l app.kubernetes.io/name=amazon-cloudwatch-observability -o json | \
jq '.items[0].status.containerStatuses[0].image') >> $GITHUB_ENV
- name: Patch the CloudWatch Agent Operator image and restart CloudWatch pods
run: |
kubectl patch deploy -n amazon-cloudwatch amazon-cloudwatch-observability-controller-manager --type='json' -p '[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "${{ env.ECR_OPERATOR_STAGING_IMAGE }}"}]'
Expand All @@ -135,20 +140,30 @@ jobs:
echo "REMOTE_SERVICE_DEPLOYMENT_NAME=$(kubectl get deployments -n ${{ env.SAMPLE_APP_NAMESPACE }} --selector=app=remote-app -o jsonpath='{.items[0].metadata.name}')" >> $GITHUB_ENV
echo "REMOTE_SERVICE_POD_IP=$(kubectl get pods -n ${{ env.SAMPLE_APP_NAMESPACE }} --selector=app=remote-app -o jsonpath='{.items[0].status.podIP}')" >> $GITHUB_ENV
- name: Verify pod ADOT image
- name: Log pod ADOT image ID
run: |
kubectl get pods -n ${{ env.SAMPLE_APP_NAMESPACE }} --output json | \
jq '.items[0].status.initContainerStatuses[0].imageID'
- name: Verify pod CWAgent image
- name: Log pod CWAgent image ID
run: |
kubectl get pods -n amazon-cloudwatch -l app.kubernetes.io/name=cloudwatch-agent -o json | \
jq '.items[0].status.containerStatuses[0].imageID'
- name: Verify pod CWAgent Operator image
- name: Log pod CWAgent Operator image ID and save image to the environment
run: |
kubectl get pods -n amazon-cloudwatch -l app.kubernetes.io/name=amazon-cloudwatch-observability -o json | \
jq '.items[0].status.containerStatuses[0].imageID'
echo "NEW_CW_AGENT_OPERATOR_IMAGE"=$(kubectl get pods -n amazon-cloudwatch -l app.kubernetes.io/name=amazon-cloudwatch-observability -o json | \
jq '.items[0].status.containerStatuses[0].image') >> $GITHUB_ENV
- name: Check if CW Agent Operator image has changed
run: |
if [ ${{ env.OLD_CW_AGENT_OPERATOR_IMAGE }} = ${{ env.NEW_CW_AGENT_OPERATOR_IMAGE }} ]; then
echo "Operator image did not change"
exit 1
fi
- name: Get the sample app endpoint
run: |
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Testing

on:
push:
branches:
- release-test-fix

permissions:
id-token: write
contents: read

jobs:
e2e-test:
uses: ./.github/workflows/appsignals-e2e-test.yml
secrets: inherit
# Two E2E tests should not run at the same time in the same EKS cluster
concurrency:
group: 'e2e-cw-agent-operator-test'
cancel-in-progress: false
with:
test-cluster-name: 'e2e-cw-agent-operator-test'

0 comments on commit 0931fce

Please sign in to comment.