837aa9040a73ff7d1e4394e5cf9fbbc2cf44daa2
[it/test.git] / ric_robot_suite / robot / resources / e2mgr / e2mgr_interface.robot
1 *** Settings ***
2 Documentation     The main interface for interacting with RIC E2 Manager (E2Mgr).
3 ...                It handles low level stuff like managing the http request library and
4 ...                E2Mgr required fields
5 Library           RequestsLibrary
6 Library           UUID
7
8 Resource          ../global_properties.robot
9 Resource          ../json_templater.robot
10
11 *** Variables ***
12 ${E2MGR_BASE_PATH}     v1/nodeb
13 ${E2MGR_ENDPOINT}      ${GLOBAL_E2MGR_SERVER_PROTOCOL}://${GLOBAL_INJECTED_E2MGR_IP_ADDR}:${GLOBAL_E2MGR_SERVER_PORT}
14 ${E2MGR_SETUP_NODEB_TEMPLATE}     robot/assets/templates/e2mgr_setup_nodeb.template
15
16
17 *** Keywords ***
18 Run E2Mgr Health Check
19      [Documentation]  Runs E2Mgr Health check
20      ${data_path} =  Set Variable           /v1/health
21      ${resp} =       Run E2Mgr GET Request  ${data_path}
22
23 Check NodeB Status
24      [Documentation]  Check NodeB Status
25      [Arguments]      ${ran_name}
26      ${resp} =                   Run E2Mgr Get NodeB Request         ${ran_name}
27      Should Be Equal As Strings  ${resp.json()['connectionStatus']}  CONNECTED
28      [Return]                    ${resp}
29
30 Run E2Mgr Get NodeB Request
31      [Documentation]  Runs E2Mgr Get NodeB Request
32      [Arguments]      ${ran_name}
33      ${data_path} =  Set Variable             ${E2MGR_BASE_PATH}/${ran_name}
34      ${resp} =       Run E2Mgr GET Request    ${data_path}
35      Should Be Equal As Strings               ${resp.json()['ranName']}  ${ran_name}
36      [Return]        ${resp}
37
38 Run E2Mgr Get All NodeBs Request 
39      [Documentation]  Runs E2Mgr Get All NodeBs Request
40      ${data_path} =  Set Variable           ${E2MGR_BASE_PATH}/ids
41      ${resp} =       Run E2Mgr GET Request  ${data_path}
42      [Return]        ${resp}
43
44 Run E2Mgr Setup NodeB X2
45      [documentation]  Setup X2 NodeB via E2 Manager
46      [Arguments]      ${ran_name}  ${ran_ip}  ${ran_port}
47      ${data_path} =  Set Variable  ${E2MGR_BASE_PATH}/x2-setup
48      ${dict} =       Create Dictionary
49      ...              ran_name=${ran_name}
50      ...              ran_ip=${ran_ip}
51      ...              ran_port=${ran_port}
52      ${data} =       Fill JSON Template File  ${E2MGR_SETUP_NODEB_TEMPLATE}  ${dict}
53      ${resp} =       Run E2Mgr POST Request   ${data_path}                   ${data}
54      [Return]         ${resp}
55
56 Run E2Mgr Setup NodeB Endc
57      [documentation]  Setup Endc NodeB via E2 Manager
58      [Arguments]      ${ran_name}  ${ran_ip}  ${ran_port}
59      ${data_path} =  Set Variable             ${E2MGR_BASE_PATH}/endc-setup
60      ${dict} =       Create Dictionary        ran_name=${ran_name}           ran_ip=${ran_ip}   ran_port=${ran_port}
61      ${data} =       Fill JSON Template File  ${E2MGR_SETUP_NODEB_TEMPLATE}  ${dict}
62      ${resp} =       Run E2Mgr POST Request   ${data_path}                   ${data}
63      [Return]         ${resp}
64
65 Run E2Mgr Delete NodeB
66      [documentation]  Delete NodeB via E2 Manager
67      [Arguments]      ${ran_name}  
68      ${data_path} =  Set Variable                ${E2MGR_BASE_PATH}/${ran_name}
69      ${resp} =       Run E2Mgr DELETE Request    ${data_path}
70
71 #
72 Run E2Mgr GET Request
73      [Documentation]  Runs E2Mgr GET Request
74      [Arguments]      ${data_path}
75      ${auth} =       Create List
76      ...              ${GLOBAL_INJECTED_E2MGR_USER}
77      ...              ${GLOBAL_INJECTED_E2MGR_PASSWORD}
78      ${session} =    Create Session  e2mgr  ${E2MGR_ENDPOINT}  auth=${auth}
79      ${uuid} =       Generate UUID
80      ${headers} =    Create Dictionary
81      ...              Accept=application/json
82      ...              Content-Type=application/json    
83      ${resp} =       Get Request     e2mgr  ${data_path}       headers=${headers}
84      Log             Received response from E2Mgr ${resp.text}
85      Should Be True  ${resp}
86      [Return]        ${resp}
87
88 Run E2Mgr DELETE Request
89      [Documentation]    Runs E2Mgr Delete Request
90      [Arguments]     ${data_path}
91      ${auth} =       Create List
92      ...              ${GLOBAL_INJECTED_E2MGR_USER}
93      ...              ${GLOBAL_INJECTED_E2MGR_PASSWORD}
94      ${session} =    Create Session  e2mgr  ${E2MGR_ENDPOINT}  auth=${auth}
95      ${uuid} =       Generate UUID
96      ${headers} =    Create Dictionary
97      ...              Accept=application/json
98      ...              Content-Type=application/json    
99      ${resp} =       Delete Request  e2mgr  ${data_path}       headers=${headers}
100      Log             Received response from E2Mgr ${resp.text}
101      Should Be True  ${resp}
102      [Return]        ${resp}
103
104 Run E2Mgr POST Request
105      [Documentation]  Send an HTTP POST to the E2 Manager
106      [Arguments]      ${data_path}  ${data}
107      ${auth} =       Create List
108      ...              ${GLOBAL_INJECTED_E2MGR_USER}
109      ...              ${GLOBAL_INJECTED_E2MGR_PASSWORD}
110      ${session} =    Create Session  e2mgr  ${E2MGR_ENDPOINT}  auth=${auth}
111      ${headers} =    Create Dictionary
112      ...              Accept=application/json
113      ...              Content-Type=application/json    
114      ${resp} =       Post Request           e2mgr
115      ...              ${data_path}
116      ...              data=${data}
117      ...              headers=${headers}
118      Log             Received response from E2Mgr ${resp.text}
119      Should Be True  ${resp}
120      [Return]        ${resp}