Create script to run performance test locally 15/90315/9
authorJakub Dudycz <jakub.dudycz@nokia.com>
Fri, 21 Jun 2019 15:19:49 +0000 (17:19 +0200)
committerJakub Dudycz <jakub.dudycz@nokia.com>
Wed, 3 Jul 2019 09:49:14 +0000 (11:49 +0200)
Change-Id: I6bbf0e9b029aef1558008286f0fbec83b76be44c
Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com>
Issue-ID: DCAEGEN2-1641

28 files changed:
tools/development/bin/constants.sh [moved from development/bin/constants.sh with 100% similarity]
tools/development/bin/consul.sh [moved from development/bin/consul.sh with 100% similarity]
tools/development/bin/dcae-msgs.sh [moved from development/bin/dcae-msgs.sh with 100% similarity]
tools/development/bin/dcae-reset.sh [moved from development/bin/dcae-reset.sh with 100% similarity]
tools/development/bin/dcae-topic.sh [moved from development/bin/dcae-topic.sh with 100% similarity]
tools/development/bin/run-xnf-simulator.sh [moved from development/bin/run-xnf-simulator.sh with 100% similarity]
tools/development/bin/start-simulation.sh [moved from development/bin/start-simulation.sh with 100% similarity]
tools/development/bin/xnf-simulation.sh [moved from development/bin/xnf-simulation.sh with 100% similarity]
tools/development/configuration/base.json [moved from development/configuration/base.json with 100% similarity]
tools/development/configuration/local.json [moved from development/configuration/local.json with 100% similarity]
tools/development/consul/configuration.hcl [moved from development/consul/configuration.hcl with 100% similarity]
tools/development/docker-compose.yml [moved from development/docker-compose.yml with 99% similarity]
tools/development/grafana/dashboards-providers/dashboard-providers.yaml [moved from development/grafana/dashboards-providers/dashboard-providers.yaml with 100% similarity]
tools/development/grafana/dashboards/connections.json [moved from development/grafana/dashboards/connections.json with 100% similarity]
tools/development/grafana/dashboards/processing.json [moved from development/grafana/dashboards/processing.json with 100% similarity]
tools/development/grafana/datasources/prometheus.yaml [moved from development/grafana/datasources/prometheus.yaml with 100% similarity]
tools/development/logs/.gitignore [moved from development/logs/.gitignore with 100% similarity]
tools/development/prometheus.yml [moved from development/prometheus.yml with 100% similarity]
tools/performance/configuration/base.json [new file with mode: 0644]
tools/performance/consul/configuration.hcl [new file with mode: 0644]
tools/performance/docker-compose.yml [new file with mode: 0644]
tools/performance/local-performance-test.sh [new file with mode: 0755]
tools/performance/logs/.gitignore [new file with mode: 0644]
tools/performance/prometheus.yml [new file with mode: 0644]
tools/ssl/.gitignore [moved from development/ssl/.gitignore with 100% similarity]
tools/ssl/Makefile-openssl [moved from development/ssl/Makefile-openssl with 100% similarity]
tools/ssl/README.md [moved from development/ssl/README.md with 100% similarity]
tools/ssl/gen-certs.sh [moved from development/ssl/gen-certs.sh with 100% similarity]

similarity index 99%
rename from development/docker-compose.yml
rename to tools/development/docker-compose.yml
index 2704722..fbc3892 100644 (file)
@@ -110,7 +110,7 @@ services:
       - 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/tools/performance/configuration/base.json b/tools/performance/configuration/base.json
