From e117efb15a1202e982c69a3686f049211f7889db Mon Sep 17 00:00:00 2001 From: kjaniak Date: Fri, 12 Jul 2019 14:29:25 +0200 Subject: Adding script for Performance tests of HV-VES on cloud Change-Id: If71b0e8b04ce23a5daafef632788667ccd50c1a1 Issue-ID: DCAEGEN2-1664 Signed-off-by: kjaniak --- .../cloud/cloud-based-performance-test.sh | 148 +++++++++++++++++++++ tools/performance/cloud/consumer-deployment.yaml | 8 +- tools/performance/cloud/producer-pod.yaml | 20 +-- tools/performance/cloud/test.properties | 7 +- tools/performance/local/local-performance-test.sh | 2 +- 5 files changed, 163 insertions(+), 22 deletions(-) create mode 100755 tools/performance/cloud/cloud-based-performance-test.sh mode change 100644 => 100755 tools/performance/cloud/consumer-deployment.yaml mode change 100644 => 100755 tools/performance/cloud/producer-pod.yaml (limited to 'tools/performance') diff --git a/tools/performance/cloud/cloud-based-performance-test.sh b/tools/performance/cloud/cloud-based-performance-test.sh new file mode 100755 index 00000000..95bd10a3 --- /dev/null +++ b/tools/performance/cloud/cloud-based-performance-test.sh @@ -0,0 +1,148 @@ +#!/usr/bin/env bash + +SCRIPT_DIRECTORY="$(pwd "$0")" +CONTAINERS_COUNT=1 +PROPERTIES_FILE=${SCRIPT_DIRECTORY}/test.properties +CONFIG_MAP_NAME=performance-test-config +PRODUCER_APPS_LABEL=hv-collector-producer +CONSUMER_APPS_LABEL=hv-collector-kafka-consumer +ONAP_NAMESPACE=onap +MAXIMUM_BACK_OFF_CHECK_ITERATIONS=30 +CHECK_NUMBER=0 +NAME_REASON_PATTERN="custom-columns=NAME:.metadata.name,REASON:.status.containerStatuses[].state.waiting.reason" + +function clean() { + echo "Cleaning up environment" + + echo "Attempting to delete ConfigMap" + kubectl delete configmap ${CONFIG_MAP_NAME} -n ${ONAP_NAMESPACE} + + echo "Attempting to delete consumer deployments" + kubectl delete deployments -l app=${CONSUMER_APPS_LABEL} -n ${ONAP_NAMESPACE} + + echo "Attempting to delete producer pods" + kubectl delete pods -l app=${PRODUCER_APPS_LABEL} -n ${ONAP_NAMESPACE} + + echo "Environment clean up finished!" +} + +function create_producers() { + set -e + for i in $(seq 1 ${CONTAINERS_COUNT}); + do + echo "Creating ${i}/${CONTAINERS_COUNT} producer" + kubectl create -f producer-pod.yaml -n ${ONAP_NAMESPACE} + done + echo "Producers created" + set +e +} + +function usage() { + echo "" + echo "Run cloud based HV-VES performance test" + echo "Usage $0 setup|start|clean|help" + echo " setup : set up ConfigMap and consumers" + echo " start : create producers - start the performance test" + echo " Optional parameters:" + echo " --containers : number of producer containers to create (1)" + echo " --properties-file : path to file with benchmark properties (./test.properties)" + echo " clean : remove ConfigMap, HV-VES consumers and producers" + echo " help : print usage" + echo "Example invocations:" + echo "./cloud-based-performance-test.sh setup" + echo "./cloud-based-performance-test.sh start" + echo "./cloud-based-performance-test.sh start --containers 10" + echo "./cloud-based-performance-test.sh start --containers 10" + echo "./cloud-based-performance-test.sh clean" + exit 1 +} + +function setup_environment() { + echo "Setting up environment" + echo "Creating ConfigMap from: $PROPERTIES_FILE" + kubectl create configmap ${CONFIG_MAP_NAME} --from-env-file=${PROPERTIES_FILE} -n ${ONAP_NAMESPACE} + + echo "Creating consumer deployment" + kubectl apply -f consumer-deployment.yaml -n ${ONAP_NAMESPACE} + + echo "Waiting for consumers to be running." + while [[ $(kubectl get pods -l app=${CONSUMER_APPS_LABEL} -n ${ONAP_NAMESPACE} | grep -c "unhealthy\|starting") -ne 0 ]] ; do + sleep 1 + done + echo "Setting up environment finished!" +} + +function start_performance_test() { + echo "Starting cloud based performance tests" + echo "________________________________________" + echo "Test configuration:" + echo "Producer containers count: ${CONTAINERS_COUNT}" + echo "Properties file path: ${PROPERTIES_FILE}" + echo "________________________________________" + + create_producers + + echo "Waiting for producers completion" + while :; do + COMPLETED_PRODUCERS=$(kubectl get pods -l app=${PRODUCER_APPS_LABEL} -n ${ONAP_NAMESPACE} | grep -c "Completed") + IMAGE_PULL_BACK_OFFS=$(kubectl get pods -l app=${PRODUCER_APPS_LABEL} -n ${ONAP_NAMESPACE} -o ${NAME_REASON_PATTERN} | grep -c "ImagePullBackOff \| ErrImagePull") + + if [[ ${IMAGE_PULL_BACK_OFFS} -gt 0 ]]; then + CHECK_NUMBER=$((CHECK_NUMBER + 1)) + if [[ ${CHECK_NUMBER} -gt ${MAXIMUM_BACK_OFF_CHECK_ITERATIONS} ]]; then + echo "Error: Image pull problem" + exit 1 + fi + fi + + [[ ${COMPLETED_PRODUCERS} -eq ${CONTAINERS_COUNT} || ${CHECK_NUMBER} -gt ${MAXIMUM_BACK_OFF_CHECK_ITERATIONS} ]] && break + sleep 1 + done + + echo "Performance test finished" + exit 0 +} + +cd ${SCRIPT_DIRECTORY} + +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 + --containers) + CONTAINERS_COUNT=${2} + ;; + --properties-file) + PROPERTIES_FILE=${2} + ;; + *) + echo "Unknown option: ${1}" + usage + ;; + 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/cloud/consumer-deployment.yaml b/tools/performance/cloud/consumer-deployment.yaml old mode 100644 new mode 100755 index 9b03aca6..5d382a42 --- a/tools/performance/cloud/consumer-deployment.yaml +++ b/tools/performance/cloud/consumer-deployment.yaml @@ -41,12 +41,12 @@ spec: spec: containers: - name: kafka-consumer-counting - image: hv-collector-kafka-consumer:1.3.0-SNAPSHOT + image: nexus3.dyn.nesc.nokia.net:10001/onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-kafka-consumer:1.3.0-SNAPSHOT ports: - containerPort: 8080 env: - name: LISTEN_PORT - value: 8080 + value: "8080" - name: KAFKA_BOOTSTRAP_SERVERS valueFrom: configMapKeyRef: @@ -84,12 +84,12 @@ spec: spec: containers: - name: kafka-processing-consumer - image: hv-collector-kafka-consumer:1.3.0-SNAPSHOT + image: nexus3.dyn.nesc.nokia.net:10001/onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-kafka-consumer:1.3.0-SNAPSHOT ports: - containerPort: 8080 env: - name: LISTEN_PORT - value: 8080 + value: "8080" - name: KAFKA_BOOTSTRAP_SERVERS valueFrom: configMapKeyRef: diff --git a/tools/performance/cloud/producer-pod.yaml b/tools/performance/cloud/producer-pod.yaml old mode 100644 new mode 100755 index 75d03795..b3248cba --- a/tools/performance/cloud/producer-pod.yaml +++ b/tools/performance/cloud/producer-pod.yaml @@ -19,25 +19,20 @@ apiVersion: v1 kind: Pod metadata: - name: hv-collector-producer + generateName: hv-collector-producer- namespace: onap labels: app: hv-collector-producer spec: containers: - name: hv-collector-producer - image: the-a-team-registry-local.esisoj70.emea.nsn-net.net/onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-rust-client:latest + image: the-a-team-registry-local.esisoj70.emea.nsn-net.net/onap/org.onap.dcaegen2.collectors.hv-ves.hv-collector-go-client:latest env: - name: HV_VES_ADDRESS valueFrom: configMapKeyRef: name: performance-test-config key: producer.hvVesAddress - - name: CLIENTS_COUNT - valueFrom: - configMapKeyRef: - name: performance-test-config - key: producer.client.count - name: MSG_SIZE valueFrom: configMapKeyRef: @@ -53,9 +48,8 @@ spec: configMapKeyRef: name: performance-test-config key: producer.message.interval - args: ["--ssl-disable", - "--address", "$HV_VES_ADDRESS", - "--clients", "$CLIENTS_COUNT", - "--msgsize", "$MSG_SIZE", - "--msgcount", "$MSG_COUNT", - "--intervalms", "$INTERVAL_MS"] \ No newline at end of file + args: ["--address", "$(HV_VES_ADDRESS)", + "--msgsize", "$(MSG_SIZE)", + "--msgcount", "$(MSG_COUNT)", + "--intervalms", "$(INTERVAL_MS)"] + restartPolicy: Never \ No newline at end of file diff --git a/tools/performance/cloud/test.properties b/tools/performance/cloud/test.properties index 9865339c..596119e7 100644 --- a/tools/performance/cloud/test.properties +++ b/tools/performance/cloud/test.properties @@ -1,9 +1,9 @@ -# TODO: in script create configmap from that file - # PRODUCER CONFIGURATION # HV-VES address -producer.hvVesAddress=ves-hv-collector:6061 +#producer.hvVesAddress=: +producer.hvVesAddress=10.43.165.111:6061 + # Number of pods to create producer.pod.count=1 # Number of clients per pod @@ -15,7 +15,6 @@ producer.message.count=1000 # Interval between messages producer.message.interval=0 - # CONSUMER CONFIGURATION # Addresses of Kafka services to consume from diff --git a/tools/performance/local/local-performance-test.sh b/tools/performance/local/local-performance-test.sh index 6d08b8e7..2fcd1305 100755 --- a/tools/performance/local/local-performance-test.sh +++ b/tools/performance/local/local-performance-test.sh @@ -5,7 +5,7 @@ CERT_FILE=${CERT_FILE:-/ssl/client.p12} CERT_PASS_FILE=${CERT_PASS_FILE:-/ssl/client.pass} HV_VES_NETWORK=${HV_VES_NETWORK:-local_default} VOLUME_MAPPING=${VOLUME_MAPPING:-$SCRIPT_DIRECTORY/../../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_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} PRODUCER_APP_NAME=hv-ves-producer HV_VES_ADDRESS=ves-hv-collector:6061 -- cgit 1.2.3-korg