Skip to content

Commit 996e700

Browse files
authored
Adding Performance test script (#289)
* Adding Performance test script Signed-off-by: James Busche <jbusche@us.ibm.com> * red hat image and more checking Signed-off-by: James Busche <jbusche@us.ibm.com> * Check for mcad install Signed-off-by: James Busche <jbusche@us.ibm.com> * remove oc and formatting Signed-off-by: James Busche <jbusche@us.ibm.com> * fix to run from any namespace Signed-off-by: James Busche <jbusche@us.ibm.com> --------- Signed-off-by: James Busche <jbusche@us.ibm.com>
1 parent 301e8f8 commit 996e700

File tree

3 files changed

+204
-0
lines changed

3 files changed

+204
-0
lines changed

test/perf-test/cleanup.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
for i in `kubectl get appwrapper -n default |grep defaultaw | awk '{print $1}'`; do kubectl delete appwrapper $i -n default ; done

test/perf-test/perf.sh

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/bin/bash
2+
3+
SCRIPT_DIR=$(readlink -f `dirname "${BASH_SOURCE[0]}"`)
4+
5+
function help() {
6+
echo "usage: perf.sh [-h]"
7+
echo
8+
echo "Description: Runs Appwrapper performance test script(s) in subdirectories under $SCRIPT_DIR."
9+
echo
10+
echo "Preconditions: "
11+
echo " - The script assumes you've logged into your cluster already. If not, it will tell you to login."
12+
echo " - The script checks that you have the mcad-controller installed, otherwise it'll tell you to install it first."
13+
echo
14+
echo "Options:"
15+
echo " -h Print this help message"
16+
echo
17+
}
18+
19+
function check_kubectl_login_status() {
20+
set +e
21+
kubectl get ns default &> /dev/null
22+
res="$?"
23+
set -e
24+
OCP="$res"
25+
if [ $OCP == 1 ]
26+
then
27+
echo "You need to login to your Kubernetes Cluster"
28+
exit 1
29+
else
30+
echo
31+
echo "Nice, looks like you're logged in"
32+
fi
33+
}
34+
35+
function check_mcad_installed_status() {
36+
set +e
37+
kubectl get pod -A |grep mcad-controller &> /dev/null
38+
res2="$?"
39+
kubectl get crd |grep appwrapper &> /dev/null
40+
res3="$?"
41+
set -e
42+
MCAD="$res2"
43+
CRD="$res3"
44+
if [[ $MCAD == 1 ]] || [[ $CRD == 1 ]]
45+
then
46+
echo "You need Install MCAD Controller first before running this script"
47+
exit 1
48+
else
49+
echo "Nice, MCAD Controller is installed"
50+
fi
51+
}
52+
53+
54+
while getopts hf: option; do
55+
case $option in
56+
h)
57+
help
58+
exit 0
59+
;;
60+
*)
61+
;;
62+
esac
63+
done
64+
shift $((OPTIND-1))
65+
66+
# Track whether we have a valid kubectl login
67+
echo "Checking whether we have a valid cluster login or not..."
68+
check_kubectl_login_status
69+
70+
# Track whether you have the MCAD controller installed
71+
echo "Checking MCAD Controller installation status"
72+
echo
73+
check_mcad_installed_status
74+
75+
echo
76+
read -p "How many appwrapper jobs do you want?" jobs
77+
78+
# Start the timer now
79+
SECONDS=0
80+
81+
echo "jobs number is $jobs"
82+
export STARTTIME=`date +"%T"`
83+
echo " "
84+
echo "Jobs started at: $STARTTIME" |tee job-$STARTTIME.log
85+
echo " "
86+
87+
# This fixes the number of jobs to be one less so the for loop gets the right amount
88+
((realjobs=$jobs-1))
89+
90+
for num in $(eval echo "{0.."$realjobs"}")
91+
do
92+
next_num=$(($num + 1))
93+
echo "Submitting job $next_num"
94+
# Had to do this OSTYPE because sed acts differently on Linux versus Mac
95+
case "$OSTYPE" in
96+
linux-gnu*)
97+
sed -i "s/defaultaw-schd-spec-with-timeout-$num/defaultaw-schd-spec-with-timeout-$next_num/g" ${SCRIPT_DIR}/preempt-exp.yaml ;;
98+
darwin*)
99+
sed -i '' "s/defaultaw-schd-spec-with-timeout-$num/defaultaw-schd-spec-with-timeout-$next_num/g" ${SCRIPT_DIR}/preempt-exp.yaml ;;
100+
*)
101+
sed -i "s/defaultaw-schd-spec-with-timeout-$num/defaultaw-schd-spec-with-timeout-$next_num/g" ${SCRIPT_DIR}/preempt-exp.yaml ;;
102+
esac
103+
kubectl apply -f ${SCRIPT_DIR}/preempt-exp.yaml
104+
done
105+
106+
# Let's reset the original preempt-exp.yaml file back to original value
107+
case "$OSTYPE" in
108+
linux-gnu*)
109+
sed -i "s/defaultaw-schd-spec-with-timeout-$next_num/defaultaw-schd-spec-with-timeout-1/g" ${SCRIPT_DIR}/preempt-exp.yaml ;;
110+
darwin*)
111+
sed -i '' "s/defaultaw-schd-spec-with-timeout-$next_num/defaultaw-schd-spec-with-timeout-1/g" ${SCRIPT_DIR}/preempt-exp.yaml ;;
112+
*)
113+
sed -i "s/defaultaw-schd-spec-with-timeout-$next_num/defaultaw-schd-spec-with-timeout-1/g" ${SCRIPT_DIR}/preempt-exp.yaml ;;
114+
esac
115+
116+
# Check for all jobs to report complete
117+
jobstatus=`kubectl get jobs -n default --no-headers --field-selector status.successful=1 |wc -l`
118+
119+
while [ $jobstatus -lt $jobs ]
120+
do
121+
echo "Number of completed jobs is: " $jobstatus " and the goal is: " $jobs
122+
sleep 10
123+
jobstatus=`kubectl get jobs -n default --no-headers --field-selector status.successful=1 |wc -l`
124+
done
125+
126+
echo " "
127+
export FINISHTIME=`date +"%T"`
128+
echo "All $jobstatus jobs finished: $FINISHTIME" |tee -a job-$STARTTIME.log
129+
echo "Total amount of time for $jobs appwrappers is: $SECONDS seconds" |tee -a ${SCRIPT_DIR}/job-$STARTTIME.log
130+
echo " "
131+
echo "Test results are stored in this file: ${SCRIPT_DIR}/job-$next_num-$STARTTIME.log"
132+
133+
# Rename the log to show the number of jobs used
134+
mv ${SCRIPT_DIR}/job-$STARTTIME.log ${SCRIPT_DIR}/job-$next_num-$STARTTIME.log
135+
136+
#Ask if you want to auto-cleanup the appwrapper jobs
137+
echo "Do you want to cleanup the most recently created appwrappers? [Y/n]"
138+
read DELETE
139+
if [[ $DELETE == "Y" || $DELETE == "y" ]]; then
140+
echo "OK, deleting"
141+
${SCRIPT_DIR}/cleanup.sh
142+
else
143+
echo "OK, you'll need to cleanup yourself later using ./cleanup.sh"
144+
fi

