Update Robot Framework format - step 3
[integration/test.git] / csit / suites / bgpcep / bgpuser / ibgp_peer_lsp.robot
1 *** Settings ***
2 Documentation       Basic tests for iBGP peers.
3 ...
4 ...                 Copyright (c) 2015-2016 Cisco Systems, Inc. and others. 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 distribution,
8 ...                 and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...
10 ...                 Test suite performs basic iBGP functional test case for
11 ...                 carrying LSP State Information in BGP as described in
12 ...                 http://tools.ietf.org/html/draft-ietf-idr-te-lsp-distribution-03
13
14 Library             OperatingSystem
15 Library             RequestsLibrary
16 Library             DateTime
17 Resource            ../../../libraries/BGPcliKeywords.robot
18 Resource            ../../../libraries/BgpOperations.robot
19 Resource            ../../../libraries/CompareStream.robot
20 Resource            ../../../libraries/KarafKeywords.robot
21 Resource            ../../../libraries/SetupUtils.robot
22 Resource            ../../../libraries/SSHKeywords.robot
23 Resource            ../../../libraries/TemplatedRequests.robot
24 Resource            ../../../libraries/WaitForFailure.robot
25 Resource            ../../../variables/Variables.robot
26
27 Suite Setup         Setup_Everything
28 Suite Teardown      BgpOperations.Teardown_Everything
29 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
30 Test Teardown       SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
31
32
33 *** Variables ***
34 ${BGP_VARIABLES_FOLDER}         ${CURDIR}/../../../variables/bgpuser/
35 ${COUNT}                        1
36 ${HOLDTIME}                     180
37 ${BGP_PEER_LOG_FILE}            bgp_peer.log
38 ${BGP_PEER_COMMAND}
39 ...                             python3 play.py --amount ${COUNT} --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --${BGP_PEER_LOG_LEVEL} --logfile ${BGP_PEER_LOG_FILE} --bgpls True
40 ${BGP_PEER_OPTIONS}             &>${BGP_PEER_LOG_FILE}
41 ${DEFAULT_RIB_CHECK_PERIOD}     1s
42 ${DEFAULT_RIB_CHECK_TIMEOUT}    10s
43 ${BGP_PEER_LOG_LEVEL}           debug
44 ${JSONKEYSTR}                   "linkstate-route"
45 ${BGP_PEER_NAME}                example-bgp-peer
46 ${DEVICE_NAME}                  controller-config
47 ${CONFIG_SESSION}               config-session
48 ${SKIP_PARAMS}                  --skipattr
49 ${RIB_INSTANCE}                 example-bgp-rib
50 ${PROTOCOL_OPENCONFIG}          ${RIB_INSTANCE}
51 ${OLD_ROUTE_KEY}                [0, 5, 0, 21, 7, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 0, 1, 0, 1, 5, 6, 7, 8]
52 ${NEW_ROUTE_KEY}                AAUAFQcAAAAAAAAAAQECAwQAAQABBQYHCA==
53
54
55 *** Test Cases ***
56 TC1_Configure_iBGP_Peer
57     [Documentation]    Configure BGP peer module with initiate-connection set to false.
58     [Tags]    critical
59     &{mapping}    Create Dictionary
60     ...    DEVICE_NAME=${DEVICE_NAME}
61     ...    BGP_NAME=${BGP_PEER_NAME}
62     ...    IP=${TOOLS_SYSTEM_IP}
63     ...    HOLDTIME=${HOLDTIME}
64     ...    PEER_PORT=${BGP_TOOL_PORT}
65     ...    INITIATE=false
66     ...    BGP_RIB=${RIB_INSTANCE}
67     ...    PASSIVE_MODE=true
68     ...    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
69     ...    RIB_INSTANCE_NAME=${RIB_INSTANCE}
70     TemplatedRequests.Put_As_Xml_Templated
71     ...    ${BGP_VARIABLES_FOLDER}${/}bgp_peer
72     ...    mapping=${mapping}
73     ...    session=${CONFIG_SESSION}
74
75 TC1_Check_Example_Bgp_Rib_Is_Empty
76     [Documentation]    Check RIB for none linkstate-routes
77     [Tags]    critical
78     BgpOperations.Check_Example_Bgp_Rib_Does_Not_Contain    ${CONFIG_SESSION}    ${JSONKEYSTR}
79
80 TC1_Connect_BGP_Peer
81     [Documentation]    Connect BGP peer with advertising the routes without mandatory params like LOC_PREF.
82     [Tags]    critical
83     BuiltIn.Run_Keyword_And_Ignore_Error
84     ...    KarafKeywords.Log_Message_To_Controller_Karaf
85     ...    Error = WELL_KNOWN_ATTR_MISSING is EXPECTED in this test case, and should be thrown when missing mandatory attributes.
86     BGPcliKeywords.Start_Console_Tool    ${BGP_PEER_COMMAND} ${SKIP_PARAMS}    ${BGP_PEER_OPTIONS}
87     BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
88
89 TC1_Check_Example_Bgp_Rib
90     [Documentation]    Check RIB for not containig linkstate-route(s), because update messages were not good.
91     [Tags]    critical
92     WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout
93     ...    ${DEFAULT_RIB_CHECK_TIMEOUT}
94     ...    ${DEFAULT_RIB_CHECK_PERIOD}
95     ...    BgpOperations.Check_Example_Bgp_Rib_Does_Not_Contain
96     ...    ${CONFIG_SESSION}
97     ...    ${JSONKEYSTR}
98
99 TC1_Disconnect_BGP_Peer
100     [Documentation]    Stop BGP peer & store logs
101     [Tags]    critical
102     BGPcliKeywords.Stop_Console_Tool
103     BGPcliKeywords.Store_File_To_Workspace    ${BGP_PEER_LOG_FILE}    tc1_${BGP_PEER_LOG_FILE}
104
105 TC1_Deconfigure_iBGP_Peer
106     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
107     &{mapping}    BuiltIn.Create_Dictionary
108     ...    DEVICE_NAME=${DEVICE_NAME}
109     ...    BGP_NAME=${BGP_PEER_NAME}
110     ...    IP=${TOOLS_SYSTEM_IP}
111     ...    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
112     TemplatedRequests.Delete_Templated
113     ...    ${BGP_VARIABLES_FOLDER}/bgp_peer
114     ...    mapping=${mapping}
115     ...    session=${CONFIG_SESSION}
116
117 TC2_Configure_iBGP_Peer
118     [Documentation]    Configures BGP peer module with initiate-connection set to false.
119     &{mapping}    BuiltIn.Create_Dictionary
120     ...    DEVICE_NAME=${DEVICE_NAME}
121     ...    BGP_NAME=${BGP_PEER_NAME}
122     ...    IP=${TOOLS_SYSTEM_IP}
123     ...    HOLDTIME=${HOLDTIME}
124     ...    PEER_PORT=${BGP_TOOL_PORT}
125     ...    INITIATE=false
126     ...    RIB_INSTANCE_NAME=${RIB_INSTANCE}
127     ...    PASSIVE_MODE=true
128     ...    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
129     TemplatedRequests.Put_As_Xml_Templated
130     ...    ${BGP_VARIABLES_FOLDER}/bgp_peer
131     ...    mapping=${mapping}
132     ...    session=${CONFIG_SESSION}
133
134 TC2_Check_Example_Bgp_Rib_Is_Empty
135     [Documentation]    Check RIB for none linkstate-routes
136     [Tags]    critical
137     BgpOperations.Check_Example_Bgp_Rib_Does_Not_Contain    ${CONFIG_SESSION}    ${JSONKEYSTR}
138
139 TC2_Connect_BGP_Peer
140     [Documentation]    Connect BGP peer
141     [Tags]    critical
142     BGPcliKeywords.Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
143     BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
144
145 TC2_Check_Example_Bgp_Rib
146     [Documentation]    Check RIB for linkstate-route(s) and check all of their attributes.
147     [Tags]    critical
148     ${route_key}    CompareStream.Set_Variable_If_At_Least_Fluorine    ${NEW_ROUTE_KEY}    ${OLD_ROUTE_KEY}
149     &{mapping}    BuiltIn.Create_Dictionary    IP=${TOOLS_SYSTEM_IP}    ROUTE_KEY=${route_key}
150     BuiltIn.Wait_Until_Keyword_Succeeds
151     ...    ${DEFAULT_RIB_CHECK_TIMEOUT}
152     ...    ${DEFAULT_RIB_CHECK_PERIOD}
153     ...    TemplatedRequests.Get_As_Json_Templated
154     ...    ${BGP_VARIABLES_FOLDER}/lsp/effective_rib_in
155     ...    mapping=${mapping}
156     ...    session=${CONFIG_SESSION}
157     ...    verify=True
158
159 TC2_Disconnect_BGP_Peer
160     [Documentation]    Stop BGP peer & store logs
161     [Tags]    critical
162     BGPcliKeywords.Stop_Console_Tool
163     BGPcliKeywords.Store_File_To_Workspace    ${BGP_PEER_LOG_FILE}    tc2_${BGP_PEER_LOG_FILE}
164
165 TC2_Deconfigure_iBGP_Peer
166     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
167     &{mapping}    BuiltIn.Create_Dictionary
168     ...    DEVICE_NAME=${DEVICE_NAME}
169     ...    BGP_NAME=${BGP_PEER_NAME}
170     ...    IP=${TOOLS_SYSTEM_IP}
171     ...    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
172     TemplatedRequests.Delete_Templated
173     ...    ${BGP_VARIABLES_FOLDER}/bgp_peer
174     ...    mapping=${mapping}
175     ...    session=${CONFIG_SESSION}
176
177
178 *** Keywords ***
179 Setup_Everything
180     [Documentation]    Initialize SetupUtils. SSH-login to mininet machine, create HTTP session,
181     ...    prepare directories for responses, put Python tool to mininet machine, setup imported resources.
182     SetupUtils.Setup_Utils_For_Setup_And_Teardown
183     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
184     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}
185     SSHKeywords.Flexible_Mininet_Login
186     SSHKeywords.Require_Python
187     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
188     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
189     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
190     KarafKeywords.Setup_Karaf_Keywords