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

feat(tests): use gha groups to group terminal output #61

Merged
merged 11 commits into from
Oct 14, 2023
14 changes: 12 additions & 2 deletions .github/workflows/aws-cloud-regression-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,25 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Setup Codespace Container
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 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
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 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 --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
run: docker rm -f codespaces
if: always()
18 changes: 12 additions & 6 deletions tests/k8s-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF | kubectl apply -f -
apiVersion: storage.k8s.io/v1
kind: StorageClass
Expand All @@ -18,9 +19,10 @@ volumeBindingMode: WaitForFirstConsumer
parameters:
type: gp2
EOF
echo "::endgroup::"

# Step 3: Deploy a test application with a PersistentVolumeClaim (PVC)
echo "Deploying test application..."
echo "::group::Deploying test application..."
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolumeClaim
Expand Down Expand Up @@ -61,24 +63,28 @@ spec:
persistentVolumeClaim:
claimName: test-pvc
EOF
echo "::endgroup::"

# Step 4: Verify the PVC and pod are created and bound
echo "Waiting for the PVC to be bound and the pod to be running..."
echo "::group::Waiting for the PVC to be bound and the pod to be running..."
sleep 30
kubectl get pvc
kubectl get pods
kubectl describe pods
kubectl describe pvc
echo "::endgroup::"


# Step 5: Test the storage functionality
TEST_POD_NAME=$(kubectl get pods -l app=test-app -o jsonpath="{.items[0].metadata.name}")
echo "Writing and reading data from the PVC in the test pod $TEST_POD_NAME..."
echo "::group::Writing and reading data from the PVC in the test pod $TEST_POD_NAME..."
kubectl exec -it $TEST_POD_NAME -- /bin/sh -c "echo 'Hello, World!' > /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::"
18 changes: 16 additions & 2 deletions tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

set -e

echo "::group::Destroy anything left running"
./destroy-aws.sh
echo "::endgroup::"

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"
Expand All @@ -18,16 +24,24 @@ 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 "==> Start Test Suite"
./k8s-test.sh
echo "Test Suite Complete"
echo "==> Test Suite Complete"

echo "::group::Tear down Environment"
echo "Terraform Destroy"
terraform destroy -auto-approve

./destroy-aws.sh
echo "::endgroup::"
Loading