X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fcommon%2Fcr_api_functions.sh;h=134f50c30793ce5ff50db1796505fb8afb401d56;hb=02a72fd14966d3a7f26e6ef93f1a045607348f14;hp=bf490fc0212ea7791df0bebe413fe194bd511ebe;hpb=f0019c8168b9d59f132ba47e939e8aa3ef324b7d;p=nonrtric.git diff --git a/test/common/cr_api_functions.sh b/test/common/cr_api_functions.sh index bf490fc0..134f50c3 100644 --- a/test/common/cr_api_functions.sh +++ b/test/common/cr_api_functions.sh @@ -19,6 +19,86 @@ # This is a script that contains container/service managemnt functions test functions for the Callback Reciver + +################ Test engine functions ################ + +# Create the image var used during the test +# arg: (selects staging, snapshot, release etc) +# is present only for images with staging, snapshot,release tags +__CR_imagesetup() { + __check_and_create_image_var CR "CR_IMAGE" "CR_IMAGE_BASE" "CR_IMAGE_TAG" LOCAL "$CR_DISPLAY_NAME" +} + +# Pull image from remote repo or use locally built image +# arg: +# Shall be used for images allowing overriding. For example use a local image when test is started to use released images +# Shall be used for images that does not allow overriding +# Both var may contain: 'remote', 'remote-remove' or 'local' +__CR_imagepull() { + echo -e $RED" Image for app CR shall never be pulled from remote repo"$ERED +} + +# Build image (only for simulator or interfaces stubs owned by the test environment) +# arg: (selects staging, snapshot, release etc) +# is present only for images with staging, snapshot,release tags +__CR_imagebuild() { + cd ../cr + echo " Building CR - $CR_DISPLAY_NAME - image: $CR_IMAGE" + docker build --build-arg NEXUS_PROXY_REPO=$NEXUS_PROXY_REPO -t $CR_IMAGE . &> .dockererr + if [ $? -eq 0 ]; then + echo -e $GREEN" Build Ok"$EGREEN + __retag_and_push_image CR_IMAGE + if [ $? -ne 0 ]; then + exit 1 + fi + else + echo -e $RED" Build Failed"$ERED + ((RES_CONF_FAIL++)) + cat .dockererr + echo -e $RED"Exiting...."$ERED + exit 1 + 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: +__CR_image_data() { + echo -e "$CR_DISPLAY_NAME\t$(docker images --format $1 $CR_IMAGE)" >> $2 + if [ ! -z "$CR_IMAGE_SOURCE" ]; then + echo -e "-- source image --\t$(docker images --format $1 $CR_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 +__CR_kube_scale_zero() { + __kube_scale_all_resources $KUBE_SIM_NAMESPACE autotest CR +} + +# 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. +__CR_kube_scale_zero_and_wait() { + echo -e $RED" CR app is not scaled in this state"$ERED +} + +# Delete all kube resouces for the app +# This function is called for apps managed by the test script. +__CR_kube_delete_all() { + __kube_delete_all_resources $KUBE_SIM_NAMESPACE autotest CR +} + +# Store docker logs +# This function is called for apps managed by the test script. +# args: +__CR_store_docker_logs() { + docker logs $CR_APP_NAME > $1$2_cr.log 2>&1 +} + +####################################################### + + ## Access to Callback Receiver # Host name may be changed if app started by kube # Direct access from script @@ -182,8 +262,9 @@ start_cr() { export CR_INTERNAL_SECURE_PORT export CR_EXTERNAL_SECURE_PORT export DOCKER_SIM_NWNAME + export CR_DISPLAY_NAME - __start_container $CR_COMPOSE_DIR NODOCKERARGS 1 $CR_APP_NAME + __start_container $CR_COMPOSE_DIR "" NODOCKERARGS 1 $CR_APP_NAME __check_service_start $CR_APP_NAME $CR_PATH$CR_ALIVE_URL fi