Skip to content

Instantly share code, notes, and snippets.

@masayag
Last active November 29, 2021 12:52
Show Gist options
  • Select an option

  • Save masayag/00ac45748b3c89e1dfe997e9c6d7e413 to your computer and use it in GitHub Desktop.

Select an option

Save masayag/00ac45748b3c89e1dfe997e9c6d7e413 to your computer and use it in GitHub Desktop.
Using JMeter for testing K4E scalability
#!/bin/bash
cd /home/test/apache-jmeter-5.4.1
export KUBECONFIG=/root/kubeconfig
Usage() {
echo "Usage:"
echo `basename $0` "<test-run-number> <edge-devices-count> <ramp-up-time-seconds> <iterations>"
}
if [ $# != 4 ] ; then
echo -e "\n"
Usage
exit 1
fi
test_plan=/home/test/k4e-scale/test_plans/k4e_test_plan.jmx
test_dir="/home/test/scale-test/test-run-$1"
if [ -d "$test_dir" ]; then
echo "Test directory $test_dir already exists"
exit 1
fi
mkdir -p $test_dir/results
echo "Run by: `basename $0` $@" > $test_dir/run.out
echo "Target folder: $test_dir" >> $test_dir/run.out
echo "Edge device count: $2" >> $test_dir/run.out
echo "Ramp up time: $3" >> $test_dir/run.out
echo "Iterations: $4" >> $test_dir/run.out
edgedevices=$(oc get edgedevices | wc -l)
edgedeploy=$(oc get edgedeployments | wc -l)
echo "Before test: There are $edgedevices edge devices and $edgedeploy edge deployments" >> $test_dir/run.out
K8S_BEARER_TOKEN=$(kubectl get secret $(kubectl get serviceaccount k4e-scale-test -o json | jq -r '.secrets[].name') -o yaml | grep " token:" | awk {'print $2'} | base64 -d)
if [ "$?" -ne "0" ]
then
echo "Failed to get token for service account k4e-scale-test"
exit 1
fi
cp $test_plan $test_dir
cp ${test_plan}.html $test_dir
JVM_ARGS="-Xms4g -Xmx64g -Xss250k -XX:MaxMetaspaceSize=1g" ./bin/jmeter.sh -n -t $test_plan -l $test_dir/results.csv -f -e -o $test_dir/results/ -JK8S_BEARER_TOKEN=$K8S_BEARER_TOKEN -JEDGE_DEVICES_COUNT=$2 -JRAMP_UP_TIME=$3 -JITERATIONS=$4 |& tee -a $test_dir/run.out
cd -
edgedevices=$(oc get edgedevices | wc -l)
edgedeploy=$(oc get edgedeployments | wc -l)
echo "After test: There are $edgedevices edge devices and $edgedeploy edge deployments" >> $test_dir/run.out
oc logs -n k4e-operator-system $(oc get pod -n k4e-operator-system -o name) -c manager > $test_dir/k4e-operator.log
kubectl get edgedevice -o=custom-columns=NAME:.metadata.name --no-headers | xargs kubectl patch edgedevice -p '{"metadata":{"finalizers":null}}' --type=merge
kubectl get edgedeployment -o=custom-columns=NAME:.metadata.name --no-headers | xargs kubectl patch edgedeployment -p '{"metadata":{"finalizers":null}}' --type=merge
oc delete edgedevice --all
oc delete edgedeployments --all
oc delete obc --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment