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