new file mode 100644 (file)
index 0000000..2a806ad
--- /dev/null
@@ -0,0 +1,11 @@
+{
+  "logLevel": "DEBUG",
+  "server.listenPort": 6061,
+  "server.idleTimeoutSec": 60,
+  "cbs.firstRequestDelaySec": 5,
+  "cbs.requestIntervalSec": 5,
+  "security.keys.keyStoreFile": "/etc/ves-hv/ssl/server.p12",
+  "security.keys.keyStorePasswordFile": "/etc/ves-hv/ssl/server.pass",
+  "security.keys.trustStoreFile": "/etc/ves-hv/ssl/trust.p12",
+  "security.keys.trustStorePasswordFile": "/etc/ves-hv/ssl/trust.pass"
+}
\ No newline at end of file
diff --git a/tools/performance/consul/configuration.hcl b/tools/performance/consul/configuration.hcl
new file mode 100644 (file)
index 0000000..f975955
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * ============LICENSE_START=======================================================
+ * csit-dcaegen2-collectors-hv-ves
+ * ================================================================================
+ * 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=========================================================
+ */
+
+server = true
+bootstrap = true
+ui = true
+client_addr = "0.0.0.0"
+
+service {
+  # name under which hv-ves collector should seek cbs
+  # usually set as CONFIG_BINDING_SERVICE environment variable
+  Name = "CBS"
+  # address of CBS as seen by hv-ves collector
+  Address = "config-binding-service"
+  Port = 10000
+}
+
diff --git a/tools/performance/docker-compose.yml b/tools/performance/docker-compose.yml
new file mode 100644 (file)
index 0000000..8214323
--- /dev/null
@@ -0,0 +1,116 @@
+version: "3.5"
+services:
+
+  message-router-zookeeper:
+    image: nexus3.onap.org:10001/onap/dmaap/zookeeper:4.0.0
+    ports:
+      - "2181:2181"
+
+  message-router-kafka-0:
+    image: nexus3.onap.org:10001/onap/dmaap/kafka111:0.0.6
+    ports:
+      - "9092:9092"
+      - "9093:9093"
+    environment:
+      HOST_IP:                                     127.0.0.1
+      KAFKA_BROKER_ID:                             0
+      ENDPOINT_PORT:                               30490
+      KAFKA_ZOOKEEPER_CONNECT:                     "message-router-zookeeper:2181"
+      KAFKA_AUTO_CREATE_TOPICS_ENABLE:             "true"
+      KAFKA_DELETE_TOPIC_ENABLE:                   "true"
+
+      KAFKA_LISTENERS:                             "INTERNAL_SASL_PLAINTEXT://0.0.0.0:9092,EXTERNAL_SASL_PLAINTEXT://0.0.0.0:9093"
+      KAFKA_ADVERTISED_LISTENERS:                  "INTERNAL_SASL_PLAINTEXT://message-router-kafka-0:9092,EXTERNAL_SASL_PLAINTEXT://message-router-kafka-0:9093"
+      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP:        "INTERNAL_SASL_PLAINTEXT:SASL_PLAINTEXT,EXTERNAL_SASL_PLAINTEXT:SASL_PLAINTEXT"
+      KAFKA_INTER_BROKER_LISTENER_NAME:            "INTERNAL_SASL_PLAINTEXT"
+      KAFKA_SASL_ENABLED_MECHANISMS:               "PLAIN"
+      KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL:  "PLAIN"
+      KAFKA_AUTHORIZER_CLASS_NAME:                 "org.onap.dmaap.kafkaAuthorize.KafkaCustomAuthorizer"
+
+      aaf_locate_url:                              https://aaf-locate:8095
+      KAFKA_LOG_DIRS:                              /opt/kafka/data
+      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR:      1
+      KAFKA_DEFAULT_REPLICATION_FACTOR:            1
+      KAFKA_NUM_PARTITIONS:                        1
+    volumes:
+      - /var/run/docker.sock:/var/run/docker.sock
+    depends_on:
+      - message-router-zookeeper
+
+  consul-server:
+    image: docker.io/consul:1.0.6
+    ports:
+      - "8500:8500"
+    volumes:
+      - ./consul/:/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", '{
+                                              "streams_publishes": {
+                                                "perf3gpp": {
+                                                  "type": "kafka",
+                                                  "aaf_credentials": {
+                                                    "username": "admin",
+                                                    "password": "admin_secret"
+                                                  },
+                                                  "kafka_info": {
+                                                    "bootstrap_servers": "message-router-kafka-0:9093",
+                                                    "topic_name": "HV_VES_PERF3GPP"
+                                                  }
+                                                }
+                                              }
+                                            }'
+    ]
+    depends_on:
+      - consul-server
+
+  config-binding-service:
+    image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app:2.2.4
+    ports:
+      - "10000:10000"
+    environment:
+      CONSUL_HOST: "consul-server"
+    depends_on:
+      - consul-bootstrap
+
+  ves-hv-collector:
+    image: onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-main:latest
+    ports:
+      - "6060:6060"
+      - "6061:6061/tcp"
+    environment:
+      JAVA_OPTS: "-Dio.netty.leakDetection.level=paranoid -Dlogback.configurationFile=/etc/ONAP/dcae-hv-ves-collector/logback.xml"
+      VESHV_CONFIGURATION_FILE: "/etc/ves-hv/configuration/base.json"
+      CONSUL_HOST: "consul-server"
+      CONFIG_BINDING_SERVICE: "CBS"
+      HOSTNAME: "dcae-hv-ves-collector"
+    healthcheck:
+      test: ./healthcheck.sh || exit 1
+      interval: 10s
+      timeout: 3s
+      retries: 3
+      start_period: 15s
+    depends_on:
+      - message-router-kafka-0
+      - config-binding-service
+    volumes:
+      - ./configuration/:/etc/ves-hv/configuration/
+      - ./logs:/var/log/ONAP/dcae-hv-ves-collector
+      - ../ssl/:/etc/ves-hv/ssl/
+
+  kafka-consumer:
+    image: onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-kafka-consumer
+    ports:
+      - "6064:6064/tcp"
+    command: ["--listen-port", "6062"]
+    depends_on:
+      - message-router-kafka-0
+
+  prometheus:
+    image: prom/prometheus
+    ports:
+      - "9090:9090"
+    volumes:
+      - ./prometheus.yml:/etc/prometheus/prometheus.yml
diff --git a/tools/performance/local-performance-test.sh b/tools/performance/local-performance-test.sh
new file mode 100755 (executable)
index 0000000..cad21ef
--- /dev/null
@@ -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/tools/performance/logs/.gitignore b/tools/performance/logs/.gitignore
new file mode 100644 (file)
index 0000000..1287e9b
--- /dev/null
@@ -0,0 +1,2 @@
+**
+!.gitignore
diff --git a/tools/performance/prometheus.yml b/tools/performance/prometheus.yml
new file mode 100644 (file)
index 0000000..b9a937c
--- /dev/null
@@ -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']