New test profile
[nonrtric.git] / test / common / mr_api_functions.sh
index 2002131..977c3da 100755 (executable)
@@ -158,7 +158,7 @@ __DMAAPMR_kube_delete_all() {
 # args: <log-dir> <file-prexix>
 __MR_store_docker_logs() {
        if [ $RUNMODE == "KUBE" ]; then
-               kubectl  logs -l "autotest=MR" -n $KUBE_ONAP_NAMESPACE --tail=-1 > $1$2_mr_stub.log 2>&1
+               kubectl $KUBECONF  logs -l "autotest=MR" -n $KUBE_ONAP_NAMESPACE --tail=-1 > $1$2_mr_stub.log 2>&1
        else
                docker logs $MR_STUB_APP_NAME > $1$2_mr_stub.log 2>&1
        fi
@@ -169,11 +169,11 @@ __MR_store_docker_logs() {
 # args: <log-dir> <file-prexix>
 __DMAAPMR_store_docker_logs() {
        if [ $RUNMODE == "KUBE" ]; then
-               for podname in $(kubectl get pods -n $KUBE_ONAP_NAMESPACE -l "autotest=DMAAPMR" -o custom-columns=":metadata.name"); do
-                       kubectl logs -n $KUBE_ONAP_NAMESPACE $podname --tail=-1 > $1$2_$podname.log 2>&1
+               for podname in $(kubectl $KUBECONF get pods -n $KUBE_ONAP_NAMESPACE -l "autotest=DMAAPMR" -o custom-columns=":metadata.name"); do
+                       kubectl $KUBECONF logs -n $KUBE_ONAP_NAMESPACE $podname --tail=-1 > $1$2_$podname.log 2>&1
                done
        else
-               docker logs $MR_DMAAP_APP_NAME > $1$2mr.log 2>&1
+               docker logs $MR_DMAAP_APP_NAME > $1$2_mr.log 2>&1
                docker logs $MR_KAFKA_APP_NAME > $1$2_mr_kafka.log 2>&1
                docker logs $MR_ZOOKEEPER_APP_NAME > $1$2_mr_zookeeper.log 2>&1
        fi
@@ -217,6 +217,18 @@ __DMAAPMR_statisics_setup() {
        fi
 }
 
+# Check application requirements, e.g. helm, the the test needs. Exit 1 if req not satisfied
+# args: -
+__MR_test_requirements() {
+       :
+}
+
+# Check application requirements, e.g. helm, the the test needs. Exit 1 if req not satisfied
+# args: -
+__DMAAPMR_test_requirements() {
+       :
+}
+
 #######################################################
 
 # Description of port mappings when running MR-STUB only or MR-STUB + MESSAGE-ROUTER
@@ -273,7 +285,7 @@ use_mr_https() {
 # args: <protocol> <internal-port> <external-port> <internal-secure-port> <external-secure-port>
 __mr_set_protocoll() {
        echo -e $BOLD"$MR_STUB_DISPLAY_NAME and $MR_DMAAP_DISPLAY_NAME protocol setting"$EBOLD
-       echo -e " Using $BOLD http $EBOLD towards $MR_STUB_DISPLAY_NAME and $MR_DMAAP_DISPLAY_NAME"
+       echo -e " Using $BOLD $1 $EBOLD towards $MR_STUB_DISPLAY_NAME and $MR_DMAAP_DISPLAY_NAME"
 
        ## Access to Dmaap mediator
 
@@ -304,7 +316,7 @@ __mr_set_protocoll() {
                MR_ZOOKEEPER_SERVICE_PATH=$MR_ZOOKEEPER_APP_NAME":"$MR_ZOOKEEPER_PORT
        fi
 
-       # For directing calls from script to e.g.PMS via message rounter
+       # For directing calls from script to e.g.A1PMS via message rounter
        # These cases shall always go though the  mr-stub
        MR_ADAPTER_HTTP="http://"$MR_STUB_APP_NAME":"$2
        MR_ADAPTER_HTTPS="https://"$MR_STUB_APP_NAME":"$4
@@ -333,7 +345,7 @@ __mr_set_protocoll() {
                        MR_ZOOKEEPER_SERVICE_PATH=$MR_ZOOKEEPER_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_ZOOKEEPER_PORT
                fi
 
-               # For directing calls from script to e.g.PMS, via message rounter
+               # For directing calls from script to e.g.A1PMS, via message rounter
                # These calls shall always go though the  mr-stub
                MR_ADAPTER_HTTP="http://"$MR_STUB_APP_NAME.$KUBE_ONAP_NAMESPACE":"$3
                MR_ADAPTER_HTTPS="https://"$MR_STUB_APP_NAME.$KUBE_ONAP_NAMESPACE":"$5
@@ -372,6 +384,9 @@ __dmaapmr_export_vars() {
 
        export MR_KAFKA_SERVICE_PATH
        export MR_ZOOKEEPER_SERVICE_PATH
+
+       export MR_KAFKA_KUBE_NODE_PORT
+       export MR_KAFKA_DOCKER_LOCALHOST_PORT
 }
 
 # Export env vars for config files, docker compose and kube resources
@@ -509,6 +524,9 @@ start_mr() {
 
                        __check_service_start $MR_DMAAP_APP_NAME $MR_DMAAP_PATH$MR_DMAAP_ALIVE_URL
 
+                       echo " Kafka TCP node port $MR_KAFKA_KUBE_NODE_PORT"
+
+
                        if [ $# -gt 0 ]; then
                                if [ $(($#%3)) -eq 0 ]; then
                                        while [ $# -gt 0 ]; do
@@ -608,6 +626,8 @@ start_mr() {
 
                        __check_service_start $MR_DMAAP_APP_NAME $MR_DMAAP_PATH$MR_DMAAP_ALIVE_URL
 
+                       echo " Kafka TCP node port $MR_KAFKA_DOCKER_LOCALHOST_PORT"
+
                        if [ $# -gt 0 ]; then
                                if [ $(($#%3)) -eq 0 ]; then
                                        while [ $# -gt 0 ]; do
@@ -621,10 +641,7 @@ start_mr() {
                                fi
                        fi
 
-                       echo " Current topics:"
-                       curlString="$MR_DMAAP_PATH/topics"
-                       result=$(__do_curl "$curlString")
-                       echo $result | indent2
+                       dmaap_api_print_topics
                fi
 
                __mr_export_vars
@@ -711,6 +728,15 @@ __dmaap_pipeclean() {
        return 1
 }
 
+# Helper function to list the current topics in DMAAP MR
+# args: -
+dmaap_api_print_topics() {
+       echo " Current topics:"
+       curlString="$MR_DMAAP_PATH/topics"
+       result=$(__do_curl "$curlString")
+       echo $result | indent2
+}
+
 
 ### Generic test cases for varaible checking
 
@@ -893,7 +919,7 @@ mr_api_generate_json_payload_file() {
        return 0
 }
 
-# Create tet file for payload
+# Create text file for payload
 # arg: <size-in-kb> <filename>
 mr_api_generate_text_payload_file() {
        __log_conf_start $@