提交 8385738e 编写于 作者: L Lukáš Doktor 提交者: Lucas Meneghel Rodrigues

qemu.tests.virtio_console: Exit background threads on test failure

Force exit background threads on thest failure.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 941ed7ed
......@@ -890,6 +890,7 @@ def run_virtio_console(test, params, env):
# Start loopback
error.context("Starting loopback", logging.info)
err = False
# TODO: Use normal LOOP_NONE when bz796048 is resolved.
guest_worker.cmd("virt.loopback(['%s'], ['%s'], %s, virt.LOOP_"
"RECONNECT_NONE)"
......@@ -970,6 +971,7 @@ def run_virtio_console(test, params, env):
raise error.TestFail("Sender thread died before interruption.")
if not threads[0].isAlive():
raise error.TestFail("Receiver thread died before interruption.")
try:
for i in xrange(no_repeats):
error.context("Interruption nr. %s" % i)
threads[1].sendidx = acceptable_loss
......@@ -1006,7 +1008,12 @@ def run_virtio_console(test, params, env):
logging.warn("Failed to get info from qtree: %s", inst)
exit_event.set()
vm.verify_kernel_crash()
raise error.TestFail('No data transfered after interruption.')
raise error.TestFail('No data transfered after'
'interruption.')
except Exception, inst:
err = True
logging.error('interrupted_loopback failed with exception: %s',
inst)
error.context("Stopping loopback", logging.info)
exit_event.set()
......@@ -1017,9 +1024,10 @@ def run_virtio_console(test, params, env):
if thread.isAlive():
workaround_unfinished_threads = True
logging.debug("Unable to destroy the thread %s", thread)
if not err: # Show only on success
logging.info('%d data sent; %d data received and verified; %d '
'interruptions %ds each.', threads[0].idx, threads[1].idx,
no_repeats, test_time)
'interruptions %ds each.', threads[0].idx,
threads[1].idx, no_repeats, test_time)
err = ""
if threads[0].ret_code:
err += "sender, "
......@@ -1128,6 +1136,7 @@ def run_virtio_console(test, params, env):
stats = array.array('f', [])
loads = utils.SystemLoad([(os.getpid(), 'autotest'),
(vm.get_pid(), 'VM'), 0])
try:
loads.start()
_time = time.time()
thread.start()
......@@ -1141,7 +1150,8 @@ def run_virtio_console(test, params, env):
thread.join()
if thread.ret_code:
no_errors += 1
logging.error("test_perf: error occured in thread %s", thread)
logging.error("test_perf: error occured in thread %s",
thread)
# Let the guest read-out all the remaining data
while not guest_worker._cmd("virt.poll('%s', %s)"
......@@ -1157,8 +1167,8 @@ def run_virtio_console(test, params, env):
logging.debug("Test ran %fs longer", _time)
stats = _process_stats(stats[1:], time_slice * 1048576)
logging.debug("Stats = %s", stats)
logging.info("Host -> Guest [MB/s] (min/med/max) = %.3f/%.3f/%.3f",
stats[0], stats[len(stats) / 2], stats[-1])
logging.info("Host -> Guest [MB/s] (min/med/max) = %.3f/%.3f/"
"%.3f", stats[0], stats[len(stats) / 2], stats[-1])
del thread
......@@ -1167,7 +1177,8 @@ def run_virtio_console(test, params, env):
stats = array.array('f', [])
guest_worker.cmd("virt.send_loop_init('%s', %d)"
% (port.name, buf_len), 30)
thread = qemu_virtio_port.ThRecv(port.sock, exit_event, buf_len)
thread = qemu_virtio_port.ThRecv(port.sock, exit_event,
buf_len)
thread.start()
loads.start()
guest_worker.cmd("virt.send_loop()", 10)
......@@ -1183,17 +1194,36 @@ def run_virtio_console(test, params, env):
thread.join()
if thread.ret_code:
no_errors += 1
logging.error("test_perf: error occured in thread %s", thread)
if (_time > time_slice): # Deviation is higher than 1 time_slice
logging.error("test_perf: error occured in thread %s",
thread)
# Deviation is higher than single time_slice
if (_time > time_slice):
logging.error(
"Test ran %fs longer which is more than one time slice", _time)
"Test ran %fs longer which is more than one time slice",
_time)
else:
logging.debug("Test ran %fs longer", _time)
stats = _process_stats(stats[1:], time_slice * 1048576)
logging.debug("Stats = %s", stats)
logging.info("Guest -> Host [MB/s] (min/med/max) = %.3f/%.3f/%.3f",
stats[0], stats[len(stats) / 2], stats[-1])
logging.info("Guest -> Host [MB/s] (min/med/max) = %.3f/%.3f/"
"%.3f", stats[0], stats[len(stats) / 2], stats[-1])
except Exception, inst:
logging.error("test_perf: Failed with %s, starting cleanup",
inst)
loads.stop()
try:
guest_worker.cmd("virt.exit_threads()", 10)
exit_event.set()
thread.join()
raise inst
except Exception, inst:
logging.error("test_perf: Critical failure, killing VM %s",
inst)
exit_event.set()
vm.destroy()
del thread
del exit_event
raise inst
del thread
del exit_event
cleanup(vm, guest_worker)
......@@ -1615,6 +1645,7 @@ def run_virtio_console(test, params, env):
loads = utils.SystemLoad([(os.getpid(), 'autotest'),
(vm.get_pid(), 'VM'), 0])
try:
loads.start()
try:
......@@ -1644,6 +1675,14 @@ def run_virtio_console(test, params, env):
logging.info("Bytes sent to client: %d", sent2)
logging.info("\n" + loads.get_cpu_status_string()[:-1])
loads.stop()
except Exception, inst:
logging.error('test_rw_notconnect_guest failed: %s', inst)
if loads:
loads.stop()
port.sock.settimeout(None)
guest_worker = qemu_virtio_port.GuestWorker(vm)
cleanup(vm, guest_worker)
raise inst
if (sent1 != sent2):
logging.warning("Inconsistent behavior: First sent %d bytes and "
"second sent %d bytes", sent1, sent2)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册