Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / bgpcep / bgpfunct / bgp_ipv6_basic.robot
1 *** Settings ***
2 Documentation     Functional test for ipv6 connection with bgp.
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 distribution,
8 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...
10 ...               This suite tests simple connection between one ibgp peer (exabgp) and Odl.
11 ...               Peer is configured with ipv6, and exabgp connectes to odl via ipv6.
12 ...               Exabgp sends one ipv6 unicast route, which presence is verified in
13 ...               example-ipv6-topology. Tests this connection multiple times, with
14 ...               different ipv6 accepted formats, e.g. (::1, 0:0:0:0:0:0:0:1, full text)
15 Suite Setup       Start_Suite
16 Suite Teardown    Stop_Suite
17 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
18 Library           RequestsLibrary
19 Library           SSHLibrary
20 Resource          ../../../variables/Variables.robot
21 Resource          ../../../libraries/BGPcliKeywords.robot
22 Resource          ../../../libraries/ExaBgpLib.robot
23 Resource          ../../../libraries/SetupUtils.robot
24 Resource          ../../../libraries/SSHKeywords.robot
25 Resource          ../../../libraries/TemplatedRequests.robot
26
27 *** Variables ***
28 ${BGP_VAR_FOLDER}    ${CURDIR}/../../../variables/bgpfunctional/ipv6
29 ${CONFIG_SESSION}    config-session
30 ${CONTROLLER_IPV6}    ::1
31 ${EXABGP_ID}      1.2.3.4
32 ${EXABGP_CFG}     exaipv6.cfg
33 ${EXABGP_LOG}     exaipv6.log
34 ${IPV6_IP}        2607:f0d0:1002:0011:0000:0000:0000:0002
35 ${IPV6_IP_2}      2607:f0d0:1002:11:0:0:0:2
36 ${IPV6_IP_3}      2607:f0d0:1002:11::2
37 ${IPV6_IP_GW}     2607:f0d0:1002:0011:0000:0000:0000:0001
38 ${HOLDTIME}       180
39 ${RIB_INSTANCE}    example-bgp-rib
40
41 *** Test Cases ***
42 Reconfigure_ODL_To_Accept_Connections
43     [Documentation]    Configure BGP peer modules with initiate-connection set to false with short ipv6 address.
44     &{mapping}    Create Dictionary    IP=${IPV6_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
45     ...    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
46     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VAR_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
47
48 Start_Exabgp
49     [Documentation]    Start exabgp with
50     [Tags]    critical
51     ${cmd}    BuiltIn.Set_Variable    ${EXABGP_CFG} > ${EXABGP_LOG}
52     ExaBgpLib.Start_ExaBgp_And_Verify_Connected    ${cmd}    ${CONFIG_SESSION}    ${EXABGP_ID}
53
54 Verify_Ipv6_Topology_Filled
55     [Documentation]    Verifies that example-ipv6-topology is filled after starting exabgp.
56     [Tags]    critical
57     Verify_Rib_Status_Filled
58
59 Delete_Bgp_Peer_Configuration
60     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
61     &{mapping}    Create Dictionary    IP=${IPV6_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
62     ...    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
63     TemplatedRequests.Delete_Templated    ${BGP_VAR_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
64
65 Verify_Ipv6_Topology_Empty
66     [Documentation]    Verifies that example-ipv6-topology is empty after deconfiguring peer for the first time.
67     [Tags]    critical
68     Verify_Rib_Status_Empty
69
70 Reconfigure_ODL_To_Accept_Connections_2
71     [Documentation]    Configure BGP peer modules with initiate-connection set to false with ipv6 address without "::" shortened version.
72     &{mapping}    Create Dictionary    IP=${IPV6_IP_2}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
73     ...    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
74     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VAR_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
75
76 Verify_Ipv6_Topology_Filled_2
77     [Documentation]    Verifies that example-ipv6-topology is filled after configuring the peer for the second time.
78     [Tags]    critical
79     Verify_Rib_Status_Filled
80
81 Delete_Bgp_Peer_Configuration_2
82     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
83     &{mapping}    Create Dictionary    IP=${IPV6_IP_2}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
84     ...    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
85     TemplatedRequests.Delete_Templated    ${BGP_VAR_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
86
87 Verify_Ipv6_Topology_Empty_2
88     [Documentation]    Verifies that example-ipv6-topology is empty after deconfiguring peer for the second time.
89     [Tags]    critical
90     Verify_Rib_Status_Empty
91
92 Reconfigure_ODL_To_Accept_Connections_3
93     [Documentation]    Configure BGP peer modules with initiate-connection set to false with full text ipv6 address.
94     &{mapping}    Create Dictionary    IP=${IPV6_IP_3}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
95     ...    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
96     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VAR_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
97
98 Verify_Ipv6_Topology_Filled_3
99     [Documentation]    Verifies that example-ipv6-topology is filled after configuring the peer for the third time.
100     [Tags]    critical
101     Verify_Rib_Status_Filled
102
103 Delete_Bgp_Peer_Configuration_3
104     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
105     &{mapping}    Create Dictionary    IP=${IPV6_IP_3}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
106     ...    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
107     TemplatedRequests.Delete_Templated    ${BGP_VAR_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
108
109 Verify_Ipv6_Topology_Empty_3
110     [Documentation]    Verifies that example-ipv6-topology is empty after final deconfiguration.
111     [Tags]    critical
112     Verify_Rib_Status_Empty
113
114 Stop_All_Exabgps
115     [Documentation]    Save exabgp logs as exaipv6.log, and stop exabgp with ctrl-c bash signal
116     BGPcliKeywords.Store_File_To_Workspace    ${EXABGP_LOG}    ${EXABGP_LOG}
117     ExaBgpLib.Stop_ExaBgp
118
119 *** Keywords ***
120 Start_Suite
121     [Documentation]    Suite setup keyword.
122     SetupUtils.Setup_Utils_For_Setup_And_Teardown
123     ${conn_id}=    SSHLibrary.Open Connection    ${ODL_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=10s
124     Builtin.Set_Suite_Variable    ${conn_id}
125     SSHKeywords.Flexible_Controller_Login
126     Configure_Ipv6_Network
127     SSHKeywords.Virtual_Env_Create
128     SSHKeywords.Virtual_Env_Install_Package    exabgp==4.0.5
129     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
130     Upload_Config_Files
131
132 Stop_Suite
133     [Documentation]    Suite teardown keyword
134     SSHKeywords.Virtual_Env_Delete
135     SSHLibrary.Close_All_Connections
136     RequestsLibrary.Delete_All_Sessions
137
138 Configure_Ipv6_Network
139     [Documentation]    Reconfigures basic network settings on controller
140     SSHLibrary.Execute_Command    sudo sh -c 'echo "NETWORKING_IPV6=yes" >> /etc/sysconfig/network'
141     SSHLibrary.Execute_Command    sudo sh -c 'echo "IPV6INIT=yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0'
142     SSHLibrary.Execute_Command    sudo sh -c 'echo "IPV6ADDR=${IPV6_IP}" >> /etc/sysconfig/network-scripts/ifcfg-eth0'
143     SSHLibrary.Execute_Command    sudo sh -c 'echo "IPV6_DEFAULTGW=${IPV6_IP_GW}" >> /etc/sysconfig/network-scripts/ifcfg-eth0'
144     SSHLibrary.Execute_Command    sudo /etc/init.d/network restart
145
146 Verify_Rib_Status_Empty
147     [Documentation]    Verifies that example-ipv6-topology is empty
148     BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    TemplatedRequests.Get_As_Json_Templated    ${BGP_VAR_FOLDER}/ipv6_topology_empty    session=${CONFIG_SESSION}    verify=True
149
150 Verify_Rib_Status_Filled
151     [Documentation]    Verifies that example-ipv6-topology is filled with ipv6 route
152     BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    TemplatedRequests.Get_As_Json_Templated    ${BGP_VAR_FOLDER}/ipv6_topology_filled    session=${CONFIG_SESSION}    verify=True
153
154 Upload_Config_Files
155     [Documentation]    Uploads exabgp config files
156     SSHLibrary.Put_File    ${BGP_VAR_FOLDER}/${EXABGP_CFG}    .
157     @{cfgfiles}=    SSHLibrary.List_Files_In_Directory    .    *.cfg
158     FOR    ${cfgfile}    IN    @{cfgfiles}
159         SSHLibrary.Execute_Command    sed -i -e 's/EXABGPIP/${IPV6_IP}/g' ${cfgfile}
160         SSHLibrary.Execute_Command    sed -i -e 's/ODLIP/${CONTROLLER_IPV6}/g' ${cfgfile}
161         SSHLibrary.Execute_Command    sed -i -e 's/ROUTERID/${EXABGP_ID}/g' ${cfgfile}
162         SSHLibrary.Execute_Command    sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
163         SSHLibrary.Execute_Command    sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
164         ${stdout}=    SSHLibrary.Execute_Command    cat ${cfgfile}
165         Log    ${stdout}
166     END