From: Adam King Date: Sat, 23 Sep 2023 16:57:06 +0000 (-0400) Subject: cephadm: add unit test for get_ipv6_address X-Git-Tag: v19.0.0~382^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4a826da317a79d045374f4452a692e87bec4596c;p=ceph.git cephadm: add unit test for get_ipv6_address I wanted to modify this function slightly to try to make both black and flake8 happy with it, so adding a unit test to make sure I don't break it. Signed-off-by: Adam King --- diff --git a/src/cephadm/tests/test_networks.py b/src/cephadm/tests/test_networks.py index 8d888468b6e4..83b908c14572 100644 --- a/src/cephadm/tests/test_networks.py +++ b/src/cephadm/tests/test_networks.py @@ -7,6 +7,7 @@ import pytest from tests.fixtures import with_cephadm_ctx, cephadm_fs, import_cephadm from cephadmlib.host_facts import _parse_ipv4_route, _parse_ipv6_route +from cephadmlib.net_utils import get_ipv6_address _cephadm = import_cephadm() @@ -226,6 +227,19 @@ class TestCommandListNetworks: def test_parse_ipv6_route(self, test_routes, test_ips, expected): assert _parse_ipv6_route(test_routes, test_ips) == expected + @mock.patch('cephadmlib.net_utils.read_file') + def test_get_ipv6_addr(self, _read_file): + proc_net_if_net6 = """fe80000000000000505400fffe347999 02 40 20 80 eth0 +fe80000000000000505400fffe04c154 03 40 20 80 eth1 +00000000000000000000000000000001 01 80 10 80 lo""" + _read_file.return_value = proc_net_if_net6 + + ipv6_addr = get_ipv6_address('eth0') + assert ipv6_addr == 'fe80::5054:ff:fe34:7999/64' + + ipv6_addr = get_ipv6_address('eth1') + assert ipv6_addr == 'fe80::5054:ff:fe04:c154/64' + @mock.patch('cephadmlib.host_facts.call_throws') @mock.patch('cephadmlib.host_facts.find_executable') def test_command_list_networks(self, _find_exe, _call_throws, cephadm_fs, capsys):