From b837e334c875d2c2392fe51d711515a97aeb6c78 Mon Sep 17 00:00:00 2001 From: Krzysztof Gajewski Date: Tue, 29 Dec 2020 13:58:35 +0100 Subject: Add HTTP to DFC tests - testing environment preparation for DFC with HTTP client - add suitable TCs for CSIT tests Issue-ID: DCAEGEN2-2527 Signed-off-by: Krzysztof Gajewski Change-Id: Ic419c38125201ed6578a308ba258709f20ae65bd --- .../datafilecollector-testharness/common/README.md | 167 +++++++++++---------- .../common/test_env.sh | 10 ++ .../common/testcase_common.sh | 74 ++++++++- 3 files changed, 172 insertions(+), 79 deletions(-) (limited to 'test/mocks/datafilecollector-testharness/common') diff --git a/test/mocks/datafilecollector-testharness/common/README.md b/test/mocks/datafilecollector-testharness/common/README.md index f0e3eec79..dc57e09df 100644 --- a/test/mocks/datafilecollector-testharness/common/README.md +++ b/test/mocks/datafilecollector-testharness/common/README.md @@ -1,205 +1,216 @@ ## Common test scripts and env file for test -**test_env.sh**
-Common env variables for test in the auto-test dir. Used by the auto test cases/suites but could be used for other test script as well. +**test_env.sh**: Common env variables for test in the auto-test dir. +Used by the auto test cases/suites but could be used for other test script as well. -**testcase_common.sh**
-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. +**testcase_common.sh**: 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**
-Common functions for auto test suites in the auto-test dir. +**testsuite_common.sh**: 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**
+**log_sim_settings**: Print the env variables needed for the simulators and their setup -**clean_containers**
+**clean_containers**: Stop and remove all containers including dfc apps and simulators -**start_simulators**
+**start_simulators**: Start all simulators in the simulator group -**start_dfc **
-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'. +**start_dfc \**: +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 **
+**kill_dfc \**: Stop and remove the dfc app container with the instance id. -**consul_config_app **
-Configure consul with json file with app config for a dfc instance using the dfc instance id and the json file. +**consul_config_app \ \**: +Configure consul with json file with app config for a dfc instance using the dfc +instance id and the json file. -**consul_config_dmaap **
-Configure consul with json file with dmaap config for a dfc instance using the dfc instance id and the json file. +**consul_config_dmaap \ \**: +Configure consul with json file with dmaap config for a dfc instance using the dfc +instance id and the json file. -**kill_dr**
+**kill_dr**: Stop and remove the DR simulator container -**kill_drr**
+**kill_drr**: Stop and remove the DR redir simulator container -**kill_mr**
+**kill_mr**: Stop and remove the MR simulator container -**kill_sftp **
+**kill_sftp \**: Stop and remove a SFTP container with the supplied instance id (0-5). -**stop_sftp **
+**stop_sftp \**: Stop a SFTP container with the supplied instance id (0-5). -**start_sftp **
+**start_sftp \**: Start a previously stopped SFTP container with the supplied instance id (0-5). -**kill_ftpes **
+**kill_ftpes \**: Stop and remove a FTPES container with the supplied instance id (0-5). -**stop_ftpes **
+**stop_ftpes \**: Stop a FTPES container with the supplied instance id (0-5). -**start_ftpes **
+**start_ftpes \**: Start a previously stopped FTPES container with the supplied instance id (0-5). -**mr_print **
+**kill_http \**: +Stop and remove a HTTP container with the supplied instance id (0-5). + +**stop_http \**: +Stop a HTTP container with the supplied instance id (0-5). + +**start_http \**: +Start a previously stopped HTTP container with the supplied instance id (0-5). + +**mr_print \**: Print a variable value from the MR simulator. -**dr_print **
+**dr_print \**: Print a variable value from the DR simulator. -**drr_print **
+**drr_print \**: Print a variable value from the DR redir simulator. -**dfc_print **
+**dfc_print \ **: Print a variable value from an dfc instance with the supplied instance id (0-5). -**mr_read **
+**mr_read \**: Read a variable value from MR sim and send to stdout -**dr_read **
+**dr_read \**: Read a variable value from DR sim and send to stdout -**drr_read **
+**drr_read \**: Read a variable value from DR redir sim and send to stdout -**sleep_wait **
+**sleep_wait \**: Sleep for a number of seconds -**sleep_heartbeat **
+**sleep_heartbeat \**: Sleep for a number of seconds and prints dfc heartbeat output every 30 sec -**mr_equal []**
+**mr_equal \ \ \[\]**: Tests if a variable value in the MR simulator is equal to a target value and an optional timeout. -
Arg: ` ` - This test set pass or fail depending on if the variable is +:Arg: ` ` - This test set pass or fail depending on if the variable is equal to the targer or not. -
Arg: ` ` - This test waits up to the timeout seconds +:Arg: ` ` - 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 []**
+**mr_greater \ \ \[\]**: Tests if a variable value in the MR simulator is greater than a target value and an optional timeout. -
Arg: ` ` - This test set pass or fail depending on if the variable is +:Arg: ` ` - This test set pass or fail depending on if the variable is greater the target or not. -
Arg: ` ` - This test waits up to the timeout seconds +:Arg: ` ` - 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 []**
+**mr_less \ \ \[\]**: Tests if a variable value in the MR simulator is less than a target value and an optional timeout. -
Arg: ` ` - This test set pass or fail depending on if the variable is +:Arg: ` ` - This test set pass or fail depending on if the variable is less than the target or not. -
Arg: ` ` - This test waits up to the timeout seconds +:Arg: ` ` - 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 []**
+**mr_contain_str \ \ \[\]**: Tests if a variable value in the MR simulator contains a substring target and an optional timeout. -
Arg: ` ` - This test set pass or fail depending on if the variable contains +:Arg: ` ` - This test set pass or fail depending on if the variable contains the target substring or not. -
Arg: ` ` - This test waits up to the timeout seconds +:Arg: ` ` - 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 []**
+**dr_equal \[\]**: Tests if a variable value in the DR simulator is equal to a target value and an optional timeout. -
Arg: ` ` - This test set pass or fail depending on if the variable is +:Arg: ` ` - This test set pass or fail depending on if the variable is equal to the target or not. -
Arg: ` ` - This test waits up to the timeout seconds +:Arg: ` ` - 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 []**
+**dr_greater \[\]**: Tests if a variable value in the DR simulator is greater than a target value and an optional timeout. -
Arg: ` ` - This test set pass or fail depending on if the variable is +:Arg: ` ` - This test set pass or fail depending on if the variable is greater the target or not. -
Arg: ` ` - This test waits up to the timeout seconds +:Arg: ` ` - 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 []**
+**dr_less \[\]**: Tests if a variable value in the DR simulator is less than a target value and an optional timeout. -
Arg: ` ` - This test set pass or fail depending on if the variable is +:Arg: ` ` - This test set pass or fail depending on if the variable is less than the target or not. -
Arg: ` ` - This test waits up to the timeout seconds +:Arg: ` ` - 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 []**
+**dr_contain_str \ \ \[\]**: Tests if a variable value in the DR simulator contains a substring target and an optional timeout. -
Arg: ` ` - This test set pass or fail depending on if the variable contains +:Arg: ` ` - This test set pass or fail depending on if the variable contains the target substring or not. -
Arg: ` ` - This test waits up to the timeout seconds +:Arg: ` ` - 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 []**
+**drr_equal \ \ \[\]**: Tests if a variable value in the DR Redir simulator is equal to a target value and an optional timeout. -
Arg: ` ` - This test set pass or fail depending on if the variable is +:Arg: ` ` - This test set pass or fail depending on if the variable is equal to the target or not. -
Arg: ` ` - This test waits up to the timeout seconds +:Arg: ` ` - 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 []**
+**drr_greater \ \ \[\]**: Tests if a variable value in the DR Redir simulator is greater than a target value and an optional timeout. -
Arg: ` ` - This test set pass or fail depending on if the variable is +:Arg: ` ` - This test set pass or fail depending on if the variable is greater the target or not. -
Arg: ` ` - This test waits up to the timeout seconds +:Arg: ` ` - 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 []**
+**drr_less \ \ \[\]**: Tests if a variable value in the DR Redir simulator is less than a target value and an optional timeout. -
Arg: ` ` - This test set pass or fail depending on if the variable is +:Arg: ` ` - This test set pass or fail depending on if the variable is less than the target or not. -
Arg: ` ` - This test waits up to the timeout seconds +:Arg: ` ` - 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 []**
+**drr_contain_str \ \ \[\]**: Tests if a variable value in the DR Redir simulator contains a substring target and an optional timeout. -
Arg: ` ` - This test set pass or fail depending on if the variable contains +:Arg: ` ` - This test set pass or fail depending on if the variable contains the target substring or not. -
Arg: ` ` - This test waits up to the timeout seconds +:Arg: ` ` - 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 **
+**dfc_contain_str \ \**: Test if a variable in the DFC contains a substring. -**store_logs **
+**store_logs \**: 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**
+**check_dfc_log**: Check the dfc application log for WARN and ERR messages and print the count. -**print_result**
+**print_result**: Print the test result. Only once at the very end of the script. -**print_all**
+**print_all**: 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 '#'. @@ -209,11 +220,11 @@ Comments that shall be visible on the screen as well as in the test case log, us The following is a list of the available functions in a test suite file. Please see a existing test suite for examples. -**suite_setup**
+**suite_setup**: Sets up the test suite and print out a heading. -**run_tc <$1 from test suite script> <$2 from test suite script>**
+**run_tc \ <$1 from test suite script> <$2 from test suite script>**: Execute a test case with arg from test suite script -**suite_complete**
+**suite_complete**: Print out the overall result of the executed test cases. diff --git a/test/mocks/datafilecollector-testharness/common/test_env.sh b/test/mocks/datafilecollector-testharness/common/test_env.sh index cc96ce8b9..a5ea8a17e 100644 --- a/test/mocks/datafilecollector-testharness/common/test_env.sh +++ b/test/mocks/datafilecollector-testharness/common/test_env.sh @@ -36,8 +36,11 @@ DFC_MAX_NUM=5 #Max number of dfc containers to run in p 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 FTPES_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 +HTTP_BASE="dfc_http-server" #Base name of the dfc_http-server containers. Instance 0 will be named dfc_http-server0, instance 1 will named dfc_http-server1 etc FTP_MAX_NUM=5 #Max number of sftp and ftpes containers to run in paralell in auto test +HTTP_MAX_NUM=5 #Max number of http containers to run in paralell in auto test FTP_MAX_IDX=$(($FTP_MAX_NUM - 1)) #Max index of sftp and ftpes containers +HTTP_MAX_IDX=$(($HTTP_MAX_NUM - 1)) #Max index of http 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" @@ -45,14 +48,21 @@ SFTP_SIMS_CONTAINER="sftp-server0:22,sftp-server1:22,sftp-server2:22,sftp-server #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 FTPES_SIMS_CONTAINER="ftpes-server-vsftpd0:21,ftpes-server-vsftpd1:21,ftpes-server-vsftpd2:21,ftpes-server-vsftpd3:21,ftpes-server-vsftpd4:21" +#List of http 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 +HTTP_SIMS_CONTAINER="http-server0:80,http-server1:80,http-server2:80,http-server3:80,http-server4:80" + #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 ftpes 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 FTPES_SIMS_LOCALHOST="localhost:1032,localhost:1033,localhost:1034,localhost:1035,localhost:1036" +#List of http 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 +HTTP_SIMS_LOCALHOST="localhost:81,localhost:82,localhost:83,localhost:84,localhost:85" + export SFTP_SIMS=$SFTP_SIMS_CONTAINER #This env will be set to SFTP_SIMS_LOCALHOST if auto test is executed with 'manual-app' export FTPES_SIMS=$FTPES_SIMS_CONTAINER #This env will be set to FTPES_SIMS_LOCALHOST if auto test is executed with 'manual-app' +export HTTP_SIMS=$HTTP_SIMS_CONTAINER #This env will be set to HTTP_SIMS_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 61f3c5d43..9f156a901 100755 --- a/test/mocks/datafilecollector-testharness/common/testcase_common.sh +++ b/test/mocks/datafilecollector-testharness/common/testcase_common.sh @@ -151,7 +151,7 @@ fi echo "" -echo "Building images for the simulators if needed, MR, DR, DR Redir and FTPES simulators" +echo "Building images for the simulators if needed, MR, DR, DR Redir, FTPES and HTTP simulators" curdir=$PWD cd $SIM_GROUP cd ../dr-sim @@ -160,6 +160,8 @@ cd ../mr-sim docker build -t mrsim:latest . &> /dev/null cd ../ftpes-sftp-server docker build -t ftpes_vsftpd:latest -f Dockerfile-ftpes . &> /dev/null +cd ../http-https-server +docker build -t http_httpd:latest -f Dockerfile-http . &> /dev/null cd $curdir echo "" @@ -170,6 +172,7 @@ echo "DR simulator: " $(docker images | grep drsim_common) echo "DR redir simulator: " $(docker images | grep drsim_common) echo "SFTP: " $(docker images | grep atmoz/sftp) echo "FTPES: " $(docker images | grep ftpes_vsftpd) +echo "HTTP: " $(docker images | grep http_httpd) echo "Consul: " $(docker images | grep consul) echo "CBS: " $(docker images | grep platform.configbinding.app) echo "" @@ -179,6 +182,7 @@ echo "" if [ $START_ARG == "manual-app" ]; then export SFTP_SIMS=$SFTP_SIMS_LOCALHOST export FTPES_SIMS=$FTPES_SIMS_LOCALHOST + export HTTP_SIMS=$HTTP_SIMS_LOCALHOST export DR_REDIR_SIM="localhost" fi #else @@ -501,13 +505,18 @@ log_sim_settings() { echo "DR_REDIR_FEEDS= "$DR_REDIR_FEEDS echo "NUM_FTPFILES= "$NUM_FTPFILES + echo "NUM_HTTPFILES= "$NUM_HTTPFILES echo "NUM_PNFS= "$NUM_PNFS echo "FILE_SIZE= "$FILE_SIZE echo "FTP_TYPE= "$FTP_TYPE + echo "HTTP_TYPE= "$HTTP_TYPE echo "FTP_FILE_PREFIXES= "$FTP_FILE_PREFIXES + echo "HTTP_FILE_PREFIXES= "$HTTP_FILE_PREFIXES echo "NUM_FTP_SERVERS= "$NUM_FTP_SERVERS + echo "NUM_HTTP_SERVERS= "$NUM_HTTP_SERVERS echo "SFTP_SIMS= "$SFTP_SIMS echo "FTPES_SIMS= "$FTPES_SIMS + echo "HTTP_SIMS= "$HTTP_SIMS echo "" } @@ -757,6 +766,64 @@ start_ftpes() { __docker_start $appname } +# Stop and remove the HTTP container, arg: +kill_http() { + + if [ $# != 1 ]; then + __print_err "need one arg, " + exit 1 + fi + + if [ $1 -lt 0 ] || [ $1 -gt $HTTP_MAX_IDX ]; then + __print_err "arg should be 0.."$HTTP_MAX_IDX + exit 1 + fi + appname=$HTTP_BASE$1 + + echo "Killing HTTP, instance id: "$1 + + __docker_stop $appname + __docker_rm $appname +} + +# Stop HTTP container, arg: +stop_http() { + + if [ $# != 1 ]; then + __print_err "need one arg, " + exit 1 + fi + + if [ $1 -lt 0 ] || [ $1 -gt $HTTP_MAX_IDX ]; then + __print_err "arg should be 0.."$HTTP_MAX_IDX + exit 1 + fi + appname=$HTTP_BASE$1 + + echo "Stopping HTTP, instance id: "$1 + + __docker_stop $appname +} + +# Starts a stopped HTTP container, arg: +start_http() { + + if [ $# != 1 ]; then + __print_err "need one arg, " + exit 1 + fi + + if [ $1 -lt 0 ] || [ $1 -gt $HTTP_MAX_IDX ]; then + __print_err "arg should be 0.."$HTTP_MAX_IDX + exit 1 + fi + appname=$HTTP_BASE$1 + + echo "Starting HTTP, instance id: "$1 + + __docker_start $appname +} + # Print a variable value from the MR simulator. Arg: mr_print() { if [ $# != 1 ]; then @@ -1132,6 +1199,11 @@ store_logs() { docker logs $appname > $TESTLOGS/$ATC/${1}_${appname}.log 2>&1 done + for (( i=0; i<=$HTTP_MAX_IDX; i++ )); do + appname=$HTTP_BASE$i + docker logs $appname > $TESTLOGS/$ATC/${1}_${appname}.log 2>&1 + done + docker logs dfc_consul > $TESTLOGS/$ATC/$1_consul.log 2>&1 docker logs dfc_cbs > $TESTLOGS/$ATC/$1_cbs.log 2>&1 } -- cgit 1.2.3-korg