Move Utils.Flexible_*_Login into SSHKeywords
[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 Suite Setup       Setup_Everything
14 Suite Teardown    BgpOperations.Teardown_Everything
15 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
16 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
17 Library           OperatingSystem
18 Library           RequestsLibrary
19 Library           DateTime
20 Variables         ${CURDIR}/../../../variables/Variables.py
21 Variables         ${CURDIR}/../../../variables/bgpuser/variables.py    ${TOOLS_SYSTEM_IP}    ${ODL_STREAM}
22 Resource          ${CURDIR}/../../../libraries/BGPcliKeywords.robot
23 Resource          ${CURDIR}/../../../libraries/BgpOperations.robot
24 Resource          ${CURDIR}/../../../libraries/BGPSpeaker.robot
25 Resource          ${CURDIR}/../../../libraries/FailFast.robot
26 Resource          ${CURDIR}/../../../libraries/KillPythonTool.robot
27 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
28 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
29 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
30 Resource          ${CURDIR}/../../../libraries/WaitForFailure.robot
31
32 *** Variables ***
33 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpuser/
34 ${COUNT}          1
35 ${HOLDTIME}       180
36 ${BGP_PEER_LOG_FILE}    bgp_peer.log
37 ${BGP_PEER_COMMAND}    python 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
38 ${BGP_PEER_OPTIONS}    &>${BGP_PEER_LOG_FILE}
39 ${DEFAULT_RIB_CHECK_PERIOD}    1s
40 ${DEFAULT_RIB_CHECK_TIMEOUT}    10s
41 ${BGP_PEER_LOG_LEVEL}    debug
42 ${ODL_LOG_LEVEL}    INFO
43 ${ODL_BGP_LOG_LEVEL}    DEFAULT
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
52 *** Test Cases ***
53 TC1_Configure_iBGP_Peer
54     [Documentation]    Configure BGP peer module with initiate-connection set to false.
55     [Tags]    critical
56     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
57     ...    INITIATE=false    BGP_RIB=${RIB_INSTANCE}    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
58     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
59
60 TC1_Check_Example_Bgp_Rib_Is_Empty
61     [Documentation]    Check RIB for none linkstate-routes
62     [Tags]    critical
63     SSHLibrary.Switch Connection    bgp_peer_console
64     BgpOperations.Check_Example_Bgp_Rib_Does_Not_Contain    ${JSONKEYSTR}
65
66 TC1_Connect_BGP_Peer
67     [Documentation]    Connect BGP peer with advertising the routes without mandatory params like LOC_PREF.
68     [Tags]    critical
69     SSHLibrary.Switch Connection    bgp_peer_console
70     BGPcliKeywords.Start_Console_Tool    ${BGP_PEER_COMMAND} ${SKIP_PARAMS}    ${BGP_PEER_OPTIONS}
71     BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
72
73 TC1_Check_Example_Bgp_Rib
74     [Documentation]    Check RIB for not containig linkstate-route(s), because update messages were not good.
75     [Tags]    critical
76     SSHLibrary.Switch Connection    bgp_peer_console
77     WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout    ${DEFAULT_RIB_CHECK_TIMEOUT}    ${DEFAULT_RIB_CHECK_PERIOD}    BgpOperations.Check_Example_Bgp_Rib_Does_Not_Contain    ${JSONKEYSTR}
78
79 TC1_Disconnect_BGP_Peer
80     [Documentation]    Stop BGP peer & store logs
81     [Tags]    critical
82     SSHLibrary.Switch Connection    bgp_peer_console
83     BGPcliKeywords.Stop_Console_Tool
84     BGPcliKeywords.Store_File_To_Workspace    ${BGP_PEER_LOG_FILE}    tc1_${BGP_PEER_LOG_FILE}
85
86 TC1_Deconfigure_iBGP_Peer
87     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
88     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
89     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
90
91 TC2_Configure_iBGP_Peer
92     [Documentation]    Configures BGP peer module with initiate-connection set to false.
93     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
94     ...    INITIATE=false    RIB_INSTANCE_NAME=${RIB_INSTANCE}    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
95     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
96
97 TC2_Check_Example_Bgp_Rib_Is_Empty
98     [Documentation]    Check RIB for none linkstate-routes
99     [Tags]    critical
100     SSHLibrary.Switch Connection    bgp_peer_console
101     BgpOperations.Check_Example_Bgp_Rib_Does_Not_Contain    ${JSONKEYSTR}
102
103 TC2_Connect_BGP_Peer
104     [Documentation]    Connect BGP peer
105     [Tags]    critical
106     SSHLibrary.Switch Connection    bgp_peer_console
107     BGPcliKeywords.Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
108     BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
109
110 TC2_Check_Example_Bgp_Rib
111     [Documentation]    Check RIB for linkstate-route(s)
112     [Tags]    critical
113     SSHLibrary.Switch Connection    bgp_peer_console
114     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_RIB_CHECK_TIMEOUT}    ${DEFAULT_RIB_CHECK_PERIOD}    BgpOperations.Check_Example_Bgp_Rib_Content    ${JSONKEYSTR}
115
116 TC2_Disconnect_BGP_Peer
117     [Documentation]    Stop BGP peer & store logs
118     [Tags]    critical
119     SSHLibrary.Switch Connection    bgp_peer_console
120     BGPcliKeywords.Stop_Console_Tool
121     BGPcliKeywords.Store_File_To_Workspace    ${BGP_PEER_LOG_FILE}    tc2_${BGP_PEER_LOG_FILE}
122
123 TC2_Deconfigure_iBGP_Peer
124     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
125     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
126     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
127
128 *** Keywords ***
129 Setup_Everything
130     [Documentation]    Initialize SetupUtils. SSH-login to mininet machine, create HTTP session,
131     ...    prepare directories for responses, put Python tool to mininet machine, setup imported resources.
132     SetupUtils.Setup_Utils_For_Setup_And_Teardown
133     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
134     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    alias=bgp_peer_console
135     SSHKeywords.Flexible_Mininet_Login
136     SSHKeywords.Require_Python
137     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
138     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
139     RequestsLibrary.Create_Session    operational    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${OPERATIONAL_API}    auth=${AUTH}
140     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
141     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${ODL_LOG_LEVEL}
142     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${ODL_BGP_LOG_LEVEL} org.opendaylight.bgpcep
143     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${ODL_BGP_LOG_LEVEL} org.opendaylight.protocol