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

Bug: test_gnmi_config_db.py::test_gnmi_configdb_full_01 uses wrong implementation of GNOI Reboot. #17436

Open
hdwhdw opened this issue Mar 10, 2025 · 0 comments
Assignees

Comments

@hdwhdw
Copy link
Contributor

hdwhdw commented Mar 10, 2025

Is it platform specific

generic

Importance or Severity

Medium

Description of the bug

GNOI System Reboot was implemented as a "config reload" at some point. There is no dependency on this feature except for the test test_gnmi_config_db.py::test_gnmi_configdb_full_01.

More specifically, GNOI.System.Reboot was implemented as a config reload in sonic-net/sonic-gnmi#7. This is not aligned with GNOI official definition and fortunately has no prod dependencies.

This test is blocking efforts in merging the real reboot, as in sonic-net/sonic-buildimage#20786

We should rewrite the test to use a real config reload in the step.

Steps to Reproduce

Pull sonic-net/sonic-buildimage#20786, sonic-net/sonic-gnmi#308 and sonic-host-services changes for gNOI Warm Reboot by rkavitha-hcl · Pull Request #191 · sonic-net/sonic-host-services into the latest buildimage and run the test.

Actual Behavior and Expected Behavior

The test fail with "06:57:30 helper.gnoi_reboot L0433 ERROR | panic: rpc error: code = InvalidArgument desc = Invalid request: reboot method is not supported."

The test should pass

Relevant log output

Running test case with Python:
Python 3.8.10
Run: python3 -m pytest gnmi/test_gnmi_configdb.py      --inventory=../ansible/veos_vtb --host-pattern=all --testbed=vms-kvm-t1-lag     --testbed_file=../ansible/vtestbed.yaml --log-cli-level=warning --log-file-level=debug     --kube_master=unset --showlocals --assert=plain --show-capture=no -rav     --ignore=ptftests --ignore=acstests --ignore=saitests --ignore=scripts --ignore=k8s --ignore=sai_qualify      --log-file='logs/gnmi/test_gnmi_configdb|||1.log' --junit-xml='logs/gnmi/test_gnmi_configdb|||1.xml'   --allow_recover --topology=t1,any --device_type=vs --maxfail=1
============================= test session starts ==============================
platform linux -- Python 3.8.10, pytest-7.4.0, pluggy-1.5.0
ansible: 2.13.13
rootdir: /var/src/sonic-mgmt/tests
configfile: pytest.ini
plugins: html-4.1.1, xdist-1.28.0, stress-1.0.1, forked-1.6.0, repeat-0.9.3, ansible-4.0.0, metadata-3.1.1, allure-pytest-2.8.22

----------------------------- live log collection ------------------------------
06:52:57 testbed.get_testbed_type                 L0263 WARNING| Unsupported testbed type - force10-7nodes
06:52:58 testbed.get_testbed_type                 L0263 WARNING| Unsupported testbed type - force10-7nodes
collected 13 items

gnmi/test_gnmi_configdb.py::test_gnmi_configdb_incremental_01 PASSED     [  7%]
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_incremental_02 PASSED     [ 15%]
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_polling_01[test_data0] PASSED [ 23%]
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_polling_01[test_data1] PASSED [ 30%]
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_polling_01[test_data2] PASSED [ 38%]
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_streaming_sample_01[test_data0] PASSED [ 46%]
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_streaming_sample_01[test_data1] PASSED [ 53%]
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_streaming_sample_01[test_data2] PASSED [ 61%]
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_streaming_onchange_01[test_data0] PASSED [ 69%]
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_streaming_onchange_01[test_data1] PASSED [ 76%]
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_streaming_onchange_01[test_data2] PASSED [ 84%]
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_streaming_onchange_02 PASSED [ 92%]
gnmi/test_gnmi_configdb.py::test_gnmi_configdb_full_01 
-------------------------------- live log call ---------------------------------
06:57:30 helper.gnoi_reboot                       L0433 ERROR  | panic: rpc error: code = InvalidArgument desc = Invalid request: reboot method is not supported.

goroutine 1 [running]:
github.com/sonic-net/sonic-gnmi/gnoi_client/system.Reboot(0xc00026b000, {0xb2bf58, 0xc0002e6000})
	/sonic/src/sonic-gnmi/gnoi_client/system/reboot.go:21 +0x1b9
main.main()
	/sonic/src/sonic-gnmi/gnoi_client/gnoi_client.go:39 +0x525
06:57:42 __init__.pytest_runtest_call             L0040 ERROR  | Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/_pytest/python.py", line 1788, in runtest
    self.ihook.pytest_pyfunc_call(pyfuncitem=self)
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/usr/local/lib/python3.8/dist-packages/_pytest/python.py", line 194, in pytest_pyfunc_call
    result = testfunction(**testargs)
  File "/var/src/sonic-mgmt/tests/gnmi/test_gnmi_configdb.py", line 282, in test_gnmi_configdb_full_01
    assert status == "down", "Full config failed to toggle interface %s status" % interface
