Add Subnet And Multicast Suite.
[integration/test.git] / csit / suites / netvirt / subnet_routing / subnet_routing_and_multicast.robot
1 *** Settings ***
2 Documentation     Test suite to validate subnet routing and multicast functionality in an openstack integrated environment.
3 ...               The assumption of this suite is that the environment is already configured with the proper
4 ...               integration bridges and vxlan tunnels.
5 Suite Setup       Start Suite
6 Suite Teardown    Stop Suite
7 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
8 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
9 Resource          ../../../libraries/BgpOperations.robot
10 Resource          ../../../libraries/KarafKeywords.robot
11 Resource          ../../../libraries/OpenStackOperations.robot
12 Resource          ../../../libraries/Utils.robot
13 Resource          ../../../libraries/SetupUtils.robot
14 Resource          ../../../variables/Variables.robot
15 Resource          ../../../variables/netvirt/Variables.robot
16 Resource          ../../../libraries/VpnOperations.robot
17
18 *** Variables ***
19 ${AS_ID}          100
20 ${SECURITY_GROUP}    mc_sg
21 ${NUM_OF_PORTS_PER_NETWORK}    4
22 ${NUM_OF_INSTANCES}    20
23 ${VPN_INSTANCE_ID}    4ae8cd92-48ca-49b5-94e1-b2921a261111
24 ${VPN_NAME}       mc_vpn1
25 ${LOOPBACK_IP}    5.5.5.2
26 ${L3VPN_RD}       2200:2
27 ${DCGW_SYSTEM_IP}    ${TOOLS_SYSTEM_1_IP}
28 ${RPING_MIP_IP}    sudo arping -I eth0:1 -c 5 -b -s @{EXTRA_NW_SUBNET}[0] @{EXTRA_NW_SUBNET}[0]
29 ${RPING_MIP_IP1}    sudo arping -I eth0:1 -c 5 -b -s @{EXTRA_NW_SUBNET}[1] @{EXTRA_NW_SUBNET}[1]
30 ${RPING_MIP_IP2}    sudo arping -I eth0:1 -c 5 -b -s @{EXTRA_NW_SUBNET}[2] @{EXTRA_NW_SUBNET}[2]
31 ${BGP_CONFIG_SERVER_CMD}    bgp-connect -h ${ODL_SYSTEM_IP} -p 7644 add
32 @{INTERFACE_STATE}    up    down
33 @{NETWORKS}       mc_net_1    mc_net_2    mc_net_3
34 @{NET_1_VMS}      mc_net_1_vm_1    mc_net_1_vm_2    mc_net_1_vm_3    mc_net_1_vm_4
35 @{NET_2_VMS}      mc_net_2_vm_1    mc_net_2_vm_2    mc_net_2_vm_3    mc_net_2_vm_4
36 @{NET_3_VMS}      mc_net_3_vm_1    mc_net_3_vm_2    mc_net_3_vm_3    mc_net_3_vm_4
37 @{NET_1_PORTS}    mc_net_1_port_1    mc_net_1_port_2    mc_net_1_port_3    mc_net_1_port_4
38 @{NET_2_PORTS}    mc_net_2_port_1    mc_net_2_port_2    mc_net_2_port_3    mc_net_2_port_4
39 @{NET_3_PORTS}    mc_net_3_port_1    mc_net_3_port_2    mc_net_3_port_3    mc_net_3_port_4
40 @{SUBNETS}        mc_sub_1    mc_sub_2    mc_sub_3
41 @{SUBNET_CIDR}    10.1.0.0/24    10.2.0.0/24    10.3.0.0/24
42 @{EXTRA_NW_SUBNET}    10.1.0.100    10.2.0.100    10.3.0.100
43 ${MASK}           255.255.255.0
44
45 *** Test Cases ***
46 Verify The Subnet Route When Neutron Port Hosting Subnet Route Is Down/up On Single VSwitch Topology
47     [Documentation]    Verify the subnet route when enterprise host is down and up.
48     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Configure_IP_On_Sub_Interface    @{NETWORKS}[0]    @{EXTRA_NW_SUBNET}[0]    @{NET_1_VM_IPS}[0]
49     ...    ${MASK}    @{INTERFACE_STATE}[1]
50     ${allowed_ip_list} =    BuiltIn.Create List    @{EXTRA_NW_SUBNET}[0]
51     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Utils.Check For Elements At URI    ${FIB_ENTRY_URL}    ${allowed_ip_list}
52     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Configure_IP_On_Sub_Interface    @{NETWORKS}[0]    @{EXTRA_NW_SUBNET}[0]    @{NET_1_VM_IPS}[0]
53     ...    ${MASK}    @{INTERFACE_STATE}[0]
54     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Verify_IP_Configured_On_Sub_Interface    @{NETWORKS}[0]    @{EXTRA_NW_SUBNET}[0]    @{NET_1_VM_IPS}[0]
55     BuiltIn.Wait Until Keyword Succeeds    30s    10s    Utils.Check For Elements At URI    ${FIB_ENTRY_URL}    ${allowed_ip_list}
56     Verify Ping between Inter Intra And Enterprise host
57
58 Verify Enterprise Hosts Reachability After VM Reboot
59     [Documentation]    Restart the VSwitch1 which is hosting the enterprise host and check the subnet route
60     OpenStackOperations.Get ControlNode Connection
61     @{NET_1_VM_IPS}    ${NET1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
62     OpenStackOperations.Reboot Nova VM    @{NET_1_VMS}[0]
63     @{NET_1_VM_IPS}    ${NET1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
64     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Configure_IP_On_Sub_Interface    @{NETWORKS}[0]    @{EXTRA_NW_SUBNET}[0]    @{NET_1_VM_IPS}[0]
65     ...    ${MASK}    @{INTERFACE_STATE}[0]
66     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Verify_IP_Configured_On_Sub_Interface    @{NETWORKS}[0]    @{EXTRA_NW_SUBNET}[0]    @{NET_1_VM_IPS}[0]
67     Verify Ping between Inter Intra And Enterprise host
68
69 Verify The Subnet Route For Multiple Subnets On Multi VSwitch Topology When DC-GW Is Restarted
70     [Documentation]    Restart dcgw and check enterprise hosts reachability
71     BgpOperations.Restart BGP Processes On DCGW    ${DCGW_SYSTEM_IP}
72     Create BGP Config On DCGW
73     Verify Ping between Inter Intra And Enterprise host
74
75 Verify The Subnet Route For Multiple Subnets On Multi VSwitch Topology When Qbgp Is Restarted
76     [Documentation]    Restart qbgp and check enterprise hosts reachability
77     BgpOperations.Restart BGP Processes On ODL    ${ODL_SYSTEM_IP}
78     Verify Ping between Inter Intra And Enterprise host
79
80 *** Keywords ***
81 Start Suite
82     [Documentation]    Test Suite for Subnet_Routing_and_Multicast_Deployments.
83     VpnOperations.Basic Suite Setup
84     BgpOperations.Start Quagga Processes On ODL    ${ODL_SYSTEM_IP}
85     BgpOperations.Start Quagga Processes On DCGW    ${DCGW_SYSTEM_IP}
86     Create Setup
87
88 Stop Suite
89     [Documentation]    Test Teardown for Subnet_Routing_and_Multicast_Deployments.
90     BgpOperations.Delete BGP Configuration On ODL    session
91     BgpOperations.Delete BGP Config On Quagga    ${DCGW_SYSTEM_IP}    ${AS_ID}
92     BgpOperations.Stop BGP Processes On Node    ${ODL_SYSTEM_IP}
93     BgpOperations.Stop BGP Processes On Node    ${DCGW_SYSTEM_IP}
94     OpenStackOperations.OpenStack Suite Teardown
95
96 Create Neutron Networks
97     [Documentation]    Create required number of networks
98     : FOR    ${net}    IN    @{NETWORKS}
99     \    OpenStackOperations.Create Network    ${net}
100     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${NETWORK_URL}    ${NETWORKS}
101
102 Create Neutron Subnets
103     [Arguments]    ${num_of_network}    ${additional_args}=${EMPTY}    ${verbose}=TRUE
104     [Documentation]    Create required number of subnets for previously created networks
105     : FOR    ${index}    IN RANGE    0    ${num_of_network}
106     \    OpenStackOperations.Create SubNet    @{NETWORKS}[${index}]    @{SUBNETS}[${index}]    @{SUBNET_CIDR}[${index}]
107     BuiltIn.Wait Until Keyword Succeeds    3s    1s    Utils.Check For Elements At URI    ${SUBNETWORK_URL}    ${SUBNETS}
108
109 Create Neutron Ports
110     [Documentation]    Create required number of ports under previously created subnets
111     ${allowed_address_pairs_args1} =    BuiltIn.Set Variable    --allowed-address ip-address=@{EXTRA_NW_SUBNET}[0] --allowed-address ip-address=@{EXTRA_NW_SUBNET}[1]
112     ${allowed_address_pairs_args2} =    BuiltIn.Set Variable    --allowed-address ip-address=@{EXTRA_NW_SUBNET}[1] --allowed-address ip-address=@{EXTRA_NW_SUBNET}[2]
113     ${allowed_address_pairs_args3} =    BuiltIn.Set Variable    --allowed-address ip-address=@{EXTRA_NW_SUBNET}[2] --allowed-address ip-address=@{EXTRA_NW_SUBNET}[0]
114     : FOR    ${index}    IN RANGE    0    ${NUM_OF_PORTS_PER_NETWORK}
115     \    OpenStackOperations.Create Port    @{NETWORKS}[0]    @{NET_1_PORTS}[${index}]    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args1}
116     : FOR    ${index}    IN RANGE    0    ${NUM_OF_PORTS_PER_NETWORK}
117     \    OpenStackOperations.Create Port    @{NETWORKS}[1]    @{NET_2_PORTS}[${index}]    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args2}
118     : FOR    ${index}    IN RANGE    0    ${NUM_OF_PORTS_PER_NETWORK}
119     \    OpenStackOperations.Create Port    @{NETWORKS}[2]    @{NET_3_PORTS}[${index}]    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args3}
120
121 Create Nova VMs
122     [Documentation]    Create Vm instances on compute nodes
123     : FOR    ${index}    IN RANGE    0    2
124     \    OpenStackOperations.Create Vm Instance With Port On Compute Node    @{NET_1_PORTS}[${index}]    @{NET_1_VMS}[${index}]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
125     \    OpenStackOperations.Create Vm Instance With Port On Compute Node    @{NET_1_PORTS}[${index+2}]    @{NET_1_VMS}[${index+2}]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
126     \    OpenStackOperations.Create Vm Instance With Port On Compute Node    @{NET_2_PORTS}[${index}]    @{NET_2_VMS}[${index}]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
127     \    OpenStackOperations.Create Vm Instance With Port On Compute Node    @{NET_2_PORTS}[${index+2}]    @{NET_2_VMS}[${index+2}]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
128     \    OpenStackOperations.Create Vm Instance With Port On Compute Node    @{NET_3_PORTS}[${index}]    @{NET_3_VMS}[${index}]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
129     \    OpenStackOperations.Create Vm Instance With Port On Compute Node    @{NET_3_PORTS}[${index+2}]    @{NET_3_VMS}[${index+2}]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
130     @{NET_1_VM_IPS}    ${NET1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_VMS}
131     @{NET_2_VM_IPS}    ${NET2_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_2_VMS}
132     @{NET_3_VM_IPS}    ${NET3_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_3_VMS}
133     BuiltIn.Set Suite Variable    @{NET_1_VM_IPS}
134     BuiltIn.Set Suite Variable    @{NET_2_VM_IPS}
135     BuiltIn.Set Suite Variable    @{NET_3_VM_IPS}
136     BuiltIn.Should Not Contain    ${NET_1_VM_IPS}    None
137     BuiltIn.Should Not Contain    ${NET_2_VM_IPS}    None
138     BuiltIn.Should Not Contain    ${NET_3_VM_IPS}    None
139     OpenStackOperations.Show Debugs    @{NET_1_VMS}    @{NET_2_VMS}    @{NET_3_VMS}
140
141 Create Setup
142     [Documentation]    Create basic topology
143     OpenStackOperations.OpenStack Suite Setup
144     ${id} =    OpenStackOperations.Get Project Id    ${ODL_RESTCONF_USER}
145     OpenStackOperations.Set Instance Quota For Project    ${NUM_OF_INSTANCES}    ${id}
146     Create Neutron Networks
147     Create Neutron Subnets    ${3}
148     OpenStackOperations.Create And Configure Security Group    ${SECURITY_GROUP}
149     Create Neutron Ports
150     Create Nova VMs
151     Create Sub Interfaces And Verify
152     Create L3VPN
153     : FOR    ${network}    IN    @{NETWORKS}
154     \    ${network_id} =    OpenStackOperations.Get Net Id    ${network}
155     \    VpnOperations.Associate L3VPN To Network    networkid=${network_id}    vpnid=${VPN_INSTANCE_ID}
156     Create BGP Config On ODL
157     Create BGP Config On DCGW
158     BuiltIn.Wait Until Keyword Succeeds    60s    10s    VpnOperations.Verify Tunnel Status as UP
159     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ${RPING_MIP_IP}
160     BuiltIn.Should Contain    ${output}    broadcast    Received 0 reply
161     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[0]    ${RPING_MIP_IP1}
162     BuiltIn.Should Contain    ${output}    broadcast    Received 0 reply
163     ${output} =    OpenStackOperations.Execute Command on VM Instance    @{NETWORKS}[2]    @{NET_3_VM_IPS}[0]    ${RPING_MIP_IP2}
164     BuiltIn.Should Contain    ${output}    broadcast    Received 0 reply
165
166 Create Sub Interfaces And Verify
167     [Documentation]    Create Sub Interface and verify for all VMs
168     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Configure_IP_On_Sub_Interface    @{NETWORKS}[0]    @{EXTRA_NW_SUBNET}[0]    @{NET_1_VM_IPS}[0]
169     ...    ${MASK}    @{INTERFACE_STATE}[0]
170     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Verify_IP_Configured_On_Sub_Interface    @{NETWORKS}[0]    @{EXTRA_NW_SUBNET}[0]    @{NET_1_VM_IPS}[0]
171     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Configure_IP_On_Sub_Interface    @{NETWORKS}[1]    @{EXTRA_NW_SUBNET}[1]    @{NET_2_VM_IPS}[0]
172     ...    ${MASK}    @{INTERFACE_STATE}[0]
173     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Verify_IP_Configured_On_Sub_Interface    @{NETWORKS}[1]    @{EXTRA_NW_SUBNET}[1]    @{NET_2_VM_IPS}[0]
174     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Configure_IP_On_Sub_Interface    @{NETWORKS}[2]    @{EXTRA_NW_SUBNET}[2]    @{NET_3_VM_IPS}[0]
175     ...    ${MASK}    @{INTERFACE_STATE}[0]
176     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Verify_IP_Configured_On_Sub_Interface    @{NETWORKS}[2]    @{EXTRA_NW_SUBNET}[2]    @{NET_3_VM_IPS}[0]
177
178 Create L3VPN
179     [Documentation]    Create L3VPN and verify the same
180     ${net_id} =    OpenStackOperations.Get Net Id    @{NETWORKS}[0]
181     ${tenant_id} =    OpenStackOperations.Get Tenant ID From Network    ${net_id}
182     VpnOperations.VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID}    name=${VPN_NAME}    rd=["${L3VPN_RD}"]    exportrt=["${L3VPN_RD}"]    importrt=["${L3VPN_RD}"]    tenantid=${tenant_id}
183     VpnOperations.Verify L3VPN On ODL    ${VPN_INSTANCE_ID}
184
185 Create BGP Config On ODL
186     [Documentation]    Configure BGP Config on ODL
187     KarafKeywords.Issue Command On Karaf Console    ${BGP_CONFIG_SERVER_CMD}
188     BgpOperations.Create BGP Configuration On ODL    localas=${AS_ID}    routerid=${ODL_SYSTEM_IP}
189     BgpOperations.AddNeighbor To BGP Configuration On ODL    remoteas=${AS_ID}    neighborAddr=${DCGW_SYSTEM_IP}
190     ${output} =    BgpOperations.Get BGP Configuration On ODL    session
191     BuiltIn.Should Contain    ${output}    ${DCGW_SYSTEM_IP}
192
193 Create BGP Config On DCGW
194     [Documentation]    Configure BGP on DCGW
195     BgpOperations.Configure BGP And Add Neighbor On DCGW    ${DCGW_SYSTEM_IP}    ${AS_ID}    ${DCGW_SYSTEM_IP}    ${ODL_SYSTEM_IP}    ${VPN_NAME}    ${L3VPN_RD}
196     ...    ${LOOPBACK_IP}
197     ${output} =    BgpOperations.Execute Show Command On Quagga    ${DCGW_SYSTEM_IP}    ${RUN_CONFIG}
198     BuiltIn.Should Contain    ${output}    ${ODL_SYSTEM_IP}
199     ${output} =    BuiltIn.Wait Until Keyword Succeeds    180s    10s    BgpOperations.Verify BGP Neighbor Status On Quagga    ${DCGW_SYSTEM_IP}    ${ODL_SYSTEM_IP}
200
201 Configure_IP_On_Sub_Interface
202     [Arguments]    ${network_name}    ${ip}    ${vm_ip}    ${mask}    ${sub_interface_state}=${EMPTY}    ${interface}=eth0
203     ...    ${sub_interface_number}=1
204     [Documentation]    Keyword for configuring specified IP on specified interface and the corresponding specified sub interface
205     OpenStackOperations.Execute Command on VM Instance    ${network_name}    ${vm_ip}    sudo ifconfig ${interface}:${sub_interface_number} ${ip} netmask ${mask} ${sub_interface_state}
206
207 Verify_IP_Configured_On_Sub_Interface
208     [Arguments]    ${network_name}    ${ip}    ${vm_ip}    ${interface}=eth0    ${sub_interface_number}=1
209     [Documentation]    Keyword for verifying specified IP on specified interface and the corresponding specified sub interface
210     ${resp} =    OpenStackOperations.Execute Command on VM Instance    ${network_name}    ${vm_ip}    sudo ifconfig ${interface}:${sub_interface_number}
211     BuiltIn.Should Contain    ${resp}    ${ip}
212
213 Verify Ping between Inter Intra And Enterprise host
214     [Documentation]    Ping Enterprise Host for Intra, Inter from different and same network
215     ${dst_ip_list} =    BuiltIn.Create List    @{NET_1_VM_IPS}    @{NET_2_VM_IPS}    @{EXTRA_NW_SUBNET}
216     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[0]    ${dst_ip_list}
217     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[0]    ${dst_ip_list}
218     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[0]    @{NET_1_VM_IPS}[2]    ${dst_ip_list}
219     OpenStackOperations.Test Operations From Vm Instance    @{NETWORKS}[1]    @{NET_2_VM_IPS}[2]    ${dst_ip_list}