瀏覽代碼

Test discoverability across multiple networks

Signed-off-by: Aanand Prasad <[email protected]>
Aanand Prasad 10 年之前
父節點
當前提交
9c91cf2967
共有 1 個文件被更改,包括 21 次插入0 次删除
  1. 21 0
      tests/acceptance/cli_test.py

+ 21 - 0
tests/acceptance/cli_test.py

@@ -126,6 +126,20 @@ class CLITestCase(DockerClientTestCase):
         proc = start_process(self.base_dir, project_options + options)
         return wait_on_process(proc, returncode=returncode)
 
+    def execute(self, container, cmd):
+        # Remove once Hijack and CloseNotifier sign a peace treaty
+        self.client.close()
+        exc = self.client.exec_create(container.id, cmd)
+        self.client.exec_start(exc)
+        return self.client.exec_inspect(exc)['ExitCode']
+
+    def lookup(self, container, service_name):
+        exit_code = self.execute(container, [
+            "nslookup",
+            "{}_{}_1".format(self.project.name, service_name)
+        ])
+        return exit_code == 0
+
     def test_help(self):
         self.base_dir = 'tests/fixtures/no-composefile'
         result = self.dispatch(['help', 'up'], returncode=1)
@@ -404,6 +418,13 @@ class CLITestCase(DockerClientTestCase):
         # web and app joined the front network
         assert sorted(front_network['Containers']) == sorted([web_container.id, app_container.id])
 
+        # web can see app but not db
+        assert self.lookup(web_container, "app")
+        assert not self.lookup(web_container, "db")
+
+        # app can see db
+        assert self.lookup(app_container, "db")
+
     def test_up_missing_network(self):
         self.base_dir = 'tests/fixtures/networks'