|
@@ 1884-1925 (lines=42) @@
|
| 1881 |
|
content={"1": "FailoverEvent1"} |
| 1882 |
|
) |
| 1883 |
|
|
| 1884 |
|
@patch("napps.kytos.mef_eline.main.emit_event") |
| 1885 |
|
@patch("napps.kytos.mef_eline.main.send_flow_mods_http") |
| 1886 |
|
def test_execute_swap_to_failover_exception( |
| 1887 |
|
self, |
| 1888 |
|
send_flow_mods_mock: MagicMock, |
| 1889 |
|
emit_main_mock: MagicMock, |
| 1890 |
|
): |
| 1891 |
|
"""Test handle_link_down method when an exception occurs.""" |
| 1892 |
|
evc1 = MagicMock(id="1") |
| 1893 |
|
good_path = MagicMock(id="GoodPath") |
| 1894 |
|
bad_path = MagicMock(id="BadPath") |
| 1895 |
|
evc1.current_path = bad_path |
| 1896 |
|
evc1.failover_path = good_path |
| 1897 |
|
evc2 = MagicMock(id="2") |
| 1898 |
|
|
| 1899 |
|
self.napp.prepare_swap_to_failover_flow = { |
| 1900 |
|
evc1: {"1": ["Flow1"]}, |
| 1901 |
|
evc2: None |
| 1902 |
|
}.get |
| 1903 |
|
|
| 1904 |
|
self.napp.prepare_swap_to_failover_event = { |
| 1905 |
|
evc1: "FailoverEvent1", |
| 1906 |
|
}.get |
| 1907 |
|
|
| 1908 |
|
send_flow_mods_mock.side_effect = FlowModException( |
| 1909 |
|
"Flowmod failed to send" |
| 1910 |
|
) |
| 1911 |
|
|
| 1912 |
|
success, failure = self.napp.execute_swap_to_failover([evc1, evc2]) |
| 1913 |
|
|
| 1914 |
|
assert success == [] |
| 1915 |
|
assert failure == [evc1, evc2] |
| 1916 |
|
|
| 1917 |
|
send_flow_mods_mock.assert_called_with( |
| 1918 |
|
{"1": ["Flow1"]}, |
| 1919 |
|
"install" |
| 1920 |
|
) |
| 1921 |
|
|
| 1922 |
|
assert evc1.current_path == bad_path |
| 1923 |
|
assert evc1.failover_path == good_path |
| 1924 |
|
|
| 1925 |
|
emit_main_mock.assert_not_called() |
| 1926 |
|
|
| 1927 |
|
@patch("napps.kytos.mef_eline.main.emit_event") |
| 1928 |
|
@patch("napps.kytos.mef_eline.main.send_flow_mods_http") |
|
@@ 1841-1881 (lines=41) @@
|
| 1838 |
|
evc6.as_dict(), |
| 1839 |
|
]) |
| 1840 |
|
|
| 1841 |
|
@patch("napps.kytos.mef_eline.main.emit_event") |
| 1842 |
|
@patch("napps.kytos.mef_eline.main.send_flow_mods_http") |
| 1843 |
|
def test_execute_swap_to_failover( |
| 1844 |
|
self, |
| 1845 |
|
send_flow_mods_mock: MagicMock, |
| 1846 |
|
emit_main_mock: MagicMock, |
| 1847 |
|
): |
| 1848 |
|
"""Test execute_swap_to_failover method.""" |
| 1849 |
|
evc1 = MagicMock(id="1") |
| 1850 |
|
good_path = MagicMock(id="GoodPath") |
| 1851 |
|
bad_path = MagicMock(id="BadPath") |
| 1852 |
|
evc1.current_path = bad_path |
| 1853 |
|
evc1.failover_path = good_path |
| 1854 |
|
evc2 = MagicMock(id="2") |
| 1855 |
|
|
| 1856 |
|
self.napp.prepare_swap_to_failover_flow = { |
| 1857 |
|
evc1: {"1": ["Flow1"]}, |
| 1858 |
|
evc2: None |
| 1859 |
|
}.get |
| 1860 |
|
|
| 1861 |
|
self.napp.prepare_swap_to_failover_event = { |
| 1862 |
|
evc1: "FailoverEvent1", |
| 1863 |
|
}.get |
| 1864 |
|
|
| 1865 |
|
success, failure = self.napp.execute_swap_to_failover([evc1, evc2]) |
| 1866 |
|
|
| 1867 |
|
assert success == [evc1] |
| 1868 |
|
assert failure == [evc2] |
| 1869 |
|
|
| 1870 |
|
send_flow_mods_mock.assert_called_with( |
| 1871 |
|
{"1": ["Flow1"]}, |
| 1872 |
|
"install" |
| 1873 |
|
) |
| 1874 |
|
|
| 1875 |
|
assert evc1.current_path == good_path |
| 1876 |
|
assert evc1.failover_path == bad_path |
| 1877 |
|
|
| 1878 |
|
emit_main_mock.assert_called_with( |
| 1879 |
|
self.napp.controller, |
| 1880 |
|
"failover_link_down", |
| 1881 |
|
content={"1": "FailoverEvent1"} |
| 1882 |
|
) |
| 1883 |
|
|
| 1884 |
|
@patch("napps.kytos.mef_eline.main.emit_event") |