Fix robot syntax with robot.tidy tool
[integration/test.git] / csit / suites / bgpcep / bgpfunct / 080_bgp_functional_rt_constrain.robot
1 *** Settings ***
2 Documentation     Functional test for bgp - route-target-constrain safi
3 ...           
4 ...               Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
5 ...           
6 ...               This program and the accompanying materials are made available under the
7 ...               terms of the Eclipse Public License v1.0 which accompanies this distbmution,
8 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...           
10 ...               This suite tests advertising rt-constrain routes to odl. For advertising from peer,
11 ...               play.py is used, sending hex messages to odl.
12 ...               For advertising to app-peer, we are sending post requests with routes in xml.
13 Suite Setup       Start_Suite
14 Suite Teardown    Stop_Suite
15 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
16 Library           RequestsLibrary
17 Library           SSHLibrary
18 Library           String
19 Library           ../../../libraries/BgpRpcClient.py    ${TOOLS_SYSTEM_IP}
20 Resource          ../../../libraries/BGPcliKeywords.robot
21 Resource          ../../../libraries/BgpOperations.robot
22 Resource          ../../../libraries/BGPSpeaker.robot
23 Resource          ../../../libraries/SetupUtils.robot
24 Resource          ../../../libraries/SSHKeywords.robot
25 Resource          ../../../libraries/TemplatedRequests.robot
26 Resource          ../../../variables/Variables.robot
27
28 *** Variables ***
29 ${HOLDTIME}       180
30 ${CONFIG_SESSION}    config-session
31 ${RT_CONSTRAIN_DIR}    ${CURDIR}/../../../variables/bgpfunctional/rt_constrain
32 ${PLAY_SCRIPT}    ${CURDIR}/../../../../tools/fastbgp/play.py
33 ${RIB_NAME}       example-bgp-rib
34 &{RT_CONSTRAIN_APP_PEER}    IP=${ODL_SYSTEM_IP}    BGP_RIB=${RIB_NAME}
35 &{RT_CONSTRAIN_ODL_CONFIG}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_NAME}    PASSIVE_MODE=true
36
37 *** Test Cases ***
38 Configure_App_Peer
39     [Documentation]    Configures bgp application peer.
40     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
41     TemplatedRequests.Put_As_Xml_Templated    ${RT_CONSTRAIN_DIR}/app_peer    mapping=${RT_CONSTRAIN_APP_PEER}    session=${CONFIG_SESSION}
42
43 Reconfigure_ODL_To_Accept_Connection
44     [Documentation]    Configures BGP peer module with initiate-connection set to false.
45     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
46     TemplatedRequests.Put_As_Xml_Templated    ${RT_CONSTRAIN_DIR}/bgp_peer    mapping=${RT_CONSTRAIN_ODL_CONFIG}    session=${CONFIG_SESSION}
47
48 Start_Bgp_Peer
49     [Documentation]    Start Python speaker to connect to ODL. We need to do WUKS until odl really starts to accept incomming bgp connection. The failure happens if the incomming connection comes too quickly after configuring the peer in the previous test case.
50     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
51     BuiltIn.Wait_Until_Keyword_Succeeds    3x    1s    Start_Bgp_Peer
52
53 Odl_To_Play_rt_constrain_default
54     [Template]    Odl_To_Play_Template
55     rt_constrain_default    ${RT_CONSTRAIN_DIR}
56
57 Play_To_Odl_rt_constrain_default
58     [Template]    Play_To_Odl_Template
59     rt_constrain_default    ${RT_CONSTRAIN_DIR}
60
61 Odl_To_Play_rt_constrain_type_0
62     [Template]    Odl_To_Play_Template
63     rt_constrain_type_0    ${RT_CONSTRAIN_DIR}
64
65 Play_To_Odl_rt_constrain_type_0
66     [Template]    Play_To_Odl_Template
67     rt_constrain_type_0    ${RT_CONSTRAIN_DIR}
68
69 Odl_To_Play_rt_constrain_type_1
70     [Template]    Odl_To_Play_Template
71     rt_constrain_type_1    ${RT_CONSTRAIN_DIR}
72
73 Play_To_Odl_rt_constrain_type_1
74     [Template]    Play_To_Odl_Template
75     rt_constrain_type_1    ${RT_CONSTRAIN_DIR}
76
77 Odl_To_Play_rt_constrain_type_2
78     [Template]    Odl_To_Play_Template
79     rt_constrain_type_2    ${RT_CONSTRAIN_DIR}
80
81 Play_To_Odl_rt_constrain_type_2
82     [Template]    Play_To_Odl_Template
83     rt_constrain_type_2    ${RT_CONSTRAIN_DIR}
84
85 Kill_Talking_BGP_Speaker
86     [Documentation]    Abort the Python speaker
87     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
88     BGPSpeaker.Kill_BGP_Speaker
89     BGPcliKeywords.Store_File_To_Workspace    play.py.out    rt_constrain_play.log
90
91 Delete_Bgp_Peer_Configuration
92     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
93     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
94     TemplatedRequests.Delete_Templated    ${RT_CONSTRAIN_DIR}/bgp_peer    mapping=${RT_CONSTRAIN_ODL_CONFIG}    session=${CONFIG_SESSION}
95
96 Deconfigure_App_Peer
97     [Documentation]    Revert the BGP configuration to the original state: without application peer
98     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
99     TemplatedRequests.Delete_Templated    ${RT_CONSTRAIN_DIR}/app_peer    mapping=${RT_CONSTRAIN_APP_PEER}    session=${CONFIG_SESSION}
100
101 *** Keywords ***
102 Start_Suite
103     [Documentation]    Initialize SetupUtils. Suite setup keyword.
104     SetupUtils.Setup_Utils_For_Setup_And_Teardown
105     ${mininet_conn_id} =    SSHLibrary.Open Connection    ${TOOLS_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=6s
106     Builtin.Set Suite Variable    ${mininet_conn_id}
107     SSHKeywords.Flexible Mininet Login    ${TOOLS_SYSTEM_USER}
108     RequestsLibrary.Create Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
109     SSHLibrary.Put File    ${PLAY_SCRIPT}    .
110     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
111
112 Stop_Suite
113     [Documentation]    Suite teardown keyword
114     SSHLibrary.Close_All_Connections
115     RequestsLibrary.Delete_All_Sessions
116
117 Start_Bgp_Peer
118     [Documentation]    Starts bgp peer and verifies that the peer runs.
119     BGPSpeaker.Start_BGP_Speaker    --amount 0 --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --debug --rt_constrain --wfr 1
120     BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen