Fix bugs with one-off legacy containers
- One-off containers were included in the warning log messages, which can make for unreadable output when there are lots (as there often are). - Compose was attempting to recreate one-off containers as normal containers when migrating. Fixed by implementing the exact naming logic from before we used labels. Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
b5ce23885b
commit
051f56a1e6
2 changed files with 47 additions and 19 deletions
|
|
@ -17,6 +17,7 @@ class ProjectTest(DockerClientTestCase):
|
|||
|
||||
self.project = Project('composetest', self.services, self.client)
|
||||
|
||||
# Create a legacy container for each service
|
||||
for service in self.services:
|
||||
service.ensure_image_exists()
|
||||
self.client.create_container(
|
||||
|
|
@ -24,6 +25,12 @@ class ProjectTest(DockerClientTestCase):
|
|||
**service.options
|
||||
)
|
||||
|
||||
# Create a single one-off legacy container
|
||||
self.client.create_container(
|
||||
name='{}_{}_run_1'.format(self.project.name, self.services[0].name),
|
||||
**self.services[0].options
|
||||
)
|
||||
|
||||
def get_names(self, **kwargs):
|
||||
if 'stopped' not in kwargs:
|
||||
kwargs['stopped'] = True
|
||||
|
|
@ -38,6 +45,9 @@ class ProjectTest(DockerClientTestCase):
|
|||
def test_get_legacy_container_names(self):
|
||||
self.assertEqual(len(self.get_names()), len(self.services))
|
||||
|
||||
def test_get_legacy_container_names_one_off(self):
|
||||
self.assertEqual(len(self.get_names(one_off=True)), 1)
|
||||
|
||||
def test_migration_to_labels(self):
|
||||
with mock.patch.object(legacy, 'log', autospec=True) as mock_log:
|
||||
self.assertEqual(self.project.containers(stopped=True), [])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue