Add option to set kafka retention time for load tests 38/97738/6
authorRemigiusz Janeczek <remigiusz.janeczek@nokia.com>
Wed, 30 Oct 2019 13:37:05 +0000 (14:37 +0100)
committerRemigiusz Janeczek <remigiusz.janeczek@nokia.com>
Mon, 4 Nov 2019 08:07:13 +0000 (09:07 +0100)
Issue-ID: DCAEGEN2-1783
Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com>
Change-Id: Ib78d018864d9cc220b1f23ab2f3f4340c17cef78

tools/performance/cloud/cloud-based-performance-test.sh

index 283c130..6c27b69 100755 (executable)
@@ -37,6 +37,12 @@ COMPLETED_PRODUCERS_SUM=0
 NAME_REASON_PATTERN="custom-columns=NAME:.metadata.name,REASON:.status.containerStatuses[].state.waiting.reason"
 HVVES_POD_NAME=$(kubectl -n ${ONAP_NAMESPACE} get pods --no-headers=true -o custom-columns=:metadata.name | grep hv-ves-collector)
 HVVES_CERT_PATH=/etc/ves-hv/ssl/
+KAFKA_RETENTION_TIME_MINUTES=60
+MILISECONDS_IN_MINUTE=60000
+CALC_RETENTION_TIME_IN_MS_CMD='expr $KAFKA_RETENTION_TIME_MINUTES \* $MILISECONDS_IN_MINUTE'
+KAFKA_ROUTER_0_POD_NAME=$(kubectl -n ${ONAP_NAMESPACE} get pods --no-headers=true -o custom-columns=:metadata.name | grep router-kafka-0)
+KAFKA_SET_TOPIC_RETENTION_TIME_CMD='kafka-topics.sh --zookeeper message-router-zookeeper:2181 --alter --topic HV_VES_PERF3GPP --config retention.ms='
+HIDE_OUTPUT='grep abc | grep 123'
 
 function clean() {
     echo "Cleaning up environment"
@@ -130,6 +136,7 @@ function print_test_setup_info() {
     echo "Test configuration:"
     echo "Producer containers count: ${CONTAINERS_COUNT}"
     echo "Properties file path: ${PROPERTIES_FILE}"
+    echo "Retention time of kafka messages in minutes: ${KAFKA_RETENTION_TIME_MINUTES}"
     echo "________________________________________"
 }
 
@@ -141,9 +148,10 @@ function usage() {
     echo "  setup    : set up ConfigMap and consumers"
     echo "  start    : create producers - start the performance test"
     echo "    Optional parameters:"
-    echo "      --load            : should test keep defined containers number till script interruption (false)"
-    echo "      --containers      : number of producer containers to create (1)"
-    echo "      --properties-file : path to file with benchmark properties (./test.properties)"
+    echo "      --load              : should test keep defined containers number till script interruption (false)"
+    echo "      --containers        : number of producer containers to create (1)"
+    echo "      --properties-file   : path to file with benchmark properties (./test.properties)"
+    echo "      --retention-time-minutes : messages retention time on kafka in minutes - only for load tests (60)"
     echo "  clean    : remove ConfigMap, HV-VES consumers and producers"
     echo "  help     : print usage"
     echo "Example invocations:"
@@ -152,6 +160,7 @@ function usage() {
     echo "./cloud-based-performance-test.sh start"
     echo "./cloud-based-performance-test.sh start --containers 10"
     echo "./cloud-based-performance-test.sh start --load true --containers 10"
+    echo "./cloud-based-performance-test.sh start --load true --containers 10 --retention-time-minutes 50"
     echo "./cloud-based-performance-test.sh start --properties-file ~/other_test.properties"
     echo "./cloud-based-performance-test.sh clean"
     exit 1
@@ -210,6 +219,9 @@ function setup_environment() {
 function start_load_tests() {
     print_test_setup_info
 
+    echo "Setting message retention time"
+    kubectl exec -it ${KAFKA_ROUTER_0_POD_NAME} -n ${ONAP_NAMESPACE} -- ${KAFKA_SET_TOPIC_RETENTION_TIME_CMD}$(eval $CALC_RETENTION_TIME_IN_MS_CMD) | eval $HIDE_OUTPUT
+
     echo "CTRL + C to stop/interrupt this script"
     create_producers
 
@@ -287,6 +299,9 @@ else
                     --properties-file)
                         PROPERTIES_FILE=${2}
                         ;;
+                    --retention-time-minutes)
+                        KAFKA_RETENTION_TIME_MINUTES=${2}
+                        ;;
                     *)
                         echo "Unknown option: ${1}"
                         usage