Skip to content

Commit

Permalink
Add dynamic timewait in integ tests (aws#82)
Browse files Browse the repository at this point in the history
* Add dynamic timewait in integ tests

* Added missed wait time

* Added windows integ tests as part of integ

1. Added instructions to run 2 integ for each windows os version

* Update pod count in tests
  • Loading branch information
KlwntSingh committed Mar 18, 2024
1 parent c83e0b3 commit d4ec306
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 81 deletions.
78 changes: 0 additions & 78 deletions .github/workflows/helm-integ-test-windows.yml

This file was deleted.

112 changes: 112 additions & 0 deletions .github/workflows/helm-integ-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,116 @@ jobs:
retry_wait_seconds: 5
command: |
cd integration-tests/terraform/helm
terraform destroy --auto-approve
HelmChartsIntegrationTestWindows-2022:
name: HelmChartsIntegrationTestWindows-2022
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Generate testing id
run: echo TESTING_ID="${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_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: 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/helm-windows
terraform init
if terraform apply -auto-approve \
-var="windows_os_version=WINDOWS_CORE_2022_x86_64" -var="kube_dir=${{ github.workspace }}/../../../.kube"; then
terraform destroy -auto-approve
else
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/helm-windows
terraform destroy --auto-approve
HelmChartsIntegrationTestWindows-2019:
name: HelmChartsIntegrationTestWindows-2019
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Generate testing id
run: echo TESTING_ID="${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ env.TERRAFORM_AWS_ASSUME_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_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: 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/helm-windows
terraform init
if terraform apply -auto-approve \
-var="windows_os_version=WINDOWS_CORE_2019_x86_64" -var="kube_dir=${{ github.workspace }}/../../../.kube"; then
terraform destroy -auto-approve
else
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/helm-windows
terraform destroy --auto-approve
21 changes: 18 additions & 3 deletions integration-tests/terraform/helm-windows/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ resource "aws_eks_node_group" "node_group_windows" {
min_size = 1
}

ami_type = "WINDOWS_CORE_2022_x86_64"
ami_type = var.windows_os_version
capacity_type = "ON_DEMAND"
disk_size = 50
instance_types = ["t3a.medium"]
instance_types = ["t3.large"]

depends_on = [
aws_iam_role_policy_attachment.node_CloudWatchAgentServerPolicy,
Expand Down Expand Up @@ -206,9 +206,24 @@ resource "helm_release" "this" {
chart = "${var.helm_dir}"
}

resource "null_resource" "deployment_wait" {
depends_on = [
helm_release.this,
]
provisioner "local-exec" {
command = <<-EOT
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
./kubectl rollout status daemonset fluent-bit-windows -n amazon-cloudwatch --timeout 600s
./kubectl rollout status daemonset cloudwatch-agent-windows -n amazon-cloudwatch --timeout 600s
EOT
}
}

resource "null_resource" "validator" {
depends_on = [
helm_release.this
helm_release.this,
null_resource.deployment_wait
]
provisioner "local-exec" {
command = "go test ${var.test_dir} -v --tags=windowslinux"
Expand Down
5 changes: 5 additions & 0 deletions integration-tests/terraform/helm-windows/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ variable "cluster_name" {
type = string
default = "cwagent-operator-helm-integ"
}

variable "windows_os_version" {
type = string
default = "WINDOWS_CORE_2022_x86_64"
}

0 comments on commit d4ec306

Please sign in to comment.