diff options
Diffstat (limited to 'test/mocks/datafilecollector-testharness/http-https-server')
5 files changed, 125 insertions, 0 deletions
diff --git a/test/mocks/datafilecollector-testharness/http-https-server/.gitignore b/test/mocks/datafilecollector-testharness/http-https-server/.gitignore new file mode 100644 index 000000000..8605df3ea --- /dev/null +++ b/test/mocks/datafilecollector-testharness/http-https-server/.gitignore @@ -0,0 +1,2 @@ +files +logs diff --git a/test/mocks/datafilecollector-testharness/http-https-server/README.md b/test/mocks/datafilecollector-testharness/http-https-server/README.md new file mode 100644 index 000000000..3f2e11492 --- /dev/null +++ b/test/mocks/datafilecollector-testharness/http-https-server/README.md @@ -0,0 +1,34 @@ +# ejbca certs + +There are needed certificates generated using CMPv2 server to properly run the https server and dfc being able to work with +https protocol. For that reason, pre-generated certs were prepared and stored in `certservice/generated-certs` directory. +If HTTP server has to work with standalone ONAP installation, certs has to be obtained directly from CMPv2 server from ONAP +unit. + +# Docker preparations + +Source: <https://docs.docker.com/install/linux/linux-postinstall/> + +`sudo usermod -aG docker $USER` + +then logout-login to activate it. + +# Prepare files for the simulator + +Run `prepare.sh` with an argument found in `test_cases.yml` (or add a new tc in that file) to create files (1MB, +5MB and 50MB files) and a large number of symbolic links to these files to simulate PM files. The files names +matches the files in the events produced by the MR simulator. The dirs with the files will be mounted +by the ftp containers, defined in the docker-compse file, when started + +# Starting/stopping the HTTP/HTTPS server(s) + +Start: `docker-compose up` + +Stop: Ctrl +C, then `docker-compose down` or `docker-compose down --remove-orphans` + +If you experience issues (or port collision), check the currently running other containers +by using 'docker ps' and stop them if necessary. + +# Cleaning docker structure + +Deep cleaning: `docker system prune` diff --git a/test/mocks/datafilecollector-testharness/http-https-server/docker-compose.yml b/test/mocks/datafilecollector-testharness/http-https-server/docker-compose.yml new file mode 100644 index 000000000..e64908d96 --- /dev/null +++ b/test/mocks/datafilecollector-testharness/http-https-server/docker-compose.yml @@ -0,0 +1,24 @@ +version: '3' + +services: + + http-https-server: + container_name: http-https-server-httpd + image: nexus3.onap.org:10001/onap/org.onap.integration.simulators.httpserver:1.0.5 + environment: + APACHE_LOG_DIR: /usr/local/apache2/logs + ports: + - "80:80" + - "443:443" + - "8080:8080" + - "32000:32000" + - "32100:32100" + volumes: + - ./../certservice/generated-certs/apache-pem:/etc/apache2/certs:ro + - ./files/onap/http:/usr/local/apache2/htdocs + command: bash -c " + echo 'Http Server start'; + touch /usr/local/apache2/htdocs/index.html; + /usr/sbin/apache2ctl -D FOREGROUND; + " + restart: on-failure diff --git a/test/mocks/datafilecollector-testharness/http-https-server/prepare.sh b/test/mocks/datafilecollector-testharness/http-https-server/prepare.sh new file mode 100755 index 000000000..937033c90 --- /dev/null +++ b/test/mocks/datafilecollector-testharness/http-https-server/prepare.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# EXAMPLE: Run test case TC2 using the command "./prepare.sh TC2" +MAIN_DIRECTORY=./files/onap +TEST_FILE=./test_cases.yml +TEST=$1 +echo "Generating files for test case:" "$TEST" + +sf=$(sed -n '/'$TEST'/,$p' $TEST_FILE | grep -m 1 'size_files') +sf=${sf//*size_files: /} +sf_array=($sf) +echo "size_files=""$sf" + +nf=$(sed -n '/'$TEST'/,$p' $TEST_FILE | grep -m 1 'number_files') +nf=${nf//*number_files: /} +nf_array=($nf) +echo "number_files=""$nf" + +df=$(sed -n '/'$TEST'/,$p' $TEST_FILE | grep -m 1 'directory_files') +df=${df//*directory_files: /} +df_array=($df) +echo "directory_files=""$df" + +rm -rf $MAIN_DIRECTORY/* +if [ "${#sf_array[@]}" = "${#nf_array[@]}" ] && [ "${#nf_array[@]}" = "${#df_array[@]}" ]; +then + N_ELEMENTS=${#df_array[@]} + for ((n=0;n<$N_ELEMENTS;n++)) + do + # Create directory + DIRECTORY=$MAIN_DIRECTORY/${df_array[$n]} + mkdir -p "$DIRECTORY" + + # Create original file + FILE_SIZE=${sf_array[$n]} + FILE_NAME=$FILE_SIZE"MB.tar.gz" + dd if=/dev/urandom of=$DIRECTORY/$FILE_NAME bs=1k count=$(echo $FILE_SIZE*1000/1 | bc) + + # Create symlinks + N_SYMLINKS=${nf_array[$n]}-1 + for ((l=0;l<=$N_SYMLINKS;l++)) + do + SYMLINK_NAME=$FILE_SIZE"MB_"$l".tar.gz" + ln -s ./$FILE_NAME $DIRECTORY/$SYMLINK_NAME + done + done +else +echo "ERROR: The number of parameters in size_files, number_files, and directory_files must be equal!" +fi + diff --git a/test/mocks/datafilecollector-testharness/http-https-server/test_cases.yml b/test/mocks/datafilecollector-testharness/http-https-server/test_cases.yml new file mode 100644 index 000000000..d27bb9384 --- /dev/null +++ b/test/mocks/datafilecollector-testharness/http-https-server/test_cases.yml @@ -0,0 +1,16 @@ +# EXAMPLE: TC1 generates (i) 10 files of 1 MB in http directory, +# (ii) 30 files of 5 MB in sftp directory, and (iii) 10 files of 10 MB in http directory +TC1: + size_files: 1 5 10 + number_files: 10 30 10 + directory_files: http http http + +TC2: + size_files: 0.5 1 5 + number_files: 2 3 1 + directory_files: http http http + +TC_10000: + size_files: 1 1 5 5 50 50 + number_files: 10000 10000 10000 10000 1 1 + directory_files: http http http http http http |