summaryrefslogtreecommitdiff
path: root/tests/integration/regression_test.py
blob: 10313a637c304fc0f93fb0d54de9f6bccfa193fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import io
import random

import docker

from .base import BaseAPIIntegrationTest, TEST_IMG
import pytest


class TestRegressions(BaseAPIIntegrationTest):
    @pytest.mark.xfail(True, reason='Docker API always returns chunked resp')
    def test_443_handle_nonchunked_response_in_stream(self):
        dfile = io.BytesIO()
        with pytest.raises(docker.errors.APIError) as exc:
            for line in self.client.build(fileobj=dfile, tag="a/b/c"):
                pass
        assert exc.value.is_error()
        dfile.close()

    def test_542_truncate_ids_client_side(self):
        self.client.start(
            self.client.create_container(TEST_IMG, ['true'])
        )
        result = self.client.containers(all=True, trunc=True)
        assert len(result[0]['Id']) == 12

    def test_647_support_doubleslash_in_image_names(self):
        with pytest.raises(docker.errors.APIError):
            self.client.inspect_image('gensokyo.jp//kirisame')

    def test_649_handle_timeout_value_none(self):
        self.client.timeout = None
        ctnr = self.client.create_container(TEST_IMG, ['sleep', '2'])
        self.client.start(ctnr)
        self.client.stop(ctnr)

    def test_715_handle_user_param_as_int_value(self):
        ctnr = self.client.create_container(TEST_IMG, ['id', '-u'], user=1000)
        self.client.start(ctnr)
        self.client.wait(ctnr)
        logs = self.client.logs(ctnr)
        logs = logs.decode('utf-8')
        assert logs == '1000\n'

    def test_792_explicit_port_protocol(self):

        tcp_port, udp_port = random.sample(range(9999, 32000), 2)
        ctnr = self.client.create_container(
            TEST_IMG, ['sleep', '9999'], ports=[2000, (2000, 'udp')],
            host_config=self.client.create_host_config(
                port_bindings={'2000/tcp': tcp_port, '2000/udp': udp_port}
            )
        )
        self.tmp_containers.append(ctnr)
        self.client.start(ctnr)
        assert self.client.port(
            ctnr, 2000
        )[0]['HostPort'] == str(tcp_port)
        assert self.client.port(
            ctnr, '2000/tcp'
        )[0]['HostPort'] == str(tcp_port)
        assert self.client.port(
            ctnr, '2000/udp'
        )[0]['HostPort'] == str(udp_port)