New O1 tests for python SDK 07/7407/5
authorsebdet <sebastien.determe@intl.att.com>
Thu, 16 Dec 2021 15:20:22 +0000 (16:20 +0100)
committerMartin Skorupski <martin.skorupski@highstreet-technologies.com>
Mon, 17 Jan 2022 23:52:25 +0000 (23:52 +0000)
Additional tests to validate RU/DU registration
+ Autmatic startup of the simulators before test session
+ Add new onap Clamp components by default
+ Restore previous test script shell based

Issue-ID: NONRTRIC-669
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Change-Id: I1aa017d8c956d6f6bf90cc316ee053db2f95da81

13 files changed:
smo-install/.gitignore
smo-install/helm-override/onap-override.yaml
smo-install/scripts/uninstall-simulators.sh [new file with mode: 0755]
smo-install/test/apex-policy-test/apex-policy-test.sh
smo-install/test/pythonsdk/src/oransdk/dmaap/dmaap.py
smo-install/test/pythonsdk/src/orantests/configuration/settings.py
smo-install/test/pythonsdk/src/orantests/conftest.py [new file with mode: 0644]
smo-install/test/pythonsdk/src/orantests/resources/network-simulators-override.yaml [new file with mode: 0644]
smo-install/test/pythonsdk/src/orantests/resources/network-simulators-topology-override.yaml [new file with mode: 0644]
smo-install/test/pythonsdk/src/orantests/test_o1.py [new file with mode: 0644]
smo-install/test/pythonsdk/test.json [new file with mode: 0644]
smo-install/test/pythonsdk/tox.ini
smo-install/test/topology-generator/network-topology-converter.py [new file with mode: 0755]

index ca733d7..307376d 100644 (file)
@@ -10,7 +10,7 @@ requirements.lock
 .settings/
 
 # IntelliJ
