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=========================================================
20 SCRIPT_DIRECTORY="$(pwd "$0")"
21 CERT_FILE=${CERT_FILE:-/ssl/client.p12}
22 CERT_PASS_FILE=${CERT_PASS_FILE:-/ssl/client.pass}
23 HV_VES_NETWORK=${HV_VES_NETWORK:-local_default}
24 VOLUME_MAPPING=${VOLUME_MAPPING:-$SCRIPT_DIRECTORY/../../ssl/:/ssl}
25 PRODUCER_IMAGE_NAME=${PRODUCER_IMAGE_NAME:-the-a-team-registry-local.esisoj70.emea.nsn-net.net/onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-go-client:latest}
27 PRODUCER_APP_NAME=hv-ves-producer
28 HV_VES_ADDRESS=ves-hv-collector:6061
30 CLIENTS_PER_CONTAINER=1
37 echo "Run HV-VES performance test locally"
38 echo "Usage $0 setup|start|clean|help"
39 echo " setup : generate certs and set up docker components"
40 echo " start : run the performance test"
41 echo " Optional parameters:"
42 echo " --address : HV-VES address in host:port format (ves-hv-collector:6061)"
43 echo " --containers : number of docker containers to create (1)"
44 echo " --clients : number of clients in a single container (1)"
45 echo " --msg-size : size in bytes of a single message (16384)"
46 echo " --msg-count : amount of messages to sent by one client in single container (1000)"
47 echo " --interval : interval between messages (0)"
48 echo " clean : remove generated certs, HV-VES components and producers"
49 echo " help : print usage"
50 echo "Example invocations:"
51 echo "./local-performance-test.sh setup"
52 echo "./local-performance-test.sh start --containers 10 --clients 100 --msg-count 10000"
53 echo "./local-performance-test.sh clean"
57 function setup_environment(){
61 cd "$SCRIPT_DIRECTORY"
64 echo "Waiting for components to be healthy.."
65 while [[ $(docker-compose ps | grep -c "unhealthy\|starting") -ne 0 ]] ; do
69 echo "All components ready"
73 function start_performance_test(){
76 create_containers ${CONTAINERS_COUNT} ${TEST_ID} &
79 ACTIVE_PRODUCERS=$(docker ps --format "table {{.ID}}\t{{.Status}}" -f "label=id=$TEST_ID")
80 ACTIVE_PRODUCERS_COUNT=$(echo "$ACTIVE_PRODUCERS" | grep -c "Up")
83 print_test_configuration
84 echo "Active producers ($ACTIVE_PRODUCERS_COUNT/$CONTAINERS_COUNT):"
85 echo "$ACTIVE_PRODUCERS"
87 EXITED_CONTAINERS=$(docker ps -aq -f "label=id=$TEST_ID" -f status=exited | wc -l)
88 [[ ${EXITED_CONTAINERS} -eq ${CONTAINERS_COUNT} ]] && break
94 print_test_configuration
96 # TODO put test result here
100 function print_test_configuration(){
101 echo "PERFORMANCE TEST IN PROGRESS"
103 echo "Test configuration:"
104 echo "Containers count: $CONTAINERS_COUNT"
105 echo "Clients per container: $CLIENTS_PER_CONTAINER"
106 echo "Message size: $MSG_SIZE"
107 echo "Messages per client: $MSG_COUNT"
108 echo "Interval: $INTERVAL_MS"
112 function create_containers(){
114 for i in $(seq 1 ${1}); do
115 docker run -d -l id="$2" -l app="$PRODUCER_APP_NAME" -v "$VOLUME_MAPPING" --network="$HV_VES_NETWORK" "$PRODUCER_IMAGE_NAME" \
116 --address "$HV_VES_ADDRESS" \
117 --certfile "$CERT_FILE" \
118 --certpass "$CERT_PASS_FILE" \
119 --clients "$CLIENTS_PER_CONTAINER" \
120 --msgsize "$MSG_SIZE" \
121 --msgcount "$MSG_COUNT" \
122 --intervalms "$INTERVAL_MS" > /dev/null
129 echo "Removing active producers"
130 docker rm --force $(docker ps -aqf "label=app=$PRODUCER_APP_NAME")
132 echo "Clearing generated certs"
136 cd "$SCRIPT_DIRECTORY"
138 echo "Removing HV-VES components"
143 cd "$SCRIPT_DIRECTORY"
145 if [[ $# -eq 0 ]]; then
156 while [[ $(($#)) -gt 0 ]]; do
162 CONTAINERS_COUNT=${2}
165 CLIENTS_PER_CONTAINER=${2}
179 start_performance_test
188 echo "Unknown action: ${arg}" >&2