271dbd548ac21319691a9d6c22682645cc42a859
[integration/test.git] / csit / suites / netvirt / bgpmultipath / l3vpn_bgp_multipath.robot
1 *** Settings ***
2 Documentation     The objective of this testsuite is to test QBGP and ODL for multipath/ECMP support.
3 ...               QBGP should be capable to receive multiple ECMP paths from different DC-GWs and
4 ...               to export the ECMP paths to ODL instead of best path selection.
5 ...               ODL should be capable to receive ECMP paths and it should program the FIB with ECMP paths.
6 Suite Setup       Start Suite
7 Suite Teardown    Stop Suite
8 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
9 Test Teardown     Test Cleanup
10 Resource          ../../../libraries/BgpOperations.robot
11 Resource          ../../../libraries/KarafKeywords.robot
12 Resource          ../../../libraries/OpenStackOperations.robot
13 Resource          ../../../libraries/Utils.robot
14 Resource          ../../../libraries/VpnOperations.robot
15 Resource          ../../../variables/Variables.robot
16
17 *** Variables ***
18 @{DCGW_RD_IRT_ERT}    11:1    22:2    33:3
19 @{DCGW_IP_LIST}    ${TOOLS_SYSTEM_1_IP}    ${TOOLS_SYSTEM_2_IP}    ${TOOLS_SYSTEM_3_IP}
20 @{LABEL}          51    52    53
21 @{L3VPN_RD_IRT_ERT}    ["@{DCGW_RD_IRT_ERT}[0]"]    ["@{DCGW_RD_IRT_ERT}[1]"]    ["@{DCGW_RD_IRT_ERT}[2]"]
22 @{MAX_PATH_LIST}    1    2    3    8    64
23 @{MAX_PATH_INVALID_LIST}    -1    0    65
24 @{NETWORK_IP}     10.1.1.1    20.1.1.1    30.1.1.1
25 @{NUM_OF_ROUTES}    1    2    3    4    5    6
26 @{VPN_NAME}       multipath_vpn_1    multipath_vpn_2    multipath_vpn_3
27 @{VPN_ID}         12345678-1234-1234-1234-123456789301    12345678-1234-1234-1234-123456789302    12345678-1234-1234-1234-123456789303
28 @{NETWORKS}       multipath_net_1    multipath_net_2    multipath_net_3
29 @{SUBNETS}        multipath_subnet_1    multipath_subnet_2    multipath_subnet_3
30 @{SUBNET_CIDR}    22.1.1.0/24    33.1.1.0/24    44.1.1.0/24
31 @{ROUTERS}        multipath_router_1    multipath_router_2    multipath_router_3
32 ${AS_ID}          100
33 ${VPNV4_ADDR_FAMILY}    vpnv4
34 ${BGP_CACHE}      bgp-cache
35 ${BGP_CONNECT}    bgp-connect -h ${ODL_SYSTEM_IP} -p 7644 add
36 ${DIPSLAY_FIB}    fib-show
37 ${ENABLE}         enable
38 ${DISABLE}        disable
39 ${MAXPATH_ERROR}    error: --maxpath range[1 - 64]
40 ${NUM_OF_DCGW}    3
41 ${NUM_OF_L3VPN}    3
42 ${START_VALUE}    0
43
44 *** Test Cases ***
45 Verify ODL supports REST API/CLI for multipath configuration (enable/disable multipath)
46     [Documentation]    Enable and disable multipath on ODL using karaf CLI and verifying it
47     Configure Multipath On ODL    ${ENABLE}
48     Verify Multipath    ${ENABLE}
49     Configure Multipath On ODL    ${DISABLE}
50     Verify Multipath    ${DISABLE}
51     Configure Multipath On ODL    ${ENABLE}
52     Verify Multipath    ${ENABLE}
53
54 Verify CSC supports REST API/CLI for max path configuration
55     [Documentation]    Verify CSC supports REST API/CLI for max path configuration
56     : FOR    ${idx}    IN RANGE    ${START_VALUE}    ${NUM_OF_DCGW}
57     \    VpnOperations.VPN Create L3VPN    name=@{VPN_NAME}[${idx}]    vpnid=@{VPN_ID}[${idx}]    rd=@{L3VPN_RD_IRT_ERT}[${idx}]    exportrt=@{L3VPN_RD_IRT_ERT}[${idx}]    importrt=@{L3VPN_RD_IRT_ERT}[${idx}]
58     VpnOperations.Verify L3VPN On ODL    @{VPN_ID}
59     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
60     \    BgpOperations.Create L3VPN on DCGW    ${dcgw}    ${AS_ID}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
61     \    BgpOperations.Verify L3VPN On DCGW    ${dcgw}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
62     : FOR    ${idx}    IN RANGE    ${START_VALUE}    ${NUM_OF_DCGW}
63     \    Configure Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[${idx}]
64     \    BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[${idx}]
65     BuiltIn.Wait Until Keyword Succeeds    60s    10s    BgpOperations.Check BGP VPNv4 Nbr On ODL    ${NUM_OF_DCGW}    False
66
67 Verify max-path error message with invalid inputs
68     [Documentation]    Verify max path error message while configuring maxpath with invalid range
69     VpnOperations.VPN Create L3VPN    name=@{VPN_NAME}[0]    vpnid=@{VPN_ID}[0]    rd=@{L3VPN_RD_IRT_ERT}[0]    exportrt=@{L3VPN_RD_IRT_ERT}[0]    importrt=@{L3VPN_RD_IRT_ERT}[0]
70     VpnOperations.Verify L3VPN On ODL    @{VPN_ID}[0]
71     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
72     \    BgpOperations.Create L3VPN on DCGW    ${dcgw}    ${AS_ID}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
73     \    BgpOperations.Verify L3VPN On DCGW    ${dcgw}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
74     : FOR    ${invalid}    IN    @{MAX_PATH_INVALID_LIST}
75     \    Configure Maxpath    ${invalid}    @{DCGW_RD_IRT_ERT}[0]
76     \    BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Maxpath    ${invalid}    @{DCGW_RD_IRT_ERT}[0]
77     BuiltIn.Wait Until Keyword Succeeds    60s    10s    BgpOperations.Check BGP VPNv4 Nbr On ODL    ${NUM_OF_DCGW}    False
78
79 Verify ODL supports dynamic configuration changes for max path value
80     [Documentation]    Verify ODL supports dynamic configuration changes for max path value
81     VpnOperations.VPN Create L3VPN    name=@{VPN_NAME}[0]    vpnid=@{VPN_ID}[0]    rd=@{L3VPN_RD_IRT_ERT}[0]    exportrt=@{L3VPN_RD_IRT_ERT}[0]    importrt=@{L3VPN_RD_IRT_ERT}[0]
82     VpnOperations.Verify L3VPN On ODL    @{VPN_ID}[0]
83     VpnOperations.Associate VPN to Router    routerid=@{router_id_list}[0]    vpnid=@{VPN_ID}[0]
84     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
85     \    BgpOperations.Create L3VPN on DCGW    ${dcgw}    ${AS_ID}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
86     \    BgpOperations.Verify L3VPN On DCGW    ${dcgw}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
87     Configure Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[0]
88     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[0]
89     : FOR    ${idx}    IN RANGE    ${START_VALUE}    ${NUM_OF_DCGW}
90     \    BgpOperations.Add Routes On DCGW    @{DCGW_IP_LIST}[${idx}]    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]    @{LABEL}[${idx}]
91     BuiltIn.Wait Until Keyword Succeeds    60s    10s    BgpOperations.Check BGP VPNv4 Nbr On ODL    ${NUM_OF_DCGW}
92     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify Routing Entry On ODL    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
93     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Verify FIB Entry On ODL    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
94     : FOR    ${index}    IN RANGE    0    3
95     \    Configure Maxpath    @{MAX_PATH_LIST}[${index}]    @{DCGW_RD_IRT_ERT}[0]
96     \    BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Maxpath    @{MAX_PATH_LIST}[${index}]    @{DCGW_RD_IRT_ERT}[0]
97     \    BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify Routing Entry On ODL    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]
98     \    ...    @{NUM_OF_ROUTES}[2]
99     \    BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify FIB Entry On ODL    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[${index}]
100
101 Verify that ECMP path gets withdrawn by QBGP after disabling multipath
102     [Documentation]    Verify that ECMP path gets withdrawn by QBGP after disabling multipath
103     VpnOperations.VPN Create L3VPN    name=@{VPN_NAME}[0]    vpnid=@{VPN_ID}[0]    rd=@{L3VPN_RD_IRT_ERT}[0]    exportrt=@{L3VPN_RD_IRT_ERT}[0]    importrt=@{L3VPN_RD_IRT_ERT}[0]
104     VpnOperations.Verify L3VPN On ODL    @{VPN_ID}[0]
105     VpnOperations.Associate VPN to Router    routerid=@{router_id_list}[0]    vpnid=@{VPN_ID}[0]
106     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
107     \    BgpOperations.Create L3VPN on DCGW    ${dcgw}    ${AS_ID}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
108     \    BgpOperations.Verify L3VPN On DCGW    ${dcgw}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
109     Configure Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[0]
110     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[0]
111     : FOR    ${idx}    IN RANGE    ${START_VALUE}    ${NUM_OF_DCGW}
112     \    BgpOperations.Add Routes On DCGW    @{DCGW_IP_LIST}[${idx}]    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]    @{LABEL}[${idx}]
113     BuiltIn.Wait Until Keyword Succeeds    60s    10s    BgpOperations.Check BGP VPNv4 Nbr On ODL    ${NUM_OF_DCGW}
114     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify Routing Entry On ODL    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
115     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Verify FIB Entry On ODL    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
116     Configure Maxpath    @{MAX_PATH_LIST}[0]    @{DCGW_RD_IRT_ERT}[0]
117     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify Routing Entry On ODL    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
118     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Verify FIB Entry On ODL    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[0]
119     Configure Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[0]
120     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify Routing Entry On ODL    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
121     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Verify FIB Entry On ODL    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
122
123 *** Keywords ***
124 Start Suite
125     [Documentation]    Setup start suite
126     VpnOperations.Basic Suite Setup
127     Create Setup
128
129 Stop Suite
130     [Documentation]    Deleting all BGP neighbors and configurations
131     BgpOperations.Delete BGP Configuration On ODL    session
132     OpenStackOperations.OpenStack Suite Teardown
133
134 Test Cleanup
135     [Documentation]    Posttest case cleanup
136     : FOR    ${l3vpn_rd}    IN    @{DCGW_RD_IRT_ERT}
137     \    Configure Maxpath    @{MAX_PATH_LIST}[0]    ${l3vpn_rd}
138     : FOR    ${vpn}    IN    @{VPN_ID}
139     \    BuiltIn.Run Keyword And Ignore Error    VpnOperations.VPN Delete L3VPN    vpnid=${vpn}
140     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
141     \    BuiltIn.Run Keyword And Ignore Error    BgpOperations.Delete L3VPN on DCGW    ${dcgw}    ${AS_ID}    ${VPN_NAME}
142
143 Create Setup
144     [Documentation]    Starting BGP process on each DCGW and ODL
145     ...    Verifying BGP neighbor session status
146     ...    Creating 3 networks, 3 subnets, one router
147     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
148     \    BgpOperations.Start Quagga Processes On DCGW    ${dcgw}
149     BgpOperations.Start Quagga Processes On ODL    ${ODL_SYSTEM_IP}
150     KarafKeywords.Issue Command On Karaf Console    ${BGP_CONNECT}
151     BgpOperations.Create BGP Configuration On ODL    localas=${AS_ID}    routerid=${ODL_SYSTEM_IP}
152     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
153     \    BgpOperations.AddNeighbor To BGP Configuration On ODL    remoteas=${AS_ID}    neighborAddr=${dcgw}
154     \    ${output} =    BgpOperations.Get BGP Configuration On ODL    session
155     \    BuiltIn.Should Contain    ${output}    ${dcgw}
156     \    BgpOperations.Configure BGP And Add Neighbor On DCGW    ${dcgw}    ${AS_ID}    ${dcgw}    ${ODL_SYSTEM_IP}    @{VPN_NAME}[0]
157     \    ...    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]
158     \    BuiltIn.Wait Until Keyword Succeeds    120s    20s    BgpOperations.Verify BGP Neighbor Status On Quagga    ${dcgw}    ${ODL_SYSTEM_IP}
159     : FOR    ${network}    IN    @{NETWORKS}
160     \    OpenStackOperations.Create Network    ${network}
161     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Utils.Check For Elements At URI    ${NETWORK_URL}    ${NETWORKS}
162     : FOR    ${index}    IN RANGE    0    3
163     \    OpenStackOperations.Create SubNet    @{NETWORKS}[${index}]    @{SUBNETS}[${index}]    @{SUBNET_CIDR}[${index}]
164     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Utils.Check For Elements At URI    ${SUBNETWORK_URL}    ${SUBNETS}
165     ${router_id_list}    BuiltIn.Create List    @{EMPTY}
166     : FOR    ${router}    IN    @{ROUTERS}
167     \    OpenStackOperations.Create Router    ${router}
168     \    ${router_id} =    OpenStackOperations.Get Router Id    ${router}
169     \    Collections.Append To List    ${router_id_list}    ${router_id}
170     BuiltIn.Set Suite Variable    ${router_id_list}
171     : FOR    ${index}    IN RANGE    0    3
172     \    OpenStackOperations.Add Router Interface    @{ROUTERS}[${index}]    @{SUBNETS}[${index}]
173     \    ${output} =    OpenStackOperations.Show Router Interface    @{ROUTERS}[${index}]
174     \    ${subnet_id} =    OpenStackOperations.Get Subnet Id    @{SUBNETS}[${index}]
175     \    BuiltIn.Should Contain    ${output}    ${subnet_id}
176
177 Configure Multipath On ODL
178     [Arguments]    ${setting}
179     [Documentation]    Enabling or disabling multipath on ODL using karaf CLI
180     BuiltIn.Run Keyword If    '${setting}' == 'enable'    KarafKeywords.Issue Command On Karaf Console    odl:multipath -f ${VPNV4_ADDR_FAMILY} ${setting}
181     ...    ELSE    KarafKeywords.Issue Command On Karaf Console    odl:multipath -f ${VPNV4_ADDR_FAMILY} ${setting}
182
183 Verify Multipath
184     [Arguments]    ${setting}
185     [Documentation]    verify multipath on ODL
186     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${BGP_CACHE}
187     BuiltIn.Run Keyword If    '${setting}' == 'enable'    BuiltIn.Should Contain    ${output}    ${VPNV4_ADDR_FAMILY}
188     ...    ELSE    BuiltIn.Should Not Contain    ${output}    ${VPNV4_ADDR_FAMILY}
189
190 Configure Maxpath
191     [Arguments]    ${maxpath}    ${rd}
192     [Documentation]    Setting maxpath on ODL using karaf CLI
193     ${maxpath_command} =    BuiltIn.Set Variable    multipath -r ${rd} -f ${VPNV4_ADDR_FAMILY} -n ${maxpath} setmaxpath
194     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${maxpath_command}
195     BuiltIn.Run Keyword If    0 < ${maxpath} < 65    BuiltIn.Should Not Contain    ${output}    ${MAXPATH_ERROR}
196     ...    ELSE    BuiltIn.Should Contain    ${output}    ${MAXPATH_ERROR}
197
198 Verify Maxpath
199     [Arguments]    ${maxpath}    ${rd}
200     [Documentation]    Verify maxpath is set properly on ODL
201     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${BGP_CACHE}
202     BuiltIn.Run Keyword If    0 < ${maxpath} < 65    BuiltIn.Should Match Regexp    ${output}    ${rd}\\s*${maxpath}
203     ...    ELSE    BuiltIn.Should Not Match Regexp    ${output}    ${rd}\\s*${maxpath}
204
205 Verify Routing Entry On ODL
206     [Arguments]    ${rd}    ${prefix}    ${no_of_times}
207     [Documentation]    Verify routing table for specific prefix
208     ${output} =    KarafKeywords.Issue Command On Karaf Console    show-bgp --cmd "ip bgp vrf ${rd}"
209     BuiltIn.Should Contain X Times    ${output}    ${prefix}    ${no_of_times}    msg="Routing table does not contain ${prefix} prefix ${no_of_times} times"
210
211 Verify FIB Entry On ODL
212     [Arguments]    ${prefix}    ${no_of_times}
213     [Documentation]    Checking FIB entries with valid counts
214     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${DIPSLAY_FIB}
215     BuiltIn.Should Contain X Times    ${output}    ${prefix}    ${no_of_times}    msg="FIB table does not contain ${prefix} prefix ${no_of_times} times"