Handle the case that the time is zero

If a container is created but not started yet, the "StartedAt" field
of the Docker container will be January 1, year 1, 00:00:00 UTC.
This commit will check for this case and print "Created" to the
status_detail field.

Depends-On: I6185e3b8fc5e5b132656ff416e08917edd938fc8
Change-Id: If3eca41e52f32dddb9cbc34d64fdc931e1d219e6
This commit is contained in:
Hongbin Lu 2017-03-08 10:26:01 -06:00
parent facc3e6d87
commit 07e391ee17

View File

@ -182,13 +182,13 @@ class TestContainer(base.BaseZunTest):
self.assertEqual(202, resp.status) self.assertEqual(202, resp.status)
# Wait for container to finish creation # Wait for container to finish creation
self.container_client.ensure_container_in_desired_state( self.container_client.ensure_container_in_desired_state(
model.uuid, 'Stopped') model.uuid, 'Created')
# Assert the container is created # Assert the container is created
resp, model = self.container_client.get_container(model.uuid) resp, model = self.container_client.get_container(model.uuid)
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
self.assertEqual('Stopped', model.status) self.assertEqual('Created', model.status)
self.assertEqual('Stopped', self._get_container_state(model.uuid)) self.assertEqual('Created', self._get_container_state(model.uuid))
return resp, model return resp, model
def _run_container(self, **kwargs): def _run_container(self, **kwargs):
@ -220,5 +220,7 @@ class TestContainer(base.BaseZunTest):
return 'Paused' return 'Paused'
elif status.get('Running'): elif status.get('Running'):
return 'Running' return 'Running'
elif status.get('Status') == 'created':
return 'Created'
else: else:
return 'Stopped' return 'Stopped'