Modify exception string to have more information

The original exception string was "Didn't spawn expected number
of processes" and it's not enough to understand why the test
failed.

Improve test_cleanup_network_namespaces_cleans_dhcp_and_l3_namespaces()
error message for timeout.

The improved error message now has expected process number, spawned
process number and process information.

Change-Id: Ie0c27316f0e26b3770724a8bc97e46adf7e32d4c
Closes-Bug: #1857035
This commit is contained in:
Choi-Sung-Hoon 2019-12-30 21:33:16 +00:00 committed by Slawek Kaplonski
parent 68f89c79c8
commit a0fbb3da9b
1 changed files with 14 additions and 4 deletions

View File

@ -15,6 +15,7 @@
import os
import eventlet
import mock
from neutron_lib import constants as n_const
@ -71,10 +72,19 @@ class NetnsCleanupTest(base.BaseSudoTestCase):
# killed during cleanup
procs_launched = self._launch_processes([l3_namespace, dhcp_namespace])
self.assertIsNot(procs_launched, 0)
common_utils.wait_until_true(
lambda: self._get_num_spawned_procs() == procs_launched,
timeout=15,
exception=Exception("Didn't spawn expected number of processes"))
try:
common_utils.wait_until_true(
lambda: self._get_num_spawned_procs() == procs_launched,
timeout=15)
except eventlet.Timeout:
num_spawned_procs = self._get_num_spawned_procs()
err_str = ("Expected number/spawned number: {0}/{1}\nProcess "
"information:\n".format(num_spawned_procs,
procs_launched))
cmd = ['ps', '-f', '-u', 'root']
err_str += utils.execute(cmd, run_as_root=True)
raise Exception(err_str)
netns_cleanup.cleanup_network_namespaces(self.conf)