Merge "[Functional] Add logging to the check test file function" into stable/train
This commit is contained in:
commit
6d45f25483
|
@ -23,6 +23,7 @@ import httplib2
|
||||||
import mock
|
import mock
|
||||||
from neutron_lib import worker as neutron_worker
|
from neutron_lib import worker as neutron_worker
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log
|
||||||
import psutil
|
import psutil
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
@ -33,6 +34,8 @@ from neutron.tests.functional import base
|
||||||
from neutron import wsgi
|
from neutron import wsgi
|
||||||
|
|
||||||
|
|
||||||
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
# Those messages will be written to temporary file each time
|
# Those messages will be written to temporary file each time
|
||||||
|
@ -156,12 +159,19 @@ class TestNeutronServer(base.BaseLoggingTestCase):
|
||||||
# Wait for temp file to be created and its size reaching the expected
|
# Wait for temp file to be created and its size reaching the expected
|
||||||
# value
|
# value
|
||||||
expected_size = len(expected_msg)
|
expected_size = len(expected_msg)
|
||||||
condition = lambda: (os.path.isfile(self.temp_file) and
|
|
||||||
os.stat(self.temp_file).st_size ==
|
def is_temp_file_ok():
|
||||||
expected_size)
|
LOG.debug("Checking file %s", self.temp_file)
|
||||||
|
if not os.path.isfile(self.temp_file):
|
||||||
|
LOG.debug("File %s not exists.", self.temp_file)
|
||||||
|
return False
|
||||||
|
temp_file_size = os.stat(self.temp_file).st_size
|
||||||
|
LOG.debug("Size of file %s is %s. Expected size: %s",
|
||||||
|
self.temp_file, temp_file_size, expected_size)
|
||||||
|
return temp_file_size == expected_size
|
||||||
|
|
||||||
try:
|
try:
|
||||||
utils.wait_until_true(condition, timeout=5, sleep=1)
|
utils.wait_until_true(is_temp_file_ok, timeout=5, sleep=1)
|
||||||
except utils.TimerTimeout:
|
except utils.TimerTimeout:
|
||||||
if not os.path.isfile(self.temp_file):
|
if not os.path.isfile(self.temp_file):
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
|
|
Loading…
Reference in New Issue