Implement depends_on to define an order for services in the v2 format.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2016-01-19 15:41:45 -05:00
commit 0bce467782
7 changed files with 70 additions and 8 deletions

View file

@ -894,9 +894,35 @@ class ConfigTest(unittest.TestCase):
'ext': {'external': True, 'driver': 'foo'}
}
})
with self.assertRaises(ConfigurationError):
with pytest.raises(ConfigurationError):
config.load(config_details)
def test_depends_on_orders_services(self):
config_details = build_config_details({
'version': 2,
'services': {
'one': {'image': 'busybox', 'depends_on': ['three', 'two']},
'two': {'image': 'busybox', 'depends_on': ['three']},
'three': {'image': 'busybox'},
},
})
actual = config.load(config_details)
assert (
[service['name'] for service in actual.services] ==
['three', 'two', 'one']
)
def test_depends_on_unknown_service_errors(self):
config_details = build_config_details({
'version': 2,
'services': {
'one': {'image': 'busybox', 'depends_on': ['three']},
},
})
with pytest.raises(ConfigurationError) as exc:
config.load(config_details)
assert "Service 'one' depends on service 'three'" in exc.exconly()
class PortsTest(unittest.TestCase):
INVALID_PORTS_TYPES = [