test/perf-test/preempt-exp.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
apiVersion: mcad.ibm.com/v1beta1
2+
kind: AppWrapper
3+
metadata:
4+
name: defaultaw-schd-spec-with-timeout-1
5+
namespace: default
6+
spec:
7+
schedulingSpec:
8+
minAvailable: 1
9+
requeuing:
10+
timeInSeconds: 120
11+
growthType: "exponential"
12+
priority: 9
13+
resources:
14+
Items: []
15+
GenericItems:
16+
- replicas: 1
17+
completionstatus: Complete
18+
custompodresources:
19+
- replicas: 1
20+
requests:
21+
cpu: 10m
22+
memory: 10M
23+
nvidia.com/gpu: 0
24+
limits:
25+
cpu: 500m
26+
memory: 128M
27+
nvidia.com/gpu: 0
28+
generictemplate:
29+
apiVersion: batch/v1
30+
kind: Job
31+
metadata:
32+
namespace: default
33+
name: defaultaw-schd-spec-with-timeout-1
34+
# labels:
35+
# appwrapper.mcad.ibm.com: defaultaw-schd-spec-with-timeout-1
36+
spec:
37+
parallelism: 1
38+
completions: 1
39+
template:
40+
metadata:
41+
namespace: default
42+
labels:
43+
appwrapper.mcad.ibm.com: "defaultaw-schd-spec-with-timeout-1"
44+
spec:
45+
containers:
46+
- name: defaultaw-schd-spec-with-timeout-1
47+
image: ubi8-minimal:latest
48+
command: [ "/bin/bash", "-c", "--" ]
49+
args: [ "sleep 10" ]
50+
resources:
51+
requests:
52+
memory: "10Mi"
53+
cpu: "10m"
54+
limits:
55+
memory: "128Mi"
56+
cpu: "500m"
57+
restartPolicy: Never

0 commit comments

Comments
 (0)