[SNDC-CSIT] Add tests for device manager
[sdnc/oam.git] / csit / tests / sdnr / functional / devicemanager / _templates / 20_pnfRegistration / pnfRegistration.robot
diff --git a/csit/tests/sdnr/functional/devicemanager/_templates/20_pnfRegistration/pnfRegistration.robot b/csit/tests/sdnr/functional/devicemanager/_templates/20_pnfRegistration/pnfRegistration.robot
new file mode 100644 (file)
index 0000000..3fadf22
--- /dev/null
@@ -0,0 +1,118 @@
+*** Settings ***
+Documentation     Set VES collector endpoint details in NTS manager
+...  VES endpooint Details and NTS manager information are stored in test environemnt variable file <environment>
+...  as dictionary NETWORK_FUNCTIONS = {}, VESCOLLECTOR ={}
+...  change number devices on command line with   --variable  DEVICE_TYPE:ORAN
+...
+
+Library  ConnectLibrary
+Library  String
+Library  SDNCBaseLibrary
+Library  SDNCRestconfLibrary
+Library  NTSimManagerNG
+Library  SDNCDataProvider
+Library  ConnectApp
+
+Suite Setup  global suite setup    &{GLOBAL_SUITE_SETUP_CONFIG}
+Suite Teardown  global suite teardown
+
+
+*** Variables ***
+${DEVICE_TYPE}  DEFINE_IN_INIT
+${SIM_COUNT}  1
+${CORE_MODEL}  DEFINE_IN_INIT
+${DEVICE_TYPE_GUI}  DEFINE_IN_INIT
+${PNF_REGISTRATION_TIMEOUT}  180
+
+
+*** Test Cases ***
+Setup NTS function
+  [Tags]  nts  bringup
+  [Documentation]  configure NTS manager to support restconf registration
+  Add Network Element Connection   ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}    ${True}
+  ...  ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['IP']}     ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['PORT']}
+  ...  ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['USER']}    ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['PASSWORD']}
+  ...  Connected
+  SDNCRestconfLibrary.Should Be Equal Connection Status Until Time    ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}    Connected
+
+Start pnf ves registration from NTS function
+  [Tags]  nts  bringup
+  [Documentation]  scales number of simulated devices per device type to '0'
+  ...              set details for VES endpoint
+  ...              scales number of simulated devices per device type
+  Stop Network Function Feature    ${NETWORK_FUNCTIONS['O_RAN_FH']['NAME']}    ves-pnf-registration
+  NTSimManagerNG.set_ves_endpoint_details_nf  ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}
+  ...  ves-endpoint-protocol=${VESCOLLECTOR}[SCHEME]
+  ...  ves-endpoint-ip=${VESCOLLECTOR}[IP]
+  ...  ves-endpoint-port=${VESCOLLECTOR}[PORT]
+  ...  ves-endpoint-auth-method=${VESCOLLECTOR}[AUTHMETHOD]
+  ...  ves-endpoint-username=${VESCOLLECTOR}[USERNAME]
+  ...  ves-endpoint-password=${VESCOLLECTOR}[PASSWORD]
+  Start Network Function Feature    ${NETWORK_FUNCTIONS['O_RAN_FH']['NAME']}    ves-pnf-registration
+  NTSimManagerNG.set_ves_config_nf  ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}
+  ...  pnf-registration=${True}
+  sleep  10s  reason=Wait before start network function
+#  Log  console=True  message=Wait some time ${PNF_REGISTRATION_TIMEOUT} till request sent by NTSim
+#  ConnectApp.should_be_equal_connection_status_until_time  ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}  Connected  ${180}
+
+
+Verify connection status SSH
+  [Tags]  pnfregistration  dm-lifecycle  SSH
+  sleep  5s  reason=Wait for processing of simulated device
+  @{pnf_list}=  NTSimManagerNG.get_simulated_pnfs_nf  ${DEVICE_TYPE}  protocol=SSH
+  ${length} =  Get Length      ${pnf_list}
+  Should Not Be Equal As Integers      ${length}       0  msg=No network functions created
+
+  Log to console  ${pnf_list}
+  FOR    ${device}    IN    @{pnf_list}
+    ${node_id}=  set variable  ${device["node-id"]}
+    ${port}=  set variable  ${device["port"]}
+    Log  console=True  message=Verify connection status: ${node_id}
+    Run Keyword And Continue On Failure  ConnectApp.Should Be Equal connection status until time
+                                                                     ...  ${node_id}  Connected   ${PNF_REGISTRATION_TIMEOUT}
+    SDNCRestconfLibrary.Should Be Equal Connection Status Until Time    ${node_id}  connected  ${5}
+    ConnectApp.should_be_equal_network_element_connection_details  ${node_id}
+                                                                     ...  node-id=${node_id}
+                                                                     ...  is-required=${False}
+                                                                     ...  status=Connected
+                                                                     ...  port=${port}
+                                                                     ...  core-model-capability=${CORE_MODEL}
+                                                                     ...  device-type=${DEVICE_TYPE_GUI}
+  END
+
+Verify connection status TLS
+  [Tags]  pnfregistration  dm-lifecycle  TLS
+  @{pnf_list}=  NTSimManagerNG.get_simulated_pnfs_nf  ${DEVICE_TYPE}  protocol=TLS
+  Log to console  ${pnf_list}
+  ${length} =  Get Length      ${pnf_list}
+  Should Not Be Equal As Integers      ${length}       0  msg=No network functions created
+
+  FOR    ${device}    IN    @{pnf_list}
+    ${node_id}=  set variable  ${device["node-id"]}
+    ${port}=  set variable  ${device["port"]}
+    Log  console=True  message=Verify connection status: ${node_id}
+    Run Keyword And Continue On Failure  ConnectApp.Should Be Equal connection status until time
+                                                                     ...  ${node_id}  Connected   ${PNF_REGISTRATION_TIMEOUT}
+    SDNCRestconfLibrary.Should Be Equal Connection Status Until Time    ${node_id}  connected  ${5}
+    ConnectApp.should_be_equal_network_element_connection_details  ${node_id}
+                                                                     ...  node-id=${node_id}
+                                                                     ...  is-required=${False}
+                                                                     ...  status=Connected
+                                                                     ...  port=${port}
+                                                                     ...  core-model-capability=${CORE_MODEL}
+                                                                     ...  device-type=${DEVICE_TYPE_GUI}
+  END
+
+Remove all networkelement connections
+  [Documentation]  Delete all network element connections, should not fail if the connection is not there
+  [Tags]  restconf  dm-lifecycle
+  Stop Network Function Feature    ${NETWORK_FUNCTIONS['O_RAN_FH']['NAME']}    ves-pnf-registration
+  @{pnf_list}=  NTSimManagerNG.get_simulated_pnfs_nf  ${DEVICE_TYPE}
+  FOR    ${device}    IN    @{pnf_list}
+    ${node_id}=  set variable  ${device["node-id"]}
+    Run Keyword And Ignore Error  ConnectApp.remove network element connection filtered  validate=${True}  node-id=${node_id}
+  END
+  NTSimManagerNG.set_ves_config_nf  ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}
+  ...  pnf-registration=${False}
+  ConnectApp.Remove Network Element Connection    ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}
+