macauley | e7df640 | 2015-07-16 17:38:20 +0800 | [diff] [blame] | 1 | """
|
| 2 | Group table test
|
| 3 | Verify each group table can created correctly
|
| 4 | """
|
| 5 | from oftest import config
|
| 6 | import oftest.base_tests as base_tests
|
| 7 | import ofp
|
| 8 | from oftest.testutils import *
|
| 9 | from accton_util import *
|
| 10 |
|
| 11 | class L2InterfaceGroup(base_tests.SimpleDataPlane):
|
| 12 | def runTest(self):
|
macauley | fd08eda | 2015-07-17 15:59:04 +0800 | [diff] [blame^] | 13 | delete_all_flows(self.controller)
|
| 14 | delete_all_groups(self.controller)
|
macauley | e7df640 | 2015-07-16 17:38:20 +0800 | [diff] [blame] | 15 |
|
macauley | fd08eda | 2015-07-17 15:59:04 +0800 | [diff] [blame^] | 16 | group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
|
| 17 | group_list2, msg2 =add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
|
macauley | e7df640 | 2015-07-16 17:38:20 +0800 | [diff] [blame] | 18 |
|
macauley | fd08eda | 2015-07-17 15:59:04 +0800 | [diff] [blame^] | 19 | stats = get_stats(self, ofp.message.group_desc_stats_request())
|
| 20 |
|
| 21 | verify_group_stats=[]
|
| 22 | for msg in msg1:
|
| 23 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 24 | group_type=msg.group_type,
|
| 25 | group_id=msg.group_id,
|
| 26 | buckets=msg.buckets)
|
| 27 | )
|
| 28 |
|
| 29 | for msg in msg2:
|
| 30 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 31 | group_type=msg.group_type,
|
| 32 | group_id=msg.group_id,
|
| 33 | buckets=msg.buckets)
|
| 34 | )
|
| 35 |
|
| 36 | self.assertEquals(stats, verify_group_stats)
|
| 37 |
|
| 38 |
|
macauley | e7df640 | 2015-07-16 17:38:20 +0800 | [diff] [blame] | 39 | class L2McastGroup(base_tests.SimpleDataPlane):
|
| 40 | def runTest(self):
|
| 41 | delete_all_flows(self.controller)
|
| 42 | delete_all_groups(self.controller)
|
| 43 |
|
macauley | fd08eda | 2015-07-17 15:59:04 +0800 | [diff] [blame^] | 44 | group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
|
| 45 | msg2=add_l2_mcast_group(self.controller, config["port_map"].keys(), 1, 1)
|
macauley | e7df640 | 2015-07-16 17:38:20 +0800 | [diff] [blame] | 46 |
|
macauley | fd08eda | 2015-07-17 15:59:04 +0800 | [diff] [blame^] | 47 | group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
|
| 48 | msg4=add_l2_mcast_group(self.controller, config["port_map"].keys(), 2, 2)
|
macauley | e7df640 | 2015-07-16 17:38:20 +0800 | [diff] [blame] | 49 |
|
macauley | fd08eda | 2015-07-17 15:59:04 +0800 | [diff] [blame^] | 50 | stats = get_stats(self, ofp.message.group_desc_stats_request())
|
| 51 |
|
| 52 | verify_group_stats=[]
|
| 53 | for msg in msg1:
|
| 54 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 55 | group_type=msg.group_type,
|
| 56 | group_id=msg.group_id,
|
| 57 | buckets=msg.buckets)
|
| 58 | )
|
| 59 |
|
| 60 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 61 | group_type=msg2.group_type,
|
| 62 | group_id=msg2.group_id,
|
| 63 | buckets=msg2.buckets)
|
| 64 | )
|
| 65 |
|
| 66 | for msg in msg3:
|
| 67 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 68 | group_type=msg.group_type,
|
| 69 | group_id=msg.group_id,
|
| 70 | buckets=msg.buckets)
|
| 71 | )
|
| 72 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 73 | group_type=msg4.group_type,
|
| 74 | group_id=msg4.group_id,
|
| 75 | buckets=msg4.buckets)
|
| 76 | )
|
| 77 |
|
| 78 | self.assertEquals(stats, verify_group_stats)
|
| 79 |
|
| 80 |
|
| 81 | class L2FloodGroup(base_tests.SimpleDataPlane):
|
| 82 | def runTest(self):
|
| 83 | delete_all_flows(self.controller)
|
| 84 | delete_all_groups(self.controller)
|
| 85 |
|
| 86 | group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
|
| 87 | msg2=add_l2_flood_group(self.controller, config["port_map"].keys(), 1, 1)
|
| 88 |
|
| 89 | group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
|
| 90 | msg4=add_l2_flood_group(self.controller, config["port_map"].keys(), 2, 2)
|
| 91 |
|
| 92 | stats = get_stats(self, ofp.message.group_desc_stats_request())
|
| 93 |
|
| 94 | verify_group_stats=[]
|
| 95 | for msg in msg1:
|
| 96 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 97 | group_type=msg.group_type,
|
| 98 | group_id=msg.group_id,
|
| 99 | buckets=msg.buckets)
|
| 100 | )
|
| 101 |
|
| 102 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 103 | group_type=msg2.group_type,
|
| 104 | group_id=msg2.group_id,
|
| 105 | buckets=msg2.buckets)
|
| 106 | )
|
| 107 |
|
| 108 | for msg in msg3:
|
| 109 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 110 | group_type=msg.group_type,
|
| 111 | group_id=msg.group_id,
|
| 112 | buckets=msg.buckets)
|
| 113 | )
|
| 114 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 115 | group_type=msg4.group_type,
|
| 116 | group_id=msg4.group_id,
|
| 117 | buckets=msg4.buckets)
|
| 118 | )
|
| 119 |
|
| 120 | self.assertEquals(stats, verify_group_stats)
|
| 121 |
|
| 122 |
|
| 123 | class L2RewriteGroup(base_tests.SimpleDataPlane):
|
| 124 | def runTest(self):
|
| 125 | delete_all_flows(self.controller)
|
| 126 | delete_all_groups(self.controller)
|
| 127 |
|
| 128 | group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
|
| 129 | msg2=add_l2_rewrite_group(self.controller, config["port_map"].keys()[0], 1, 1, [00,11,22,33,44,55], [00,22,22,22,22,22])
|
| 130 |
|
| 131 | group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
|
| 132 | msg4=add_l2_rewrite_group(self.controller, config["port_map"].keys()[0], 2, 2, [00,11,22,33,44,55], [00,33,33,33,33,33])
|
| 133 |
|
| 134 | stats = get_stats(self, ofp.message.group_desc_stats_request())
|
| 135 |
|
| 136 | verify_group_stats=[]
|
| 137 | for msg in msg1:
|
| 138 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 139 | group_type=msg.group_type,
|
| 140 | group_id=msg.group_id,
|
| 141 | buckets=msg.buckets)
|
| 142 | )
|
| 143 |
|
| 144 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 145 | group_type=msg2.group_type,
|
| 146 | group_id=msg2.group_id,
|
| 147 | buckets=msg2.buckets)
|
| 148 | )
|
| 149 |
|
| 150 | for msg in msg3:
|
| 151 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 152 | group_type=msg.group_type,
|
| 153 | group_id=msg.group_id,
|
| 154 | buckets=msg.buckets)
|
| 155 | )
|
| 156 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 157 | group_type=msg4.group_type,
|
| 158 | group_id=msg4.group_id,
|
| 159 | buckets=msg4.buckets)
|
| 160 | )
|
| 161 |
|
| 162 | self.assertEquals(stats, verify_group_stats)
|
| 163 |
|
| 164 |
|
| 165 | class L3UnicastGroup(base_tests.SimpleDataPlane):
|
| 166 | def runTest(self):
|
| 167 | delete_all_flows(self.controller)
|
| 168 | delete_all_groups(self.controller)
|
| 169 |
|
| 170 | group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
|
| 171 | msg2=add_l3_unicast_group(self.controller, config["port_map"].keys()[0], 1, 1, [0x00,0x11,0x22,0x33,0x44,0x55], [00,0x22,0x22,0x22,0x22,0x22])
|
| 172 |
|
| 173 | group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
|
| 174 | msg4=add_l3_unicast_group(self.controller, config["port_map"].keys()[0], 2, 2, [0x00,0x11,0x22,0x33,0x44,0x55], [00,0x33,0x33,0x33,0x33,0x33])
|
| 175 |
|
| 176 | stats = get_stats(self, ofp.message.group_desc_stats_request())
|
| 177 |
|
| 178 | verify_group_stats=[]
|
| 179 | for msg in msg1:
|
| 180 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 181 | group_type=msg.group_type,
|
| 182 | group_id=msg.group_id,
|
| 183 | buckets=msg.buckets)
|
| 184 | )
|
| 185 |
|
| 186 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 187 | group_type=msg2.group_type,
|
| 188 | group_id=msg2.group_id,
|
| 189 | buckets=msg2.buckets)
|
| 190 | )
|
| 191 |
|
| 192 | for msg in msg3:
|
| 193 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 194 | group_type=msg.group_type,
|
| 195 | group_id=msg.group_id,
|
| 196 | buckets=msg.buckets)
|
| 197 | )
|
| 198 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 199 | group_type=msg4.group_type,
|
| 200 | group_id=msg4.group_id,
|
| 201 | buckets=msg4.buckets)
|
| 202 | )
|
| 203 |
|
| 204 | self.assertEquals(stats, verify_group_stats)
|
| 205 |
|
| 206 |
|
| 207 | class L3ECMPGroup(base_tests.SimpleDataPlane):
|
| 208 | def runTest(self):
|
| 209 | delete_all_flows(self.controller)
|
| 210 | delete_all_groups(self.controller)
|
| 211 |
|
| 212 | group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
|
| 213 | msg2=add_l3_unicast_group(self.controller, config["port_map"].keys()[0], 1, 1, [0x00,0x11,0x22,0x33,0x44,0x55], [00,0x22,0x22,0x22,0x22,0x22])
|
| 214 |
|
| 215 | group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
|
| 216 | msg4=add_l3_unicast_group(self.controller, config["port_map"].keys()[0], 2, 2, [0x00,0x11,0x22,0x33,0x44,0x55], [00,0x33,0x33,0x33,0x33,0x33])
|
| 217 |
|
| 218 | group_ids=[msg2.group_id, msg4.group_id]
|
| 219 |
|
| 220 | msg5=add_l3_ecmp_group(self.controller, 1, group_ids)
|
| 221 |
|
| 222 | stats = get_stats(self, ofp.message.group_desc_stats_request())
|
| 223 |
|
| 224 | verify_group_stats=[]
|
| 225 | for msg in msg1:
|
| 226 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 227 | group_type=msg.group_type,
|
| 228 | group_id=msg.group_id,
|
| 229 | buckets=msg.buckets)
|
| 230 | )
|
| 231 |
|
| 232 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 233 | group_type=msg2.group_type,
|
| 234 | group_id=msg2.group_id,
|
| 235 | buckets=msg2.buckets)
|
| 236 | )
|
| 237 |
|
| 238 | for msg in msg3:
|
| 239 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 240 | group_type=msg.group_type,
|
| 241 | group_id=msg.group_id,
|
| 242 | buckets=msg.buckets)
|
| 243 | )
|
| 244 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 245 | group_type=msg4.group_type,
|
| 246 | group_id=msg4.group_id,
|
| 247 | buckets=msg4.buckets)
|
| 248 | )
|
| 249 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 250 | group_type=msg5.group_type,
|
| 251 | group_id=msg5.group_id,
|
| 252 | buckets=msg5.buckets)
|
| 253 | )
|
| 254 |
|
| 255 | self.assertEquals(stats, verify_group_stats)
|
| 256 |
|
| 257 |
|
| 258 | class L3InterfaceGroup(base_tests.SimpleDataPlane):
|
| 259 | def runTest(self):
|
| 260 | delete_all_flows(self.controller)
|
| 261 | delete_all_groups(self.controller)
|
| 262 |
|
| 263 | group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
|
| 264 | msg2=add_l3_interface_group(self.controller, config["port_map"].keys()[0], 1, 1, [0x00,0x11,0x22,0x33,0x44,0x55])
|
| 265 | group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False)
|
| 266 | msg4=add_l3_interface_group(self.controller, config["port_map"].keys()[0], 2, 2, [0x00,0x11,0x22,0x33,0x44,0x66])
|
| 267 |
|
| 268 | stats = get_stats(self, ofp.message.group_desc_stats_request())
|
| 269 |
|
| 270 | verify_group_stats=[]
|
| 271 | for msg in msg1:
|
| 272 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 273 | group_type=msg.group_type,
|
| 274 | group_id=msg.group_id,
|
| 275 | buckets=msg.buckets)
|
| 276 | )
|
| 277 |
|
| 278 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 279 | group_type=msg2.group_type,
|
| 280 | group_id=msg2.group_id,
|
| 281 | buckets=msg2.buckets)
|
| 282 | )
|
| 283 |
|
| 284 | for msg in msg3:
|
| 285 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 286 | group_type=msg.group_type,
|
| 287 | group_id=msg.group_id,
|
| 288 | buckets=msg.buckets)
|
| 289 | )
|
| 290 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 291 | group_type=msg4.group_type,
|
| 292 | group_id=msg4.group_id,
|
| 293 | buckets=msg4.buckets)
|
| 294 | )
|
| 295 |
|
| 296 |
|
| 297 | self.assertEquals(stats, verify_group_stats)
|
| 298 |
|
| 299 |
|
| 300 | class L3McastGroup(base_tests.SimpleDataPlane):
|
| 301 | def runTest(self):
|
| 302 | delete_all_flows(self.controller)
|
| 303 | delete_all_groups(self.controller)
|
| 304 |
|
| 305 | # Vlan 3 forward to vlan 3 port 1 and 2
|
| 306 | # Vlan 3 foward to vlan 1 port 1
|
| 307 | # Vlan 3 foward to vlan 2 port 1
|
| 308 | # Vlan 3 foward to vlan 2 port 2
|
| 309 | group_list1_1, msg1 = add_l2_interface_grouop(self.controller, [config["port_map"].keys()[0]], 1, False, False)
|
| 310 | msg2=add_l3_interface_group(self.controller, config["port_map"].keys()[0], 1, 1, [0x00,0x11,0x22,0x33,0x44,0x11])
|
| 311 | group_list1_2, msg3 = add_l2_interface_grouop(self.controller, [config["port_map"].keys()[0]], 2, False, False)
|
| 312 | msg4=add_l3_interface_group(self.controller, config["port_map"].keys()[0], 2, 2, [0x00,0x11,0x22,0x33,0x44,0x22])
|
| 313 | group_list2_1, msg5 = add_l2_interface_grouop(self.controller, [config["port_map"].keys()[1]], 2, False, False)
|
| 314 | msg6=add_l3_interface_group(self.controller, config["port_map"].keys()[1], 2, 3, [0x00,0x11,0x22,0x33,0x44,0x33])
|
| 315 | group_list3, msg7 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 3, False, False)
|
| 316 |
|
| 317 | group_actions=[msg2.group_id, msg4.group_id, msg6.group_id]
|
| 318 | group_actions.extend(group_list3)
|
| 319 |
|
| 320 | msg8=add_l3_mcast_group(self.controller, 3, 1, group_actions)
|
| 321 |
|
| 322 | stats = get_stats(self, ofp.message.group_desc_stats_request())
|
| 323 |
|
| 324 | verify_group_stats=[]
|
| 325 | for msg in msg1:
|
| 326 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 327 | group_type=msg.group_type,
|
| 328 | group_id=msg.group_id,
|
| 329 | buckets=msg.buckets)
|
| 330 | )
|
| 331 |
|
| 332 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 333 | group_type=msg2.group_type,
|
| 334 | group_id=msg2.group_id,
|
| 335 | buckets=msg2.buckets)
|
| 336 | )
|
| 337 |
|
| 338 | for msg in msg3:
|
| 339 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 340 | group_type=msg.group_type,
|
| 341 | group_id=msg.group_id,
|
| 342 | buckets=msg.buckets)
|
| 343 | )
|
| 344 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 345 | group_type=msg4.group_type,
|
| 346 | group_id=msg4.group_id,
|
| 347 | buckets=msg4.buckets)
|
| 348 | )
|
| 349 | for msg in msg5:
|
| 350 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 351 | group_type=msg.group_type,
|
| 352 | group_id=msg.group_id,
|
| 353 | buckets=msg.buckets)
|
| 354 | )
|
| 355 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 356 | group_type=msg6.group_type,
|
| 357 | group_id=msg6.group_id,
|
| 358 | buckets=msg6.buckets)
|
| 359 | )
|
| 360 | for msg in msg7:
|
| 361 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 362 | group_type=msg.group_type,
|
| 363 | group_id=msg.group_id,
|
| 364 | buckets=msg.buckets)
|
| 365 | )
|
| 366 |
|
| 367 | verify_group_stats.append(ofp.group_desc_stats_entry(
|
| 368 | group_type=msg8.group_type,
|
| 369 | group_id=msg8.group_id,
|
| 370 | buckets=msg8.buckets)
|
| 371 | )
|
| 372 |
|
| 373 | self.assertEquals(stats, verify_group_stats)
|
| 374 |
|
| 375 |
|
| 376 | |