diff options
Diffstat (limited to 'test')
6 files changed, 194 insertions, 0 deletions
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/README.md b/test/mocks/datafilecollector-testharness/simulator-group/README.md new file mode 100644 index 000000000..4d448f8d2 --- /dev/null +++ b/test/mocks/datafilecollector-testharness/simulator-group/README.md @@ -0,0 +1,41 @@ +#Introduction +The purpose of the "simulator-group" is to run all containers in one go with specified behavior. +Mainly this is needed for CSIT tests but can be used also for local testing. + + +###Preparation +Build the mr-sim image. + +cd ../mr-sim + +Run the docker build command to build the image for the MR simulator: 'docker build -t mrsim:latest . + +cd ../dr-sim + +Run the docker build command to build the image for the DR simulators: `docker build -t drsim_common:latest . + + +cd ../simulator-group + +Copy the 'configuration' and 'tls' catalogues from the ftps-sftp-server dir. + +Check the README.md in ftps-sftp-server dir in case the cert need to be updated. + +cp -r ./ftps-sftp-server/configuration . + +cp -r ../ftps-sftp-server/tls . + + +###Execution + +Edit the `docker-compose-setup.sh` to setup the env variables to the desired test behavior for each simulators. +See each simulator to find a description of the available settings. + +Run the script `docker-compose-setup.sh`to create a docker-compose with the desired settings. All simulators +will be started with the generated docker-compose.yml file + +Kill all the containers with `simulators-kill.se` + +`simulators_start.sh` is for CSIT test and requires the env variables for test setting to be present in the shell. +`setup-ftp-files.for-image.sh` is for CSIT and executed when the ftp servers are started from the docker-compose-setup.sh`. + diff --git a/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-setup.sh b/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-setup.sh new file mode 100755 index 000000000..d0171a5e3 --- /dev/null +++ b/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-setup.sh @@ -0,0 +1,11 @@ +#/bin/bash + +#Script for manually starting all simulators with test setting below + +export DR_TC="" +export DR_REDIR_TC="" +export MR_TC="--tc100" +export BC_TC="" +export NUM_FTPFILES="250" + +source ./simulators-start.sh
\ No newline at end of file diff --git a/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-template.yml b/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-template.yml new file mode 100644 index 000000000..e7c700759 --- /dev/null +++ b/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-template.yml @@ -0,0 +1,59 @@ +version: '2' +services: + + drsim: + network_mode: "host" + image: drsim_common:latest + ports: + - "3906:3906" + - "3907:3907" + container_name: dfc_dr-sim + command: node dmaapDR.js ${DR_TC} + + drsim_redir: + image: drsim_common:latest + ports: + - "3908:3908" + - "3909:3909" + container_name: dfc_dr-redir-sim + command: node dmaapDR_redir.js ${DR_REDIR_TC} + + mrsim: + image: mrsim:latest + ports: + - "2222:2222" + container_name: dfc_mr-sim + command: python mr-sim.py ${MR_TC} + + sftp-server: + container_name: dfc_sftp-server + image: atmoz/sftp:alpine + ports: + - "1022:22" +# volumes: +# - ./files/onap/sftp/:/home/onap/ + restart: on-failure + command: onap:pano:1001 + + + ftpes-server-vsftpd: + container_name: dfc_ftpes-server-vsftpd + image: docker.io/panubo/vsftpd + ports: + - "21:21" + - "8001-8010:8001-8010" + environment: + FTP_USER: onap + FTP_PASSWORD: pano + PASV_ADDRESS: localhost + PASV_MIN_PORT: 8001 + PASV_MAX_PORT: 8010 + volumes: + - ./tls/ftp.crt:/etc/ssl/private/ftp.crt:ro + - ./tls/ftp.key:/etc/ssl/private/ftp.key:ro + - ./tls/dfc.crt:/etc/ssl/private/dfc.crt:ro + - ./configuration/vsftpd_ssl.conf:/etc/vsftpd_ssl.conf:ro + +# - ./files/onap/ftps/:/srv/ + restart: on-failure +
\ No newline at end of file diff --git a/test/mocks/datafilecollector-testharness/simulator-group/setup-ftp-files-for-image.sh b/test/mocks/datafilecollector-testharness/simulator-group/setup-ftp-files-for-image.sh new file mode 100755 index 000000000..d8e57a3d8 --- /dev/null +++ b/test/mocks/datafilecollector-testharness/simulator-group/setup-ftp-files-for-image.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Script to create files for the FTP server to return upon request. +# The file names matches the files names in the events polled from the MR simulator. +# Intended for execution in the running ftp containers in the ftp-root dir. + +echo "Running ftp file creations" + +NUM=200 #Default number of files + +if [ $# -eq 1 ]; then + NUM=$1 +fi + +truncate -s 1MB 1MB.tar.gz +truncate -s 5MB 5MB.tar.gz +truncate -s 50MB 50MB.tar.gz + + +i=0 +while [ $i -lt $NUM ]; do #Problem with for loop and var substituion in curly bracket....so used good old style loop + ln -s 1MB.tar.gz 1MB_$i.tar.gz + ln -s 5MB.tar.gz 5MB_$i.tar.gz + let i=i+1 +done + + +ln -s 50MB.tar.gz 50MB_0.tar.gz #Large file, only for single file test diff --git a/test/mocks/datafilecollector-testharness/simulator-group/simulators-kill.sh b/test/mocks/datafilecollector-testharness/simulator-group/simulators-kill.sh new file mode 100755 index 000000000..b7cd6a38b --- /dev/null +++ b/test/mocks/datafilecollector-testharness/simulator-group/simulators-kill.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +#Stop all simulators + +docker kill dfc_dr-sim +docker kill dfc_dr-redir-sim +docker kill dfc_mr-sim +docker kill dfc_sftp-server +docker kill dfc_ftpes-server-vsftpd + diff --git a/test/mocks/datafilecollector-testharness/simulator-group/simulators-start.sh b/test/mocks/datafilecollector-testharness/simulator-group/simulators-start.sh new file mode 100755 index 000000000..ef1b90a38 --- /dev/null +++ b/test/mocks/datafilecollector-testharness/simulator-group/simulators-start.sh @@ -0,0 +1,45 @@ +#!/bin/bash + + +# Starts all simulators with the test settings +# Intended for CSIT test. For manual start, use the docker-compose-setup.sh + +docker-compose -f docker-compose-template.yml config > docker-compose.yml + +docker-compose up -d + +DR_SIM="$(docker ps -q --filter='name=dfc_dr-sim')" +DR_RD_SIM="$(docker ps -q --filter='name=dfc_dr-redir-sim')" +MR_SIM="$(docker ps -q --filter='name=dfc_mr-sim')" +SFTP_SIM="$(docker ps -q --filter='name=dfc_sftp-server')" +FTPS_SIM="$(docker ps -q --filter='name=dfc_ftpes-server-vsftpd')" + +#Wait for initialization of docker containers for all simulators +for i in {1..10}; do +if [ $(docker inspect --format '{{ .State.Running }}' $DR_SIM) ] && \ +[ $(docker inspect --format '{{ .State.Running }}' $DR_RD_SIM) ] && \ +[ $(docker inspect --format '{{ .State.Running }}' $MR_SIM) ] && \ +[ $(docker inspect --format '{{ .State.Running }}' $SFTP_SIM) ] && \ +[ $(docker inspect --format '{{ .State.Running }}' $FTPS_SIM) ] + then + echo "All simulators Running" + break + else + echo sleep $i + sleep $i + fi +done + +#Populate the ftp server with files +if [ -z "$NUM_FTPFILES" ] + then + NUM_FTPFILES=200 +fi + + +docker cp setup-ftp-files-for-image.sh $SFTP_SIM:/tmp/ +docker exec -w /home/onap/ $SFTP_SIM /tmp/setup-ftp-files-for-image.sh $NUM_FTPFILES >/dev/null 2>&1 + +docker cp setup-ftp-files-for-image.sh $FTPS_SIM:/tmp/setup-ftp-files-for-image.sh +docker exec -w /srv $FTPS_SIM /tmp/setup-ftp-files-for-image.sh $NUM_FTPFILES >/dev/null 2>&1 + |