2 Documentation The main interface for interacting with SDN-GC. It handles low level stuff like managing the http request library and SDN-GC required fields
3 Library RequestsLibrary
4 Library ONAPLibrary.Utilities
5 Library SeleniumLibrary
8 Library StringTemplater
9 Library ONAPLibrary.ServiceMapping
10 Library ONAPLibrary.Templating
11 Resource global_properties.robot
12 Resource browser_setup.robot
16 ${PRELOAD_VNF_TOPOLOGY_OPERATION_PATH} /operations/VNF-API:preload-vnf-topology-operation
17 ${PRELOAD_VNF_CONFIG_PATH} /config/VNF-API:preload-vnfs/vnf-preload-list
18 ${PRELOAD_VNF_TOPOLOGY_OPERATION_BODY} sdnc
19 ${SDNGC_INDEX_PATH} /restconf
20 ${SDNCGC_HEALTHCHECK_OPERATION_PATH} /operations/SLI-API:healthcheck
21 ${SDNGC_REST_ENDPOINT} ${GLOBAL_SDNGC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDNC_IP_ADDR}:${GLOBAL_SDNGC_REST_PORT}
22 ${SDNGC_ADMIN_ENDPOINT} ${GLOBAL_SDNGC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDNC_PORTAL_IP_ADDR}:${GLOBAL_SDNGC_ADMIN_PORT}
23 ${SDNGC_ADMIN_SIGNUP_URL} ${SDNGC_ADMIN_ENDPOINT}/signup
24 ${SDNGC_ADMIN_LOGIN_URL} ${SDNGC_ADMIN_ENDPOINT}/login
25 ${SDNGC_ADMIN_VNF_PROFILE_URL} ${SDNGC_ADMIN_ENDPOINT}/mobility/getVnfProfile
28 Run SDNGC Health Check
29 [Documentation] Runs an SDNGC healthcheck
30 ${resp}= Run SDNGC Post Request ${SDNGC_INDEX PATH}${SDNCGC_HEALTHCHECK_OPERATION_PATH} ${None}
31 Should Be Equal As Strings ${resp.status_code} 200
32 Should Be Equal As Strings ${resp.json()['output']['response-code']} 200
35 [Documentation] Runs an SDNGC get request
36 [Arguments] ${data_path}
37 ${auth}= Create List ${GLOBAL_SDNGC_USERNAME} ${GLOBAL_SDNGC_PASSWORD}
38 Log Creating session ${SDNGC_REST_ENDPOINT}
39 ${session}= Create Session sdngc ${SDNGC_REST_ENDPOINT} auth=${auth}
40 ${uuid}= Generate UUID4
41 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
42 ${resp}= Get Request sdngc ${data_path} headers=${headers}
43 Log Received response from sdngc ${resp.text}
47 [Documentation] Runs an SDNGC put request
48 [Arguments] ${data_path} ${data}
49 ${auth}= Create List ${GLOBAL_SDNGC_USERNAME} ${GLOBAL_SDNGC_PASSWORD}
50 Log Creating session ${SDNGC_REST_ENDPOINT}
51 ${session}= Create Session sdngc ${SDNGC_REST_ENDPOINT} auth=${auth}
52 ${uuid}= Generate UUID4
53 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
54 ${resp}= Put Request sdngc ${data_path} data=${data} headers=${headers}
55 Log Received response from sdngc ${resp.text}
58 Run SDNGC Post Request
59 [Documentation] Runs an SDNGC post request
60 [Arguments] ${data_path} ${data}
61 ${auth}= Create List ${GLOBAL_SDNGC_USERNAME} ${GLOBAL_SDNGC_PASSWORD}
62 Log Creating session ${SDNGC_REST_ENDPOINT}
63 ${session}= Create Session sdngc ${SDNGC_REST_ENDPOINT} auth=${auth}
64 ${uuid}= Generate UUID4
65 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
66 ${resp}= Post Request sdngc ${data_path} data=${data} headers=${headers}
67 Log Received response from sdngc ${resp.text}
70 Run SDNGC Delete Request
71 [Documentation] Runs an SDNGC delete request
72 [Arguments] ${data_path}
73 ${auth}= Create List ${GLOBAL_SDNGC_USERNAME} ${GLOBAL_SDNGC_PASSWORD}
74 Log Creating session ${SDNGC_REST_ENDPOINT}
75 ${session}= Create Session sdngc ${SDNGC_REST_ENDPOINT} auth=${auth}
76 ${uuid}= Generate UUID4
77 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
78 ${resp}= Delete Request sdngc ${data_path} headers=${headers}
79 Log Received response from sdngc ${resp.text}
84 [Arguments] ${service_type_uuid} ${generic_vnf_name} ${generic_vnf_type} ${vf_module_name} ${vf_modules} ${service} ${uuid}
85 ${base_vf_module_type}= Catenate
86 ${closedloop_vf_module}= Create Dictionary
87 Set Directory default ./demo/service_mapping
88 ${templates}= Get Service Template Mapping default ${service} ${generic_vnf_type}
89 :FOR ${vf_module} IN @{vf_modules}
90 \ ${vf_module_type}= Get From Dictionary ${vf_module} name
91 # need to pass in vnf_index if non-zero
92 \ ${dict} Run Keyword If "${generic_vnf_name}".endswith('0') Get From Mapping With Index ${templates} ${vf_module} 0
93 \ ... ELSE IF "${generic_vnf_name}".endswith('1') Get From Mapping With Index ${templates} ${vf_module} 1
94 \ ... ELSE IF "${generic_vnf_name}".endswith('2') Get From Mapping With Index ${templates} ${vf_module} 2
95 \ ... ELSE Get From Mapping ${templates} ${vf_module}
96 # skip this iteration if no template
97 \ ${test_dict_length} = Get Length ${dict}
98 \ Continue For Loop If ${test_dict_length} == 0
99 \ ${filename}= Get From Dictionary ${dict} template
100 \ ${base_vf_module_type}= Set Variable If '${dict['isBase']}' == 'true' ${vf_module_type} ${base_vf_module_type}
101 \ ${closedloop_vf_module}= Set Variable If '${dict['isBase']}' == 'false' ${vf_module} ${closedloop_vf_module}
102 \ ${vf_name}= Update Module Name ${dict} ${vf_module_name}
103 # Admin portal update no longer
104 #\ Preload Vnf Profile ${vf_module_type}
105 \ Preload One Vnf Topology ${service_type_uuid} ${generic_vnf_name} ${generic_vnf_type} ${vf_name} ${vf_module_type} ${service} ${filename} ${uuid}
106 [Return] ${base_vf_module_type} ${closedloop_vf_module}
110 [Arguments] ${dict} ${vf_module_name}
111 Return From Keyword If 'prefix' not in ${dict} ${vf_module_name}
112 Return From Keyword If '${dict['prefix']}' == '' ${vf_module_name}
113 ${name}= Replace String ${vf_module_name} Vfmodule_ ${dict['prefix']}
116 Get From Mapping With Index
117 [Documentation] Retrieve the appropriate prelad template entry for the passed vf_module
118 [Arguments] ${templates} ${vf_module} ${vnf_index}=0
119 ${vf_module_name}= Get From DIctionary ${vf_module} name
120 :FOR ${template} IN @{templates}
121 \ Return From Keyword If '${template['name_pattern']}' in '${vf_module_name}' and ('${template['vnf_index']}' == '${vnf_index}') ${template}
122 ${result}= Create Dictionary
126 [Documentation] Retrieve the appropriate prelad template entry for the passed vf_module
127 [Arguments] ${templates} ${vf_module}
128 ${vf_module_name}= Get From DIctionary ${vf_module} name
129 :FOR ${template} IN @{templates}
130 \ Return From Keyword If '${template['name_pattern']}' in '${vf_module_name}' ${template}
131 ${result}= Create Dictionary
134 Preload One Vnf Topology
135 [Arguments] ${service_type_uuid} ${generic_vnf_name} ${generic_vnf_type} ${vf_module_name} ${vf_module_type} ${service} ${filename} ${uuid}
136 Return From Keyword If '${filename}' == ''
137 ${parameters}= Get Template Parameters ${generic_vnf_name} ${filename} ${uuid}
138 Set To Dictionary ${parameters} generic_vnf_name=${generic_vnf_name} generic_vnf_type=${generic_vnf_type} service_type=${service_type_uuid} vf_module_name=${vf_module_name} vf_module_type=${vf_module_type}
139 Create Environment sdnc ${GLOBAL_TEMPLATE_FOLDER}
140 ${data}= Apply Template sdnc ${PRELOAD_VNF_TOPOLOGY_OPERATION_BODY}/preload.jinja ${parameters}
141 ${put_resp}= Run SDNGC Post Request ${SDNGC_INDEX_PATH}${PRELOAD_VNF_TOPOLOGY_OPERATION_PATH} ${data}
142 Should Be Equal As Strings ${put_resp.json()['output']['response-code']} 200
143 ${get_resp}= Run SDNGC Get Request ${SDNGC_INDEX_PATH}${PRELOAD_VNF_CONFIG_PATH}/${vf_module_name}/${vf_module_type}
144 Should Be Equal As Strings ${get_resp.status_code} 200
146 Get Template Parameters
147 [Arguments] ${generic_vnf_name} ${template} ${uuid}
148 ${rest} ${suite}= Split String From Right ${SUITE NAME} . 1
149 ${uuid}= Catenate ${uuid}
150 ${hostid}= Get Substring ${uuid} -4
151 ${ecompnet}= Evaluate (${GLOBAL_BUILD_NUMBER}%128)+128
154 # Initialize the value map with the properties generated from the Robot VM /opt/config folder
155 ${valuemap}= Copy Dictionary ${GLOBAL_INJECTED_PROPERTIES}
157 # These should be deprecated by the above....
158 Set To Dictionary ${valuemap} artifacts_version=${GLOBAL_INJECTED_ARTIFACTS_VERSION}
159 Set To Dictionary ${valuemap} network=${GLOBAL_INJECTED_NETWORK}
160 Set To Dictionary ${valuemap} public_net_id=${GLOBAL_INJECTED_PUBLIC_NET_ID}
161 Set To Dictionary ${valuemap} cloud_env=${GLOBAL_INJECTED_CLOUD_ENV}
162 Set To Dictionary ${valuemap} install_script_version=${GLOBAL_INJECTED_SCRIPT_VERSION}
163 Set To Dictionary ${valuemap} vm_image_name=${GLOBAL_INJECTED_VM_IMAGE_NAME}
164 Set To Dictionary ${valuemap} vm_flavor_name=${GLOBAL_INJECTED_VM_FLAVOR}
167 # update the value map with unique values.
168 Set To Dictionary ${valuemap} uuid=${uuid} hostid=${hostid} ecompnet=${ecompnet} generic_vnf_name=${generic_vnf_name}
171 # Mash together the defaults dict with the test case dict to create the set of
174 ${suite_templates}= Get From Dictionary ${GLOBAL_PRELOAD_PARAMETERS} ${suite}
175 ${template}= Get From Dictionary ${suite_templates} ${template}
176 ${defaults}= Get From Dictionary ${GLOBAL_PRELOAD_PARAMETERS} defaults
177 # add all of the defaults to template...
178 @{keys}= Get Dictionary Keys ${defaults}
179 :FOR ${key} IN @{keys}
180 \ ${value}= Get From Dictionary ${defaults} ${key}
181 \ Set To Dictionary ${template} ${key} ${value}
184 # Get the vnf_parameters to preload
186 ${vnf_parameters}= Resolve VNF Parameters Into Array ${valuemap} ${template}
187 ${vnf_parameters_json}= Evaluate json.dumps(${vnf_parameters}) json
188 ${parameters}= Create Dictionary vnf_parameters=${vnf_parameters_json}
189 [Return] ${parameters}
191 Resolve Values Into Dictionary
192 [Arguments] ${valuemap} ${from} ${to}
193 ${keys}= Get Dictionary Keys ${from}
194 :FOR ${key} IN @{keys}
195 \ ${value}= Get From Dictionary ${from} ${key}
196 \ ${value}= Template String ${value} ${valuemap}
197 \ Set To Dictionary ${to} ${key} ${value}
199 Resolve VNF Parameters Into Array
200 [Arguments] ${valuemap} ${from}
201 ${vnf_parameters}= Create List
202 ${keys}= Get Dictionary Keys ${from}
203 :FOR ${key} IN @{keys}
204 \ ${value}= Get From Dictionary ${from} ${key}
205 \ ${value}= Template String ${value} ${valuemap}
206 \ ${parameter}= Create Dictionary vnf-parameter-name=${key} vnf-parameter-value=${value}
207 \ Append To List ${vnf_parameters} ${parameter}
208 [Return] ${vnf_parameters}
211 [Arguments] ${vnf_name}
212 Login To SDNGC Admin GUI
213 Go To ${SDNGC_ADMIN_VNF_PROFILE_URL}
214 Click Button xpath=//button[@data-target='#add_vnf_profile']
215 Input Text xpath=//input[@id='nf_vnf_type'] ${vnf_name}
216 Input Text xpath=//input[@id='nf_availability_zone_count'] 999
217 Input Text xpath=//input[@id='nf_equipment_role'] robot-ete-test
218 Click Button xpath=//button[contains(.,'Submit')]
219 Page Should Contain VNF Profile
220 Input Text xpath=//div[@id='vnf_profile_filter']//input ${vnf_name}
221 Page Should Contain ${vnf_name}
224 [Arguments] ${vnf_name}
225 Login To SDNGC Admin GUI
226 Go To ${SDNGC_ADMIN_VNF_PROFILE_URL}
227 Page Should Contain VNF Profile
228 Input Text xpath=//div[@id='vnf_profile_filter']//input ${vnf_name}
229 Page Should Contain ${vnf_name}
230 Click Button xpath=//button[contains(@onclick, '${vnf_name}')]
231 Page Should Contain Are you sure you want to delete VNF_PROFILE
232 Click Button xpath=//button[contains(text(), 'Yes')]
233 Page Should Not Contain ${vnf_name}
235 Login To SDNGC Admin GUI
236 [Documentation] Login To SDNGC Admin GUI
237 ## Setup Browser is now being managed by the test case
239 Go To ${SDNGC_ADMIN_SIGNUP_URL}
240 ##Maximize Browser Window
241 Set Selenium Speed ${GLOBAL_SELENIUM_DELAY}
242 Set Browser Implicit Wait ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
243 Log Logging in to ${SDNGC_ADMIN_LOGIN_URL}
245 Title Should Be AdminPortal
246 ${uuid}= Generate UUID4
247 ${shortened_uuid}= Evaluate str("${uuid}")[:12]
248 ${email}= Catenate ${shortened_uuid}@robotete.com
249 Input Text xpath=//input[@id='nf_email'] ${email}
250 Input Password xpath=//input[@id='nf_password'] ${shortened_uuid}
251 Click Button xpath=//button[@type='submit']
252 Wait Until Page Contains User created 20s
253 Go To ${SDNGC_ADMIN_LOGIN_URL}
254 Input Text xpath=//input[@id='email'] ${email}
255 Input Password xpath=//input[@id='password'] ${shortened_uuid}
256 Click Button xpath=//button[@type='submit']
257 Title Should Be SDN-C AdminPortal
258 Log Logged in to ${SDNGC_ADMIN_LOGIN_URL}