blob: b311e9bd68baa1de768386302990037cffb034d2 [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation The main interface for interacting with SDN-GC. It handles low level stuff like managing the http request library and SDN-GC required fields
3Library RequestsLibrary
Jerry Floodd40619e2017-08-24 09:38:48 -04004Library UUID
DR695Hccff30b2017-02-17 18:44:24 -05005Library OperatingSystem
6Library ExtendedSelenium2Library
7Library Collections
8Library String
9Library StringTemplater
10Resource global_properties.robot
11Resource ../resources/json_templater.robot
12Resource browser_setup.robot
13
14Variables ../assets/service_mappings.py
15
16*** Variables ***
17${PRELOAD_VNF_TOPOLOGY_OPERATION_PATH} /operations/VNF-API:preload-vnf-topology-operation
18${PRELOAD_VNF_CONFIG_PATH} /config/VNF-API:preload-vnfs/vnf-preload-list
19${PRELOAD_VNF_TOPOLOGY_OPERATION_BODY} robot/assets/templates/sdnc/
20${SDNGC_INDEX_PATH} /restconf
21${SDNCGC_HEALTHCHECK_OPERATION_PATH} /operations/SLI-API:healthcheck
DR695Hbf5a3a32017-06-30 13:09:57 -040022${SDNGC_REST_ENDPOINT} ${GLOBAL_SDNGC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDNC_IP_ADDR}:${GLOBAL_SDNGC_REST_PORT}
Gary Wu251aa682018-07-30 15:22:20 -070023${SDNGC_ADMIN_ENDPOINT} ${GLOBAL_SDNGC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDNC_PORTAL_IP_ADDR}:${GLOBAL_SDNGC_ADMIN_PORT}
DR695Hccff30b2017-02-17 18:44:24 -050024${SDNGC_ADMIN_SIGNUP_URL} ${SDNGC_ADMIN_ENDPOINT}/signup
25${SDNGC_ADMIN_LOGIN_URL} ${SDNGC_ADMIN_ENDPOINT}/login
26${SDNGC_ADMIN_VNF_PROFILE_URL} ${SDNGC_ADMIN_ENDPOINT}/mobility/getVnfProfile
27
28*** Keywords ***
29Run SDNGC Health Check
30 [Documentation] Runs an SDNGC healthcheck
31 ${resp}= Run SDNGC Post Request ${SDNGC_INDEX PATH}${SDNCGC_HEALTHCHECK_OPERATION_PATH} ${None}
32 Should Be Equal As Strings ${resp.status_code} 200
Jerry Floodd40619e2017-08-24 09:38:48 -040033 Should Be Equal As Strings ${resp.json()['output']['response-code']} 200
DR695Hccff30b2017-02-17 18:44:24 -050034
35Run SDNGC Get Request
36 [Documentation] Runs an SDNGC get request
37 [Arguments] ${data_path}
38 ${auth}= Create List ${GLOBAL_SDNGC_USERNAME} ${GLOBAL_SDNGC_PASSWORD}
39 Log Creating session ${SDNGC_REST_ENDPOINT}
40 ${session}= Create Session sdngc ${SDNGC_REST_ENDPOINT} auth=${auth}
41 ${uuid}= Generate UUID
42 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
43 ${resp}= Get Request sdngc ${data_path} headers=${headers}
44 Log Received response from sdngc ${resp.text}
45 [Return] ${resp}
Jerry Floodd40619e2017-08-24 09:38:48 -040046
DR695Hccff30b2017-02-17 18:44:24 -050047Run SDNGC Put Request
48 [Documentation] Runs an SDNGC put request
49 [Arguments] ${data_path} ${data}
50 ${auth}= Create List ${GLOBAL_SDNGC_USERNAME} ${GLOBAL_SDNGC_PASSWORD}
51 Log Creating session ${SDNGC_REST_ENDPOINT}
52 ${session}= Create Session sdngc ${SDNGC_REST_ENDPOINT} auth=${auth}
53 ${uuid}= Generate UUID
54 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
55 ${resp}= Put Request sdngc ${data_path} data=${data} headers=${headers}
56 Log Received response from sdngc ${resp.text}
57 [Return] ${resp}
58
59Run SDNGC Post Request
60 [Documentation] Runs an SDNGC post request
61 [Arguments] ${data_path} ${data}
62 ${auth}= Create List ${GLOBAL_SDNGC_USERNAME} ${GLOBAL_SDNGC_PASSWORD}
63 Log Creating session ${SDNGC_REST_ENDPOINT}
64 ${session}= Create Session sdngc ${SDNGC_REST_ENDPOINT} auth=${auth}
65 ${uuid}= Generate UUID
66 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
67 ${resp}= Post Request sdngc ${data_path} data=${data} headers=${headers}
68 Log Received response from sdngc ${resp.text}
Jerry Floodd40619e2017-08-24 09:38:48 -040069 [Return] ${resp}
70
DR695Hccff30b2017-02-17 18:44:24 -050071Run SDNGC Delete Request
72 [Documentation] Runs an SDNGC delete request
73 [Arguments] ${data_path}
74 ${auth}= Create List ${GLOBAL_SDNGC_USERNAME} ${GLOBAL_SDNGC_PASSWORD}
75 Log Creating session ${SDNGC_REST_ENDPOINT}
76 ${session}= Create Session sdngc ${SDNGC_REST_ENDPOINT} auth=${auth}
77 ${uuid}= Generate UUID
78 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
79 ${resp}= Delete Request sdngc ${data_path} headers=${headers}
80 Log Received response from sdngc ${resp.text}
81 [Return] ${resp}
82
83
84Preload Vnf
85 [Arguments] ${service_type_uuid} ${generic_vnf_name} ${generic_vnf_type} ${vf_module_name} ${vf_modules} ${service} ${uuid}
Jerry Flood3a169a32017-12-01 12:39:10 -050086 ${base_vf_module_type}= Catenate
DR695Hccff30b2017-02-17 18:44:24 -050087 ${closedloop_vf_module}= Create Dictionary
88 ${templates}= Get From Dictionary ${GLOBAL_SERVICE_TEMPLATE_MAPPING} ${service}
89 :for ${vf_module} in @{vf_modules}
90 \ ${vf_module_type}= Get From Dictionary ${vf_module} name
91 \ ${dict} Get From Mapping ${templates} ${vf_module}
92 \ ${filename}= Get From Dictionary ${dict} template
93 \ ${base_vf_module_type}= Set Variable If '${dict['isBase']}' == 'true' ${vf_module_type} ${base_vf_module_type}
94 \ ${closedloop_vf_module}= Set Variable If '${dict['isBase']}' == 'false' ${vf_module} ${closedloop_vf_module}
Jerry Floodd40619e2017-08-24 09:38:48 -040095 \ ${vf_name}= Update Module Name ${dict} ${vf_module_name}
96 \ Preload Vnf Profile ${vf_module_type}
DR695Hccff30b2017-02-17 18:44:24 -050097 \ Preload One Vnf Topology ${service_type_uuid} ${generic_vnf_name} ${generic_vnf_type} ${vf_name} ${vf_module_type} ${service} ${filename} ${uuid}
Jerry Floodd40619e2017-08-24 09:38:48 -040098 [Return] ${base_vf_module_type} ${closedloop_vf_module}
DR695Hccff30b2017-02-17 18:44:24 -050099
100
101Update Module Name
102 [Arguments] ${dict} ${vf_module_name}
103 Return From Keyword If 'prefix' not in ${dict} ${vf_module_name}
104 Return From Keyword If '${dict['prefix']}' == '' ${vf_module_name}
Jerry Floodd40619e2017-08-24 09:38:48 -0400105 ${name}= Replace String ${vf_module_name} Vfmodule_ ${dict['prefix']}
106 [Return] ${name}
DR695Hccff30b2017-02-17 18:44:24 -0500107
108Get From Mapping
Jerry Floodd40619e2017-08-24 09:38:48 -0400109 [Documentation] Retrieve the appropriate prelad template entry for the passed vf_module
DR695Hccff30b2017-02-17 18:44:24 -0500110 [Arguments] ${templates} ${vf_module}
111 ${vf_module_name}= Get From DIctionary ${vf_module} name
Jerry Floodd40619e2017-08-24 09:38:48 -0400112 :for ${template} in @{templates}
113 \ Return From Keyword If '${template['name_pattern']}' in '${vf_module_name}' ${template}
DR695Hccff30b2017-02-17 18:44:24 -0500114 [Return] None
Jerry Floodd40619e2017-08-24 09:38:48 -0400115
DR695Hccff30b2017-02-17 18:44:24 -0500116Preload One Vnf Topology
117 [Arguments] ${service_type_uuid} ${generic_vnf_name} ${generic_vnf_type} ${vf_module_name} ${vf_module_type} ${service} ${filename} ${uuid}
118 Return From Keyword If '${filename}' == ''
Jerry Floodd40619e2017-08-24 09:38:48 -0400119 ${data_template}= OperatingSystem.Get File ${PRELOAD_VNF_TOPOLOGY_OPERATION_BODY}/preload.template
Bin Yang326219a2018-05-31 05:35:33 +0000120 ${parameters}= Get Template Parameters ${generic_vnf_name} ${filename} ${uuid}
Jerry Flood81d33fb2017-11-21 16:21:21 -0500121 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}
Jerry Floodd40619e2017-08-24 09:38:48 -0400122 ${data}= Fill JSON Template ${data_template} ${parameters}
DR695Hccff30b2017-02-17 18:44:24 -0500123 ${put_resp}= Run SDNGC Post Request ${SDNGC_INDEX_PATH}${PRELOAD_VNF_TOPOLOGY_OPERATION_PATH} ${data}
Jerry Floodd40619e2017-08-24 09:38:48 -0400124 Should Be Equal As Strings ${put_resp.json()['output']['response-code']} 200
DR695Hccff30b2017-02-17 18:44:24 -0500125 ${get_resp}= Run SDNGC Get Request ${SDNGC_INDEX_PATH}${PRELOAD_VNF_CONFIG_PATH}/${vf_module_name}/${vf_module_type}
126 Should Be Equal As Strings ${get_resp.status_code} 200
127
128Get Template Parameters
Bin Yang326219a2018-05-31 05:35:33 +0000129 [Arguments] ${generic_vnf_name} ${template} ${uuid}
DR695Hccff30b2017-02-17 18:44:24 -0500130 ${rest} ${suite}= Split String From Right ${SUITE NAME} . 1
131 ${uuid}= Catenate ${uuid}
132 ${hostid}= Get Substring ${uuid} -4
Jerry Flood81d33fb2017-11-21 16:21:21 -0500133 ${ecompnet}= Evaluate (${GLOBAL_BUILD_NUMBER}%128)+128
134
135
DR695Hccff30b2017-02-17 18:44:24 -0500136 # Initialize the value map with the properties generated from the Robot VM /opt/config folder
Jerry Flood81d33fb2017-11-21 16:21:21 -0500137 ${valuemap}= Copy Dictionary ${GLOBAL_INJECTED_PROPERTIES}
138
139 # These should be deprecated by the above....
Jerry Flood028e1852017-03-16 16:44:17 -0400140 Set To Dictionary ${valuemap} artifacts_version=${GLOBAL_INJECTED_ARTIFACTS_VERSION}
Jerry Floodd40619e2017-08-24 09:38:48 -0400141 Set To Dictionary ${valuemap} network=${GLOBAL_INJECTED_NETWORK}
Jerry Floodd7503152017-10-09 16:33:00 -0400142 Set To Dictionary ${valuemap} public_net_id=${GLOBAL_INJECTED_PUBLIC_NET_ID}
143 Set To Dictionary ${valuemap} cloud_env=${GLOBAL_INJECTED_CLOUD_ENV}
Jerry Flood81d33fb2017-11-21 16:21:21 -0500144 Set To Dictionary ${valuemap} install_script_version=${GLOBAL_INJECTED_SCRIPT_VERSION}
Jerry Floodd7503152017-10-09 16:33:00 -0400145 Set To Dictionary ${valuemap} vm_image_name=${GLOBAL_INJECTED_VM_IMAGE_NAME}
Jerry Flood81d33fb2017-11-21 16:21:21 -0500146 Set To Dictionary ${valuemap} vm_flavor_name=${GLOBAL_INJECTED_VM_FLAVOR}
147
148
DR695Hccff30b2017-02-17 18:44:24 -0500149 # update the value map with unique values.
Bin Yang326219a2018-05-31 05:35:33 +0000150 Set To Dictionary ${valuemap} uuid=${uuid} hostid=${hostid} ecompnet=${ecompnet} generic_vnf_name=${generic_vnf_name}
Jerry Flood81d33fb2017-11-21 16:21:21 -0500151
152 #
153 # Mash together the defaults dict with the test case dict to create the set of
154 # preload parameters
155 #
DR695Hccff30b2017-02-17 18:44:24 -0500156 ${suite_templates}= Get From Dictionary ${GLOBAL_PRELOAD_PARAMETERS} ${suite}
157 ${template}= Get From Dictionary ${suite_templates} ${template}
Jerry Flood81d33fb2017-11-21 16:21:21 -0500158 ${defaults}= Get From Dictionary ${GLOBAL_PRELOAD_PARAMETERS} defaults
159 # add all of the defaults to template...
160 @{keys}= Get Dictionary Keys ${defaults}
161 :for ${key} in @{keys}
162 \ ${value}= Get From Dictionary ${defaults} ${key}
163 \ Set To Dictionary ${template} ${key} ${value}
164
165 #
166 # Get the vnf_parameters to preload
167 #
168 ${vnf_parameters}= Resolve VNF Parameters Into Array ${valuemap} ${template}
Jerry Floodd40619e2017-08-24 09:38:48 -0400169 ${vnf_parameters_json}= Evaluate json.dumps(${vnf_parameters}) json
Jerry Flood81d33fb2017-11-21 16:21:21 -0500170 ${parameters}= Create Dictionary vnf_parameters=${vnf_parameters_json}
DR695Hccff30b2017-02-17 18:44:24 -0500171 [Return] ${parameters}
Jerry Floodd40619e2017-08-24 09:38:48 -0400172
173Resolve Values Into Dictionary
DR695Hccff30b2017-02-17 18:44:24 -0500174 [Arguments] ${valuemap} ${from} ${to}
175 ${keys}= Get Dictionary Keys ${from}
176 :for ${key} in @{keys}
177 \ ${value}= Get From Dictionary ${from} ${key}
178 \ ${value}= Template String ${value} ${valuemap}
179 \ Set To Dictionary ${to} ${key} ${value}
Jerry Floodd40619e2017-08-24 09:38:48 -0400180
181Resolve VNF Parameters Into Array
Jerry Flood81d33fb2017-11-21 16:21:21 -0500182 [Arguments] ${valuemap} ${from}
Jerry Floodd40619e2017-08-24 09:38:48 -0400183 ${vnf_parameters}= Create List
184 ${keys}= Get Dictionary Keys ${from}
185 :for ${key} in @{keys}
186 \ ${value}= Get From Dictionary ${from} ${key}
187 \ ${value}= Template String ${value} ${valuemap}
188 \ ${parameter}= Create Dictionary vnf-parameter-name=${key} vnf-parameter-value=${value}
189 \ Append To List ${vnf_parameters} ${parameter}
190 [Return] ${vnf_parameters}
191
DR695Hccff30b2017-02-17 18:44:24 -0500192Preload Vnf Profile
193 [Arguments] ${vnf_name}
194 Login To SDNGC Admin GUI
195 Go To ${SDNGC_ADMIN_VNF_PROFILE_URL}
196 Click Button xpath=//button[@data-target='#add_vnf_profile']
197 Input Text xpath=//input[@id='nf_vnf_type'] ${vnf_name}
198 Input Text xpath=//input[@id='nf_availability_zone_count'] 999
199 Input Text xpath=//input[@id='nf_equipment_role'] robot-ete-test
200 Click Button xpath=//button[contains(.,'Submit')]
Jerry Floodd40619e2017-08-24 09:38:48 -0400201 Page Should Contain VNF Profile
DR695Hccff30b2017-02-17 18:44:24 -0500202 Input Text xpath=//div[@id='vnf_profile_filter']//input ${vnf_name}
Jerry Floodd40619e2017-08-24 09:38:48 -0400203 Page Should Contain ${vnf_name}
DR695Hccff30b2017-02-17 18:44:24 -0500204
205Delete Vnf Profile
206 [Arguments] ${vnf_name}
207 Login To SDNGC Admin GUI
208 Go To ${SDNGC_ADMIN_VNF_PROFILE_URL}
Jerry Floodd40619e2017-08-24 09:38:48 -0400209 Page Should Contain VNF Profile
DR695Hccff30b2017-02-17 18:44:24 -0500210 Input Text xpath=//div[@id='vnf_profile_filter']//input ${vnf_name}
211 Page Should Contain ${vnf_name}
Jerry Floodd40619e2017-08-24 09:38:48 -0400212 Click Button xpath=//button[contains(@onclick, '${vnf_name}')]
DR695Hccff30b2017-02-17 18:44:24 -0500213 Page Should Contain Are you sure you want to delete VNF_PROFILE
214 Click Button xpath=//button[contains(text(), 'Yes')]
215 Page Should Not Contain ${vnf_name}
Jerry Floodd40619e2017-08-24 09:38:48 -0400216
DR695Hccff30b2017-02-17 18:44:24 -0500217Login To SDNGC Admin GUI
218 [Documentation] Login To SDNGC Admin GUI
Jerry Floodd40619e2017-08-24 09:38:48 -0400219 ## Setup Browser is now being managed by the test case
DR695Hccff30b2017-02-17 18:44:24 -0500220 ## Setup Browser
221 Go To ${SDNGC_ADMIN_SIGNUP_URL}
Jerry Flood81d33fb2017-11-21 16:21:21 -0500222 ##Maximize Browser Window
DR695Hccff30b2017-02-17 18:44:24 -0500223 Set Selenium Speed ${GLOBAL_SELENIUM_DELAY}
224 Set Browser Implicit Wait ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
225 Log Logging in to ${SDNGC_ADMIN_LOGIN_URL}
226 Handle Proxy Warning
227 Title Should Be AdminPortal
Jerry Floodd40619e2017-08-24 09:38:48 -0400228 ${uuid}= Generate UUID
DR695Hccff30b2017-02-17 18:44:24 -0500229 ${shortened_uuid}= Evaluate str("${uuid}")[:12]
230 ${email}= Catenate ${shortened_uuid}@robotete.com
231 Input Text xpath=//input[@id='nf_email'] ${email}
232 Input Password xpath=//input[@id='nf_password'] ${shortened_uuid}
233 Click Button xpath=//button[@type='submit']
234 Wait Until Page Contains User created 20s
235 Go To ${SDNGC_ADMIN_LOGIN_URL}
236 Input Text xpath=//input[@id='email'] ${email}
237 Input Password xpath=//input[@id='password'] ${shortened_uuid}
238 Click Button xpath=//button[@type='submit']
239 Title Should Be SDN-C AdminPortal
240 Log Logged in to ${SDNGC_ADMIN_LOGIN_URL}