blob: e5a5ca92f67aaeff6f53c1f5442b0703b488edbf [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 ***
12${RESOURCE_PATH_CREATE} /PyPDPServer/createPolicy
13${RESOURCE_PATH_CREATE_PUSH} /PyPDPServer/pushPolicy
14${RESOURCE_PATH_CREATE_DELETE} /PyPDPServer/deletePolicy
15${RESOURCE_PATH_GET_CONFIG} /PyPDPServer/getConfig
16${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}
jf986099c63292017-03-09 15:28:42 -050057
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}
jf986099c63292017-03-09 15:28:42 -050064
DR695Hccff30b2017-02-17 18:44:24 -050065Initialize VFW Policy
66# Create Config Policy
67# Push Config Policy ${CONFIG_POLICY_NAME} ${CONFIG_POLICY_TYPE}
68# Create Ops Policy
jf986099c63292017-03-09 15:28:42 -050069# Push Ops Policy ${OPS_POLICY_NAME} ${OPS_POLICY_TYPE}
DR695Hccff30b2017-02-17 18:44:24 -050070 Get Configs VFW Policy
jf986099c63292017-03-09 15:28:42 -050071
DR695Hccff30b2017-02-17 18:44:24 -050072Initialize VDNS Policy
73 Get Configs VDNS Policy
jf986099c63292017-03-09 15:28:42 -050074
DR695Hccff30b2017-02-17 18:44:24 -050075Get Configs VFW Policy
76 [Documentation] Get Config Policy for VFW
77 ${getconfigpolicy}= Catenate .*${CONFIG_POLICY_NAME}*
78 ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy}
79 ${output} = Fill JSON Template File ${GECONFIG_VFW_TEMPLATE} ${configpolicy_name}
80 ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output}
81 Should Be Equal As Strings ${get_resp.status_code} 200
jf986099c63292017-03-09 15:28:42 -050082
DR695Hccff30b2017-02-17 18:44:24 -050083 ${json}= Parse Json ${get_resp.content}
84 ${config}= Parse Json ${json[0]["config"]}
jf986099c63292017-03-09 15:28:42 -050085
86 # Extract object1 from Array
DR695Hccff30b2017-02-17 18:44:24 -050087 ${severity}= Get Variable Value ${config["content"]["thresholds"][0]["severity"]}
jf986099c63292017-03-09 15:28:42 -050088 Should Be Equal ${severity} ${Expected_Severity_1}
DR695Hccff30b2017-02-17 18:44:24 -050089 ${Thresold_Value}= Get Variable Value ${config["content"]["thresholds"][0]["thresholdValue"]}
jf986099c63292017-03-09 15:28:42 -050090 Should Be Equal ${Thresold_Value} ${Expected_Threshold_1}
DR695Hccff30b2017-02-17 18:44:24 -050091 ${direction}= Get Variable Value ${config["content"]["thresholds"][0]["direction"]}
jf986099c63292017-03-09 15:28:42 -050092 Should Be Equal ${direction} ${Expected_Direction_1}
93
DR695Hccff30b2017-02-17 18:44:24 -050094 # Extract object2 from Array
95 ${severity_1}= Get Variable Value ${config["content"]["thresholds"][1]["severity"]}
jf986099c63292017-03-09 15:28:42 -050096 Should Be Equal ${severity_1} ${Expected_Severity_2}
DR695Hccff30b2017-02-17 18:44:24 -050097 ${Thresold_Value_1}= Get Variable Value ${config["content"]["thresholds"][1]["thresholdValue"]}
jf986099c63292017-03-09 15:28:42 -050098 Should Be Equal ${Thresold_Value_1} ${Expected_Threshold_2}
DR695Hccff30b2017-02-17 18:44:24 -050099 ${direction_1}= Get Variable Value ${config["content"]["thresholds"][1]["direction"]}
jf986099c63292017-03-09 15:28:42 -0500100 Should Be Equal ${direction_1} ${Expected_Direction_2}
101
DR695Hccff30b2017-02-17 18:44:24 -0500102Get Configs VDNS Policy
103 [Documentation] Get Config Policy for VDNS
104 ${getconfigpolicy}= Catenate .*vLoadBalancer*
105 ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy}
106 ${output} = Fill JSON Template File ${GECONFIG_VFW_TEMPLATE} ${configpolicy_name}
107 ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output}
108 Should Be Equal As Strings ${get_resp.status_code} 200
109 ${json}= Parse Json ${get_resp.content}
110 ${config}= Parse Json ${json[0]["config"]}
jf986099c63292017-03-09 15:28:42 -0500111
112 # Extract object1 from Array
DR695Hccff30b2017-02-17 18:44:24 -0500113 ${severity}= Get Variable Value ${config["content"]["thresholds"][0]["severity"]}
jf986099c63292017-03-09 15:28:42 -0500114 Should Be Equal ${severity} ${Expected_Severity_3}
DR695Hccff30b2017-02-17 18:44:24 -0500115 ${Thresold_Value}= Get Variable Value ${config["content"]["thresholds"][0]["thresholdValue"]}
jf986099c63292017-03-09 15:28:42 -0500116 Should Be Equal ${Thresold_Value} ${Expected_Threshold_3}
DR695Hccff30b2017-02-17 18:44:24 -0500117 ${direction}= Get Variable Value ${config["content"]["thresholds"][0]["direction"]}
jf986099c63292017-03-09 15:28:42 -0500118 Should Be Equal ${direction} ${Expected_Direction_3}
DR695Hccff30b2017-02-17 18:44:24 -0500119
120Teardown Closed Loop
121 [Documentation] Tear down a closed loop test case
jf986099c63292017-03-09 15:28:42 -0500122 Terminate All Processes
123 Teardown VNF
124 Log Teardown complete
DR695Hccff30b2017-02-17 18:44:24 -0500125
DR695Hccff30b2017-02-17 18:44:24 -0500126Create Config Policy
jf986099c63292017-03-09 15:28:42 -0500127 [Documentation] Create Config Policy
128 ${randompolicyname} = Create Policy Name
DR695Hccff30b2017-02-17 18:44:24 -0500129 ${policyname1}= Catenate com.${randompolicyname}
jf986099c63292017-03-09 15:28:42 -0500130 ${CONFIG_POLICY_NAME}= Set Test Variable ${policyname1}
DR695Hccff30b2017-02-17 18:44:24 -0500131 ${configpolicy}= Create Dictionary policy_name=${CONFIG_POLICY_NAME}
132 ${output} = Fill JSON Template File ${CREATE_CONFIG_TEMPLATE} ${configpolicy}
133 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
134 Should Be Equal As Strings ${put_resp.status_code} 200
135
136 Create Policy Name
137 [Documentation] Generate Policy Name
jf986099c63292017-03-09 15:28:42 -0500138 [Arguments] ${prefix}=ETE_
DR695Hccff30b2017-02-17 18:44:24 -0500139 ${random}= Generate Random String 15 [LOWER][NUMBERS]
140 ${policyname}= Catenate ${prefix}${random}
141 [Return] ${policyname}
jf986099c63292017-03-09 15:28:42 -0500142
DR695Hccff30b2017-02-17 18:44:24 -0500143Create Ops Policy
jf986099c63292017-03-09 15:28:42 -0500144 [Documentation] Create Opertional Policy
145 ${randompolicyname} = Create Policy Name
DR695Hccff30b2017-02-17 18:44:24 -0500146 ${policyname1}= Catenate com.${randompolicyname}
jf986099c63292017-03-09 15:28:42 -0500147 ${OPS_POLICY_NAME}= Set Test Variable ${policyname1}
DR695Hccff30b2017-02-17 18:44:24 -0500148 ${dict}= Create Dictionary policy_name=${OPS_POLICY_NAME}
149 #${NEWPOLICY1}= Create Dictionary policy_name=com.${OPS_POLICY_NAME}
150 ${output} = Fill JSON Template File ${CREATE_OPS_TEMPLATE} ${dict}
151 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output}
152 Log ${put_resp}
153 Should Be Equal As Strings ${put_resp.status_code} 200
jf986099c63292017-03-09 15:28:42 -0500154
DR695Hccff30b2017-02-17 18:44:24 -0500155Push Ops Policy
156 [Documentation] Push Ops 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
162
163Push Config Policy
164 [Documentation] Push Config Policy
165 [Arguments] ${policyname} ${policytype}
jf986099c63292017-03-09 15:28:42 -0500166 ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype}
DR695Hccff30b2017-02-17 18:44:24 -0500167 ${output} = Fill JSON Template ${PUSH_POLICY_TEMPLATE} ${dict}
168 ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output}
169 Should Be Equal As Strings ${put_resp.status_code} 200
jf986099c63292017-03-09 15:28:42 -0500170
171
DR695Hccff30b2017-02-17 18:44:24 -0500172Delete Config Policy
173 [Documentation] Delete Config Policy
174 [Arguments] ${policy_name}
175 ${policyname3}= Catenate com.Config_BRMS_Param_${policyname}.1.xml
jf986099c63292017-03-09 15:28:42 -0500176 ${dict}= Create Dictionary policy_name=${policyname3}
DR695Hccff30b2017-02-17 18:44:24 -0500177 ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict}
178 ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output}
jf986099c63292017-03-09 15:28:42 -0500179 Should Be Equal As Strings ${put_resp.status_code} 200
180
DR695Hccff30b2017-02-17 18:44:24 -0500181Delete Ops Policy
182 [Documentation] Delete Ops Policy
183 [Arguments] ${policy_name}
184 ${policyname3}= Catenate com.Config_MS_com.vFirewall.1.xml
jf986099c63292017-03-09 15:28:42 -0500185 ${dict}= Create Dictionary policy_name=${policyname3}
DR695Hccff30b2017-02-17 18:44:24 -0500186 ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict}
187 ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output}
jf986099c63292017-03-09 15:28:42 -0500188 Should Be Equal As Strings ${put_resp.status_code} 200
189
DR695Hccff30b2017-02-17 18:44:24 -0500190Orchestrate VNF vFW closedloop
191 [Documentation] VNF Orchestration for vFW
jf986099c63292017-03-09 15:28:42 -0500192 Log VNF Orchestration flow TEST NAME=${TEST NAME}
193 Setup Orchestrate VNF ${GLOBAL_AAI_CLOUD_OWNER} SharedNode OwnerType v1 CloudZone
194 ${stack_name} ${service}= Orchestrate VNF ETE_CLP vFW vFW ${TENANT_NAME}
195 [Return] ${stack_name}
196
DR695Hccff30b2017-02-17 18:44:24 -0500197 Orchestrate VNF vDNS closedloop
198 [Documentation] VNF Orchestration for vLB
jf986099c63292017-03-09 15:28:42 -0500199 Log VNF Orchestration flow TEST NAME=${TEST NAME}
200 Setup Orchestrate VNF ${GLOBAL_AAI_CLOUD_OWNER} SharedNode OwnerType v1 CloudZone
201 ${stack_name} ${service}= Orchestrate VNF ETE_CLP vLB vLB ${TENANT_NAME}
202 [Return] ${stack_name}