From 5c6eb170878cefa12f717a62c31f7228d440e61e Mon Sep 17 00:00:00 2001 From: Koren Lev Date: Tue, 10 Oct 2017 18:08:39 +0300 Subject: release 1.1 for euphrates Change-Id: Iddc0e0148db7c72458b7fcdfcb7664e4aa609be0 Signed-off-by: Koren Lev --- .../fetch/cli_fetch/test_cli_fetch_host_pnics.py | 19 +++--- .../cli_fetch/test_cli_fetch_vservice_vnics.py | 36 ++++++---- .../cli_fetch/test_data/cli_fetch_host_pnics.py | 7 +- .../test_data/cli_fetch_vservice_vnics.py | 77 ++++++++++------------ 4 files changed, 76 insertions(+), 63 deletions(-) (limited to 'app/test/fetch/cli_fetch') diff --git a/app/test/fetch/cli_fetch/test_cli_fetch_host_pnics.py b/app/test/fetch/cli_fetch/test_cli_fetch_host_pnics.py index d9df2ac..ff7b5e3 100644 --- a/app/test/fetch/cli_fetch/test_cli_fetch_host_pnics.py +++ b/app/test/fetch/cli_fetch/test_cli_fetch_host_pnics.py @@ -7,6 +7,7 @@ # which accompanies this distribution, and is available at # # http://www.apache.org/licenses/LICENSE-2.0 # ############################################################################### +import copy import unittest from discover.fetchers.cli.cli_fetch_host_pnics import CliFetchHostPnics @@ -113,20 +114,22 @@ class TestCliFetchHostPnics(TestFetch): self.assertEqual(result, INTERFACE_DETAILS, "Can't get interface details") def test_handle_mac_address_line(self): - self.fetcher.handle_line(RAW_INTERFACE, MAC_ADDRESS_LINE) - self.assertEqual(RAW_INTERFACE["mac_address"], MAC_ADDRESS, - "Can't get the correct mac address") + interface = copy.deepcopy(RAW_INTERFACE) + self.fetcher.handle_line(interface, MAC_ADDRESS_LINE) + self.assertEqual(interface["mac_address"], MAC_ADDRESS, + "Can't get the correct MAC address") # Test failed, defect, result: addr: expected result: fe80::f816:3eff:fea1:eb73/64 - @unittest.SkipTest def test_handle_ipv6_address_line(self): - self.fetcher.handle_line(RAW_INTERFACE, IPV6_ADDRESS_LINE) - self.assertEqual(RAW_INTERFACE['IPv6 Address'], IPV6_ADDRESS, + interface = copy.deepcopy(RAW_INTERFACE) + self.fetcher.handle_line(interface, IPV6_ADDRESS_LINE) + self.assertEqual(interface['IPv6 Address'], IPV6_ADDRESS, "Can't get the correct ipv6 address") def test_handle_ipv4_address_line(self): - self.fetcher.handle_line(RAW_INTERFACE, IPV4_ADDRESS_LINE) - self.assertEqual(RAW_INTERFACE['IP Address'], IPV4_ADDRESS, + interface = copy.deepcopy(RAW_INTERFACE) + self.fetcher.handle_line(interface, IPV4_ADDRESS_LINE) + self.assertEqual(interface['IP Address'], IPV4_ADDRESS, "Can't get the correct ipv4 address") def test_set_interface_data(self): diff --git a/app/test/fetch/cli_fetch/test_cli_fetch_vservice_vnics.py b/app/test/fetch/cli_fetch/test_cli_fetch_vservice_vnics.py index e1334e3..a94727b 100644 --- a/app/test/fetch/cli_fetch/test_cli_fetch_vservice_vnics.py +++ b/app/test/fetch/cli_fetch/test_cli_fetch_vservice_vnics.py @@ -7,6 +7,8 @@ # which accompanies this distribution, and is available at # # http://www.apache.org/licenses/LICENSE-2.0 # ############################################################################### +import copy + from discover.fetchers.cli.cli_fetch_vservice_vnics import CliFetchVserviceVnics from test.fetch.test_fetch import TestFetch from test.fetch.cli_fetch.test_data.cli_fetch_vservice_vnics import * @@ -52,7 +54,9 @@ class TestCliFetchVserviceVnics(TestFetch): # reset methods self.fetcher.inv.get_by_id = original_get_by_id - self.assertEqual(result, [], "Can't get empty array when the host doesn't contain host_type") + self.assertEqual(result, [], + "Can't get empty array when the host " + "doesn't contain host_type") def test_get_with_compute_host(self): # store original methods @@ -66,14 +70,17 @@ class TestCliFetchVserviceVnics(TestFetch): # reset methods self.fetcher.inv.get_by_id = original_get_by_id - self.assertEqual(result, [], "Can't get empty array when the host type doesn't contain network") + self.assertEqual(result, [], + "Can't get empty array when the host type " + "doesn't contain network") def test_handle_service(self): # store original method original_run_fetch_lines = self.fetcher.run_fetch_lines original_set_interface_data = self.fetcher.set_interface_data # mock the method - self.fetcher.run_fetch_lines = MagicMock(return_value=IFCONFIG_RESULT) + self.fetcher.run_fetch_lines = \ + MagicMock(return_value=IP_ADDRESS_SHOW_RESULT) self.fetcher.set_interface_data = MagicMock() result = self.fetcher.handle_service(NETWORK_NODE['id'], SERVICE_ID) # reset method @@ -81,6 +88,8 @@ class TestCliFetchVserviceVnics(TestFetch): self.fetcher.set_interface_data = original_set_interface_data self.assertNotEqual(result, [], "Can't get interfaces data") + self.assertEqual(result[0].get("IPv6 Address"), IPV6_ADDRESS, + "incorrect IPv6 address") def test_set_interface_data(self): # store original methods @@ -93,33 +102,38 @@ class TestCliFetchVserviceVnics(TestFetch): self.fetcher.inv.get_by_id = MagicMock(return_value=VSERVICE) self.fetcher.inv.set = MagicMock() - self.fetcher.set_interface_data(VNIC) + vnic = copy.deepcopy(VNIC) + self.fetcher.set_interface_data(vnic) # reset methods self.fetcher.inv.get_by_field = original_get_by_field self.fetcher.inv.get_by_id = original_get_by_id self.fetcher.inv.set = original_set - self.assertIn("data", VNIC, "Can't set data") - self.assertIn("cidr", VNIC, "Can't set cidr") - self.assertIn("network", VNIC, "Can't set network") + self.assertIn("data", vnic, "Can't set data") + self.assertIn("cidr", vnic, "Can't set cidr") + self.assertIn("network", vnic, "Can't set network") def test_handle_mac_address_line(self): self.fetcher.handle_line(RAW_VNIC, MAC_ADDRESS_LINE) - self.assertEqual(RAW_VNIC['mac_address'], MAC_ADDRESS, "Can't get the correct mac address from the line") + self.assertEqual(RAW_VNIC['mac_address'], MAC_ADDRESS, + "Can't get the correct mac address from the line") def test_handle_ipv4_address_line(self): self.fetcher.handle_line(RAW_VNIC, IPV4_ADDRESS_LINE) - self.assertEqual(RAW_VNIC['IP Address'], IPV4_ADDRESS, "Can't get the correct ipv4 address from the line") + self.assertEqual(RAW_VNIC['IP Address'], IPV4_ADDRESS, + "Can't get the correct ipv4 address from the line") def test_handle_ipv6_address_line(self): self.fetcher.handle_line(RAW_VNIC, IPV6_ADDRESS_LINE) - self.assertEqual(RAW_VNIC['IPv6 Address'], IPV6_ADDRESS, "Can't get the correct ipv6 address from the line") + self.assertEqual(RAW_VNIC['IPv6 Address'], IPV6_ADDRESS, + "Can't get the correct ipv6 address from the line") def test_get_net_size(self): size = self.fetcher.get_net_size(NET_MASK_ARRAY) self.assertEqual(size, SIZE, "Can't get the size of network by netmask") def test_get_cidr_for_vnic(self): - cidr = self.fetcher.get_cidr_for_vnic(VNIC) + vnic = copy.deepcopy(VNIC) + cidr = self.fetcher.get_cidr_for_vnic(vnic) self.assertEqual(cidr, CIDR, "the cidr info is wrong") diff --git a/app/test/fetch/cli_fetch/test_data/cli_fetch_host_pnics.py b/app/test/fetch/cli_fetch/test_data/cli_fetch_host_pnics.py index 316c68a..bb369d1 100644 --- a/app/test/fetch/cli_fetch/test_data/cli_fetch_host_pnics.py +++ b/app/test/fetch/cli_fetch/test_data/cli_fetch_host_pnics.py @@ -51,7 +51,7 @@ INTERFACE_DETAILS = { "state": "UP" } -MAC_ADDRESS_LINE = "eno16777728 Link encap:Ethernet HWaddr 00:50:56:ac:e8:97 " +MAC_ADDRESS_LINE = " link/ether 00:50:56:ac:e8:97 brd ff:ff:ff:ff:ff:ff" MAC_ADDRESS = "00:50:56:ac:e8:97" RAW_INTERFACE = { "host": "node-6.cisco.com", @@ -132,9 +132,10 @@ INTERFACE = { INTERFACES_GET_RESULTS = [INTERFACE] -IPV6_ADDRESS_LINE = " inet6 addr: fe80::f816:3eff:fea1:eb73/64 Scope:Link" +IPV6_ADDRESS_LINE = " inet6 fe80::f816:3eff:fea1:eb73/64 " \ + "scope global mngtmpaddr dynamic" IPV6_ADDRESS = "fe80::f816:3eff:fea1:eb73/64" -IPV4_ADDRESS_LINE = " inet addr:172.16.13.2 Bcast:172.16.13.255 Mask:255.255.255.0" +IPV4_ADDRESS_LINE = " inet 172.16.13.2/24 brd 10.56.20.255 scope global eth0" IPV4_ADDRESS = "172.16.13.2" ETHTOOL_RESULT = [ diff --git a/app/test/fetch/cli_fetch/test_data/cli_fetch_vservice_vnics.py b/app/test/fetch/cli_fetch/test_data/cli_fetch_vservice_vnics.py index bef0ed2..15261f1 100644 --- a/app/test/fetch/cli_fetch/test_data/cli_fetch_vservice_vnics.py +++ b/app/test/fetch/cli_fetch/test_data/cli_fetch_vservice_vnics.py @@ -157,26 +157,25 @@ NET_MASK_ARRAY = ["255", "255", "255", "0"] SIZE = '24' VNIC = { - "IP Address": "172.16.13.2", - "IPv6 Address": "fe80::f816:3eff:fea1:eb73/64", + "IP Address": "10.56.20.80", + "IPv6 Address": "2001:420:4482:24c1:250:56ff:feac:502a", "host": "node-6.cisco.com", - "id": "tapa68b2627-a1", + "id": "eth0", "lines": [ - "Link encap:Ethernet HWaddr fa:16:3e:a1:eb:73", - "inet addr:172.16.13.2 Bcast:172.16.13.255 Mask:255.255.255.0", - "inet6 addr: fe80::f816:3eff:fea1:eb73/64 Scope:Link", - "UP BROADCAST RUNNING MULTICAST MTU:1450 Metric:1", - "RX packets:28 errors:0 dropped:35 overruns:0 frame:0", - "TX packets:8 errors:0 dropped:0 overruns:0 carrier:0", - "collisions:0 txqueuelen:0", - "RX bytes:4485 (4.4 KB) TX bytes:648 (648.0 B)", - "" + " mtu 1500 qdisc pfifo_fast state UP group default qlen 1000", + "link/ether 00:50:56:ac:50:2a brd ff:ff:ff:ff:ff:ff", + "inet 10.56.20.80/24 brd 10.56.20.255 scope global eth0", + "valid_lft forever preferred_lft forever", + "inet6 2001:420:4482:24c1:250:56ff:feac:502a/64 scope global mngtmpaddr dynamic", + "valid_lft 2591971sec preferred_lft 604771sec", + "inet6 fe80::250:56ff:feac:502a/64 scope link", + "valid_lft forever preferred_lft forever" ], - "mac_address": "fa:16:3e:a1:eb:73", + "mac_address": "00:50:56:ac:50:2a", "master_parent_id": "qdhcp-8673c48a-f137-4497-b25d-08b7b218fd17", "master_parent_type": "vservice", "name": "tapa68b2627-a1", - "netmask": "255.255.255.0", + "netmask": "24", "parent_id": "qdhcp-8673c48a-f137-4497-b25d-08b7b218fd17-vnics", "parent_text": "vNICs", "parent_type": "vnics_folder", @@ -190,7 +189,7 @@ RAW_VNIC = { "lines": [], "master_parent_id": "qdhcp-8673c48a-f137-4497-b25d-08b7b218fd17", "master_parent_type": "vservice", - "name": "tapa68b2627-a1", + "name": "eth0", "parent_id": "qdhcp-8673c48a-f137-4497-b25d-08b7b218fd17-vnics", "parent_text": "vNICs", "parent_type": "vnics_folder", @@ -276,35 +275,31 @@ VSERVICE = { } -CIDR = "172.16.13.0/24" +CIDR = "10.56.20.0/24" -IFCONFIG_RESULT = [ - "lo Link encap:Local Loopback ", - " inet addr:127.0.0.1 Mask:255.0.0.0", - " inet6 addr: ::1/128 Scope:Host", - " UP LOOPBACK RUNNING MTU:65536 Metric:1", - " RX packets:0 errors:0 dropped:0 overruns:0 frame:0", - " TX packets:0 errors:0 dropped:0 overruns:0 carrier:0", - " collisions:0 txqueuelen:0 ", - " RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)", - "", - "tapa68b2627-a1 Link encap:Ethernet HWaddr fa:16:3e:a1:eb:73 ", - " inet addr:172.16.13.2 Bcast:172.16.13.255 Mask:255.255.255.0", - " inet6 addr: fe80::f816:3eff:fea1:eb73/64 Scope:Link", - " UP BROADCAST RUNNING MULTICAST MTU:1450 Metric:1", - " RX packets:28 errors:0 dropped:35 overruns:0 frame:0", - " TX packets:8 errors:0 dropped:0 overruns:0 carrier:0", - " collisions:0 txqueuelen:0 ", - " RX bytes:4485 (4.4 KB) TX bytes:648 (648.0 B)", - "" +IP_ADDRESS_SHOW_RESULT = [ + "1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1", + " link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00", + " inet 127.0.0.1/8 scope host lo", + " valid_lft forever preferred_lft forever", + " inet6 ::1/128 scope host", + " valid_lft forever preferred_lft forever", + "2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000", + " link/ether 00:50:56:ac:50:2a brd ff:ff:ff:ff:ff:ff", + " inet 10.56.20.80/24 brd 10.56.20.255 scope global eth0", + " valid_lft forever preferred_lft forever", + " inet6 2001:420:4482:24c1:250:56ff:feac:502a/64 scope global mngtmpaddr dynamic", + " valid_lft 2591971sec preferred_lft 604771sec", + " inet6 fe80::250:56ff:feac:502a/64 scope link", + " valid_lft forever preferred_lft forever" ] -MAC_ADDRESS_LINE = "tapa68b2627-a1 Link encap:Ethernet HWaddr 00:50:56:ac:e8:97 " -MAC_ADDRESS = "00:50:56:ac:e8:97" -IPV6_ADDRESS_LINE = " inet6 addr: fe80::f816:3eff:fea1:eb73/64 Scope:Link" -IPV6_ADDRESS = "fe80::f816:3eff:fea1:eb73/64" -IPV4_ADDRESS_LINE = " inet addr:172.16.13.2 Bcast:172.16.13.255 Mask:255.255.255.0" -IPV4_ADDRESS = "172.16.13.2" +MAC_ADDRESS_LINE = " link/ether 00:50:56:ac:50:2a brd ff:ff:ff:ff:ff:ff" +MAC_ADDRESS = "00:50:56:ac:50:2a" +IPV6_ADDRESS_LINE = " inet6 2001:420:4482:24c1:250:56ff:feac:502a/64 scope global mngtmpaddr dynamic" +IPV6_ADDRESS = "2001:420:4482:24c1:250:56ff:feac:502a" +IPV4_ADDRESS_LINE = " inet 10.56.20.80/24 brd 10.56.20.255 scope global eth0" +IPV4_ADDRESS = "10.56.20.80" # functional test INPUT = "node-6.cisco.com" -- cgit 1.2.3-korg