X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Fsuites%2Fbgpcep%2Fbgpflowspec%2F010_bgp_flowspec.robot;h=ef3930ab6becc0424a2133747f397aa89f03bdc3;hb=HEAD;hp=e069c66d9cf23b28e2988b505f06a2aedf5fa921;hpb=270cbc2ee02bb04295ce4bd8d31054bc02ce3bba;p=integration%2Ftest.git diff --git a/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot b/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot index e069c66d9c..ef3930ab6b 100644 --- a/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot +++ b/csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot @@ -1,120 +1,143 @@ *** Settings *** -Documentation Functional test for bgp flowspec. +Documentation Functional test for bgp flowspec. ... -... Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. +... Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. ... -... This program and the accompanying materials are made available under the -... terms of the Eclipse Public License v1.0 which accompanies this distribution, -... and is available at http://www.eclipse.org/legal/epl-v10.html -Suite Setup Start Suite -Suite Teardown Stop Suite -Library RequestsLibrary -Library SSHLibrary -Variables ${CURDIR}/../../../variables/Variables.py -Variables ${CURDIR}/../../../variables/bgpuser/variables.py ${TOOLS_SYSTEM_IP} ${ODL_STREAM} -Resource ${CURDIR}/../../../libraries/ExaBgpLib.robot -Resource ${CURDIR}/../../../libraries/SSHKeywords.robot -Resource ${CURDIR}/../../../libraries/SetupUtils.robot -Resource ${CURDIR}/../../../libraries/CompareStream.robot -Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot +... This program and the accompanying materials are made available under the +... terms of the Eclipse Public License v1.0 which accompanies this distribution, +... and is available at http://www.eclipse.org/legal/epl-v10.html + +Library RequestsLibrary +Library SSHLibrary +Resource ../../../libraries/CompareStream.robot +Resource ../../../libraries/ExaBgpLib.robot +Resource ../../../libraries/SSHKeywords.robot +Resource ../../../libraries/TemplatedRequests.robot +Resource ../../../variables/Variables.robot + +Suite Setup Start_Suite +Suite Teardown Stop_Suite + *** Variables *** -${HOLDTIME} 180 -${BGP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/bgpflowspec -${CMD} env exabgp.tcp.port=1790 exabgp --debug -${EXP0} empty-flowspec.json -${CFG1} bgp-flowspec.cfg -${EXP1} bgp-flowspec.json -${CFG2} bgp-flowspec-redirect.cfg -${EXP2} bgp-flowspec-redirect.json -${FLOWSPEC_URL} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/tables/bgp-types:ipv4-address-family/bgp-flowspec:flowspec-subsequent-address-family/bgp-flowspec:flowspec-routes -${CONFIG_SESSION} session -${DEVICE_NAME} controller-config -${BGP_PEER_NAME} example-bgp-peer -${RIB_INSTANCE} example-bgp-rib -${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE} +${BGP_VARIABLES_FOLDER} ${CURDIR}/../../../variables/bgpflowspec/ +${CMD} env exabgp.tcp.port=1790 exabgp --debug +${HOLDTIME} 180 +${EXP0} {"bgp-flowspec:flowspec-routes": {}} +${CFG1} bgp-flowspec.cfg +${EXP1} bgp_flowspec +${CFG2} bgp-flowspec-redirect.cfg +${EXP2} bgp_flowspec_redirect +${FLOWSPEC_URL} +... /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/loc-rib/tables/bgp-types:ipv4-address-family/bgp-flowspec:flowspec-subsequent-address-family/bgp-flowspec:flowspec-routes +${CONFIG_SESSION} session +${DEVICE_NAME} controller-config +${RIB_INSTANCE} example-bgp-rib +${PROTOCOL_OPENCONFIG} ${RIB_INSTANCE} +@{EMPTY_LIST} + *** Test Cases *** Check_For_Empty_Topology_Before_Talking [Documentation] Sanity check bgp-flowspec:flowspec-routes is up but empty. [Tags] critical - BuiltIn.Wait Until Keyword Succeeds 60s 3s Verify Empty Flowspec Data + BuiltIn.Wait_Until_Keyword_Succeeds 60s 3s Verify_Empty_Flowspec_Data Reconfigure_ODL_To_Accept_Connection [Documentation] Configure BGP peer module with initiate-connection set to false. - &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} - ... INITIATE=false RIB_INSTANCE_NAME=${RIB_INSTANCE} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} PASSIVE_MODE=true - TemplatedRequests.Put_As_Xml_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION} + &{mapping} BuiltIn.Create_Dictionary + ... IP=${TOOLS_SYSTEM_IP} + ... HOLDTIME=${HOLDTIME} + ... PEER_PORT=${BGP_TOOL_PORT} + ... INITIATE=false + ... BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} + ... PASSIVE_MODE=true + TemplatedRequests.Put_As_Xml_Templated + ... ${BGP_VARIABLES_FOLDER}/bgp_peer + ... mapping=${mapping} + ... session=${CONFIG_SESSION} -FlowSpec Test 1 +FlowSpec_Test_1 [Documentation] Testing flowspec values for ${CFG1} - [Setup] Setup Testcase ${CFG1} - BuiltIn.Wait Until Keyword Succeeds 15s 1s Verify Flowspec Data ${EXP1} + [Setup] Setup_Testcase ${CFG1} + BuiltIn.Wait_Until_Keyword_Succeeds 15s 1s Verify_Flowspec_Data ${EXP1} [Teardown] ExaBgpLib.Stop_ExaBgp -FlowSpec Test 2 +FlowSpec_Test_2 [Documentation] Testing flowspec values for ${CFG2} - [Setup] Setup Testcase ${CFG2} - BuiltIn.Wait Until Keyword Succeeds 15s 1s Verify Flowspec Data ${EXP2} + [Setup] Setup_Testcase ${CFG2} + BuiltIn.Wait_Until_Keyword_Succeeds 15s 1s Verify_Flowspec_Data ${EXP2} [Teardown] ExaBgpLib.Stop_ExaBgp Deconfigure_ODL_To_Accept_Connection [Documentation] Deconfigure BGP peer. - &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME} NAME=${BGP_PEER_NAME} IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} - TemplatedRequests.Delete_Templated ${BGP_VARIABLES_FOLDER}/bgp_peer mapping=${mapping} session=${CONFIG_SESSION} + &{mapping} BuiltIn.Create_Dictionary IP=${TOOLS_SYSTEM_IP} BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG} + TemplatedRequests.Delete_Templated + ... ${BGP_VARIABLES_FOLDER}/bgp_peer + ... mapping=${mapping} + ... session=${CONFIG_SESSION} + *** Keywords *** -Start Suite +Start_Suite [Documentation] Suite setup keyword - ${mininet_conn_id}= SSHLibrary.Open Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s - Builtin.Set Suite Variable ${mininet_conn_id} - SSHKeywords.Flexible Mininet Login ${TOOLS_SYSTEM_USER} - ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command ls return_stdout=True return_stderr=True - ... return_rc=True - ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command sudo apt-get install -y python-pip return_stdout=True return_stderr=True - ... return_rc=True - ${stdout} ${stderr} ${rc}= SSHLibrary.Execute Command sudo pip install exabgp return_stdout=True return_stderr=True - ... return_rc=True - RequestsLibrary.Create Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} - Upload Config Files ${CURDIR}/../../../variables/bgpflowspec/ - -Stop Suite + SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s + SSHKeywords.Flexible_Mininet_Login ${TOOLS_SYSTEM_USER} + SSHKeywords.Virtual_Env_Create + SSHKeywords.Virtual_Env_Install_Package setuptools==44.0.0 + SSHKeywords.Virtual_Env_Install_Package exabgp==3.4.16 + RequestsLibrary.Create_Session ${CONFIG_SESSION} http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} + Upload_Config_Files ${BGP_VARIABLES_FOLDER} + +Stop_Suite [Documentation] Suite teardown keyword - SSHLibrary.Close All Connections - RequestsLibrary.Delete All Sessions + SSHLibrary.Close_All_Connections + RequestsLibrary.Delete_All_Sessions -Upload Config Files - [Arguments] ${dir_name} +Upload_Config_Files [Documentation] Uploads exabgp config files - SSHLibrary.Put Directory ${CURDIR}/../../../variables/bgpflowspec/ . - @{cfgfiles}= SSHLibrary.List Files In Directory . *.cfg - : FOR ${cfgfile} IN @{cfgfiles} - \ SSHLibrary.Execute Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile} - \ SSHLibrary.Execute Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile} - \ ${stdout}= SSHLibrary.Execute Command cat ${cfgfile} - \ Log ${stdout} - -Setup Testcase + [Arguments] ${dir_name} + SSHLibrary.Put_Directory ${BGP_VARIABLES_FOLDER} . + @{cfgfiles} SSHLibrary.List_Files_In_Directory . *.cfg + FOR ${cfgfile} IN @{cfgfiles} + SSHLibrary.Execute_Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile} + SSHLibrary.Execute_Command sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile} + ${stdout} SSHLibrary.Execute_Command cat ${cfgfile} + Log ${stdout} + END + +Setup_Testcase [Arguments] ${cfg_file} - Verify Empty Flowspec Data - ExaBgpLib.Start_ExaBgp_And_Verify_Connected ${cfg_file} ${CONFIG_SESSION} ${TOOLS_SYSTEM_IP} + Verify_Empty_Flowspec_Data + ExaBgpLib.Start_ExaBgp_And_Verify_Connected + ... ${cfg_file} + ... ${CONFIG_SESSION} + ... ${TOOLS_SYSTEM_IP} + ... connection_retries=${3} -Verify Empty Flowspec Data +Verify_Empty_Flowspec_Data [Documentation] Verify expected response. - Verify Flowspec Data ${EXP0} + Verify_Empty_Flowspec_Data_Neon -Verify Flowspec Data - [Arguments] ${exprspfile} +Verify_Flowspec_Data [Documentation] Verify expected response - ${keys_with_bits}= BuiltIn.Create_List - ${expected_rsp}= Get Expected Response From File ${exprspfile} - ${rsp}= RequestsLibrary.Get Request ${CONFIG_SESSION} ${FLOWSPEC_URL} - TemplatedRequests.Normalize_Jsons_With_Bits_And_Compare ${expected_rsp} ${rsp.content} keys_with_bits=${keys_with_bits} - -Get Expected Response From File - [Arguments] ${exprspfile} - [Documentation] Looks for release specific response first, then take default. - ${status} ${expresponse}= BuiltIn.Run_Keyword_And_Ignore_Error OperatingSystem.Get File ${CURDIR}/../../../variables/bgpflowspec/${exprspfile}.${ODL_STREAM} - Return From Keyword If '${status}' == 'PASS' ${expresponse} - ${expresponse}= OperatingSystem.Get File ${CURDIR}/../../../variables/bgpflowspec/${exprspfile} - [Return] ${expresponse} + [Arguments] ${exprspdir} + TemplatedRequests.Get_As_Json_Templated + ... ${BGP_VARIABLES_FOLDER}${/}${exprspdir} + ... session=${CONFIG_SESSION} + ... verify=True + +Normalize_And_Compare + [Documentation] Verify empty flowspec data + ${rsp} RequestsLibrary.GET On Session ${CONFIG_SESSION} url=${FLOWSPEC_URL} + TemplatedRequests.Normalize_Jsons_With_Bits_And_Compare + ... ${EXP0} + ... ${rsp.content} + ... keys_with_bits=${EMPTY_LIST} + +Verify_Empty_Flowspec_Data_Neon + [Documentation] Verify empty flowspec data on neon + TemplatedRequests.Get_As_Json_Templated + ... ${BGP_VARIABLES_FOLDER}${/}empty_route + ... session=${CONFIG_SESSION} + ... verify=True