diff --git a/tests/integration/api_container_test.py b/tests/integration/api_container_test.py index aa27fbfd7..50df39f24 100644 --- a/tests/integration/api_container_test.py +++ b/tests/integration/api_container_test.py @@ -1294,7 +1294,10 @@ def test_attach_no_stream(self): ) self.tmp_containers.append(container) self.client.start(container) - self.client.wait(container, condition='not-running') + wait_kwargs = {} + if TEST_API_VERSION >= "1.30": + wait_kwargs['condition'] = 'not-running' + self.client.wait(container, **wait_kwargs) output = self.client.attach(container, stream=False, logs=True) assert output == 'hello\n'.encode(encoding='ascii') diff --git a/tests/integration/api_exec_test.py b/tests/integration/api_exec_test.py index 4d7748f5e..f0dfe53eb 100644 --- a/tests/integration/api_exec_test.py +++ b/tests/integration/api_exec_test.py @@ -2,7 +2,7 @@ from ..helpers import ctrl_with from ..helpers import requires_api_version from .base import BaseAPIIntegrationTest -from .base import TEST_IMG +from .base import TEST_IMG, TEST_API_VERSION from docker.utils.proxy import ProxyConfig from docker.utils.socket import next_frame_header from docker.utils.socket import read_exactly @@ -35,17 +35,19 @@ def test_execute_command_with_proxy_env(self): for item in expected: assert item in output - # Overwrite some variables with a custom environment - env = {'https_proxy': 'xxx', 'HTTPS_PROXY': 'XXX'} - - res = self.client.exec_create(container, cmd=cmd, environment=env) - output = self.client.exec_start(res).decode('utf-8').split('\n') - expected = [ - 'ftp_proxy=a', 'https_proxy=xxx', 'http_proxy=c', 'no_proxy=d', - 'FTP_PROXY=a', 'HTTPS_PROXY=XXX', 'HTTP_PROXY=c', 'NO_PROXY=d' - ] - for item in expected: - assert item in output + # Setting environment for exec is not supported in API < 1.25 + if TEST_API_VERSION > "1.24": + # Overwrite some variables with a custom environment + env = {'https_proxy': 'xxx', 'HTTPS_PROXY': 'XXX'} + + res = self.client.exec_create(container, cmd=cmd, environment=env) + output = self.client.exec_start(res).decode('utf-8').split('\n') + expected = [ + 'ftp_proxy=a', 'https_proxy=xxx', 'http_proxy=c', 'no_proxy=d', + 'FTP_PROXY=a', 'HTTPS_PROXY=XXX', 'HTTP_PROXY=c', 'NO_PROXY=d' + ] + for item in expected: + assert item in output def test_execute_command(self): container = self.client.create_container(TEST_IMG, 'cat', diff --git a/tests/integration/api_swarm_test.py b/tests/integration/api_swarm_test.py index b4125d24d..69c950567 100644 --- a/tests/integration/api_swarm_test.py +++ b/tests/integration/api_swarm_test.py @@ -27,8 +27,6 @@ def test_init_swarm_simple(self): @requires_api_version('1.24') def test_init_swarm_force_new_cluster(self): - pytest.skip('Test stalls the engine on 1.12.0') - assert self.init_swarm() version_1 = self.client.inspect_swarm()['Version']['Index'] assert self.client.init_swarm(force_new_cluster=True) diff --git a/tests/integration/models_containers_test.py b/tests/integration/models_containers_test.py index 219b9a4cb..91ef68718 100644 --- a/tests/integration/models_containers_test.py +++ b/tests/integration/models_containers_test.py @@ -104,6 +104,7 @@ def test_run_with_network(self): assert 'Networks' in attrs['NetworkSettings'] assert list(attrs['NetworkSettings']['Networks'].keys()) == [net_name] + @requires_api_version('1.32') def test_run_with_networking_config(self): net_name = random_name() client = docker.from_env(version=TEST_API_VERSION) @@ -137,6 +138,7 @@ def test_run_with_networking_config(self): assert attrs['NetworkSettings']['Networks'][net_name]['DriverOpts'] \ == test_driver_opt + @requires_api_version('1.32') def test_run_with_networking_config_with_undeclared_network(self): net_name = random_name() client = docker.from_env(version=TEST_API_VERSION) @@ -165,6 +167,7 @@ def test_run_with_networking_config_with_undeclared_network(self): ) self.tmp_containers.append(container.id) + @requires_api_version('1.32') def test_run_with_networking_config_only_undeclared_network(self): net_name = random_name() client = docker.from_env(version=TEST_API_VERSION) diff --git a/tests/integration/models_services_test.py b/tests/integration/models_services_test.py index f1439a418..2607f8a7a 100644 --- a/tests/integration/models_services_test.py +++ b/tests/integration/models_services_test.py @@ -23,25 +23,30 @@ def tearDownClass(cls): def test_create(self): client = docker.from_env(version=TEST_API_VERSION) name = helpers.random_name() - service = client.services.create( + create_kwargs = { # create arguments - name=name, - labels={'foo': 'bar'}, + 'name': name, + 'labels': {'foo': 'bar'}, # ContainerSpec arguments - image="alpine", - command="sleep 300", - container_labels={'container': 'label'}, - rollback_config={'order': 'start-first'} - ) + 'image': "alpine", + 'command': "sleep 300", + 'container_labels': {'container': 'label'} + } + if TEST_API_VERSION >= "1.28": + args['rollback_config'] = {'order': 'start-first'} + + service = client.services.create(**create_kwargs) + assert service.name == name assert service.attrs['Spec']['Labels']['foo'] == 'bar' container_spec = service.attrs['Spec']['TaskTemplate']['ContainerSpec'] assert "alpine" in container_spec['Image'] assert container_spec['Labels'] == {'container': 'label'} - spec_rollback = service.attrs['Spec'].get('RollbackConfig', None) - assert spec_rollback is not None - assert ('Order' in spec_rollback and - spec_rollback['Order'] == 'start-first') + if TEST_API_VERSION >= "1.28": + spec_rollback = service.attrs['Spec'].get('RollbackConfig', None) + assert spec_rollback is not None + assert ('Order' in spec_rollback and + spec_rollback['Order'] == 'start-first') def test_create_with_network(self): client = docker.from_env(version=TEST_API_VERSION)