From 9e3381e8d0416bd5dace217ee1a130d5c431063b Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Tue, 22 Nov 2022 16:07:49 +0100
Subject: [PATCH] Test tools:

- Added readme file on how to use the Mock MicroWave SDN Controller and run the tests for the MicroWaveDeviceDriver and MicroWaveServiceHandler.
- Updated the descriptors associated to this test.
---
 src/tests/tools/mock_sdn_ctrl/README.md       | 53 +++++++++++++++++++
 .../mock_sdn_ctrl/network_descriptors.json    |  2 +-
 .../mock_sdn_ctrl/service_descriptor.json     |  2 +-
 3 files changed, 55 insertions(+), 2 deletions(-)
 create mode 100644 src/tests/tools/mock_sdn_ctrl/README.md

diff --git a/src/tests/tools/mock_sdn_ctrl/README.md b/src/tests/tools/mock_sdn_ctrl/README.md
new file mode 100644
index 000000000..d8a6fe6b2
--- /dev/null
+++ b/src/tests/tools/mock_sdn_ctrl/README.md
@@ -0,0 +1,53 @@
+# Mock MicroWave SDN Controller
+
+This REST server implements very basic support for the following YANG data models:
+- IETF YANG data model for Network Topology
+  - Ref: https://www.rfc-editor.org/rfc/rfc8345.html
+- IETF YANG data model for Transport Network Client Signals
+  - Ref: https://www.ietf.org/archive/id/draft-ietf-ccamp-client-signal-yang-07.html
+
+The aim of this server is to enable testing the MicroWaveDeviceDriver and the MicroWaveServiceHandler.
+Follow the steps below to perform the test:
+
+## 1. Deploy TeraFlowSDN controller and the scenario
+Deploy the test scenario "microwave_deploy.sh":
+```bash
+source src/tests/tools/microwave_deploy.sh
+./deploy.sh
+```
+
+## 2. Install requirements and run the Mock MicroWave SDN controller
+__NOTE__: if you run the Mock MicroWave SDN controller from the PyEnv used for developping on the TeraFlowSDN framework,
+all the requirements are already in place. Install them only if you execute it in a separate/standalone environment.
+
+Install the required dependencies as follows:
+```bash
+pip install Flask==2.1.3 Flask-RESTful==0.3.9
+```
+
+Run the Mock MicroWave SDN Controller as follows:
+```bash
+python src/tests/tools/mock_sdn_ctrl/MockMWSdnCtrl.py
+```
+
+## 3. Deploy the test descriptors
+Edit the descriptors to meet your environment specifications.
+Edit "network_descriptors.json" and change IP address and port of the MicroWave SDN controller of the "MW" device.
+- Set value of config rule "_connect/address" to the address of the host where the Mock MicroWave SDN controller is
+  running (default="192.168.1.1").
+- Set value of config rule "_connect/port" to the port where your Mock MicroWave SDN controller is listening on
+  (default="8443").
+
+Upload the "network_descriptors.json" through the TeraFlowSDN WebUI.
+- If not already selected, select context "admin".
+- Check that a network topology with 4 routers + 1 microwave radio system are loaded. They should form 2 rings.
+
+Upload the "service_descriptor.json" through the TeraFlowSDN WebUI.
+- Check that 2 services have been created.
+- The "mw-svc" should have a connection and be supported by a sub-service.
+- The sub-service should also have a connection.
+- The R1, R3, and MW devices should have configuration rules established.
+
+# 4. Delete the microwave service
+Find the "mw-svc" on the WebUI, navigate to its details, and delete the service pressing the "Delete Service" button.
+The service, sub-service, and device configuration rules should be removed.
diff --git a/src/tests/tools/mock_sdn_ctrl/network_descriptors.json b/src/tests/tools/mock_sdn_ctrl/network_descriptors.json
index d42fe61dc..25fa940a4 100644
--- a/src/tests/tools/mock_sdn_ctrl/network_descriptors.json
+++ b/src/tests/tools/mock_sdn_ctrl/network_descriptors.json
@@ -70,7 +70,7 @@
             "device_id": {"device_uuid": {"uuid": "MW"}}, "device_type": "microwave-radio-system", "device_drivers": [4],
             "device_operational_status": 2, "device_endpoints": [],
             "device_config": {"config_rules": [
-                {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "192.168.1.56"}},
+                {"action": 1, "custom": {"resource_key": "_connect/address", "resource_value": "192.168.1.1"}},
                 {"action": 1, "custom": {"resource_key": "_connect/port", "resource_value": "8443"}},
                 {"action": 1, "custom": {"resource_key": "_connect/settings", "resource_value": {"timeout": 120}}}
             ]}
diff --git a/src/tests/tools/mock_sdn_ctrl/service_descriptor.json b/src/tests/tools/mock_sdn_ctrl/service_descriptor.json
index 3e15bed5c..a4109bc7b 100644
--- a/src/tests/tools/mock_sdn_ctrl/service_descriptor.json
+++ b/src/tests/tools/mock_sdn_ctrl/service_descriptor.json
@@ -3,7 +3,7 @@
         {
             "service_id": {
                 "context_id": {"context_uuid": {"uuid": "admin"}},
-                "service_uuid": {"uuid": "siae-svc"}
+                "service_uuid": {"uuid": "mw-svc"}
             },
             "service_type": 2,
             "service_status": {"service_status": 1},
-- 
GitLab