Test env updates
[nonrtric.git] / test / common / mr_api_functions.sh
old mode 100644 (file)
new mode 100755 (executable)
index 0d44bdf..3569f6c
@@ -44,7 +44,7 @@ __DMAAPMR_imagesetup() {
 # <pull-policy-original> Shall be used for images that does not allow overriding
 # Both var may contain: 'remote', 'remote-remove' or 'local'
 __MR_imagepull() {
-       echo -e $RED"Image for app CR shall never be pulled from remove repo"$ERED
+       echo -e $RED"Image for app MR shall never be pulled from remote repo"$ERED
 }
 
 # Pull image from remote repo or use locally built image
@@ -53,9 +53,9 @@ __MR_imagepull() {
 # <pull-policy-original> Shall be used for images that does not allow overriding
 # Both var may contain: 'remote', 'remote-remove' or 'local'
 __DMAAPMR_imagepull() {
-       __check_and_pull_image $2 "DMAAP Message Router" $MR_DMAAP_APP_NAME $ONAP_DMAAPMR_IMAGE
-       __check_and_pull_image $2 "ZooKeeper" $MR_ZOOKEEPER_APP_NAME $ONAP_ZOOKEEPER_IMAGE
-       __check_and_pull_image $2 "Kafka" $MR_KAFKA_APP_NAME $ONAP_KAFKA_IMAGE
+       __check_and_pull_image $2 "DMAAP Message Router" $MR_DMAAP_APP_NAME ONAP_DMAAPMR_IMAGE
+       __check_and_pull_image $2 "ZooKeeper" $MR_ZOOKEEPER_APP_NAME ONAP_ZOOKEEPER_IMAGE
+       __check_and_pull_image $2 "Kafka" $MR_KAFKA_APP_NAME ONAP_KAFKA_IMAGE
 }
 
 # Build image (only for simulator or interfaces stubs owned by the test environment)
@@ -66,9 +66,13 @@ __MR_imagebuild() {
        echo " Building MR - $MR_STUB_DISPLAY_NAME - image: $MRSTUB_IMAGE"
        docker build  --build-arg NEXUS_PROXY_REPO=$NEXUS_PROXY_REPO -t $MRSTUB_IMAGE . &> .dockererr
        if [ $? -eq 0 ]; then
-               echo -e  $GREEN" Build Ok"$EGREEN
+               echo -e  $GREEN"  Build Ok"$EGREEN
+               __retag_and_push_image MRSTUB_IMAGE
+               if [ $? -ne 0 ]; then
+                       exit 1
+               fi
        else
-               echo -e $RED" Build Failed"$ERED
+               echo -e $RED"  Build Failed"$ERED
                ((RES_CONF_FAIL++))
                cat .dockererr
                echo -e $RED"Exiting...."$ERED
@@ -84,17 +88,31 @@ __DMAAPMR_imagebuild() {
 }
 
 # Generate a string for each included image using the app display name and a docker images format string
+# If a custom image repo is used then also the source image from the local repo is listed
 # arg: <docker-images-format-string> <file-to-append>
 __MR_image_data() {
        echo -e "$MR_STUB_DISPLAY_NAME\t$(docker images --format $1 $MRSTUB_IMAGE)" >>   $2
+       if [ ! -z "$MRSTUB_IMAGE_SOURCE" ]; then
+               echo -e "-- source image --\t$(docker images --format $1 $MRSTUB_IMAGE_SOURCE)" >>   $2
+       fi
 }
 
 # Generate a string for each included image using the app display name and a docker images format string
+# If a custom image repo is used then also the source image from the local repo is listed
 # arg: <docker-images-format-string> <file-to-append>
 __DMAAPMR_image_data() {
        echo -e "DMAAP Message Router\t$(docker images --format $1 $ONAP_DMAAPMR_IMAGE)" >>   $2
+       if [ ! -z "$ONAP_DMAAPMR_IMAGE_SOURCE" ]; then
+               echo -e "-- source image --\t$(docker images --format $1 $ONAP_DMAAPMR_IMAGE_SOURCE)" >>   $2
+       fi
        echo -e "ZooKeeper\t$(docker images --format $1 $ONAP_ZOOKEEPER_IMAGE)" >>   $2
+       if [ ! -z "$ONAP_ZOOKEEPER_IMAGE_SOURCE" ]; then
+               echo -e "-- source image --\t$(docker images --format $1 $ONAP_ZOOKEEPER_IMAGE_SOURCE)" >>   $2
+       fi
        echo -e "Kafka\t$(docker images --format $1 $ONAP_KAFKA_IMAGE)" >>   $2
+       if [ ! -z "$ONAP_KAFKA_IMAGE_SOURCE" ]; then
+               echo -e "-- source image --\t$(docker images --format $1 $ONAP_KAFKA_IMAGE_SOURCE)" >>   $2
+       fi
 }
 
 # Scale kubernetes resources to zero
@@ -562,9 +580,9 @@ start_mr() {
 
                        __create_topic $MR_WRITE_TOPIC "Topic for writing policy messages"
 
-                       __dmaap_pipeclean $MR_READ_TOPIC "/events/A1-POLICY-AGENT-READ" "/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=100"
+                       __dmaap_pipeclean $MR_READ_TOPIC "/events/$MR_READ_TOPIC" "/events/$MR_READ_TOPIC/users/policy-agent?timeout=1000&limit=100"
 
-                       __dmaap_pipeclean $MR_WRITE_TOPIC "/events/A1-POLICY-AGENT-WRITE" "/events/A1-POLICY-AGENT-WRITE/users/mr-stub?timeout=1000&limit=100"
+                       __dmaap_pipeclean $MR_WRITE_TOPIC "/events/$MR_WRITE_TOPIC" "/events/$MR_WRITE_TOPIC/users/mr-stub?timeout=1000&limit=100"
 
                        echo " Current topics:"
                        curlString="$MR_DMAAP_PATH/topics"