Enhancements of the test env and test scripts
Change-Id: I14af2b53ec3d31d25956ddd02b5a378b3606539b
Issue-ID: NONRTRIC-289
Signed-off-by: BjornMagnussonXA <bjorn.magnusson@est.tech>
Change-Id: I0b10c13f574c3437185798613b1f64bded152117
diff --git a/test/auto-test/FTC150.sh b/test/auto-test/FTC150.sh
index 1cd2a33..3e13bf5 100755
--- a/test/auto-test/FTC150.sh
+++ b/test/auto-test/FTC150.sh
@@ -32,65 +32,77 @@
generate_uuid
#Test agent and simulator protocol versions (others are http only)
-TESTED_PROTOCOLS="HTTP HTTPS"
+NB_TESTED_PROTOCOLS="HTTP HTTPS"
+SB_TESTED_PROTOCOLS="HTTP HTTPS"
-for __httpx in $TESTED_PROTOCOLS ; do
+for __nb_httpx in $NB_TESTED_PROTOCOLS ; do
+ for __sb_httpx in $SB_TESTED_PROTOCOLS ; do
- echo "#####################################################################"
- echo "#####################################################################"
- echo "### Testing SDNC using: $__httpx"
- echo "#####################################################################"
- echo "#####################################################################"
+ echo "#####################################################################"
+ echo "#####################################################################"
+ echo "### Testing SDNC using Northbound: $__nb_httpx and Southbound: $__sb_httpx"
+ echo "#####################################################################"
+ echo "#####################################################################"
- # Clean container and start all needed containers #
- clean_containers
+ # Clean container and start all needed containers #
+ clean_containers
- start_ric_simulators ricsim_g1 1 OSC_2.1.0
- start_ric_simulators ricsim_g2 1 STD_1.1.3
+ start_ric_simulators ricsim_g1 1 OSC_2.1.0
+ start_ric_simulators ricsim_g2 1 STD_1.1.3
- start_sdnc
+ start_sdnc
- if [ $__httpx == "HTTPS" ]; then
- # "Using secure ports towards SDNC"
- use_sdnc_https
- else
- #"Using non-secure ports towards SDNC"
- use_sdnc_http
- fi
+ if [ $__nb_httpx == "HTTPS" ]; then
+ # "Using secure ports towards SDNC"
+ use_sdnc_https
+ else
+ #"Using non-secure ports towards SDNC"
+ use_sdnc_http
+ fi
- # API tests
+ if [ $__sb_httpx == "HTTPS" ]; then
+ # "Using secure ports towards SDNC"
+ use_simulator_https
+ else
+ #"Using non-secure ports towards SDNC"
+ use_simulator_http
+ fi
- controller_api_get_A1_policy_type 404 OSC ricsim_g1_1 1
+ # API tests
- sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
+ controller_api_get_A1_policy_type 404 OSC ricsim_g1_1 1
+
+ sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
- controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1
- controller_api_get_A1_policy_ids 200 STD ricsim_g2_1
+ controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1
+ controller_api_get_A1_policy_ids 200 STD ricsim_g2_1
- controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1
- controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1 testdata/OSC/sim_1.json
- controller_api_get_A1_policy_type 404 OSC ricsim_g1_1 99
+ controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1
+ controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1 testdata/OSC/sim_1.json
+ controller_api_get_A1_policy_type 404 OSC ricsim_g1_1 99
- controller_api_put_A1_policy 202 OSC ricsim_g1_1 1 4000 testdata/OSC/pi1_template.json
- controller_api_put_A1_policy 404 OSC ricsim_g1_1 5 1001 testdata/OSC/pi1_template.json
- controller_api_put_A1_policy 201 STD ricsim_g2_1 5000 testdata/STD/pi1_template.json
+ controller_api_put_A1_policy 202 OSC ricsim_g1_1 1 4000 testdata/OSC/pi1_template.json
+ controller_api_put_A1_policy 404 OSC ricsim_g1_1 5 1001 testdata/OSC/pi1_template.json
+ controller_api_put_A1_policy 201 STD ricsim_g2_1 5000 testdata/STD/pi1_template.json
- controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1 4000
- controller_api_get_A1_policy_ids 200 STD ricsim_g2_1 5000
+ controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1 4000
+ controller_api_get_A1_policy_ids 200 STD ricsim_g2_1 5000
- controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000
- controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000
+ controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000
+ controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000
- VAL='NOT IN EFFECT'
- controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000 "$VAL" "false"
- controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000 "UNDEFINED"
+ VAL='NOT IN EFFECT'
+ controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000 "$VAL" "false"
+ controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000 "UNDEFINED"
- controller_api_delete_A1_policy 202 OSC ricsim_g1_1 1 4000
- controller_api_delete_A1_policy 204 STD ricsim_g2_1 5000
+ controller_api_delete_A1_policy 202 OSC ricsim_g1_1 1 4000
+ controller_api_delete_A1_policy 204 STD ricsim_g2_1 5000
- store_logs $__httpx
+ store_logs "NB_"$__nb_httpx"_SB_"$__sb_httpx
+
+ done
done
diff --git a/test/auto-test/README.md b/test/auto-test/README.md
index 8c8ffd0..0429e36 100644
--- a/test/auto-test/README.md
+++ b/test/auto-test/README.md
@@ -1,43 +1,31 @@
+## Overview
+The bash scripts in this dir are intended for function test of the Non-RT RIC in different configurations, using simulators when needed for the external interfaces.
+A few of the bash scripts are so called 'suites', These suite scripts calls a sequence of the other bash scripts.
-## Automated test Description
-This auto-test repo stores test script for automated test cases for Policy Agent.
-Each of the testcase script will bring up a containerized test enviroment for Policy Agent,
-CBS, consul, and simulator(TBD).
+## Automated test scripts
+There are two types of scripts, filenames in the format FTCXXX.sh test one or more components of the Non-RT RIC. Filenames in the format SuiteZZZZ.sh tests a number of FTCXXX.sh script as one suite. (XXX is an integer selected from the categories described further below).
+FTC is short for Function Test Case.
-### Overview
+The requirements, in terms of the execution enviroment, to run a script or a suite is to have docker, docker-compose and python3 installed (the scripts warns if not installed).
+The scripts have been tested to work on both MacOS and Ubuntu. They should work also in git bash on windows but not yet verified.
-Right now, test cases are written in bash scripts. \
-Each test case script(ex. `FTC1.sh)` will call functions defined in `../common`. \
-The environment vriables are set in`test_env.sh`. \
-The automated test support both local build Policy Agent image testing and remote image stored in Nexus.
-```
-# Local image
-export POLICY_AGENT_LOCAL_IMAGE=o-ran-sc/nonrtric-policy-agent
-# Remote image
-export POLICY_AGENT_REMOTE_IMAGE=nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent
-```
-### Test Cases Description(more TBD)
-`FTC1.sh`: Test policy-agent can refresh configurations from consul
+## Configuration
+The test scripts uses configuration from a single file, found in `../common/test_env.sh`, which contains all needed configuration in terms of image names, image tags, ports, file paths, passwords etc. This file can be modified if needed. See the README.md in `../common/` for all details of the config file.
-### Logs
-All log files are stored at `logs/<testcase id>`. \
-The logs include the application.log and the container log from Policy Agent, the container logs from each simulator and the
-test case log (same as the screen output). \
-In the test cases the logs are stored with a prefix so the logs can be stored at different steps during the test.
-All test cases contains an entry to save all logs with prefix 'END' at the end of each test case.
+## How to run
+A test script, for example FTC1, is executed from the cmd line using the script filename and one or more parameters:
-### Manual
-Test case command:
-```
-./<testcase-id>.sh local | remote
+ ./FTC1.sh remote.
-Discription:
-local: test image: POLICY_AGENT_LOCAL_IMAGE=o-ran-sc/nonrtric-policy-agent
-remote: test image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent
+See the README.md in `../common/` for all details about available parameters and their meaning.
-```
+Each test script prints out the overall result of the tests in the end of the execution.
-### Test case categories
+The test scripts produce quite a number of logs; all container logs, a log of all http/htps calls from the test scripts including the payload, some configuration created during test and also a test case log (same as what is printed on the screen during execution). All these logs are stored in `logs/FTCXXX/`. So each test script is using its own log directory.
+
+## Test case categories
+The test script are number using these basic categories.
+
1-99 - Basic sanity tests
100-199 - API tests
@@ -50,22 +38,23 @@
Suites
-### Test case file
-A test case file contains a number of steps to verify a certain functionality.
-A description of the test case should be given to the ``TC_ONELINE_DESCR`` var. The description will be printed in
-the test result.
+To get an overview of the available test scripts, use the following command to print the test script description:
+'grep ONELINE *.sh' in the dir of the test scripts.
-The empty template for a test case files looks like this:
-
-(Only the parts noted with < and > shall be changed.)
+## Test case file - template
+A test script contains a number of steps to verify a certain functionality.
+The empty template for a test case file looks like this.
+Only the parts noted with < and > shall be changed.
+It is strongly suggested to look at the existing test scripts, it is probably easier to copy an existing test script instead of creating one from scratch. The README.md in `../common/` describes the functions available in the test script in detail.
-----------------------------------------------------------
```
-#!/usr/bin/env bash
+#!/bin/bash
TC_ONELINE_DESCR="<test case description>"
-. ../common/testcase_common.sh $1
+. ../common/testcase_common.sh $@
+< other scripts need to be sourced for specific interfaces>
#### TEST BEGIN ####
@@ -80,8 +69,6 @@
```
-----------------------------------------------------------
-The ../common/testcase_common.sh contains all functions needed for the test case file. See the README.md file in
-the ../common dir for a description of all available functions.
## License
diff --git a/test/common/README.md b/test/common/README.md
index 73ced4b..09e8e22 100644
--- a/test/common/README.md
+++ b/test/common/README.md
@@ -6,7 +6,7 @@
`test_env.sh` \
Common env variables for test in the auto-test dir. All configuration of port numbers, image names and version etc shall be made in this file.
-Used by the auto test scripts/suites but could be used for other test script as well.
+Used by the auto test scripts/suites but could be used for other test script as well. It is possible to configure a test case with a different file using the command line argument '--env-file'.
`testcase_common.sh` \
Common functions for auto test cases in the auto-test dir. This script is the foundation of test auto environment which sets up images and enviroment variables needed by this script as well as the script adapting to the APIs.
@@ -54,7 +54,7 @@
| arg list |
|--|
-| `local|remote|remote-remove [auto-clean] [--stop-at-error] [--use-local-image <app-nam> [<app-name>]*]` |
+| `local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [ --env-file <environment-filename> ] [--use-local-image <app-nam> [<app-name>]*]` |
| parameter | description |
|-|-|
@@ -63,8 +63,10 @@
| `remote-remove` | same as remote but all images are removed first so that fresh images are pulled when running |
| `auto-clean` | all containers will be automatically stopped and removed when the test case is complete. Requires the function 'auto_clean_containers' to be included last in the applicable auto-test script |
| `--stop-at-error` | intended for debugging and make the script stop at first 'FAIL' and save all logs with a prefix 'STOP_AT_ERROR' |
-| `--use-local-image <app-nam> [<app-name>]*` | nnly applicable when running as 'remote' or 'remote-remove'. Mainly for debugging when a locally built image shall be used together with other remote images from nexus.Accepts a space separated list of PA, CP, RICSIM, SDNC for Policy Agent, Control Panel, A1-controller and the Ric simulator |
| `--ricsim-prefix <prefix>` | use another prefix for the ric simulator container name than the standard 'ricsim'. Note that the testscript has to read and use the env var `$RIC_SIM_PREFIX` instead of a hardcoded name of the ric(s). |
+| `--env-file` | point to a different file with environment variables, instead of the default 'test_env.sh' |
+| `--use-local-image <app-nam> [<app-name>]*` | nnly applicable when running as 'remote' or 'remote-remove'. Mainly for debugging when a locally built image shall be used together with other remote images from nexus.Accepts a space separated list of PA, CP, RICSIM, SDNC for Policy Agent, Control Panel, A1-controller and the Ric simulator |
+
#### Function: print_result ####
Print a test report of an auto-test script.
diff --git a/test/common/controller_api_functions.sh b/test/common/controller_api_functions.sh
index e33c619..378a6d4 100644
--- a/test/common/controller_api_functions.sh
+++ b/test/common/controller_api_functions.sh
@@ -79,10 +79,10 @@
paramError=1
if [ $# -gt 3 ] && [ $2 == "OSC" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies"
+ url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/a1-p/policytypes/$4/policies"
paramError=0
elif [ $# -gt 2 ] && [ $2 == "STD" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies"
+ url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/A1-P/v1/policies"
paramError=0
fi
@@ -150,7 +150,7 @@
paramError=1
if [ $# -gt 3 ] && [ $2 == "OSC" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4"
+ url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/a1-p/policytypes/$4"
paramError=0
fi
@@ -209,10 +209,10 @@
paramError=1
if [ $# -eq 5 ] && [ $2 == "OSC" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$UUID$5"
+ url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/a1-p/policytypes/$4/policies/$UUID$5"
paramError=0
elif [ $# -eq 4 ] && [ $2 == "STD" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$UUID$4"
+ url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/A1-P/v1/policies/$UUID$4"
paramError=0
fi
@@ -254,12 +254,12 @@
paramError=1
if [ $# -eq 6 ] && [ $2 == "OSC" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$UUID$5"
+ url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/a1-p/policytypes/$4/policies/$UUID$5"
body=$(sed 's/XXX/'${5}'/g' $6)
paramError=0
elif [ $# -eq 5 ] && [ $2 == "STD" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$UUID$4"
+ url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/A1-P/v1/policies/$UUID$4"
body=$(sed 's/XXX/'${4}'/g' $5)
paramError=0
fi
@@ -304,7 +304,7 @@
targetJson=""
paramError=1
if [ $# -ge 5 ] && [ $2 == "OSC" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/a1-p/policytypes/$4/policies/$UUID$5/status"
+ url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/a1-p/policytypes/$4/policies/$UUID$5/status"
if [ $# -gt 5 ]; then
targetJson="{\"instance_status\":\"$6\""
targetJson=$targetJson",\"has_been_deleted\":\"$7\""
@@ -312,7 +312,7 @@
fi
paramError=0
elif [ $# -ge 4 ] && [ $2 == "STD" ]; then
- url="http://$3:$RIC_SIM_INTERNAL_PORT/A1-P/v1/policies/$UUID$4/status"
+ url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/A1-P/v1/policies/$UUID$4/status"
if [ $# -gt 4 ]; then
targetJson="{\"enforceStatus\":\"$5\""
if [ $# -eq 6 ]; then
diff --git a/test/common/test_env.sh b/test/common/test_env.sh
index 391b596..8417ece 100755
--- a/test/common/test_env.sh
+++ b/test/common/test_env.sh
@@ -146,6 +146,7 @@
export SDNC_EXTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container external securee port (host -> container)
export SDNC_INTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container internal secure port (container -> container)
export SDNC_DB_APP_NAME="sdnc-db" # Name of the SDNC DB container
+export SDNC_A1_TRUSTSTORE_PASSWORD="" # SDNC truststore password
SDNC_USER="admin" # SDNC username
SDNC_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # SNDC PWD
SDNC_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for SNDC API
diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh
index a69df91..39a593c 100755
--- a/test/common/testcase_common.sh
+++ b/test/common/testcase_common.sh
@@ -18,7 +18,7 @@
#
# This is a script that contains all the functions needed for auto test
-# Arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [--use-local-image <app-nam> [<app-name>]*]
+# Arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [ --env-file <environment-filename> ] [--use-local-image <app-nam> [<app-name>]*]
#Formatting for 'echo' cmd
@@ -52,37 +52,11 @@
# Just resetting any previous echo formatting...
echo -ne $EBOLD
-# source test environment variables
-. ../common/test_env.sh
+# default test environment variables
+TEST_ENV_VAR_FILE="../common/test_env.sh"
echo "Test case started as: ${BASH_SOURCE[$i+1]} "$@
-#Vars for A1 interface version and container count
-G1_A1_VERSION=""
-G2_A1_VERSION=""
-G3_A1_VERSION=""
-G1_COUNT=0
-G2_COUNT=0
-G3_COUNT=0
-
-# Vars to switch between http and https. Extra curl flag needed for https
-export RIC_SIM_HTTPX="http"
-export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
-export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT
-export RIC_SIM_CERT_MOUNT_DIR="./cert"
-
-export MR_HTTPX="http"
-export MR_PORT=$MR_INTERNAL_PORT
-export MR_LOCAL_PORT=$MR_EXTERNAL_PORT #When agent is running outside the docker net
-
-export CR_HTTPX="http"
-export CR_PORT=$CR_INTERNAL_PORT
-export CR_LOCAL_PORT=$CR_EXTERNAL_PORT #When CR is running outside the docker net
-
-export SDNC_HTTPX="http"
-export SDNC_PORT=$SDNC_INTERNAL_PORT
-export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_PORT #When agent is running outside the docker net
-
#Localhost constant
LOCALHOST="http://localhost:"
@@ -220,6 +194,19 @@
fi
fi
if [ $paramerror -eq 0 ]; then
+ if [ "$1" == "--env-file" ]; then
+ shift;
+ TEST_ENV_VAR_FILE=$1
+ if [ -z "$1" ]; then
+ paramerror=1
+ else
+ echo "Option set - Overriding test_env.sh with: "$1
+ shift;
+ foundparm=0
+ fi
+ fi
+ fi
+ if [ $paramerror -eq 0 ]; then
if [ "$1" == "--use-local-image" ]; then
USE_LOCAL_IMAGES=""
shift
@@ -247,10 +234,45 @@
fi
if [ $paramerror -eq 1 ]; then
- echo -e $RED"Expected arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [--use-local-image <app-nam> [<app-name>]*]"$ERED
+ echo -e $RED"Expected arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [ --env-file <environment-filename> ] [--use-local-image <app-nam> [<app-name>]*]"$ERED
exit 1
fi
+# sourcing the selected env variables for the test case
+if [ -f "$TEST_ENV_VAR_FILE" ]; then
+ echo -e $BOLD"Sourcing env vars from: "$TEST_ENV_VAR_FILE$EBOLD
+ . $TEST_ENV_VAR_FILE
+else
+ echo -e $RED"Selected env var fle does not exist: "$TEST_ENV_VAR_FILE$ERED
+ exit 1
+fi
+
+#Vars for A1 interface version and container count
+G1_A1_VERSION=""
+G2_A1_VERSION=""
+G3_A1_VERSION=""
+G1_COUNT=0
+G2_COUNT=0
+G3_COUNT=0
+
+# Vars to switch between http and https. Extra curl flag needed for https
+export RIC_SIM_HTTPX="http"
+export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:"
+export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT
+export RIC_SIM_CERT_MOUNT_DIR="./cert"
+
+export MR_HTTPX="http"
+export MR_PORT=$MR_INTERNAL_PORT
+export MR_LOCAL_PORT=$MR_EXTERNAL_PORT #When agent is running outside the docker net
+
+export CR_HTTPX="http"
+export CR_PORT=$CR_INTERNAL_PORT
+export CR_LOCAL_PORT=$CR_EXTERNAL_PORT #When CR is running outside the docker net
+
+export SDNC_HTTPX="http"
+export SDNC_PORT=$SDNC_INTERNAL_PORT
+export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_PORT #When agent is running outside the docker net
+
echo -e $BOLD"Checking configured image setting for this test case"$EBOLD
#Temp var to check for image variable name errors
diff --git a/test/simulator-group/sdnc/docker-compose.yml b/test/simulator-group/sdnc/docker-compose.yml
index 31b4e2b..f835504 100644
--- a/test/simulator-group/sdnc/docker-compose.yml
+++ b/test/simulator-group/sdnc/docker-compose.yml
@@ -13,12 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==================================================================================
-version: '2.1'
+version: '3'
networks:
default:
- driver: bridge
- name: ${DOCKER_SIM_NWNAME}
+ external:
+ name: ${DOCKER_SIM_NWNAME}
services:
db:
@@ -55,6 +55,7 @@
environment:
- MYSQL_ROOT_PASSWORD=openECOMP1.0
- SDNC_CONFIG_DIR=/opt/onap/sdnc/data/properties
+ - A1_TRUSTSTORE_PASSWORD=${SDNC_A1_TRUSTSTORE_PASSWORD}
logging:
driver: "json-file"
options: