Skip to content

Commit

Permalink
Try increasing the time locally
Browse files Browse the repository at this point in the history
Signed-off-by: anushkamittal2001 <[email protected]>
  • Loading branch information
anushkamittal2001 committed Sep 26, 2023
1 parent aeb8864 commit 13968d9
Showing 1 changed file with 56 additions and 3 deletions.
59 changes: 56 additions & 3 deletions .github/workflows/load-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,65 @@ jobs:

- name: Run ./start.sh Script
run: |
cd k6
"#!/usr/bin/env bash
set -euo pipefail
NAMESPACE="load-test"
if [[ $# -lt 3 ]]; then
echo "Usage: $0 <script> <vus> <iterations>" 1>&2
echo "Example: $0 tests/my-test.js 10 100" 1>&2
exit 1
fi
SCRIPT="$1"
VUS="$2"
ITERATIONS="$3"
if [[ $ITERATIONS -lt $VUS ]]; then
echo "iterations must be greater or equal to vus" 1>&2
exit 1
fi
echo "Deploying namespace..."
kubectl create ns "$NAMESPACE"
echo "Deploying RBAC..."
kubectl apply -n "$NAMESPACE" -f rbac.yaml
# copy the script to a temp file under a common name
# so that we can reference always to the same name in the pod
SCRIPT_DIR=$(mktemp -d)
NEW_SCRIPT_PATH="${SCRIPT_DIR}/script.js"
./start.sh tests/my-test.js 10 100
timeout-minutes: 30
cp "$SCRIPT" "$NEW_SCRIPT_PATH"
echo "Creating configmap..."
kubectl create configmap -n "$NAMESPACE" load-test --from-file="tests/util.js" --from-file="$NEW_SCRIPT_PATH" --from-literal="vus=$VUS" --from-literal="iterations=$ITERATIONS"
rm -rf "$SCRIPT_DIR"
echo "Deploying k6 job..."
kubectl apply -n "$NAMESPACE" -f job.yaml
echo "Waiting for the job to be completed..."
kubectl wait -n "$NAMESPACE" --for=condition=complete --timeout=1200s jobs/load-test
echo "Extracting logs and summary..."
kubectl logs -n "$NAMESPACE" jobs/load-test > "$(basename "$SCRIPT")-${VUS}vu-${ITERATIONS}it-logs.txt"
echo "Clean up job and configmap..."
kubectl delete -n "$NAMESPACE" jobs load-test
kubectl delete -n "$NAMESPACE" configmap load-test
kubectl delete clusterrolebinding load-test
echo "Clean up..."
kubectl delete ns "$NAMESPACE"
"
working-directory: ${{ github.workspace }}/load-testing


- name: Delete Kind cluster
run: |
kind delete cluster --name my-kind-cluster
Expand Down

0 comments on commit 13968d9

Please sign in to comment.