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

retry thrice finding devices with Ykush reset #3200

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions realsense2_camera/test/live_camera/rosci.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ def usage():
print( ' --device <> Run only on the specified device(s); list of devices separated by ',', No white spaces' )
print( ' e.g.: --device=d455,d435i,d585 (or) --device d455,d435i,d585 ')
print( ' Note: if --device option not used, tests run on all connected devices ')

sys.exit( 2 )

def command(dev_name, test=None):
cmd = ['pytest-3']
cmd += ['-s']
cmd += ['-m', ''.join(dev_name)]
if test:
cmd += ['-k', f'{test}']
cmd += ['-k', f'{test}']
cmd += [''.join(dir_live_tests)]
cmd += ['--debug']
cmd += [f'--junit-xml={logdir}/{dev_name.upper()}_pytest.xml']
Expand All @@ -70,7 +70,7 @@ def run_test(cmd, test=None, dev_name=None, stdout=None, append =False):
if test:
stdout = stdout + os.sep + str(dev_name.upper()) + '_' + test + '.log'
else:
stdout = stdout + os.sep + str(dev_name.upper()) + '_' + 'full.log'
stdout = stdout + os.sep + str(dev_name.upper()) + '_' + 'full.log'
if stdout is None:
sys.stdout.flush()
elif stdout and stdout != subprocess.PIPE:
Expand All @@ -93,10 +93,10 @@ def run_test(cmd, test=None, dev_name=None, stdout=None, append =False):
except Exception as e:
log.e("---Test Failed---")
log.w( "Error Exception:\n ",e )

finally:
if handle:
handle.close()
handle.close()
junit_xml_parsing(f'{dev_name.upper()}_pytest.xml')

def junit_xml_parsing(xml_file):
Expand All @@ -121,24 +121,29 @@ def junit_xml_parsing(xml_file):
new_xml = xml_file.split('.')[0]
tree.write(f'{logdir}/{new_xml}_refined.xml')

def find_devices_run_tests():
global logdir, device_set
def find_devices_run_tests():
from rspy import devices
global logdir, device_set, _device_by_sn
max_retry = 3

try:
os.makedirs( logdir, exist_ok=True )

from rspy import devices

#Update dict '_device_by_sn' from devices module of rspy
devices.query( hub_reset = hub_reset )
global _device_by_sn
while(max_retry and not devices._device_by_sn):
subprocess.run('ykushcmd ykush3 --reset', shell=True)
time.sleep(2.0)
devices.query( hub_reset = hub_reset )
max_retry -= 1

if not devices._device_by_sn:
assert False, 'No Camera device detected!'
else:
connected_devices = [device.name for device in devices._device_by_sn.values()]
log.i('Connected devices:', connected_devices)
connected_devices = [device.name for device in devices._device_by_sn.values()]
log.i('Connected devices:', connected_devices)

testname = regex if regex else None

if device_set:
#Loop in for user specified devices and run tests only on them
devices_not_found = []
Expand Down Expand Up @@ -183,7 +188,7 @@ def find_devices_run_tests():
regex = arg
elif opt == '--device':
device_set = arg.split(',')

find_devices_run_tests()

sys.exit( 0 )
Loading