summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2019-11-07 16:17:11 +0100
committerRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2019-11-15 12:24:00 +0100
commitbcbb80b41a63f2181d56cec2a18db97e28dec184 (patch)
treef0e95a8b673355b3abc01057d873d9153e7afe8f /tools
parent4f24529aef0b32ed7e3a721b805fa5de20b82d3d (diff)
Improve performance test environment rebooting script
Issue-ID: DCAEGEN2-1883 Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com> Change-Id: I841ee6326467d495dc40686bca0f22800cb4ac61
Diffstat (limited to 'tools')
-rwxr-xr-xtools/performance/cloud/reboot-test-environment.sh81
1 files changed, 57 insertions, 24 deletions
diff --git a/tools/performance/cloud/reboot-test-environment.sh b/tools/performance/cloud/reboot-test-environment.sh
index 853df148..5f13cb25 100755
--- a/tools/performance/cloud/reboot-test-environment.sh
+++ b/tools/performance/cloud/reboot-test-environment.sh
@@ -24,42 +24,62 @@ HV_VES_IMAGE="nexus3.dyn.nesc.nokia.net:10001/onap/org.onap.dcaegen2.collectors.
KAFKA_ROUTER_0_POD_NAME=$(kubectl -n ${ONAP_NAMESPACE} get pods --no-headers=true -o custom-columns=:metadata.name | grep router-kafka-0)
KAFKA_TOPIC_RESET_CMD='kafka-topics.sh --delete --zookeeper message-router-zookeeper:2181 --topic HV_VES_PERF3GPP'
HIDE_OUTPUT='grep abc | grep 123'
+YELLOW=$(tput setaf 3)
+GREEN=$(tput setaf 2)
+CYAN=$(tput setaf 6)
+NO_COLOR=$(tput sgr0)
+VERBOSE="false"
+
+function formatOutput(){
+ read line
+ echo "${YELLOW}$line${NO_COLOR}"
+ while read line; do
+ if [ ${VERBOSE} == "true" ]; then
+ echo " $line"
+ fi
+ done
+}
function usage() {
echo ""
- echo "Reebot test environment for performance tests"
- echo "Usage $0 reboot|help"
- echo " reboot: reboots the test environment"
- echo " help : print usage"
+ echo "Reboot test environment for performance tests"
+ echo "Usage $0"
+ echo " -v --verbose : reboot the test environment verbosely"
+ echo " help : print usage"
echo "Example invocation:"
- echo "./reboot-test-environment.sh reboot"
+ echo "./reboot-test-environment.sh"
+ echo "./reboot-test-environment.sh --verbose"
echo ""
}
function rebootEnvironment(){
- ./cloud-based-performance-test.sh clean
+ echo "${CYAN}Rebooting test environment${NO_COLOR}"
- redeployPod
+ ./cloud-based-performance-test.sh clean | formatOutput
- waitForPodRedeployment
+ redeployPod | formatOutput
- echo "Updating HV-VES image"
- kubectl patch pod ${HVVES_POD_NAME} -n ${ONAP_NAMESPACE} --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"'${HV_VES_IMAGE}'"}]'
+ deleteKafkaTopic | formatOutput
- echo "Deleting Kafka topic"
- kubectl exec -it ${KAFKA_ROUTER_0_POD_NAME} -n ${ONAP_NAMESPACE} -- ${KAFKA_TOPIC_RESET_CMD} | eval $HIDE_OUTPUT
+ ./cloud-based-performance-test.sh setup | formatOutput
- waitForHvVesRunning
+ echo "${GREEN}Environment ready!${NO_COLOR}"
- ./cloud-based-performance-test.sh setup
}
function redeployPod(){
+ echo "Redeploying pod"
kubectl scale --replicas=0 deploy ${HVVES_CONTAINER_NAME} -n ${ONAP_NAMESPACE}
waitForPodTermination
kubectl scale --replicas=1 deploy ${HVVES_CONTAINER_NAME} -n ${ONAP_NAMESPACE}
sleep 10s
+
+ waitForPodRedeployment
+
+ updateHvVesImage
+
+ waitForHvVesRunning
}
function waitForPodTermination(){
@@ -69,6 +89,18 @@ function waitForPodTermination(){
HVVES_POD_NAME=$(kubectl -n ${ONAP_NAMESPACE} get pods --no-headers=true -o custom-columns=:metadata.name | grep hv-ves-collector)
sleep 1s
done
+
+ echo "Pod terminated"
+}
+
+function updateHvVesImage() {
+ echo "Updating HV-VES image"
+ kubectl patch pod ${HVVES_POD_NAME} -n ${ONAP_NAMESPACE} --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"'${HV_VES_IMAGE}'"}]'
+}
+
+function deleteKafkaTopic() {
+ echo "Deleting Kafka topic"
+ kubectl exec -it ${KAFKA_ROUTER_0_POD_NAME} -n ${ONAP_NAMESPACE} -- ${KAFKA_TOPIC_RESET_CMD} | eval $HIDE_OUTPUT
}
function waitForPodRedeployment(){
@@ -96,21 +128,22 @@ function loadHvVesPodName(){
if [[ $# -eq 0 ]]; then
- usage
+ rebootEnvironment
else
- for arg in ${@}
+ for arg
do
case ${arg} in
- reboot)
- rebootEnvironment
- ;;
+ --verbose|-v)
+ VERBOSE=true
+ rebootEnvironment
+ ;;
help)
- usage
- ;;
+ usage
+ ;;
*)
- echo "Unknown action: ${arg}" >&2
- usage
- ;;
+ echo "Unknown action: ${arg}" >&2
+ usage
+ ;;
esac
done
fi \ No newline at end of file