Merge "Adapt to O-RU use case spec"
[nonrtric.git] / test / common / README.md
index 2422eb9..dd64c42 100644 (file)
@@ -16,7 +16,7 @@ Cleans all services, deployments, pods, replica set etc started by the test envi
 `compare_json.py` \
 A python script to compare two json obects for equality. Note that the comparsion always sort json-arrays before comparing (that is, it does not care about the order of items within the array). In addition, the target json object may specify individual parameter values where equality is 'dont care'.
 
-`consult_cbs_function.sh` \
+`consul_cbs_function.sh` \
 Contains functions for managing Consul and CBS as well as create the configuration for the PMS.
 
 `control_panel_api_function.sh` \
@@ -49,9 +49,15 @@ Contains functions for adapting towards the ECS API
 `extract_sdnc_reply.py` \
 A python script to extract the information from an sdnc (A1 Controller) reply json. Helper for the test environment.
 
+`gateway_api_functions.sh` \
+Contains functions for managing the Non-RT RIC Gateway
+
 `http_proxy_api_functions.sh` \
 Contains functions for managing the Http Proxy
 
+`kube_proxy_api_functions.sh` \
+Contains functions for managing the Kube Proxy - to gain access to all services pod inside a kube cluster.
+
 `mr_api_functions.sh` \
 Contains functions for managing the MR Stub and the Dmaap Message Router
 
