Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic timewait in integ tests #82

Merged
merged 4 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 2m always enough? any chance that we need to loop this?

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"
}
Loading