Append more BGP multipath testcases for ODL
[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 ${DISPLAY_VPN4_ALL}    show-bgp --cmd "ip bgp ${VPNV4_ADDR_FAMILY} all"
37 ${DIPSLAY_FIB}    fib-show
38 ${ENABLE}         enable
39 ${DISABLE}        disable
40 ${MAXPATH_ERROR}    error: --maxpath range[1 - 64]
41 ${NUM_OF_DCGW}    3
42 ${NUM_OF_L3VPN}    3
43 ${START_VALUE}    0
44
45 *** Test Cases ***
46 Verify ODL supports REST API/CLI for multipath configuration (enable/disable multipath)
47     [Documentation]    Enable and disable multipath on ODL using karaf CLI and verifying it
48     Configure Multipath On ODL    ${ENABLE}
49     Verify Multipath    ${ENABLE}
50     Configure Multipath On ODL    ${DISABLE}
51     Verify Multipath    ${DISABLE}
52     Configure Multipath On ODL    ${ENABLE}
53     Verify Multipath    ${ENABLE}
54
55 Verify CSC supports REST API/CLI for max path configuration
56     [Documentation]    Verify CSC supports REST API/CLI for max path configuration
57     : FOR    ${idx}    IN RANGE    ${START_VALUE}    ${NUM_OF_DCGW}
58     \    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}]
59     VpnOperations.Verify L3VPN On ODL    @{VPN_ID}
60     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
61     \    BgpOperations.Create L3VPN on DCGW    ${dcgw}    ${AS_ID}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
62     \    BgpOperations.Verify L3VPN On DCGW    ${dcgw}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
63     : FOR    ${idx}    IN RANGE    ${START_VALUE}    ${NUM_OF_DCGW}
64     \    Configure Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[${idx}]
65     \    BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[${idx}]
66     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Check BGP VPNv4 Nbr On ODL    ${NUM_OF_DCGW}    False
67
68 Verify max-path error message with invalid inputs
69     [Documentation]    Verify max path error message while configuring maxpath with invalid range
70     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]
71     VpnOperations.Verify L3VPN On ODL    @{VPN_ID}[0]
72     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
73     \    BgpOperations.Create L3VPN on DCGW    ${dcgw}    ${AS_ID}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
74     \    BgpOperations.Verify L3VPN On DCGW    ${dcgw}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
75     : FOR    ${invalid}    IN    @{MAX_PATH_INVALID_LIST}
76     \    Configure Maxpath    ${invalid}    @{DCGW_RD_IRT_ERT}[0]
77     \    BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Maxpath    ${invalid}    @{DCGW_RD_IRT_ERT}[0]
78     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Check BGP VPNv4 Nbr On ODL    ${NUM_OF_DCGW}    False
79
80 Verify ODL supports dynamic configuration changes for max path value
81     [Documentation]    Verify ODL supports dynamic configuration changes for max path value
82     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]
83     VpnOperations.Verify L3VPN On ODL    @{VPN_ID}[0]
84     VpnOperations.Associate VPN to Router    routerid=@{router_id_list}[0]    vpnid=@{VPN_ID}[0]
85     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
86     \    BgpOperations.Create L3VPN on DCGW    ${dcgw}    ${AS_ID}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
87     \    BgpOperations.Verify L3VPN On DCGW    ${dcgw}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
88     Configure Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[0]
89     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[0]
90     : FOR    ${idx}    IN RANGE    ${START_VALUE}    ${NUM_OF_DCGW}
91     \    BgpOperations.Add Routes On DCGW    @{DCGW_IP_LIST}[${idx}]    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]    @{LABEL}[${idx}]
92     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Check BGP VPNv4 Nbr On ODL    ${NUM_OF_DCGW}
93     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify Routing Entry On ODL    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
94     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Verify FIB Entry On ODL    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
95     : FOR    ${index}    IN RANGE    0    3
96     \    Configure Maxpath    @{MAX_PATH_LIST}[${index}]    @{DCGW_RD_IRT_ERT}[0]
97     \    BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Maxpath    @{MAX_PATH_LIST}[${index}]    @{DCGW_RD_IRT_ERT}[0]
98     \    BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify Routing Entry On ODL    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]
99     \    ...    @{NUM_OF_ROUTES}[2]
100     \    BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify FIB Entry On ODL    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[${index}]
101
102 Verify that ECMP path gets withdrawn by QBGP after disabling multipath
103     [Documentation]    Verify that ECMP path gets withdrawn by QBGP after disabling multipath
104     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]
105     VpnOperations.Verify L3VPN On ODL    @{VPN_ID}[0]
106     VpnOperations.Associate VPN to Router    routerid=@{router_id_list}[0]    vpnid=@{VPN_ID}[0]
107     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
108     \    BgpOperations.Create L3VPN on DCGW    ${dcgw}    ${AS_ID}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
109     \    BgpOperations.Verify L3VPN On DCGW    ${dcgw}    @{VPN_NAME}[0]    @{DCGW_RD_IRT_ERT}[0]
110     Configure Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[0]
111     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[0]
112     : FOR    ${idx}    IN RANGE    ${START_VALUE}    ${NUM_OF_DCGW}
113     \    BgpOperations.Add Routes On DCGW    @{DCGW_IP_LIST}[${idx}]    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]    @{LABEL}[${idx}]
114     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Check BGP VPNv4 Nbr On ODL    ${NUM_OF_DCGW}
115     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify Routing Entry On ODL    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
116     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Verify FIB Entry On ODL    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
117     Configure Maxpath    @{MAX_PATH_LIST}[0]    @{DCGW_RD_IRT_ERT}[0]
118     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify Routing Entry On ODL    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
119     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Verify FIB Entry On ODL    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[0]
120     Configure Maxpath    @{MAX_PATH_LIST}[2]    @{DCGW_RD_IRT_ERT}[0]
121     BuiltIn.Wait Until Keyword Succeeds    60s    10s    Verify Routing Entry On ODL    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
122     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Verify FIB Entry On ODL    @{NETWORK_IP}[0]    @{NUM_OF_ROUTES}[2]
123
124 *** Keywords ***
125 Start Suite
126     [Documentation]    Setup start suite
127     VpnOperations.Basic Suite Setup
128     Create Setup
129
130 Stop Suite
131     [Documentation]    Deleting all BGP neighbors and configurations
132     BgpOperations.Delete BGP Configuration On ODL    session
133     OpenStackOperations.OpenStack Suite Teardown
134
135 Test Cleanup
136     [Documentation]    Posttest case cleanup
137     : FOR    ${l3vpn_rd}    IN    @{DCGW_RD_IRT_ERT}
138     \    Configure Maxpath    @{MAX_PATH_LIST}[0]    ${l3vpn_rd}
139     : FOR    ${vpn}    IN    @{VPN_ID}
140     \    BuiltIn.Run Keyword And Ignore Error    VpnOperations.VPN Delete L3VPN    vpnid=${vpn}
141     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
142     \    BuiltIn.Run Keyword And Ignore Error    BgpOperations.Delete L3VPN on DCGW    ${dcgw}    ${AS_ID}    ${VPN_NAME}
143
144 Create Setup
145     [Documentation]    Starting BGP process on each DCGW and ODL
146     ...    Verifying BGP neighbor session status
147     ...    Creating 3 networks, 3 subnets, one router
148     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
149     \    BgpOperations.Start Quagga Processes On DCGW    ${dcgw}
150     BgpOperations.Start Quagga Processes On ODL    ${ODL_SYSTEM_IP}
151     KarafKeywords.Issue Command On Karaf Console    ${BGP_CONNECT}
152     BgpOperations.Create BGP Configuration On ODL    localas=${AS_ID}    routerid=${ODL_SYSTEM_IP}
153     : FOR    ${dcgw}    IN    @{DCGW_IP_LIST}
154     \    BgpOperations.AddNeighbor To BGP Configuration On ODL    remoteas=${AS_ID}    neighborAddr=${dcgw}
155     \    ${output} =    BgpOperations.Get BGP Configuration On ODL    session
156     \    BuiltIn.Should Contain    ${output}    ${dcgw}
157     \    BgpOperations.Configure BGP And Add Neighbor On DCGW    ${dcgw}    ${AS_ID}    ${dcgw}    ${ODL_SYSTEM_IP}    @{VPN_NAME}[0]
158     \    ...    @{DCGW_RD_IRT_ERT}[0]    @{NETWORK_IP}[0]
159     \    BuiltIn.Wait Until Keyword Succeeds    120s    20s    BgpOperations.Verify BGP Neighbor Status On Quagga    ${dcgw}    ${ODL_SYSTEM_IP}
160     : FOR    ${network}    IN    @{NETWORKS}
161     \    OpenStackOperations.Create Network    ${network}
162     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Utils.Check For Elements At URI    ${NETWORK_URL}    ${NETWORKS}
163     : FOR    ${index}    IN RANGE    0    3
164     \    OpenStackOperations.Create SubNet    @{NETWORKS}[${index}]    @{SUBNETS}[${index}]    @{SUBNET_CIDR}[${index}]
165     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Utils.Check For Elements At URI    ${SUBNETWORK_URL}    ${SUBNETS}
166     ${router_id_list}    BuiltIn.Create List    @{EMPTY}
167     : FOR    ${router}    IN    @{ROUTERS}
168     \    OpenStackOperations.Create Router    ${router}
169     \    ${router_id} =    OpenStackOperations.Get Router Id    ${router}
170     \    Collections.Append To List    ${router_id_list}    ${router_id}
171     BuiltIn.Set Suite Variable    ${router_id_list}
172     : FOR    ${index}    IN RANGE    0    3
173     \    OpenStackOperations.Add Router Interface    @{ROUTERS}[${index}]    @{SUBNETS}[${index}]
174     \    ${output} =    OpenStackOperations.Show Router Interface    @{ROUTERS}[${index}]
175     \    ${subnet_id} =    OpenStackOperations.Get Subnet Id    @{SUBNETS}[${index}]
176     \    BuiltIn.Should Contain    ${output}    ${subnet_id}
177
178 Configure Multipath On ODL
179     [Arguments]    ${setting}
180     [Documentation]    Enabling or disabling multipath on ODL using karaf CLI
181     BuiltIn.Run Keyword If    '${setting}' == 'enable'    KarafKeywords.Issue Command On Karaf Console    odl:multipath -f ${VPNV4_ADDR_FAMILY} ${setting}
182     ...    ELSE    KarafKeywords.Issue Command On Karaf Console    odl:multipath -f ${VPNV4_ADDR_FAMILY} ${setting}
183
184 Verify Multipath
185     [Arguments]    ${setting}
186     [Documentation]    verify multipath on ODL
187     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${BGP_CACHE}
188     BuiltIn.Run Keyword If    '${setting}' == 'enable'    BuiltIn.Should Contain    ${output}    ${VPNV4_ADDR_FAMILY}
189     ...    ELSE    BuiltIn.Should Not Contain    ${output}    ${VPNV4_ADDR_FAMILY}
190
191 Configure Maxpath
192     [Arguments]    ${maxpath}    ${rd}
193     [Documentation]    Setting maxpath on ODL using karaf CLI
194     ${maxpath_command} =    BuiltIn.Set Variable    multipath -r ${rd} -f ${VPNV4_ADDR_FAMILY} -n ${maxpath} setmaxpath
195     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${maxpath_command}
196     BuiltIn.Run Keyword If    0 < ${maxpath} < 65    BuiltIn.Should Not Contain    ${output}    ${MAXPATH_ERROR}
197     ...    ELSE    BuiltIn.Should Contain    ${output}    ${MAXPATH_ERROR}
198
199 Verify Maxpath
200     [Arguments]    ${maxpath}    ${rd}
201     [Documentation]    Verify maxpath is set properly on ODL
202     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${BGP_CACHE}
203     BuiltIn.Run Keyword If    0 < ${maxpath} < 65    BuiltIn.Should Match Regexp    ${output}    ${rd}\\s*${maxpath}
204     ...    ELSE    BuiltIn.Should Not Match Regexp    ${output}    ${rd}\\s*${maxpath}
205
206 Check BGP VPNv4 Nbr On ODL
207     [Arguments]    ${dcgw_count}    ${flag}=True    ${start}=${START_VALUE}
208     [Documentation]    Check BGP VPNv4 neighbor all on ODL
209     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${DISPLAY_VPN4_ALL}
210     : FOR    ${index}    IN RANGE    ${start}    ${dcgw_count}
211     \    BuiltIn.Run Keyword If    ${flag}==True    BuiltIn.Should Contain    ${output}    ${DCGW_IP_LIST[${index}]}
212     \    ...    ELSE    BuiltIn.Should Not Contain    ${output}    ${DCGW_IP_LIST[${index}]}
213
214 Verify Routing Entry On ODL
215     [Arguments]    ${rd}    ${prefix}    ${no_of_times}
216     [Documentation]    Verify routing table for specific prefix
217     ${output} =    KarafKeywords.Issue Command On Karaf Console    show-bgp --cmd "ip bgp vrf ${rd}"
218     BuiltIn.Should Contain X Times    ${output}    ${prefix}    ${no_of_times}    msg="Routing table does not contain ${prefix} prefix ${no_of_times} times"
219
220 Verify FIB Entry On ODL
221     [Arguments]    ${prefix}    ${no_of_times}
222     [Documentation]    Checking FIB entries with valid counts
223     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${DIPSLAY_FIB}
224     BuiltIn.Should Contain X Times    ${output}    ${prefix}    ${no_of_times}    msg="FIB table does not contain ${prefix} prefix ${no_of_times} times"