aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks
diff options
context:
space:
mode:
authorRehanRaza <muhammad.rehan.raza@est.tech>2019-03-01 08:21:22 +0000
committerRehanRaza <muhammad.rehan.raza@est.tech>2019-03-01 08:21:22 +0000
commitd74e5a6083efe5e8979987cb687c6428d5e490fc (patch)
tree938618c85ac233b205f25562d792091d7d299863 /test/mocks
parentd38feb6936783a37631c444d62fe74a78dd41824 (diff)
ROP file creation script for e2e testing
* Creates a number of files (set using NUM_FILES) with standard filenames * File are created using a template XML file (set using FILE_TEMPLATE) * Files are updated after a specific interval (set using UPDATE_MINS) * At each update, the name of oldest file is modified with current timestamp * Works for multiple PNF nodes (set using NUM_NODES) Change-Id: I279970720ae25a360bd7a56923ebf3b8825abfd8 Issue-ID: DCAEGEN2-1225 Signed-off-by: RehanRaza <muhammad.rehan.raza@est.tech>
Diffstat (limited to 'test/mocks')
-rw-r--r--test/mocks/mass-pnf-sim/.gitignore3
-rwxr-xr-xtest/mocks/mass-pnf-sim/ROP_file_creator.sh69
-rw-r--r--test/mocks/mass-pnf-sim/templates/file_template.xml.gzbin0 -> 188545 bytes
3 files changed, 71 insertions, 1 deletions
diff --git a/test/mocks/mass-pnf-sim/.gitignore b/test/mocks/mass-pnf-sim/.gitignore
index 0db78788e..7111c7f28 100644
--- a/test/mocks/mass-pnf-sim/.gitignore
+++ b/test/mocks/mass-pnf-sim/.gitignore
@@ -1,3 +1,4 @@
pnf-sim-lw-*
.env/
-pnf-sim-lightweight/logs/* \ No newline at end of file
+pnf-sim-lightweight/logs/*
+files/onap/*
diff --git a/test/mocks/mass-pnf-sim/ROP_file_creator.sh b/test/mocks/mass-pnf-sim/ROP_file_creator.sh
new file mode 100755
index 000000000..1451658ed
--- /dev/null
+++ b/test/mocks/mass-pnf-sim/ROP_file_creator.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+MAIN_DIRECTORY=./files/onap
+FILE_TEMPLATE=./templates/file_template.xml.gz
+UPDATE_MINS=15
+NUM_NODES=20
+NUM_FILES=10
+
+rm -rf $MAIN_DIRECTORY/*
+for ((m=1;m<=$NUM_NODES;m++))
+do
+ DIRECTORY=$MAIN_DIRECTORY/"node"$m
+ mkdir -p "$DIRECTORY"
+done
+
+for ((n=0;n<$NUM_FILES;n++))
+do
+ if [[ "$OSTYPE" == "linux-gnu" ]]; then # Linux OS
+ DATE=$(date -d $(($UPDATE_MINS*$n))" minutes ago" +"%Y%m%d")
+ TIME_START=$(date -d $(($UPDATE_MINS*($n+1)-1))" minutes ago" +"%H%M")
+ TIME_END=$(date -d $(($UPDATE_MINS*$n))" minutes ago" +"%H%M")
+ elif [[ "$OSTYPE" == "darwin"* ]]; then # Mac OS
+ DATE=$(date -v "-"$(($UPDATE_MINS*$n))"M" +"%Y%m%d")
+ TIME_START=$(date -v "-"$(($UPDATE_MINS*($n+1)-1))"M" +"%H%M")
+ TIME_END=$(date -v "-"$(($UPDATE_MINS*$n))"M" +"%H%M")
+ else
+ echo "ERROR: OS not supported"
+ exit 1
+ fi
+
+ FILE_NAME_TIMESTAMP="A"$DATE"."$TIME_START"-"$TIME_END
+ TIMESTAMP_ARRAY[$n]=$FILE_NAME_TIMESTAMP
+
+ for ((m=1;m<=$NUM_NODES;m++))
+ do
+ DIRECTORY=$MAIN_DIRECTORY/"node"$m
+ FILE_NAME=$FILE_NAME_TIMESTAMP"_node"$m".xml.gz"
+ cp $FILE_TEMPLATE $DIRECTORY/$FILE_NAME
+ done
+done
+
+while true
+do
+ sleep $(($UPDATE_MINS*60))
+ OLD_TIMESTAMP=${TIMESTAMP_ARRAY[$NUM_FILES-1]}
+ unset TIMESTAMP_ARRAY[$NUM_FILES-1]
+
+ DATE=$(date +"%Y%m%d")
+ TIME_END=$(date +"%H%M")
+ if [[ "$OSTYPE" == "linux-gnu" ]]; then # Linux OS
+ TIME_START=$(date -d $(($UPDATE_MINS-1))" minutes ago" +"%H%M")
+ elif [[ "$OSTYPE" == "darwin"* ]]; then # Mac OS
+ TIME_START=$(date -v "-"$(($UPDATE_MINS-1))"M" +"%H%M")
+ else
+ echo "ERROR: OS not supported"
+ exit 1
+ fi
+
+ NEW_TIMESTAMP="A"$DATE"."$TIME_START"-"$TIME_END
+ TIMESTAMP_ARRAY=("$NEW_TIMESTAMP" "${TIMESTAMP_ARRAY[@]}")
+
+ for ((m=1;m<=$NUM_NODES;m++))
+ do
+ DIRECTORY=$MAIN_DIRECTORY/"node"$m
+ OLD_FILE_NAME=$OLD_TIMESTAMP"_node"$m".xml.gz"
+ NEW_FILE_NAME=$NEW_TIMESTAMP"_node"$m".xml.gz"
+ mv $DIRECTORY/$OLD_FILE_NAME $DIRECTORY/$NEW_FILE_NAME
+ echo "Renamed OLD file: "$OLD_FILE_NAME" to NEW file: "$NEW_FILE_NAME
+ done
+done
diff --git a/test/mocks/mass-pnf-sim/templates/file_template.xml.gz b/test/mocks/mass-pnf-sim/templates/file_template.xml.gz
new file mode 100644
index 000000000..0e6624a09
--- /dev/null
+++ b/test/mocks/mass-pnf-sim/templates/file_template.xml.gz
Binary files differ