AssertionError: Full config failed to toggle interface Ethernet0 status

FAILED                                                                   [100%]DEBUG:tests.conftest:[log_custom_msg] item: <Function test_gnmi_configdb_full_01>
INFO:root:Can not get Allure report URL. Please check logs


=================================== FAILURES ===================================
__________________________ test_gnmi_configdb_full_01 __________________________

duthosts = [<MultiAsicSonicHost vlab-03>], rand_one_dut_hostname = 'vlab-03'
ptfhost = <tests.common.devices.ptf.PTFHost object at 0x7f225c067ac0>

    def test_gnmi_configdb_full_01(duthosts, rand_one_dut_hostname, ptfhost):
        '''
        Verify GNMI native write, full config for configDB
        Toggle interface admin status
        '''
        duthost = duthosts[rand_one_dut_hostname]
        if duthost.is_supervisor_node():
            pytest.skip("gnmi test relies on port data not present on supervisor card '%s'" % rand_one_dut_hostname)
        interface = get_first_interface(duthost)
        assert interface is not None, "Invalid interface"
    
        # Get ASIC namespace and check interface
        if duthost.sonichost.is_multi_asic:
            for asic in duthost.frontend_asics:
                dic = get_sonic_cfggen_output(duthost, asic.namespace)
                if interface in dic["PORT"]:
                    break
        else:
            dic = get_sonic_cfggen_output(duthost)
    
        assert "PORT" in dic, "Failed to read running config"
        assert interface in dic["PORT"], "Failed to get interface %s" % interface
        assert "admin_status" in dic["PORT"][interface], "Failed to get interface %s" % interface
    
        # Update full config with GNMI
        dic["PORT"][interface]["admin_status"] = "down"
        filename = "full.txt"
        with open(filename, 'w') as file:
            json.dump(dic, file)
        ptfhost.copy(src=filename, dest='/root')
        delete_list = ["/sonic-db:CONFIG_DB/localhost/"]
        update_list = ["/sonic-db:CONFIG_DB/localhost/:@/root/%s" % filename]
        gnmi_set(duthost, ptfhost, delete_list, update_list, [])
        # Check interface status and gnmi_get result
        status = get_interface_status(duthost, "admin_status", interface)
        assert status == "up", "Port status is changed"
        # GNOI reboot
        gnoi_reboot(duthost, 0, 0, "abc")
        pytest_assert(
            wait_until(600, 10, 0, duthost.critical_services_fully_started),
            "All critical services should be fully started!")
        wait_critical_processes(duthost)
        pytest_assert(
            wait_until(300, 10, 0, check_interface_status_of_up_ports, duthost),
            "Not all ports that are admin up on are operationally up")
        # Check interface status
        status = get_interface_status(duthost, "admin_status", interface)
>       assert status == "down", "Full config failed to toggle interface %s status" % interface
E       AssertionError: Full config failed to toggle interface Ethernet0 status

delete_list = ['/sonic-db:CONFIG_DB/localhost/']
dic        = {'AAA': {'accounting': {'login': 'tacacs+,local'}, 'authentication': {'login': 'tacacs+'}, 'authorization': {'login': ...led'}, 'dhcp_server': {'available_mem_threshold': '10.0', 'rate_limit_interval': '600', 'state': 'enabled'}, ...}, ...}
duthost    = <MultiAsicSonicHost vlab-03>
duthosts   = [<MultiAsicSonicHost vlab-03>]
file       = <_io.TextIOWrapper name='full.txt' mode='w' encoding='UTF-8'>
filename   = 'full.txt'
interface  = 'Ethernet0'
ptfhost    = <tests.common.devices.ptf.PTFHost object at 0x7f225c067ac0>
rand_one_dut_hostname = 'vlab-03'
status     = 'up'
update_list = ['/sonic-db:CONFIG_DB/localhost/:@/root/full.txt']

gnmi/test_gnmi_configdb.py:282: AssertionError
=============================== warnings summary ===============================
../../../../usr/local/lib/python3.8/dist-packages/paramiko/transport.py:236
  /usr/local/lib/python3.8/dist-packages/paramiko/transport.py:236: CryptographyDeprecationWarning: Blowfish has been deprecated
    "class": algorithms.Blowfish,

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
- generated xml file: /var/src/sonic-mgmt/tests/logs/gnmi/test_gnmi_configdb|||1.xml -
=========================== short test summary info ============================
FAILED gnmi/test_gnmi_configdb.py::test_gnmi_configdb_full_01 - AssertionErro...
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
============= 1 failed, 12 passed, 1 warning in 310.71s (0:05:10) ==============

Output of show version

Attach files (if any)

No response

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

No branches or pull requests

2 participants