diff options
Diffstat (limited to 'development')
-rwxr-xr-x | development/bin/constants.sh | 22 | ||||
-rwxr-xr-x | development/bin/dcae-msgs.sh | 5 | ||||
-rwxr-xr-x | development/bin/dcae-reset.sh | 7 | ||||
-rwxr-xr-x | development/bin/dcae-topic.sh | 7 | ||||
-rwxr-xr-x | development/bin/run-xnf-simulator.sh | 39 | ||||
-rwxr-xr-x | development/bin/start-simulation.sh | 66 | ||||
-rw-r--r-- | development/docker-compose.yml | 16 |
7 files changed, 124 insertions, 38 deletions
diff --git a/development/bin/constants.sh b/development/bin/constants.sh new file mode 100755 index 00000000..f0df9b00 --- /dev/null +++ b/development/bin/constants.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# ============LICENSE_START======================================================= +# dcaegen2-collectors-veshv +# ================================================================================ +# Copyright (C) 2019 NOKIA +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= + +DCAE_APP_HOSTNAME=localhost +DCAE_APP_PORT=6064 +DCAE_APP_ADDRESS=${DCAE_APP_HOSTNAME}:${DCAE_APP_PORT}
\ No newline at end of file diff --git a/development/bin/dcae-msgs.sh b/development/bin/dcae-msgs.sh index cb05a8c3..964be14f 100755 --- a/development/bin/dcae-msgs.sh +++ b/development/bin/dcae-msgs.sh @@ -56,9 +56,12 @@ while getopts "$optspec" arg; do done shift $((OPTIND-1)) +DEVELOPMENT_BIN_DIRECTORY=$(realpath $(dirname "$0")) +source ${DEVELOPMENT_BIN_DIRECTORY}/constants.sh + if [ -n "${VERBOSE+x}" ]; then echo "All messages count currently consumed by dcae app simulator: " fi -curl --request GET localhost:6063/messages/all/count +curl --request GET ${DCAE_APP_ADDRESS}/messages/all/count echo diff --git a/development/bin/dcae-reset.sh b/development/bin/dcae-reset.sh index e5b7b056..03baf97a 100755 --- a/development/bin/dcae-reset.sh +++ b/development/bin/dcae-reset.sh @@ -57,9 +57,12 @@ while getopts "$optspec" arg; do done shift $((OPTIND-1)) +DEVELOPMENT_BIN_DIRECTORY=$(realpath $(dirname "$0")) +source ${DEVELOPMENT_BIN_DIRECTORY}/constants.sh + if [ -n "${VERBOSE+x}" ]; then - echo "Requesting DCAE app running on port 6063 to reset messages count" + echo "Requesting DCAE app running on port ${DCAE_APP_PORT} to reset messages count" fi -curl --request DELETE localhost:6063/messages +curl --request DELETE ${DCAE_APP_ADDRESS}/messages echo diff --git a/development/bin/dcae-topic.sh b/development/bin/dcae-topic.sh index 8c176221..aefb1d0b 100755 --- a/development/bin/dcae-topic.sh +++ b/development/bin/dcae-topic.sh @@ -56,11 +56,14 @@ while getopts "$optspec" arg; do done shift $((OPTIND-1)) +DEVELOPMENT_BIN_DIRECTORY=$(realpath $(dirname "$0")) +source ${DEVELOPMENT_BIN_DIRECTORY}/constants.sh + TOPIC=${1:-HV_VES_PERF3GPP} if [ -n "${VERBOSE+x}" ]; then - echo "Requesting DCAE app running on port 6063 to consume messages from topic: ${TOPIC}" + echo "Requesting DCAE app running on ${DCAE_APP_ADDRESS} to consume messages from topic: ${TOPIC}" fi -curl --request PUT localhost:6063/configuration/topics -d ${TOPIC} +curl --request PUT ${DCAE_APP_ADDRESS}/configuration/topics -d ${TOPIC} echo
\ No newline at end of file diff --git a/development/bin/run-xnf-simulator.sh b/development/bin/run-xnf-simulator.sh index d8de0097..e4d8d94a 100755 --- a/development/bin/run-xnf-simulator.sh +++ b/development/bin/run-xnf-simulator.sh @@ -21,7 +21,13 @@ set -euo pipefail usage() { echo "Start xnf-simulator container on given port and inside of given docker-network" - echo "Usage: $0 [-h|--help] [-v|--verbose] <xnf listen port> [<hv ves docker network>]" + echo "Usage: $0 [-h|--help] [-v|--verbose] [--ssl-disable] <xnf listen port> [<hv ves hostname> <hv ves port> <hv ves docker network>]" + echo "" + echo "Optional parameters:" + echo " - ssl-disable : Should xNF simulator be configured without using SSL/TLS connections" + echo "Default values:" + echo " - hv ves hostname: ves-hv-collector" + echo " - hv ves port: 6061" exit 1 } @@ -32,6 +38,8 @@ while getopts "$optspec" arg; do case "${OPTARG}" in verbose) VERBOSE=True ;; + ssl-disable) + SSL_DISABLE=True ;; help) usage ;; *) @@ -53,27 +61,42 @@ shift $((OPTIND-1)) LISTEN_PORT=$1 -if [ $# -gt 1 ]; then - HV_VES_NETWORK=${2} +HV_VES_HOSTNAME=${2:-ves-hv-collector} +HV_VES_PORT=${3:-6061} +if [ $# -gt 3 ]; then + HV_VES_NETWORK=${4} fi PORTS="${LISTEN_PORT}:${LISTEN_PORT}/tcp" HV_VES_REPO_HOME=$(realpath $(dirname "$0"))/.. +if [ -n "${SSL_DISABLE+x}" ]; then + SSL_CONFIGURATION="--ssl-disable" +else + SSL_CONFIGURATION="--key-store-password onaponap --trust-store-password onaponap" +fi + if [ -n "${VERBOSE+x}" ]; then - echo "Starting xnf-simulator with ports configuration: ${PORTS}" + echo "Starting xnf-simulator with " + echo " - ports configuration: ${PORTS}" + echo " - SSL configuration: ${SSL_CONFIGURATION}" echo "Container id:" fi + XNF_CONTAINER_ID=$(docker run -d \ -v ${HV_VES_REPO_HOME}/ssl/:/etc/ves-hv/ \ + --health-cmd='curl -s -f http://localhost:6063/health/ready || exit 1' \ + --health-interval=5s \ + --health-retries=3 \ + --health-start-period='10s' \ -p ${PORTS} \ onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-xnf-simulator \ --listen-port ${LISTEN_PORT} \ - --ves-host ves-hv-collector \ - --ves-port 6061 \ - --key-store-password onaponap \ - --trust-store-password onaponap) + --health-check-api-port 6063 \ + --ves-host ${HV_VES_HOSTNAME} \ + --ves-port ${HV_VES_PORT} \ + ${SSL_CONFIGURATION}) echo $XNF_CONTAINER_ID diff --git a/development/bin/start-simulation.sh b/development/bin/start-simulation.sh index beede920..8c63ddbb 100755 --- a/development/bin/start-simulation.sh +++ b/development/bin/start-simulation.sh @@ -23,21 +23,25 @@ set -euo pipefail function usage() { echo "" echo "Send messages to hv-ves from multiple xNF simulators" - echo "Usage: $0 [-h|--help] [-v|--verbose] [--messages-in-batch] [--docker-network] [--xnf-logs-directory]" + echo "Usage: $0 [-h|--help] [-v|--verbose] [--ssl-disable]" + echo " [--messages-in-batch=ARG] [--docker-network=ARG] [--xnf-logs-directory=ARG]" echo " <hv ves hostname> <hv ves port> <simulators amount> <messages batches amount per simulator> <messages sending interval>" echo "" echo " - hv ves hostname : HighVolume VES Collector network hostname" echo " - hv ves port : HighVolume VES Collector network port" echo " - simulators amount : Amount of xNF simulators to be launched" - echo " - messages amount per simulator : Amount of messages to be sent from each xNF simulator to HV-VES" - echo " - messages sending interval : interval in seconds between sending messages from xNFs" + echo " - messages batches amount per simulator : Amount of batches of messages to be sent from each xNF simulator to HV-VES" + echo " - messages sending interval : interval in seconds between sending batches of messages from xNFs" echo "Optional parameters:" + echo " - ssl-disable : Should xNF simulator be configured without using SSL/TLS connections" echo " - messages-in-batch : Amount of messages sent on each request" echo " - docker-network : Docker network to which xNF simulators should be added" echo " - xnf-logs-directory : Path to directory where logs from all xNF simulators should be stored" echo "Example invocations:" echo "./start-simulation.sh --messages-in-batch=5 --docker-network=development_default ves-hv-collector 6061 10 20 0.5" echo "./start-simulation.sh --messages-in-batch=5 --xnf-logs-directory=/tmp/xnf-simulation localhost 6061 10 20 0.5" + echo "Invocation with remote HV-VES host (Kubernetes slave IP given with default K8S NodePort for HV-VES service):" + echo "./start-simulation.sh --ssl-disable --xnf-logs-directory=/tmp/xnf-simulation 10.183.36.78 30222 5 100 5" exit 1 } @@ -56,10 +60,12 @@ function create_logs_dir() { } function create_xNFs_simulators() { + echo "Creating ${XNFS_AMOUNT} xNFs simulators" + [ -n "${SSL_DISABLE+x}" ] && verbose_log "--ssl-disable flag will be set inside containers." for i in $(seq 1 ${XNFS_AMOUNT}); do local XNF_PORT=$(get_unoccupied_port 32000 65000) verbose_log "Starting xNF simulator container on port ${XNF_PORT} using run-xnf-simulator script" - XNF_CONTAINER_ID=$(${DEVELOPMENT_BIN_DIRECTORY}/run-xnf-simulator.sh $XNF_PORT ${DOCKER_NETWORK:-}) + XNF_CONTAINER_ID=$(${DEVELOPMENT_BIN_DIRECTORY}/run-xnf-simulator.sh ${SSL_DISABLE} $XNF_PORT ${HV_VES_HOSTNAME} ${HV_VES_PORT} ${DOCKER_NETWORK:-}) CREATED_XNF_SIMULATORS_PORTS+=(${XNF_PORT}) verbose_log "Container id: ${XNF_CONTAINER_ID}" CREATED_XNF_SIMULATORS_IDS+=(${XNF_CONTAINER_ID}) @@ -80,19 +86,20 @@ function get_unoccupied_port() { } function wait_for_containers_startup_or_fail() { - local seconds_to_wait=10 + local intervals_amount=30 + local wait_interval=5 local all_containers_healthy=1 - verbose_log "Waiting ${seconds_to_wait}s for containers startup" + verbose_log "Waiting up to ${intervals_amount} times with interval of ${wait_interval}s for containers startup" set +e - for i in $(seq 1 ${seconds_to_wait}); do + for i in $(seq 1 ${intervals_amount}); do verbose_log "Try no. ${i}" all_containers_healthy=1 - for port in ${CREATED_XNF_SIMULATORS_PORTS[@]}; do - verbose_log "Checking container on port ${port}" - local status_code=$(curl -s -o /dev/null -I -w "%{http_code}" localhost:${port}/healthcheck) - if [ $status_code -ne 200 ]; then - verbose_log "Container on port ${port} is unhealthy " + for id in ${CREATED_XNF_SIMULATORS_IDS[@]}; do + verbose_log "Checking container with id ${id}" + health=$(docker inspect --format='{{json .State.Health.Status}}' ${id}) + if [ ${health} != "\"healthy\"" ]; then + verbose_log "Container ${id} is not in healthy state. Actual status: ${health}" all_containers_healthy=0 break fi @@ -100,7 +107,8 @@ function wait_for_containers_startup_or_fail() { if [ $all_containers_healthy -eq 1 ]; then break fi - sleep 1 + verbose_log "Sleeping for ${wait_interval}s" + sleep $wait_interval done set -e @@ -113,8 +121,8 @@ function wait_for_containers_startup_or_fail() { } function start_simulation() { - verbose_log "Simulation: every xNF will send ${MESSAGES_IN_BATCH} messages to hv-ves - ${MESSAGE_BATCHES_AMOUNT} times, once every ${MESSAGES_SENDING_INTERVAL}" + verbose_log "Simulation: every xNF will send ${MESSAGES_IN_BATCH} messages to hv-ves ( running on + ${HV_VES_HOSTNAME}:${HV_VES_PORT} ) ${MESSAGE_BATCHES_AMOUNT} times, once every ${MESSAGES_SENDING_INTERVAL}s" for port in ${CREATED_XNF_SIMULATORS_PORTS[@]}; do start_single_simulation $port $MESSAGES_IN_BATCH & done @@ -144,11 +152,12 @@ function wait_for_simulators_to_finish_sending_messages() { for i in $(seq 1 ${seconds_to_wait}); do verbose_log "Wait no. ${i}" all_containers_finished=1 - for port in ${CREATED_XNF_SIMULATORS_PORTS[@]}; do - local container_status=$(curl --request GET -s localhost:${port}/healthcheck | jq -r '.["Detailed status"]') + for id in ${CREATED_XNF_SIMULATORS_IDS[@]}; do + verbose_log "Checking container ${id}" + local container_status=$(docker inspect --format='{{json .State.Health.Log }}' ${id} | jq '.[-1] | .Output') - verbose_log "Container on port ${port} status: ${container_status}" - if [ "${container_status}" = "Busy" ]; then + verbose_log "Container ${id} status: ${container_status}" + if [ "${container_status}" != "\"UP\\nNo simulation is in progress at the moment\"" ]; then all_containers_finished=0 break fi @@ -157,8 +166,18 @@ function wait_for_simulators_to_finish_sending_messages() { echo "All containers finished sending messages" break fi + verbose_log "Sleeping for 1s" sleep 1 done + + + if [ $all_containers_finished -ne 1 ]; then + echo "[ERROR] Some xNFs simulators failed to finish sending messages - simulation probably failed" + echo "For debug output rerun simulation with -v and --xnf-logs-directory command line options" + cleanup + echo "Exitting..." + exit 3 + fi } function cleanup() { @@ -170,7 +189,7 @@ function cleanup() { if [ -n "${XNF_LOGS_DIRECTORY+x}" ]; then local log_file=${XNF_LOGS_DIRECTORY}/${container_id}.log verbose_log "Writing container logs to: ${log_file}" - docker logs ${container_id} > $log_file + docker logs ${container_id} &> $log_file fi verbose_log "Removing container: ${container_id}" docker rm $container_id > /dev/null @@ -202,6 +221,8 @@ while getopts "$optspec" arg; do case "${OPTARG}" in verbose) VERBOSE=True ;; + ssl-disable) + SSL_DISABLE="--ssl-disable" ;; help) usage ;; *) @@ -239,14 +260,14 @@ MESSAGE_BATCHES_AMOUNT=${4} MESSAGES_SENDING_INTERVAL=${5} # set defaults if absent -[ -z "${MESSAGES_IN_BATCH}" ] && MESSAGES_IN_BATCH=1 +[ -z "${MESSAGES_IN_BATCH+x}" ] && MESSAGES_IN_BATCH=1 +[ -z "${SSL_DISABLE+x}" ] && SSL_DISABLE="" create_logs_dir CREATED_XNF_SIMULATORS_PORTS=() CREATED_XNF_SIMULATORS_IDS=() -echo "Creating ${XNFS_AMOUNT} xNFs simulators" trap cleanup SIGINT SIGTERM create_xNFs_simulators @@ -259,6 +280,7 @@ assure_all_xNFs_requests_were_sent assumed_message_sending_time=$(echo ";0.00025 * $XNFS_AMOUNT" | bc) seconds_to_wait=$(echo ";$assumed_message_sending_time * $MESSAGE_BATCHES_AMOUNT * $MESSAGES_IN_BATCH" | bc) +seconds_to_wait=$(echo ";if($seconds_to_wait > 2) $seconds_to_wait else 2" | bc) wait_for_simulators_to_finish_sending_messages $seconds_to_wait # there might be network lag between moment when xNF finished sending messages and they actually are received by hv-ves # thus we cannot start removing xNFs immediately to prevent closing socket channels diff --git a/development/docker-compose.yml b/development/docker-compose.yml index adf8947d..284199d0 100644 --- a/development/docker-compose.yml +++ b/development/docker-compose.yml @@ -67,7 +67,9 @@ services: "--config-url", "http://consul-server:8500/v1/kv/veshv-config?raw=true", "--kafka-bootstrap-servers", "message-router-kafka:9092", "--key-store-password", "onaponap", - "--trust-store-password", "onaponap"] + "--trust-store-password", "onaponap", + "--first-request-delay", "2", + "--log-level", "DEBUG"] environment: JAVA_OPTS: "-Dio.netty.leakDetection.level=paranoid" healthcheck: @@ -91,12 +93,20 @@ services: image: onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-xnf-simulator ports: - "6062:6062/tcp" + - "6063:6063" command: ["--listen-port", "6062", + "--health-check-api-port", "6063", "--ves-host", "ves-hv-collector", "--ves-port", "6061", "--key-store", "/etc/ves-hv/client.p12", "--key-store-password", "onaponap", "--trust-store-password", "onaponap"] + healthcheck: + test: curl -f http://localhost:6063/health/ready || exit 1 + interval: 10s + timeout: 3s + retries: 3 + start_period: 10s depends_on: - ves-hv-collector volumes: @@ -105,8 +115,8 @@ services: dcae-app-simulator: image: onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-dcae-app-simulator ports: - - "6063:6063/tcp" - command: ["--listen-port", "6063", + - "6064:6064/tcp" + command: ["--listen-port", "6064", "--kafka-bootstrap-servers", "message-router-kafka:9092", "--kafka-topics", "HV_VES_PERF3GPP"] depends_on: |