Chore: Add gerrit maven verify GHA workflow
[sdnc/oam.git] / csit / tests / sdnr / functional / devicemanager / _templates / 20_pnfRegistration / pnfRegistration.robot
1 *** Settings ***
2 Documentation     Set VES collector endpoint details in NTS manager
3 ...  VES endpooint Details and NTS manager information are stored in test environemnt variable file <environment>
4 ...  as dictionary NETWORK_FUNCTIONS = {}, VESCOLLECTOR ={}
5 ...  change number devices on command line with   --variable  DEVICE_TYPE:ORAN
6 ...
7
8 Library  ConnectLibrary
9 Library  String
10 Library  SDNCBaseLibrary
11 Library  SDNCRestconfLibrary
12 Library  NTSimManagerNG
13 Library  SDNCDataProvider
14 Library  ConnectApp
15
16 Suite Setup  global suite setup    &{GLOBAL_SUITE_SETUP_CONFIG}
17 Suite Teardown  global suite teardown
18
19
20 *** Variables ***
21 ${DEVICE_TYPE}  DEFINE_IN_INIT
22 ${SIM_COUNT}  1
23 ${CORE_MODEL}  DEFINE_IN_INIT
24 ${DEVICE_TYPE_GUI}  DEFINE_IN_INIT
25 ${PNF_REGISTRATION_TIMEOUT}  180
26
27
28 *** Test Cases ***
29 Setup NTS function
30   [Tags]  nts  bringup
31   [Documentation]  configure NTS manager to support restconf registration
32   Add Network Element Connection   device_name=${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}    is_required=${True}
33   ...  host=${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['IP']}     port=${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['PORT']}
34   ...  username=${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['USER']}    password=${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['PASSWORD']}
35   ...  check_connection_status=Connected
36   SDNCRestconfLibrary.Should Be Equal Connection Status Until Time    ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}    Connected
37
38 Start pnf ves registration from NTS function
39   [Tags]  nts  bringup
40   [Documentation]  scales number of simulated devices per device type to '0'
41   ...              set details for VES endpoint
42   ...              scales number of simulated devices per device type
43   Stop Network Function Feature    ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}    ves-pnf-registration  # stopping feature not necessary
44   NTSimManagerNG.set_ves_endpoint_details_nf  ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}
45   ...  ves-endpoint-protocol=${VESCOLLECTOR}[SCHEME]
46   ...  ves-endpoint-ip=${VESCOLLECTOR}[IP]
47   ...  ves-endpoint-port=${VESCOLLECTOR}[PORT]
48   ...  ves-endpoint-auth-method=${VESCOLLECTOR}[AUTHMETHOD]
49   ...  ves-endpoint-username=${VESCOLLECTOR}[USERNAME]
50   ...  ves-endpoint-password=${VESCOLLECTOR}[PASSWORD]
51   Start Network Function Feature    ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}    ves-pnf-registration
52   NTSimManagerNG.set_ves_config_nf  ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}
53   ...  pnf-registration=${True}
54   sleep  10s  reason=Wait before start network function
55 #  Log  console=True  message=Wait some time ${PNF_REGISTRATION_TIMEOUT} till request sent by NTSim
56 #  ConnectApp.should_be_equal_connection_status_until_time  ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}  Connected  ${180}
57
58
59 Verify connection status SSH
60   [Tags]  pnfregistration  dm-lifecycle  SSH
61   sleep  5s  reason=Wait for processing of simulated device
62   @{pnf_list}=  NTSimManagerNG.get_simulated_pnfs_nf  ${DEVICE_TYPE}  protocol=SSH
63   ${length} =   Get Length      ${pnf_list}
64   Should Not Be Equal As Integers       ${length}       0  msg=No network functions created
65
66   Log to console  ${pnf_list}
67   FOR    ${device}    IN    @{pnf_list}
68     ${node_id}=  set variable  ${device["node-id"]}
69     ${port}=  set variable  ${device["port"]}
70     Log  console=True  message=Verify connection status: ${node_id}
71     Run Keyword And Continue On Failure  ConnectApp.Should Be Equal connection status until time
72                                                                      ...  ${node_id}  Connected   ${PNF_REGISTRATION_TIMEOUT}
73     SDNCRestconfLibrary.Should Be Equal Connection Status Until Time    ${node_id}  connected  ${5}
74     ConnectApp.should_be_equal_network_element_connection_details  ${node_id}
75                                                                      ...  node-id=${node_id}
76                                                                      ...  is-required=${False}
77                                                                      ...  status=Connected
78                                                                      ...  port=${port}
79                                                                      ...  device-type=${DEVICE_TYPE_GUI}
80   END
81
82 Verify connection status TLS
83   [Tags]  pnfregistration  dm-lifecycle  TLS
84   @{pnf_list}=  NTSimManagerNG.get_simulated_pnfs_nf  ${DEVICE_TYPE}  protocol=TLS
85   Log to console  ${pnf_list}
86   ${length} =   Get Length      ${pnf_list}
87   Should Not Be Equal As Integers       ${length}       0  msg=No network functions created
88
89   FOR    ${device}    IN    @{pnf_list}
90     ${node_id}=  set variable  ${device["node-id"]}
91     ${port}=  set variable  ${device["port"]}
92     Log  console=True  message=Verify connection status: ${node_id}
93     Run Keyword And Continue On Failure  ConnectApp.Should Be Equal connection status until time
94                                                                      ...  ${node_id}  Connected   ${PNF_REGISTRATION_TIMEOUT}
95     SDNCRestconfLibrary.Should Be Equal Connection Status Until Time    ${node_id}  connected  ${5}
96     ConnectApp.should_be_equal_network_element_connection_details  ${node_id}
97                                                                      ...  node-id=${node_id}
98                                                                      ...  is-required=${False}
99                                                                      ...  status=Connected
100                                                                      ...  port=${port}
101                                                                      ...  device-type=${DEVICE_TYPE_GUI}
102   END
103
104 Remove all networkelement connections
105   [Documentation]  Delete all network element connections, should not fail if the connection is not there
106   [Tags]  restconf  dm-lifecycle
107   Stop Network Function Feature    ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}    ves-pnf-registration
108   @{pnf_list}=  NTSimManagerNG.get_simulated_pnfs_nf  ${DEVICE_TYPE}
109   FOR    ${device}    IN    @{pnf_list}
110     ${node_id}=  set variable  ${device["node-id"]}
111     Run Keyword And Ignore Error  ConnectApp.remove network element connection filtered  node-id=${node_id}
112   END
113   NTSimManagerNG.set_ves_config_nf  ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}
114   ...  pnf-registration=${False}
115   ConnectApp.Remove Network Element Connection    ${NETWORK_FUNCTIONS['${DEVICE_TYPE}']['NAME']}
116