2 # ============LICENSE_START=======================================================
3 # dcaegen2-collectors-veshv
4 # ================================================================================
5 # Copyright (C) 2019 NOKIA
6 # ================================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END=========================================================
21 HVVES_POD_NAME=$(kubectl -n ${ONAP_NAMESPACE} get pods --no-headers=true -o custom-columns=:metadata.name | grep hv-ves-collector)
22 HVVES_CONTAINER_NAME=dep-dcae-hv-ves-collector
23 HV_VES_IMAGE="nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-main:latest"
24 KAFKA_ROUTER_0_POD_NAME=$(kubectl -n ${ONAP_NAMESPACE} get pods --no-headers=true -o custom-columns=:metadata.name | grep router-kafka-0)
25 KAFKA_TOPIC_RESET_CMD='kafka-topics --delete --zookeeper message-router-zookeeper:2181 --topic HV_VES_PERF3GPP'
26 HIDE_OUTPUT='grep abc | grep 123'
27 YELLOW=$(tput setaf 3)
33 function formatOutput(){
35 echo "${YELLOW}$line${NO_COLOR}"
37 if [ ${VERBOSE} == "true" ]; then
45 echo "Reboot test environment for performance tests"
47 echo " -v --verbose : reboot the test environment verbosely"
48 echo " help : print usage"
49 echo "Example invocation:"
50 echo "./reboot-test-environment.sh"
51 echo "./reboot-test-environment.sh --verbose"
55 function rebootEnvironment(){
56 echo "${CYAN}Rebooting test environment${NO_COLOR}"
58 ./cloud-based-performance-test.sh clean | formatOutput
60 redeployPod | formatOutput
62 deleteKafkaTopic | formatOutput
64 ./cloud-based-performance-test.sh setup | formatOutput
66 ./cloud-based-performance-test.sh stop | formatOutput
68 ./cloud-based-performance-test.sh reset_producers | formatOutput
70 echo "${GREEN}Environment ready!${NO_COLOR}"
75 function redeployPod(){
76 echo "Redeploying pod"
77 kubectl scale --replicas=0 deploy ${HVVES_CONTAINER_NAME} -n ${ONAP_NAMESPACE}
79 kubectl scale --replicas=1 deploy ${HVVES_CONTAINER_NAME} -n ${ONAP_NAMESPACE}
82 waitForPodRedeployment
89 function waitForPodTermination(){
90 echo "Waiting for pod termination..."
92 while [ "${HVVES_POD_NAME}" != "" ] ; do
93 HVVES_POD_NAME=$(kubectl -n ${ONAP_NAMESPACE} get pods --no-headers=true -o custom-columns=:metadata.name | grep hv-ves-collector)
100 function updateHvVesImage() {
101 echo "Updating HV-VES image"
102 kubectl patch pod ${HVVES_POD_NAME} -n ${ONAP_NAMESPACE} --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"'${HV_VES_IMAGE}'"}]'
105 function deleteKafkaTopic() {
106 echo "Deleting Kafka topic"
107 kubectl exec -it ${KAFKA_ROUTER_0_POD_NAME} -n ${ONAP_NAMESPACE} -- ${KAFKA_TOPIC_RESET_CMD} | eval $HIDE_OUTPUT
110 function waitForPodRedeployment(){
112 echo "Waiting for pod redeploy..."
114 while [ "${HVVES_POD_NAME}" = "" ] ; do
115 HVVES_POD_NAME=$(kubectl -n ${ONAP_NAMESPACE} get pods --no-headers=true -o custom-columns=:metadata.name | grep hv-ves-collector)
120 function waitForHvVesRunning(){
121 echo "Waiting for HV-VES running..."
123 while [ "${POD_STATUS}" != "2/2" ]; do
124 POD_STATUS=$(kubectl get pod ${HVVES_POD_NAME} -n ${ONAP_NAMESPACE} --no-headers=true | awk '{print $2}')
129 function loadHvVesPodName(){
130 HVVES_POD_NAME=$(kubectl -n ${ONAP_NAMESPACE} get pods --no-headers=true -o custom-columns=:metadata.name | grep hv-ves-collector)
134 if [[ $# -eq 0 ]]; then
148 echo "Unknown action: ${arg}" >&2