tests: add interactive_sync adapted to shell

This commit is contained in:
Francisco Molina
2020-03-17 17:23:27 +01:00
parent d57c39f09f
commit a31003a23c
6 changed files with 55 additions and 14 deletions
+23 -9
View File
@@ -9,19 +9,33 @@
import pexpect
def test_utils_interactive_sync(child, retries, delay):
"""Synchronisation for 'test_utils_interactive_sync' function.
def _test_utils_interactive_sync(child, retries, delay, ready_cmd='r',
ready_exp='READY'):
Interacts through input to wait for node being ready.
"""
for _ in range(0, retries):
child.sendline('r')
ret = child.expect_exact(['READY', pexpect.TIMEOUT], timeout=delay)
for _ in range(retries):
child.sendline(ready_cmd)
ret = child.expect_exact([ready_exp, pexpect.TIMEOUT], timeout=delay)
if ret == 0:
break
else:
# Last call to make it fail her,
child.expect_exact('READY', timeout=0)
# Last call to make it fail here,
child.expect_exact(ready_exp, timeout=0)
def test_utils_interactive_sync(child, retries, delay):
"""Synchronization for 'test_utils_interactive_sync' function
Interacts through input to wait for node being ready.
"""
_test_utils_interactive_sync(child, retries, delay)
child.sendline('s')
child.expect_exact('START')
def test_utils_interactive_sync_shell(child, retries, delay):
"""Synchronization `shell` and `test_utils_interactive_sync` modules are
used ('test_utils_interactive_sync' function is not)
Interacts through input to wait for node being ready.
"""
_test_utils_interactive_sync(child, retries, delay, '\n', '>')