2014-01-06 03:26:32 +01:00
|
|
|
from __future__ import unicode_literals
|
2015-05-30 22:17:21 +02:00
|
|
|
|
2015-02-27 12:54:57 +01:00
|
|
|
from compose import config
|
2015-05-30 22:17:21 +02:00
|
|
|
from compose.const import LABEL_PROJECT
|
2015-02-27 12:54:57 +01:00
|
|
|
from compose.project import Project
|
2015-01-12 15:59:05 +01:00
|
|
|
from compose.container import Container
|
2013-12-19 17:55:12 +01:00
|
|
|
from .testcases import DockerClientTestCase
|
|
|
|
|
|
|
|
|
2015-05-27 04:09:26 +02:00
|
|
|
def build_service_dicts(service_config):
|
|
|
|
return config.load(config.ConfigDetails(service_config, 'working_dir', None))
|
|
|
|
|
|
|
|
|
2013-12-19 17:55:12 +01:00
|
|
|
class ProjectTest(DockerClientTestCase):
|
2015-05-21 02:45:48 +02:00
|
|
|
|
|
|
|
def test_containers(self):
|
|
|
|
web = self.create_service('web')
|
|
|
|
db = self.create_service('db')
|
|
|
|
project = Project('composetest', [web, db], self.client)
|
|
|
|
|
|
|
|
project.up()
|
|
|
|
|
|
|
|
containers = project.containers()
|
|
|
|
self.assertEqual(len(containers), 2)
|
|
|
|
|
|
|
|
def test_containers_with_service_names(self):
|
|
|
|
web = self.create_service('web')
|
|
|
|
db = self.create_service('db')
|
|
|
|
project = Project('composetest', [web, db], self.client)
|
|
|
|
|
|
|
|
project.up()
|
|
|
|
|
|
|
|
containers = project.containers(['web'])
|
|
|
|
self.assertEqual(
|
|
|
|
[c.name for c in containers],
|
|
|
|
['composetest_web_1'])
|
|
|
|
|
2015-07-03 15:25:15 +02:00
|
|
|
def test_containers_with_extra_service(self):
|
|
|
|
web = self.create_service('web')
|
|
|
|
web_1 = web.create_container()
|
|
|
|
|
|
|
|
db = self.create_service('db')
|
|
|
|
db_1 = db.create_container()
|
|
|
|
|
|
|
|
self.create_service('extra').create_container()
|
|
|
|
|
|
|
|
project = Project('composetest', [web, db], self.client)
|
|
|
|
self.assertEqual(
|
|
|
|
set(project.containers(stopped=True)),
|
|
|
|
set([web_1, db_1]),
|
|
|
|
)
|
|
|
|
|
2014-07-12 01:39:23 +02:00
|
|
|
def test_volumes_from_service(self):
|
2015-05-27 04:09:26 +02:00
|
|
|
service_dicts = build_service_dicts({
|
2015-03-19 02:23:17 +01:00
|
|
|
'data': {
|
|
|
|
'image': 'busybox:latest',
|
|
|
|
'volumes': ['/var/data'],
|
|
|
|
},
|
|
|
|
'db': {
|
|
|
|
'image': 'busybox:latest',
|
|
|
|
'volumes_from': ['data'],
|
|
|
|
},
|
2015-05-27 04:09:26 +02:00
|
|
|
})
|
2015-02-27 12:54:57 +01:00
|
|
|
project = Project.from_dicts(
|
2015-01-12 15:59:05 +01:00
|
|
|
name='composetest',
|
2015-03-19 02:23:17 +01:00
|
|
|
service_dicts=service_dicts,
|
2014-07-12 01:39:23 +02:00
|
|
|
client=self.client,
|
|
|
|
)
|
|
|
|
db = project.get_service('db')
|
|
|
|
data = project.get_service('data')
|
|
|
|
self.assertEqual(db.volumes_from, [data])
|
|
|
|
|
|
|
|
def test_volumes_from_container(self):
|
|
|
|
data_container = Container.create(
|
|
|
|
self.client,
|
|
|
|
image='busybox:latest',
|
|
|
|
volumes=['/var/data'],
|
2015-01-12 15:59:05 +01:00
|
|
|
name='composetest_data_container',
|
2015-05-30 22:17:21 +02:00
|
|
|
labels={LABEL_PROJECT: 'composetest'},
|
2014-07-12 01:39:23 +02:00
|
|
|
)
|
2015-02-27 12:54:57 +01:00
|
|
|
project = Project.from_dicts(
|
2015-01-12 15:59:05 +01:00
|
|
|
name='composetest',
|
2015-05-27 04:09:26 +02:00
|
|
|
service_dicts=build_service_dicts({
|
2014-07-12 01:39:23 +02:00
|
|
|
'db': {
|
|
|
|
'image': 'busybox:latest',
|
2015-01-12 15:59:05 +01:00
|
|
|
'volumes_from': ['composetest_data_container'],
|
2014-07-12 01:39:23 +02:00
|
|
|
},
|
2015-02-27 12:54:57 +01:00
|
|
|
}),
|
2014-07-12 01:39:23 +02:00
|
|
|
client=self.client,
|
|
|
|
)
|
|
|
|
db = project.get_service('db')
|
|
|
|
self.assertEqual(db.volumes_from, [data_container])
|
|
|
|
|
2015-03-06 22:30:56 +01:00
|
|
|
def test_net_from_service(self):
|
2015-02-27 12:54:57 +01:00
|
|
|
project = Project.from_dicts(
|
2015-03-06 22:30:56 +01:00
|
|
|
name='composetest',
|
2015-05-27 04:09:26 +02:00
|
|
|
service_dicts=build_service_dicts({
|
2015-03-06 22:30:56 +01:00
|
|
|
'net': {
|
|
|
|
'image': 'busybox:latest',
|
2015-05-21 17:19:15 +02:00
|
|
|
'command': ["top"]
|
2015-03-06 22:30:56 +01:00
|
|
|
},
|
|
|
|
'web': {
|
|
|
|
'image': 'busybox:latest',
|
|
|
|
'net': 'container:net',
|
2015-05-21 17:19:15 +02:00
|
|
|
'command': ["top"]
|
2015-02-27 12:54:57 +01:00
|
|
|
},
|
|
|
|
}),
|
2015-03-06 22:30:56 +01:00
|
|
|
client=self.client,
|
|
|
|
)
|
|
|
|
|
|
|
|
project.up()
|
|
|
|
|
|
|
|
web = project.get_service('web')
|
|
|
|
net = project.get_service('net')
|
2015-03-26 04:13:01 +01:00
|
|
|
self.assertEqual(web._get_net(), 'container:' + net.containers()[0].id)
|
2015-03-06 22:30:56 +01:00
|
|
|
|
|
|
|
def test_net_from_container(self):
|
|
|
|
net_container = Container.create(
|
|
|
|
self.client,
|
|
|
|
image='busybox:latest',
|
|
|
|
name='composetest_net_container',
|
2015-05-30 22:17:21 +02:00
|
|
|
command='top',
|
|
|
|
labels={LABEL_PROJECT: 'composetest'},
|
2015-03-06 22:30:56 +01:00
|
|
|
)
|
|
|
|
net_container.start()
|
|
|
|
|
2015-02-27 12:54:57 +01:00
|
|
|
project = Project.from_dicts(
|
2015-03-06 22:30:56 +01:00
|
|
|
name='composetest',
|
2015-05-27 04:09:26 +02:00
|
|
|
service_dicts=build_service_dicts({
|
2015-03-06 22:30:56 +01:00
|
|
|
'web': {
|
|
|
|
'image': 'busybox:latest',
|
|
|
|
'net': 'container:composetest_net_container'
|
|
|
|
},
|
2015-02-27 12:54:57 +01:00
|
|
|
}),
|
2015-03-06 22:30:56 +01:00
|
|
|
client=self.client,
|
|
|
|
)
|
|
|
|
|
|
|
|
project.up()
|
|
|
|
|
|
|
|
web = project.get_service('web')
|
2015-03-26 04:13:01 +01:00
|
|
|
self.assertEqual(web._get_net(), 'container:' + net_container.id)
|
2015-03-06 22:30:56 +01:00
|
|
|
|
2013-12-20 19:30:23 +01:00
|
|
|
def test_start_stop_kill_remove(self):
|
2013-12-20 17:22:54 +01:00
|
|
|
web = self.create_service('web')
|
|
|
|
db = self.create_service('db')
|
2015-01-12 15:59:05 +01:00
|
|
|
project = Project('composetest', [web, db], self.client)
|
2013-12-20 17:22:54 +01:00
|
|
|
|
|
|
|
project.start()
|
|
|
|
|
|
|
|
self.assertEqual(len(web.containers()), 0)
|
|
|
|
self.assertEqual(len(db.containers()), 0)
|
2013-12-19 17:55:12 +01:00
|
|
|
|
2013-12-20 19:30:23 +01:00
|
|
|
web_container_1 = web.create_container()
|
|
|
|
web_container_2 = web.create_container()
|
|
|
|
db_container = db.create_container()
|
|
|
|
|
|
|
|
project.start(service_names=['web'])
|
|
|
|
self.assertEqual(set(c.name for c in project.containers()), set([web_container_1.name, web_container_2.name]))
|
|
|
|
|
2013-12-19 17:55:12 +01:00
|
|
|
project.start()
|
2013-12-20 19:30:23 +01:00
|
|
|
self.assertEqual(set(c.name for c in project.containers()), set([web_container_1.name, web_container_2.name, db_container.name]))
|
2013-12-19 17:55:12 +01:00
|
|
|
|
2013-12-20 19:30:23 +01:00
|
|
|
project.stop(service_names=['web'], timeout=1)
|
|
|
|
self.assertEqual(set(c.name for c in project.containers()), set([db_container.name]))
|
2013-12-19 17:55:12 +01:00
|
|
|
|
2013-12-20 19:30:23 +01:00
|
|
|
project.kill(service_names=['db'])
|
|
|
|
self.assertEqual(len(project.containers()), 0)
|
|
|
|
self.assertEqual(len(project.containers(stopped=True)), 3)
|
2013-12-19 17:55:12 +01:00
|
|
|
|
2013-12-20 19:30:23 +01:00
|
|
|
project.remove_stopped(service_names=['web'])
|
|
|
|
self.assertEqual(len(project.containers(stopped=True)), 1)
|
|
|
|
|
|
|
|
project.remove_stopped()
|
|
|
|
self.assertEqual(len(project.containers(stopped=True)), 0)
|
2014-03-21 19:34:19 +01:00
|
|
|
|
|
|
|
def test_project_up(self):
|
|
|
|
web = self.create_service('web')
|
2014-04-23 16:46:26 +02:00
|
|
|
db = self.create_service('db', volumes=['/var/db'])
|
2015-01-12 15:59:05 +01:00
|
|
|
project = Project('composetest', [web, db], self.client)
|
2014-03-21 19:34:19 +01:00
|
|
|
project.start()
|
|
|
|
self.assertEqual(len(project.containers()), 0)
|
2014-04-23 16:46:26 +02:00
|
|
|
|
2014-06-08 13:32:16 +02:00
|
|
|
project.up(['db'])
|
|
|
|
self.assertEqual(len(project.containers()), 1)
|
|
|
|
self.assertEqual(len(db.containers()), 1)
|
|
|
|
self.assertEqual(len(web.containers()), 0)
|
|
|
|
|
2015-05-21 21:03:02 +02:00
|
|
|
def test_project_up_starts_uncreated_services(self):
|
|
|
|
db = self.create_service('db')
|
|
|
|
web = self.create_service('web', links=[(db, 'db')])
|
|
|
|
project = Project('composetest', [db, web], self.client)
|
|
|
|
project.up(['db'])
|
|
|
|
self.assertEqual(len(project.containers()), 1)
|
|
|
|
|
|
|
|
project.up()
|
|
|
|
self.assertEqual(len(project.containers()), 2)
|
|
|
|
self.assertEqual(len(db.containers()), 1)
|
|
|
|
self.assertEqual(len(web.containers()), 1)
|
|
|
|
|
2014-06-08 13:32:16 +02:00
|
|
|
def test_project_up_recreates_containers(self):
|
|
|
|
web = self.create_service('web')
|
2014-08-31 19:07:49 +02:00
|
|
|
db = self.create_service('db', volumes=['/etc'])
|
2015-01-12 15:59:05 +01:00
|
|
|
project = Project('composetest', [web, db], self.client)
|
2014-06-08 13:32:16 +02:00
|
|
|
project.start()
|
|
|
|
self.assertEqual(len(project.containers()), 0)
|
|
|
|
|
2014-04-23 16:46:26 +02:00
|
|
|
project.up(['db'])
|
|
|
|
self.assertEqual(len(project.containers()), 1)
|
|
|
|
old_db_id = project.containers()[0].id
|
2014-08-31 19:07:49 +02:00
|
|
|
db_volume_path = project.containers()[0].get('Volumes./etc')
|
2014-04-23 16:46:26 +02:00
|
|
|
|
2014-03-21 19:34:19 +01:00
|
|
|
project.up()
|
|
|
|
self.assertEqual(len(project.containers()), 2)
|
2014-04-23 16:46:26 +02:00
|
|
|
|
|
|
|
db_container = [c for c in project.containers() if 'db' in c.name][0]
|
2014-08-02 22:31:08 +02:00
|
|
|
self.assertNotEqual(db_container.id, old_db_id)
|
2014-08-31 19:07:49 +02:00
|
|
|
self.assertEqual(db_container.get('Volumes./etc'), db_volume_path)
|
2014-04-23 16:46:26 +02:00
|
|
|
|
2014-06-09 01:20:51 +02:00
|
|
|
def test_project_up_with_no_recreate_running(self):
|
2014-06-08 13:32:16 +02:00
|
|
|
web = self.create_service('web')
|
|
|
|
db = self.create_service('db', volumes=['/var/db'])
|
2015-01-12 15:59:05 +01:00
|
|
|
project = Project('composetest', [web, db], self.client)
|
2014-06-08 13:32:16 +02:00
|
|
|
project.start()
|
|
|
|
self.assertEqual(len(project.containers()), 0)
|
|
|
|
|
|
|
|
project.up(['db'])
|
|
|
|
self.assertEqual(len(project.containers()), 1)
|
|
|
|
old_db_id = project.containers()[0].id
|
|
|
|
db_volume_path = project.containers()[0].inspect()['Volumes']['/var/db']
|
|
|
|
|
2015-05-12 12:11:36 +02:00
|
|
|
project.up(allow_recreate=False)
|
2014-06-08 13:32:16 +02:00
|
|
|
self.assertEqual(len(project.containers()), 2)
|
|
|
|
|
|
|
|
db_container = [c for c in project.containers() if 'db' in c.name][0]
|
2014-08-02 22:31:08 +02:00
|
|
|
self.assertEqual(db_container.id, old_db_id)
|
|
|
|
self.assertEqual(db_container.inspect()['Volumes']['/var/db'],
|
|
|
|
db_volume_path)
|
2014-06-08 13:32:16 +02:00
|
|
|
|
2014-06-09 01:20:51 +02:00
|
|
|
def test_project_up_with_no_recreate_stopped(self):
|
2014-06-09 00:47:09 +02:00
|
|
|
web = self.create_service('web')
|
|
|
|
db = self.create_service('db', volumes=['/var/db'])
|
2015-01-12 15:59:05 +01:00
|
|
|
project = Project('composetest', [web, db], self.client)
|
2014-06-09 00:47:09 +02:00
|
|
|
project.start()
|
|
|
|
self.assertEqual(len(project.containers()), 0)
|
|
|
|
|
|
|
|
project.up(['db'])
|
2015-05-12 12:11:36 +02:00
|
|
|
project.kill()
|
2014-06-09 00:47:09 +02:00
|
|
|
|
|
|
|
old_containers = project.containers(stopped=True)
|
|
|
|
|
|
|
|
self.assertEqual(len(old_containers), 1)
|
|
|
|
old_db_id = old_containers[0].id
|
|
|
|
db_volume_path = old_containers[0].inspect()['Volumes']['/var/db']
|
|
|
|
|
2015-05-12 12:11:36 +02:00
|
|
|
project.up(allow_recreate=False)
|
2014-06-09 00:47:09 +02:00
|
|
|
|
|
|
|
new_containers = project.containers(stopped=True)
|
|
|
|
self.assertEqual(len(new_containers), 2)
|
2015-05-12 12:11:36 +02:00
|
|
|
self.assertEqual([c.is_running for c in new_containers], [True, True])
|
2014-06-09 00:47:09 +02:00
|
|
|
|
|
|
|
db_container = [c for c in new_containers if 'db' in c.name][0]
|
2014-08-02 22:31:08 +02:00
|
|
|
self.assertEqual(db_container.id, old_db_id)
|
|
|
|
self.assertEqual(db_container.inspect()['Volumes']['/var/db'],
|
|
|
|
db_volume_path)
|
2014-06-09 00:47:09 +02:00
|
|
|
|
2014-06-21 12:39:36 +02:00
|
|
|
def test_project_up_without_all_services(self):
|
|
|
|
console = self.create_service('console')
|
2014-06-07 15:19:28 +02:00
|
|
|
db = self.create_service('db')
|
2015-01-12 15:59:05 +01:00
|
|
|
project = Project('composetest', [console, db], self.client)
|
2014-06-07 15:19:28 +02:00
|
|
|
project.start()
|
|
|
|
self.assertEqual(len(project.containers()), 0)
|
|
|
|
|
|
|
|
project.up()
|
2014-06-21 12:39:36 +02:00
|
|
|
self.assertEqual(len(project.containers()), 2)
|
2014-06-07 15:19:28 +02:00
|
|
|
self.assertEqual(len(db.containers()), 1)
|
2014-06-21 12:39:36 +02:00
|
|
|
self.assertEqual(len(console.containers()), 1)
|
2014-06-07 15:19:28 +02:00
|
|
|
|
2014-06-08 13:32:16 +02:00
|
|
|
def test_project_up_starts_links(self):
|
|
|
|
console = self.create_service('console')
|
|
|
|
db = self.create_service('db', volumes=['/var/db'])
|
|
|
|
web = self.create_service('web', links=[(db, 'db')])
|
|
|
|
|
2015-01-12 15:59:05 +01:00
|
|
|
project = Project('composetest', [web, db, console], self.client)
|
2014-06-08 13:32:16 +02:00
|
|
|
project.start()
|
|
|
|
self.assertEqual(len(project.containers()), 0)
|
|
|
|
|
|
|
|
project.up(['web'])
|
|
|
|
self.assertEqual(len(project.containers()), 2)
|
|
|
|
self.assertEqual(len(web.containers()), 1)
|
|
|
|
self.assertEqual(len(db.containers()), 1)
|
|
|
|
self.assertEqual(len(console.containers()), 0)
|
|
|
|
|
2015-03-06 22:30:56 +01:00
|
|
|
def test_project_up_starts_depends(self):
|
2015-02-27 12:54:57 +01:00
|
|
|
project = Project.from_dicts(
|
2015-03-06 22:30:56 +01:00
|
|
|
name='composetest',
|
2015-05-27 04:09:26 +02:00
|
|
|
service_dicts=build_service_dicts({
|
2015-03-06 22:30:56 +01:00
|
|
|
'console': {
|
|
|
|
'image': 'busybox:latest',
|
2015-05-21 17:19:15 +02:00
|
|
|
'command': ["top"],
|
2015-03-06 22:30:56 +01:00
|
|
|
},
|
2015-03-26 04:13:01 +01:00
|
|
|
'data': {
|
2015-03-06 22:30:56 +01:00
|
|
|
'image': 'busybox:latest',
|
2015-05-21 17:19:15 +02:00
|
|
|
'command': ["top"]
|
2015-03-06 22:30:56 +01:00
|
|
|
},
|
2015-03-13 15:51:26 +01:00
|
|
|
'db': {
|
2015-03-06 22:30:56 +01:00
|
|
|
'image': 'busybox:latest',
|
2015-05-21 17:19:15 +02:00
|
|
|
'command': ["top"],
|
2015-03-13 15:51:26 +01:00
|
|
|
'volumes_from': ['data'],
|
2015-03-06 22:30:56 +01:00
|
|
|
},
|
|
|
|
'web': {
|
|
|
|
'image': 'busybox:latest',
|
2015-05-21 17:19:15 +02:00
|
|
|
'command': ["top"],
|
2015-03-13 15:51:26 +01:00
|
|
|
'links': ['db'],
|
2015-03-06 22:30:56 +01:00
|
|
|
},
|
2015-02-27 12:54:57 +01:00
|
|
|
}),
|
2015-03-06 22:30:56 +01:00
|
|
|
client=self.client,
|
|
|
|
)
|
|
|
|
project.start()
|
|
|
|
self.assertEqual(len(project.containers()), 0)
|
2014-06-08 13:32:16 +02:00
|
|
|
|
2015-03-06 22:30:56 +01:00
|
|
|
project.up(['web'])
|
|
|
|
self.assertEqual(len(project.containers()), 3)
|
|
|
|
self.assertEqual(len(project.get_service('web').containers()), 1)
|
2015-03-13 15:51:26 +01:00
|
|
|
self.assertEqual(len(project.get_service('db').containers()), 1)
|
|
|
|
self.assertEqual(len(project.get_service('data').containers()), 1)
|
2015-03-06 22:30:56 +01:00
|
|
|
self.assertEqual(len(project.get_service('console').containers()), 0)
|
|
|
|
|
|
|
|
def test_project_up_with_no_deps(self):
|
2015-02-27 12:54:57 +01:00
|
|
|
project = Project.from_dicts(
|
2015-03-06 22:30:56 +01:00
|
|
|
name='composetest',
|
2015-05-27 04:09:26 +02:00
|
|
|
service_dicts=build_service_dicts({
|
2015-03-06 22:30:56 +01:00
|
|
|
'console': {
|
|
|
|
'image': 'busybox:latest',
|
2015-05-21 17:19:15 +02:00
|
|
|
'command': ["top"],
|
2015-03-06 22:30:56 +01:00
|
|
|
},
|
2015-03-26 04:13:01 +01:00
|
|
|
'data': {
|
2015-03-06 22:30:56 +01:00
|
|
|
'image': 'busybox:latest',
|
2015-05-21 17:19:15 +02:00
|
|
|
'command': ["top"]
|
2015-03-06 22:30:56 +01:00
|
|
|
},
|
2015-03-13 15:51:26 +01:00
|
|
|
'db': {
|
2015-03-06 22:30:56 +01:00
|
|
|
'image': 'busybox:latest',
|
2015-05-21 17:19:15 +02:00
|
|
|
'command': ["top"],
|
2015-03-13 15:51:26 +01:00
|
|
|
'volumes_from': ['data'],
|
2015-03-06 22:30:56 +01:00
|
|
|
},
|
|
|
|
'web': {
|
|
|
|
'image': 'busybox:latest',
|
2015-05-21 17:19:15 +02:00
|
|
|
'command': ["top"],
|
2015-03-13 15:51:26 +01:00
|
|
|
'links': ['db'],
|
2015-03-06 22:30:56 +01:00
|
|
|
},
|
2015-02-27 12:54:57 +01:00
|
|
|
}),
|
2015-03-06 22:30:56 +01:00
|
|
|
client=self.client,
|
|
|
|
)
|
2014-06-08 13:32:16 +02:00
|
|
|
project.start()
|
|
|
|
self.assertEqual(len(project.containers()), 0)
|
|
|
|
|
2015-03-13 15:51:26 +01:00
|
|
|
project.up(['db'], start_deps=False)
|
2015-03-06 22:30:56 +01:00
|
|
|
self.assertEqual(len(project.containers(stopped=True)), 2)
|
2015-03-13 15:51:26 +01:00
|
|
|
self.assertEqual(len(project.get_service('web').containers()), 0)
|
|
|
|
self.assertEqual(len(project.get_service('db').containers()), 1)
|
|
|
|
self.assertEqual(len(project.get_service('data').containers()), 0)
|
|
|
|
self.assertEqual(len(project.get_service('data').containers(stopped=True)), 1)
|
2015-03-06 22:30:56 +01:00
|
|
|
self.assertEqual(len(project.get_service('console').containers()), 0)
|
2014-06-08 13:32:16 +02:00
|
|
|
|
2014-03-21 19:34:19 +01:00
|
|
|
def test_unscale_after_restart(self):
|
|
|
|
web = self.create_service('web')
|
2015-01-12 15:59:05 +01:00
|
|
|
project = Project('composetest', [web], self.client)
|
2014-03-21 19:34:19 +01:00
|
|
|
|
|
|
|
project.start()
|
|
|
|
|
|
|
|
service = project.get_service('web')
|
|
|
|
service.scale(1)
|
|
|
|
self.assertEqual(len(service.containers()), 1)
|
|
|
|
service.scale(3)
|
|
|
|
self.assertEqual(len(service.containers()), 3)
|
|
|
|
project.up()
|
|
|
|
service = project.get_service('web')
|
|
|
|
self.assertEqual(len(service.containers()), 3)
|
|
|
|
service.scale(1)
|
|
|
|
self.assertEqual(len(service.containers()), 1)
|
|
|
|
project.up()
|
|
|
|
service = project.get_service('web')
|
|
|
|
self.assertEqual(len(service.containers()), 1)
|
|
|
|
# does scale=0 ,makes any sense? after recreating at least 1 container is running
|
|
|
|
service.scale(0)
|
|
|
|
project.up()
|
|
|
|
service = project.get_service('web')
|
|
|
|
self.assertEqual(len(service.containers()), 1)
|