2 Documentation Test Suite for Network and Subnet Broadcast with security group
3 Suite Setup Start Suite
4 Suite Teardown OpenStackOperations.OpenStack Suite Teardown
5 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Test Teardown OpenStackOperations.Get Test Teardown Debugs
8 Library RequestsLibrary
12 Library OperatingSystem
13 Resource ../../../libraries/DevstackUtils.robot
14 Resource ../../../libraries/KarafKeywords.robot
15 Resource ../../../libraries/OpenStackOperations.robot
16 Resource ../../../libraries/OVSDB.robot
17 Resource ../../../libraries/OvsManager.robot
18 Resource ../../../libraries/SetupUtils.robot
19 Resource ../../../libraries/Utils.robot
20 Resource ../../../variables/Variables.robot
21 Resource ../../../variables/netvirt/Variables.robot
24 @{SECURITY_GROUP} sgbcast1 sgbcast2
25 @{NETWORKS} sgbcast_net_1 sgbcast_net_2
26 @{SUBNETS} sgbcast_sub_1 sgbcast_sub_2
27 @{SUBNET_CIDRS} 55.0.0.0/24 56.0.0.0/24
28 ${ROUTER} sgbcast_router
29 @{NET_1_PORTS} sgbcast_net_1_port_1 sgbcast_net_1_port_2 sgbcast_net_1_port_3
30 @{NET_2_PORTS} sgbcast_net_2_port_1 sgbcast_net_2_port_2
31 @{NET_1_VMS} sgbcast_net_1_vm_1 sgbcast_net_1_vm_2 sgbcast_net_1_vm_3
32 @{NET_2_VMS} sgbcast_net_2_vm_1 sgbcast_net_2_vm_2
33 ${DUMP_FLOW} sudo ovs-ofctl dump-flows br-int -OOpenflow13
34 ${DUMP_PORT_DESC} sudo ovs-ofctl dump-ports-desc br-int -OOpenflow13
36 ${BCAST_IP} 255.255.255.255
37 ${SUBNET1_BCAST_IP} 55.0.0.255
38 ${SUBNET2_BCAST_IP} 56.0.0.255
39 ${ENABLE_BCAST} echo 0 | sudo tee /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
42 Verify Network Broadcast traffic between the VMs hosted in Single Network
43 [Documentation] This TC is to verify Network Broadcast traffic between the VMs hosted in Same Network on same/different compute node
44 ${pkt_check} = BuiltIn.Set Variable If "${OPENSTACK_TOPO}" == "1cmb-0ctl-0cmp" 10 5
45 Wait Until Keyword Succeeds 30s 5s Verify L3Broadcast With Antispoofing Table ${OS_CMP1_IP} ${EGRESS_ACL_TABLE} ${BCAST_IP}
46 ... @{VM_IPS}[0] same pingsuccess pkt_check=${pkt_check}
48 Verify Network Broadcast traffic between the VMs hosted in Multi Network
49 [Documentation] This TC is to verify Network Broadcast traffic between the VMs hosted in Different Network on same/different compute node.
50 ${pkt_check} = BuiltIn.Set Variable If "${OPENSTACK_TOPO}" == "1cmb-0ctl-0cmp" 5 0
51 Wait Until Keyword Succeeds 30s 5s Verify L3Broadcast With Antispoofing Table ${OS_CMP1_IP} ${EGRESS_ACL_TABLE} ${BCAST_IP}
52 ... @{VM_IPS}[3] different pingsuccess pkt_check=${pkt_check}
54 Verify Subnet Broadcast traffic between the VMs hosted on same compute node in Single Network
55 [Documentation] Verify L3-Subnet Broadcast traffic between the VMs hosted on same compute node in Single Network
56 Wait Until Keyword Succeeds 30s 5s Verify L3Broadcast With Antispoofing Table ${OS_CMP1_IP} ${EGRESS_ACL_TABLE} ${SUBNET1_BCAST_IP}
57 ... @{VM_IPS}[0] same pingsuccess ${VM2_SUBMETA} pkt_check=5 additional_args=| grep ${VM2_SUBMETA}
59 Verify Subnet Broadcast traffic between the VMs hosted on Different compute node in Single Network
60 [Documentation] Verify L3-Subnet Broadcast traffic between the VMs hosted on same compute node in Single Network
61 Wait Until Keyword Succeeds 30s 5s Verify L3Broadcast With Antispoofing Table ${OS_CMP2_IP} ${EGRESS_ACL_TABLE} ${SUBNET1_BCAST_IP}
62 ... @{VM_IPS}[0] same pingsuccess ${VM3_SUBMETA} pkt_check=5 additional_args=| grep ${VM3_SUBMETA}
64 Verify Subnet Broadcast traffic between the VMs hosted on same compute node in Multi Network
65 [Documentation] Verify L3-Subnet Broadcast traffic between the VMs hosted on same compute node in Multi Network
66 Wait Until Keyword Succeeds 30s 5s Verify L3Broadcast With Antispoofing Table ${OS_CMP1_IP} ${EGRESS_ACL_TABLE} ${SUBNET2_BCAST_IP}
67 ... @{VM_IPS}[0] different nosuccess ${VM4_SUBMETA} pkt_check=0 additional_args=| grep ${VM4_SUBMETA}
69 Verify Subnet Broadcast traffic between the VMs hosted on Different compute node in Multi Network
70 [Documentation] Verify L3-Subnet Broadcast traffic between the VMs hosted on Different compute node in Multi Network
71 Wait Until Keyword Succeeds 30s 5s Verify L3Broadcast With Antispoofing Table ${OS_CMP2_IP} ${EGRESS_ACL_TABLE} ${SUBNET2_BCAST_IP}
72 ... @{VM_IPS}[0] different nosuccess ${VM5_SUBMETA} pkt_check=0 additional_args=| grep ${VM5_SUBMETA}
76 [Documentation] Test Suite for Network and Subnet Broadcast with security group
77 OpenStackOperations.OpenStack Suite Setup
79 OpenStackOperations.Show Debugs @{NET_1_VMS} @{NET_2_VMS}
80 OpenStackOperations.Get Suite Debugs
83 : FOR ${network} IN @{NETWORKS}
84 \ OpenStackOperations.Create Network ${network}
85 : FOR ${i} IN RANGE len(${NETWORKS})
86 \ OpenStackOperations.Create SubNet @{NETWORKS}[${i}] @{SUBNETS}[${i}] @{SUBNET_CIDRS}[${i}]
87 OpenStackOperations.Create Allow All SecurityGroup @{SECURITY_GROUP}[0]
88 OpenStackOperations.Create Router ${ROUTER}
89 : FOR ${interface} IN @{SUBNETS}
90 \ OpenStackOperations.Add Router Interface ${ROUTER} ${interface}
91 : FOR ${port_net1} IN @{NET_1_PORTS}
92 \ OpenStackOperations.Create Port @{NETWORKS}[0] ${port_net1} sg=@{SECURITY_GROUP}[0]
93 : FOR ${port_net2} IN @{NET_2_PORTS}
94 \ OpenStackOperations.Create Port @{NETWORKS}[1] ${port_net2} sg=@{SECURITY_GROUP}[0]
95 @{ports} = BuiltIn.Create List @{NET_1_PORTS}[0] @{NET_1_PORTS}[1] @{NET_1_PORTS}[2] @{NET_2_PORTS}[0] @{NET_2_PORTS}[1]
96 @{vms} = BuiltIn.Create List @{NET_1_VMS}[0] @{NET_1_VMS}[1] @{NET_1_VMS}[2] @{NET_2_VMS}[0] @{NET_2_VMS}[1]
97 @{nodes} = BuiltIn.Create List ${OS_CMP1_HOSTNAME} ${OS_CMP1_HOSTNAME} ${OS_CMP2_HOSTNAME} ${OS_CMP1_HOSTNAME} ${OS_CMP2_HOSTNAME}
98 : FOR ${port} ${vm} ${node} IN ZIP ${ports} ${vms}
100 \ OpenStackOperations.Create Vm Instance With Port On Compute Node ${port} ${vm} ${node} sg=@{SECURITY_GROUP}[0]
101 @{vms} = Collections.Combine Lists ${NET_1_VMS} ${NET_2_VMS}
102 @{VM_IPS} = OpenStackOperations.Get VM IPs @{vms}
103 BuiltIn.Should Not Contain ${VM_IPS} None
104 BuiltIn.Set Suite Variable @{VM_IPS}
105 OpenStackOperations.Execute Command on VM Instance ${NETWORKS[0]} @{VM_IPS}[0] ${ENABLE_BCAST}
106 OpenStackOperations.Execute Command on VM Instance ${NETWORKS[1]} @{VM_IPS}[3] ${ENABLE_BCAST}
107 ${vm1_in_port} ${vm1_meta} = BuiltIn.Wait Until Keyword Succeeds 60s 10s Get VMs Metadata and In Port @{NET_1_PORTS}[0]
109 ${vm2_in_port} ${vm2_meta} = BuiltIn.Wait Until Keyword Succeeds 60s 10s Get VMs Metadata and In Port @{NET_1_PORTS}[1]
111 ${vm3_in_port} ${vm3_meta} = BuiltIn.Wait Until Keyword Succeeds 60s 10s Get VMs Metadata and In Port @{NET_1_PORTS}[2]
113 ${vm4_in_port} ${vm4_meta} = BuiltIn.Wait Until Keyword Succeeds 60s 10s Get VMs Metadata and In Port @{NET_2_PORTS}[0]
115 ${vm5_in_port} ${vm5_meta} = BuiltIn.Wait Until Keyword Succeeds 60s 10s Get VMs Metadata and In Port @{NET_2_PORTS}[1]
117 ${VM1_SUBMETA} = Get Submetadata ${vm1_meta}
118 ${VM2_SUBMETA} = Get Submetadata ${vm2_meta}
119 ${VM3_SUBMETA} = Get Submetadata ${vm3_meta}
120 ${VM4_SUBMETA} = Get Submetadata ${vm4_meta}
121 ${VM5_SUBMETA} = Get Submetadata ${vm5_meta}
122 BuiltIn.Set Suite Variable ${VM1_SUBMETA}
123 BuiltIn.Set Suite Variable ${VM2_SUBMETA}
124 BuiltIn.Set Suite Variable ${VM3_SUBMETA}
125 BuiltIn.Set Suite Variable ${VM4_SUBMETA}
126 BuiltIn.Set Suite Variable ${VM5_SUBMETA}
128 Get VMs Metadata and In Port
129 [Arguments] ${portname} ${OS_COMPUTE_IP}
130 [Documentation] This keyword is to get the VM metadata and the in_port Id of the VM
131 ${subport} = OpenStackOperations.Get Sub Port Id ${portname}
132 ${get_vm_in_port} = Utils.Run Command On Remote System And Log ${OS_COMPUTE_IP} ${DUMP_PORT_DESC} | grep ${subport} | awk '{print$1}'
133 ${vms_in_port} = BuiltIn.Should Match Regexp ${get_vm_in_port} [0-9]+
134 ${grep_metadata} = Utils.Run Command On Remote System And Log ${OS_COMPUTE_IP} ${DUMP_FLOW} | grep table=${VLAN_INTERFACE_INGRESS_TABLE} | grep in_port=${vms_in_port} | awk '{print$7}'
135 @{metadata} = String.Split string ${grep_metadata} ,
136 ${get_write_metadata} = Collections.get from list ${metadata} 0
137 @{complete_metadata} = String.Split string ${get_write_metadata} :
138 ${extract_metadata} = Collections.get from list ${complete_metadata} 1
139 @{split_metadata} = String.Split string ${extract_metadata} /
140 ${vm_metadata} = Collections.Get From List ${split_metadata} 0
141 [Return] ${vms_in_port} ${vm_metadata}
144 [Arguments] ${vm_metadata}
145 [Documentation] Get the submetadata of the VM
146 ${cmd1} = Utils.Run Command On Remote System And Log ${OS_CMP1_IP} ${DUMP_FLOW} | grep ${EGRESS_LPORT_DISPATCHER_TABLE} | grep write_metadata:
147 ${output1} = String.Get Regexp Matches ${cmd1} reg6=(\\w+) 1
148 ${cmd2} = Utils.Run Command On Remote System And Log ${OS_CMP2_IP} ${DUMP_FLOW} | grep ${EGRESS_LPORT_DISPATCHER_TABLE} | grep write_metadata:
149 ${output2} = String.Get Regexp Matches ${cmd2} reg6=(\\w+) 1
150 ${metalist} = Collections.Combine Lists ${output1} ${output2}
151 : FOR ${meta} IN @{metalist}
152 \ ${metadata_check_status} = Run Keyword And Return Status should contain ${vm_metadata} ${meta}
153 \ Return From Keyword if ${metadata_check_status} == True ${meta}
155 Verify L3Broadcast With Antispoofing Table
156 [Arguments] ${OS_COMPUTE_IP} ${EGRESS_ACL_TABLE} ${BCAST_IP} ${vm_ip} ${subnet_var} ${ping_response}='pingsuccess'
157 ... ${vm_submeta}='' ${pkt_check}=0 ${additional_args}=${EMPTY}
158 [Documentation] Verify the l3 broadcast requests are hitting to antispoofing table in same subnet
159 ${get_pkt_count_before_bcast} = OvsManager.Get Packet Count In Table For IP ${OS_COMPUTE_IP} ${EGRESS_ACL_TABLE} ${BCAST_IP} additional_args=| grep ${vm_submeta}
160 ${output} = OpenStackOperations.Execute Command on VM Instance @{NETWORKS}[0] ${vm_ip} ping -c ${PACKET_COUNT} ${BCAST_IP}
161 BuiltIn.Run Keyword If '${ping_response}'=='pingsuccess' BuiltIn.Should Contain ${output} ${PING_REGEXP}
162 ... ELSE BuiltIn.Should Contain ${output} ${NO_PING_REGEXP}
163 ${bcast_egress} = Utils.Run Command On Remote System And Log ${OS_COMPUTE_IP} ${DUMP_FLOW} | grep table=${EGRESS_ACL_TABLE} | grep ${BCAST_IP} ${additional_args}
164 ${get_pkt_count_after_bcast} = OvsManager.Get Packet Count In Table For IP ${OS_COMPUTE_IP} ${EGRESS_ACL_TABLE} ${BCAST_IP} additional_args=| grep ${vm_submeta}
165 ${pkt_diff} = Evaluate int(${get_pkt_count_after_bcast})-int(${get_pkt_count_before_bcast})
166 BuiltIn.Should Be Equal As Numbers ${pkt_diff} ${pkt_check}