DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Policy Closed Loop Test cases |
| 3 | |
| 4 | Resource ../policy_interface.robot |
| 5 | Resource ../stack_validation/policy_check_vfw.robot |
| 6 | Resource vnf_orchestration_test_template.robot |
| 7 | Library String |
| 8 | Library HttpLibrary.HTTP |
| 9 | LIbrary 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 | |
| 28 | ${CONFIG_POLICY_NAME} vFirewall |
| 29 | ${CONFIG_POLICY_TYPE} Unknown |
| 30 | ${OPS_POLICY_NAME} |
| 31 | ${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 | |
| 48 | ${DNSSCALINGSTACK} |
| 49 | |
| 50 | *** Keywords *** |
| 51 | VFW Policy |
| 52 | Log Suite name ${SUITE NAME} ${TEST NAME} ${PREV TEST NAME} |
| 53 | Initialize VFW Policy |
| 54 | ${stackname}= Orchestrate VNF vFW closedloop |
| 55 | Policy Check Firewall Stack ${stackname} ${VFWPOLICYRATE} |
| 56 | |
| 57 | |
| 58 | VDNS Policy |
| 59 | Initialize VDNS Policy |
| 60 | ${stackname}= Orchestrate VNF vDNS closedloop |
| 61 | ${dnsscaling}= Policy Check vLB Stack ${stackname} ${VLBPOLICYRATE} |
| 62 | Set Test Variable ${DNSSCALINGSTACK} ${dnsscaling} |
| 63 | |
| 64 | Initialize VFW Policy |
| 65 | # Create Config Policy |
| 66 | # Push Config Policy ${CONFIG_POLICY_NAME} ${CONFIG_POLICY_TYPE} |
| 67 | # Create Ops Policy |
| 68 | # Push Ops Policy ${OPS_POLICY_NAME} ${OPS_POLICY_TYPE} |
| 69 | Get Configs VFW Policy |
| 70 | |
| 71 | Initialize VDNS Policy |
| 72 | Get Configs VDNS Policy |
| 73 | |
| 74 | Get Configs VFW Policy |
| 75 | [Documentation] Get Config Policy for VFW |
| 76 | ${getconfigpolicy}= Catenate .*${CONFIG_POLICY_NAME}* |
| 77 | ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy} |
| 78 | ${output} = Fill JSON Template File ${GECONFIG_VFW_TEMPLATE} ${configpolicy_name} |
| 79 | ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output} |
| 80 | Should Be Equal As Strings ${get_resp.status_code} 200 |
| 81 | |
| 82 | ${json}= Parse Json ${get_resp.content} |
| 83 | ${config}= Parse Json ${json[0]["config"]} |
| 84 | |
| 85 | # Extract object1 from Array |
| 86 | ${severity}= Get Variable Value ${config["content"]["thresholds"][0]["severity"]} |
| 87 | Should Be Equal ${severity} ${Expected_Severity_1} |
| 88 | ${Thresold_Value}= Get Variable Value ${config["content"]["thresholds"][0]["thresholdValue"]} |
| 89 | Should Be Equal ${Thresold_Value} ${Expected_Threshold_1} |
| 90 | ${direction}= Get Variable Value ${config["content"]["thresholds"][0]["direction"]} |
| 91 | Should Be Equal ${direction} ${Expected_Direction_1} |
| 92 | |
| 93 | # Extract object2 from Array |
| 94 | ${severity_1}= Get Variable Value ${config["content"]["thresholds"][1]["severity"]} |
| 95 | Should Be Equal ${severity_1} ${Expected_Severity_2} |
| 96 | ${Thresold_Value_1}= Get Variable Value ${config["content"]["thresholds"][1]["thresholdValue"]} |
| 97 | Should Be Equal ${Thresold_Value_1} ${Expected_Threshold_2} |
| 98 | ${direction_1}= Get Variable Value ${config["content"]["thresholds"][1]["direction"]} |
| 99 | Should Be Equal ${direction_1} ${Expected_Direction_2} |
| 100 | |
| 101 | Get Configs VDNS Policy |
| 102 | [Documentation] Get Config Policy for VDNS |
| 103 | ${getconfigpolicy}= Catenate .*vLoadBalancer* |
| 104 | ${configpolicy_name}= Create Dictionary config_policy_name=${getconfigpolicy} |
| 105 | ${output} = Fill JSON Template File ${GECONFIG_VFW_TEMPLATE} ${configpolicy_name} |
| 106 | ${get_resp} = Run Policy Get Configs Request ${RESOURCE_PATH_GET_CONFIG} ${output} |
| 107 | Should Be Equal As Strings ${get_resp.status_code} 200 |
| 108 | ${json}= Parse Json ${get_resp.content} |
| 109 | ${config}= Parse Json ${json[0]["config"]} |
| 110 | |
| 111 | # Extract object1 from Array |
| 112 | ${severity}= Get Variable Value ${config["content"]["thresholds"][0]["severity"]} |
| 113 | Should Be Equal ${severity} ${Expected_Severity_3} |
| 114 | ${Thresold_Value}= Get Variable Value ${config["content"]["thresholds"][0]["thresholdValue"]} |
| 115 | Should Be Equal ${Thresold_Value} ${Expected_Threshold_3} |
| 116 | ${direction}= Get Variable Value ${config["content"]["thresholds"][0]["direction"]} |
| 117 | Should Be Equal ${direction} ${Expected_Direction_3} |
| 118 | |
| 119 | Teardown Closed Loop |
| 120 | [Documentation] Tear down a closed loop test case |
| 121 | Terminate All Processes |
| 122 | Teardown VDNS |
| 123 | Teardown VNF |
| 124 | #Clean A&AI Inventory VFWPolicy_Customer Rackspece vFW |
| 125 | # Delete Config Policy ${CONFIG_POLICY_NAME} |
| 126 | # Delete Ops Policy ${OPS_POLICY_NAME} |
| 127 | Log Teardown complete |
| 128 | |
| 129 | Teardown VDNS |
| 130 | Return From Keyword if '${DNSSCALINGSTACK}' == '' |
| 131 | # This needs to be done via VID |
| 132 | Teardown Stack ${DNSSCALINGSTACK} |
| 133 | |
| 134 | Create Config Policy |
| 135 | [Documentation] Create Config Policy |
| 136 | ${randompolicyname} = Create Policy Name |
| 137 | ${policyname1}= Catenate com.${randompolicyname} |
| 138 | ${CONFIG_POLICY_NAME}= Set Test Variable ${policyname1} |
| 139 | ${configpolicy}= Create Dictionary policy_name=${CONFIG_POLICY_NAME} |
| 140 | ${output} = Fill JSON Template File ${CREATE_CONFIG_TEMPLATE} ${configpolicy} |
| 141 | ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output} |
| 142 | Should Be Equal As Strings ${put_resp.status_code} 200 |
| 143 | |
| 144 | Create Policy Name |
| 145 | [Documentation] Generate Policy Name |
| 146 | [Arguments] ${prefix}=ETE_ |
| 147 | ${random}= Generate Random String 15 [LOWER][NUMBERS] |
| 148 | ${policyname}= Catenate ${prefix}${random} |
| 149 | [Return] ${policyname} |
| 150 | |
| 151 | Create Ops Policy |
| 152 | [Documentation] Create Opertional Policy |
| 153 | ${randompolicyname} = Create Policy Name |
| 154 | ${policyname1}= Catenate com.${randompolicyname} |
| 155 | ${OPS_POLICY_NAME}= Set Test Variable ${policyname1} |
| 156 | ${dict}= Create Dictionary policy_name=${OPS_POLICY_NAME} |
| 157 | #${NEWPOLICY1}= Create Dictionary policy_name=com.${OPS_POLICY_NAME} |
| 158 | ${output} = Fill JSON Template File ${CREATE_OPS_TEMPLATE} ${dict} |
| 159 | ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE} ${output} |
| 160 | Log ${put_resp} |
| 161 | Should Be Equal As Strings ${put_resp.status_code} 200 |
| 162 | |
| 163 | Push Ops Policy |
| 164 | [Documentation] Push Ops Policy |
| 165 | [Arguments] ${policyname} ${policytype} |
| 166 | ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype} |
| 167 | ${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 |
| 170 | |
| 171 | Push Config Policy |
| 172 | [Documentation] Push Config Policy |
| 173 | [Arguments] ${policyname} ${policytype} |
| 174 | ${dict}= Create Dictionary policy_name=${policyname} policy_type=${policytype} |
| 175 | ${output} = Fill JSON Template ${PUSH_POLICY_TEMPLATE} ${dict} |
| 176 | ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output} |
| 177 | Should Be Equal As Strings ${put_resp.status_code} 200 |
| 178 | |
| 179 | |
| 180 | Delete Config Policy |
| 181 | [Documentation] Delete Config Policy |
| 182 | [Arguments] ${policy_name} |
| 183 | ${policyname3}= Catenate com.Config_BRMS_Param_${policyname}.1.xml |
| 184 | ${dict}= Create Dictionary policy_name=${policyname3} |
| 185 | ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict} |
| 186 | ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output} |
| 187 | Should Be Equal As Strings ${put_resp.status_code} 200 |
| 188 | |
| 189 | Delete Ops Policy |
| 190 | [Documentation] Delete Ops Policy |
| 191 | [Arguments] ${policy_name} |
| 192 | ${policyname3}= Catenate com.Config_MS_com.vFirewall.1.xml |
| 193 | ${dict}= Create Dictionary policy_name=${policyname3} |
| 194 | ${output} = Fill JSON Template ${DEL_POLICY_TEMPLATE} ${dict} |
| 195 | ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output} |
| 196 | Should Be Equal As Strings ${put_resp.status_code} 200 |
| 197 | |
| 198 | Orchestrate VNF vFW closedloop |
| 199 | [Documentation] VNF Orchestration for vFW |
| 200 | Log VNF Orchestration flow TEST NAME=${TEST NAME} |
| 201 | Setup Orchestrate VNF ${GLOBAL_AAI_CLOUD_OWNER} ${GLOBAL_OPENSTACK_SERVICE_REGION} SharedNode OwnerType v1 CloudZone |
| 202 | ${stack_name} ${service}= Orchestrate VNF ETE_CLP vFW vFW ${GLOBAL_OPENSTACK_SERVICE_REGION} ${TENANT_NAME} |
| 203 | [Return] ${stack_name} |
| 204 | |
| 205 | Orchestrate VNF vDNS closedloop |
| 206 | [Documentation] VNF Orchestration for vLB |
| 207 | Log VNF Orchestration flow TEST NAME=${TEST NAME} |
| 208 | Setup Orchestrate VNF ${GLOBAL_AAI_CLOUD_OWNER} ${GLOBAL_OPENSTACK_SERVICE_REGION} SharedNode OwnerType v1 CloudZone |
| 209 | ${stack_name} ${service}= Orchestrate VNF ETE_CLP vLB vLB ${GLOBAL_OPENSTACK_SERVICE_REGION} ${TENANT_NAME} |
| 210 | [Return] ${stack_name} |