Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test]Fix sonic-ctrmgrd build error #11730

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ouxlwhu
Copy link
Contributor

@ouxlwhu ouxlwhu commented Aug 13, 2022

Signed-off-by: ouxiaolong ouxiaolong@asterfusion.com

Why I did it

Sometimes, building sonic-ctrmgrd fails like this:

============================= test session starts ==============================
platform linux -- Python 3.9.2, pytest-6.0.2, py-1.10.0, pluggy-0.13.0
rootdir: /sonic/src/sonic-ctrmgrd, configfile: pytest.ini
plugins: cov-2.10.1
collected 16 items

tests/container_startup_test.py .                                        [  6%]
tests/container_test.py ......                                           [ 43%]
tests/ctrmgr_iptables_test.py F                                          [ 50%]
tests/ctrmgr_tools_test.py .                                             [ 56%]
tests/ctrmgrd_test.py ...                                                [ 75%]
tests/kube_commands_test.py ....                                         [100%]

=================================== FAILURES ===================================
_________________________ TestIPTableUpdate.test_table _________________________

self = <tests.ctrmgr_iptables_test.TestIPTableUpdate object at 0x7f1347a0f1c0>
mock_proc = <MagicMock name='run' id='139720781667488'>

    @patch("ctrmgr_iptables.subprocess.run")
    def test_table(self, mock_proc):
        global current_rules, current_tc
    
        mock_proc.side_effect = mock_subproc_run
        for i, tc in test_data.items():
            print("----- Test: {} Start ------------------".format(i))
            current_tc = tc
            current_rules = tc["pre_rules"].copy()
    
            ctrmgr_iptables.DST_IP = ""
            ctrmgr_iptables.DST_PORT = ""
            ctrmgr_iptables.DST_FILE = os.path.join(
                    os.path.dirname(os.path.realpath(__file__)),
                    tc.get("conf_file", PROXY_FILE))
            ret = ctrmgr_iptables.iptable_proxy_rule_upd(tc["ip"], tc["port"])
            if "ret" in tc:
>               assert ret == tc["ret"]
E               AssertionError: assert '159.138.20.20:3128' == ''
E                 + 159.138.20.20:3128

tests/ctrmgr_iptables_test.py:171: AssertionError

This is because the domain name 'www.google.comx' sometimes unexpectedly resolves to an IP(an unfixed IP).

ouxl@aster241:~$ nslookup 
> www.google.comx
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   www.google.comx
Address: 159.138.20.20

How I did it

Change the domain name 'www.google.comx' in the file src/sonic-ctrmgrd/tests/ctrmgr_iptables_test.py to a domain name that will never be resolved an IP address .

How to verify it

Rebuild the module completely several times

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: ouxiaolong <ouxiaolong@asterfusion.com>
@ouxlwhu ouxlwhu requested a review from lguohan as a code owner August 13, 2022 04:49
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 13, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: ouxlwhu / name: Long Ou (58ae1ca)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant