blob: f83ce5b15f436a238e546aa495e3f2d1adaa429e [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation Policy Closed Loop Test cases
3
Brian Freeman20f11e42018-07-26 13:55:28 -05004Resource ../policy_interface.robot
DR695Hccff30b2017-02-17 18:44:24 -05005Resource ../stack_validation/policy_check_vfw.robot
Brian Freeman20f11e42018-07-26 13:55:28 -05006Resource ../stack_validation/packet_generator_interface.robot
DR695Hccff30b2017-02-17 18:44:24 -05007Resource vnf_orchestration_test_template.robot
Brian Freeman20f11e42018-07-26 13:55:28 -05008
DR695Hccff30b2017-02-17 18:44:24 -05009Library String
10Library HttpLibrary.HTTP
11LIbrary Process
12
13*** Variables ***
Jerry Flooda9ee25c2017-05-31 14:50:37 -040014${RESOURCE_PATH_CREATE} /pdp/createPolicy
15${RESOURCE_PATH_CREATE_PUSH} /pdp/pushPolicy
16${RESOURCE_PATH_CREATE_DELETE} /pdp/deletePolicy
17${RESOURCE_PATH_GET_CONFIG} /pdp/getConfig
DR695Hccff30b2017-02-17 18:44:24 -050018${CREATE_CONFIG_TEMPLATE} robot/assets/templates/policy/closedloop_configpolicy.template
19${CREATE_OPS_TEMPLATE} robot/assets/templates/policy/closedloop_opspolicy.template
20${PUSH_POLICY_TEMPLATE} robot/assets/templates/policy/closedloop_pushpolicy.template
21${DEL_POLICY_TEMPLATE} robot/assets/templates/policy/closedloop_deletepolicy.template
22${GECONFIG_VFW_TEMPLATE} robot/assets/templates/policy/closedloop_getconfigpolicy.template
23
24# 'Normal' number of pg streams that will be set when policy is triggered
25${VFWPOLICYRATE} 5
26
27# Max nslookup requests per second before triggering event.
28${VLBPOLICYRATE} 20
29
jf986099c63292017-03-09 15:28:42 -050030${CONFIG_POLICY_NAME} vFirewall
31${CONFIG_POLICY_TYPE} Unknown
32${OPS_POLICY_NAME}
DR695Hccff30b2017-02-17 18:44:24 -050033${OPS_POLICY_TYPE} BRMS_PARAM
34
35# VFW low threshold
36${Expected_Severity_1} MAJOR
37${Expected_Threshold_1} 300
38${Expected_Direction_1} LESS_OR_EQUAL
39
40# VFW high threshold
41${Expected_Severity_2} CRITICAL
42${Expected_Threshold_2} 700
43${Expected_Direction_2} GREATER_OR_EQUAL
44
45# VDNS High threshold
46${Expected_Severity_3} MAJOR
47${Expected_Threshold_3} 200
48${Expected_Direction_3} GREATER_OR_EQUAL
49
jf986099c63292017-03-09 15:28:42 -050050#********** Test Case Variables ************
51${DNSSCALINGSTACK}
DR695Hccff30b2017-02-17 18:44:24 -050052
53*** Keywords ***
54VFW Policy
55 Log Suite name ${SUITE NAME} ${TEST NAME} ${PREV TEST NAME}
56 Initialize VFW Policy
jf986099c63292017-03-09 15:28:42 -050057 ${stackname}= Orchestrate VNF vFW closedloop
DR695Hccff30b2017-02-17 18:44:24 -050058 Policy Check Firewall Stack ${stackname} ${VFWPOLICYRATE}
Jerry Flood8877bca2017-03-14 07:34:41 -040059 Delete VNF
DR695Hccff30b2017-02-17 18:44:24 -050060
61VDNS Policy
62 Initialize VDNS Policy
63 ${stackname}= Orchestrate VNF vDNS closedloop
64 ${dnsscaling}= Policy Check vLB Stack ${stackname} ${VLBPOLICYRATE}
65 Set Test Variable ${DNSSCALINGSTACK} ${dnsscaling}
Jerry Flood8877bca2017-03-14 07:34:41 -040066 Delete VNF
jf986099c63292017-03-09 15:28:42 -050067
DR695Hccff30b2017-02-17 18:44:24 -050068Initialize VFW Policy
69# Create Config Policy
70# Push Config Policy ${CONFIG_POLICY_NAME} ${CONFIG_POLICY_TYPE}
71# Create Ops Policy
jf986099c63292017-03-09 15:28:42 -050072# Push Ops Policy ${OPS_POLICY_NAME} ${OPS_POLICY_TYPE}
DR695Hccff30b2017-02-17 18:44:24 -050073 Get Configs VFW Policy
jf986099c63292017-03-09 15:28:42 -050074
DR695Hccff30b2017-02-17 18:44:24 -050075Initialize VDNS Policy
76 Get Configs VDNS Policy
jf986099c63292017-03-09 15:28:42 -050077
DR695Hccff30b2017-02-17 18:44:24 -050078Get Configs VFW Policy
79 [Documentation] Get Config Policy for VFW
80 ${getconfigpolicy}= Catenate .*${CONFIG_POLICY_NAME}*
81 ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy}
82 ${output} = Fill JSON Template File ${GECONFIG_VFW_TEMPLATE} ${configpolicy_name}
83 ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output}
84 Should Be Equal As Strings ${get_resp.status_code} 200
jf986099c63292017-03-09 15:28:42 -050085
DR695Hccff30b2017-02-17 18:44:24 -050086 ${json}= Parse Json ${get_resp.content}
87 ${config}= Parse Json ${json[0]["config"]}
jf986099c63292017-03-09 15:28:42 -050088
89 # Extract object1 from Array
DR695Hccff30b2017-02-17 18:44:24 -050090 ${severity}= Get Variable Value ${config["content"]["thresholds"][0]["severity"]}
jf986099c63292017-03-09 15:28:42 -050091 Should Be Equal ${severity} ${Expected_Severity_1}
DR695Hccff30b2017-02-17 18:44:24 -050092 ${Thresold_Value}= Get Variable Value ${config["content"]["thresholds"][0]["thresholdValue"]}
Gary Wu80676112018-03-20 13:22:17 -070093 Should Be Equal As Integers ${Thresold_Value} ${Expected_Threshold_1}
DR695Hccff30b2017-02-17 18:44:24 -050094 ${direction}= Get Variable Value ${config["content"]["thresholds"][0]["direction"]}
jf986099c63292017-03-09 15:28:42 -050095 Should Be Equal ${direction} ${Expected_Direction_1}
96
DR695Hccff30b2017-02-17 18:44:24 -050097 # Extract object2 from Array
98 ${severity_1}= Get Variable Value ${config["content"]["thresholds"][1]["severity"]}
jf986099c63292017-03-09 15:28:42 -050099 Should Be Equal ${severity_1} ${Expected_Severity_2}
DR695Hccff30b2017-02-17 18:44:24 -0500100 ${Thresold_Value_1}= Get Variable Value ${config["content"]["thresholds"][1]["thresholdValue"]}
Gary Wu80676112018-03-20 13:22:17 -0700101 Should Be Equal As Integers ${Thresold_Value_1} ${Expected_Threshold_2}
DR695Hccff30b2017-02-17 18:44:24 -0500102 ${direction_1}= Get Variable Value ${config["content"]["thresholds"][1]["direction"]}
jf986099c63292017-03-09 15:28:42 -0500103 Should Be Equal ${direction_1} ${Expected_Direction_2}
104
DR695Hccff30b2017-02-17 18:44:24 -0500105Get Configs VDNS Policy
106 [Documentation] Get Config Policy for VDNS
Gary Wu7cfa85a2018-03-20 11:36:23 -0700107 ${getconfigpolicy}= Catenate .*MicroServicevDNS*
DR695Hccff30b2017-02-17 18:44:24 -0500108 ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy}
109 ${output} = Fill JSON Template File ${GECONFIG_VFW_TEMPLATE} ${configpolicy_name}
110 ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output}
111 Should Be Equal As Strings ${get_resp.status_code} 200
112 ${json}= Parse Json ${get_resp.content}
113 ${config}= Parse Json ${json[0]["config"]}
jf986099c63292017-03-09 15:28:42 -0500114
115 # Extract object1 from Array
Pamela Dragosh51b6f5c2018-03-20 12:56:35 -0400116 ${severity}= Get Variable Value ${config["content"]["tca_policy"]["metricsPerEventName"][0]["thresholds"][0]["severity"]}
117 Should Be Equal ${severity} ${Expected_Severity_2}
118 ${Thresold_Value}= Get Variable Value ${config["content"]["tca_policy"]["metricsPerEventName"][0]["thresholds"][0]["thresholdValue"]}
Gary Wu80676112018-03-20 13:22:17 -0700119 Should Be Equal As Integers ${Thresold_Value} ${Expected_Threshold_1}
DR695Hce07d412018-04-11 22:28:41 -0400120 ${direction}= Get Variable Value ${config["content"]["tca_policy"]["metricsPerEventName"][0]["thresholds"][0]["direction"]}
jf986099c63292017-03-09 15:28:42 -0500121 Should Be Equal ${direction} ${Expected_Direction_3}
DR695Hccff30b2017-02-17 18:44:24 -0500122
123Teardown Closed Loop
124 [Documentation] Tear down a closed loop test case
jf986099c63292017-03-09 15:28:42 -0500125 Terminate All Processes
126 Teardown VNF
127 Log Teardown complete
DR695Hccff30b2017-02-17 18:44:24 -0500128
DR695Hccff30b2017-02-17 18:44:24 -0500129Create Config Policy
jf986099c63292017-03-09 15:28:42 -0500130 [Documentation] Create Config Policy
131 ${randompolicyname} = Create Policy Name
DR695Hccff30b2017-02-17 18:44:24 -0500132 ${policyname1}= Catenate com.${randompolicyname}
jf986099c63292017-03-09 15:28:42 -0500133 ${CONFIG_POLICY_NAME}= Set Test Variable ${policyname1}
DR695Hccff30b2017-02-17 18:44:24 -0500134 ${configpolicy}= Create Dictionary policy_name=${CONFIG_POLICY_NAME}
135 ${output} = Fill JSON Template File ${CREATE_CONFIG_TEMPLATE} ${configpolicy}
136 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
137 Should Be Equal As Strings ${put_resp.status_code} 200
138
139 Create Policy Name
140 [Documentation] Generate Policy Name
jf986099c63292017-03-09 15:28:42 -0500141 [Arguments] ${prefix}=ETE_
DR695Hccff30b2017-02-17 18:44:24 -0500142 ${random}= Generate Random String 15 [LOWER][NUMBERS]
143 ${policyname}= Catenate ${prefix}${random}
144 [Return] ${policyname}
jf986099c63292017-03-09 15:28:42 -0500145
DR695Hccff30b2017-02-17 18:44:24 -0500146Create Ops Policy
jf986099c63292017-03-09 15:28:42 -0500147 [Documentation] Create Opertional Policy
148 ${randompolicyname} = Create Policy Name
DR695Hccff30b2017-02-17 18:44:24 -0500149 ${policyname1}= Catenate com.${randompolicyname}
jf986099c63292017-03-09 15:28:42 -0500150 ${OPS_POLICY_NAME}= Set Test Variable ${policyname1}
DR695Hccff30b2017-02-17 18:44:24 -0500151 ${dict}= Create Dictionary policy_name=${OPS_POLICY_NAME}
152 #${NEWPOLICY1}= Create Dictionary policy_name=com.${OPS_POLICY_NAME}
153 ${output} = Fill JSON Template File ${CREATE_OPS_TEMPLATE} ${dict}
154 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
155 Log ${put_resp}
156 Should Be Equal As Strings ${put_resp.status_code} 200
jf986099c63292017-03-09 15:28:42 -0500157
DR695Hccff30b2017-02-17 18:44:24 -0500158Push Ops Policy
159 [Documentation] Push Ops Policy
160 [Arguments] ${policyname} ${policytype}
jf986099c63292017-03-09 15:28:42 -0500161 ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype}
DR695Hccff30b2017-02-17 18:44:24 -0500162 ${output} = Fill JSON Template ${PUSH_POLICY_TEMPLATE} ${dict}
163 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output}
164 Should Be Equal As Strings ${put_resp.status_code} 200
165
166Push Config Policy
167 [Documentation] Push Config Policy
168 [Arguments] ${policyname} ${policytype}
jf986099c63292017-03-09 15:28:42 -0500169 ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype}
DR695Hccff30b2017-02-17 18:44:24 -0500170 ${output} = Fill JSON Template ${PUSH_POLICY_TEMPLATE} ${dict}
171 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output}
172 Should Be Equal As Strings ${put_resp.status_code} 200
jf986099c63292017-03-09 15:28:42 -0500173
174
DR695Hccff30b2017-02-17 18:44:24 -0500175Delete Config Policy
176 [Documentation] Delete Config Policy
177 [Arguments] ${policy_name}
178 ${policyname3}= Catenate com.Config_BRMS_Param_${policyname}.1.xml
jf986099c63292017-03-09 15:28:42 -0500179 ${dict}= Create Dictionary policy_name=${policyname3}
DR695Hccff30b2017-02-17 18:44:24 -0500180 ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict}
181 ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output}
jf986099c63292017-03-09 15:28:42 -0500182 Should Be Equal As Strings ${put_resp.status_code} 200
183
DR695Hccff30b2017-02-17 18:44:24 -0500184Delete Ops Policy
185 [Documentation] Delete Ops Policy
186 [Arguments] ${policy_name}
187 ${policyname3}= Catenate com.Config_MS_com.vFirewall.1.xml
jf986099c63292017-03-09 15:28:42 -0500188 ${dict}= Create Dictionary policy_name=${policyname3}
DR695Hccff30b2017-02-17 18:44:24 -0500189 ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict}
190 ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output}
jf986099c63292017-03-09 15:28:42 -0500191 Should Be Equal As Strings ${put_resp.status_code} 200
192
DR695Hccff30b2017-02-17 18:44:24 -0500193Orchestrate VNF vFW closedloop
194 [Documentation] VNF Orchestration for vFW
jf986099c63292017-03-09 15:28:42 -0500195 Log VNF Orchestration flow TEST NAME=${TEST NAME}
196 Setup Orchestrate VNF ${GLOBAL_AAI_CLOUD_OWNER} SharedNode OwnerType v1 CloudZone
Jerry Flood3a169a32017-12-01 12:39:10 -0500197 ${stack_name} ${service}= Orchestrate VNF ETE_CLP vFWCL vFWCL ${TENANT_NAME}
jf986099c63292017-03-09 15:28:42 -0500198 [Return] ${stack_name}
199
DR695Hccff30b2017-02-17 18:44:24 -0500200 Orchestrate VNF vDNS closedloop
201 [Documentation] VNF Orchestration for vLB
jf986099c63292017-03-09 15:28:42 -0500202 Log VNF Orchestration flow TEST NAME=${TEST NAME}
203 Setup Orchestrate VNF ${GLOBAL_AAI_CLOUD_OWNER} SharedNode OwnerType v1 CloudZone
204 ${stack_name} ${service}= Orchestrate VNF ETE_CLP vLB vLB ${TENANT_NAME}
205 [Return] ${stack_name}
Brian Freeman20f11e42018-07-26 13:55:28 -0500206
207VFWCL High Test
208 [Documentation] Test Control Loop for High Traffic
209 [Arguments] ${pkg_host}
210 Enable Streams ${pkg_host} 10
211 :FOR ${i} IN RANGE 8
212 \ Sleep 15s
213 \ ${resp}= Get List Of Enabled Streams ${pkg_host}
214 \ ${stream_count}= Evaluate len(${resp['sample-plugin']['pg-streams']['pg-stream']})
215 \ Log To Console Number of steam: ${stream_count}
216 \ Exit For Loop If '${stream_count}'=='5'
217 Should Be Equal As Integers ${stream_count} 5
218
219VFWCL Low Test
220 [Documentation] Test Control Loop for Low Traffic
221 [Arguments] ${pkg_host}
222 Enable Streams ${pkg_host} 1
223 Get List Of Enabled Streams ${pkg_host}
224 :FOR ${i} IN RANGE 8
225 \ Sleep 15s
226 \ ${resp}= Get List Of Enabled Streams ${pkg_host}
227 \ ${stream_count}= Evaluate len(${resp['sample-plugin']['pg-streams']['pg-stream']})
228 \ Log To Console Number of steam: ${stream_count}
229 \ Exit For Loop If '${stream_count}'=='5'
230 Should Be Equal As Integers ${stream_count} 5
231
232