Merge pull request #130 from orchardup/fix-hanging-recreate

Fix hanging recreate
This commit is contained in:
Ben Firshman 2014-03-03 18:49:36 +00:00
commit bf87f897d7
3 changed files with 14 additions and 5 deletions

View File

@ -165,9 +165,9 @@ class Service(object):
intermediate_container = Container.create( intermediate_container = Container.create(
self.client, self.client,
image=container.image, image=container.image,
command='echo',
volumes_from=container.id, volumes_from=container.id,
entrypoint=None entrypoint=['echo'],
command=[],
) )
intermediate_container.start() intermediate_container.start()
intermediate_container.wait() intermediate_container.wait()

View File

@ -114,9 +114,16 @@ class ServiceTest(DockerClientTestCase):
self.assertIn('/var/db', container.inspect()['Volumes']) self.assertIn('/var/db', container.inspect()['Volumes'])
def test_recreate_containers(self): def test_recreate_containers(self):
service = self.create_service('db', environment={'FOO': '1'}, volumes=['/var/db'], entrypoint=['ps']) service = self.create_service(
'db',
environment={'FOO': '1'},
volumes=['/var/db'],
entrypoint=['ps'],
command=['ax']
)
old_container = service.create_container() old_container = service.create_container()
self.assertEqual(old_container.dictionary['Config']['Entrypoint'], ['ps']) self.assertEqual(old_container.dictionary['Config']['Entrypoint'], ['ps'])
self.assertEqual(old_container.dictionary['Config']['Cmd'], ['ax'])
self.assertIn('FOO=1', old_container.dictionary['Config']['Env']) self.assertIn('FOO=1', old_container.dictionary['Config']['Env'])
self.assertEqual(old_container.name, 'figtest_db_1') self.assertEqual(old_container.name, 'figtest_db_1')
service.start_container(old_container) service.start_container(old_container)
@ -131,9 +138,10 @@ class ServiceTest(DockerClientTestCase):
new_container = new[0] new_container = new[0]
intermediate_container = intermediate[0] intermediate_container = intermediate[0]
self.assertEqual(intermediate_container.dictionary['Config']['Entrypoint'], None) self.assertEqual(intermediate_container.dictionary['Config']['Entrypoint'], ['echo'])
self.assertEqual(new_container.dictionary['Config']['Entrypoint'], ['ps']) self.assertEqual(new_container.dictionary['Config']['Entrypoint'], ['ps'])
self.assertEqual(new_container.dictionary['Config']['Cmd'], ['ax'])
self.assertIn('FOO=2', new_container.dictionary['Config']['Env']) self.assertIn('FOO=2', new_container.dictionary['Config']['Env'])
self.assertEqual(new_container.name, 'figtest_db_1') self.assertEqual(new_container.name, 'figtest_db_1')
service.start_container(new_container) service.start_container(new_container)

View File

@ -22,12 +22,13 @@ class DockerClientTestCase(unittest.TestCase):
self.client.remove_image(i) self.client.remove_image(i)
def create_service(self, name, **kwargs): def create_service(self, name, **kwargs):
if 'command' not in kwargs:
kwargs['command'] = ["/bin/sleep", "300"]
return Service( return Service(
project='figtest', project='figtest',
name=name, name=name,
client=self.client, client=self.client,
image="ubuntu", image="ubuntu",
command=["/bin/sleep", "300"],
**kwargs **kwargs
) )