blob: bb330b3f41d8bf242bd298b4cc9e6eafeb61f977 [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
4Library UUID
5Library 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}
23${SDNGC_ADMIN_ENDPOINT} ${GLOBAL_SDNGC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDNC_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
33 Should Be Equal As Strings ${resp.json()['output']['response-code']} 200
34
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}
46
47Run 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}
69 [Return] ${resp}
70
71Run 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}
86 ${base_vf_module_type}= Catenate ''
87 ${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}
95 \ ${vf_name}= Update Module Name ${dict} ${vf_module_name}
96 \ Preload Vnf Profile ${vf_module_type}
97 \ Preload One Vnf Topology ${service_type_uuid} ${generic_vnf_name} ${generic_vnf_type} ${vf_name} ${vf_module_type} ${service} ${filename} ${uuid}
98 [Return] ${base_vf_module_type} ${closedloop_vf_module}
99
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}
105 ${name}= Replace String ${vf_module_name} Vfmodule_ ${dict['prefix']}
106 [Return] ${name}
107
108Get From Mapping
109 [Documentation] Retrieve the appropriate prelad template entry for the passed vf_module
110 [Arguments] ${templates} ${vf_module}
111 ${vf_module_name}= Get From DIctionary ${vf_module} name
112 :for ${template} in @{templates}
113 \ Return From Keyword If '${template['name_pattern']}' in '${vf_module_name}' ${template}
114 [Return] None
115
116
117Preload One Vnf Topology
118 [Arguments] ${service_type_uuid} ${generic_vnf_name} ${generic_vnf_type} ${vf_module_name} ${vf_module_type} ${service} ${filename} ${uuid}
119 Return From Keyword If '${filename}' == ''
120 ${data_template}= OperatingSystem.Get File ${PRELOAD_VNF_TOPOLOGY_OPERATION_BODY}/${filename}
121 ${parameters}= Get Template Parameters ${filename} ${uuid}
122 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} uuid=${uuid}
123 ${data}= Fill JSON Template ${data_template} ${parameters}
124 ${put_resp}= Run SDNGC Post Request ${SDNGC_INDEX_PATH}${PRELOAD_VNF_TOPOLOGY_OPERATION_PATH} ${data}
125 Should Be Equal As Strings ${put_resp.json()['output']['response-code']} 200
126 ${get_resp}= Run SDNGC Get Request ${SDNGC_INDEX_PATH}${PRELOAD_VNF_CONFIG_PATH}/${vf_module_name}/${vf_module_type}
127 Should Be Equal As Strings ${get_resp.status_code} 200
128
129Get Template Parameters
130 [Arguments] ${template} ${uuid}
131 ${rest} ${suite}= Split String From Right ${SUITE NAME} . 1
132 ${uuid}= Catenate ${uuid}
133 ${hostid}= Get Substring ${uuid} -4
134 ${ecompnet}= Evaluate ${GLOBAL_BUILD_NUMBER}%255
135 # Initialize the value map with the properties generated from the Robot VM /opt/config folder
Jerry Flood028e1852017-03-16 16:44:17 -0400136 ${valuemap}= Create Dictionary
137 Set To Dictionary ${valuemap} artifacts_version=${GLOBAL_INJECTED_ARTIFACTS_VERSION}
138 Set To Dictionary ${valuemap} network=${GLOBAL_INJECTED_NETWORK}
DR695Hccff30b2017-02-17 18:44:24 -0500139 # update the value map with unique values.
140 Set To Dictionary ${valuemap} uuid=${uuid} hostid=${hostid} ecompnet=${ecompnet}
141 ${parameters}= Create Dictionary
142 ${defaults}= Get From Dictionary ${GLOBAL_PRELOAD_PARAMETERS} defaults
143 Resolve Values Into Dictionary ${valuemap} ${defaults} ${parameters}
144 ${suite_templates}= Get From Dictionary ${GLOBAL_PRELOAD_PARAMETERS} ${suite}
145 ${template}= Get From Dictionary ${suite_templates} ${template}
146 Resolve Values Into Dictionary ${valuemap} ${template} ${parameters}
147 [Return] ${parameters}
148
149Resolve Values Into Dictionary
150 [Arguments] ${valuemap} ${from} ${to}
151 ${keys}= Get Dictionary Keys ${from}
152 :for ${key} in @{keys}
153 \ ${value}= Get From Dictionary ${from} ${key}
154 \ ${value}= Template String ${value} ${valuemap}
155 \ Set To Dictionary ${to} ${key} ${value}
156
157Preload Vnf Profile
158 [Arguments] ${vnf_name}
159 Login To SDNGC Admin GUI
160 Go To ${SDNGC_ADMIN_VNF_PROFILE_URL}
161 Click Button xpath=//button[@data-target='#add_vnf_profile']
162 Input Text xpath=//input[@id='nf_vnf_type'] ${vnf_name}
163 Input Text xpath=//input[@id='nf_availability_zone_count'] 999
164 Input Text xpath=//input[@id='nf_equipment_role'] robot-ete-test
165 Click Button xpath=//button[contains(.,'Submit')]
166 Page Should Contain VNF Profile
167 Input Text xpath=//div[@id='vnf_profile_filter']//input ${vnf_name}
168 Page Should Contain ${vnf_name}
169
170Delete Vnf Profile
171 [Arguments] ${vnf_name}
172 Login To SDNGC Admin GUI
173 Go To ${SDNGC_ADMIN_VNF_PROFILE_URL}
174 Page Should Contain VNF Profile
175 Input Text xpath=//div[@id='vnf_profile_filter']//input ${vnf_name}
176 Page Should Contain ${vnf_name}
177 Click Button xpath=//button[contains(@onclick, '${vnf_name}')]
178 Page Should Contain Are you sure you want to delete VNF_PROFILE
179 Click Button xpath=//button[contains(text(), 'Yes')]
180 Page Should Not Contain ${vnf_name}
181
182Login To SDNGC Admin GUI
183 [Documentation] Login To SDNGC Admin GUI
184 ## Setup Browser is now being managed by the test case
185 ## Setup Browser
186 Go To ${SDNGC_ADMIN_SIGNUP_URL}
187 Maximize Browser Window
188 Set Selenium Speed ${GLOBAL_SELENIUM_DELAY}
189 Set Browser Implicit Wait ${GLOBAL_SELENIUM_BROWSER_IMPLICIT_WAIT}
190 Log Logging in to ${SDNGC_ADMIN_LOGIN_URL}
191 Handle Proxy Warning
192 Title Should Be AdminPortal
193 ${uuid}= Generate UUID
194 ${shortened_uuid}= Evaluate str("${uuid}")[:12]
195 ${email}= Catenate ${shortened_uuid}@robotete.com
196 Input Text xpath=//input[@id='nf_email'] ${email}
197 Input Password xpath=//input[@id='nf_password'] ${shortened_uuid}
198 Click Button xpath=//button[@type='submit']
199 Wait Until Page Contains User created 20s
200 Go To ${SDNGC_ADMIN_LOGIN_URL}
201 Input Text xpath=//input[@id='email'] ${email}
202 Input Password xpath=//input[@id='password'] ${shortened_uuid}
203 Click Button xpath=//button[@type='submit']
204 Title Should Be SDN-C AdminPortal
205 Log Logged in to ${SDNGC_ADMIN_LOGIN_URL}