-.idea/*
+**/.idea/*
 *.iml
 
 # Mac OS
index bdb3f12..308e98a 100644 (file)
@@ -306,17 +306,17 @@ policy:
   policy-clamp-fe:
     enabled: false
   policy-clamp-cl-runtime:
-    enabled: false
+    enabled: true
   policy-clamp-cl-k8s-ppnt:
-    enabled: false
+    enabled: true
   policy-gui:
     enabled: false
   policy-nexus:
     enabled: false
   policy-clamp-cl-pf-ppnt:
-    enabled: false
+    enabled: true
   policy-clamp-cl-http-ppnt:
-    enabled: false
+    enabled: true
 
 pomba:
   enabled: false
diff --git a/smo-install/scripts/uninstall-simulators.sh b/smo-install/scripts/uninstall-simulators.sh
new file mode 100755 (executable)
index 0000000..e93eb67
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# ORAN SMO Package
+# ================================================================================
+# Copyright (C) 2021 AT&T Intellectual Property. All rights
+#                             reserved.
+# ================================================================================
+# 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.
+# ============LICENSE_END============================================
+# ===================================================================
+# 
+###
+
+SCRIPT=$(readlink -f "$0")
+SCRIPT_PATH=$(dirname "$SCRIPT")
+cd $SCRIPT_PATH
+
+echo "Stopping Network Simulators namespace ..."
+./sub-scripts/uninstall-simulators.sh
+
+kubectl get pods -n network
+kubectl get namespaces
index cd92629..0bfaee6 100755 (executable)
@@ -39,3 +39,113 @@ echo "Dmaap url: $dmaap_url"
 sdnc_url=`kubectl get services -n onap | grep sdnc-oam | awk  '{print $3}'`:$sdnc_port
 echo "SDNC url: $sdnc_url"
 echo -e "\n"
+
+verifyApexPolicyStatus(){
+    for i in {1..60}; do
+        curl  -s -o /dev/null -X POST -H accept:application/json -H Content-Type:application/json "http://$dmaap_url/events/unauthenticated.SEC_FAULT_OUTPUT/" -d @./data/LinkFailureEvent.json
+        sleep 3
+        res=`kubectl logs onap-policy-apex-pdp-0 -n onap | grep "Task Selection Execution: 'LinkMonitorPolicy:0.0.1:NULL:LinkFailureOrClearedState'" | wc -l`
+        if [[ $res != 0 ]]; then
+            echo -e "LinkFailureEvent sent to Dmaap\n"
+            break;
+        else
+            sleep 2
+        fi
+    done
+}
+
+checkStatus(){
+        echo "res:$1"
+        if [ "$1" == "$2" ]; then
+            echo -e "$3\n"
+        else
+            echo -e "Result is not as expected: $2\n"
+            exit;
+        fi
+}
+
+checkPolicyStatus(){
+    for i in {1..60}; do
+        res=$(curl -sk -u 'healthcheck:zb!XztG34' -X GET "https://$pap_url/policy/pap/v1/components/healthcheck")
+        apex_info=$(echo $res| cut -d'{' -f 4)
+
+        echo "Verify policy Pap"
+        if [[ $res == *"url\":\"https://$1:6969/policy/pap/v1/healthcheck\",\"healthy\":true"* ]]; then
+          echo "Policy Pap is ready"
+          echo "Verify policy api"
+          if [[ $res == *"url\":\"https://$2:6969/policy/api/v1/healthcheck\",\"healthy\":true"* ]]; then
+            echo "Policy API is ready"
+            echo "Verify policy Apex pdp"
+            if [[ $apex_info == *"instanceId\":\"apex"*  && $apex_info == *"healthy\":\"HEALTHY"* ]]; then
+              echo "Policy APEX pdp is ready"
+              break;
+            else
+              echo "Policy Apex pdp not ready yet. Wait for a while and retry."
+              sleep $i
+            fi
+          else
+            echo "Policy api not ready yet. Wait for a while and retry."
+            sleep $i
+          fi
+        else
+          echo "Policy Pap not ready yet. Wait for a while and retry."
+          sleep $i
+        fi
+    done
+}
+
+checkPolicyDeployment (){
+  res=$(curl -sk -u 'healthcheck:zb!XztG34' -X GET "https://$pap_url/policy/pap/v1/policies/status")
+  str1="onap.policies.native.apex.LinkMonitor\",\"version\":\"1.0.0\"},\"policyType\":{\"name\":\"onap.policies.native.Apex\",\"version\":\"1.0.0\"},\"deploy\":true"
+        if [[ $res == *"$str1"* ]]; then
+          echo "Policy successfully deployed"
+        else
+          echo "Policy deployment failed"
+          exit;
+        fi
+}
+
+echo "Create topic:"
+curl -sk -X POST "http://$dmaap_url/topics/create" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"topicName\": \"unauthenticated.SEC_FAULT_OUTPUT\",  \"topicDescription\": \"test topic\",  \"partitionCount\": 1,  \"replicationCnCount\": 1,  \"transactionEnabled\": \"false\"}"
+echo "Get topics:"
+curl -sk http://$dmaap_url/topics/listAll
+echo -e "\n"
+
+echo "Policy component healthcheck:"
+pap_pod=`kubectl get pods -n onap | grep onap-policy-pap | awk  '{print $1}'`
+api_pod=`kubectl get pods -n onap | grep onap-policy-api | awk  '{print $1}'`
+checkPolicyStatus $pap_pod $api_pod
+echo -e "\n"
+
+echo "Create policy:"
+res=`curl -sk -u 'healthcheck:zb!XztG34' -X POST "https://$api_url/policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies" -H "Accept: application/json" -H "Content-Type: application/json" -d @./data/ToscaPolicy.json`
+res2=`curl -sk -u 'healthcheck:zb!XztG34' -X GET "https://$api_url/policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies/onap.policies.native.apex.LinkMonitor/versions/1.0.0"`
+if [[ $res2 ]]; then
+    echo "Policy created successfully"
+fi
+echo -e "\n"
+
+echo "Deploy the policy to apex-pdp via Policy PAP:"
+curl -sk -u 'healthcheck:zb!XztG34' -X POST "https://$pap_url/policy/pap/v1/pdps/policies" -H "Accept: application/json" -H "Content-Type: application/json" -d @./data/DeployPolicyPAP.json
+echo -e "\n"
+
+echo "Verify policy deployed:"
+checkPolicyDeployment
+echo -e "\n"
+
+echo "Check O-du/O-ru status"
+res=$(curl -sk -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X GET "http://$sdnc_url/rests/data/network-topology:network-topology/topology=topology-netconf/node=o-du-1122/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=o-ru-11221")
+expected="{\"o-ran-sc-du-hello-world:du-to-ru-connection\":[{\"name\":\"o-ru-11221\",\"operational-state\":\"ENABLED\",\"administrative-state\":\"LOCKED\",\"status\":\"disconnected\"}]}"
+checkStatus $res $expected "O-ru has status LOCKED"
+
+echo -e "\n"
+echo "Wait for a while for Apex engine to be ready before sending Dmaap event"
+verifyApexPolicyStatus
+
+echo -e "\n"
+echo "Wait for a while and check O-du/O-ru status again"
+sleep 5
+res=$(curl -sk -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X GET "http://$sdnc_url/rests/data/network-topology:network-topology/topology=topology-netconf/node=o-du-1122/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=o-ru-11221")
+expected="{\"o-ran-sc-du-hello-world:du-to-ru-connection\":[{\"name\":\"o-ru-11221\",\"operational-state\":\"ENABLED\",\"administrative-state\":\"UNLOCKED\",\"status\":\"disconnected\"}]}"
+checkStatus $res $expected "O-ru has status UNLOCKED"
+
index 6affd4e..52eac7d 100644 (file)
@@ -55,6 +55,19 @@ class OranDmaap(Dmaap):
         """
         OranDmaap._send_event("unauthenticated.SEC_FAULT_OUTPUT", event, "Send link failure event")
 
+    @classmethod
+    def get_message_from_topic(cls, topic, timeout, dmaap_group, dmaap_user) -> str:
+        """
+        Get payload from any topic.
+
+        Returns:
+            the result
+
+        """
+        url = f"{cls.base_url}/events/{topic}/{dmaap_group}/{dmaap_user}?timeout={timeout}"
+        return cls.send_message('GET',
+                                  'Get payload of specific topic', url)
+
     @classmethod
     def get_result(cls) -> str:
         """
index d4fe625..6abd625 100644 (file)
@@ -80,3 +80,10 @@ POLICY_PAP_URL = "https://"+subprocess.run("kubectl get services policy-pap -n o
 POLICY_API_URL = "https://"+subprocess.run("kubectl get services policy-api -n onap |grep policy-api | awk '{print $3}'", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()+":6969"
 SDNC_URL = "http://"+subprocess.run("kubectl get services sdnc-oam -n onap |grep sdnc-oam | awk '{print $3}'", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8').strip()+":8282"
 
+### Network simulators topology
+NETWORK_SIMULATORS_RU_LIST = ["o-ru-11211","o-ru-11221","o-ru-11222","o-ru-11223"]
+NETWORK_SIMULATORS_DU_LIST = ["o-du-1121","o-du-1122"]
+NETWORK_SIMULATORS_TOPOLOGY_SERVER = ["topology-server"]
+NETWORK_SIMULATOR_DEVICES_LIST = NETWORK_SIMULATORS_RU_LIST + NETWORK_SIMULATORS_DU_LIST + NETWORK_SIMULATORS_TOPOLOGY_SERVER
+DMAAP_GROUP = "o1test"
+DMAAP_USER = "o1test"
diff --git a/smo-install/test/pythonsdk/src/orantests/conftest.py b/smo-install/test/pythonsdk/src/orantests/conftest.py
new file mode 100644 (file)
index 0000000..82d19ce
--- /dev/null
@@ -0,0 +1,95 @@
+import pytest
+import logging
+import logging.config
+from subprocess import check_output
+from waiting import wait
+import time
+from onapsdk.configuration import settings
+from oransdk.dmaap.dmaap import OranDmaap
+import os
+
+resources_path="./resources"
+
+# Set working dir as python script location
+abspath = os.path.abspath(__file__)
+dname = os.path.dirname(abspath)
+os.chdir(dname)
+
+logging.config.dictConfig(settings.LOG_CONFIG)
+logger = logging.getLogger("Test Session setup")
+
+
+def start_network_simulators():
+       cmd="kubectl create namespace network"
+       check_output(cmd, shell=True).decode('utf-8')
+       cmd=f"helm install --debug oran-simulator local/ru-du-simulators --namespace network -f {resources_path}/network-simulators-override.yaml -f {resources_path}/network-simulators-topology-override.yaml"
+       check_output(cmd, shell=True).decode('utf-8')
+
+def stop_network_simulators():
+       cmd="kubectl delete namespace network"
+       return check_output(cmd, shell=True).decode('utf-8')
+
+def is_network_simulators_up():
+       cmd="kubectl get pods --field-selector status.phase!=Running -n network"
+       result=check_output(cmd, shell=True).decode('utf-8')
+       logger.info (f"Checking if network simulators is UP:{result}")
+       if "" == result:
+               logger.info ("Network sims is Up")
+               return True
+       else:
+               logger.info ("Network sims is Down")
+               return False
+
+def is_onap_up():
+       cmd="kubectl get pods --field-selector status.phase!=Running -n onap | wc -l"
+       result=check_output(cmd, shell=True).decode('utf-8')
+       logger.info (f"Checking if ONAP is UP:{result}")
+       if int(result) <= 9:
+               logger.info ("ONAP is Up")
+               return True
+       else:
+               logger.info ("ONAP is Down")
+               return False
+
+def is_nonrtric_up():
+       cmd="kubectl get pods --field-selector status.phase!=Running -n nonrtric | wc -l"
+       result=check_output(cmd, shell=True).decode('utf-8')
+       logger.info (f"Checking if NONRTRIC is UP:{result}")
+       if int(result) == 0:
+               logger.info ("NONRTRIC is Up")
+               return True
+       else:
+               logger.info ("NONRTRIC is Down")
+               return False
+
+def wait_for_smo_to_be_running():
+       wait(lambda: is_onap_up() and is_nonrtric_up(), sleep_seconds=10, timeout_seconds=300, waiting_for="SMO to be ready")
+
+def wait_for_network_simulators_to_be_running():
+       wait(lambda: is_network_simulators_up(), sleep_seconds=10, timeout_seconds=60, waiting_for="Network simulators to be ready")
+
+def pytest_sessionstart(session):
+       wait_for_smo_to_be_running()
+       # Due to an Onap Ves bugs or dmaap ?? DU sims must send messages twice so we need to restart the sims
+       start_network_simulators()
+       wait_for_network_simulators_to_be_running()
+       time.sleep(2)
+       dmaap = OranDmaap()
+        # Do a first get to register the o1test/o1test user in DMAAP, all messages will then be stored for him
+       dmaap.get_message_from_topic("unauthenticated.VES_PNFREG_OUTPUT", 10000, settings.DMAAP_GROUP, settings.DMAAP_USER)
+
+       ## Now kill the simulators and restart them for the test session
+       stop_network_simulators()
+
+       start_network_simulators()
+       wait_for_network_simulators_to_be_running()
+       # Wait enough time to have at least the SDNR notifications sent
+       time.sleep(30)
+       logger.info ("Test Session setup completed successfully")
+
+
+
+def pytest_sessionfinish(session, exitstatus):
+       stop_network_simulators()
+       logger.info ("Test Session cleanup done")
+
diff --git a/smo-install/test/pythonsdk/src/orantests/resources/network-simulators-override.yaml b/smo-install/test/pythonsdk/src/orantests/resources/network-simulators-override.yaml
new file mode 100644 (file)
index 0000000..4749a81
--- /dev/null
@@ -0,0 +1,58 @@
+###
+# ============LICENSE_START=======================================================
+# ORAN SMO Package
+# ================================================================================
+# Copyright (C) 2021 AT&T Intellectual Property. All rights
+#                             reserved.
+# ================================================================================
+# 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.
+# ============LICENSE_END============================================
+# ===================================================================
+# 
+###
+
+##### Network Simulators #####
+
+ru-du-simulators:
+  topologyServer: true
+  ruSimulator: true
+  duSimulator: true
+
+
+x-ntsimNg: &ntsimConfig
+  sdnControllerUsername: admin
+  sdnControllerPassword: Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
+
+  vesEndpointUsername: sample1
+  vesEndpointPassword: sample1
+
+ru-simulator: 
+  ntsimNg:
+    <<: *ntsimConfig
+    ipV6Enabled: false
+    sshConnections: 0
+    tlsConnections: 1
+
+du-simulator:
+  ntsimNg:
+    <<: *ntsimConfig
+    ipV6Enabled: false
+    sshConnections: 1
+    tlsConnections: 0
+
+topology-server:
+  ntsimNg:  
+    <<: *ntsimConfig
+    ipV6Enabled: false
+    sshConnections: 0
+    tlsConnections: 1
diff --git a/smo-install/test/pythonsdk/src/orantests/resources/network-simulators-topology-override.yaml b/smo-install/test/pythonsdk/src/orantests/resources/network-simulators-topology-override.yaml
new file mode 100644 (file)
index 0000000..b500b26
--- /dev/null
@@ -0,0 +1,373 @@
+###
+# ============LICENSE_START=======================================================
+# ORAN SMO Package
+# ================================================================================
+# Copyright (C) 2021 AT&T Intellectual Property. All rights
+#                             reserved.
+# ================================================================================
+# 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.
+# ============LICENSE_END============================================
+# ===================================================================
+# 
+###
+
+
+###### Sim Topology Override ########
+ru-simulator:
+  rus:
+    - name: o-ru-11211
+      simulatedFaults:
+        - name: fault1
+          condition: "Interface Fault"
+          severity: CRITICAL
+          specificProblem: "Interface Fault"
+          faultSeverity: CRITICAL
+          cleared: false
+          text: "Interface Fault"
+          faultId: 30
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+        - name: fault1-close
+          condition: "Interface Fault"
+          severity: NORMAL
+          specificProblem: "Interface Fault"
+          faultSeverity: CRITICAL
+          cleared: true
+          text: "Interface Fault"
+          faultId: 30
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+
+        - name: fault2
+          condition: "C/U-plane logical Connection faulty"
+          severity: CRITICAL
+          specificProblem: "C/U-plane logical Connection faulty"
+          faultSeverity: CRITICAL
+          cleared: false
+          text: "C/U-plane logical Connection faulty"
+          faultId: 28
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+        - name: fault2-close
+          condition: "C/U-plane logical Connection faulty"
+          severity: NORMAL
+          specificProblem: "C/U-plane logical Connection faulty"
+          faultSeverity: CRITICAL
+          cleared: true
+          text: "C/U-plane logical Connection faulty"
+          faultId: 28
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+
+    - name: o-ru-11221
+      simulatedFaults:
+        - name: fault1
+          condition: "Interface Fault"
+          severity: CRITICAL
+          specificProblem: "Interface Fault"
+          faultSeverity: CRITICAL
+          cleared: false
+          text: "Interface Fault"
+          faultId: 30
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+        - name: fault1-close
+          condition: "Interface Fault"
+          severity: NORMAL
+          specificProblem: "Interface Fault"
+          faultSeverity: CRITICAL
+          cleared: true
+          text: "Interface Fault"
+          faultId: 30
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+
+        - name: fault2
+          condition: "C/U-plane logical Connection faulty"
+          severity: CRITICAL
+          specificProblem: "C/U-plane logical Connection faulty"
+          faultSeverity: CRITICAL
+          cleared: false
+          text: "C/U-plane logical Connection faulty"
+          faultId: 28
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+        - name: fault2-close
+          condition: "C/U-plane logical Connection faulty"
+          severity: NORMAL
+          specificProblem: "C/U-plane logical Connection faulty"
+          faultSeverity: CRITICAL
+          cleared: true
+          text: "C/U-plane logical Connection faulty"
+          faultId: 28
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+
+    - name: o-ru-11222
+      simulatedFaults:
+        - name: fault1
+          condition: "Interface Fault"
+          severity: CRITICAL
+          specificProblem: "Interface Fault"
+          faultSeverity: CRITICAL
+          cleared: false
+          text: "Interface Fault"
+          faultId: 30
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+        - name: fault1-close
+          condition: "Interface Fault"
+          severity: NORMAL
+          specificProblem: "Interface Fault"
+          faultSeverity: CRITICAL
+          cleared: true
+          text: "Interface Fault" 
+          faultId: 30
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+
+        - name: fault2
+          condition: "C/U-plane logical Connection faulty"
+          severity: CRITICAL
+          specificProblem: "C/U-plane logical Connection faulty"
+          faultSeverity: CRITICAL
+          cleared: false
+          text: "C/U-plane logical Connection faulty"
+          faultId: 28
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+        - name: fault2-close
+          condition: "C/U-plane logical Connection faulty"
+          severity: NORMAL
+          specificProblem: "C/U-plane logical Connection faulty"
+          faultSeverity: CRITICAL
+          cleared: true
+          text: "C/U-plane logical Connection faulty"
+          faultId: 28
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+
+    - name: o-ru-11223
+      simulatedFaults:
+        - name: fault1
+          condition: "Interface Fault"
+          severity: CRITICAL
+          specificProblem: "Interface Fault"
+          faultSeverity: CRITICAL
+          cleared: false
+          text: "Interface Fault"
+          faultId: 30
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+        - name: fault1-close
+          condition: "Interface Fault"
+          severity: NORMAL
+          specificProblem: "Interface Fault"
+          faultSeverity: CRITICAL
+          cleared: true
+          text: "Interface Fault" 
+          faultId: 30
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+
+        - name: fault2
+          condition: "C/U-plane logical Connection faulty"
+          severity: CRITICAL
+          specificProblem: "C/U-plane logical Connection faulty"
+          faultSeverity: CRITICAL
+          cleared: false
+          text: "C/U-plane logical Connection faulty"
+          faultId: 28
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+        - name: fault2-close
+          condition: "C/U-plane logical Connection faulty"
+          severity: NORMAL
+          specificProblem: "C/U-plane logical Connection faulty"
+          faultSeverity: CRITICAL
+          cleared: true
+          text: "C/U-plane logical Connection faulty"
+          faultId: 28
+          object: "09a95e08-5b53-4734-815f-a9c12300fc62"
+
+du-simulator:
+  dus:
+    - name: o-du-1121
+      rus:
+        - name: o-ru-11211
+          administrativeState: LOCKED
+          operationalState: ENABLED
+          status: disconnected
+
+      simulatedFaults:
+        - name: o-ru-11211
+          condition: "O-RU Port Down"
+          severity: CRITICAL
+          specificProblem: "O-RU Port Down"
+          faultSeverity: CRITICAL
+          cleared: false
+          text: "O-RU Port Down"
+        - name: o-ru-11211
+          condition: "O-RU Port Down"
+          severity: NORMAL
+          specificProblem: "O-RU Port Down"
+          faultSeverity: CRITICAL
+          cleared: true
+          text: "O-RU Port Down"
+
+    - name: o-du-1122
+      rus:
+        - name: o-ru-11221
+          administrativeState: LOCKED
+          operationalState: ENABLED
+          status: disconnected
+        - name: o-ru-11222
+          administrativeState: UNLOCKED
+          operationalState: ENABLED
+          status: connected
+        - name: o-ru-11223
+          administrativeState: LOCKED
+          operationalState: DISABLED
+          status: unable-to-connect
+
+      simulatedFaults:
+        - name: o-ru-11221
+          condition: "O-RU Port Down"
+          severity: CRITICAL
+          specificProblem: "O-RU Port Down"
+          faultSeverity: CRITICAL
+          cleared: false
+          text: "O-RU Port Down"
+        - name: o-ru-11221
+          condition: "O-RU Port Down"
+          severity: NORMAL
+          specificProblem: "O-RU Port Down"
+          faultSeverity: CRITICAL
+          cleared: true
+          text: "O-RU Port Down"
+
+        - name: o-ru-11222
+          condition: "O-RU Port Down"
+          severity: CRITICAL
+          specificProblem: "O-RU Port Down"
+          faultSeverity: CRITICAL
+          cleared: false
+          text: "O-RU Port Down"
+        - name: o-ru-11222
+          condition: "O-RU Port Down"
+          severity: NORMAL
+          specificProblem: "O-RU Port Down"
+          faultSeverity: CRITICAL
+          cleared: true
+          text: "O-RU Port Down"
+
+        - name: o-ru-11223
+          condition: "O-RU Port Down"
+          severity: CRITICAL
+          specificProblem: "O-RU Port Down"
+          faultSeverity: CRITICAL
+          cleared: false
+          text: "O-RU Port Down"
+        - name: o-ru-11223
+          condition: "O-RU Port Down"
+          severity: NORMAL
+          specificProblem: "O-RU Port Down"
+          faultSeverity: CRITICAL
+          cleared: true
+          text: "O-RU Port Down"
+
+topology-server:
+  simulatedFaults:
+    - name: fault1
+      condition: "CPRI Port Down"
+      severity: MAJOR
+      object: "Slot-0-Port-A"
+      specificProblem: "CPRI Port Down"
+      faultSeverity: MAJOR
+      cleared: false
+      text: "CPRI Port Down"
+    - name: fault1-close
+      condition: "CPRI Port Down"
+      severity: NORMAL
+      object: "Slot-0-Port-A"
+      specificProblem: "CPRI Port Down"
+      faultSeverity: MAJOR
+      cleared: true
+      text: "CPRI Port Down"
+
+    - name: fault2
+      condition: "CPRI Port Down"
+      severity: MAJOR
+      object: "Slot-0-Port-C"
+      specificProblem: "CPRI Port Down"
+      faultSeverity: MAJOR
+      cleared: false
+      text: "CPRI Port Down"
+    - name: fault2-close
+      condition: "CPRI Port Down"
+      severity: NORMAL
+      object: "Slot-0-Port-C"
+      specificProblem: "CPRI Port Down"
+      faultSeverity: MAJOR
+      cleared: true
+      text: "CPRI Port Down"
+
+    - name: fault3
+      condition: "CPRI Port Down"
+      severity: MAJOR
+      object: "Slot-2-Port-B"
+      specificProblem: "CPRI Port Down"
+      faultSeverity: MAJOR
+      cleared: false
+      text: "CPRI Port Down"
+    - name: fault3-close
+      condition: "CPRI Port Down"
+      severity: NORMAL
+      object: "Slot-2-Port-B"
+      specificProblem: "CPRI Port Down"
+      faultSeverity: MAJOR
+      cleared: false
+      text: "CPRI Port Down"
+  nodes:
+    - name: o-du-1121
+      uuid: bc089635-7a85-4197-9310-9b14f476a4b9
+      nodeEdgePointUuid: 639f24cb-a5e9-454f-b05d-6307be419aff
+      interfaceName: "O-DU-interface-1"
+      interfaceDescription: "Simulated interface for O-DU"
+    - name: o-ru-11211
+      uuid: 6b0d3930-100b-466c-9f44-2748ffb6baa2
+      nodeEdgePointUuid: bb7e5882-6e4a-46a7-a95b-0bb7310ede24
+      interfaceName: "09a95e08-5b53-4834-815f-a9c12300fc63"
+      interfaceDescription: "Simulated interface for O-RU"
+
+    - name: o-du-1122
+      uuid: ac089635-7a85-4197-9310-9b14f476a4a9
+      nodeEdgePointUuid: 539f24cb-a5e9-454f-b05d-6307be419afe
+      interfaceName: "O-DU-interface-1"
+      interfaceDescription: "Simulated interface for O-DU"
+    - name: o-ru-11221
+      uuid: 6b0d3930-100b-466c-9f44-2748ffb6aaa1
+      nodeEdgePointUuid: bb7e5882-6e3a-46a7-a95b-0bb7310ede22
+      interfaceName: "09a95e08-5b53-4734-815f-a9c12300fc62"
+      interfaceDescription: "Simulated interface for O-RU"
+    - name: o-ru-11222
+      uuid: 69a8fdf0-2bdd-44a2-9bc4-8813640fa02c
+      nodeEdgePointUuid: 124488fc-05d0-421b-8a16-4eaf86cbc89b
+      interfaceName: "0d242150-33a6-4e7c-9988-ae3b01e8a7ea"
+      interfaceDescription: "Simulated interface for O-RU"
+    - name: o-ru-11223
+      uuid: c8499a83-211e-4cef-be30-a1cc2208bbb6
+      nodeEdgePointUuid: 5f01a4c2-9067-4b05-a1a5-7d8998f4f11f
+      interfaceName: "d3ea2f17-a841-4e71-9ef9-9549159aabe7"
+      interfaceDescription: "Simulated interface for O-RU"
+
+  topologyUuid: 7adfee73-44be-4813-a0dc-89f657f0a436
+  links:
+    - duNode: o-du-1121
+      ruNode: o-ru-11211
+      uuid: ac78b69f-22df-46fd-ae76-cc989bc30bbd
+
+    - duNode: o-du-1122
+      ruNode: o-ru-11221
+      uuid: ac78b69f-22df-46fd-ae76-cc989bc30abc
+    - duNode: o-du-1122
+      ruNode: o-ru-11222
+      uuid: ac78b69f-22df-46fd-ae76-cc989bc30ae9
+    - duNode: o-du-1122
+      ruNode: o-ru-11223
+      uuid: bc98b69f-22df-46fd-ae76-cc989bc30ae9
diff --git a/smo-install/test/pythonsdk/src/orantests/test_o1.py b/smo-install/test/pythonsdk/src/orantests/test_o1.py
new file mode 100644 (file)
index 0000000..85771e8
--- /dev/null
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: Apache-2.0
+
+import logging
+from onapsdk.configuration import settings
+from oransdk.dmaap.dmaap import OranDmaap
+import json
+
+BASIC_AUTH = {}
+
+logging.config.dictConfig(settings.LOG_CONFIG)
+logger = logging.getLogger("test O1")
+
+def test_network_devices_registration():
+       logger.info("Verify if SDNR sends well the RU registration to VES by checking in DMAAP")
+       dmaap = OranDmaap()
+       # As the user has been registered in DMAAP during test session init, that call should return all sims registered by SDNR
+       events = dmaap.get_message_from_topic("unauthenticated.VES_PNFREG_OUTPUT", 10000, settings.DMAAP_GROUP, settings.DMAAP_USER).json()
+       # events should be a list of messages
+       logger.info("Verify if the number of events is well equals to the number of devices")
+       assert (len(events) >= 6)
+
+       for event in events:
+               logger.info(f"Checking event: {event}")
+               eventjson = json.loads(event)
+               logger.info("json ?"+str(eventjson))
+               assert(eventjson["event"]["commonEventHeader"]["sourceName"] in settings.NETWORK_SIMULATOR_DEVICES_LIST)
+
+               if "o-ru" in eventjson["event"]["commonEventHeader"]["sourceName"]:
+                       logger.info(f"RU event detected checking SDNR has well registered it")
+                       assert(eventjson["event"]["commonEventHeader"]["reportingEntityName"] == "ONAP SDN-R")
+               elif "o-du" in eventjson["event"]["commonEventHeader"]["sourceName"]:
+                       logger.info(f"DU detected checking it has well registered itself")
+                       assert("o-du" in eventjson["event"]["commonEventHeader"]["reportingEntityName"])
diff --git a/smo-install/test/pythonsdk/test.json b/smo-install/test/pythonsdk/test.json
new file mode 100644 (file)
index 0000000..c511a95
--- /dev/null
@@ -0,0 +1,212 @@
+{
+  "event": {
+    "commonEventHeader": {
+      "sourceId": "",
+      "startEpochMicrosec": 1639658749500474,
+      "eventId": "EventType5G-0",
+      "timeZoneOffset": "+00:00",
+      "reportingEntityId": "",
+      "internalHeaderFields": {
+        "collectorTimeStamp": "Thu, 12 16 2021 12:45:49 UTC"
+      },
+      "priority": "Normal",
+      "version": "4.1",
+      "nfVendorName": "sdn",
+      "reportingEntityName": "o-du-1121",
+      "sequence": 0,
+      "domain": "pnfRegistration",
+      "lastEpochMicrosec": 1639658749500474,
+      "eventName": "EventType5G",
+      "vesEventListenerVersion": "7.2.1",
+      "sourceName": "o-du-1121",
+      "nfNamingCode": "sdn controller"
+    },
+    "pnfRegistrationFields": {
+      "unitType": "O-RAN-sim",
+      "macAddress": "19:17:b0:ba:ad:16",
+      "serialNumber": "o-du-1121-10.1.42.145-830-Simulated Device Melacon",
+      "additionalFields": {
+        "protocol": "SSH",
+        "password": "netconf!",
+        "oamPort": "830",
+        "betweenAttemptsTimeout": "2000",
+        "keepaliveDelay": "120",
+        "sleep-factor": "1.5",
+        "reconnectOnChangedSchema": "false",
+        "connectionTimeout": "20000",
+        "maxConnectionAttempts": "100",
+        "username": "netconf",
+        "tcpOnly": "false"
+      },
+      "pnfRegistrationFieldsVersion": "2.0",
+      "manufactureDate": "2019-08-16",
+      "modelNumber": "Simulated Device Melacon",
+      "lastServiceDate": "2019-08-16",
+      "unitFamily": "Simulated Device",
+      "vendorName": "Melacon",
+      "oamV4IpAddress": "10.1.42.145",
+      "softwareVersion": "2.3.5"
+    }
+  }
+}","{
+  "event": {
+    "commonEventHeader": {
+      "sourceId": "",
+      "startEpochMicrosec": 1639658750697573,
+      "eventId": "EventType5G-0",
+      "timeZoneOffset": "+00:00",
+      "reportingEntityId": "",
+      "internalHeaderFields": {
+        "collectorTimeStamp": "Thu, 12 16 2021 12:45:50 UTC"
+      },
+      "priority": "Normal",
+      "version": "4.1",
+      "nfVendorName": "sdn",
+      "reportingEntityName": "o-du-1122",
+      "sequence": 0,
+      "domain": "pnfRegistration",
+      "lastEpochMicrosec": 1639658750697573,
+      "eventName": "EventType5G",
+      "vesEventListenerVersion": "7.2.1",
+      "sourceName": "o-du-1122",
+      "nfNamingCode": "sdn controller"
+    },
+    "pnfRegistrationFields": {
+      "unitType": "O-RAN-sim",
+      "macAddress": "90:6c:3c:27:e3:d6",
+      "serialNumber": "o-du-1122-10.1.42.253-830-Simulated Device Melacon",
+      "additionalFields": {
+        "protocol": "SSH",
+        "password": "netconf!",
+        "oamPort": "830",
+        "betweenAttemptsTimeout": "2000",
+        "keepaliveDelay": "120",
+        "sleep-factor": "1.5",
+        "reconnectOnChangedSchema": "false",
+        "connectionTimeout": "20000",
+        "maxConnectionAttempts": "100",
+        "username": "netconf",
+        "tcpOnly": "false"
+      },
+      "pnfRegistrationFieldsVersion": "2.0",
+      "manufactureDate": "2019-08-16",
+      "modelNumber": "Simulated Device Melacon",
+      "lastServiceDate": "2019-08-16",
+      "unitFamily": "Simulated Device",
+      "vendorName": "Melacon",
+      "oamV4IpAddress": "10.1.42.253",
+      "softwareVersion": "2.3.5"
+    }
+  }
+}","{
+  "event": {
+    "commonEventHeader": {
+      "sourceId": "o-ru-11223",
+      "startEpochMicrosec": 1639658756241000,
+      "eventId": "o-ru-11223",
+      "nfcNamingCode": "",
+      "timeZoneOffset": "+00:00",
+      "internalHeaderFields": {
+        "collectorTimeStamp": "Thu, 12 16 2021 12:45:56 UTC"
+      },
+      "eventType": "NetConf Callhome Registration",
+      "priority": "Normal",
+      "version": "4.1",
+      "nfVendorName": "NTS",
+      "reportingEntityName": "ONAP SDN-R",
+      "sequence": 0,
+      "domain": "pnfRegistration",
+      "lastEpochMicrosec": 1639658756241000,
+      "eventName": "o-ru-11223",
+      "vesEventListenerVersion": "7.2.1",
+      "sourceName": "o-ru-11223",
+      "nfNamingCode": ""
+    },
+    "pnfRegistrationFields": {
+      "unitType": "chassis",
+      "serialNumber": "23412",
+      "additionalFields": {},
+      "pnfRegistrationFieldsVersion": "2.0",
+      "manufactureDate": "Unknown",
+      "modelNumber": "O1-O-RU-Simulator",
+      "unitFamily": "interface org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.Chassis",
+      "vendorName": "NTS",
+      "oamV4IpAddress": "10.1.42.238",
+      "softwareVersion": "3.8.1 (2029-10-30 11:47:59)"
+    }
+  }
+}","{
+  "event": {
+    "commonEventHeader": {
+      "sourceId": "o-ru-11211",
+      "startEpochMicrosec": 1639658759987000,
+      "eventId": "o-ru-11211",
+      "nfcNamingCode": "",
+      "timeZoneOffset": "+00:00",
+      "internalHeaderFields": {
+        "collectorTimeStamp": "Thu, 12 16 2021 12:46:00 UTC"
+      },
+      "eventType": "NetConf Callhome Registration",
+      "priority": "Normal",
+      "version": "4.1",
+      "nfVendorName": "NTS",
+      "reportingEntityName": "ONAP SDN-R",
+      "sequence": 0,
+      "domain": "pnfRegistration",
+      "lastEpochMicrosec": 1639658759987000,
+      "eventName": "o-ru-11211",
+      "vesEventListenerVersion": "7.2.1",
+      "sourceName": "o-ru-11211",
+      "nfNamingCode": ""
+    },
+    "pnfRegistrationFields": {
+      "unitType": "chassis",
+      "serialNumber": "23412",
+      "additionalFields": {},
+      "pnfRegistrationFieldsVersion": "2.0",
+      "manufactureDate": "Unknown",
+      "modelNumber": "O1-O-RU-Simulator",
+      "unitFamily": "interface org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.Chassis",
+      "vendorName": "NTS",
+      "oamV4IpAddress": "10.1.42.251",
+      "softwareVersion": "3.8.1 (2029-10-30 11:47:59)"
+    }
+  }
+}","{
+  "event": {
+    "commonEventHeader": {
+      "sourceId": "o-ru-11221",
+      "startEpochMicrosec": 1639658763586000,
+      "eventId": "o-ru-11221",
+      "nfcNamingCode": "",
+      "timeZoneOffset": "+00:00",
+      "internalHeaderFields": {
+        "collectorTimeStamp": "Thu, 12 16 2021 12:46:03 UTC"
+      },
+      "eventType": "NetConf Callhome Registration",
+      "priority": "Normal",
+      "version": "4.1",
+      "nfVendorName": "NTS",
+      "reportingEntityName": "ONAP SDN-R",
+      "sequence": 0,
+      "domain": "pnfRegistration",
+      "lastEpochMicrosec": 1639658763586000,
+      "eventName": "o-ru-11221",
+      "vesEventListenerVersion": "7.2.1",
+      "sourceName": "o-ru-11221",
+      "nfNamingCode": ""
+    },
+    "pnfRegistrationFields": {
+      "unitType": "chassis",
+      "serialNumber": "23412",
+      "additionalFields": {},
+      "pnfRegistrationFieldsVersion": "2.0",
+      "manufactureDate": "Unknown",
+      "modelNumber": "O1-O-RU-Simulator",
+      "unitFamily": "interface org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.Chassis",
+      "vendorName": "NTS",
+      "oamV4IpAddress": "10.1.42.237",
+      "softwareVersion": "3.8.1 (2029-10-30 11:47:59)"
+    }
+  }
+}
index 7475a4f..5ce0b66 100644 (file)
@@ -9,7 +9,7 @@ deps =
     pytest-cov==2.10.1
     pydocstyle==5.1.1
     onapsdk==9.0.0
-
+    waiting==1.4.1
 passenv = *
 
 [testenv:unit-tests]
diff --git a/smo-install/test/topology-generator/network-topology-converter.py b/smo-install/test/topology-generator/network-topology-converter.py
new file mode 100755 (executable)
index 0000000..e2a4c7b
--- /dev/null
@@ -0,0 +1,67 @@
+#!/usr/bin/env python3
+
+import json
+import sys
+import yaml
+
+def read_json_topology_file (filename):
+       return json.loads(open(filename, "r").read())
+
+def save_helm_override_file (helm_file, filename):
+       with open(filename, 'w') as file:
+               return yaml.dump(helm_file, file)
+
+def get_name_of_node (node):
+       for name in node["name"]:
+               if name["value-name"] == "topology-node-name":
+                       return name["value"]
+
+def search_all_topology_nodes (topology_json):
+       ru_nodes = {}
+       du_nodes = {}
+       ue_nodes = {}
+       cu_nodes = {}
+       near_rt_ric_nodes = {}
+       smo_nodes = {}
+
+       for node in topology_json["tapi-common:context"]["tapi-topology:topology-context"]["topology"][0]["node"]:
+
+               if node["o-ran-topology:function"] == "o-ran-common-identity-refs:o-ru-function":
+                       ru_nodes[get_name_of_node(node)]=node
+
+               elif node["o-ran-topology:function"] == "o-ran-common-identity-refs:o-du-function":
+                       du_nodes[get_name_of_node(node)]=node
+               elif node["o-ran-topology:function"] == "o-ran-common-identity-refs:user-equipment-function":
+                       ue_nodes[get_name_of_node(node)]=node
+               elif node["o-ran-topology:function"] == "o-ran-common-identity-refs:o-cu-up-function":
+                       cu_nodes[get_name_of_node(node)]=node
+               elif node["o-ran-topology:function"] == "o-ran-common-identity-refs:near-rt-ric-function":
+                       near_rt_ric_nodes[get_name_of_node(node)]=node
+               elif node["o-ran-topology:function"] == "o-ran-common-identity-refs:smo-function":
+                       smo_nodes[get_name_of_node(node)]=node
+       return {"ru_nodes":ru_nodes, "du_nodes": du_nodes, "ue_nodes": ue_nodes, "cu_nodes": cu_nodes, "near_rt_ric_nodes":near_rt_ric_nodes, "smo_nodes":smo_nodes}
+
+def generate_ru_node (ru_nodes):
+       rus=[]
+       for ru_key in ru_nodes:
+               rus.append({"name":ru_key, "simulatedFaults":[]})
+       return {"ru_simulator":{"rus":rus}}
+
+def generate_ru_faults ():
+       return {}
+
+all_nodes=search_all_topology_nodes(read_json_topology_file (sys.argv[1]))
+helm_override={}
+helm_override = {**helm_override, **generate_ru_node(all_nodes["ru_nodes"])}
+
+
+print ("#RU:"+str(len(all_nodes["ru_nodes"])))
+print ("#DU:"+str(len(all_nodes["du_nodes"])))
+print ("#UE:"+str(len(all_nodes["ue_nodes"])))
+print ("#CU:"+str(len(all_nodes["cu_nodes"])))
+print ("#NEAR_RTRIC:"+str(len(all_nodes["near_rt_ric_nodes"])))
+print ("#SMO:"+str(len(all_nodes["smo_nodes"])))
+number_of_nodes=len(all_nodes["ru_nodes"])+len(all_nodes["du_nodes"])+len(all_nodes["ue_nodes"])+len(all_nodes["cu_nodes"])+len(all_nodes["near_rt_ric_nodes"])+len(all_nodes["smo_nodes"])
+print ("#Nodes(total):"+str(number_of_nodes))
+
+print(save_helm_override_file(helm_override, sys.argv[2]))