Skip to content
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

Improve shell scripts - add deploy_csv script #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions deploy_csv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
#Script created to copy csv config file to jmeter slave pods
#It requires that you supply the path to the csv file and destination path in the jmeter pods

namespace="$1"

[ -n "$namespace" ] || read -p 'Enter the Jmeter Namespace: ' namespace

kubectl get namespace | grep $namespace >> /dev/null

if [ $? != 0 ];
then
echo "Namespace does not exist in the kubernetes cluster"
echo ""
echo "Below is the list of namespaces in the kubernetes cluster"

kubectl get namespaces
echo ""
echo "Please check and try again"
exit
fi

csv="$2"
[ -n "$csv" ] || read -p 'Enter path to the csv file:' csv

if [ ! -f "$csv" ];
then
echo "csv file was not found in PATH"
echo "Kindly check and input the correct file path"
exit
fi

csv_name="$(basename "$csv")"

path="$3"
[ -n "$path" ] || read -p 'Enter destination path:' path



#Get Master pod details

kubectl -n $namespace get po | grep jmeter-slave | grep Running | awk '{print $1}' | while read -r slave_pod ; do
echo "Deploying $csv_name to: $slave_pod"
kubectl -n $namespace cp "$csv" "$slave_pod:$path/$csv_name"
done



7 changes: 4 additions & 3 deletions start_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ then
exit
fi

jmx="$1"
[ -n "$jmx" ] || read -p 'Enter path to the jmx file ' jmx
jmx="$2"
[ -n "$jmx" ] || read -p 'Enter path to the jmx file:' jmx

if [ ! -f "$jmx" ];
then
Expand All @@ -33,6 +33,7 @@ fi

test_name="$(basename "$jmx")"


#Get Master pod details

master_pod=`kubectl -n $namespace get po | grep jmeter-master | awk '{print $1}'`
Expand All @@ -41,4 +42,4 @@ kubectl -n $namespace cp "$jmx" "$master_pod:/$test_name"

## Echo Starting Jmeter load test

kubectl -n $namespace exec -ti $master_pod -- /bin/bash /load_test "$test_name"
kubectl -n $namespace exec -ti $master_pod -- /bin/bash /load_test "$test_name"