Skip to content

Commit 20ef813

Browse files
committed
Adjust integration tests
Signed-off-by: Christopher Petito <[email protected]>
1 parent bd164f9 commit 20ef813

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed

tests/integration/api_container_test.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,10 @@ def test_attach_no_stream(self):
12941294
)
12951295
self.tmp_containers.append(container)
12961296
self.client.start(container)
1297-
self.client.wait(container, condition='not-running')
1297+
wait_kwargs = {}
1298+
if TEST_API_VERSION >= "1.30":
1299+
wait_kwargs['condition'] = 'not-running'
1300+
self.client.wait(container, **wait_kwargs)
12981301
output = self.client.attach(container, stream=False, logs=True)
12991302
assert output == 'hello\n'.encode(encoding='ascii')
13001303

tests/integration/api_exec_test.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from ..helpers import ctrl_with
33
from ..helpers import requires_api_version
44
from .base import BaseAPIIntegrationTest
5-
from .base import TEST_IMG
5+
from .base import TEST_IMG, TEST_API_VERSION
66
from docker.utils.proxy import ProxyConfig
77
from docker.utils.socket import next_frame_header
88
from docker.utils.socket import read_exactly
@@ -35,17 +35,19 @@ def test_execute_command_with_proxy_env(self):
3535
for item in expected:
3636
assert item in output
3737

38-
# Overwrite some variables with a custom environment
39-
env = {'https_proxy': 'xxx', 'HTTPS_PROXY': 'XXX'}
40-
41-
res = self.client.exec_create(container, cmd=cmd, environment=env)
42-
output = self.client.exec_start(res).decode('utf-8').split('\n')
43-
expected = [
44-
'ftp_proxy=a', 'https_proxy=xxx', 'http_proxy=c', 'no_proxy=d',
45-
'FTP_PROXY=a', 'HTTPS_PROXY=XXX', 'HTTP_PROXY=c', 'NO_PROXY=d'
46-
]
47-
for item in expected:
48-
assert item in output
38+
# Setting environment for exec is not supported in API < 1.25
39+
if TEST_API_VERSION > "1.24":
40+
# Overwrite some variables with a custom environment
41+
env = {'https_proxy': 'xxx', 'HTTPS_PROXY': 'XXX'}
42+
43+
res = self.client.exec_create(container, cmd=cmd, environment=env)
44+
output = self.client.exec_start(res).decode('utf-8').split('\n')
45+
expected = [
46+
'ftp_proxy=a', 'https_proxy=xxx', 'http_proxy=c', 'no_proxy=d',
47+
'FTP_PROXY=a', 'HTTPS_PROXY=XXX', 'HTTP_PROXY=c', 'NO_PROXY=d'
48+
]
49+
for item in expected:
50+
assert item in output
4951

5052
def test_execute_command(self):
5153
container = self.client.create_container(TEST_IMG, 'cat',

tests/integration/api_swarm_test.py

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ def test_init_swarm_simple(self):
2727

2828
@requires_api_version('1.24')
2929
def test_init_swarm_force_new_cluster(self):
30-
pytest.skip('Test stalls the engine on 1.12.0')
31-
3230
assert self.init_swarm()
3331
version_1 = self.client.inspect_swarm()['Version']['Index']
3432
assert self.client.init_swarm(force_new_cluster=True)

tests/integration/models_containers_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def test_run_with_network(self):
104104
assert 'Networks' in attrs['NetworkSettings']
105105
assert list(attrs['NetworkSettings']['Networks'].keys()) == [net_name]
106106

107+
@requires_api_version('1.32')
107108
def test_run_with_networking_config(self):
108109
net_name = random_name()
109110
client = docker.from_env(version=TEST_API_VERSION)
@@ -137,6 +138,7 @@ def test_run_with_networking_config(self):
137138
assert attrs['NetworkSettings']['Networks'][net_name]['DriverOpts'] \
138139
== test_driver_opt
139140

141+
@requires_api_version('1.32')
140142
def test_run_with_networking_config_with_undeclared_network(self):
141143
net_name = random_name()
142144
client = docker.from_env(version=TEST_API_VERSION)
@@ -165,6 +167,7 @@ def test_run_with_networking_config_with_undeclared_network(self):
165167
)
166168
self.tmp_containers.append(container.id)
167169

170+
@requires_api_version('1.32')
168171
def test_run_with_networking_config_only_undeclared_network(self):
169172
net_name = random_name()
170173
client = docker.from_env(version=TEST_API_VERSION)

tests/integration/models_services_test.py

+17-12
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,30 @@ def tearDownClass(cls):
2323
def test_create(self):
2424
client = docker.from_env(version=TEST_API_VERSION)
2525
name = helpers.random_name()
26-
service = client.services.create(
26+
create_kwargs = {
2727
# create arguments
28-
name=name,
29-
labels={'foo': 'bar'},
28+
'name': name,
29+
'labels': {'foo': 'bar'},
3030
# ContainerSpec arguments
31-
image="alpine",
32-
command="sleep 300",
33-
container_labels={'container': 'label'},
34-
rollback_config={'order': 'start-first'}
35-
)
31+
'image': "alpine",
32+
'command': "sleep 300",
33+
'container_labels': {'container': 'label'}
34+
}
35+
if TEST_API_VERSION >= "1.28":
36+
args['rollback_config'] = {'order': 'start-first'}
37+
38+
service = client.services.create(**create_kwargs)
39+
3640
assert service.name == name
3741
assert service.attrs['Spec']['Labels']['foo'] == 'bar'
3842
container_spec = service.attrs['Spec']['TaskTemplate']['ContainerSpec']
3943
assert "alpine" in container_spec['Image']
4044
assert container_spec['Labels'] == {'container': 'label'}
41-
spec_rollback = service.attrs['Spec'].get('RollbackConfig', None)
42-
assert spec_rollback is not None
43-
assert ('Order' in spec_rollback and
44-
spec_rollback['Order'] == 'start-first')
45+
if TEST_API_VERSION >= "1.28":
46+
spec_rollback = service.attrs['Spec'].get('RollbackConfig', None)
47+
assert spec_rollback is not None
48+
assert ('Order' in spec_rollback and
49+
spec_rollback['Order'] == 'start-first')
4550

4651
def test_create_with_network(self):
4752
client = docker.from_env(version=TEST_API_VERSION)

0 commit comments

Comments
 (0)