Selaa lähdekoodia

Update service tests to use mounts instead of volumes

Signed-off-by: Joffrey F <[email protected]>
Joffrey F 10 vuotta sitten
vanhempi
sitoutus
3bdcc9d954
1 muutettua tiedostoa jossa 16 lisäystä ja 14 poistoa
  1. 16 14
      tests/integration/service_test.py

+ 16 - 14
tests/integration/service_test.py

@@ -88,13 +88,13 @@ class ServiceTest(DockerClientTestCase):
         service = self.create_service('db', volumes=[VolumeSpec.parse('/var/db')])
         container = service.create_container()
         container.start()
-        self.assertIn('/var/db', container.get('Volumes'))
+        self.assertIsNotNone(container.get_mount('/var/db'))
 
     def test_create_container_with_volume_driver(self):
         service = self.create_service('db', volume_driver='foodriver')
         container = service.create_container()
         container.start()
-        self.assertEqual('foodriver', container.get('Config.VolumeDriver'))
+        self.assertEqual('foodriver', container.get('HostConfig.VolumeDriver'))
 
     def test_create_container_with_cpu_shares(self):
         service = self.create_service('db', cpu_shares=73)
@@ -158,12 +158,10 @@ class ServiceTest(DockerClientTestCase):
             volumes=[VolumeSpec(host_path, container_path, 'rw')])
         container = service.create_container()
         container.start()
-
-        volumes = container.inspect()['Volumes']
-        self.assertIn(container_path, volumes)
+        self.assertIsNotNone(container.get_mount(container_path))
 
         # Match the last component ("host-path"), because boot2docker symlinks /tmp
-        actual_host_path = volumes[container_path]
+        actual_host_path = container.get_mount(container_path)['Source']
         self.assertTrue(path.basename(actual_host_path) == path.basename(host_path),
                         msg=("Last component differs: %s, %s" % (actual_host_path, host_path)))
 
@@ -173,10 +171,10 @@ class ServiceTest(DockerClientTestCase):
         """
         service = self.create_service('data', volumes=[VolumeSpec.parse('/data/')])
         old_container = create_and_start_container(service)
-        volume_path = old_container.get('Volumes')['/data']
+        volume_path = old_container.get_mount('/data')['Source']
 
         new_container = service.recreate_container(old_container)
-        self.assertEqual(new_container.get('Volumes')['/data'], volume_path)
+        self.assertEqual(new_container.get_mount('/data')['Source'], volume_path)
 
     def test_duplicate_volume_trailing_slash(self):
         """
@@ -250,7 +248,7 @@ class ServiceTest(DockerClientTestCase):
         self.assertEqual(old_container.name, 'composetest_db_1')
         old_container.start()
         old_container.inspect()  # reload volume data
-        volume_path = old_container.get('Volumes')['/etc']
+        volume_path = old_container.get_mount('/etc')['Source']
 
         num_containers_before = len(self.client.containers(all=True))
 
@@ -262,7 +260,7 @@ class ServiceTest(DockerClientTestCase):
         self.assertEqual(new_container.get('Config.Cmd'), ['-d', '1'])
         self.assertIn('FOO=2', new_container.get('Config.Env'))
         self.assertEqual(new_container.name, 'composetest_db_1')
-        self.assertEqual(new_container.get('Volumes')['/etc'], volume_path)
+        self.assertEqual(new_container.get_mount('/etc')['Source'], volume_path)
         self.assertIn(
             'affinity:container==%s' % old_container.id,
             new_container.get('Config.Env'))
@@ -305,14 +303,18 @@ class ServiceTest(DockerClientTestCase):
         )
 
         old_container = create_and_start_container(service)
-        self.assertEqual(list(old_container.get('Volumes').keys()), ['/data'])
-        volume_path = old_container.get('Volumes')['/data']
+        self.assertEqual(
+            [mount['Destination'] for mount in old_container.get('Mounts')], ['/data']
+        )
+        volume_path = old_container.get_mount('/data')['Source']
 
         new_container, = service.execute_convergence_plan(
             ConvergencePlan('recreate', [old_container]))
 
-        self.assertEqual(list(new_container.get('Volumes')), ['/data'])
-        self.assertEqual(new_container.get('Volumes')['/data'], volume_path)
+        self.assertEqual(
+            [mount['Destination'] for mount in new_container.get('Mounts')], ['/data']
+        )
+        self.assertEqual(new_container.get_mount('/data')['Source'], volume_path)
 
     def test_execute_convergence_plan_when_image_volume_masks_config(self):
         service = self.create_service(