From 2a5918013d10ce4590373805835b47414a66ea4e Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Fri, 5 Apr 2024 09:54:13 +0000
Subject: [PATCH] OFC'24 test:

- Reorganized descriptor files
- Reorganized node agent config files
- Reorganized old node agent deploy scripts
- Updated node agents deploy scripts
---
 src/tests/ofc24/_old/README.md                | 21 +++++++++
 .../{ => _old}/startExtraNetConfigAgent.sh    |  0
 src/tests/ofc24/{ => _old}/start_topo.sh      |  0
 src/tests/ofc24/deploy-node-agents.sh         | 46 ++++++++-----------
 .../{ => descriptors}/7.service-bidir.json    |  0
 .../{ => descriptors}/7.service-unidir.json   |  0
 .../descriptors_topology.json                 |  0
 .../{ => descriptors/old}/1.context.json      |  0
 .../{ => descriptors/old}/2.device1.json      |  0
 .../{ => descriptors/old}/3.device2.json      |  0
 .../{ => descriptors/old}/4.device3_R1.json   |  0
 .../{ => descriptors/old}/5.device4_R2.json   |  0
 .../ofc24/{ => descriptors/old}/6.links.json  |  0
 src/tests/ofc24/destroy-node-agents.sh        | 22 +++++++++
 .../platform_r1.xml                           |  0
 .../platform_r2.xml                           |  0
 .../platform_t1.xml                           |  0
 .../platform_t2.xml                           |  0
 .../startNetconfAgent-mg-on.sh                | 15 ++++++
 .../startNetconfAgent-tp.sh                   | 17 +++++++
 .../ofc24/tempOC/files/startNetconfAgent.sh   |  7 ---
 21 files changed, 94 insertions(+), 34 deletions(-)
 create mode 100644 src/tests/ofc24/_old/README.md
 rename src/tests/ofc24/{ => _old}/startExtraNetConfigAgent.sh (100%)
 rename src/tests/ofc24/{ => _old}/start_topo.sh (100%)
 rename src/tests/ofc24/{ => descriptors}/7.service-bidir.json (100%)
 rename src/tests/ofc24/{ => descriptors}/7.service-unidir.json (100%)
 rename src/tests/ofc24/{ => descriptors}/descriptors_topology.json (100%)
 rename src/tests/ofc24/{ => descriptors/old}/1.context.json (100%)
 rename src/tests/ofc24/{ => descriptors/old}/2.device1.json (100%)
 rename src/tests/ofc24/{ => descriptors/old}/3.device2.json (100%)
 rename src/tests/ofc24/{ => descriptors/old}/4.device3_R1.json (100%)
 rename src/tests/ofc24/{ => descriptors/old}/5.device4_R2.json (100%)
 rename src/tests/ofc24/{ => descriptors/old}/6.links.json (100%)
 create mode 100755 src/tests/ofc24/destroy-node-agents.sh
 rename src/tests/ofc24/{tempOC/files => node-agents-config}/platform_r1.xml (100%)
 rename src/tests/ofc24/{tempOC/files => node-agents-config}/platform_r2.xml (100%)
 rename src/tests/ofc24/{tempOC/files => node-agents-config}/platform_t1.xml (100%)
 rename src/tests/ofc24/{tempOC/files => node-agents-config}/platform_t2.xml (100%)
 create mode 100755 src/tests/ofc24/node-agents-config/startNetconfAgent-mg-on.sh
 create mode 100755 src/tests/ofc24/node-agents-config/startNetconfAgent-tp.sh
 delete mode 100644 src/tests/ofc24/tempOC/files/startNetconfAgent.sh

