From 11d730fe0aa458ee072a58d5f45466ed57fa611c Mon Sep 17 00:00:00 2001 From: fernandoataoldotcom Date: Sat, 14 Oct 2023 13:21:07 +0000 Subject: [PATCH 01/11] feat(tests): use gha groups to group terminal output --- tests/run.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/run.sh b/tests/run.sh index 6ee3eb1..8342bc0 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -4,12 +4,15 @@ set -e ./destroy-aws.sh +echo "::group::Deploying Kubernetes" echo "Terraform Init" terraform init echo "Terraform Plan" terraform plan echo "Terraform Apply" terraform apply -auto-approve +echo "::endgroup::" +echo "::group::Configuring Kubernetes" echo "Authenticate with Kubernetes" aws eks update-kubeconfig --region us-west-2 --name captain-cluster --role-arn arn:aws:iam::761182885829:role/glueops-captain echo "Delete AWS CNI" @@ -18,16 +21,23 @@ echo "Install Calico CNI" helm repo add projectcalico https://docs.tigera.io/calico/charts helm repo update helm install calico projectcalico/tigera-operator --version v3.26.1 --namespace tigera-operator -f calico.yaml --create-namespace +echo "::endgroup::" +echo "::group::Deploying new Node Pool" echo "Deploy node pool" sed -i 's/#//g' main.tf terraform apply -auto-approve echo "Get nodes and pods from kubernetes" kubectl get nodes kubectl get pods -A -o=wide -echo "Start Test Suite" +echo "::endgroup::" +echo "::group::Start Test Suite" +echo "" ./k8s-test.sh echo "Test Suite Complete" +echo "::endgroup::" +echo "::group::Tear down Environment" echo "Terraform Destroy" terraform destroy -auto-approve ./destroy-aws.sh +echo "::endgroup::" From 704a0fff47953a72fbafc31c1ddfa19239d5b699 Mon Sep 17 00:00:00 2001 From: fernandoataoldotcom Date: Sat, 14 Oct 2023 13:51:51 +0000 Subject: [PATCH 02/11] feat(tests): more groups --- .../workflows/aws-cloud-regression-suite.yml | 17 ++++++++++++----- tests/k8s-test.sh | 18 ++++++++++++------ tests/run.sh | 6 ++++++ 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.github/workflows/aws-cloud-regression-suite.yml b/.github/workflows/aws-cloud-regression-suite.yml index ce71f64..8505d69 100644 --- a/.github/workflows/aws-cloud-regression-suite.yml +++ b/.github/workflows/aws-cloud-regression-suite.yml @@ -19,15 +19,22 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Running AWS Regression Suite + - name: Setup Codespace Container env: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | - docker run -v $(pwd):/app --workdir /app/tests --rm -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 ghcr.io/glueops/codespaces:v0.31.1 ./run.sh + echo "::group::Setup Codespace Container" + docker run -d -v $(pwd):/app --workdir /app/tests --rm -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 --name codespaces ghcr.io/glueops/codespaces:v0.31.1 sleep infinity + echo "::endgroup::" + + - name: Running AWS Regression Suite + run: | + docker exec codespaces ./run.sh - name: Run AWS Destroy Only (in case previous step failed) - env: - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | - docker run -v $(pwd):/app --workdir /app/tests --rm -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 ghcr.io/glueops/codespaces:v0.31.1 ./destroy-aws.sh + docker exec codespaces ./destroy-aws.sh if: always() + + - name: Delete Codespaces Container + run: docker rm -f codespaces diff --git a/tests/k8s-test.sh b/tests/k8s-test.sh index 161e520..085a16b 100755 --- a/tests/k8s-test.sh +++ b/tests/k8s-test.sh @@ -3,11 +3,12 @@ set -e # Step 1: Verify storage driver installation (Amazon EBS CSI Driver) -echo "Checking if the storage driver is installed..." +echo "::group::Checking if the storage driver is installed..." kubectl get pods -n kube-system | grep "ebs-csi-" +echo "::endgroup::" # Step 2: Create a StorageClass -echo "Creating StorageClass..." +echo "::group::Creating StorageClass..." cat < /data/test.txt" kubectl exec -it $TEST_POD_NAME -- cat /data/test.txt +echo "::endgroup::" # Step 6: Clean up (Optional) -echo "Cleaning up test resources..." +echo "::group::Cleaning up test resources..." kubectl delete deployment test-app kubectl delete pvc test-pvc kubectl delete storageclass ebs-sc +echo "::endgroup::" diff --git a/tests/run.sh b/tests/run.sh index 8342bc0..0edcb33 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -2,7 +2,9 @@ set -e +echo "::group::Destroy anything left running" ./destroy-aws.sh +echo "::endgroup::" echo "::group::Deploying Kubernetes" echo "Terraform Init" @@ -12,6 +14,7 @@ terraform plan echo "Terraform Apply" terraform apply -auto-approve echo "::endgroup::" + echo "::group::Configuring Kubernetes" echo "Authenticate with Kubernetes" aws eks update-kubeconfig --region us-west-2 --name captain-cluster --role-arn arn:aws:iam::761182885829:role/glueops-captain @@ -22,6 +25,7 @@ helm repo add projectcalico https://docs.tigera.io/calico/charts helm repo update helm install calico projectcalico/tigera-operator --version v3.26.1 --namespace tigera-operator -f calico.yaml --create-namespace echo "::endgroup::" + echo "::group::Deploying new Node Pool" echo "Deploy node pool" sed -i 's/#//g' main.tf @@ -30,11 +34,13 @@ echo "Get nodes and pods from kubernetes" kubectl get nodes kubectl get pods -A -o=wide echo "::endgroup::" + echo "::group::Start Test Suite" echo "" ./k8s-test.sh echo "Test Suite Complete" echo "::endgroup::" + echo "::group::Tear down Environment" echo "Terraform Destroy" terraform destroy -auto-approve From 37520a522646cfd59372ebaf19db58f30a92de35 Mon Sep 17 00:00:00 2001 From: fernandoataoldotcom Date: Sat, 14 Oct 2023 14:01:54 +0000 Subject: [PATCH 03/11] fix(tests): move env vars --- .github/workflows/aws-cloud-regression-suite.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/aws-cloud-regression-suite.yml b/.github/workflows/aws-cloud-regression-suite.yml index 8505d69..2dba431 100644 --- a/.github/workflows/aws-cloud-regression-suite.yml +++ b/.github/workflows/aws-cloud-regression-suite.yml @@ -24,16 +24,16 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | echo "::group::Setup Codespace Container" - docker run -d -v $(pwd):/app --workdir /app/tests --rm -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 --name codespaces ghcr.io/glueops/codespaces:v0.31.1 sleep infinity + docker run -d -v $(pwd):/app --workdir /app/tests --rm --name codespaces ghcr.io/glueops/codespaces:v0.31.1 sleep infinity echo "::endgroup::" - name: Running AWS Regression Suite run: | - docker exec codespaces ./run.sh + docker exec -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces ./run.sh - name: Run AWS Destroy Only (in case previous step failed) run: | - docker exec codespaces ./destroy-aws.sh + docker exec -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces ./destroy-aws.sh if: always() - name: Delete Codespaces Container From 6bc7bc11facf9fa4787a870b7793684aa75bb401 Mon Sep 17 00:00:00 2001 From: fernandoataoldotcom Date: Sat, 14 Oct 2023 14:05:09 +0000 Subject: [PATCH 04/11] fix(tests): chmod --- .github/workflows/aws-cloud-regression-suite.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/aws-cloud-regression-suite.yml b/.github/workflows/aws-cloud-regression-suite.yml index 2dba431..ced67d5 100644 --- a/.github/workflows/aws-cloud-regression-suite.yml +++ b/.github/workflows/aws-cloud-regression-suite.yml @@ -29,11 +29,11 @@ jobs: - name: Running AWS Regression Suite run: | - docker exec -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces ./run.sh + docker exec -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces chmod +x run.sh && ./run.sh - name: Run AWS Destroy Only (in case previous step failed) run: | - docker exec -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces ./destroy-aws.sh + docker exec -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces chmod +x destroy-aws.sh && ./destroy-aws.sh if: always() - name: Delete Codespaces Container From df10d34b9d22685cbc7a4703bfd78334ee92c0d7 Mon Sep 17 00:00:00 2001 From: fernandoataoldotcom Date: Sat, 14 Oct 2023 14:10:02 +0000 Subject: [PATCH 05/11] fix(tests): workdir --- .github/workflows/aws-cloud-regression-suite.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/aws-cloud-regression-suite.yml b/.github/workflows/aws-cloud-regression-suite.yml index ced67d5..8785b79 100644 --- a/.github/workflows/aws-cloud-regression-suite.yml +++ b/.github/workflows/aws-cloud-regression-suite.yml @@ -20,20 +20,22 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Setup Codespace Container - env: - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | echo "::group::Setup Codespace Container" docker run -d -v $(pwd):/app --workdir /app/tests --rm --name codespaces ghcr.io/glueops/codespaces:v0.31.1 sleep infinity echo "::endgroup::" - name: Running AWS Regression Suite + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | - docker exec -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces chmod +x run.sh && ./run.sh + docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces ./run.sh - name: Run AWS Destroy Only (in case previous step failed) + env: + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | - docker exec -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces chmod +x destroy-aws.sh && ./destroy-aws.sh + docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces ./destroy-aws.sh if: always() - name: Delete Codespaces Container From 4034bec94b9f5ebdd20997c01bdbc8d9695f5ce8 Mon Sep 17 00:00:00 2001 From: fernandoataoldotcom Date: Sat, 14 Oct 2023 14:14:49 +0000 Subject: [PATCH 06/11] fix(tests): one chmod --- .github/workflows/aws-cloud-regression-suite.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/aws-cloud-regression-suite.yml b/.github/workflows/aws-cloud-regression-suite.yml index 8785b79..5fed3c9 100644 --- a/.github/workflows/aws-cloud-regression-suite.yml +++ b/.github/workflows/aws-cloud-regression-suite.yml @@ -29,7 +29,7 @@ jobs: env: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | - docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces ./run.sh + docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces chmod +x run.sh && ./run.sh - name: Run AWS Destroy Only (in case previous step failed) env: From 46161d7ea8ce755fc85068b9ec74216cb78b2b76 Mon Sep 17 00:00:00 2001 From: fernandoataoldotcom Date: Sat, 14 Oct 2023 14:18:57 +0000 Subject: [PATCH 07/11] test(tests): debugging --- .github/workflows/aws-cloud-regression-suite.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/aws-cloud-regression-suite.yml b/.github/workflows/aws-cloud-regression-suite.yml index 5fed3c9..1e82855 100644 --- a/.github/workflows/aws-cloud-regression-suite.yml +++ b/.github/workflows/aws-cloud-regression-suite.yml @@ -29,6 +29,9 @@ jobs: env: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | + docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces ls + docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces pwd + docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces chmod +x run.sh && ./run.sh - name: Run AWS Destroy Only (in case previous step failed) From 28a54209c94f948b11f816253ebeef35ef7f26c0 Mon Sep 17 00:00:00 2001 From: fernandoataoldotcom Date: Sat, 14 Oct 2023 14:23:46 +0000 Subject: [PATCH 08/11] test(tests): sh --- .github/workflows/aws-cloud-regression-suite.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/aws-cloud-regression-suite.yml b/.github/workflows/aws-cloud-regression-suite.yml index 1e82855..f10be6d 100644 --- a/.github/workflows/aws-cloud-regression-suite.yml +++ b/.github/workflows/aws-cloud-regression-suite.yml @@ -32,13 +32,13 @@ jobs: docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces ls docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces pwd - docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces chmod +x run.sh && ./run.sh + docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces sh ./run.sh - name: Run AWS Destroy Only (in case previous step failed) env: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | - docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces ./destroy-aws.sh + docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces sh ./destroy-aws.sh if: always() - name: Delete Codespaces Container From 53369bb679a7ed82e6c77429660547e08d41de37 Mon Sep 17 00:00:00 2001 From: fernandoataoldotcom Date: Sat, 14 Oct 2023 14:58:16 +0000 Subject: [PATCH 09/11] test(tests): remove debugging commands, ensure container is destroyed --- .github/workflows/aws-cloud-regression-suite.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/aws-cloud-regression-suite.yml b/.github/workflows/aws-cloud-regression-suite.yml index f10be6d..220d52f 100644 --- a/.github/workflows/aws-cloud-regression-suite.yml +++ b/.github/workflows/aws-cloud-regression-suite.yml @@ -29,9 +29,6 @@ jobs: env: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | - docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces ls - docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces pwd - docker exec --workdir /app/tests -e AWS_SECRET_ACCESS_KEY -e AWS_ACCESS_KEY_ID=AKIA3COQJC7C2PNUKZV4 -e AWS_DEFAULT_REGION=us-west-2 codespaces sh ./run.sh - name: Run AWS Destroy Only (in case previous step failed) @@ -43,3 +40,4 @@ jobs: - name: Delete Codespaces Container run: docker rm -f codespaces + if: always() From 32deeca7d3ab22914e3d3e73b59585df808e9d07 Mon Sep 17 00:00:00 2001 From: fernandoataoldotcom Date: Sat, 14 Oct 2023 14:58:55 +0000 Subject: [PATCH 10/11] fix(run.sh): remove nested group --- tests/run.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index 0edcb33..da268cc 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -35,11 +35,10 @@ kubectl get nodes kubectl get pods -A -o=wide echo "::endgroup::" -echo "::group::Start Test Suite" +echo "Start Test Suite" echo "" ./k8s-test.sh echo "Test Suite Complete" -echo "::endgroup::" echo "::group::Tear down Environment" echo "Terraform Destroy" From 9e57b43a7053e0fd834161fd9a4e08a3cebd027f Mon Sep 17 00:00:00 2001 From: fernandoataoldotcom Date: Sat, 14 Oct 2023 15:32:03 +0000 Subject: [PATCH 11/11] style(tests): formatting for improved output readability --- tests/run.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index da268cc..06ff4cd 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -35,10 +35,9 @@ kubectl get nodes kubectl get pods -A -o=wide echo "::endgroup::" -echo "Start Test Suite" -echo "" +echo "==> Start Test Suite" ./k8s-test.sh -echo "Test Suite Complete" +echo "==> Test Suite Complete" echo "::group::Tear down Environment" echo "Terraform Destroy"