Merge pull request #2713 from aanand/links-v2
Support links in v2 files
This commit is contained in:
commit
013c5ea3f9
7 changed files with 21 additions and 30 deletions
|
|
@ -461,6 +461,10 @@ class CLITestCase(DockerClientTestCase):
|
|||
app_container = self.project.get_service('app').containers()[0]
|
||||
db_container = self.project.get_service('db').containers()[0]
|
||||
|
||||
for net_name in [front_name, back_name]:
|
||||
links = app_container.get('NetworkSettings.Networks.{}.Links'.format(net_name))
|
||||
assert '{}:database'.format(db_container.name) in links
|
||||
|
||||
# db and app joined the back network
|
||||
assert sorted(back_network['Containers']) == sorted([db_container.id, app_container.id])
|
||||
|
||||
|
|
@ -474,6 +478,9 @@ class CLITestCase(DockerClientTestCase):
|
|||
# app can see db
|
||||
assert self.lookup(app_container, "db")
|
||||
|
||||
# app has aliased db to "database"
|
||||
assert self.lookup(app_container, "database")
|
||||
|
||||
@v2_only()
|
||||
def test_up_missing_network(self):
|
||||
self.base_dir = 'tests/fixtures/networks'
|
||||
|
|
@ -566,18 +573,6 @@ class CLITestCase(DockerClientTestCase):
|
|||
for name in ['bar', 'foo']
|
||||
]
|
||||
|
||||
@v2_only()
|
||||
def test_up_with_links_is_invalid(self):
|
||||
self.base_dir = 'tests/fixtures/v2-simple'
|
||||
|
||||
result = self.dispatch(
|
||||
['-f', 'links-invalid.yml', 'up', '-d'],
|
||||
returncode=1)
|
||||
|
||||
# TODO: fix validation error messages for v2 files
|
||||
# assert "Unsupported config option for service 'simple': 'links'" in result.stderr
|
||||
assert "Unsupported config option" in result.stderr
|
||||
|
||||
def test_up_with_links_v1(self):
|
||||
self.base_dir = 'tests/fixtures/links-composefile'
|
||||
self.dispatch(['up', '-d', 'web'], None)
|
||||
|
|
|
|||
2
tests/fixtures/networks/docker-compose.yml
vendored
2
tests/fixtures/networks/docker-compose.yml
vendored
|
|
@ -9,6 +9,8 @@ services:
|
|||
image: busybox
|
||||
command: top
|
||||
networks: ["front", "back"]
|
||||
links:
|
||||
- "db:database"
|
||||
db:
|
||||
image: busybox
|
||||
command: top
|
||||
|
|
|
|||
|
|
@ -536,14 +536,6 @@ class ServiceTest(unittest.TestCase):
|
|||
ports=["127.0.0.1:1000-2000:2000-3000"])
|
||||
self.assertEqual(service.specifies_host_port(), True)
|
||||
|
||||
def test_get_links_with_networking(self):
|
||||
service = Service(
|
||||
'foo',
|
||||
image='foo',
|
||||
links=[(Service('one'), 'one')],
|
||||
use_networking=True)
|
||||
self.assertEqual(service._get_links(link_to_self=True), [])
|
||||
|
||||
def test_image_name_from_config(self):
|
||||
image_name = 'example/web:latest'
|
||||
service = Service('foo', image=image_name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue