Migrate Get Requests invocations(libraries)
[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
14 Library             RequestsLibrary
15 Library             SSHLibrary
16 Library             String
17 Library             ../../../libraries/BgpRpcClient.py    ${TOOLS_SYSTEM_IP}
18 Resource            ../../../libraries/BGPcliKeywords.robot
19 Resource            ../../../libraries/BgpOperations.robot
20 Resource            ../../../libraries/BGPSpeaker.robot
21 Resource            ../../../libraries/SetupUtils.robot
22 Resource            ../../../libraries/SSHKeywords.robot
23 Resource            ../../../libraries/TemplatedRequests.robot
24 Resource            ../../../variables/Variables.robot
25
26 Suite Setup         Start_Suite
27 Suite Teardown      Stop_Suite
28 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
29
30
31 *** Variables ***
32 ${HOLDTIME}                     180
33 ${CONFIG_SESSION}               config-session
34 ${RT_CONSTRAIN_DIR}             ${CURDIR}/../../../variables/bgpfunctional/rt_constrain
35 ${PLAY_SCRIPT}                  ${CURDIR}/../../../../tools/fastbgp/play.py
36 ${RIB_NAME}                     example-bgp-rib
37 &{RT_CONSTRAIN_APP_PEER}        IP=${ODL_SYSTEM_IP}    BGP_RIB=${RIB_NAME}
38 &{RT_CONSTRAIN_ODL_CONFIG}
39 ...                             IP=${TOOLS_SYSTEM_IP}
40 ...                             HOLDTIME=${HOLDTIME}
41 ...                             PEER_PORT=${BGP_TOOL_PORT}
42 ...                             INITIATE=false
43 ...                             BGP_RIB=${RIB_NAME}
44 ...                             PASSIVE_MODE=true
45
46
47 *** Test Cases ***
48 Configure_App_Peer
49     [Documentation]    Configures bgp application peer.
50     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
51     TemplatedRequests.Put_As_Xml_Templated
52     ...    ${RT_CONSTRAIN_DIR}/app_peer
53     ...    mapping=${RT_CONSTRAIN_APP_PEER}
54     ...    session=${CONFIG_SESSION}
55
56 Reconfigure_ODL_To_Accept_Connection
57     [Documentation]    Configures BGP peer module with initiate-connection set to false.
58     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
59     TemplatedRequests.Put_As_Xml_Templated
60     ...    ${RT_CONSTRAIN_DIR}/bgp_peer
61     ...    mapping=${RT_CONSTRAIN_ODL_CONFIG}
62     ...    session=${CONFIG_SESSION}
63
64 Start_Bgp_Peer
65     [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.
66     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
67     BuiltIn.Wait_Until_Keyword_Succeeds    3x    1s    Start_Bgp_Peer
68
69 Odl_To_Play_rt_constrain_default
70     [Template]    Odl_To_Play_Template
71     rt_constrain_default    ${RT_CONSTRAIN_DIR}
72
73 Play_To_Odl_rt_constrain_default
74     [Template]    Play_To_Odl_Template
75     rt_constrain_default    ${RT_CONSTRAIN_DIR}
76
77 Odl_To_Play_rt_constrain_type_0
78     [Template]    Odl_To_Play_Template
79     rt_constrain_type_0    ${RT_CONSTRAIN_DIR}
80
81 Play_To_Odl_rt_constrain_type_0
82     [Template]    Play_To_Odl_Template
83     rt_constrain_type_0    ${RT_CONSTRAIN_DIR}
84
85 Odl_To_Play_rt_constrain_type_1
86     [Template]    Odl_To_Play_Template
87     rt_constrain_type_1    ${RT_CONSTRAIN_DIR}
88
89 Play_To_Odl_rt_constrain_type_1
90     [Template]    Play_To_Odl_Template
91     rt_constrain_type_1    ${RT_CONSTRAIN_DIR}
92
93 Odl_To_Play_rt_constrain_type_2
94     [Template]    Odl_To_Play_Template
95     rt_constrain_type_2    ${RT_CONSTRAIN_DIR}
96
97 Play_To_Odl_rt_constrain_type_2
98     [Template]    Play_To_Odl_Template
99     rt_constrain_type_2    ${RT_CONSTRAIN_DIR}
100
101 Kill_Talking_BGP_Speaker
102     [Documentation]    Abort the Python speaker
103     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
104     BGPSpeaker.Kill_BGP_Speaker
105     BGPcliKeywords.Store_File_To_Workspace    play.py.out    rt_constrain_play.log
106
107 Delete_Bgp_Peer_Configuration
108     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
109     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
110     TemplatedRequests.Delete_Templated
111     ...    ${RT_CONSTRAIN_DIR}/bgp_peer
112     ...    mapping=${RT_CONSTRAIN_ODL_CONFIG}
113     ...    session=${CONFIG_SESSION}
114
115 Deconfigure_App_Peer
116     [Documentation]    Revert the BGP configuration to the original state: without application peer
117     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
118     TemplatedRequests.Delete_Templated
119     ...    ${RT_CONSTRAIN_DIR}/app_peer
120     ...    mapping=${RT_CONSTRAIN_APP_PEER}
121     ...    session=${CONFIG_SESSION}
122
123
124 *** Keywords ***
125 Start_Suite
126     [Documentation]    Initialize SetupUtils. Suite setup keyword.
127     SetupUtils.Setup_Utils_For_Setup_And_Teardown
128     ${mininet_conn_id} =    SSHLibrary.Open Connection
129     ...    ${TOOLS_SYSTEM_IP}
130     ...    prompt=${DEFAULT_LINUX_PROMPT}
131     ...    timeout=6s
132     Builtin.Set Suite Variable    ${mininet_conn_id}
133     SSHKeywords.Flexible Mininet Login    ${TOOLS_SYSTEM_USER}
134     RequestsLibrary.Create Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
135     SSHLibrary.Put File    ${PLAY_SCRIPT}    .
136     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
137
138 Stop_Suite
139     [Documentation]    Suite teardown keyword
140     SSHLibrary.Close_All_Connections
141     RequestsLibrary.Delete_All_Sessions
142
143 Start_Bgp_Peer
144     [Documentation]    Starts bgp peer and verifies that the peer runs.
145     BGPSpeaker.Start_BGP_Speaker
146     ...    --amount 0 --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --debug --rt_constrain --wfr 1
147     BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen