Merge "Adapt to O-RU use case spec"
[nonrtric.git] / test / common / rapp_catalogue_api_functions.sh
index 777b9d3..254883e 100644 (file)
 
 # This is a script that contains container/service managemnt functions test functions for RAPP Catalogue API
 
+################ Test engine functions ################
+
+# Create the image var used during the test
+# arg: [<image-tag-suffix>] (selects staging, snapshot, release etc)
+# <image-tag-suffix> is present only for images with staging, snapshot,release tags
+__RC_imagesetup() {
+       __check_and_create_image_var RC "RAPP_CAT_IMAGE" "RAPP_CAT_IMAGE_BASE" "RAPP_CAT_IMAGE_TAG" $1 "$RAPP_CAT_DISPLAY_NAME"
+}
+
+# Pull image from remote repo or use locally built image
+# arg: <pull-policy-override> <pull-policy-original>
+# <pull-policy-override> Shall be used for images allowing overriding. For example use a local image when test is started to use released images
+# <pull-policy-original> Shall be used for images that does not allow overriding
+# Both arg var may contain: 'remote', 'remote-remove' or 'local'
+__RC_imagepull() {
+       __check_and_pull_image $1 "$c" $RAPP_CAT_APP_NAME RAPP_CAT_IMAGE
+}
+
+# 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>
+__RC_image_data() {
+       echo -e "$RAPP_CAT_DISPLAY_NAME\t$(docker images --format $1 $RAPP_CAT_IMAGE)" >>   $2
+       if [ ! -z "$RAPP_CAT_IMAGE_SOURCE" ]; then
+               echo -e "-- source image --\t$(docker images --format $1 $RAPP_CAT_IMAGE_SOURCE)" >>   $2
+       fi
+}
+
+# Scale kubernetes resources to zero
+# All resources shall be ordered to be scaled to 0, if relevant. If not relevant to scale, then do no action.
+# This function is called for apps fully managed by the test script
+__RC_kube_scale_zero() {
+       __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest RC
+}
+
+# Scale kubernetes resources to zero and wait until this has been accomplished, if relevant. If not relevant to scale, then do no action.
+# This function is called for prestarted apps not managed by the test script.
+__RC_kube_scale_zero_and_wait() {
+       __kube_scale_and_wait_all_resources $KUBE_NONRTRIC_NAMESPACE app nonrtric-rappcatalogueservice
+       __kube_scale_all_resources $KUBE_NONRTRIC_NAMESPACE autotest RC
+}
+
+# Delete all kube resouces for the app
+# This function is called for apps managed by the test script.
+__RC_kube_delete_all() {
+       __kube_delete_all_resources $KUBE_NONRTRIC_NAMESPACE autotest RC
+}
+
+# Store docker logs
+# This function is called for apps managed by the test script.
+# args: <log-dir> <file-prexix>
+__RC_store_docker_logs() {
+       docker logs $RAPP_CAT_APP_NAME > $1$2_rc.log 2>&1
+}
+
+#######################################################
+
 ## Access to RAPP Catalogue
 # Host name may be changed if app started by kube
 # Direct access from script
@@ -154,7 +211,9 @@ start_rapp_catalogue() {
         export RAPP_CAT_EXTERNAL_SECURE_PORT
         export DOCKER_SIM_NWNAME
 
-               __start_container $RAPP_CAT_COMPOSE_DIR NODOCKERARGS 1 $RAPP_CAT_APP_NAME
+               export RAPP_CAT_DISPLAY_NAME
+
+               __start_container $RAPP_CAT_COMPOSE_DIR "" NODOCKERARGS 1 $RAPP_CAT_APP_NAME
 
                __check_service_start $RAPP_CAT_APP_NAME $RC_PATH$RAPP_CAT_ALIVE_URL
        fi