Create script to run performance test locally
Change-Id: I6bbf0e9b029aef1558008286f0fbec83b76be44c
Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com>
Issue-ID: DCAEGEN2-1641
diff --git a/development/bin/constants.sh b/tools/development/bin/constants.sh
similarity index 100%
rename from development/bin/constants.sh
rename to tools/development/bin/constants.sh
diff --git a/development/bin/consul.sh b/tools/development/bin/consul.sh
similarity index 100%
rename from development/bin/consul.sh
rename to tools/development/bin/consul.sh
diff --git a/development/bin/dcae-msgs.sh b/tools/development/bin/dcae-msgs.sh
similarity index 100%
rename from development/bin/dcae-msgs.sh
rename to tools/development/bin/dcae-msgs.sh
diff --git a/development/bin/dcae-reset.sh b/tools/development/bin/dcae-reset.sh
similarity index 100%
rename from development/bin/dcae-reset.sh
rename to tools/development/bin/dcae-reset.sh
diff --git a/development/bin/dcae-topic.sh b/tools/development/bin/dcae-topic.sh
similarity index 100%
rename from development/bin/dcae-topic.sh
rename to tools/development/bin/dcae-topic.sh
diff --git a/development/bin/run-xnf-simulator.sh b/tools/development/bin/run-xnf-simulator.sh
similarity index 100%
rename from development/bin/run-xnf-simulator.sh
rename to tools/development/bin/run-xnf-simulator.sh
diff --git a/development/bin/start-simulation.sh b/tools/development/bin/start-simulation.sh
similarity index 100%
rename from development/bin/start-simulation.sh
rename to tools/development/bin/start-simulation.sh
diff --git a/development/bin/xnf-simulation.sh b/tools/development/bin/xnf-simulation.sh
similarity index 100%
rename from development/bin/xnf-simulation.sh
rename to tools/development/bin/xnf-simulation.sh
diff --git a/development/configuration/base.json b/tools/development/configuration/base.json
similarity index 100%
rename from development/configuration/base.json
rename to tools/development/configuration/base.json
diff --git a/development/configuration/local.json b/tools/development/configuration/local.json
similarity index 100%
rename from development/configuration/local.json
rename to tools/development/configuration/local.json
diff --git a/development/consul/configuration.hcl b/tools/development/consul/configuration.hcl
similarity index 100%
rename from development/consul/configuration.hcl
rename to tools/development/consul/configuration.hcl
diff --git a/development/docker-compose.yml b/tools/development/docker-compose.yml
similarity index 99%
rename from development/docker-compose.yml
rename to tools/development/docker-compose.yml
index 2704722..fbc3892 100644
--- a/development/docker-compose.yml
+++ b/tools/development/docker-compose.yml
@@ -110,7 +110,7 @@
- config-binding-service
volumes:
- ./configuration/:/etc/ves-hv/configuration/
- - ./ssl/:/etc/ves-hv/ssl/
+ - ../ssl/:/etc/ves-hv/ssl/
- ./logs:/var/log/ONAP/dcae-hv-ves-collector
diff --git a/development/grafana/dashboards-providers/dashboard-providers.yaml b/tools/development/grafana/dashboards-providers/dashboard-providers.yaml
similarity index 100%
rename from development/grafana/dashboards-providers/dashboard-providers.yaml
rename to tools/development/grafana/dashboards-providers/dashboard-providers.yaml
diff --git a/development/grafana/dashboards/connections.json b/tools/development/grafana/dashboards/connections.json
similarity index 100%
rename from development/grafana/dashboards/connections.json
rename to tools/development/grafana/dashboards/connections.json
diff --git a/development/grafana/dashboards/processing.json b/tools/development/grafana/dashboards/processing.json
similarity index 100%
rename from development/grafana/dashboards/processing.json
rename to tools/development/grafana/dashboards/processing.json
diff --git a/development/grafana/datasources/prometheus.yaml b/tools/development/grafana/datasources/prometheus.yaml
similarity index 100%
rename from development/grafana/datasources/prometheus.yaml
rename to tools/development/grafana/datasources/prometheus.yaml
diff --git a/development/logs/.gitignore b/tools/development/logs/.gitignore
similarity index 100%
rename from development/logs/.gitignore
rename to tools/development/logs/.gitignore
diff --git a/development/prometheus.yml b/tools/development/prometheus.yml
similarity index 100%
rename from development/prometheus.yml
rename to tools/development/prometheus.yml
diff --git a/development/configuration/base.json b/tools/performance/configuration/base.json
similarity index 100%
copy from development/configuration/base.json
copy to tools/performance/configuration/base.json
diff --git a/development/consul/configuration.hcl b/tools/performance/consul/configuration.hcl
similarity index 100%
copy from development/consul/configuration.hcl
copy to tools/performance/consul/configuration.hcl
diff --git a/development/docker-compose.yml b/tools/performance/docker-compose.yml
similarity index 70%
copy from development/docker-compose.yml
copy to tools/performance/docker-compose.yml
index 2704722..8214323 100644
--- a/development/docker-compose.yml
+++ b/tools/performance/docker-compose.yml
@@ -1,10 +1,6 @@
version: "3.5"
services:
- #
- # DMaaP Message Router
- #
-
message-router-zookeeper:
image: nexus3.onap.org:10001/onap/dmaap/zookeeper:4.0.0
ports:
@@ -15,7 +11,6 @@
ports:
- "9092:9092"
- "9093:9093"
-# command: "start-kafka.sh"
environment:
HOST_IP: 127.0.0.1
KAFKA_BROKER_ID: 0
@@ -42,10 +37,6 @@
depends_on:
- message-router-zookeeper
- #
- # Consul / CBS
- #
-
consul-server:
image: docker.io/consul:1.0.6
ports:
@@ -53,7 +44,7 @@
volumes:
- ./consul/:/consul/config
- consul-config:
+ consul-bootstrap:
image: docker.io/consul:1.0.6
restart: on-failure
command: ["kv", "put", "-http-addr=http://consul-server:8500", "dcae-hv-ves-collector", '{
@@ -82,11 +73,7 @@
environment:
CONSUL_HOST: "consul-server"
depends_on:
- - consul-config
-
- #
- # DCAE HV VES Collector
- #
+ - consul-bootstrap
ves-hv-collector:
image: onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-main:latest
@@ -110,72 +97,20 @@
- config-binding-service
volumes:
- ./configuration/:/etc/ves-hv/configuration/
- - ./ssl/:/etc/ves-hv/ssl/
- ./logs:/var/log/ONAP/dcae-hv-ves-collector
+ - ../ssl/:/etc/ves-hv/ssl/
-
- #
- # Simulators
- #
-
- xnf-simulator:
- 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-file", "/etc/ves-hv/client.pass",
- "--trust-store", "/etc/ves-hv/trust.p12",
- "--trust-store-password-file", "/etc/ves-hv/trust.pass"]
- 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:
- - ./ssl/:/etc/ves-hv/
-
- dcae-app-simulator:
- image: onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-dcae-app-simulator
+ kafka-consumer:
+ image: onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-kafka-consumer
ports:
- "6064:6064/tcp"
- command: ["--listen-port", "6064",
- "--kafka-bootstrap-servers", "message-router-kafka-0:9092",
- "--kafka-topics", "HV_VES_PERF3GPP"]
+ command: ["--listen-port", "6062"]
depends_on:
- message-router-kafka-0
- #
- # Monitoring
- #
-
prometheus:
image: prom/prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
-
- grafana:
- image: grafana/grafana
- ports:
- - "3000:3000"
- environment:
- GF_AUTH_DISABLE_LOGIN_FORM: "true"
- GF_AUTH_DISABLE_SIGNOUT_MENU: "true"
- GF_AUTH_ANONYMOUS_ENABLED: "true"
- GF_AUTH_ANONYMOUS_ORG_ROLE: "Admin"
- volumes:
- - ./grafana/datasources:/etc/grafana/provisioning/datasources
- - ./grafana/dashboards-providers:/etc/grafana/provisioning/dashboards
- # defined in ./grafana/dashboards-providers/dasboard-providers.yaml
- - ./grafana/dashboards:/var/lib/grafana/dashboards/hv-ves
-
-
diff --git a/tools/performance/local-performance-test.sh b/tools/performance/local-performance-test.sh
new file mode 100755
index 0000000..cad21ef
--- /dev/null
+++ b/tools/performance/local-performance-test.sh
@@ -0,0 +1,176 @@
+#!/usr/bin/env bash
+
+cd "$(dirname "$0")"
+
+CERT_FILE=${CERT_FILE:-/ssl/client.p12}
+CERT_PASS_FILE=${CERT_PASS_FILE:-/ssl/client.pass}
+HV_VES_NETWORK=${HV_VES_NETWORK:-performance_default}
+VOLUME_MAPPING=${VOLUME_MAPPING:-$PWD/../ssl/:/ssl}
+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-rust-client:latest}
+
+PRODUCER_APP_NAME=hv-ves-producer
+HV_VES_ADDRESS=ves-hv-collector:6061
+CONTAINERS_COUNT=1
+CLIENTS_PER_CONTAINER=1
+MSG_SIZE=16384
+MSG_COUNT=1000
+INTERVAL_MS=0
+
+
+function usage() {
+ echo ""
+ echo "Run HV-VES performance test locally"
+ echo "Usage $0 setup|start|clean|help"
+ echo " setup : generate certs and set up docker components"
+ echo " start : run the performance test"
+ echo " Optional parameters:"
+ echo " --address : HV-VES address in host:port format (ves-hv-collector:6061)"
+ echo " --containers : number of docker containers to create (1)"
+ echo " --clients : number of clients in single container (1)"
+ echo " --msg-size : size in bytes of a single message (16384)"
+ echo " --msg-count : amount of messages to sent by one client in single container (1000)"
+ echo " --interval : interval between messages (0)"
+ echo " clean : remove generated certs, HV-VES components and producers"
+ echo " help : print usage"
+ echo "Example invocations:"
+ echo "./local-performance-test.sh setup"
+ echo "./local-performance-test.sh start --containers 10 --clients 100 --msg-count 10000"
+ echo "./local-performance-test.sh clean"
+ exit 1
+}
+
+function setup_environment(){
+ echo "Setting up"
+ cd ../ssl
+ ./gen-certs.sh
+ cd ../performance
+ docker-compose up -d
+
+ echo "Waiting for components to be healthy.."
+ while [[ $(docker-compose ps | grep -c "unhealthy\|starting") -ne 0 ]] ; do
+ sleep 1
+ done
+
+ echo "All components ready"
+ exit 0
+}
+
+function start_performance_test(){
+
+ TEST_ID=$(date +%s)
+ create_containers ${CONTAINERS_COUNT} ${TEST_ID} &
+
+ while :; do
+ ACTIVE_PRODUCERS=$(docker ps --format "table {{.ID}}\t{{.Status}}" -f "label=id=$TEST_ID")
+ ACTIVE_PRODUCERS_COUNT=$(echo "$ACTIVE_PRODUCERS" | grep -c "Up")
+
+ clear
+ print_test_configuration
+ echo "Active producers ($ACTIVE_PRODUCERS_COUNT/$CONTAINERS_COUNT):"
+ echo "$ACTIVE_PRODUCERS"
+
+ EXITED_CONTAINERS=$(docker ps -aq -f "label=id=$TEST_ID" -f status=exited | wc -l)
+ [[ ${EXITED_CONTAINERS} -eq ${CONTAINERS_COUNT} ]] && break
+
+ sleep 1
+ done
+
+ clear
+ print_test_configuration
+ echo "Test finished"
+ # TODO put test result here
+ exit 0
+}
+
+function print_test_configuration(){
+ echo "PERFORMANCE TEST IN PROGRESS"
+ echo ""
+ echo "Test configuration:"
+ echo "Containers count: $CONTAINERS_COUNT"
+ echo "Clients per container: $CLIENTS_PER_CONTAINER"
+ echo "Message size: $MSG_SIZE"
+ echo "Messages per client: $MSG_COUNT"
+ echo "Interval: $INTERVAL_MS"
+ echo ""
+}
+
+function create_containers(){
+
+ for i in $(seq 1 ${1}); do
+ docker run -d -l id="$2" -l app="$PRODUCER_APP_NAME" -v "$VOLUME_MAPPING" --network="$HV_VES_NETWORK" "$PRODUCER_IMAGE_NAME" \
+ --address "$HV_VES_ADDRESS" \
+ --certfile "$CERT_FILE" \
+ --certpass "$CERT_PASS_FILE" \
+ --containers "$CONTAINERS_COUNT" \
+ --clients "$CLIENTS_PER_CONTAINER" \
+ --msgsize "$MSG_SIZE" \
+ --msgcount "$MSG_COUNT" \
+ --intervalms "$INTERVAL_MS" > /dev/null
+ done
+}
+
+function clean(){
+ echo "Cleaning up"
+
+ echo "Removing active producers"
+ docker rm --force $(docker ps -aqf "label=app=$PRODUCER_APP_NAME")
+
+ echo "Clearing generated certs"
+ cd ../ssl
+ ./gen-certs.sh clean
+ cd ../performance
+
+ echo "Removing HV-VES components"
+ docker-compose down
+ exit 0
+}
+
+if [[ $# -eq 0 ]]; then
+ usage
+else
+ for arg in ${@}
+ do
+ case ${arg} in
+ setup)
+ setup_environment
+ ;;
+ start)
+ shift 1
+ while [[ $(($#)) -gt 0 ]]; do
+ case "${1}" in
+ --address)
+ HV_VES_ADDRESS=${2}
+ ;;
+ --containers)
+ CONTAINERS_COUNT=${2}
+ ;;
+ --clients)
+ CLIENTS_PER_CONTAINER=${2}
+ ;;
+ --msg-size)
+ MSG_SIZE=${2}
+ ;;
+ --msg-count)
+ MSG_COUNT=${2}
+ ;;
+ --interval)
+ INTERVAL_MS=${2}
+ ;;
+ esac
+ shift 2
+ done
+ start_performance_test
+ ;;
+ clean)
+ clean
+ ;;
+ help)
+ usage
+ ;;
+ *)
+ echo "Unknown action: ${arg}" >&2
+ usage
+ ;;
+ esac
+ done
+fi
\ No newline at end of file
diff --git a/development/logs/.gitignore b/tools/performance/logs/.gitignore
similarity index 100%
copy from development/logs/.gitignore
copy to tools/performance/logs/.gitignore
diff --git a/tools/performance/prometheus.yml b/tools/performance/prometheus.yml
new file mode 100644
index 0000000..b9a937c
--- /dev/null
+++ b/tools/performance/prometheus.yml
@@ -0,0 +1,14 @@
+global:
+ scrape_interval: 5s
+ external_labels:
+ monitor: 'my-monitor'
+
+scrape_configs:
+ - job_name: 'prometheus'
+ static_configs:
+ - targets: ['localhost:9090']
+
+ - job_name: 'kafka-consumer'
+ metrics_path: '/monitoring/prometheus'
+ static_configs:
+ - targets: ['kafka-consumer:6062']
diff --git a/development/ssl/.gitignore b/tools/ssl/.gitignore
similarity index 100%
rename from development/ssl/.gitignore
rename to tools/ssl/.gitignore
diff --git a/development/ssl/Makefile-openssl b/tools/ssl/Makefile-openssl
similarity index 100%
rename from development/ssl/Makefile-openssl
rename to tools/ssl/Makefile-openssl
diff --git a/development/ssl/README.md b/tools/ssl/README.md
similarity index 100%
rename from development/ssl/README.md
rename to tools/ssl/README.md
diff --git a/development/ssl/gen-certs.sh b/tools/ssl/gen-certs.sh
similarity index 100%
rename from development/ssl/gen-certs.sh
rename to tools/ssl/gen-certs.sh