@@ -66,7 +72,7 @@ Contains functions for adapting towards the RIC (A1) simulator admin API.
 
 `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. The test cases shall be started with the file for the intended target using command line argument '--env-file'. There are preconfigured env files, pattern 'test_env*.sh', in ../common.
+Used by the auto test scripts/suites but could be used for other test script as well. The test cases shall be started with the file for the intended target using 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.
@@ -75,6 +81,47 @@ The included functions are described in detail further below.
 `testsuite_common.sh` \
 Common functions for running two or more auto test scripts as a suite.
 
+## Integration of a new applicaton
+
+Integration a new application to the test environment involves the following steps.
+
+* Choose a short name for the application. Should be a uppcase name. For example, the NonRTRIC Gateway has NGW as short name.
+This short name shall be added to the testengine_config.sh. See that file for detailed instructions.
+
+* Create a file in this directory using the pattern `<application-name>_api_functions.sh`.
+This file must implement the following functions used by the test engine. Note that functions must include the application short name in the function name. If the application does not run in kubernetes, then the last three functions in the list can be omitted.
+
+| Function |
+|--|
+| __<app-short_name>_imagesetup |
+| __<app-short_name>_imagepull |
+| __<app-short_name>_imagebuild |
+| __<app-short_name>_image_data |
+| __<app-short_name>_kube_scale_zero |
+| __<app-short_name>_kube_scale_zero_and_wait |
+| __<app-short_name>_kube_delete_all |
+
+In addition, all other functions used for testing of the application shall also be added to the file. For example functions to start the application, setting interface parameters as well as functions to send rest call towards the api of the application and validating the result.
+
+* Add the application variables to api_curl.sh. This file contains a generic function to make rest calls to an api. It also supports switching betweeen direct rest calls or rest calls via messsage router.
+
+* Create a directory beneath in the simulator-group dir. This new directory shall contain docker-compose files, config files (with or without variable substitutions) and kubernetes resource files.
+
+All docker-compose files and all kubernetes resource files need to defined special lables. These lables are used by the test enginge to identify containers and resources started and used by the test engine.
+
+| Label for docker compose | Description |
+|--|--|
+| nrttest_app | shall contain the application short name |
+| nrttest_dp  | shall be set by a variable containing the display name, a short textual description of the applicaion |
+
+| Label for kubernetes resource | Description |
+|--|--|
+| autotest | shall contain the application short name |
+
+* Add mandatory image(s) and image tag(s) to the appropriate environment files for each release in the file(s) `test_env_<system>-<release-name>`.
+In addition, all other needed environment shall also be defined in these file.
+
+
 # Description of functions in testcase_common.sh #
 
 ## Script args ##
@@ -82,7 +129,7 @@ The script can be started with these arguments
 
 | arg list |
 |--|
-| `remote|remote-remove docker|kube --env-file <environment-filename> [release] [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [--use-local-image <app-nam>+]  [--use-snapshot-image <app-nam>+] [--use-staging-image <app-nam>+] [--use-release-image <app-nam>+]` |
+| `remote|remote-remove docker|kube --env-file <environment-filename> [release] [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [--use-local-image <app-nam>+]  [--use-snapshot-image <app-nam>+] [--use-staging-image <app-nam>+] [--use-release-image <app-nam>+] [--image-repo <repo-address] [--repo-policy local|remote] [--cluster-timeout <timeout-in seconds>]` |
 
 | parameter | description |
 |-|-|
@@ -99,8 +146,18 @@ The script can be started with these arguments
 | `--use-snapshot-image` | The script will use images from the nexus snapshot repo for the supplied apps, space separated list of app short names |
 | `--use-staging-image` | The script will use images from the nexus staging repo for the supplied apps, space separated list of app short names |
 | `--use-release-image` | The script will use images from the nexus release repo for the supplied apps, space separated list of app short names |
+| `--image-repo` |  Url to optional image repo. Only locally built images will be re-tagged and pushed to this repo |
+| `-repo-policy ` |  Policy controlling which images to re-tag and push to image repo in param --image-repo. Can be set to 'local' (push on locally built images) or 'remote' (push locally built images and images from nexus repo). Default is 'local' |
+| `--cluster-timeout` |  Optional timeout for cluster where it takes time to obtain external ip/host-name. Timeout in seconds |
 | `help` | Print this info along with the test script description and the list of app short names supported |
 
+## Function: setup_testenvironment
+Main function to setup the test environment before any tests are started.
+Must be called right after sourcing all component scripts.
+| arg list |
+|--|
+| None |
+
 ## Function: indent1 ##
 Indent every line of a command output with one space char.
 | arg list |
@@ -155,16 +212,6 @@ Mark a test as a deviation from the requirements. The list of deviations will be
 | --------- | ----------- |
 | `<deviation-message-to-print>` | Any text message describing the deviation. The text will also be printed in the test report. The intention is to mark known deviations, compared to required functionality |
 
-## Function: get_kube_sim_host ##
-Translate ric name to kube host name.
-| arg list |
-|--|
-| `<ric-name>` |
-
-| parameter | description |
-| --------- | ----------- |
-| `<ric-name>` | The name of the ric to translate into a host name (ip) |
-
 ## Function: clean_environment ##
 Stop and remove all containers (docker) or resources (kubernetes). Containers not part of the test are not affected (docker only). Removes all resources started by previous kube tests (kube only).
 | arg list |
@@ -188,37 +235,12 @@ Make the script sleep for a number of seconds.
 | `<sleep-time-in-sec> ` | Number of seconds to sleep |
 | `<any-text-in-quotes-to-be-printed>` | Optional. The text will be printed, if present |
 
-## Function: generate_uuid ##
-Geneate a UUID prefix to use along with the policy instance number when creating/deleting policies. Sets the env var UUID.
-UUID is then automatically added to the policy id in GET/PUT/DELETE.
-| arg list |
-|--|
-| None |
-
-## Function: check_policy_agent_logs ##
-Check the Policy Agent log for any warnings and errors and print the count of each.
-| arg list |
-|--|
-| None |
-
-## Function: check_ecs_logs ##
-Check the ECS log for any warnings and errors and print the count of each.
-| arg list |
-|--|
-| None |
-
 ## Function: check_control_panel_logs ##
 Check the Control Panel log for any warnings and errors and print the count of each.
 | arg list |
 |--|
 | None |
 
-## Function: check_sdnc_logs ##
-Check the SDNC log for any warnings and errors and print the count of each.
-| arg list |
-|--|
-| None |
-
 ## Function: store_logs ##
 Take a snap-shot of all logs for all running containers and stores them in `./logs/<ATC-id>`. All logs will get the specified prefix in the file name. In general, one of the last steps in an auto-test script shall be to call this function. If logs shall be taken several times during a test script, different prefixes shall be used each time.
 | arg list |
@@ -313,6 +335,13 @@ Configure the Policy Agent to make upto 5 retries if an API calls return any of
 |--|
 | `[<response-code>]*` |
 
+
+## Function: check_policy_agent_logs ##
+Check the Policy Agent log for any warnings and errors and print the count of each.
+| arg list |
+|--|
+| None |
+
 ## Function: api_equal() ##
 
 Tests if the array length of a json array in the Policy Agent simulator is equal to a target value.
@@ -727,7 +756,7 @@ Test of GET '/v2/configuration'
 | `[<response-code>]*` | A space separated list of http response codes, may be empty to reset to 'no codes'.  |
 
 
-# Description of functions in consult_cbs_function.sh #
+# Description of functions in consul_cbs_function.sh #
 
 
 ## Function: consul_config_app ##
@@ -799,6 +828,12 @@ Start the SDNC A1 Controller container and its database container
 |--|
 | None |
 
+## Function: check_sdnc_logs ##
+Check the SDNC log for any warnings and errors and print the count of each.
+| arg list |
+|--|
+| None |
+
 ## Function: controller_api_get_A1_policy_ids ##
 Test of GET policy ids towards OSC or STD type simulator.
 To test response code only, provide the response code, 'OSC' + policy type or 'STD'
@@ -970,8 +1005,14 @@ Start the ECS container in docker or kube depending on running mode.
 |--|
 | None |
 
-## Function: restart_ecs ##
-Restart the ECS container.
+## Function: stop_ecs ##
+Stop the ECS container.
+| arg list |
+|--|
+| None |
+
+## Function: start_stopped_ecs ##
+Start a previously stopped ecs.
 | arg list |
 |--|
 | None |
@@ -988,7 +1029,11 @@ Configure the ECS log on trace level. The ECS must be running.
 |--|
 | None |
 
-# Description of functions in ecs_api_function.sh #
+## Function: check_ecs_logs ##
+Check the ECS log for any warnings and errors and print the count of each.
+| arg list |
+|--|
+| None |
 
 ## Function: ecs_equal ##
 Tests if a variable value in the ECS is equal to a target value.
@@ -1275,15 +1320,101 @@ Test of GET '/status'.
 | `<response-code>` | Expected http response code |
 | `<type>` | Type id, if the interface supports type in url |
 
+# Description of functions in gateway_api_functions.sh #
+
+
+## Function: use_gateway_http ##
+Use http for all calls to the gateway. This is set by default.
+| arg list |
+|--|
+| None |
+
+## Function: use_gateway_https ##
+Use https for all calls to the gateway.
+| arg list |
+|--|
+| None |
+
+## Function: set_gateway_debug ##
+Set debug level logging in the gateway
+| arg list |
+|--|
+| None |
+
+## Function: set_gateway_trace ##
+Set debug level logging in the trace
+| arg list |
+|--|
+| None |
+
+## Function: start_gateway ##
+Start the the gateway container in docker or kube depending on start mode
+| arg list |
+|--|
+| None |
+
+## Function: gateway_pms_get_status ##
+Sample test of pms api (status)
+| arg list |
+|--|
+| `<response-code> ` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<response-code>` | Expected http response code |
+
+## Function: gateway_ecs_get_types ##
+Sample test of ecs api (get ei type)
+Only response code tested - not payload
+| arg list |
+|--|
+| `<response-code> ` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<response-code>` | Expected http response code |
 
 # Description of functions in http_proxy_api_functions.sh #
 
+## Function: use_http_proxy_http ##
+Use http for all proxy requests. Note that this only applicable to the actual proxy request, the proxied protocol can still be http and https.
+| arg list |
+|--|
+| None |
+
+## Function: use_http_proxy_https ##
+Use https for all proxy requests. Note that this only applicable to the actual proxy request, the proxied protocol can still be http and https.
+| arg list |
+|--|
+| None |
+
 ## Function: start_http_proxy ##
 Start the http proxy container in docker or kube depending on running mode.
 | arg list |
 |--|
 | None |
 
+# Description of functions in kube_proxy_api_functions.sh #
+
+## Function: use_kube_proxy_http ##
+Use http for all proxy requests. Note that this only applicable to the actual proxy request, the proxied protocol can still be http and https.
+| arg list |
+|--|
+| None |
+
+## Function: use_kube_proxy_https ##
+Use https for all proxy requests. Note that this only applicable to the actual proxy request, the proxied protocol can still be http and https.
+| arg list |
+|--|
+| None |
+
+## Function: start_kube_proxy ##
+Start the kube proxy container in kube. This proxy enabled the test env to access all services and pods in a kube cluster.
+No proxy is started if the function is called in docker mode.
+| arg list |
+|--|
+| None |
+
 # Description of functions in mr_api_functions.sh #
 
 ## Function: use_mr_http ##
@@ -1612,6 +1743,23 @@ Start a group of simulator where a group may contain 1 more simulators. Started
 |`<count>`| And integer, 1 or greater. Specifies the number of simulators to start|
 |`<interface-id>`| Shall be the interface id of the simulator. See the repo 'a1-interface' for the available ids. |
 
+## Function: get_kube_sim_host ##
+Translate ric name to kube host name.
+| arg list |
+|--|
+| `<ric-name>` |
+
+| parameter | description |
+| --------- | ----------- |
+| `<ric-name>` | The name of the ric to translate into a host name (ip) |
+
+## Function: generate_policy_uuid ##
+Geneate a UUID prefix to use along with the policy instance number when creating/deleting policies. Sets the env var UUID.
+UUID is then automatically added to the policy id in GET/PUT/DELETE.
+| arg list |
+|--|
+| None |
+
 ## Function: sim_equal ##
 Tests if a variable value in the RIC simulator is equal to a target value.
 Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.