TESTLOGS=$PWD/logs
# Create a log dir for the test case
-mkdir -p $TESTLOGS/$ATC
+mkdir -p $TESTLOGS/$ATC
# Clear the log dir for the test case
rm $TESTLOGS/$ATC/*.log &> /dev/null
echo "Trying to set env var SIM_GROUP to dir 'simulator-group' in the integration repo, but failed."
echo "Please set the SIM_GROUP manually in the test_env.sh"
exit 1
- else
+ else
echo "SIM_GROUP auto set to: " $SIM_GROUP
fi
elif [ $SIM_GROUP = *simulator_group ]; then
echo ""
-echo "Building images for the simulators if needed, MR, DR, DR Redir and FTPS 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
docker build -t drsim_common:latest . &> /dev/null
cd ../mr-sim
docker build -t mrsim:latest . &> /dev/null
-cd ../ftps-sftp-server
-docker build -t ftps_vsftpd:latest -f Dockerfile-ftps . &> /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 ""
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 "FTPS: " $(docker images | grep ftps_vsftpd)
+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 ""
#Configure DR sim with correct address for DR redirect simulator
if [ $START_ARG == "manual-app" ]; then
export SFTP_SIMS=$SFTP_SIMS_LOCALHOST
- export FTPS_SIMS=$FTPS_SIMS_LOCALHOST
+ export FTPES_SIMS=$FTPES_SIMS_LOCALHOST
+ export HTTP_SIMS=$HTTP_SIMS_LOCALHOST
export DR_REDIR_SIM="localhost"
fi
#else
# export SFTP_SIMS=$SFTP_SIMS_CONTAINER
-# export FTPS_SIMS=$FTPS_SIMS_CONTAINER
+# export FTPES_SIMS=$FTPES_SIMS_CONTAINER
# export DR_REDIR_SIM="drsim_redir"
#fi
#<flag-to-strip-new-line> may contain any string, it is just a flag
# Returns the variable value (if success) and return code 0 or an error message and return code 1
__do_curl() {
- res=$(curl -sw "%{http_code}" $1)
+ res=$(curl -skw "%{http_code}" $1)
http_code="${res:${#res}-3}"
if [ ${#res} -eq 3 ]; then
echo "<no-response-from-server>"
}
__start_dfc_image() {
-
+ set -x
if [ $# != 2 ]; then
__print_err "need tow args, <dfc-instance-name> 0.."$$DFC_MAX_IDX
exit 1
docker network ls| grep $DOCKER_SIM_NWNAME > /dev/null || docker network create $DOCKER_SIM_NWNAME
echo "Starting DFC: " $appname " with ports mapped to " $localport " and " $localport_secure " in docker network "$DOCKER_SIM_NWNAME
-
- docker run -d -p $localport":8100" -p $localport_secure":8433" --network=$DOCKER_SIM_NWNAME -e CONSUL_HOST=$CONSUL_HOST -e CONSUL_PORT=$CONSUL_PORT -e CONFIG_BINDING_SERVICE=$CONFIG_BINDING_SERVICE -e HOSTNAME=$appname --name $appname $DFC_IMAGE > /dev/null
-
+ docker run -d --volume $(pwd)/../simulator-group/tls/:/opt/app/datafile/etc/cert/ -p $localport":8100" -p $localport_secure":8433" --network=$DOCKER_SIM_NWNAME -e CONSUL_HOST=$CONSUL_HOST -e CONSUL_PORT=$CONSUL_PORT -e CONFIG_BINDING_SERVICE=$CONFIG_BINDING_SERVICE -e CONFIG_BINDING_SERVICE_SERVICE_PORT=$CONFIG_BINDING_SERVICE_SERVICE_PORT -e HOSTNAME=$appname --name $appname $DFC_IMAGE
+ sleep 3
+ set +x
dfc_started=false
for i in {1..10}; do
- if [ $(docker inspect --format '{{ .State.Running }}' $appname) ]
- then
- echo " Image: $(docker inspect --format '{{ .Config.Image }}' ${appname})"
- echo "DFC container ${appname} running"
- dfc_started=true
- break
- else
- sleep $i
- fi
+ if [ $(docker inspect --format '{{ .State.Running }}' $appname) ]
+ then
+ echo " Image: $(docker inspect --format '{{ .Config.Image }}' ${appname})"
+ echo "DFC container ${appname} running"
+ dfc_started=true
+ break
+ else
+ sleep $i
+ fi
done
if ! [ $dfc_started ]; then
echo "DFC container ${appname} could not be started"
fi
done
- if ! [ $dfc_hb ]; then
+ if [ "$dfc_hb" = "false" ]; then
echo "DFC ${appname} did not respond to heartbeat"
+ exit 1
fi
}
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 "FTPS_SIMS= "$FTPS_SIMS
+ echo "FTPES_SIMS= "$FTPES_SIMS
+ echo "HTTP_SIMS= "$HTTP_SIMS
echo ""
}
if [ $1 -lt 0 ] || [ $1 -gt $DFC_MAX_IDX ]; then
__print_err "arg should be 0.."$DFC_MAX_IDX
exit 1
- fi
+ fi
appname=$DFC_APP_BASE$1
STARTED_DFCS=$STARTED_DFCS"_"$appname"_"
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>
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
}
__docker_start $appname
}
-# Stop and remove the FTPS container, arg: <ftps-instance-id>
-kill_ftps() {
+# Stop and remove the FTPES container, arg: <ftpes-instance-id>
+kill_ftpes() {
if [ $# != 1 ]; then
- __print_err "need one arg, <ftpS-instance-id>"
+ __print_err "need one arg, <ftpes-instance-id>"
exit 1
fi
__print_err "arg should be 0.."$FTP_MAX_IDX
exit 1
fi
- appname=$FTPS_BASE$1
+ appname=$FTPES_BASE$1
- echo "Killing FTPS, instance id: "$1
+ echo "Killing FTPES, instance id: "$1
__docker_stop $appname
__docker_rm $appname
}
-# Stop FTPS container, arg: <ftps-instance-id>
-stop_ftps() {
+# Stop FTPES container, arg: <ftpes-instance-id>
+stop_ftpes() {
if [ $# != 1 ]; then
- __print_err "need one arg, <ftps-instance-id>"
+ __print_err "need one arg, <ftpes-instance-id>"
exit 1
fi
__print_err "arg should be 0.."$FTP_MAX_IDX
exit 1
fi
- appname=$FTPS_BASE$1
+ appname=$FTPES_BASE$1
- echo "Stopping FTPS, instance id: "$1
+ echo "Stopping FTPES, instance id: "$1
__docker_stop $appname
}
-# Starts a stopped FTPS container, arg: <ftps-instance-id>
-start_ftps() {
+# Starts a stopped FTPES container, arg: <ftpes-instance-id>
+start_ftpes() {
if [ $# != 1 ]; then
- __print_err "need one arg, <ftps-instance-id>"
+ __print_err "need one arg, <ftpes-instance-id>"
exit 1
fi
__print_err "arg should be 0.."$FTP_MAX_IDX
exit 1
fi
- appname=$FTPS_BASE$1
+ appname=$FTPES_BASE$1
- echo "Starting FTPS, instance id: "$1
+ echo "Starting FTPES, instance id: "$1
+
+ __docker_start $appname
+}
+
+# Stop and remove the HTTP container, arg: <http-instance-id>
+kill_http() {
+
+ if [ $# != 1 ]; then
+ __print_err "need one arg, <http-instance-id>"
+ 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: <http-instance-id>
+stop_http() {
+
+ if [ $# != 1 ]; then
+ __print_err "need one arg, <http-instance-id>"
+ 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: <http-instance-id>
+start_http() {
+
+ if [ $# != 1 ]; then
+ __print_err "need one arg, <http-instance-id>"
+ 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
}
echo -e "---- MR sim, \033[1m $1 \033[0m: $(__do_curl http://127.0.0.1:$MR_PORT/$1)"
}
+# Print a variable value from the MR https simulator. Arg: <variable-name>
+mr_secure_print() {
+ if [ $# != 1 ]; then
+ __print_err "need one arg, <sim-param>"
+ exit 1
+ fi
+ echo -e "---- MR sim, \033[1m $1 \033[0m: $(__do_curl https://127.0.0.1:$MR_PORT_SECURE/$1)"
+}
+
# Print a variable value from the DR simulator. Arg: <variable-name>
dr_print() {
if [ $# != 1 ]; then
echo "$(__do_curl http://127.0.0.1:$MR_PORT/$1)"
}
+# Read a variable value from MR https sim and send to stdout. Arg: <variable-name>
+mr_secure_read() {
+ echo "$(__do_curl https://127.0.0.1:$MR_PORT_SECURE/$1)"
+}
+
# Read a variable value from DR sim and send to stdout. Arg: <variable-name>
dr_read() {
echo "$(__do_curl http://127.0.0.1:$DR_PORT/$1)"
fi
}
+mr_secure_equal() {
+ if [ $# -eq 2 ] || [ $# -eq 3 ]; then
+ __var_test "MR" "https://127.0.0.1:$MR_PORT_SECURE/" $1 "=" $2 $3
+ else
+ __print_err "Wrong args to mr_secure_equal, needs two or three args: <sim-param> <target-value> [ timeout ]"
+ fi
+}
+
# Tests if a variable value in the MR simulator is greater than a target value and and optional timeout.
# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
# greater than the target or not.
fi
}
+mr_secure_greater() {
+ if [ $# -eq 2 ] || [ $# -eq 3 ]; then
+ __var_test "MR" "https://127.0.0.1:$MR_PORT_SECURE/" $1 ">" $2 $3
+ else
+ __print_err "Wrong args to mr_secure_greater, needs two or three args: <sim-param> <target-value> [ timeout ]"
+ fi
+}
+
# Tests if a variable value in the MR simulator is less than a target value and and optional timeout.
# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
# less than the target or not.
__print_err "Wrong args to mr_less, needs two or three args: <sim-param> <target-value> [ timeout ]"
fi
}
+mr_secure_less() {
+ if [ $# -eq 2 ] || [ $# -eq 3 ]; then
+ __var_test "MR" "https://127.0.0.1:$MR_PORT_SECURE/" $1 "<" $2 $3
+ else
+ __print_err "Wrong args to mr_secure_less, needs two or three args: <sim-param> <target-value> [ timeout ]"
+ fi
+}
# Tests if a variable value in the MR simulator contains the target string and and optional timeout.
# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable contains
__print_err "Wrong args to mr_contain_str, needs two or three args: <sim-param> <target-value> [ timeout ]"
fi
}
+mr_secure_contain_str() {
+ if [ $# -eq 2 ] || [ $# -eq 3 ]; then
+ __var_test "MR" "https://127.0.0.1:$MR_PORT_SECURE/" $1 "contain_str" $2 $3
+ else
+ __print_err "Wrong args to mr_secure_contain_str, needs two or three args: <sim-param> <target-value> [ timeout ]"
+ fi
+}
# Tests if a variable value in the DR simulator is equal to a target value and and optional timeout.
# Arg: <variable-name> <target-value> - This test set pass or fail depending on if the variable is
for (( i=0; i<=$FTP_MAX_IDX; i++ )); do
appname=$SFTP_BASE$i
docker logs $appname > $TESTLOGS/$ATC/${1}_${appname}.log 2>&1
- appname=$FTPS_BASE$i
+ appname=$FTPES_BASE$i
+ 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