Issue-3503: Improve timestamp validation in tests
CLITestCase.test_events_human_readable fails due to wrong assumption that host where tests were launched will have the same date time as Docker daemon. This fix introduces internal method for validating timestamp in Docker logs Signed-off-by: Denys Makogon <lildee1991@gmail.com>
This commit is contained in:
parent
86b5ed1a84
commit
1298b9aa5d
1 changed files with 13 additions and 1 deletions
|
|
@ -1473,6 +1473,17 @@ class CLITestCase(DockerClientTestCase):
|
|||
assert Counter(e['action'] for e in lines) == {'create': 2, 'start': 2}
|
||||
|
||||
def test_events_human_readable(self):
|
||||
|
||||
def has_timestamp(string):
|
||||
str_iso_date, str_iso_time, container_info = string.split(' ', 2)
|
||||
try:
|
||||
return isinstance(datetime.datetime.strptime(
|
||||
'%s %s' % (str_iso_date, str_iso_time),
|
||||
'%Y-%m-%d %H:%M:%S.%f'),
|
||||
datetime.datetime)
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
events_proc = start_process(self.base_dir, ['events'])
|
||||
self.dispatch(['up', '-d', 'simple'])
|
||||
wait_on_condition(ContainerCountCondition(self.project, 1))
|
||||
|
|
@ -1489,7 +1500,8 @@ class CLITestCase(DockerClientTestCase):
|
|||
|
||||
assert expected_template.format('create', container.id) in lines[0]
|
||||
assert expected_template.format('start', container.id) in lines[1]
|
||||
assert lines[0].startswith(datetime.date.today().isoformat())
|
||||
|
||||
assert has_timestamp(lines[0])
|
||||
|
||||
def test_env_file_relative_to_compose_file(self):
|
||||
config_path = os.path.abspath('tests/fixtures/env-file/docker-compose.yml')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue