| @@ 366-414 (lines=49) @@ | ||
| 363 | self.napp.check_storehouse_consistency(switch) |
|
| 364 | mock_install_flows.assert_called() |
|
| 365 | ||
| 366 | @patch('napps.kytos.flow_manager.main.Main._install_flows') |
|
| 367 | @patch('napps.kytos.flow_manager.main.FlowFactory.get_class') |
|
| 368 | @patch("napps.kytos.flow_manager.main.StoreHouse.save_flow") |
|
| 369 | def test_no_strict_delete(self, *args): |
|
| 370 | """Test the non-strict matching method. |
|
| 371 | ||
| 372 | Test non-strict matching to delete a Flow using a cookie. |
|
| 373 | """ |
|
| 374 | (mock_save_flow, _, _) = args |
|
| 375 | dpid = "00:00:00:00:00:00:00:01" |
|
| 376 | switch = get_switch_mock(dpid, 0x04) |
|
| 377 | switch.id = dpid |
|
| 378 | stored_flow = { |
|
| 379 | "command": "add", |
|
| 380 | "flow": { |
|
| 381 | "actions": [ |
|
| 382 | { |
|
| 383 | "action_type": "set_vlan", |
|
| 384 | "vlan_id": 300 |
|
| 385 | } |
|
| 386 | ], |
|
| 387 | "cookie": 6191162389751548793, |
|
| 388 | "match": { |
|
| 389 | "dl_vlan": 300, |
|
| 390 | "in_port": 1 |
|
| 391 | } |
|
| 392 | } |
|
| 393 | } |
|
| 394 | stored_flow2 = { |
|
| 395 | "command": "add", |
|
| 396 | "flow": { |
|
| 397 | "actions": [], |
|
| 398 | "cookie": 4961162389751548787, |
|
| 399 | "match": { |
|
| 400 | "in_port": 2 |
|
| 401 | } |
|
| 402 | } |
|
| 403 | } |
|
| 404 | flow_to_install = { |
|
| 405 | "cookie": 6191162389751548793, |
|
| 406 | "cookie_mask": 18446744073709551615 |
|
| 407 | } |
|
| 408 | flow_list = {"flow_list": [stored_flow, stored_flow2]} |
|
| 409 | command = "delete" |
|
| 410 | self.napp.stored_flows = {dpid: flow_list} |
|
| 411 | ||
| 412 | self.napp._store_changed_flows(command, flow_to_install, switch) |
|
| 413 | mock_save_flow.assert_called() |
|
| 414 | self.assertEqual(len(self.napp.stored_flows), 1) |
|
| 415 | ||
| 416 | @patch('napps.kytos.flow_manager.main.Main._install_flows') |
|
| 417 | @patch('napps.kytos.flow_manager.main.FlowFactory.get_class') |
|
| @@ 459-500 (lines=42) @@ | ||
| 456 | mock_save_flow.assert_called() |
|
| 457 | self.assertEqual(len(self.napp.stored_flows[dpid]['flow_list']), 2) |
|
| 458 | ||
| 459 | @patch('napps.kytos.flow_manager.main.Main._install_flows') |
|
| 460 | @patch('napps.kytos.flow_manager.main.FlowFactory.get_class') |
|
| 461 | @patch("napps.kytos.flow_manager.main.StoreHouse.save_flow") |
|
| 462 | def test_no_strict_delete_with_ipv4_fail(self, *args): |
|
| 463 | """Test the non-strict matching method. |
|
| 464 | ||
| 465 | Test non-strict Fail case matching to delete a Flow using IPv4. |
|
| 466 | """ |
|
| 467 | (mock_save_flow, _, _) = args |
|
| 468 | dpid = "00:00:00:00:00:00:00:01" |
|
| 469 | switch = get_switch_mock(dpid, 0x04) |
|
| 470 | switch.id = dpid |
|
| 471 | stored_flow = { |
|
| 472 | "command": "add", |
|
| 473 | "flow": { |
|
| 474 | "priority": 10, |
|
| 475 | "cookie": 84114904, |
|
| 476 | "match": { |
|
| 477 | "ipv4_src": "192.168.2.1", |
|
| 478 | "ipv4_dst": "192.168.0.2", |
|
| 479 | }, |
|
| 480 | "actions": [] |
|
| 481 | } |
|
| 482 | } |
|
| 483 | stored_flow2 = { |
|
| 484 | "command": "add", |
|
| 485 | "flow": { |
|
| 486 | "actions": [], |
|
| 487 | "cookie": 4961162389751548787, |
|
| 488 | "match": { |
|
| 489 | "in_port": 2 |
|
| 490 | } |
|
| 491 | } |
|
| 492 | } |
|
| 493 | flow_to_install = {"match": {"ipv4_src": '192.168.1.1/24'}} |
|
| 494 | flow_list = {"flow_list": [stored_flow, stored_flow2]} |
|
| 495 | command = "delete" |
|
| 496 | self.napp.stored_flows = {dpid: flow_list} |
|
| 497 | ||
| 498 | self.napp._store_changed_flows(command, flow_to_install, switch) |
|
| 499 | mock_save_flow.assert_called() |
|
| 500 | self.assertEqual(len(self.napp.stored_flows[dpid]['flow_list']), 3) |
|
| 501 | ||
| @@ 416-457 (lines=42) @@ | ||
| 413 | mock_save_flow.assert_called() |
|
| 414 | self.assertEqual(len(self.napp.stored_flows), 1) |
|
| 415 | ||
| 416 | @patch('napps.kytos.flow_manager.main.Main._install_flows') |
|
| 417 | @patch('napps.kytos.flow_manager.main.FlowFactory.get_class') |
|
| 418 | @patch("napps.kytos.flow_manager.main.StoreHouse.save_flow") |
|
| 419 | def test_no_strict_delete_with_ipv4(self, *args): |
|
| 420 | """Test the non-strict matching method. |
|
| 421 | ||
| 422 | Test non-strict matching to delete a Flow using IPv4. |
|
| 423 | """ |
|
| 424 | (mock_save_flow, _, _) = args |
|
| 425 | dpid = "00:00:00:00:00:00:00:01" |
|
| 426 | switch = get_switch_mock(dpid, 0x04) |
|
| 427 | switch.id = dpid |
|
| 428 | stored_flow = { |
|
| 429 | "command": "add", |
|
| 430 | "flow": { |
|
| 431 | "priority": 10, |
|
| 432 | "cookie": 84114904, |
|
| 433 | "match": { |
|
| 434 | "ipv4_src": "192.168.1.120", |
|
| 435 | "ipv4_dst": "192.168.0.2", |
|
| 436 | }, |
|
| 437 | "actions": [] |
|
| 438 | } |
|
| 439 | } |
|
| 440 | stored_flow2 = { |
|
| 441 | "command": "add", |
|
| 442 | "flow": { |
|
| 443 | "actions": [], |
|
| 444 | "cookie": 4961162389751548787, |
|
| 445 | "match": { |
|
| 446 | "in_port": 2 |
|
| 447 | } |
|
| 448 | } |
|
| 449 | } |
|
| 450 | flow_to_install = {"match": {"ipv4_src": '192.168.1.1/24'}} |
|
| 451 | flow_list = {"flow_list": [stored_flow, stored_flow2]} |
|
| 452 | command = "delete" |
|
| 453 | self.napp.stored_flows = {dpid: flow_list} |
|
| 454 | ||
| 455 | self.napp._store_changed_flows(command, flow_to_install, switch) |
|
| 456 | mock_save_flow.assert_called() |
|
| 457 | self.assertEqual(len(self.napp.stored_flows[dpid]['flow_list']), 2) |
|
| 458 | ||
| 459 | @patch('napps.kytos.flow_manager.main.Main._install_flows') |
|
| 460 | @patch('napps.kytos.flow_manager.main.FlowFactory.get_class') |
|