summaryrefslogtreecommitdiffstats
path: root/test/mocks/datafilecollector-testharness
diff options
context:
space:
mode:
Diffstat (limited to 'test/mocks/datafilecollector-testharness')
-rw-r--r--test/mocks/datafilecollector-testharness/ftps-sftp-server/.gitignore1
-rw-r--r--test/mocks/datafilecollector-testharness/ftps-sftp-server/docker-compose.yml7
-rwxr-xr-xtest/mocks/datafilecollector-testharness/ftps-sftp-server/prepare.sh50
-rw-r--r--test/mocks/datafilecollector-testharness/ftps-sftp-server/test_cases.yml11
4 files changed, 59 insertions, 10 deletions
diff --git a/test/mocks/datafilecollector-testharness/ftps-sftp-server/.gitignore b/test/mocks/datafilecollector-testharness/ftps-sftp-server/.gitignore
new file mode 100644
index 000000000..bd6c5bed8
--- /dev/null
+++ b/test/mocks/datafilecollector-testharness/ftps-sftp-server/.gitignore
@@ -0,0 +1 @@
+files/onap/*
diff --git a/test/mocks/datafilecollector-testharness/ftps-sftp-server/docker-compose.yml b/test/mocks/datafilecollector-testharness/ftps-sftp-server/docker-compose.yml
index 4d2d32984..466ca5642 100644
--- a/test/mocks/datafilecollector-testharness/ftps-sftp-server/docker-compose.yml
+++ b/test/mocks/datafilecollector-testharness/ftps-sftp-server/docker-compose.yml
@@ -8,7 +8,7 @@ services:
ports:
- "1022:22"
volumes:
- - ./files/onap/:/home/onap/
+ - ./files/onap/sftp/:/home/onap/
restart: on-failure
command: onap:pano:1001
@@ -30,10 +30,7 @@ services:
- ./tls/dfc.crt:/etc/ssl/private/dfc.crt:ro
- ./configuration/vsftpd_ssl.conf:/etc/vsftpd_ssl.conf:ro
- - ./files/onap/0.5MB.tar.gz:/srv/0.5MB.tar.gz:ro
- - ./files/onap/1MB.tar.gz:/srv/1MB.tar.gz:ro
- - ./files/onap/5MB.tar.gz:/srv/5MB.tar.gz:ro
- - ./files/onap/10MB.tar.gz:/srv/10MB.tar.gz:ro
+ - ./files/onap/ftps/:/srv/
restart: on-failure
command: vsftpd /etc/vsftpd_ssl.conf
diff --git a/test/mocks/datafilecollector-testharness/ftps-sftp-server/prepare.sh b/test/mocks/datafilecollector-testharness/ftps-sftp-server/prepare.sh
index 76f333409..f1146a61e 100755
--- a/test/mocks/datafilecollector-testharness/ftps-sftp-server/prepare.sh
+++ b/test/mocks/datafilecollector-testharness/ftps-sftp-server/prepare.sh
@@ -1,10 +1,50 @@
#!/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"
-mkdir -p files/onap
+sf=$(sed -n '/'$TEST'/,$p' $TEST_FILE | grep -m 1 'size_files')
+sf=${sf//*size_files: /}
+sf_array=($sf)
+echo "size_files=""$sf"
-dd if=/dev/urandom of=./files/onap/0.5MB.tar.gz bs=1k count=512
-dd if=/dev/urandom of=./files/onap/1MB.tar.gz bs=1M count=1
-dd if=/dev/urandom of=./files/onap/5MB.tar.gz bs=1M count=5
-dd if=/dev/urandom of=./files/onap/10MB.tar.gz bs=1M count=10
+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=1;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
sudo chown root:root ./configuration/vsftpd_ssl.conf
diff --git a/test/mocks/datafilecollector-testharness/ftps-sftp-server/test_cases.yml b/test/mocks/datafilecollector-testharness/ftps-sftp-server/test_cases.yml
new file mode 100644
index 000000000..8dba11479
--- /dev/null
+++ b/test/mocks/datafilecollector-testharness/ftps-sftp-server/test_cases.yml
@@ -0,0 +1,11 @@
+# EXAMPLE: TC1 generates (i) 10 files of 1 MB in ftps directory,
+# (ii) 30 files of 5 MB in sftp directory, and (iii) 10 files of 10 MB in sftp directory
+TC1:
+ size_files: 1 5 10
+ number_files: 10 30 10
+ directory_files: ftps sftp sftp
+
+TC2:
+ size_files: 0.5 1 5
+ number_files: 2 3 1
+ directory_files: ftps ftps sftp