tests: Allow more VMs to be used that there are screen lines

curses prints were causing parallel-vm.py to terminate if there were too
many VMs to fit into the screen. For now, simply hide any VMs from the
live status if there is not sufficient room for them.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Jouni Malinen 2023-01-20 19:46:32 +02:00 committed by Jouni Malinen
parent 831be65149
commit a70a4672d8

View file

@ -201,12 +201,18 @@ def vm_read_stderr(vm):
raise raise
def vm_next_step(_vm, scr, test_queue): def vm_next_step(_vm, scr, test_queue):
scr.move(_vm['idx'] + 1, 10) max_y, max_x = scr.getmaxyx()
scr.clrtoeol() status_line = num_servers + 1
if status_line >= max_y:
status_line = max_y - 1
if _vm['idx'] + 1 < status_line:
scr.move(_vm['idx'] + 1, 10)
scr.clrtoeol()
if not test_queue: if not test_queue:
_vm['proc'].stdin.write(b'\n') _vm['proc'].stdin.write(b'\n')
_vm['proc'].stdin.flush() _vm['proc'].stdin.flush()
scr.addstr("shutting down") if _vm['idx'] + 1 < status_line:
scr.addstr("shutting down")
logger.info("VM[%d] shutting down" % _vm['idx']) logger.info("VM[%d] shutting down" % _vm['idx'])
return return
(name, count) = test_queue.pop(0) (name, count) = test_queue.pop(0)
@ -214,11 +220,16 @@ def vm_next_step(_vm, scr, test_queue):
_vm['current_count'] = count _vm['current_count'] = count
_vm['proc'].stdin.write(name.encode() + b'\n') _vm['proc'].stdin.write(name.encode() + b'\n')
_vm['proc'].stdin.flush() _vm['proc'].stdin.flush()
scr.addstr(name) if _vm['idx'] + 1 < status_line:
scr.addstr(name)
logger.debug("VM[%d] start test %s" % (_vm['idx'], name)) logger.debug("VM[%d] start test %s" % (_vm['idx'], name))
def check_vm_start(scr, sel, test_queue): def check_vm_start(scr, sel, test_queue):
running = False running = False
max_y, max_x = scr.getmaxyx()
status_line = num_servers + 1
if status_line >= max_y:
status_line = max_y - 1
for i in range(num_servers): for i in range(num_servers):
if vm[i]['proc']: if vm[i]['proc']:
running = True running = True
@ -231,9 +242,10 @@ def check_vm_start(scr, sel, test_queue):
num_starting = num_vm_starting() num_starting = num_vm_starting()
if vm[i]['cmd'] and len(test_queue) > num_starting and \ if vm[i]['cmd'] and len(test_queue) > num_starting and \
num_starting < max_start: num_starting < max_start:
scr.move(i + 1, 10) if i + 1 < status_line:
scr.clrtoeol() scr.move(i + 1, 10)
scr.addstr(i + 1, 10, "starting VM") scr.clrtoeol()
scr.addstr(i + 1, 10, "starting VM")
start_vm(vm[i], sel) start_vm(vm[i], sel)
return True, True return True, True
@ -244,12 +256,18 @@ def vm_terminated(_vm, scr, sel, test_queue):
for stream in [_vm['proc'].stdout, _vm['proc'].stderr]: for stream in [_vm['proc'].stdout, _vm['proc'].stderr]:
sel.unregister(stream) sel.unregister(stream)
_vm['proc'] = None _vm['proc'] = None
scr.move(_vm['idx'] + 1, 10) max_y, max_x = scr.getmaxyx()
scr.clrtoeol() status_line = num_servers + 1
if status_line >= max_y:
status_line = max_y - 1
if _vm['idx'] + 1 < status_line:
scr.move(_vm['idx'] + 1, 10)
scr.clrtoeol()
log = '{}/{}.srv.{}/console'.format(dir, timestamp, _vm['idx'] + 1) log = '{}/{}.srv.{}/console'.format(dir, timestamp, _vm['idx'] + 1)
with open(log, 'r') as f: with open(log, 'r') as f:
if "Kernel panic" in f.read(): if "Kernel panic" in f.read():
scr.addstr("kernel panic") if _vm['idx'] + 1 < status_line:
scr.addstr("kernel panic")
logger.info("VM[%d] kernel panic" % _vm['idx']) logger.info("VM[%d] kernel panic" % _vm['idx'])
updated = True updated = True
if test_queue: if test_queue:
@ -258,21 +276,26 @@ def vm_terminated(_vm, scr, sel, test_queue):
if _vm['proc']: if _vm['proc']:
num_vm += 1 num_vm += 1
if len(test_queue) > num_vm: if len(test_queue) > num_vm:
scr.addstr("unexpected exit") if _vm['idx'] + 1 < status_line:
scr.addstr("unexpected exit")
logger.info("VM[%d] unexpected exit" % i) logger.info("VM[%d] unexpected exit" % i)
updated = True updated = True
return updated return updated
def update_screen(scr, total_tests): def update_screen(scr, total_tests):
scr.move(num_servers + 1, 10) max_y, max_x = scr.getmaxyx()
status_line = num_servers + 1
if status_line >= max_y:
status_line = max_y - 1
scr.move(status_line, 10)
scr.clrtoeol() scr.clrtoeol()
scr.addstr("{} %".format(int(100.0 * (total_passed + total_failed + total_skipped) / total_tests))) scr.addstr("{} %".format(int(100.0 * (total_passed + total_failed + total_skipped) / total_tests)))
scr.addstr(num_servers + 1, 20, scr.addstr(status_line, 20,
"TOTAL={} STARTED={} PASS={} FAIL={} SKIP={}".format(total_tests, total_started, total_passed, total_failed, total_skipped)) "TOTAL={} STARTED={} PASS={} FAIL={} SKIP={}".format(total_tests, total_started, total_passed, total_failed, total_skipped))
global all_failed global all_failed
max_y, max_x = scr.getmaxyx() max_y, max_x = scr.getmaxyx()
max_lines = max_y - num_servers - 3 max_lines = max_y - num_servers - 3
if len(all_failed) > 0 and max_lines > 0: if len(all_failed) > 0 and max_lines > 0 and num_servers + 2 < max_y - 1:
scr.move(num_servers + 2, 0) scr.move(num_servers + 2, 0)
scr.addstr("Last failed test cases:") scr.addstr("Last failed test cases:")
if max_lines >= len(all_failed): if max_lines >= len(all_failed):
@ -280,6 +303,8 @@ def update_screen(scr, total_tests):
count = 0 count = 0
for i in range(len(all_failed) - max_lines, len(all_failed)): for i in range(len(all_failed) - max_lines, len(all_failed)):
count += 1 count += 1
if num_servers + 2 + count >= max_y:
break
scr.move(num_servers + 2 + count, 0) scr.move(num_servers + 2 + count, 0)
scr.addstr(all_failed[i]) scr.addstr(all_failed[i])
scr.clrtoeol() scr.clrtoeol()
@ -302,13 +327,18 @@ def show_progress(scr):
start_vm(vm[0], sel) start_vm(vm[0], sel)
scr.leaveok(1) scr.leaveok(1)
max_y, max_x = scr.getmaxyx()
status_line = num_servers + 1
if status_line >= max_y:
status_line = max_y - 1
scr.addstr(0, 0, "Parallel test execution status", curses.A_BOLD) scr.addstr(0, 0, "Parallel test execution status", curses.A_BOLD)
for i in range(0, num_servers): for i in range(0, num_servers):
scr.addstr(i + 1, 0, "VM %d:" % (i + 1), curses.A_BOLD) if i + 1 < status_line:
status = "starting VM" if vm[i]['proc'] else "not yet started" scr.addstr(i + 1, 0, "VM %d:" % (i + 1), curses.A_BOLD)
scr.addstr(i + 1, 10, status) status = "starting VM" if vm[i]['proc'] else "not yet started"
scr.addstr(num_servers + 1, 0, "Total:", curses.A_BOLD) scr.addstr(i + 1, 10, status)
scr.addstr(num_servers + 1, 20, "TOTAL={} STARTED=0 PASS=0 FAIL=0 SKIP=0".format(total_tests)) scr.addstr(status_line, 0, "Total:", curses.A_BOLD)
scr.addstr(status_line, 20, "TOTAL={} STARTED=0 PASS=0 FAIL=0 SKIP=0".format(total_tests))
scr.refresh() scr.refresh()
while True: while True: