blob: dcbb7e65df8ccc0bd17548891d283ce780fa326a [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
DR695Hccff30b2017-02-17 18:44:24 -050010LIbrary Process
11
12*** Variables ***
Jerry Flooda9ee25c2017-05-31 14:50:37 -040013${RESOURCE_PATH_CREATE} /pdp/createPolicy
14${RESOURCE_PATH_CREATE_PUSH} /pdp/pushPolicy
15${RESOURCE_PATH_CREATE_DELETE} /pdp/deletePolicy
16${RESOURCE_PATH_GET_CONFIG} /pdp/getConfig
DR695Hccff30b2017-02-17 18:44:24 -050017${CREATE_CONFIG_TEMPLATE} robot/assets/templates/policy/closedloop_configpolicy.template
18${CREATE_OPS_TEMPLATE} robot/assets/templates/policy/closedloop_opspolicy.template
19${PUSH_POLICY_TEMPLATE} robot/assets/templates/policy/closedloop_pushpolicy.template
20${DEL_POLICY_TEMPLATE} robot/assets/templates/policy/closedloop_deletepolicy.template
21${GECONFIG_VFW_TEMPLATE} robot/assets/templates/policy/closedloop_getconfigpolicy.template
22
23# 'Normal' number of pg streams that will be set when policy is triggered
24${VFWPOLICYRATE} 5
25
26# Max nslookup requests per second before triggering event.
27${VLBPOLICYRATE} 20
28
jf986099c63292017-03-09 15:28:42 -050029${CONFIG_POLICY_NAME} vFirewall
30${CONFIG_POLICY_TYPE} Unknown
31${OPS_POLICY_NAME}
DR695Hccff30b2017-02-17 18:44:24 -050032${OPS_POLICY_TYPE} BRMS_PARAM
33
34# VFW low threshold
35${Expected_Severity_1} MAJOR
36${Expected_Threshold_1} 300
37${Expected_Direction_1} LESS_OR_EQUAL
38
39# VFW high threshold
40${Expected_Severity_2} CRITICAL
41${Expected_Threshold_2} 700
42${Expected_Direction_2} GREATER_OR_EQUAL
43
44# VDNS High threshold
45${Expected_Severity_3} MAJOR
46${Expected_Threshold_3} 200
47${Expected_Direction_3} GREATER_OR_EQUAL
48
jf986099c63292017-03-09 15:28:42 -050049#********** Test Case Variables ************
50${DNSSCALINGSTACK}
DR695Hccff30b2017-02-17 18:44:24 -050051
52*** Keywords ***
53VFW Policy
54 Log Suite name ${SUITE NAME} ${TEST NAME} ${PREV TEST NAME}
55 Initialize VFW Policy
jf986099c63292017-03-09 15:28:42 -050056 ${stackname}= Orchestrate VNF vFW closedloop
Gary Wu5323bc22018-11-02 11:27:28 -070057 Policy Check FirewallCL Stack ${stackname} ${VFWPOLICYRATE}
Jerry Flood8877bca2017-03-14 07:34:41 -040058 Delete VNF
DR695Hccff30b2017-02-17 18:44:24 -050059
60VDNS Policy
61 Initialize VDNS Policy
62 ${stackname}= Orchestrate VNF vDNS closedloop
63 ${dnsscaling}= Policy Check vLB Stack ${stackname} ${VLBPOLICYRATE}
64 Set Test Variable ${DNSSCALINGSTACK} ${dnsscaling}
Jerry Flood8877bca2017-03-14 07:34:41 -040065 Delete VNF
jf986099c63292017-03-09 15:28:42 -050066
DR695Hccff30b2017-02-17 18:44:24 -050067Initialize VFW Policy
68# Create Config Policy
69# Push Config Policy ${CONFIG_POLICY_NAME} ${CONFIG_POLICY_TYPE}
70# Create Ops Policy
jf986099c63292017-03-09 15:28:42 -050071# Push Ops Policy ${OPS_POLICY_NAME} ${OPS_POLICY_TYPE}
DR695Hccff30b2017-02-17 18:44:24 -050072 Get Configs VFW Policy
jf986099c63292017-03-09 15:28:42 -050073
DR695Hccff30b2017-02-17 18:44:24 -050074Initialize VDNS Policy
75 Get Configs VDNS Policy
jf986099c63292017-03-09 15:28:42 -050076
DR695Hccff30b2017-02-17 18:44:24 -050077Get Configs VFW Policy
78 [Documentation] Get Config Policy for VFW
79 ${getconfigpolicy}= Catenate .*${CONFIG_POLICY_NAME}*
80 ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy}
81 ${output} = Fill JSON Template File ${GECONFIG_VFW_TEMPLATE} ${configpolicy_name}
82 ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output}
83 Should Be Equal As Strings ${get_resp.status_code} 200
DR695H0ca56d12019-05-14 11:48:20 -040084 ${config}= Catenate ${get_resp.json()[0]["config"]}
Gary Wu5323bc22018-11-02 11:27:28 -070085 ${thresholds}= Get Variable Value ${config["content"]["tca_policy"]["metricsPerEventName"][0]["thresholds"]}
jf986099c63292017-03-09 15:28:42 -050086
87 # Extract object1 from Array
Gary Wu5323bc22018-11-02 11:27:28 -070088 Should Be Equal ${thresholds[0]["severity"]} ${Expected_Severity_1}
89 Should Be Equal As Integers ${thresholds[0]["thresholdValue"]} ${Expected_Threshold_1}
90 Should Be Equal ${thresholds[0]["direction"]} ${Expected_Direction_1}
jf986099c63292017-03-09 15:28:42 -050091
DR695Hccff30b2017-02-17 18:44:24 -050092 # Extract object2 from Array
Gary Wu5323bc22018-11-02 11:27:28 -070093 Should Be Equal ${thresholds[1]["severity"]} ${Expected_Severity_2}
94 Should Be Equal As Integers ${thresholds[1]["thresholdValue"]} ${Expected_Threshold_2}
95 Should Be Equal ${thresholds[1]["direction"]} ${Expected_Direction_2}
jf986099c63292017-03-09 15:28:42 -050096
DR695Hccff30b2017-02-17 18:44:24 -050097Get Configs VDNS Policy
98 [Documentation] Get Config Policy for VDNS
Gary Wu7cfa85a2018-03-20 11:36:23 -070099 ${getconfigpolicy}= Catenate .*MicroServicevDNS*
DR695Hccff30b2017-02-17 18:44:24 -0500100 ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy}
101 ${output} = Fill JSON Template File ${GECONFIG_VFW_TEMPLATE} ${configpolicy_name}
102 ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output}
103 Should Be Equal As Strings ${get_resp.status_code} 200
DR695H0ca56d12019-05-14 11:48:20 -0400104 ${config}= Catenate ${get_resp.json()[0]["config"]}
Gary Wu5323bc22018-11-02 11:27:28 -0700105 ${thresholds}= Get Variable Value ${config["content"]["tca_policy"]["metricsPerEventName"][0]["thresholds"]}
jf986099c63292017-03-09 15:28:42 -0500106
107 # Extract object1 from Array
Gary Wu5323bc22018-11-02 11:27:28 -0700108 Should Be Equal ${thresholds[0]["severity"]} ${Expected_Severity_2}
109 Should Be Equal As Integers ${thresholds[0]["thresholdValue"]} ${Expected_Threshold_1}
110 Should Be Equal ${thresholds[0]["direction"]} ${Expected_Direction_3}
DR695Hccff30b2017-02-17 18:44:24 -0500111
112Teardown Closed Loop
113 [Documentation] Tear down a closed loop test case
jf986099c63292017-03-09 15:28:42 -0500114 Terminate All Processes
115 Teardown VNF
116 Log Teardown complete
DR695Hccff30b2017-02-17 18:44:24 -0500117
DR695Hccff30b2017-02-17 18:44:24 -0500118Create Config Policy
jf986099c63292017-03-09 15:28:42 -0500119 [Documentation] Create Config Policy
120 ${randompolicyname} = Create Policy Name
DR695Hccff30b2017-02-17 18:44:24 -0500121 ${policyname1}= Catenate com.${randompolicyname}
jf986099c63292017-03-09 15:28:42 -0500122 ${CONFIG_POLICY_NAME}= Set Test Variable ${policyname1}
DR695Hccff30b2017-02-17 18:44:24 -0500123 ${configpolicy}= Create Dictionary policy_name=${CONFIG_POLICY_NAME}
124 ${output} = Fill JSON Template File ${CREATE_CONFIG_TEMPLATE} ${configpolicy}
125 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
126 Should Be Equal As Strings ${put_resp.status_code} 200
127
128 Create Policy Name
129 [Documentation] Generate Policy Name
jf986099c63292017-03-09 15:28:42 -0500130 [Arguments] ${prefix}=ETE_
DR695Hccff30b2017-02-17 18:44:24 -0500131 ${random}= Generate Random String 15 [LOWER][NUMBERS]
132 ${policyname}= Catenate ${prefix}${random}
133 [Return] ${policyname}
jf986099c63292017-03-09 15:28:42 -0500134
DR695Hccff30b2017-02-17 18:44:24 -0500135Create Ops Policy
jf986099c63292017-03-09 15:28:42 -0500136 [Documentation] Create Opertional Policy
137 ${randompolicyname} = Create Policy Name
DR695Hccff30b2017-02-17 18:44:24 -0500138 ${policyname1}= Catenate com.${randompolicyname}
jf986099c63292017-03-09 15:28:42 -0500139 ${OPS_POLICY_NAME}= Set Test Variable ${policyname1}
DR695Hccff30b2017-02-17 18:44:24 -0500140 ${dict}= Create Dictionary policy_name=${OPS_POLICY_NAME}
141 #${NEWPOLICY1}= Create Dictionary policy_name=com.${OPS_POLICY_NAME}
142 ${output} = Fill JSON Template File ${CREATE_OPS_TEMPLATE} ${dict}
143 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
144 Log ${put_resp}
145 Should Be Equal As Strings ${put_resp.status_code} 200
jf986099c63292017-03-09 15:28:42 -0500146
DR695Hccff30b2017-02-17 18:44:24 -0500147Push Ops Policy
148 [Documentation] Push Ops Policy
149 [Arguments] ${policyname} ${policytype}
jf986099c63292017-03-09 15:28:42 -0500150 ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype}
DR695Hccff30b2017-02-17 18:44:24 -0500151 ${output} = Fill JSON Template ${PUSH_POLICY_TEMPLATE} ${dict}
152 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output}
153 Should Be Equal As Strings ${put_resp.status_code} 200
154
155Push Config Policy
156 [Documentation] Push Config Policy
157 [Arguments] ${policyname} ${policytype}
jf986099c63292017-03-09 15:28:42 -0500158 ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype}
DR695Hccff30b2017-02-17 18:44:24 -0500159 ${output} = Fill JSON Template ${PUSH_POLICY_TEMPLATE} ${dict}
160 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output}
161 Should Be Equal As Strings ${put_resp.status_code} 200
jf986099c63292017-03-09 15:28:42 -0500162
163
DR695Hccff30b2017-02-17 18:44:24 -0500164Delete Config Policy
165 [Documentation] Delete Config Policy
166 [Arguments] ${policy_name}
167 ${policyname3}= Catenate com.Config_BRMS_Param_${policyname}.1.xml
jf986099c63292017-03-09 15:28:42 -0500168 ${dict}= Create Dictionary policy_name=${policyname3}
DR695Hccff30b2017-02-17 18:44:24 -0500169 ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict}
170 ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output}
jf986099c63292017-03-09 15:28:42 -0500171 Should Be Equal As Strings ${put_resp.status_code} 200
172
DR695Hccff30b2017-02-17 18:44:24 -0500173Delete Ops Policy
174 [Documentation] Delete Ops Policy
175 [Arguments] ${policy_name}
176 ${policyname3}= Catenate com.Config_MS_com.vFirewall.1.xml
jf986099c63292017-03-09 15:28:42 -0500177 ${dict}= Create Dictionary policy_name=${policyname3}
DR695Hccff30b2017-02-17 18:44:24 -0500178 ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict}
179 ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output}
jf986099c63292017-03-09 15:28:42 -0500180 Should Be Equal As Strings ${put_resp.status_code} 200
181
DR695Hccff30b2017-02-17 18:44:24 -0500182Orchestrate VNF vFW closedloop
183 [Documentation] VNF Orchestration for vFW
jf986099c63292017-03-09 15:28:42 -0500184 Log VNF Orchestration flow TEST NAME=${TEST NAME}
185 Setup Orchestrate VNF ${GLOBAL_AAI_CLOUD_OWNER} SharedNode OwnerType v1 CloudZone
Jerry Flood3a169a32017-12-01 12:39:10 -0500186 ${stack_name} ${service}= Orchestrate VNF ETE_CLP vFWCL vFWCL ${TENANT_NAME}
jf986099c63292017-03-09 15:28:42 -0500187 [Return] ${stack_name}
188
DR695Hccff30b2017-02-17 18:44:24 -0500189 Orchestrate VNF vDNS closedloop
190 [Documentation] VNF Orchestration for vLB
jf986099c63292017-03-09 15:28:42 -0500191 Log VNF Orchestration flow TEST NAME=${TEST NAME}
192 Setup Orchestrate VNF ${GLOBAL_AAI_CLOUD_OWNER} SharedNode OwnerType v1 CloudZone
193 ${stack_name} ${service}= Orchestrate VNF ETE_CLP vLB vLB ${TENANT_NAME}
194 [Return] ${stack_name}
Brian Freeman20f11e42018-07-26 13:55:28 -0500195
196VFWCL High Test
197 [Documentation] Test Control Loop for High Traffic
198 [Arguments] ${pkg_host}
199 Enable Streams ${pkg_host} 10
Gary Wu9eb062d2018-11-09 20:10:10 -0800200 Log To Console Set number of streams to 10
201 :FOR ${i} IN RANGE 12
Brian Freeman20f11e42018-07-26 13:55:28 -0500202 \ Sleep 15s
203 \ ${resp}= Get List Of Enabled Streams ${pkg_host}
204 \ ${stream_count}= Evaluate len(${resp['sample-plugin']['pg-streams']['pg-stream']})
Gary Wu9eb062d2018-11-09 20:10:10 -0800205 \ Log To Console Number of streams: ${stream_count}
206 \ Exit For Loop If '${stream_count}'=='5'
Brian Freeman20f11e42018-07-26 13:55:28 -0500207 Should Be Equal As Integers ${stream_count} 5
208
209VFWCL Low Test
210 [Documentation] Test Control Loop for Low Traffic
211 [Arguments] ${pkg_host}
212 Enable Streams ${pkg_host} 1
Gary Wu9eb062d2018-11-09 20:10:10 -0800213 Log To Console Set number of streams to 1
Brian Freeman20f11e42018-07-26 13:55:28 -0500214 Get List Of Enabled Streams ${pkg_host}
Gary Wu9eb062d2018-11-09 20:10:10 -0800215 :FOR ${i} IN RANGE 12
Brian Freeman20f11e42018-07-26 13:55:28 -0500216 \ Sleep 15s
217 \ ${resp}= Get List Of Enabled Streams ${pkg_host}
218 \ ${stream_count}= Evaluate len(${resp['sample-plugin']['pg-streams']['pg-stream']})
Gary Wu9eb062d2018-11-09 20:10:10 -0800219 \ Log To Console Number of streams: ${stream_count}
220 \ Exit For Loop If '${stream_count}'=='5'
Brian Freeman20f11e42018-07-26 13:55:28 -0500221 Should Be Equal As Integers ${stream_count} 5
222
223