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