[ARVADOS] created: 5c5858bc9281daa891103d0ae45fce8f096d6535

git at public.curoverse.com git at public.curoverse.com
Wed Dec 16 11:07:28 EST 2015


        at  5c5858bc9281daa891103d0ae45fce8f096d6535 (commit)


commit 5c5858bc9281daa891103d0ae45fce8f096d6535
Author: Brett Smith <brett at curoverse.com>
Date:   Wed Dec 16 11:07:24 2015 -0500

    7927: Docker cleaner service uses Docker API v1.14.
    
    This helps it work consistently across a variety of Docker versions.
    See the comment in the tests for more background.

diff --git a/services/dockercleaner/arvados_docker/cleaner.py b/services/dockercleaner/arvados_docker/cleaner.py
index 2435e6d..719cc2a 100755
--- a/services/dockercleaner/arvados_docker/cleaner.py
+++ b/services/dockercleaner/arvados_docker/cleaner.py
@@ -288,7 +288,7 @@ def run(args, docker_client):
 def main(arguments):
     args = parse_arguments(arguments)
     setup_logging(args)
-    run(args, docker.Client())
+    run(args, docker.Client(version='1.14'))
 
 if __name__ == '__main__':
     main(sys.argv[1:])
diff --git a/services/dockercleaner/tests/test_cleaner.py b/services/dockercleaner/tests/test_cleaner.py
index 43abe4f..31a48b2 100644
--- a/services/dockercleaner/tests/test_cleaner.py
+++ b/services/dockercleaner/tests/test_cleaner.py
@@ -374,6 +374,21 @@ class RunTestCase(unittest.TestCase):
         self.assertEqual(event_kwargs[0]['until'], event_kwargs[1]['since'])
 
 
+ at mock.patch('docker.Client', name='docker_client')
+ at mock.patch('arvados_docker.cleaner.run', name='cleaner_run')
+class MainTestCase(unittest.TestCase):
+    def test_client_api_version(self, run_mock, docker_client):
+        cleaner.main(['--quota', '1000T'])
+        self.assertEqual(1, docker_client.call_count)
+        # 1.14 is the first version that's well defined, going back to
+        # Docker 1.2, and still supported up to at least Docker 1.9.
+        # See <https://docs.docker.com/engine/reference/api/docker_remote_api/>.
+        self.assertEqual('1.14',
+                         docker_client.call_args[1].get('version'))
+        self.assertEqual(1, run_mock.call_count)
+        self.assertIs(run_mock.call_args[0][1], docker_client())
+
+
 class ContainerRemovalTestCase(unittest.TestCase):
     LIFECYCLE = ['create', 'attach', 'start', 'resize', 'die', 'destroy']
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list