diff --git a/src/tests/ofc24/_old/README.md b/src/tests/ofc24/_old/README.md
new file mode 100644
index 000000000..93e95fc64
--- /dev/null
+++ b/src/tests/ofc24/_old/README.md
@@ -0,0 +1,21 @@
+# OFC'24 - Test scenario
+
+## Start Topology
+Topology is composed of 2 transponders managed through OpenConfig and 2 Multi-granular ROAMDS
+Strat the topology executing the following command:
+```bash
+sudo ./start_topo.sh
+```
+
+## Populate the TFS context and topology
+Pushing the JSON files following the file indexes, i.e, 1, 2, 3, ...
+The last JSON file with ID 7 is the service.
+To check the service is onboarded successfully go into the TFS WebUI and check the `Service` tab.
+
+## Check configuration in devices
+Check if the devices are configured properly.
+To check that, run, for each device (X={1, 2, 3, 4}):
+```bash
+screen -r tX
+```
+To release the terminal, press `Ctrl + A + D`
diff --git a/src/tests/ofc24/startExtraNetConfigAgent.sh b/src/tests/ofc24/_old/startExtraNetConfigAgent.sh
similarity index 100%
rename from src/tests/ofc24/startExtraNetConfigAgent.sh
rename to src/tests/ofc24/_old/startExtraNetConfigAgent.sh
diff --git a/src/tests/ofc24/start_topo.sh b/src/tests/ofc24/_old/start_topo.sh
similarity index 100%
rename from src/tests/ofc24/start_topo.sh
rename to src/tests/ofc24/_old/start_topo.sh
diff --git a/src/tests/ofc24/deploy-node-agents.sh b/src/tests/ofc24/deploy-node-agents.sh
index d0d32e079..1c1e45526 100755
--- a/src/tests/ofc24/deploy-node-agents.sh
+++ b/src/tests/ofc24/deploy-node-agents.sh
@@ -17,8 +17,8 @@ TEST_NAME="ofc24"
 
 
 echo
-echo "Pre-deploy clean-up:"
-echo "--------------------"
+echo "Clean-up:"
+echo "---------"
 docker rm -f na-t1 na-t2 na-r1 na-r2
 docker network rm na-br
 
@@ -34,35 +34,33 @@ echo
 echo "Create Management Network and Node Agents:"
 echo "------------------------------------------"
 docker network create -d bridge --subnet=172.254.253.0/24 --gateway=172.254.253.254 --ip-range=172.254.253.0/24 na-br
-docker run -d --name na-t1 --network=na-br --ip 172.254.253.1 \
-    --volume "$PWD/src/tests/${TEST_NAME}/tempOC/files/platform_t1.xml:/confd/examples.confd/OC23/demoECOC21.xml" \
+docker run -dit --init --name na-t1 --network=na-br --ip 172.254.253.101 \
+    --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/startNetconfAgent-tp.sh:/confd/examples.confd/OC23/startNetconfAgent.sh" \
+    --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/platform_t1.xml:/confd/examples.confd/OC23/platform.xml" \
     asgamb1/oc23bgp.img:latest /confd/examples.confd/OC23/startNetconfAgent.sh
-    #--volume "$PWD/src/tests/${TEST_NAME}/tempOC/files/startNetconfAgent.sh:/confd/examples.confd/OC23/startNetconfAgent.sh" \
-docker run -d --name na-t2 --network=na-br --ip 172.254.253.2 \
-    --volume "$PWD/src/tests/${TEST_NAME}/tempOC/files/platform_t2.xml:/confd/examples.confd/OC23/demoECOC21.xml" \
+docker run -dit --init --name na-t2 --network=na-br --ip 172.254.253.102 \
+    --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/startNetconfAgent-tp.sh:/confd/examples.confd/OC23/startNetconfAgent.sh" \
+    --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/platform_t2.xml:/confd/examples.confd/OC23/platform.xml" \
     asgamb1/oc23bgp.img:latest /confd/examples.confd/OC23/startNetconfAgent.sh
-    #--volume "$PWD/src/tests/${TEST_NAME}/tempOC/files/startNetconfAgent.sh:/confd/examples.confd/OC23/startNetconfAgent.sh" \
-docker run -d --name na-r1 --network=na-br --ip 172.254.253.101 \
-    --volume "$PWD/src/tests/${TEST_NAME}/tempOC/files/platform_r1.xml:/confd/examples.confd/OC23/init_openconfig-platform.xml" \
+docker run -dit --init --name na-r1 --network=na-br --ip 172.254.253.201 \
+    --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/startNetconfAgent-mg-on.sh:/confd/examples.confd/OC23/startNetconfAgent.sh" \
+    --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/platform_r1.xml:/confd/examples.confd/OC23/platform.xml" \
     asgamb1/flexscale-node.img:latest /confd/examples.confd/OC23/startNetconfAgent.sh
