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} 10.0.0.255
38 ${SUBNET2_BCAST_IP} 20.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 Wait Until Keyword Succeeds 30s 5s Verify L3Broadcast With Antispoofing Table ${OS_COMPUTE1_IP} ${EGRESS_ACL_TABLE} ${BCAST_IP}
47 Verify Network Broadcast traffic between the VMs hosted in Multi Network
48 [Documentation] This TC is to verify Network Broadcast traffic between the VMs hosted in Different Network on same/different compute node.
49 Wait Until Keyword Succeeds 30s 5s Verify L3Broadcast With Antispoofing Table ${OS_COMPUTE1_IP} ${EGRESS_ACL_TABLE} ${BCAST_IP}
50 ... @{VM_IPS}[3] different
54 [Documentation] Test Suite for Network and Subnet Broadcast with security group
55 OpenStackOperations.OpenStack Suite Setup
59 : FOR ${network} IN @{NETWORKS}
60 \ OpenStackOperations.Create Network ${network}
61 : FOR ${i} IN RANGE len(${NETWORKS})
62 \ OpenStackOperations.Create SubNet @{NETWORKS}[${i}] @{SUBNETS}[${i}] @{SUBNET_CIDRS}[${i}]
63 OpenStackOperations.Create Allow All SecurityGroup @{SECURITY_GROUP}[0]
64 OpenStackOperations.Create Router ${ROUTER}
65 : FOR ${interface} IN @{SUBNETS}
66 \ OpenStackOperations.Add Router Interface ${ROUTER} ${interface}
67 : FOR ${port_net1} IN @{NET_1_PORTS}
68 \ OpenStackOperations.Create Port @{NETWORKS}[0] ${port_net1} sg=@{SECURITY_GROUP}[0]
69 : FOR ${port_net2} IN @{NET_2_PORTS}
70 \ OpenStackOperations.Create Port @{NETWORKS}[1] ${port_net2} sg=@{SECURITY_GROUP}[0]
71 @{ports} = BuiltIn.Create List @{NET_1_PORTS}[0] @{NET_1_PORTS}[1] @{NET_1_PORTS}[2] @{NET_2_PORTS}[0] @{NET_2_PORTS}[1]
72 @{vms} = BuiltIn.Create List @{NET_1_VMS}[0] @{NET_1_VMS}[1] @{NET_1_VMS}[2] @{NET_2_VMS}[0] @{NET_2_VMS}[1]
73 @{nodes} = BuiltIn.Create List ${OS_CMP1_HOSTNAME} ${OS_CMP1_HOSTNAME} ${OS_CMP2_HOSTNAME} ${OS_CMP1_HOSTNAME} ${OS_CMP2_HOSTNAME}
74 : FOR ${port} ${vm} ${node} IN ZIP ${ports} ${vms}
76 \ OpenStackOperations.Create Vm Instance With Port On Compute Node ${port} ${vm} ${node} sg=@{SECURITY_GROUP}[0]
77 @{vms} = Collections.Combine Lists ${NET_1_VMS} ${NET_2_VMS}
78 @{VM_IPS} = OpenStackOperations.Get VM IPs @{vms}
79 BuiltIn.Should Not Contain ${VM_IPS} None
80 BuiltIn.Set Suite Variable @{VM_IPS}
81 OpenStackOperations.Execute Command on VM Instance ${NETWORKS[0]} @{VM_IPS}[0] ${ENABLE_BCAST}
82 OpenStackOperations.Execute Command on VM Instance ${NETWORKS[1]} @{VM_IPS}[3] ${ENABLE_BCAST}
83 ${vm1_in_port} ${vm1_meta} = BuiltIn.Wait Until Keyword Succeeds 60s 10s Get VMs Metadata and In Port @{NET_1_PORTS}[0]
84 ... ${OS_COMPUTE_1_IP}
85 ${vm2_in_port} ${vm2_meta} = BuiltIn.Wait Until Keyword Succeeds 60s 10s Get VMs Metadata and In Port @{NET_1_PORTS}[1]
86 ... ${OS_COMPUTE_1_IP}
87 ${vm3_in_port} ${vm3_meta} = BuiltIn.Wait Until Keyword Succeeds 60s 10s Get VMs Metadata and In Port @{NET_1_PORTS}[2]
88 ... ${OS_COMPUTE_2_IP}
89 ${vm4_in_port} ${vm4_meta} = BuiltIn.Wait Until Keyword Succeeds 60s 10s Get VMs Metadata and In Port @{NET_2_PORTS}[0]
90 ... ${OS_COMPUTE_1_IP}
91 ${vm5_in_port} ${vm5_meta} = BuiltIn.Wait Until Keyword Succeeds 60s 10s Get VMs Metadata and In Port @{NET_2_PORTS}[1]
92 ... ${OS_COMPUTE_2_IP}
93 ${VM1_SUBMETA} = Get Submetadata ${vm1_meta}
94 ${VM2_SUBMETA} = Get Submetadata ${vm2_meta}
95 ${VM3_SUBMETA} = Get Submetadata ${vm3_meta}
96 ${VM4_SUBMETA} = Get Submetadata ${vm4_meta}
97 ${VM5_SUBMETA} = Get Submetadata ${vm5_meta}
98 BuiltIn.Set Suite Variable ${VM1_SUBMETA}
99 BuiltIn.Set Suite Variable ${VM2_SUBMETA}
100 BuiltIn.Set Suite Variable ${VM3_SUBMETA}
101 BuiltIn.Set Suite Variable ${VM4_SUBMETA}
102 BuiltIn.Set Suite Variable ${VM5_SUBMETA}
104 Get VMs Metadata and In Port
105 [Arguments] ${portname} ${OS_COMPUTE_IP}
106 [Documentation] This keyword is to get the VM metadata and the in_port Id of the VM
107 ${subport} = OpenStackOperations.Get Sub Port Id ${portname}
108 ${get_vm_in_port} = Utils.Run Command On Remote System And Log ${OS_COMPUTE_IP} ${DUMP_PORT_DESC} | grep ${subport} | awk '{print$1}'
109 ${vms_in_port} = BuiltIn.Should Match Regexp ${get_vm_in_port} [0-9]+
110 ${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}'
111 @{metadata} = String.Split string ${grep_metadata} ,
112 ${get_write_metadata} = Collections.get from list ${metadata} 0
113 @{complete_metadata} = String.Split string ${get_write_metadata} :
114 ${extract_metadata} = Collections.get from list ${complete_metadata} 1
115 @{split_metadata} = String.Split string ${extract_metadata} /
116 ${vm_metadata} = Collections.Get From List ${split_metadata} 0
117 [Return] ${vms_in_port} ${vm_metadata}
120 [Arguments] ${vm_metadata}
121 [Documentation] Get the submetadata of the VM
122 ${cmd1} = Utils.Run Command On Remote System And Log ${OS_COMPUTE1_IP} ${DUMP_FLOW} | grep ${EGRESS_LPORT_DISPATCHER_TABLE} | grep write_metadata:
123 ${output1} = String.Get Regexp Matches ${cmd1} reg6=(\\w+) 1
124 ${cmd2} = Utils.Run Command On Remote System And Log ${OS_COMPUTE2_IP} ${DUMP_FLOW} | grep ${EGRESS_LPORT_DISPATCHER_TABLE} | grep write_metadata:
125 ${output2} = String.Get Regexp Matches ${cmd2} reg6=(\\w+) 1
126 ${metalist} = Collections.Combine Lists ${output1} ${output2}
127 : FOR ${meta} IN @{metalist}
128 \ ${metadata_check_status} = Run Keyword And Return Status should contain ${vm_metadata} ${meta}
129 \ Return From Keyword if ${metadata_check_status} == True ${meta}
131 Verify L3Broadcast With Antispoofing Table
132 [Arguments] ${OS_COMPUTE_IP} ${EGRESS_ACL_TABLE} ${BCAST_IP} ${vm_ip} ${subnet_var}
133 [Documentation] Verify the l3 broadcast requests are hitting to antispoofing table in same subnet
134 ${get_pkt_count_before_bcast} = OvsManager.Get Packet Count In Table For IP ${OS_COMPUTE_IP} ${EGRESS_ACL_TABLE} ${BCAST_IP}
135 ${output} = OpenStackOperations.Execute Command on VM Instance @{NETWORKS}[0] ${vm_ip} ping -c ${PACKET_COUNT} ${BCAST_IP}
136 BuiltIn.Should Contain ${output} ${PING_REGEXP}
137 ${bcast_egress} = Utils.Run Command On Remote System And Log ${OS_COMPUTE_IP} ${DUMP_FLOW} | grep table=${EGRESS_ACL_TABLE} | grep ${BCAST_IP}
138 ${get_pkt_count_after_bcast} = OvsManager.Get Packet Count In Table For IP ${OS_COMPUTE_IP} ${EGRESS_ACL_TABLE} ${BCAST_IP}
139 ${pkt_diff} = Evaluate int(${get_pkt_count_after_bcast})-int(${get_pkt_count_before_bcast})
140 BuiltIn.Run Keyword If '${subnet_var}' == 'same' Should Be Equal As Numbers ${pkt_diff} ${PACKET_COUNT}
141 ... ELSE Should Be True ${pkt_diff}==0