sonic-swss
sonic-swss copied to clipboard
[tests/conftest.py]: new API runcmd_interactive.
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
retest vs please
@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.
/AzurePipelines run
Commenter does not have sufficient privileges for PR 1424 in repo Azure/sonic-swss
@jleveque : How can I run only 'Azure.sonic-swss'. thx