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