Skip to content

Commit

Permalink
feat(tests): more groups
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandoataoldotcom authored Oct 14, 2023
1 parent 11d730f commit 704a0ff
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/aws-cloud-regression-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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::"
6 changes: 6 additions & 0 deletions tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

set -e

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

echo "::group::Deploying Kubernetes"
echo "Terraform Init"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 704a0ff

Please sign in to comment.