Skip to content

edited yml

edited yml #49

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
name: Run EKS op-int-test Integration Tests
env:
TERRAFORM_AWS_ASSUME_ROLE: ${{ secrets.TERRAFORM_AWS_ASSUME_ROLE }}
ECR_OPERATOR_STAGING_IMAGE: ${{ secrets.ECR_OPERATOR_STAGING_IMAGE }}
on:
push:
branches:
- main*
- op-int-test
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
jobs:
OperatorIntegrationTest:
name: OperatorIntegrationTest
runs-on: ubuntu-latest
env:
OPERATOR_IMAGE: ${{ secrets.ECR_OPERATOR_STAGING_IMAGE }}
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Checkout code
uses: actions/checkout@v2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }}
aws-region: us-west-2
- name: Login to ECR
if: steps.cached_binaries.outputs.cache-hit == false
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Set up Docker Buildx
if: steps.cached_binaries.outputs.cache-hit == false
uses: docker/setup-buildx-action@v1
- name: Set up QEMU
if: steps.cached_binaries.outputs.cache-hit == false
uses: docker/setup-qemu-action@v1
- name: Build Cloudwatch Agent Operator Image and push to ECR
uses: docker/build-push-action@v4
if: steps.cached_binaries.outputs.cache-hit == false
with:
file: ./Dockerfile
context: .
push: true
tags: ${{ env.ECR_OPERATOR_STAGING_IMAGE }}
platforms: linux/amd64, linux/arm64
- name: Update manager.yaml
run: |
sed -i "s|\${OPERATOR_IMAGE}|$ECR_OPERATOR_STAGING_IMAGE|" config/manager/manager.yaml
cat config/manager/manager.yaml
- name: Verify Terraform version
run: terraform --version
- name: Terraform apply
uses: nick-fields/retry@v2
with:
max_attempts: 1
timeout_minutes: 60 # EKS takes about 20 minutes to spin up a cluster and service on the cluster
retry_wait_seconds: 5
command: |
cd integration-tests/terraform/testbuild
terraform init
if terraform apply --auto-approve; then
cd -
echo "running make test certificate"
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.12.0/cert-manager.yaml
echo "running make install"
make install
echo "running make deploy"
make deploy
sleep 180
cd integration-tests/terraform/testbuild
kubectl apply -f sample-instrumentation.yaml
kubectl apply -f test-deployment.yaml
kubectl apply -f ns-annotation-test-deployment.yaml
kubectl apply -f agent_daemon_set.yaml
sleep 120
kubectl get all -n amazon-cloudwatch
kubectl describe pod
kubectl get pods -A
kubectl describe deployment cloudwatch-controller-manager -n amazon-cloudwatch
kubectl describe deployment nginx -n amazon-cloudwatch
kubectl describe deployment nginx
kubectl describe daemonset cloudwatch-agent -n amazon-cloudwatch
pod_name="$(kubectl get pods -n amazon-cloudwatch -l app.kubernetes.io/component=amazon-cloudwatch-agent,app.kubernetes.io/instance=amazon-cloudwatch.cloudwatch-agent -o=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}')"
echo "Pod name: $pod_name"
status=$(kubectl get pod "$pod_name" -n amazon-cloudwatch -o=jsonpath='{.status.phase}')
if [ "$status" != "Running" ]; then
echo "Pod $pod_name is not running. Exiting with ERROR."
echo "Testcase 1: Pod running test case: FAIL"
terraform destroy -auto-approve && exit 1
else
echo "Pod $pod_name is running."
echo "Testcase 1: Pod running test case: PASS"
fi
else
terraform destroy -auto-approve && exit 1
fi
- name: java Annotation testing
run: |
cd integration-tests/terraform/testbuild/cmd
go run ./test_default_and_ns_instrumentation_main.go
if [ $? -ne 0 ]; then
terraform destroy -auto-approve && exit 1
fi
- name: Terraform destroy
if: ${{ cancelled() || failure() }}
uses: nick-fields/retry@v2
with:
max_attempts: 3
timeout_minutes: 8
retry_wait_seconds: 5
command: |
cd integration-tests/terraform/eks
terraform destroy --auto-approve