-
Notifications
You must be signed in to change notification settings - Fork 64
Adding Performance test script #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
for i in `kubectl get appwrapper -n default |grep defaultaw | awk '{print $1}'`; do kubectl delete appwrapper $i -n default ; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
#!/bin/bash | ||
jbusche marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
jbusche marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SCRIPT_DIR=$(readlink -f `dirname "${BASH_SOURCE[0]}"`) | ||
|
||
function help() { | ||
echo "usage: perf.sh [-h]" | ||
echo | ||
echo "Description: Runs Appwrapper performance test script(s) in subdirectories under $SCRIPT_DIR." | ||
echo | ||
echo "Preconditions: " | ||
echo " - The script assumes you've logged into your cluster already. If not, it will tell you to login." | ||
echo " - The script checks that you have the mcad-controller installed, otherwise it'll tell you to install it first." | ||
echo | ||
echo "Options:" | ||
echo " -h Print this help message" | ||
echo | ||
} | ||
|
||
function check_kubectl_login_status() { | ||
set +e | ||
kubectl get ns default &> /dev/null | ||
res="$?" | ||
set -e | ||
OCP="$res" | ||
if [ $OCP == 1 ] | ||
then | ||
echo "You need to login to your Kubernetes Cluster" | ||
exit 1 | ||
else | ||
echo | ||
echo "Nice, looks like you're logged in" | ||
fi | ||
} | ||
|
||
function check_mcad_installed_status() { | ||
set +e | ||
kubectl get pod -A |grep mcad-controller &> /dev/null | ||
res2="$?" | ||
kubectl get crd |grep appwrapper &> /dev/null | ||
res3="$?" | ||
set -e | ||
MCAD="$res2" | ||
CRD="$res3" | ||
if [[ $MCAD == 1 ]] || [[ $CRD == 1 ]] | ||
then | ||
echo "You need Install MCAD Controller first before running this script" | ||
exit 1 | ||
else | ||
echo "Nice, MCAD Controller is installed" | ||
fi | ||
} | ||
|
||
|
||
while getopts hf: option; do | ||
case $option in | ||
h) | ||
help | ||
exit 0 | ||
;; | ||
*) | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND-1)) | ||
|
||
# Track whether we have a valid kubectl login | ||
echo "Checking whether we have a valid cluster login or not..." | ||
check_kubectl_login_status | ||
|
||
# Track whether you have the MCAD controller installed | ||
echo "Checking MCAD Controller installation status" | ||
echo | ||
check_mcad_installed_status | ||
|
||
echo | ||
read -p "How many appwrapper jobs do you want?" jobs | ||
|
||
# Start the timer now | ||
SECONDS=0 | ||
|
||
echo "jobs number is $jobs" | ||
export STARTTIME=`date +"%T"` | ||
echo " " | ||
echo "Jobs started at: $STARTTIME" |tee job-$STARTTIME.log | ||
echo " " | ||
|
||
# This fixes the number of jobs to be one less so the for loop gets the right amount | ||
((realjobs=$jobs-1)) | ||
|
||
for num in $(eval echo "{0.."$realjobs"}") | ||
do | ||
next_num=$(($num + 1)) | ||
echo "Submitting job $next_num" | ||
# Had to do this OSTYPE because sed acts differently on Linux versus Mac | ||
case "$OSTYPE" in | ||
linux-gnu*) | ||
sed -i "s/defaultaw-schd-spec-with-timeout-$num/defaultaw-schd-spec-with-timeout-$next_num/g" ${SCRIPT_DIR}/preempt-exp.yaml ;; | ||
darwin*) | ||
sed -i '' "s/defaultaw-schd-spec-with-timeout-$num/defaultaw-schd-spec-with-timeout-$next_num/g" ${SCRIPT_DIR}/preempt-exp.yaml ;; | ||
*) | ||
sed -i "s/defaultaw-schd-spec-with-timeout-$num/defaultaw-schd-spec-with-timeout-$next_num/g" ${SCRIPT_DIR}/preempt-exp.yaml ;; | ||
esac | ||
kubectl apply -f ${SCRIPT_DIR}/preempt-exp.yaml | ||
done | ||
|
||
# Let's reset the original preempt-exp.yaml file back to original value | ||
case "$OSTYPE" in | ||
linux-gnu*) | ||
sed -i "s/defaultaw-schd-spec-with-timeout-$next_num/defaultaw-schd-spec-with-timeout-1/g" ${SCRIPT_DIR}/preempt-exp.yaml ;; | ||
darwin*) | ||
sed -i '' "s/defaultaw-schd-spec-with-timeout-$next_num/defaultaw-schd-spec-with-timeout-1/g" ${SCRIPT_DIR}/preempt-exp.yaml ;; | ||
*) | ||
sed -i "s/defaultaw-schd-spec-with-timeout-$next_num/defaultaw-schd-spec-with-timeout-1/g" ${SCRIPT_DIR}/preempt-exp.yaml ;; | ||
esac | ||
|
||
# Check for all jobs to report complete | ||
jobstatus=`kubectl get jobs -n default --no-headers --field-selector status.successful=1 |wc -l` | ||
|
||
while [ $jobstatus -lt $jobs ] | ||
do | ||
echo "Number of completed jobs is: " $jobstatus " and the goal is: " $jobs | ||
sleep 10 | ||
jobstatus=`kubectl get jobs -n default --no-headers --field-selector status.successful=1 |wc -l` | ||
done | ||
|
||
echo " " | ||
export FINISHTIME=`date +"%T"` | ||
echo "All $jobstatus jobs finished: $FINISHTIME" |tee -a job-$STARTTIME.log | ||
echo "Total amount of time for $jobs appwrappers is: $SECONDS seconds" |tee -a ${SCRIPT_DIR}/job-$STARTTIME.log | ||
echo " " | ||
echo "Test results are stored in this file: ${SCRIPT_DIR}/job-$next_num-$STARTTIME.log" | ||
|
||
# Rename the log to show the number of jobs used | ||
mv ${SCRIPT_DIR}/job-$STARTTIME.log ${SCRIPT_DIR}/job-$next_num-$STARTTIME.log | ||
|
||
#Ask if you want to auto-cleanup the appwrapper jobs | ||
echo "Do you want to cleanup the most recently created appwrappers? [Y/n]" | ||
read DELETE | ||
if [[ $DELETE == "Y" || $DELETE == "y" ]]; then | ||
echo "OK, deleting" | ||
${SCRIPT_DIR}/cleanup.sh | ||
else | ||
echo "OK, you'll need to cleanup yourself later using ./cleanup.sh" | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
apiVersion: mcad.ibm.com/v1beta1 | ||
kind: AppWrapper | ||
metadata: | ||
name: defaultaw-schd-spec-with-timeout-1 | ||
namespace: default | ||
spec: | ||
schedulingSpec: | ||
minAvailable: 1 | ||
requeuing: | ||
timeInSeconds: 120 | ||
growthType: "exponential" | ||
priority: 9 | ||
resources: | ||
Items: [] | ||
GenericItems: | ||
- replicas: 1 | ||
completionstatus: Complete | ||
custompodresources: | ||
- replicas: 1 | ||
requests: | ||
cpu: 10m | ||
memory: 10M | ||
nvidia.com/gpu: 0 | ||
limits: | ||
cpu: 500m | ||
memory: 128M | ||
nvidia.com/gpu: 0 | ||
generictemplate: | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
namespace: default | ||
name: defaultaw-schd-spec-with-timeout-1 | ||
# labels: | ||
# appwrapper.mcad.ibm.com: defaultaw-schd-spec-with-timeout-1 | ||
spec: | ||
parallelism: 1 | ||
completions: 1 | ||
template: | ||
metadata: | ||
namespace: default | ||
labels: | ||
appwrapper.mcad.ibm.com: "defaultaw-schd-spec-with-timeout-1" | ||
spec: | ||
containers: | ||
- name: defaultaw-schd-spec-with-timeout-1 | ||
image: ubi8-minimal:latest | ||
command: [ "/bin/bash", "-c", "--" ] | ||
args: [ "sleep 10" ] | ||
resources: | ||
requests: | ||
memory: "10Mi" | ||
cpu: "10m" | ||
limits: | ||
memory: "128Mi" | ||
cpu: "500m" | ||
restartPolicy: Never |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.