115f63ae3642777f4b8b12e27387d275ef2626cd
[it/test.git] / ric_robot_suite / helm / nanobot / configmap-src / public / resources / e2mgr_interface.robot
1 #   Copyright (c) 2019 AT&T Intellectual Property.
2 #   Copyright (c) 2020 HCL Technologies Limited.
3 #   Licensed under the Apache License, Version 2.0 (the "License");
4 #   you may not use this file except in compliance with the License.
5 #   You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #   Unless required by applicable law or agreed to in writing, software
10 #   distributed under the License is distributed on an "AS IS" BASIS,
11 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #   See the License for the specific language governing permissions and
13 #   limitations under the License.
14
15 *** Settings *** 
16 Documentation     The main interface for interacting with RIC E2 Manager (E2Mgr). 
17 ...                It handles low level stuff like managing the http request library and 
18 ...                E2Mgr required fields 
19 Library           RequestsLibrary 
20 Library           UUID 
21  
22 Resource          /robot/resources/global_properties.robot 
23 Resource          /robot/resources/json_templater.robot 
24  
25 *** Variables *** 
26 ${E2MGR_BASE_PATH}     v1/nodeb 
27 ${E2MGR_ENDPOINT}      ${GLOBAL_E2MGR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_E2MGR_IP_ADDR}:${GLOBAL_E2MGR_SERVER_PORT} 
28 ${E2MGR_SETUP_NODEB_TEMPLATE}     robot/assets/templates/e2mgr_setup_nodeb.template 
29  
30  
31 ** Keywords *** 
32 Run E2Mgr Health Check 
33      [Documentation]  Runs E2Mgr Health check 
34      ${data_path} =  Set Variable           /v1/health 
35      ${resp} =       Run E2Mgr GET Request      ${data_path} 
36  
37 Check NodeB Status 
38      [Documentation]  Check NodeB Status 
39      [Arguments]      ${ran_name} 
40      ${resp} =                   Run E2Mgr Get NodeB Request         ${ran_name} 
41      Should Be Equal As Strings  ${resp.json()['connectionStatus']}  CONNECTED 
42      [Return]                    ${resp} 
43  
44 Run E2Mgr Get NodeB Request 
45      [Documentation]  Runs E2Mgr Get NodeB Request 
46      [Arguments]      ${ran_name} 
47      ${data_path} =  Set Variable             ${E2MGR_BASE_PATH}/${ran_name} 
48      ${resp} =       Run E2Mgr GET Request    ${data_path} 
49      Should Be Equal As Strings               ${resp.json()['ranName']}  ${ran_name} 
50      [Return]        ${resp} 
51  
52 Run E2Mgr Get All NodeBs Request 
53      [Documentation]  Runs E2Mgr Get All NodeBs Request 
54      ${data_path} =  Set Variable           ${E2MGR_BASE_PATH}/ids 
55      ${resp} =       Run E2Mgr GET Request  ${data_path} 
56      [Return]        ${resp} 
57  
58 Run E2Mgr Setup NodeB X2 
59      [documentation]  Setup X2 NodeB via E2 Manager 
60      [Arguments]      ${ran_name}  ${ran_ip}  ${ran_port} 
61      ${data_path} =  Set Variable  ${E2MGR_BASE_PATH}/x2-setup 
62      ${dict} =       Create Dictionary 
63      ...              ran_name=${ran_name} 
64      ...              ran_ip=${ran_ip} 
65      ...              ran_port=${ran_port} 
66      ${data} =       Fill JSON Template File  ${E2MGR_SETUP_NODEB_TEMPLATE}  ${dict} 
67      ${resp} =       Run E2Mgr POST Request   ${data_path}                   ${data} 
68      [Return]         ${resp} 
69  
70 Run E2Mgr Setup NodeB Endc 
71      [documentation]  Setup Endc NodeB via E2 Manager 
72      [Arguments]      ${ran_name}  ${ran_ip}  ${ran_port} 
73      ${data_path} =  Set Variable             ${E2MGR_BASE_PATH}/endc-setup 
74      ${dict} =       Create Dictionary        ran_name=${ran_name}           ran_ip=${ran_ip}   ran_port=${ran_port} 
75      ${data} =       Fill JSON Template File  ${E2MGR_SETUP_NODEB_TEMPLATE}  ${dict} 
76      ${resp} =       Run E2Mgr POST Request   ${data_path}                   ${data} 
77      [Return]         ${resp} 
78  
79 Run E2Mgr Delete NodeB 
80      [documentation]  Delete NodeB via E2 Manager 
81      [Arguments]      ${ran_name} 
82      ${data_path} =  Set Variable                ${E2MGR_BASE_PATH}/${ran_name} 
83      ${resp} =       Run E2Mgr DELETE Request    ${data_path} 
84  
85
86 Run E2Mgr GET Request 
87      [Documentation]  Runs E2Mgr GET Request 
88      [Arguments]      ${data_path} 
89      ${auth} =       Create List 
90      ...              ${GLOBAL_INJECTED_E2MGR_USER} 
91      ...              ${GLOBAL_INJECTED_E2MGR_PASSWORD} 
92      ${session} =    Create Session  e2mgr  ${E2MGR_ENDPOINT}  auth=${auth} 
93      ${uuid} =       Generate UUID 
94      ${headers} =    Create Dictionary 
95      ...              Accept=application/json 
96      ...              Content-Type=application/json 
97      ${resp} =       Get Request     e2mgr  ${data_path}       headers=${headers} 
98      Log             Received response from E2Mgr ${resp.text} 
99      Should Be True  ${resp} 
100      [Return]        ${resp} 
101  
102 Run E2Mgr DELETE Request 
103      [Documentation]    Runs E2Mgr Delete Request 
104      [Arguments]     ${data_path} 
105      ${auth} =       Create List 
106      ...              ${GLOBAL_INJECTED_E2MGR_USER} 
107      ...              ${GLOBAL_INJECTED_E2MGR_PASSWORD} 
108      ${session} =    Create Session  e2mgr  ${E2MGR_ENDPOINT}  auth=${auth} 
109      ${uuid} =       Generate UUID 
110      ${headers} =    Create Dictionary 
111      ...              Accept=application/json 
112      ...              Content-Type=application/json 
113      ${resp} =       Delete Request  e2mgr  ${data_path}       headers=${headers} 
114      Log             Received response from E2Mgr ${resp.text} 
115      Should Be True  ${resp} 
116      [Return]        ${resp} 
117  
118 Run E2Mgr POST Request 
119      [Documentation]  Send an HTTP POST to the E2 Manager 
120      [Arguments]      ${data_path}  ${data} 
121      ${auth} =       Create List 
122      ...              ${GLOBAL_INJECTED_E2MGR_USER} 
123      ...              ${GLOBAL_INJECTED_E2MGR_PASSWORD} 
124      ${session} =    Create Session  e2mgr  ${E2MGR_ENDPOINT}  auth=${auth} 
125      ${headers} =    Create Dictionary 
126      ...              Accept=application/json 
127      ...              Content-Type=application/json 
128      ${resp} =       Post Request           e2mgr 
129      ...              ${data_path} 
130      ...              data=${data} 
131      ...              headers=${headers} 
132      Log             Received response from E2Mgr ${resp.text} 
133      Should Be True  ${resp} 
134      [Return]        ${resp} 
135