blob: 785619f9d564dbcfe71b8c21d976d63b71e554b8 [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001*** Settings ***
2Documentation Policy ONAP CSIT Test cases
3Library String
4Library HttpLibrary.HTTP
5LIbrary Process
6Library BuiltIn
7Resource policy_interface.robot
8Resource json_templater.robot
9
10*** Variables ***
11${RESOURCE_PATH_CREATE} /pdp/api/createPolicy
12${RESOURCE_PATH_CREATE_PUSH} /pdp/api/pushPolicy
13${RESOURCE_PATH_CREATE_DELETE} /pdp/api/deletePolicy
14${RESOURCE_PATH_GET_CONFIG} /pdp/api/getConfig
15${CREATE_CONFIG_VFW_TEMPLATE} ${CURDIR}/configpolicy_vFW_R1.template
16${CREATE_CONFIG_VDNS_TEMPLATE} ${CURDIR}/configpolicy_vDNS_R1.template
17${CREATE_CONFIG_VCPE_TEMPLATE} ${CURDIR}/configpolicy_vCPE_R1.template
18${CREATE_OPS_VFW_TEMPLATE} ${CURDIR}/opspolicy_VFW_R1.template
19${CREATE_OOF_HPA_TEMPLATE} ${CURDIR}/oofpolicy_HPA_R1.template
20${CREATE_SDNC_VFW_TEMPLATE} ${CURDIR}/sdncnamingpolicy_vFW.template
21${CREATE_SDNC_VPG_TEMPLATE} ${CURDIR}/sdncnamingpolicy_vPG.template
22${PUSH_POLICY_TEMPLATE} ${CURDIR}/pushpolicy.template
23${CREATE_OPS_VDNS_TEMPLATE} ${CURDIR}/opspolicy_VDNS_R1.template
24${DEL_POLICY_TEMPLATE} ${CURDIR}/deletepolicy.template
25${GETCONFIG_TEMPLATE} ${CURDIR}/getconfigpolicy.template
26${GETOOF_TEMPLATE} ${CURDIR}/getoofpolicy.template
27${CONFIG_POLICY_VFW_NAME} vFirewall
28${CONFIG_POLICY_VFW_TYPE} MicroService
29${CONFIG_POLICY_VDNS_NAME} vLoadBalancer
30${CONFIG_POLICY_VDNS_TYPE} MicroService
31${OPS_POLICY_VFW_NAME} vFirewall
32${OPS_POLICY_VFW_TYPE} BRMS_PARAM
33${OPS_POLICY_VDNS_NAME} vLoadBalancer
34${OPS_POLICY_VDNS_TYPE} BRMS_PARAM
35${CONFIG_POLICY_VCPE_NAME} vCPE
36${CONFIG_POLICY_VCPE_TYPE} MicroService
37${OPS_POLICY_VCPE_NAME} vCPE
38${OPS_POLICY_VCPE_TYPE} BRMS_PARAM
39${OPS_POLICY_VOLTE_NAME} VoLTE
40${OPS_POLICY_VOLTE_TYPE} BRMS_PARAM
41${OOF_POLICY_HPA_NAME} HPA
42${OOF_POLICY_HPA_TYPE} Optimization
43${SDNC_POLICY_VFW_NAME} ONAP_vFW_Naming
44${SDNC_POLICY_VPG_NAME} ONAP_vPG_Naming
45${file_path} ../testsuite/robot/assets/templates/ControlLoopDemo__closedLoopControlName.drl
46${RESOURCE_PATH_UPLOAD} /pdp/api/policyEngineImport?importParametersJson=%7B%22serviceName%22%3A%22Manyu456%22%2C%20%22serviceType%22%3A%22BRMSPARAM%22%7D
47${CREATE_OPS_VCPE_TEMPLATE} ${CURDIR}/opspolicy_vCPE_R1.template
48${CREATE_OPS_VOLTE_TEMPLATE} ${CURDIR}/opspolicy_vOLTE_R1.template
49
50
51*** Test Cases ***
52Policy Health check
53 Run Policy Health Check
54
55VFW Config Policy
56 ${CONFIG_POLICY_VFW_NAME}= Create Config VFW Policy
57 Push Config Policy ${CONFIG_POLICY_VFW_NAME} ${CONFIG_POLICY_VFW_TYPE}
58 #VFW Policy Tests
59
60VDNS Config Policy
61 ${CONFIG_POLICY_VDNS_NAME}= Create Config VDNS Policy
62 Push Config Policy ${CONFIG_POLICY_VDNS_NAME} ${CONFIG_POLICY_VDNS_TYPE}
63 #VDNS Policy Tests
64
65VCPE Config Policy
66 ${CONFIG_POLICY_VCPE_NAME}= Create Config VCPE Policy
67 Push Config Policy ${CONFIG_POLICY_VCPE_NAME} ${CONFIG_POLICY_VCPE_TYPE}
68 #VCPE Policy Tests
69
70VFW Ops Policy
71 ${OPS_POLICY_VFW_NAME}= Create Ops VFW Policy
72 Push Ops Policy ${OPS_POLICY_VFW_NAME} ${OPS_POLICY_VFW_TYPE}
73
74VDNS Ops Policy
75 ${OPS_POLICY_VDNS_NAME}= Create Ops VDNS Policy
76 Push Ops Policy ${OPS_POLICY_VDNS_NAME} ${OPS_POLICY_VDNS_TYPE}
77
78VCPE Ops Policy
79 ${OPS_POLICY_VCPE_NAME}= Create Ops VCPE Policy
80 Push Ops Policy ${OPS_POLICY_VCPE_NAME} ${OPS_POLICY_VCPE_TYPE}
81
82VOLTE Ops Policy
83 ${OPS_POLICY_VOLTE_NAME}= Create Ops VOLTE Policy
84 Push Ops Policy ${OPS_POLICY_VOLTE_NAME} ${OPS_POLICY_VOLTE_TYPE}
85 #VOLTE Policy Tests
86
87VFW SDNC Naming Policy
88 ${SDNC_POLICY_VFW_NAME}= Create VFW SDNC Naming Policy
89 Push Config Policy ${SDNC_POLICY_VFW_NAME} ${CONFIG_POLICY_VFW_TYPE}
90 #VFW Policy Tests
91
92VPG SDNC Naming Policy
93 ${SDNC_POLICY_VPG_NAME}= Create VPG SDNC Naming Policy
94 Push Config Policy ${SDNC_POLICY_VPG_NAME} ${CONFIG_POLICY_VFW_TYPE}
95 #VPG Policy Tests
96
97HPA OOF Policy
98 ${OOF_POLICY_HPA_NAME}= Create OOF HPA Policy
99 Push Config Policy ${OOF_POLICY_HPA_NAME} ${OOF_POLICY_HPA_TYPE}
100 #HPA Policy Tests
101
102VFW Get Configs Policy
103 Sleep 5s
104 Get Configs VFW Policy
105
106VDNS Get Configs Policy
107 Sleep 5s
108 Get Configs VDNS Policy
109
110VCPE Get Configs Policy
111 Sleep 5s
112 Get Configs VCPE Policy
113
114HPA Get OOF Policy
115 Sleep 5s
116 Get OOF HPA Policy
117
118*** Keywords ***
119
120VFW Policy Tests
121 ${CONFIG_POLICY_VFW_NAME}= Create Config VFW Policy
122 Push Config Policy ${CONFIG_POLICY_VFW_NAME} ${CONFIG_POLICY_VFW_TYPE}
123 Get Configs VFW Policy
124 ${OPS_POLICY_VFW_NAME}= Create Ops VFW Policy
125 Push Ops Policy ${OPS_POLICY_VFW_NAME} ${OPS_POLICY_VFW_TYPE}
126 ${SDNC_POLICY_VFW_NAME}= Create VFW SDNC Naming Policy
127 Push Config Policy ${CONFIG_POLICY_VFW_NAME} ${CONFIG_POLICY_VFW_TYPE}
128
129VDNS Policy Tests
130 ${CONFIG_POLICY_VDNS_NAME}= Create Config VDNS Policy
131 Push Config Policy ${CONFIG_POLICY_VDNS_NAME} ${CONFIG_POLICY_VDNS_TYPE}
132 Get Configs VDNS Policy
133 ${OPS_POLICY_VDNS_NAME}= Create Ops VDNS Policy
134 Push Ops Policy ${OPS_POLICY_VDNS_NAME} ${OPS_POLICY_VDNS_TYPE}
135
136VCPE Policy Tests
137 ${CONFIG_POLICY_VCPE_NAME}= Create Config VCPE Policy
138 Push Config Policy ${CONFIG_POLICY_VCPE_NAME} ${CONFIG_POLICY_VCPE_TYPE}
139 Get Configs VCPE Policy
140 ${OPS_POLICY_VCPE_NAME}= Create Ops VCPE Policy
141 Push Ops Policy ${OPS_POLICY_VCPE_NAME} ${OPS_POLICY_VCPE_TYPE}
142
143VPG Policy Tests
144 ${SDNC_POLICY_VPG_NAME}= Create VPG SDNC Naming Policy
145 Push Config Policy ${SDNC_POLICY_VPG_NAME} ${CONFIG_POLICY_VFW_TYPE}
146
147VOLTE Policy Tests
148 ${OPS_POLICY_VOLTE_NAME}= Create Ops VOLTE Policy
149 Push Ops Policy ${OPS_POLICY_VOLTE_NAME} ${OPS_POLICY_VOLTE_TYPE}
150
151HPA Policy Tests
152 ${OOF_POLICY_HPA_NAME}= Create OOF HPA Policy
153 Push Config Policy ${OOF_POLICY_HPA_NAME} ${OOF_POLICY_HPA_TYPE}
154 Get OOF HPA Policy
155
156Get Configs VFW Policy
157 [Documentation] Get Config Policy for VFW
158 ${getconfigpolicy}= Catenate .*${CONFIG_POLICY_VFW_NAME}*
159 ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy}
160 ${output} = Fill JSON Template File ${GETCONFIG_TEMPLATE} ${configpolicy_name}
161 ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output}
162 Should Be Equal As Strings ${get_resp.status_code} 200
163
164Create OOF HPA Policy
165 [Documentation] Create OOF Policy
166 ${randompolicyname} = Create Policy Name
167 ${policyname1}= Catenate com.${randompolicyname}_HPA
168 ${OOF_POLICY_HPA_NAME}= Set Test Variable ${policyname1}
169 ${hpapolicy}= Create Dictionary policy_name=${policyname1}
170 ${output} = Fill JSON Template File ${CREATE_OOF_HPA_TEMPLATE} ${hpapolicy}
171 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
172 Log ${put_resp}
173 Should Be Equal As Strings ${put_resp.status_code} 200
174 [Return] ${policyname1}
175
176Get OOF HPA Policy
177 [Documentation] Get OOF Policy for HPA
178 ${gethpapolicy}= Catenate .*${OOF_POLICY_HPA_NAME}*
179 ${hpapolicy_name}= Create Dictionary oof_policy_name=${gethpapolicy}
180 ${output} = Fill JSON Template File ${GETOOF_TEMPLATE} ${hpapolicy_name}
181 ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output}
182 Should Be Equal As Strings ${get_resp.status_code} 200
183
184Create Config VFW Policy
185 [Documentation] Create Config Policy
186 ${randompolicyname} = Create Policy Name
187 ${policyname1}= Catenate com.${randompolicyname}_vFirewall
188 ${CONFIG_POLICY_VFW_NAME}= Set Test Variable ${policyname1}
189 ${configpolicy}= Create Dictionary policy_name=${policyname1}
190 ${output} = Fill JSON Template File ${CREATE_CONFIG_VFW_TEMPLATE} ${configpolicy}
191 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
192 Should Be Equal As Strings ${put_resp.status_code} 200
193 [Return] ${policyname1}
194
195Create VPG SDNC Naming Policy
196 [Documentation] Create VPG SDNC Naming Policy
197 ${randompolicyname} = Create Policy Name
198 ${policyname1}= Catenate com.${randompolicyname}_ONAP_vPG_Naming
199 ${SDNC_POLICY_VPG_NAME}= Set Test Variable ${policyname1}
200 ${sdncpolicy}= Create Dictionary policy_name=${policyname1}
201 ${output} = Fill JSON Template File ${CREATE_SDNC_VPG_TEMPLATE} ${sdncpolicy}
202 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
203 Should Be Equal As Strings ${put_resp.status_code} 200
204 [Return] ${policyname1}
205
206Create VFW SDNC Naming Policy
207 [Documentation] Create VFW SDNC Naming Policy
208 ${randompolicyname} = Create Policy Name
209 ${policyname1}= Catenate com.${randompolicyname}_ONAP_vFW_Naming
210 ${SDNC_POLICY_VFW_NAME}= Set Test Variable ${policyname1}
211 ${sdncpolicy}= Create Dictionary policy_name=${policyname1}
212 ${output} = Fill JSON Template File ${CREATE_SDNC_VFW_TEMPLATE} ${sdncpolicy}
213 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
214 Should Be Equal As Strings ${put_resp.status_code} 200
215 [Return] ${policyname1}
216
217Create Policy Name
218 [Documentation] Generate Policy Name
219 [Arguments] ${prefix}=CSIT_
220 ${random}= Generate Random String 15 [LOWER][NUMBERS]
221 ${policyname}= Catenate ${prefix}${random}
222 [Return] ${policyname}
223
224Create Ops VFW Policy
225 [Documentation] Create Operational Policy
226 ${randompolicyname} = Create Policy Name
227 ${policyname1}= Catenate com.${randompolicyname}_vFirewall
228 ${OPS_POLICY_VFW_NAME}= Set Test Variable ${policyname1}
229 ${dict}= Create Dictionary policy_name=${policyname1}
230 ${output} = Fill JSON Template File ${CREATE_OPS_VFW_TEMPLATE} ${dict}
231 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
232 Log ${put_resp}
233 Should Be Equal As Strings ${put_resp.status_code} 200
234 [Return] ${policyname1}
235
236Push Ops Policy
237 [Documentation] Push Ops Policy
238 [Arguments] ${policyname} ${policytype}
239 ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype}
240 ${output} = Fill JSON Template File ${PUSH_POLICY_TEMPLATE} ${dict}
241 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output}
242 Should Be Equal As Strings ${put_resp.status_code} 200
243
244Push Config Policy
245 [Documentation] Push Config Policy
246 [Arguments] ${policyname} ${policytype}
247 ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype}
248 ${output} = Fill JSON Template File ${PUSH_POLICY_TEMPLATE} ${dict}
249 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output}
250 Should Be Equal As Strings ${put_resp.status_code} 200
251
252Delete Ops Policy
253 [Documentation] Delete Config Policy
254 [Arguments] ${policy_name}
255 ${policyname3}= Catenate com.Config_BRMS_Param_${policyname}.1.xml
256 ${dict}= Create Dictionary policy_name=${policyname3}
257 ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict}
258 ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output}
259 Should Be Equal As Strings ${put_resp.status_code} 200
260
261Delete Config Policy
262 [Documentation] Delete Ops Policy
263 [Arguments] ${policy_name}
264 ${policyname3}= Catenate com.Config_MS_com.${policy_name}.1.xml
265 ${dict}= Create Dictionary policy_name=${policyname3}
266 ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict}
267 ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output}
268 Should Be Equal As Strings ${put_resp.status_code} 200
269
270Delete OOF Policy
271 [Documentation] Delete OOF Policy
272 [Arguments] ${policy_name}
273 ${policyname3}= Catenate com.Config_OOF_${policy_name}.1.xml
274 ${dict}= Create Dictionary policy_name=${policyname3}
275 ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict}
276 ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output}
277 Should Be Equal As Strings ${put_resp.status_code} 200
278
279Get Configs VDNS Policy
280 [Documentation] Get Config Policy for VDNS
281 ${getconfigpolicy}= Catenate .*${CONFIG_POLICY_VDNS_NAME}*
282 ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy}
283 ${output} = Fill JSON Template File ${GETCONFIG_TEMPLATE} ${configpolicy_name}
284 ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output}
285 Should Be Equal As Strings ${get_resp.status_code} 200
286
287Create Config VDNS Policy
288 [Documentation] Create Config Policy
289 ${randompolicyname} = Create Policy Name
290 ${policyname1}= Catenate com.${randompolicyname}_vLoadBalancer
291 ${CONFIG_POLICY_VDNS_NAME}= Set Test Variable ${policyname1}
292 ${configpolicy}= Create Dictionary policy_name=${policyname1}
293 ${output} = Fill JSON Template File ${CREATE_CONFIG_VDNS_TEMPLATE} ${configpolicy}
294 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
295 Should Be Equal As Strings ${put_resp.status_code} 200
296 [Return] ${policyname1}
297
298Create Ops VDNS Policy
299 [Documentation] Create Operational Policy
300 ${randompolicyname} = Create Policy Name
301 ${policyname1}= Catenate com.${randompolicyname}_vLoadBalancer
302 ${OPS_POLICY_VDNS_NAME}= Set Test Variable ${policyname1}
303 ${dict}= Create Dictionary policy_name=${policyname1}
304 ${output} = Fill JSON Template File ${CREATE_OPS_VDNS_TEMPLATE} ${dict}
305 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
306 Log ${put_resp}
307 Should Be Equal As Strings ${put_resp.status_code} 200
308 [Return] ${policyname1}
309
310Create Config VCPE Policy
311 [Documentation] Create Config Policy
312 ${randompolicyname} = Create Policy Name
313 ${policyname1}= Catenate com.${randompolicyname}_vCPE
314 ${CONFIG_POLICY_VCPE_NAME}= Set Test Variable ${policyname1}
315 ${configpolicy}= Create Dictionary policy_name=${policyname1}
316 ${output} = Fill JSON Template File ${CREATE_CONFIG_VCPE_TEMPLATE} ${configpolicy}
317 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
318 Should Be Equal As Strings ${put_resp.status_code} 200
319 [Return] ${policyname1}
320
321Get Configs VCPE Policy
322 [Documentation] Get Config Policy for VCPE
323 ${getconfigpolicy}= Catenate .*${CONFIG_POLICY_VCPE_NAME}*
324 ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy}
325 ${output} = Fill JSON Template File ${GETCONFIG_TEMPLATE} ${configpolicy_name}
326 ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output}
327 Should Be Equal As Strings ${get_resp.status_code} 200
328
329Create Ops vCPE Policy
330 [Documentation] Create Operational Policy
331 ${randompolicyname} = Create Policy Name
332 ${policyname1}= Catenate com.${randompolicyname}_vCPE
333 ${OPS_POLICY_VCPE_NAME}= Set Test Variable ${policyname1}
334 ${dict}= Create Dictionary policy_name=${policyname1}
335 ${output} = Fill JSON Template File ${CREATE_OPS_VCPE_TEMPLATE} ${dict}
336 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
337 Log ${put_resp}
338 Should Be Equal As Strings ${put_resp.status_code} 200
339 [Return] ${policyname1}
340
341Create Ops VolTE Policy
342 [Documentation] Create Operational Policy
343 ${randompolicyname} = Create Policy Name
344 ${policyname1}= Catenate com.${randompolicyname}_VoLTE
345 ${dict}= Create Dictionary policy_name=${policyname1}
346 ${output} = Fill JSON Template File ${CREATE_OPS_VOLTE_TEMPLATE} ${dict}
347 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
348 Log ${put_resp}
349 Should Be Equal As Strings ${put_resp.status_code} 200
350 [Return] ${policyname1}
351
352Upload DRL file
353 [Documentation] Upload DRL file1
354 ${file_data}= Get Binary File ${file_path}
355 ${files}= Create Dictionary file=${file_data}
356 #${CONFIG_POLICY_VDNS_NAME}= Set Test Variable ${policyname1}
357 # ${files2} = {'file': open('../testsuite/robot/assets/templates/ControlLoopDemo__closedLoopControlName.drl', 'rb')}
358 # ${files}= Create Dictionary file ${file_data}
359 ${put_resp} = Run Policy Post form Request ${RESOURCE_PATH_UPLOAD} ${files}
360 Should Be Equal As Strings ${put_resp.status_code} 200