Skip to content

Commit

Permalink
Testing apm
Browse files Browse the repository at this point in the history
  • Loading branch information
mitali-salvi committed Sep 1, 2023
1 parent ee80879 commit 1f6a4d3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 31 deletions.
57 changes: 27 additions & 30 deletions .github/workflows/operator-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,33 @@ jobs:
- name: Build the operator
run: mkdir ${{ github.workspace }}/dist $$ make kustomize && make release-artifacts IMG=506463145083.dkr.ecr.us-west-2.amazonaws.com/cwagent-operator-pre-release:latest

- name: Build the operator
run: cat ${{ github.workspace }}/dist/amazon-cloudwatch-agent-operator.yaml
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.TERRAFORM_AWS_ASSUME_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}

- name: Set up terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false

- name: Terraform apply
uses: nick-fields/retry@v2
with:
max_attempts: 3
timeout_minutes: 60 # EKS takes about 20 minutes to spin up a cluster and service on the cluster
retry_wait_seconds: 5
command: |
cd testing/terraform/eks/deployment
terraform init
terraform validate
if terraform apply -var="operator_yaml=${{ github.workspace }}/dist/amazon-cloudwatch-agent-operator.yaml" --auto-approve; then
terraform destroy -auto-approve
else
terraform destroy -var="operator_yaml=${{ github.workspace }}/dist/amazon-cloudwatch-agent-operator.yaml" --auto-approve && exit 1
fi
# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v2
# with:
# role-to-assume: ${{ secrets.TERRAFORM_AWS_ASSUME_ROLE }}
# aws-region: ${{ env.AWS_DEFAULT_REGION }}
#
# - name: Set up terraform
# uses: hashicorp/setup-terraform@v2
# with:
# terraform_wrapper: false
#
# - name: Terraform apply
# uses: nick-fields/retry@v2
# with:
# max_attempts: 3
# timeout_minutes: 60 # EKS takes about 20 minutes to spin up a cluster and service on the cluster
# retry_wait_seconds: 5
# command: |
# cd testing/terraform/eks/deployment
# terraform init
# terraform validate
# if terraform apply --auto-approve; then
# terraform destroy -auto-approve
# else
# terraform destroy -auto-approve && exit 1
# fi
#
# - name: Terraform destroy
# if: ${{ cancelled() || failure() }}
# uses: nick-fields/retry@v2
Expand All @@ -61,4 +58,4 @@ jobs:
# retry_wait_seconds: 5
# command: |
# cd testing/terraform/eks/deployment
# terraform destroy --auto-approve
# terraform destroy -var="operator_yaml=${{ github.workspace }}/dist/amazon-cloudwatch-agent-operator.yaml" --auto-approve
13 changes: 12 additions & 1 deletion testing/terraform/eks/deployment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,24 @@ resource "null_resource" "setup-operator-validator" {
provisioner local-exec {
command = <<-EOT
kubectl create namespace testing_ground
for i in {1..3}
do
operator_status=$(kubectl apply -f ${var.operator_yaml} 2>&1)
if [[ "${operator_status}" == *"Error "* ]]; then
sleep 60
continue
fi
break
done
EOT
}
}

resource "null_resource" "operator-validator" {
depends_on = [
null_resource.eks-addon
aws_eks_cluster.this,
aws_eks_node_group.this,
null_resource.kubectl-addon
]
provisioner "local-exec" {
command = <<-EOT
Expand Down
5 changes: 5 additions & 0 deletions testing/terraform/eks/deployment/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ variable "k8s_version" {
type = string
default = "1.27"
}

variable "operator_yaml" {
type = string
default = ""
}

0 comments on commit 1f6a4d3

Please sign in to comment.