blob: 5853abf55972162fbf088badef6b17aab374953f [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
Gary Wu5323bc22018-11-02 11:27:28 -070058 Policy Check FirewallCL 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"]}
Gary Wu5323bc22018-11-02 11:27:28 -070088 ${thresholds}= Get Variable Value ${config["content"]["tca_policy"]["metricsPerEventName"][0]["thresholds"]}
jf986099c63292017-03-09 15:28:42 -050089
90 # Extract object1 from Array
Gary Wu5323bc22018-11-02 11:27:28 -070091 Should Be Equal ${thresholds[0]["severity"]} ${Expected_Severity_1}
92 Should Be Equal As Integers ${thresholds[0]["thresholdValue"]} ${Expected_Threshold_1}
93 Should Be Equal ${thresholds[0]["direction"]} ${Expected_Direction_1}
jf986099c63292017-03-09 15:28:42 -050094
DR695Hccff30b2017-02-17 18:44:24 -050095 # Extract object2 from Array
Gary Wu5323bc22018-11-02 11:27:28 -070096 Should Be Equal ${thresholds[1]["severity"]} ${Expected_Severity_2}
97 Should Be Equal As Integers ${thresholds[1]["thresholdValue"]} ${Expected_Threshold_2}
98 Should Be Equal ${thresholds[1]["direction"]} ${Expected_Direction_2}
jf986099c63292017-03-09 15:28:42 -050099
DR695Hccff30b2017-02-17 18:44:24 -0500100Get Configs VDNS Policy
101 [Documentation] Get Config Policy for VDNS
Gary Wu7cfa85a2018-03-20 11:36:23 -0700102 ${getconfigpolicy}= Catenate .*MicroServicevDNS*
DR695Hccff30b2017-02-17 18:44:24 -0500103 ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy}
104 ${output} = Fill JSON Template File ${GECONFIG_VFW_TEMPLATE} ${configpolicy_name}
105 ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output}
106 Should Be Equal As Strings ${get_resp.status_code} 200
107 ${json}= Parse Json ${get_resp.content}
108 ${config}= Parse Json ${json[0]["config"]}
Gary Wu5323bc22018-11-02 11:27:28 -0700109 ${thresholds}= Get Variable Value ${config["content"]["tca_policy"]["metricsPerEventName"][0]["thresholds"]}
jf986099c63292017-03-09 15:28:42 -0500110
111 # Extract object1 from Array
Gary Wu5323bc22018-11-02 11:27:28 -0700112 Should Be Equal ${thresholds[0]["severity"]} ${Expected_Severity_2}
113 Should Be Equal As Integers ${thresholds[0]["thresholdValue"]} ${Expected_Threshold_1}
114 Should Be Equal ${thresholds[0]["direction"]} ${Expected_Direction_3}
DR695Hccff30b2017-02-17 18:44:24 -0500115
116Teardown Closed Loop
117 [Documentation] Tear down a closed loop test case
jf986099c63292017-03-09 15:28:42 -0500118 Terminate All Processes
119 Teardown VNF
120 Log Teardown complete
DR695Hccff30b2017-02-17 18:44:24 -0500121
DR695Hccff30b2017-02-17 18:44:24 -0500122Create Config Policy
jf986099c63292017-03-09 15:28:42 -0500123 [Documentation] Create Config Policy
124 ${randompolicyname} = Create Policy Name
DR695Hccff30b2017-02-17 18:44:24 -0500125 ${policyname1}= Catenate com.${randompolicyname}
jf986099c63292017-03-09 15:28:42 -0500126 ${CONFIG_POLICY_NAME}= Set Test Variable ${policyname1}
DR695Hccff30b2017-02-17 18:44:24 -0500127 ${configpolicy}= Create Dictionary policy_name=${CONFIG_POLICY_NAME}
128 ${output} = Fill JSON Template File ${CREATE_CONFIG_TEMPLATE} ${configpolicy}
129 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
130 Should Be Equal As Strings ${put_resp.status_code} 200
131
132 Create Policy Name
133 [Documentation] Generate Policy Name
jf986099c63292017-03-09 15:28:42 -0500134 [Arguments] ${prefix}=ETE_
DR695Hccff30b2017-02-17 18:44:24 -0500135 ${random}= Generate Random String 15 [LOWER][NUMBERS]
136 ${policyname}= Catenate ${prefix}${random}
137 [Return] ${policyname}
jf986099c63292017-03-09 15:28:42 -0500138
DR695Hccff30b2017-02-17 18:44:24 -0500139Create Ops Policy
jf986099c63292017-03-09 15:28:42 -0500140 [Documentation] Create Opertional Policy
141 ${randompolicyname} = Create Policy Name
DR695Hccff30b2017-02-17 18:44:24 -0500142 ${policyname1}= Catenate com.${randompolicyname}
jf986099c63292017-03-09 15:28:42 -0500143 ${OPS_POLICY_NAME}= Set Test Variable ${policyname1}
DR695Hccff30b2017-02-17 18:44:24 -0500144 ${dict}= Create Dictionary policy_name=${OPS_POLICY_NAME}
145 #${NEWPOLICY1}= Create Dictionary policy_name=com.${OPS_POLICY_NAME}
146 ${output} = Fill JSON Template File ${CREATE_OPS_TEMPLATE} ${dict}
147 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
148 Log ${put_resp}
149 Should Be Equal As Strings ${put_resp.status_code} 200
jf986099c63292017-03-09 15:28:42 -0500150
DR695Hccff30b2017-02-17 18:44:24 -0500151Push Ops Policy
152 [Documentation] Push Ops Policy
153 [Arguments] ${policyname} ${policytype}
jf986099c63292017-03-09 15:28:42 -0500154 ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype}
DR695Hccff30b2017-02-17 18:44:24 -0500155 ${output} = Fill JSON Template ${PUSH_POLICY_TEMPLATE} ${dict}
156 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output}
157 Should Be Equal As Strings ${put_resp.status_code} 200
158
159Push Config Policy
160 [Documentation] Push Config Policy
161 [Arguments] ${policyname} ${policytype}
jf986099c63292017-03-09 15:28:42 -0500162 ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype}
DR695Hccff30b2017-02-17 18:44:24 -0500163 ${output} = Fill JSON Template ${PUSH_POLICY_TEMPLATE} ${dict}
164 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output}
165 Should Be Equal As Strings ${put_resp.status_code} 200
jf986099c63292017-03-09 15:28:42 -0500166
167
DR695Hccff30b2017-02-17 18:44:24 -0500168Delete Config Policy
169 [Documentation] Delete Config Policy
170 [Arguments] ${policy_name}
171 ${policyname3}= Catenate com.Config_BRMS_Param_${policyname}.1.xml
jf986099c63292017-03-09 15:28:42 -0500172 ${dict}= Create Dictionary policy_name=${policyname3}
DR695Hccff30b2017-02-17 18:44:24 -0500173 ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict}
174 ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output}
jf986099c63292017-03-09 15:28:42 -0500175 Should Be Equal As Strings ${put_resp.status_code} 200
176
DR695Hccff30b2017-02-17 18:44:24 -0500177Delete Ops Policy
178 [Documentation] Delete Ops Policy
179 [Arguments] ${policy_name}
180 ${policyname3}= Catenate com.Config_MS_com.vFirewall.1.xml
jf986099c63292017-03-09 15:28:42 -0500181 ${dict}= Create Dictionary policy_name=${policyname3}
DR695Hccff30b2017-02-17 18:44:24 -0500182 ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict}
183 ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output}
jf986099c63292017-03-09 15:28:42 -0500184 Should Be Equal As Strings ${put_resp.status_code} 200
185
DR695Hccff30b2017-02-17 18:44:24 -0500186Orchestrate VNF vFW closedloop
187 [Documentation] VNF Orchestration for vFW
jf986099c63292017-03-09 15:28:42 -0500188 Log VNF Orchestration flow TEST NAME=${TEST NAME}
189 Setup Orchestrate VNF ${GLOBAL_AAI_CLOUD_OWNER} SharedNode OwnerType v1 CloudZone
Jerry Flood3a169a32017-12-01 12:39:10 -0500190 ${stack_name} ${service}= Orchestrate VNF ETE_CLP vFWCL vFWCL ${TENANT_NAME}
jf986099c63292017-03-09 15:28:42 -0500191 [Return] ${stack_name}
192
DR695Hccff30b2017-02-17 18:44:24 -0500193 Orchestrate VNF vDNS closedloop
194 [Documentation] VNF Orchestration for vLB
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
197 ${stack_name} ${service}= Orchestrate VNF ETE_CLP vLB vLB ${TENANT_NAME}
198 [Return] ${stack_name}
Brian Freeman20f11e42018-07-26 13:55:28 -0500199
200VFWCL High Test
201 [Documentation] Test Control Loop for High Traffic
202 [Arguments] ${pkg_host}
203 Enable Streams ${pkg_host} 10
Gary Wu9eb062d2018-11-09 20:10:10 -0800204 Log To Console Set number of streams to 10
205 :FOR ${i} IN RANGE 12
Brian Freeman20f11e42018-07-26 13:55:28 -0500206 \ Sleep 15s
207 \ ${resp}= Get List Of Enabled Streams ${pkg_host}
208 \ ${stream_count}= Evaluate len(${resp['sample-plugin']['pg-streams']['pg-stream']})
Gary Wu9eb062d2018-11-09 20:10:10 -0800209 \ Log To Console Number of streams: ${stream_count}
210 \ Exit For Loop If '${stream_count}'=='5'
Brian Freeman20f11e42018-07-26 13:55:28 -0500211 Should Be Equal As Integers ${stream_count} 5
212
213VFWCL Low Test
214 [Documentation] Test Control Loop for Low Traffic
215 [Arguments] ${pkg_host}
216 Enable Streams ${pkg_host} 1
Gary Wu9eb062d2018-11-09 20:10:10 -0800217 Log To Console Set number of streams to 1
Brian Freeman20f11e42018-07-26 13:55:28 -0500218 Get List Of Enabled Streams ${pkg_host}
Gary Wu9eb062d2018-11-09 20:10:10 -0800219 :FOR ${i} IN RANGE 12
Brian Freeman20f11e42018-07-26 13:55:28 -0500220 \ Sleep 15s
221 \ ${resp}= Get List Of Enabled Streams ${pkg_host}
222 \ ${stream_count}= Evaluate len(${resp['sample-plugin']['pg-streams']['pg-stream']})
Gary Wu9eb062d2018-11-09 20:10:10 -0800223 \ Log To Console Number of streams: ${stream_count}
224 \ Exit For Loop If '${stream_count}'=='5'
Brian Freeman20f11e42018-07-26 13:55:28 -0500225 Should Be Equal As Integers ${stream_count} 5
226
227