Skip to content

Commit

Permalink
Add script to run e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
  • Loading branch information
JorTurFer committed Apr 12, 2022
1 parent 7c82b3d commit a03c681
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 84 deletions.
44 changes: 2 additions & 42 deletions .github/workflows/build_canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,46 +143,6 @@ jobs:
node_image: kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac
cluster_name: http-add-on-smoke-tests-cluster

- name: Install KEDA
- name: Run e2e test
run: |
helm repo add kedacore https://kedacore.github.io/charts
helm repo update
helm install keda kedacore/keda --namespace keda --create-namespace --wait
- name: Show Kubernetes resources in keda namespace
run: kubectl get all --namespace keda

- name: Install Http-add-on
run: |
helm install http-add-on kedacore/keda-add-ons-http --set images.tag=canary --namespace http-add-on --create-namespace --wait
- name: Show Kubernetes resources in http-add-on namespace
run: kubectl get all --namespace http-add-on

- name: Create resources
run: |
kubectl create ns app
helm install xkcd ./examples/xkcd --set autoscaling.http.minReplicas=1 -n app --wait
- name: Show Kubernetes resources in app namespace
run: kubectl get all --namespace app

- name: Check http-add-on generated ScaledObject
run: |
n=0
max=5
until [ "$n" -ge "$max" ]
do
ready=$(kubectl get so xkcd-app -n app -o jsonpath="{.status.conditions[0].status}")
echo "ready: $ready"
if [ $ready == "True" ]; then
break
fi
n=$((n+1))
sleep 15
done
if [ $n -eq $max ]; then
echo "The HPA is not working correctly"
exit 1
fi
./tests/e2e-test.sh
46 changes: 4 additions & 42 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,47 +155,9 @@ jobs:
with:
node_image: kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac
cluster_name: http-add-on-smoke-tests-cluster

- name: Install KEDA
run: |
helm repo add kedacore https://kedacore.github.io/charts
helm repo update
helm install keda kedacore/keda --namespace keda --create-namespace --wait
- name: Show Kubernetes resources in keda namespace
run: kubectl get all --namespace keda

- name: Install Http-add-on
run: |
helm install http-add-on kedacore/keda-add-ons-http --set images.tag=${{ steps.get_version.outputs.VERSION }} --namespace http-add-on --create-namespace --wait
- name: Show Kubernetes resources in http-add-on namespace
run: kubectl get all --namespace http-add-on

- name: Create resources
- name: Run e2e test
run: |
kubectl create ns app
helm install xkcd ./examples/xkcd --set autoscaling.http.minReplicas=1 -n app --wait
- name: Show Kubernetes resources in app namespace
run: kubectl get all --namespace app

- name: Check http-add-on generated ScaledObject
run: |
n=0
max=5
until [ "$n" -ge "$max" ]
do
ready=$(kubectl get so xkcd-app -n app -o jsonpath="{.status.conditions[0].status}")
echo "ready: $ready"
if [ $ready == "True" ]; then
break
fi
n=$((n+1))
sleep 15
done
if [ $n -eq $max ]; then
echo "The HPA is not working correctly"
exit 1
fi
./tests/e2e-test.sh
env:
TAG: ${{ steps.get_version.outputs.VERSION }}
105 changes: 105 additions & 0 deletions tests/e2e-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash

TAG=${TAG:-canary}

# Install KEDA
helm repo add kedacore https://kedacore.github.io/charts
helm repo update
helm upgrade --install keda kedacore/keda --namespace keda --create-namespace --wait

# Show Kubernetes resources in keda namespace
kubectl get all --namespace keda

# Install Http-add-on
helm upgrade --install http-add-on kedacore/keda-add-ons-http --set images.tag=$TAG --namespace keda --create-namespace --wait

# Show Kubernetes resources in http-add-on namespace
kubectl get all --namespace http-add-on

# Create resources
kubectl create ns app
helm upgrade --install xkcd ./examples/xkcd -n app --wait

# Show Kubernetes resources in app namespace
kubectl get all --namespace app

# Check http-add-on generated ScaledObject
n=0
max=5
until [ "$n" -ge "$max" ]
do
ready=$(kubectl get so xkcd-app -n app -o jsonpath="{.status.conditions[0].status}")
echo "ready: $ready"
if [ $ready == "True" ]; then
break
fi
n=$((n+1))
sleep 15
done
if [ $n -eq $max ]; then
echo "The ScaledObject is not working correctly"
exit 1
fi
echo "The ScaledObject is working correctly"

# Check that deployment has 0 instances
n=0
max=5
until [ "$n" -ge "$max" ]
do
replicas=$(kubectl get deploy xkcd -n app -o jsonpath="{.spec.replicas}")
echo "replicas: $replicas"
if [ $replicas == "0" ]; then
break
fi
n=$((n+1))
sleep 15
done
if [ $n -eq $max ]; then
echo "Current replica count is not 0"
exit 1
fi
echo "The workflow is scaled to zero"

# Generate one request

cat <<EOF | kubectl apply -f -
apiVersion: batch/v1
kind: Job
metadata:
name: generate-request
namespace: app
spec:
template:
spec:
containers:
- name: curl-client
image: curlimages/curl
imagePullPolicy: Always
command: ["curl", "-H", "Host: myhost.com", "keda-add-ons-http-interceptor-proxy.keda:8080"]
restartPolicy: Never
activeDeadlineSeconds: 600
backoffLimit: 5
EOF

# Check that deployment has 1 instances
n=0
max=5
until [ "$n" -ge "$max" ]
do
replicas=$(kubectl get deploy xkcd -n app -o jsonpath="{.spec.replicas}")
echo "replicas: $replicas"
if [ $replicas == "1" ]; then
break
fi
n=$((n+1))
sleep 15
done
if [ $n -eq $max ]; then
echo "Current replica count is not 1"
exit 1
fi

echo "The workflow is scaled to one"

echo "SUCCESS"

0 comments on commit a03c681

Please sign in to comment.