X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/482dc81f2b7533043bc5195bded942f970f163d8..HEAD:/services/dockercleaner/tests/test_cleaner.py diff --git a/services/dockercleaner/tests/test_cleaner.py b/services/dockercleaner/tests/test_cleaner.py index 9fbd3e3014..cd03538fcd 100644 --- a/services/dockercleaner/tests/test_cleaner.py +++ b/services/dockercleaner/tests/test_cleaner.py @@ -1,15 +1,19 @@ #!/usr/bin/env python3 +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 import collections import itertools import json +import os import random import tempfile import time import unittest import docker -import mock +from unittest import mock from arvados_docker import cleaner @@ -390,7 +394,7 @@ class RunTestCase(unittest.TestCase): self.assertEqual(event_kwargs[0]['until'], event_kwargs[1]['since']) -@mock.patch('docker.Client', name='docker_client') +@mock.patch('docker.APIClient', name='docker_client') @mock.patch('arvados_docker.cleaner.run', name='cleaner_run') class MainTestCase(unittest.TestCase): @@ -400,11 +404,9 @@ class MainTestCase(unittest.TestCase): cf.flush() cleaner.main(['--config', cf.name]) 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 - # . - self.assertEqual('1.14', + # We are standardized on Docker API version 1.35. + # See DockerAPIVersion in lib/crunchrun/docker.go. + self.assertEqual('1.35', docker_client.call_args[1].get('version')) self.assertEqual(1, run_mock.call_count) self.assertIs(run_mock.call_args[0][1], docker_client()) @@ -437,6 +439,11 @@ class ConfigTestCase(unittest.TestCase): self.assertEqual('never', config['RemoveStoppedContainers']) self.assertEqual(1, config['Verbose']) + def test_args_no_config(self): + self.assertEqual(False, os.path.exists(cleaner.DEFAULT_CONFIG_FILE)) + config = cleaner.load_config(['--quota', '1G']) + self.assertEqual(1 << 30, config['Quota']) + class ContainerRemovalTestCase(unittest.TestCase): LIFECYCLE = ['create', 'attach', 'start', 'resize', 'die', 'destroy']