aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/datafilecollector-testharness/simulator-group
diff options
context:
space:
mode:
authorBjornMagnussonXA <bjorn.magnusson@est.tech>2019-04-26 19:29:54 +0000
committerBjornMagnussonXA <bjorn.magnusson@est.tech>2019-04-26 19:29:54 +0000
commit42dcb266339a26803074f3190d1d9576e9dd05b7 (patch)
treef9b073cbacd0abfd528716cd5fbcf48eb0db9fc6 /test/mocks/datafilecollector-testharness/simulator-group
parentf13132901d327a84a229b1c7eef467d2c891ca44 (diff)
DFC automated tests
Test cases and suites for DFC automated test Issue-ID: DCAEGEN2-1434 Change-Id: Ibe2200f7dad358520d78217bad4ca6d3b514a3c3 Signed-off-by: BjornMagnussonXA <bjorn.magnusson@est.tech>
Diffstat (limited to 'test/mocks/datafilecollector-testharness/simulator-group')
-rw-r--r--test/mocks/datafilecollector-testharness/simulator-group/.gitignore6
-rw-r--r--test/mocks/datafilecollector-testharness/simulator-group/Dockerfile-sim-monitor15
-rw-r--r--test/mocks/datafilecollector-testharness/simulator-group/README.md20
-rwxr-xr-xtest/mocks/datafilecollector-testharness/simulator-group/docker-compose-setup.sh14
-rw-r--r--test/mocks/datafilecollector-testharness/simulator-group/docker-compose-template.yml2
-rwxr-xr-xtest/mocks/datafilecollector-testharness/simulator-group/setup-ftp-files-for-image.sh8
-rw-r--r--test/mocks/datafilecollector-testharness/simulator-group/sim-monitor.js48
-rwxr-xr-xtest/mocks/datafilecollector-testharness/simulator-group/simulators-kill.sh2
-rwxr-xr-xtest/mocks/datafilecollector-testharness/simulator-group/simulators-start.sh6
9 files changed, 94 insertions, 27 deletions
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/.gitignore b/test/mocks/datafilecollector-testharness/simulator-group/.gitignore
new file mode 100644
index 000000000..48e8e80a3
--- /dev/null
+++ b/test/mocks/datafilecollector-testharness/simulator-group/.gitignore
@@ -0,0 +1,6 @@
+configuration
+tls
+docker-compose.yml
+node_modules
+package.json
+prepare-images.sh \ No newline at end of file
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/Dockerfile-sim-monitor b/test/mocks/datafilecollector-testharness/simulator-group/Dockerfile-sim-monitor
new file mode 100644
index 000000000..145d2d992
--- /dev/null
+++ b/test/mocks/datafilecollector-testharness/simulator-group/Dockerfile-sim-monitor
@@ -0,0 +1,15 @@
+#Image for monitor simulator
+
+FROM node:8
+
+WORKDIR /app
+
+COPY sim-monitor.js ./
+COPY package*.json ./
+
+RUN npm install express
+RUN npm install argparse
+
+EXPOSE 9999
+
+CMD node /app/sim-monitor.js \ No newline at end of file
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/README.md b/test/mocks/datafilecollector-testharness/simulator-group/README.md
index 5981c7978..dc8f28669 100644
--- a/test/mocks/datafilecollector-testharness/simulator-group/README.md
+++ b/test/mocks/datafilecollector-testharness/simulator-group/README.md
@@ -31,11 +31,12 @@ cp -r ../ftps-sftp-server/tls .
###Execution
Edit the `docker-compose-setup.sh` (or create a copy) to setup the env variables to the desired test behavior for each simulators.
-See each simulator to find a description of the available settings.
+See each simulator to find a description of the available settings (DR_TC, DR_REDIR_TC and MR_TC).
The following env variables shall be set (example values).
Note that NUM_FTPFILES and NUM_PNFS controls the number of ftp files created in the ftp servers.
-A total of NUM_FTPFILES * NUM_PNFS ftp files will be created in each dtp server (4 files in the below example).
+A total of NUM_FTPFILES * NUM_PNFS ftp files will be created in each ftp server (4 files in the below example).
Large settings will be time consuming at start of the servers.
+Note that the number of files must match the number of file references emitted from the MR sim.
DR_TC="--tc normal" #Normal behavior of the DR sim
@@ -49,6 +50,12 @@ NUM_FTPFILES="2" #Two file for each PNF
NUM_PNFS="2" #Two PNFs
+To minimize the number of ftp file creation, the following two variables can be configured in the same file.
+FILE_SIZE="1MB" #File size for FTP file (1KB, 1MB, 5MB, 50MB or ALL)
+FTP_TYPE="SFTP" #Type of FTP files to generate (SFTP, FTPS or ALL)
+
+If `FTP_TYPE` is set to `ALL`, both ftp servers will be populated with the same files. If set to `SFTP` or `FTPS` then only the server serving that protocol will be populated with files.
+
Run the script `docker-compose-setup.sh`to create a docker-compose with the desired settings. The desired setting
in the script need to be manually adapted to for each specific simulator behavior according to the above. Check each simulator for available
parameters.
@@ -73,3 +80,12 @@ or the one in nexus `nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.dat
###Simulator monitor
Start the simulator monitor server with `sim-monitor-start.sh` and the open a browser with the url `localhost:9999/mon`
to see the statisics page with data from MR sim, DR sim and DR redir sim.
+Or run as a container, build image first. Note, does not work on Mac.
+
+`cp ../dr-sim/package.json .`
+
+`docker build -t sim-mon:latest -f Dockerfile-sim-monitor .`
+
+Then run it, `docker run --network="host" --name sim-mon -it -d sim-mon:latest`
+
+Stop it with `docker stop sim-mon` and if desired, remove the container by `docker rm sim-mon`
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-setup.sh b/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-setup.sh
index af36d0562..b9b38f8a8 100755
--- a/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-setup.sh
+++ b/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-setup.sh
@@ -2,13 +2,13 @@
#Script for manually starting all simulators with test setting below
-export DR_TC="--tc normal"
-export DR_REDIR_TC="--tc normal"
-export MR_TC="--tc100"
+export DR_TC="--tc normal" #Test behaviour for DR sim
+export DR_REDIR_TC="--tc normal" #Test behaviour for DR redir sim
+export MR_TC="--tc710" #Test behaviour for MR sim
export BC_TC="" #Not in use yet
-export NUM_FTPFILES="10"
-export NUM_PNFS="700"
-export FILE_SIZE="1MB"
-export FTP_TYPE="SFTP"
+export NUM_FTPFILES="105" #Number of FTP files to generate per PNF
+export NUM_PNFS="700" #Number of unuqie PNFs to generate FTP file for
+export FILE_SIZE="1MB" #File size for FTP file (1KB, 1MB, 5MB, 50MB or ALL)
+export FTP_TYPE="SFTP" #Type of FTP files to generate (SFTP, FTPS or ALL)
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
index 89a45a476..850563155 100644
--- a/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-template.yml
+++ b/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-template.yml
@@ -70,4 +70,4 @@ services:
- ./configuration/vsftpd_ssl.conf:/etc/vsftpd_ssl.conf:ro
restart: on-failure
- \ No newline at end of file
+ command: vsftpd /etc/vsftpd_ssl.conf
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
index 6c2b4f29f..7685c81a3 100755
--- 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
@@ -37,10 +37,10 @@ p=0
while [ $p -lt $PNFS ]; do
i=0
while [ $i -lt $NUM ]; do #Problem with for loop and var substituion in curly bracket....so used good old style loop
- if [ $FSIZE = "ALL" ] || [ $FSIZE = "1KB" ]; then ln -s 1KB.tar.gz 'A20000626.2315+0200-2330+0200_PNF'$p'-'$i'-1KB.tar.gz'; fi
- if [ $FSIZE = "ALL" ] || [ $FSIZE = "1MB" ]; then ln -s 1MB.tar.gz 'A20000626.2315+0200-2330+0200_PNF'$p'-'$i'-1MB.tar.gz'; fi
- if [ $FSIZE = "ALL" ] || [ $FSIZE = "5MB" ]; then ln -s 5MB.tar.gz 'A20000626.2315+0200-2330+0200_PNF'$p'-'$i'-5MB.tar.gz'; fi
- if [ $FSIZE = "ALL" ] || [ $FSIZE = "50MB" ]; then ln -s 50MB.tar.gz 'A20000626.2315+0200-2330+0200_PNF'$p'-'$i'-50MB.tar.gz'; fi
+ if [ $FSIZE = "ALL" ] || [ $FSIZE = "1KB" ]; then ln -s 1KB.tar.gz 'A20000626.2315+0200-2330+0200_PNF'$p'-'$i'-1KB.tar.gz' >& /dev/null; fi
+ if [ $FSIZE = "ALL" ] || [ $FSIZE = "1MB" ]; then ln -s 1MB.tar.gz 'A20000626.2315+0200-2330+0200_PNF'$p'-'$i'-1MB.tar.gz' >& /dev/null; fi
+ if [ $FSIZE = "ALL" ] || [ $FSIZE = "5MB" ]; then ln -s 5MB.tar.gz 'A20000626.2315+0200-2330+0200_PNF'$p'-'$i'-5MB.tar.gz' >& /dev/null; fi
+ if [ $FSIZE = "ALL" ] || [ $FSIZE = "50MB" ]; then ln -s 50MB.tar.gz 'A20000626.2315+0200-2330+0200_PNF'$p'-'$i'-50MB.tar.gz' >& /dev/null; fi
let i=i+1
done
let p=p+1
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/sim-monitor.js b/test/mocks/datafilecollector-testharness/simulator-group/sim-monitor.js
index e4a19c21e..634d1441e 100644
--- a/test/mocks/datafilecollector-testharness/simulator-group/sim-monitor.js
+++ b/test/mocks/datafilecollector-testharness/simulator-group/sim-monitor.js
@@ -30,19 +30,27 @@ function getSimCtr(url, cb) {
}).on("error", (err) => {
console.log("Error: " + err.message);
- cb("no response from simulator");
+ cb("no response");
});
};
//Status variables, for parameters values fetched from other simulators
-var mr1, mr2, mr3, mr4, mr5, mr6, mr7;
+var mr1, mr2, mr3, mr4, mr5, mr6, mr7, mr8, mr9, mr10;
-var dr1, dr2, dr3, dr4, dr5, dr6, dr7, dr8, dr9;
+var dr1, dr2, dr3, dr4, dr5, dr6, dr7, dr8, dr9, dr10;
var drr1, drr2, drr3, drr4, drr5, drr6;
+//Heartbeat var
+var dfc1;
+
app.get("/mon",function(req, res){
+ //DFC
+ getSimCtr("http://127.0.0.1:8100/heartbeat", function(data) {
+ dfc1 = data;
+ });
+
//MR
getSimCtr("http://127.0.0.1:2222/ctr_requests", function(data) {
mr1 = data;
@@ -65,6 +73,15 @@ app.get("/mon",function(req, res){
getSimCtr("http://127.0.0.1:2222/ctr_unique_PNFs", function(data) {
mr7 = data;
});
+ getSimCtr("http://127.0.0.1:2222/exe_time_first_poll", function(data) {
+ mr8 = data;
+ });
+ getSimCtr("http://127.0.0.1:2222/ctr_files", function(data) {
+ mr9 = data;
+ });
+ getSimCtr("http://127.0.0.1:2222/status", function(data) {
+ mr10 = data;
+ });
//DR
getSimCtr("http://127.0.0.1:3906/ctr_publish_query", function(data) {
@@ -94,7 +111,10 @@ app.get("/mon",function(req, res){
getSimCtr("http://127.0.0.1:3906/execution_time", function(data) {
dr9 = data;
});
-
+ getSimCtr("http://127.0.0.1:3906/ctr_double_publish", function(data) {
+ dr10 = data;
+ });
+
//DR REDIR
getSimCtr("http://127.0.0.1:3908/ctr_publish_requests", function(data) {
drr1 = data;
@@ -120,21 +140,28 @@ app.get("/mon",function(req, res){
"<html>" +
"<head>" +
"<meta http-equiv=\"refresh\" content=\"5\">"+ //5 sec auto reefresh
- "<title>Simulator monitor</title>"+
- "</head>" +
- "<body>" +
+ "<title>DFC and simulator monitor</title>"+
+ "</head>" +
+ "<body>" +
+ "<h3>DFC</h3>" +
+ "<font face=\"Courier New\">"+
+ "Heartbeat:....................................." + dfc1 + "<br>" +
+ "</font>"+
"<h3>MR Simulator</h3>" +
- "<font face=\"courier\">"+
+ "<font face=\"Courier New\">"+
"MR TC:........................................." + mr4 + "<br>" +
+ "Status:........................................" + mr10 + "<br>" +
"Execution time (mm.ss):........................" + mr6 + "<br>" +
+ "Execution time from first poll (mm.ss):....... " + mr8 + "<br>" +
"Number of requests (polls):...................." + mr1 + "<br>" +
"Number of responses (polls):..................." + mr2 + "<br>" +
+ "Number of files in all responses:.............." + mr9 + "<br>" +
"Number of unique files in all responses:......." + mr3 + "<br>" +
"Number of events..............................." + mr5 + "<br>" +
"Number of unique PNFs.........................." + mr7 + "<br>" +
"</font>"+
"<h3>DR Simulator</h3>" +
- "<font face=\"courier\">"+
+ "<font face=\"Courier New\">"+
"DR TC:........................................." + dr8 + "<br>" +
"Execution time (mm.ss):........................" + dr9 + "<br>" +
"Number of queries:............................." + dr1 + "<br>" +
@@ -144,9 +171,10 @@ app.get("/mon",function(req, res){
"Number of responses with redirect:............." + dr5 + "<br>" +
"Number of responses without redirect:.........." + dr6 + "<br>" +
"Number of published files:....................." + dr7 + "<br>" +
+ "Number of double published files:.............." + dr10 + "<br>" +
"</font>"+
"<h3>DR Redirect Simulator</h3>" +
- "<font face=\"courier\">"+
+ "<font face=\"Courier New\">"+
"DR REDIR TC:..................................." + drr3 + "<br>" +
"Execution time (mm.ss):........................" + drr4 + "<br>" +
"Number of requests:............................" + drr1 + "<br>" +
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/simulators-kill.sh b/test/mocks/datafilecollector-testharness/simulator-group/simulators-kill.sh
index b7cd6a38b..3f0ba357a 100755
--- a/test/mocks/datafilecollector-testharness/simulator-group/simulators-kill.sh
+++ b/test/mocks/datafilecollector-testharness/simulator-group/simulators-kill.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-#Stop all simulators
+#Stop all simulators
docker kill dfc_dr-sim
docker kill dfc_dr-redir-sim
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/simulators-start.sh b/test/mocks/datafilecollector-testharness/simulator-group/simulators-start.sh
index cc5ce32ec..774b753cb 100755
--- a/test/mocks/datafilecollector-testharness/simulator-group/simulators-start.sh
+++ b/test/mocks/datafilecollector-testharness/simulator-group/simulators-start.sh
@@ -51,11 +51,13 @@ fi
if [ $FTP_TYPE = "ALL" ] || [ $FTP_TYPE = "SFTP" ]; then
echo "Creating files for SFTP server, may take time...."
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 $NUM_PNFS $FILE_SIZE #>/dev/null 2>&1
+ #Double slash needed for docker on win...
+ docker exec -w //home/onap/ $SFTP_SIM //tmp/setup-ftp-files-for-image.sh $NUM_FTPFILES $NUM_PNFS $FILE_SIZE #>/dev/null 2>&1
fi
if [ $FTP_TYPE = "ALL" ] || [ $FTP_TYPE = "FTPS" ]; then
echo "Creating files for FTPS server, may take time...."
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 $NUM_PNFS $FILE_SIZE #>/dev/null 2>&1
+ #Double slash needed for docker on win...
+ docker exec -w //srv $FTPS_SIM //tmp/setup-ftp-files-for-image.sh $NUM_FTPFILES $NUM_PNFS $FILE_SIZE #>/dev/null 2>&1
fi
echo "Done: All simulators started and configured"