sonic-swss icon indicating copy to clipboard operation
sonic-swss copied to clipboard

[tests/conftest.py]: new API runcmd_interactive.

Open praveen-li opened this issue 5 years ago • 5 comments

Changes: -- new API runcmd_interactive to execute a command in interactive mode. Usage: Say in a Test, we want to run "config save" and want to pass confirmation later.

Signed-off-by: Praveen Chaudhary [email protected]

What I did Changes: -- new API runcmd_interactive to execute a command in interactive mode. Usage: Say in a Test, we want to run "config save" and want to pass confirmation later.

Why I did it Need such command for tests like below:

                exitCode, child = self.dvs.runcmd_interactive('config save')
                # -- AcquireLock.
                child.settimeout(3)
                out = str(child.recv(RECV_SIZE))
                assert 'continue' in out
                # -- send No
                child.send("N"+"\n")
                out = str(child.recv(RECV_SIZE))
                assert 'Aborted' in out
                child.close()

How I verified it Wrote test which uses it, for lock in configDB. These tests are not pushed in Azure but we need interactive command to run better tests anyways.

~/praveen/sonic-swss/tests$ sudo pytest --pdb --dvsname=vs-jk test_config_lock.py --junitxml=report.xml
============================================================ test session starts ============================================================
platform linux2 -- Python 2.7.17, pytest-3.3.0, py-1.8.0, pluggy-0.6.0
rootdir: /home/falco/praveen/sonic-swss/tests, inifile:
collected 5 items

test_config_lock.py .....                                                                                                             [100%]

------------------------------------ generated xml file: /home/falco/praveen/sonic-swss/tests/report.xml ------------------------------------
======================================================== 5 passed in 108.65 seconds =========================================================

Details if related

praveen-li avatar Aug 31 '20 17:08 praveen-li

retest vs please

praveen-li avatar Sep 15 '20 00:09 praveen-li

@lguohan kindly review. This API to run command in interactive mode will be useful for tests. Thx.

-- new API runcmd_interactive to execute a command in interactive mode. Usage: Say in a Test, we want to run "config save" and want to pass confirmation later.

praveen-li avatar Mar 04 '21 06:03 praveen-li

/AzurePipelines run

praveen-li avatar Mar 05 '21 20:03 praveen-li

Commenter does not have sufficient privileges for PR 1424 in repo Azure/sonic-swss

azure-pipelines[bot] avatar Mar 05 '21 20:03 azure-pipelines[bot]

@jleveque : How can I run only 'Azure.sonic-swss'. thx

praveen-li avatar Mar 05 '21 20:03 praveen-li