blob: 0a0a895065b4771a077a83a239af0d46ad100ac7 [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation Policy Closed Loop Test cases
3
4Resource ../policy_interface.robot
5Resource ../stack_validation/policy_check_vfw.robot
6Resource vnf_orchestration_test_template.robot
7Library String
8Library HttpLibrary.HTTP
9LIbrary Process
10
11*** Variables ***
Jerry Flooda9ee25c2017-05-31 14:50:37 -040012${RESOURCE_PATH_CREATE} /pdp/createPolicy
13${RESOURCE_PATH_CREATE_PUSH} /pdp/pushPolicy
14${RESOURCE_PATH_CREATE_DELETE} /pdp/deletePolicy
15${RESOURCE_PATH_GET_CONFIG} /pdp/getConfig
DR695Hccff30b2017-02-17 18:44:24 -050016${CREATE_CONFIG_TEMPLATE} robot/assets/templates/policy/closedloop_configpolicy.template
17${CREATE_OPS_TEMPLATE} robot/assets/templates/policy/closedloop_opspolicy.template
18${PUSH_POLICY_TEMPLATE} robot/assets/templates/policy/closedloop_pushpolicy.template
19${DEL_POLICY_TEMPLATE} robot/assets/templates/policy/closedloop_deletepolicy.template
20${GECONFIG_VFW_TEMPLATE} robot/assets/templates/policy/closedloop_getconfigpolicy.template
21
22# 'Normal' number of pg streams that will be set when policy is triggered
23${VFWPOLICYRATE} 5
24
25# Max nslookup requests per second before triggering event.
26${VLBPOLICYRATE} 20
27
jf986099c63292017-03-09 15:28:42 -050028${CONFIG_POLICY_NAME} vFirewall
29${CONFIG_POLICY_TYPE} Unknown
30${OPS_POLICY_NAME}
DR695Hccff30b2017-02-17 18:44:24 -050031${OPS_POLICY_TYPE} BRMS_PARAM
32
33# VFW low threshold
34${Expected_Severity_1} MAJOR
35${Expected_Threshold_1} 300
36${Expected_Direction_1} LESS_OR_EQUAL
37
38# VFW high threshold
39${Expected_Severity_2} CRITICAL
40${Expected_Threshold_2} 700
41${Expected_Direction_2} GREATER_OR_EQUAL
42
43# VDNS High threshold
44${Expected_Severity_3} MAJOR
45${Expected_Threshold_3} 200
46${Expected_Direction_3} GREATER_OR_EQUAL
47
jf986099c63292017-03-09 15:28:42 -050048#********** Test Case Variables ************
49${DNSSCALINGSTACK}
DR695Hccff30b2017-02-17 18:44:24 -050050
51*** Keywords ***
52VFW Policy
53 Log Suite name ${SUITE NAME} ${TEST NAME} ${PREV TEST NAME}
54 Initialize VFW Policy
jf986099c63292017-03-09 15:28:42 -050055 ${stackname}= Orchestrate VNF vFW closedloop
DR695Hccff30b2017-02-17 18:44:24 -050056 Policy Check Firewall Stack ${stackname} ${VFWPOLICYRATE}
Jerry Flood8877bca2017-03-14 07:34:41 -040057 Delete VNF
DR695Hccff30b2017-02-17 18:44:24 -050058
59VDNS Policy
60 Initialize VDNS Policy
61 ${stackname}= Orchestrate VNF vDNS closedloop
62 ${dnsscaling}= Policy Check vLB Stack ${stackname} ${VLBPOLICYRATE}
63 Set Test Variable ${DNSSCALINGSTACK} ${dnsscaling}
Jerry Flood8877bca2017-03-14 07:34:41 -040064 Delete VNF
jf986099c63292017-03-09 15:28:42 -050065
DR695Hccff30b2017-02-17 18:44:24 -050066Initialize VFW Policy
67# Create Config Policy
68# Push Config Policy ${CONFIG_POLICY_NAME} ${CONFIG_POLICY_TYPE}
69# Create Ops Policy
jf986099c63292017-03-09 15:28:42 -050070# Push Ops Policy ${OPS_POLICY_NAME} ${OPS_POLICY_TYPE}
DR695Hccff30b2017-02-17 18:44:24 -050071 Get Configs VFW Policy
jf986099c63292017-03-09 15:28:42 -050072
DR695Hccff30b2017-02-17 18:44:24 -050073Initialize VDNS Policy
74 Get Configs VDNS Policy
jf986099c63292017-03-09 15:28:42 -050075
DR695Hccff30b2017-02-17 18:44:24 -050076Get Configs VFW Policy
77 [Documentation] Get Config Policy for VFW
78 ${getconfigpolicy}= Catenate .*${CONFIG_POLICY_NAME}*
79 ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy}
80 ${output} = Fill JSON Template File ${GECONFIG_VFW_TEMPLATE} ${configpolicy_name}
81 ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output}
82 Should Be Equal As Strings ${get_resp.status_code} 200
jf986099c63292017-03-09 15:28:42 -050083
DR695Hccff30b2017-02-17 18:44:24 -050084 ${json}= Parse Json ${get_resp.content}
85 ${config}= Parse Json ${json[0]["config"]}
jf986099c63292017-03-09 15:28:42 -050086
87 # Extract object1 from Array
DR695Hccff30b2017-02-17 18:44:24 -050088 ${severity}= Get Variable Value ${config["content"]["thresholds"][0]["severity"]}
jf986099c63292017-03-09 15:28:42 -050089 Should Be Equal ${severity} ${Expected_Severity_1}
DR695Hccff30b2017-02-17 18:44:24 -050090 ${Thresold_Value}= Get Variable Value ${config["content"]["thresholds"][0]["thresholdValue"]}
Gary Wu80676112018-03-20 13:22:17 -070091 Should Be Equal As Integers ${Thresold_Value} ${Expected_Threshold_1}
DR695Hccff30b2017-02-17 18:44:24 -050092 ${direction}= Get Variable Value ${config["content"]["thresholds"][0]["direction"]}
jf986099c63292017-03-09 15:28:42 -050093 Should Be Equal ${direction} ${Expected_Direction_1}
94
DR695Hccff30b2017-02-17 18:44:24 -050095 # Extract object2 from Array
96 ${severity_1}= Get Variable Value ${config["content"]["thresholds"][1]["severity"]}
jf986099c63292017-03-09 15:28:42 -050097 Should Be Equal ${severity_1} ${Expected_Severity_2}
DR695Hccff30b2017-02-17 18:44:24 -050098 ${Thresold_Value_1}= Get Variable Value ${config["content"]["thresholds"][1]["thresholdValue"]}
Gary Wu80676112018-03-20 13:22:17 -070099 Should Be Equal As Integers ${Thresold_Value_1} ${Expected_Threshold_2}
DR695Hccff30b2017-02-17 18:44:24 -0500100 ${direction_1}= Get Variable Value ${config["content"]["thresholds"][1]["direction"]}
jf986099c63292017-03-09 15:28:42 -0500101 Should Be Equal ${direction_1} ${Expected_Direction_2}
102
DR695Hccff30b2017-02-17 18:44:24 -0500103Get Configs VDNS Policy
104 [Documentation] Get Config Policy for VDNS
Gary Wu7cfa85a2018-03-20 11:36:23 -0700105 ${getconfigpolicy}= Catenate .*MicroServicevDNS*
DR695Hccff30b2017-02-17 18:44:24 -0500106 ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy}
107 ${output} = Fill JSON Template File ${GECONFIG_VFW_TEMPLATE} ${configpolicy_name}
108 ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output}
109 Should Be Equal As Strings ${get_resp.status_code} 200
110 ${json}= Parse Json ${get_resp.content}
111 ${config}= Parse Json ${json[0]["config"]}
jf986099c63292017-03-09 15:28:42 -0500112
113 # Extract object1 from Array
Pamela Dragosh51b6f5c2018-03-20 12:56:35 -0400114 ${severity}= Get Variable Value ${config["content"]["tca_policy"]["metricsPerEventName"][0]["thresholds"][0]["severity"]}
115 Should Be Equal ${severity} ${Expected_Severity_2}
116 ${Thresold_Value}= Get Variable Value ${config["content"]["tca_policy"]["metricsPerEventName"][0]["thresholds"][0]["thresholdValue"]}
Gary Wu80676112018-03-20 13:22:17 -0700117 Should Be Equal As Integers ${Thresold_Value} ${Expected_Threshold_1}
DR695Hce07d412018-04-11 22:28:41 -0400118 ${direction}= Get Variable Value ${config["content"]["tca_policy"]["metricsPerEventName"][0]["thresholds"][0]["direction"]}
jf986099c63292017-03-09 15:28:42 -0500119 Should Be Equal ${direction} ${Expected_Direction_3}
DR695Hccff30b2017-02-17 18:44:24 -0500120
121Teardown Closed Loop
122 [Documentation] Tear down a closed loop test case
jf986099c63292017-03-09 15:28:42 -0500123 Terminate All Processes
124 Teardown VNF
125 Log Teardown complete
DR695Hccff30b2017-02-17 18:44:24 -0500126
DR695Hccff30b2017-02-17 18:44:24 -0500127Create Config Policy
jf986099c63292017-03-09 15:28:42 -0500128 [Documentation] Create Config Policy
129 ${randompolicyname} = Create Policy Name
DR695Hccff30b2017-02-17 18:44:24 -0500130 ${policyname1}= Catenate com.${randompolicyname}
jf986099c63292017-03-09 15:28:42 -0500131 ${CONFIG_POLICY_NAME}= Set Test Variable ${policyname1}
DR695Hccff30b2017-02-17 18:44:24 -0500132 ${configpolicy}= Create Dictionary policy_name=${CONFIG_POLICY_NAME}
133 ${output} = Fill JSON Template File ${CREATE_CONFIG_TEMPLATE} ${configpolicy}
134 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
135 Should Be Equal As Strings ${put_resp.status_code} 200
136
137 Create Policy Name
138 [Documentation] Generate Policy Name
jf986099c63292017-03-09 15:28:42 -0500139 [Arguments] ${prefix}=ETE_
DR695Hccff30b2017-02-17 18:44:24 -0500140 ${random}= Generate Random String 15 [LOWER][NUMBERS]
141 ${policyname}= Catenate ${prefix}${random}
142 [Return] ${policyname}
jf986099c63292017-03-09 15:28:42 -0500143
DR695Hccff30b2017-02-17 18:44:24 -0500144Create Ops Policy
jf986099c63292017-03-09 15:28:42 -0500145 [Documentation] Create Opertional Policy
146 ${randompolicyname} = Create Policy Name
DR695Hccff30b2017-02-17 18:44:24 -0500147 ${policyname1}= Catenate com.${randompolicyname}
jf986099c63292017-03-09 15:28:42 -0500148 ${OPS_POLICY_NAME}= Set Test Variable ${policyname1}
DR695Hccff30b2017-02-17 18:44:24 -0500149 ${dict}= Create Dictionary policy_name=${OPS_POLICY_NAME}
150 #${NEWPOLICY1}= Create Dictionary policy_name=com.${OPS_POLICY_NAME}
151 ${output} = Fill JSON Template File ${CREATE_OPS_TEMPLATE} ${dict}
152 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
153 Log ${put_resp}
154 Should Be Equal As Strings ${put_resp.status_code} 200
jf986099c63292017-03-09 15:28:42 -0500155
DR695Hccff30b2017-02-17 18:44:24 -0500156Push Ops Policy
157 [Documentation] Push Ops Policy
158 [Arguments] ${policyname} ${policytype}
jf986099c63292017-03-09 15:28:42 -0500159 ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype}
DR695Hccff30b2017-02-17 18:44:24 -0500160 ${output} = Fill JSON Template ${PUSH_POLICY_TEMPLATE} ${dict}
161 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output}
162 Should Be Equal As Strings ${put_resp.status_code} 200
163
164Push Config Policy
165 [Documentation] Push Config Policy
166 [Arguments] ${policyname} ${policytype}
jf986099c63292017-03-09 15:28:42 -0500167 ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype}
DR695Hccff30b2017-02-17 18:44:24 -0500168 ${output} = Fill JSON Template ${PUSH_POLICY_TEMPLATE} ${dict}
169 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output}
170 Should Be Equal As Strings ${put_resp.status_code} 200
jf986099c63292017-03-09 15:28:42 -0500171
172
DR695Hccff30b2017-02-17 18:44:24 -0500173Delete Config Policy
174 [Documentation] Delete Config Policy
175 [Arguments] ${policy_name}
176 ${policyname3}= Catenate com.Config_BRMS_Param_${policyname}.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 -0500182Delete Ops Policy
183 [Documentation] Delete Ops Policy
184 [Arguments] ${policy_name}
185 ${policyname3}= Catenate com.Config_MS_com.vFirewall.1.xml
jf986099c63292017-03-09 15:28:42 -0500186 ${dict}= Create Dictionary policy_name=${policyname3}
DR695Hccff30b2017-02-17 18:44:24 -0500187 ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict}
188 ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output}
jf986099c63292017-03-09 15:28:42 -0500189 Should Be Equal As Strings ${put_resp.status_code} 200
190
DR695Hccff30b2017-02-17 18:44:24 -0500191Orchestrate VNF vFW closedloop
192 [Documentation] VNF Orchestration for vFW
jf986099c63292017-03-09 15:28:42 -0500193 Log VNF Orchestration flow TEST NAME=${TEST NAME}
194 Setup Orchestrate VNF ${GLOBAL_AAI_CLOUD_OWNER} SharedNode OwnerType v1 CloudZone
Jerry Flood3a169a32017-12-01 12:39:10 -0500195 ${stack_name} ${service}= Orchestrate VNF ETE_CLP vFWCL vFWCL ${TENANT_NAME}
jf986099c63292017-03-09 15:28:42 -0500196 [Return] ${stack_name}
197
DR695Hccff30b2017-02-17 18:44:24 -0500198 Orchestrate VNF vDNS closedloop
199 [Documentation] VNF Orchestration for vLB
jf986099c63292017-03-09 15:28:42 -0500200 Log VNF Orchestration flow TEST NAME=${TEST NAME}
201 Setup Orchestrate VNF ${GLOBAL_AAI_CLOUD_OWNER} SharedNode OwnerType v1 CloudZone
202 ${stack_name} ${service}= Orchestrate VNF ETE_CLP vLB vLB ${TENANT_NAME}
203 [Return] ${stack_name}