From 5340a6d760c463c759cdf3514357dfe5eb11a31e Mon Sep 17 00:00:00 2001 From: aiordache Date: Mon, 14 Sep 2020 19:11:13 +0200 Subject: [PATCH] Add test for scale with stopped containers Signed-off-by: aiordache --- tests/integration/project_test.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/integration/project_test.py b/tests/integration/project_test.py index 879701076..96929f209 100644 --- a/tests/integration/project_test.py +++ b/tests/integration/project_test.py @@ -1347,6 +1347,36 @@ class ProjectTest(DockerClientTestCase): project.up() assert len(project.containers()) == 3 + def test_project_up_scale_with_stopped_containers(self): + config_data = build_config( + services=[{ + 'name': 'web', + 'image': BUSYBOX_IMAGE_WITH_TAG, + 'command': 'top', + 'scale': 2 + }] + ) + project = Project.from_config( + name='composetest', config_data=config_data, client=self.client + ) + + project.up() + containers = project.containers() + assert len(containers) == 2 + + self.client.stop(containers[0].id) + project.up(scale_override={'web': 2}) + containers = project.containers() + assert len(containers) == 2 + + self.client.stop(containers[0].id) + project.up(scale_override={'web': 3}) + assert len(project.containers()) == 3 + + self.client.stop(containers[0].id) + project.up(scale_override={'web': 1}) + assert len(project.containers()) == 1 + def test_initialize_volumes(self): vol_name = '{:x}'.format(random.getrandbits(32)) full_vol_name = 'composetest_{}'.format(vol_name)