-    #--volume "$PWD/src/tests/${TEST_NAME}/tempOC/files/startNetconfAgent.sh:/confd/examples.confd/OC23/startNetconfAgent.sh" \
-docker run -d --name na-r2 --network=na-br --ip 172.254.253.102 \
-    --volume "$PWD/src/tests/${TEST_NAME}/tempOC/files/platform_r2.xml:/confd/examples.confd/OC23/init_openconfig-platform.xml" \
+docker run -dit --init --name na-r2 --network=na-br --ip 172.254.253.202 \
+    --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/startNetconfAgent-mg-on.sh:/confd/examples.confd/OC23/startNetconfAgent.sh" \
+    --volume "$PWD/src/tests/${TEST_NAME}/node-agents-config/platform_r2.xml:/confd/examples.confd/OC23/platform.xml" \
     asgamb1/flexscale-node.img:latest /confd/examples.confd/OC23/startNetconfAgent.sh
-    #--volume "$PWD/src/tests/${TEST_NAME}/tempOC/files/startNetconfAgent.sh:/confd/examples.confd/OC23/startNetconfAgent.sh" \
 
 
 echo
 echo "Waiting for initialization..."
 echo "-----------------------------"
 docker ps -a
-sleep 5
-docker ps -a
 while ! docker logs na-t1 2>&1 | grep -q '*** ConfD OpenConfig NETCONF agent ***'; do sleep 1; done
 while ! docker logs na-t2 2>&1 | grep -q '*** ConfD OpenConfig NETCONF agent ***'; do sleep 1; done
 while ! docker logs na-r1 2>&1 | grep -q '*** ConfD OpenConfig NETCONF agent ***'; do sleep 1; done
 while ! docker logs na-r2 2>&1 | grep -q '*** ConfD OpenConfig NETCONF agent ***'; do sleep 1; done
-sleep 2
+sleep 3
 docker ps -a
 
 
@@ -70,16 +68,10 @@ echo
 echo "Dump Node Agent status:"
 echo "-----------------------"
 docker ps -a
-#docker logs na-t1
-#docker logs na-t2
-#docker logs na-r1
-#docker logs na-r2
-
+docker logs na-t1
+docker logs na-t2
+docker logs na-r1
+docker logs na-r2
 
-#echo
-#echo "Post-test clean-up:"
-#echo "-------------------"
-#docker rm -f na-t1 na-t2 na-r1 na-r2
-#docker network rm na-br
 
 echo "Done!"
diff --git a/src/tests/ofc24/7.service-bidir.json b/src/tests/ofc24/descriptors/7.service-bidir.json
similarity index 100%
rename from src/tests/ofc24/7.service-bidir.json
rename to src/tests/ofc24/descriptors/7.service-bidir.json
diff --git a/src/tests/ofc24/7.service-unidir.json b/src/tests/ofc24/descriptors/7.service-unidir.json
similarity index 100%
rename from src/tests/ofc24/7.service-unidir.json
rename to src/tests/ofc24/descriptors/7.service-unidir.json
diff --git a/src/tests/ofc24/descriptors_topology.json b/src/tests/ofc24/descriptors/descriptors_topology.json
similarity index 100%
rename from src/tests/ofc24/descriptors_topology.json
rename to src/tests/ofc24/descriptors/descriptors_topology.json
diff --git a/src/tests/ofc24/1.context.json b/src/tests/ofc24/descriptors/old/1.context.json
similarity index 100%
rename from src/tests/ofc24/1.context.json
rename to src/tests/ofc24/descriptors/old/1.context.json
diff --git a/src/tests/ofc24/2.device1.json b/src/tests/ofc24/descriptors/old/2.device1.json
similarity index 100%
rename from src/tests/ofc24/2.device1.json
rename to src/tests/ofc24/descriptors/old/2.device1.json
diff --git a/src/tests/ofc24/3.device2.json b/src/tests/ofc24/descriptors/old/3.device2.json
similarity index 100%
rename from src/tests/ofc24/3.device2.json
rename to src/tests/ofc24/descriptors/old/3.device2.json
diff --git a/src/tests/ofc24/4.device3_R1.json b/src/tests/ofc24/descriptors/old/4.device3_R1.json
similarity index 100%
rename from src/tests/ofc24/4.device3_R1.json
rename to src/tests/ofc24/descriptors/old/4.device3_R1.json
diff --git a/src/tests/ofc24/5.device4_R2.json b/src/tests/ofc24/descriptors/old/5.device4_R2.json
similarity index 100%
rename from src/tests/ofc24/5.device4_R2.json
rename to src/tests/ofc24/descriptors/old/5.device4_R2.json
diff --git a/src/tests/ofc24/6.links.json b/src/tests/ofc24/descriptors/old/6.links.json
similarity index 100%
rename from src/tests/ofc24/6.links.json
rename to src/tests/ofc24/descriptors/old/6.links.json
diff --git a/src/tests/ofc24/destroy-node-agents.sh b/src/tests/ofc24/destroy-node-agents.sh
new file mode 100755
index 000000000..19e7fc9a9
--- /dev/null
+++ b/src/tests/ofc24/destroy-node-agents.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+echo
+echo "Clean-up:"
+echo "---------"
+docker rm -f na-t1 na-t2 na-r1 na-r2
+docker network rm na-br
+
+echo "Done!"
diff --git a/src/tests/ofc24/tempOC/files/platform_r1.xml b/src/tests/ofc24/node-agents-config/platform_r1.xml
similarity index 100%
rename from src/tests/ofc24/tempOC/files/platform_r1.xml
rename to src/tests/ofc24/node-agents-config/platform_r1.xml
diff --git a/src/tests/ofc24/tempOC/files/platform_r2.xml b/src/tests/ofc24/node-agents-config/platform_r2.xml
similarity index 100%
rename from src/tests/ofc24/tempOC/files/platform_r2.xml
rename to src/tests/ofc24/node-agents-config/platform_r2.xml
diff --git a/src/tests/ofc24/tempOC/files/platform_t1.xml b/src/tests/ofc24/node-agents-config/platform_t1.xml
similarity index 100%
rename from src/tests/ofc24/tempOC/files/platform_t1.xml
rename to src/tests/ofc24/node-agents-config/platform_t1.xml
diff --git a/src/tests/ofc24/tempOC/files/platform_t2.xml b/src/tests/ofc24/node-agents-config/platform_t2.xml
similarity index 100%
rename from src/tests/ofc24/tempOC/files/platform_t2.xml
rename to src/tests/ofc24/node-agents-config/platform_t2.xml
diff --git a/src/tests/ofc24/node-agents-config/startNetconfAgent-mg-on.sh b/src/tests/ofc24/node-agents-config/startNetconfAgent-mg-on.sh
new file mode 100755
index 000000000..fe5ad5618
--- /dev/null
+++ b/src/tests/ofc24/node-agents-config/startNetconfAgent-mg-on.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+echo 'Cleaning...'
+make clean
+
+echo 'Rebuilding...'
+make all
+
+echo 'Initializing database...'
+cp platform.xml confd-cdb/
+
+echo 'Starting ConfD...'
+make start2
+
+echo 'ConfD Ready!!'
diff --git a/src/tests/ofc24/node-agents-config/startNetconfAgent-tp.sh b/src/tests/ofc24/node-agents-config/startNetconfAgent-tp.sh
new file mode 100755
index 000000000..afc28cee7
--- /dev/null
+++ b/src/tests/ofc24/node-agents-config/startNetconfAgent-tp.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+echo 'Cleaning...'
+make clean
+
+echo 'Rebuilding...'
+make all
+
+echo 'Initializing database...'
+cp platform.xml confd-cdb/
+cp interfaces.xml confd-cdb/
+cp bgp.xml confd-cdb/
+
+echo 'Starting ConfD...'
+make start2
+
+echo 'ConfD Ready!!'
diff --git a/src/tests/ofc24/tempOC/files/startNetconfAgent.sh b/src/tests/ofc24/tempOC/files/startNetconfAgent.sh
deleted file mode 100644
index 10b721883..000000000
--- a/src/tests/ofc24/tempOC/files/startNetconfAgent.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-make clean
-make all
-#make init
-cp init_openconfig-platform.xml confd-cdb/
-#cp init_flex-scale-mg-on.xml confd-cdb/
-make start2
-- 
GitLab