aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/datafilecollector-testharness/common
diff options
context:
space:
mode:
authormaximesson <maxime.bonneau@est.tech>2019-08-30 14:05:15 +0000
committerDaniel Rose <dr695h@att.com>2019-09-09 14:55:34 +0000
commit69311bf8082471be45574c9a99b23e31e606669c (patch)
treec005c78aca429a7f09806de6a610b0b03e32de21 /test/mocks/datafilecollector-testharness/common
parent6a5ec681a93a0ddf55080f164187791ed92578be (diff)
Updated README files and adaptation of consul/cbs config
Change-Id: I81494f56978a3d0ff06ec0d66968f33f08114103 Issue-ID: DCAEGEN2-1719 Signed-off-by: maximesson <maxime.bonneau@est.tech>
Diffstat (limited to 'test/mocks/datafilecollector-testharness/common')
-rw-r--r--test/mocks/datafilecollector-testharness/common/README.md212
-rw-r--r--test/mocks/datafilecollector-testharness/common/test_env.sh52
-rwxr-xr-xtest/mocks/datafilecollector-testharness/common/testcase_common.sh40
3 files changed, 253 insertions, 51 deletions
diff --git a/test/mocks/datafilecollector-testharness/common/README.md b/test/mocks/datafilecollector-testharness/common/README.md
index b5cda65ef..bcd345739 100644
--- a/test/mocks/datafilecollector-testharness/common/README.md
+++ b/test/mocks/datafilecollector-testharness/common/README.md
@@ -7,4 +7,214 @@ Common env variables for test in the auto-test dir. Used by the auto test cases/
Common functions for auto test cases in the auto-test dir. A subset of the functions could be used in other test scripts as well.
**testsuite_common.sh**</br>
-Common functions for auto test suites in the auto-test dir. \ No newline at end of file
+Common functions for auto test suites in the auto-test dir.
+
+##Descriptions of functions in testcase_common.sh
+
+The following is a list of the available functions in a test case file. Please see some of the defined test cases for examples.
+
+**log_sim_settings**</br>
+Print the env variables needed for the simulators and their setup
+
+**clean_containers**</br>
+Stop and remove all containers including dfc apps and simulators
+
+**start_simulators**</br>
+Start all simulators in the simulator group
+
+**start_dfc <dfc-instance-id>**</br>
+Start the dfc application. The arg shall be an integer from 0 to 5 representing the dfc instance to start. DFC app will get a name like 'dfc_app0' to 'dfc_app4'.
+
+**kill_dfc <dfc-instance-id> **</br>
+Stop and remove the dfc app container with the instance id.
+
+**consul_config_app <dfc-instance-id> <json-file-path>**</br>
+Configure consul with json file with app config for a dfc instance using the dfc instance id and the json file.
+
+**consul_config_dmaap <dfc-instance-id> <json-file-path>**</br>
+Configure consul with json file with dmaap config for a dfc instance using the dfc instance id and the json file.
+
+**kill_dr**</br>
+Stop and remove the DR simulator container
+
+**kill_drr**</br>
+Stop and remove the DR redir simulator container
+
+**kill_mr**</br>
+Stop and remove the MR simulator container
+
+**kill_sftp <sftp-instance-id>**</br>
+Stop and remove a SFTP container with the supplied instance id (0-5).
+
+**stop_sftp <sftp-instance-id>**</br>
+Stop a SFTP container with the supplied instance id (0-5).
+
+**start_sftp <sftp-instance-id>**</br>
+Start a previously stopped SFTP container with the supplied instance id (0-5).
+
+**kill_ftps <ftps-instance-id>**</br>
+Stop and remove a FTPS container with the supplied instance id (0-5).
+
+**stop_ftps <ftps-instance-id>**</br>
+Stop a FTPS container with the supplied instance id (0-5).
+
+**start_ftps <ftps-instance-id>**</br>
+Start a previously stopped FTPS container with the supplied instance id (0-5).
+
+**mr_print <vaiable-name>**</br>
+Print a variable value from the MR simulator.
+
+**dr_print <vaiable-name>**</br>
+Print a variable value from the DR simulator.
+
+**drr_print <vaiable-name>**</br>
+Print a variable value from the DR redir simulator.
+
+**dfc_print <dfc-instance-id> <vaiable-name>**</br>
+Print a variable value from an dfc instance with the supplied instance id (0-5).
+
+**mr_read <vaiable-name>**</br>
+Read a variable value from MR sim and send to stdout
+
+**dr_read <vaiable-name>**</br>
+Read a variable value from DR sim and send to stdout
+
+**drr_read <vaiable-name>**</br>
+Read a variable value from DR redir sim and send to stdout
+
+**sleep_wait <sleep-time-in-sec>**</br>
+Sleep for a number of seconds
+
+**sleep_heartbeat <sleep-time-in-sec>**</br>
+Sleep for a number of seconds and prints dfc heartbeat output every 30 sec
+
+**mr_equal <variable-name> <target-value> [<timeout-in-sec>]**</br>
+Tests if a variable value in the MR simulator is equal to a target value and an optional timeout.
+</br>Arg: ``<variable-name> <target-value>`` - This test set pass or fail depending on if the variable is
+equal to the targer or not.
+</br>Arg: ``<variable-name> <target-value> <timeout-in-sec>`` - This test waits up to the timeout seconds
+before setting pass or fail depending on if the variable value becomes equal to the target
+value or not.
+
+**mr_greater <variable-name> <target-value> [<timeout-in-sec>]**</br>
+Tests if a variable value in the MR simulator is greater than a target value and an optional timeout.
+</br>Arg: ``<variable-name> <target-value>`` - This test set pass or fail depending on if the variable is
+greater the target or not.
+</br>Arg: ``<variable-name> <target-value> <timeout-in-sec>`` - This test waits up to the timeout seconds
+before setting pass or fail depending on if the variable value is greater than the target
+value or not.
+
+**mr_less <variable-name> <target-value> [<timeout-in-sec>]**</br>
+Tests if a variable value in the MR simulator is less than a target value and an optional timeout.
+</br>Arg: ``<variable-name> <target-value>`` - This test set pass or fail depending on if the variable is
+less than the target or not.
+</br>Arg: ``<variable-name> <target-value> <timeout-in-sec>`` - This test waits up to the timeout seconds
+before setting pass or fail depending on if the variable value is less than the target
+value or not.
+
+**mr_contain_str <variable-name> <target-value> [<timeout-in-sec>]**</br>
+Tests if a variable value in the MR simulator contains a substring target and an optional timeout.
+</br>Arg: ``<variable-name> <target-value>`` - This test set pass or fail depending on if the variable contains
+the target substring or not.
+</br>Arg: ``<variable-name> <target-value> <timeout-in-sec>`` - This test waits up to the timeout seconds
+before setting pass or fail depending on if the variable value contains the target
+substring or not.
+
+**dr_equal <variable-name> <target-value> [<timeout-in-sec>]**</br>
+Tests if a variable value in the DR simulator is equal to a target value and an optional timeout.
+</br>Arg: ``<variable-name> <target-value>`` - This test set pass or fail depending on if the variable is
+equal to the target or not.
+</br>Arg: ``<variable-name> <target-value> <timeout-in-sec>`` - This test waits up to the timeout seconds
+before setting pass or fail depending on if the variable value becomes equal to the target
+value or not.
+
+**dr_greater <variable-name> <target-value> [<timeout-in-sec>]**</br>
+Tests if a variable value in the DR simulator is greater than a target value and an optional timeout.
+</br>Arg: ``<variable-name> <target-value>`` - This test set pass or fail depending on if the variable is
+greater the target or not.
+</br>Arg: ``<variable-name> <target-value> <timeout-in-sec>`` - This test waits up to the timeout seconds
+before setting pass or fail depending on if the variable value is greater than the target
+value or not.
+
+**dr_less <variable-name> <target-value> [<timeout-in-sec>]**</br>
+Tests if a variable value in the DR simulator is less than a target value and an optional timeout.
+</br>Arg: ``<variable-name> <target-value>`` - This test set pass or fail depending on if the variable is
+less than the target or not.
+</br>Arg: ``<variable-name> <target-value> <timeout-in-sec>`` - This test waits up to the timeout seconds
+before setting pass or fail depending on if the variable value is less than the target
+value or not.
+
+**dr_contain_str <variable-name> <target-value> [<timeout-in-sec>]**</br>
+Tests if a variable value in the DR simulator contains a substring target and an optional timeout.
+</br>Arg: ``<variable-name> <target-value>`` - This test set pass or fail depending on if the variable contains
+the target substring or not.
+</br>Arg: ``<variable-name> <target-value> <timeout-in-sec>`` - This test waits up to the timeout seconds
+before setting pass or fail depending on if the variable value contains the target
+substring or not.
+
+**drr_equal <variable-name> <target-value> [<timeout-in-sec>]**</br>
+Tests if a variable value in the DR Redir simulator is equal to a target value and an optional timeout.
+</br>Arg: ``<variable-name> <target-value>`` - This test set pass or fail depending on if the variable is
+equal to the target or not.
+</br>Arg: ``<variable-name> <target-value> <timeout-in-sec>`` - This test waits up to the timeout seconds
+before setting pass or fail depending on if the variable value becomes equal to the target
+value or not.
+
+**drr_greater <variable-name> <target-value> [<timeout-in-sec>]**</br>
+Tests if a variable value in the DR Redir simulator is greater than a target value and an optional timeout.
+</br>Arg: ``<variable-name> <target-value>`` - This test set pass or fail depending on if the variable is
+greater the target or not.
+</br>Arg: ``<variable-name> <target-value> <timeout-in-sec>`` - This test waits up to the timeout seconds
+before setting pass or fail depending on if the variable value is greater than the target
+value or not.
+
+**drr_less <variable-name> <target-value> [<timeout-in-sec>]**</br>
+Tests if a variable value in the DR Redir simulator is less than a target value and an optional timeout.
+</br>Arg: ``<variable-name> <target-value>`` - This test set pass or fail depending on if the variable is
+less than the target or not.
+</br>Arg: ``<variable-name> <target-value> <timeout-in-sec>`` - This test waits up to the timeout seconds
+before setting pass or fail depending on if the variable value is less than the target
+value or not.
+
+**drr_contain_str <variable-name> <target-value> [<timeout-in-sec>]**</br>
+Tests if a variable value in the DR Redir simulator contains a substring target and an optional timeout.
+</br>Arg: ``<variable-name> <target-value>`` - This test set pass or fail depending on if the variable contains
+the target substring or not.
+</br>Arg: ``<variable-name> <target-value> <timeout-in-sec>`` - This test waits up to the timeout seconds
+before setting pass or fail depending on if the variable value contains the target
+substring or not.
+
+**dfc_contain_str <variable-name> <substring-in-quotes>**</br>
+Test if a variable in the DFC contains a substring.
+
+**store_logs <log-prefix>**</br>
+Store all dfc app and simulators log to the test case log dir. All logs get a prefix to
+separate logs stored at different steps in the test script.
+If logs need to be stored in several locations, use different prefix to easily identify the location
+when the logs where taken.
+
+**check_dfc_log**</br>
+Check the dfc application log for WARN and ERR messages and print the count.
+
+**print_result**</br>
+Print the test result. Only once at the very end of the script.
+
+**print_all**</br>
+Print all variables from the simulators and the dfc heartbeat.
+
+In addition, comment in the file can be added using the normal comment sign in bash '#'.
+Comments that shall be visible on the screen as well as in the test case log, use ``echo "<msg>"``.
+
+
+##Descriptions of functions in testsuite_common.sh
+
+The following is a list of the available functions in a test suite file. Please see a existing test suite for examples.
+
+**suite_setup**</br>
+Sets up the test suite and print out a heading.
+
+**run_tc <tc-script> <$1 from test suite script> <$2 from test suite script>**</br>
+Execute a test case with arg from test suite script
+
+**suite_complete**</br>
+Print out the overall result of the executed test cases. \ No newline at end of file
diff --git a/test/mocks/datafilecollector-testharness/common/test_env.sh b/test/mocks/datafilecollector-testharness/common/test_env.sh
index 7ba35ef27..1a97ffc73 100644
--- a/test/mocks/datafilecollector-testharness/common/test_env.sh
+++ b/test/mocks/datafilecollector-testharness/common/test_env.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-# This env variable is only needed if the auto test scripts tests are executed in a different folder than 'auto-test' in the integration repo
+# This env variable is only needed if the auto test scripts tests are executed in a different folder than 'auto-test' in the integration repo
# Change '<local-path>' to your path to the integration repo. In addition to the auto-test, the 'common' dir is needed if not executed in the
# integration repo.
#
@@ -18,33 +18,41 @@ export DFC_LOCAL_IMAGE=onap/org.onap.dcaegen2.collectors.datafile.datafile-app-s
# Common env var for auto-test.
-DFC_PORT=8100
-DFC_PORT_SECURE=8433
-DFC_LOGPATH="/var/log/ONAP/application.log"
-DOCKER_SIM_NWNAME="dfcnet"
-CONSUL_HOST="consul-server"
-CONSUL_PORT=8500
-CONFIG_BINDING_SERVICE="config-binding-service"
-MR_PORT=2222
-MR_PORT_SECURE=2223
-DR_PORT=3906
-DR_PORT_SECURE=3907
-DRR_PORT=3908
-DRR_PORT_SECURE=3909
-DFC_APP_BASE="dfc_app"
-DFC_MAX_NUM=5
-DFC_MAX_IDX=$(($DFC_MAX_NUM - 1))
-SFTP_BASE="dfc_sftp-server"
-FTPS_BASE="dfc_ftpes-server-vsftpd"
-FTP_MAX_NUM=5
-FTP_MAX_IDX=$(($FTP_MAX_NUM - 1))
+DFC_PORT=8100 #Up to five dfc apps can be used, dfc_app0 will be mapped to 8100 on local machine for http, dfc_app1 mapped to 8101 etc
+DFC_PORT_SECURE=8433 #Up to five dfc apps can be used, dfc_app0 will be mapped to 8433 on local machine for hhtps, dfc_app1 mapped to 8434 etc
+DFC_LOGPATH="/var/log/ONAP/application.log" #Path the application log in the dfc container
+DOCKER_SIM_NWNAME="dfcnet" #Name of docker private network
+CONSUL_HOST="consul-server" #Host name of consul
+CONSUL_PORT=8500 #Port number of consul
+CONFIG_BINDING_SERVICE="config-binding-service" #Host name of CBS
+MR_PORT=2222 #MR simulator port number http
+DR_PORT=3906 #DR simulator port number http
+DR_PORT_SECURE=3907 #DR simulator port number for https
+DRR_PORT=3908 #DR Redirect simulator port number for http
+DRR_PORT_SECURE=3909 #DR Redirect simulator port number for https
+DFC_APP_BASE="dfc_app" #Base name of the dfc containers. Instance 0 will be named dfc_app0, instance 1 will named dfc_app1 etc
+DFC_MAX_NUM=5 #Max number of dfc containers to run in paralell in auto test
+DFC_MAX_IDX=$(($DFC_MAX_NUM - 1)) #Max index of the dfc containers
+SFTP_BASE="dfc_sftp-server" #Base name of the dfc_sftp-server containers. Instance 0 will be named dfc_sftp-server0, instance 1 will named dfc_sftp-server1 etc
+FTPS_BASE="dfc_ftpes-server-vsftpd" #Base name of the dfc_ftpes-server-vsftpd containers. Instance 0 will be named dfc_ftpes-server-vsftpd0, instance 1 will named dfc_ftpes-server-vsftpd1 etc
+FTP_MAX_NUM=5 #Max number of sftp and ftps containers to run in paralell in auto test
+FTP_MAX_IDX=$(($FTP_MAX_NUM - 1)) #Max index of sftp and ftps containers
+
+#List of sftp server name and port number, used by MR sim to produce file urls. Theses server names and ports are used when running dfc and the simulators in a private docker network
SFTP_SIMS_CONTAINER="sftp-server0:22,sftp-server1:22,sftp-server2:22,sftp-server3:22,sftp-server4:22"
+
+#List of sftp server name and port number, used by MR sim to produce file urls. Theses server names and ports are used when running dfc and the simulators in a private docker network
FTPS_SIMS_CONTAINER="ftpes-server-vsftpd0:21,ftpes-server-vsftpd1:21,ftpes-server-vsftpd2:21,ftpes-server-vsftpd3:21,ftpes-server-vsftpd4:21"
+
+#List of sftp server name and port number, used by MR sim to produce file urls. Theses server names and ports are used when running dfc as stand along app and the simulators in a private docker network
SFTP_SIMS_LOCALHOST="localhost:1022,localhost:1023,localhost:1024,localhost:1025,localhost:1026"
+
+#List of ftps server name and port number, used by MR sim to produce file urls. Theses server names and ports are used when running dfc as stand along app and the simulators in a private docker network
FTPS_SIMS_LOCALHOST="localhost:1032,localhost:1033,localhost:1034,localhost:1035,localhost:1036"
export SFTP_SIMS=$SFTP_SIMS_CONTAINER #This env will be set to SFTP_SIMS_LOCALHOST if auto test is executed with 'manual-app'
export FTPS_SIMS=$FTPS_SIMS_CONTAINER #This env will be set to FTPS_SIMS_LOCALHOST if auto test is executed with 'manual-app'
-export DR_REDIR_SIM="drsim_redir" #This env will be set to 'localhost' if auto test is executed with 'manual-app'
+#Host name of the DR redirect simulator
+export DR_REDIR_SIM="drsim_redir" #This env will be set to 'localhost' if auto test is executed with arg 'manual-app'
diff --git a/test/mocks/datafilecollector-testharness/common/testcase_common.sh b/test/mocks/datafilecollector-testharness/common/testcase_common.sh
index deed26dfd..a1e092157 100755
--- a/test/mocks/datafilecollector-testharness/common/testcase_common.sh
+++ b/test/mocks/datafilecollector-testharness/common/testcase_common.sh
@@ -557,35 +557,28 @@ start_dfc() {
fi
}
-# Configure consul with dfc config, args <app|dmaap> <dfc-instance-id> <json-file-path>
+# Configure consul with dfc config, args <dfc-instance-id> <json-file-path>
# Not intended to be called directly by test scripts.
__consul_config() {
- if [ $# != 3 ]; then
- __print_err "need three args, <app|dmaap> <dfc-instance-id> <json-file-path>"
+ if [ $# != 2 ]; then
+ __print_err "need two args, <dfc-instance-id> <json-file-path>"
exit 1
fi
- if [ $2 -lt 0 ] || [ $2 -gt $DFC_MAX_IDX ]; then
+ if [ $1 -lt 0 ] || [ $1 -gt $DFC_MAX_IDX ]; then
__print_err "dfc-instance-id should be 0.."$DFC_MAX_IDX
exit 1
fi
- if ! [ -f $3 ]; then
- __print_err "json file does not extis: "$3
+ if ! [ -f $2 ]; then
+ __print_err "json file does not extis: "$2
exit 1
fi
- if [ $1 == "app" ]; then
- appname=$DFC_APP_BASE$2
- elif [ $1 == "dmaap" ]; then
- appname=$DFC_APP_BASE$2":dmaap"
- else
- __print_err "config type should be 'app' or 'dmaap'"
- exit 1
- fi
+ appname=$DFC_APP_BASE$1
- echo "Configuring consul for " $appname " from " $3
- curl -s http://127.0.0.1:${CONSUL_PORT}/v1/kv/${appname}?dc=dc1 -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data-binary "@"$3 >/dev/null
+ echo "Configuring consul for " $appname " from " $2
+ curl -s http://127.0.0.1:${CONSUL_PORT}/v1/kv/${appname}?dc=dc1 -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data-binary "@"$2 >/dev/null
}
# Configure consul with dfc app config, args <dfc-instance-id> <json-file-path>
@@ -593,20 +586,11 @@ consul_config_app() {
if [ $START_ARG == "manual-app" ]; then
echo "Replacing 'mrsim' with 'localhost' in json app config for consul"
sed 's/mrsim/localhost/g' $2 > .tmp_app.json
- __consul_config app $1 .tmp_app.json
- else
- __consul_config app $1 $2
- fi
-}
-
-# Configure consul with dfc dmaap config, args <dfc-instance-id> <json-file-path>
-consul_config_dmaap() {
- if [ $START_ARG == "manual-app" ]; then
echo "Replacing 'drsim' with 'localhost' in json dmaap config for consul"
- sed 's/drsim/localhost/g' $2 > .tmp_dmaap.json
- __consul_config dmaap $1 .tmp_dmaap.json
+ sed 's/drsim/localhost/g' .tmp_app.json > .app.json
+ __consul_config $1 .app.json
else
- __consul_config dmaap $1 $2
+ __consul_config $1 $2
fi
}