Commit Graph

64 Commits

Author SHA1 Message Date
Aarni Koskela d50cc429c2 Enable Ruff I (import sort), autofix
Signed-off-by: Aarni Koskela <akx@iki.fi>
2024-01-03 21:28:56 +02:00
Milas Bowman 0f0b20a6a7 Merge branch 'jannefleischer/main'
Manually merging #3164.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-15 14:04:29 -04:00
Janne Jakob Fleischer bea63224e0 volume: added support for bind propagation
https://docs.docker.com/storage/bind-mounts/#configure-bind-propagation

Signed-off-by: Janne Jakob Fleischer <janne.fleischer@ils-forschung.de>
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-08-15 10:35:07 -04:00
Aarni Koskela 8a3402c049 Replace string formatting with f-strings
Signed-off-by: Aarni Koskela <akx@iki.fi>
2023-08-15 13:36:53 +03:00
Sebastiaan van Stijn 5064995bc4
tests/integration: update some tests for updated error-messages
I was in the process of cleaning up some error-messages, and it looks like
the docker-py tests were depending on strings that will be removed;

    =================================== FAILURES ===================================
    _____________ CreateContainerTest.test_create_with_restart_policy ______________
    tests/integration/api_container_test.py:126: in test_create_with_restart_policy
        assert 'You cannot remove ' in err
    E   AssertionError: assert 'You cannot remove ' in 'cannot remove container d11580f6078108691096ec8a23404a6bda9ad1d1b2bafe88b17d127a67728833: container is restarting: stop the container before removing or force remove'
    ____________________ ErrorsTest.test_api_error_parses_json _____________________
    tests/integration/errors_test.py:13: in test_api_error_parses_json
        assert 'You cannot remove a running container' in explanation
    E   AssertionError: assert 'You cannot remove a running container' in 'cannot remove container 4b90ce2e907dd0f99d0f561619b803e7a2a31809ced366c537874dd13f8a47ec: container is running: stop the container before removing or force remove'

This updates the tests to match on a string that will be present in both the
old and new error-messages, but added a "lower()", so that matching will be
done case-insensitive (Go errors generally should be lowercase).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-14 14:52:58 +02:00
Sebastiaan van Stijn fb974de27a
tests/integration: fix flake8 failures (E721 do not compare types)
Run flake8 docker/ tests/
      flake8 docker/ tests/
      shell: /usr/bin/bash -e {0}
      env:
        DOCKER_BUILDKIT: 1
        pythonLocation: /opt/hostedtoolcache/Python/3.11.4/x64
        PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.4/x64/lib/pkgconfig
        Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
        Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
        Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
        LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.4/x64/lib
    tests/integration/api_container_test.py:1395:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
    tests/integration/api_container_test.py:1408:24: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
    tests/integration/api_image_test.py:35:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
    tests/integration/api_image_test.py:46:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
    Error: Process completed with exit code 1.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-14 10:26:36 +02:00
Milas Bowman e901eac7a8
test: add additional tests for cgroupns option (#3024)
See #2930.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-08-12 14:27:53 -04:00
Milas Bowman 26064dd6b5
deps: upgrade websocket-client to latest (#3022)
* Upgrade websocket-client to latest
* Add basic integration test for streaming logs via websocket

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-07-29 11:09:47 -04:00
Milas Bowman 74e0c5eb8c test: fix flaky container log test
Ensure the container has exited before attempting to grab the logs.

Since we are not streaming them, it's possible to attach + grab logs
before the output is processed, resulting in a test failure. If the
container has exited, it's guaranteed to have logged :)

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-07-26 13:00:49 -04:00
Sebastiaan van Stijn 7168e09b16
test: fix for cgroupv2 (#2940)
This test was verifying that the container has the right options set (through
`docker inspect`), but also checks if the cgroup-rules are set within the
container by reading `/sys/fs/cgroup/devices/devices.list`

Unlike cgroups v1, on cgroups v2, there is no file interface, and rules are
handled through ebpf, which means that the test will fail because this file
is not present.

From the Linux documentation for cgroups v2:
https://github.com/torvalds/linux/blob/v5.16/Documentation/admin-guide/cgroup-v2.rst#device-controller

> (...)
> Device controller manages access to device files. It includes both creation of
> new device files (using mknod), and access to the existing device files.
>
> Cgroup v2 device controller has no interface files and is implemented on top
> of cgroup BPF. To control access to device files, a user may create bpf programs
> of type BPF_PROG_TYPE_CGROUP_DEVICE and attach them to cgroups with
> BPF_CGROUP_DEVICE flag. (...)

Given that setting the right cgroups is not really a responsibility of this SDK,
it should be sufficient to verify that the right options were set in the container
configuration, so this patch is removing the part that checks the cgroup, to
allow this test to be run on a host with cgroups v2 enabled.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-26 12:06:51 -04:00
Anthony Sottile 5fcc293ba2 use python3.6+ constructs
Signed-off-by: Anthony Sottile <asottile@umich.edu>
2021-07-05 18:30:07 -04:00
Ulysses Souza c8fba210a2 Remove support to pre python 3.6
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-03-22 10:18:23 -03:00
Sebastiaan van Stijn 26d8045ffa Fix CreateContainerTest.test_invalid_log_driver_raises_exception
This test was updated in 7d92fbdee1, but
omitted the "error" prefix in the message, causing the test to fail;

    _________ CreateContainerTest.test_invalid_log_driver_raises_exception _________
    tests/integration/api_container_test.py:293: in test_invalid_log_driver_raises_exception
        assert excinfo.value.explanation in expected_msgs
    E   AssertionError: assert 'error looking up logging plugin asdf: plugin "asdf" not found' in ["logger: no log driver named 'asdf' is registered", 'looking up logging plugin asdf: plugin "asdf" not found']
    E    +  where 'error looking up logging plugin asdf: plugin "asdf" not found' = APIError(HTTPError('400 Client Error: Bad Request for url: http+docker://localhost/v1.39/containers/create')).explanation
    E    +    where APIError(HTTPError('400 Client Error: Bad Request for url: http+docker://localhost/v1.39/containers/create')) = <ExceptionInfo APIError tblen=6>.value

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-07-17 15:59:12 +02:00
Wilson Júnior 7d92fbdee1
Fix tests to support both log plugin feedbacks
Signed-off-by: Wilson Júnior <wilsonpjunior@gmail.com>
Docker-DCO-1.1-Signed-off-by: Wilson Júnior <wilsonpjunior@gmail.com> (github: wpjunior)
2020-04-21 17:00:48 -03:00
Sebastiaan van Stijn da90bb3259
xfail "docker top" tests, and adjust for alpine image
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-17 10:25:53 +01:00
Sebastiaan van Stijn 54b48a9b7a
Update alpine version to 3.10, and rename BUSYBOX variable
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-08-10 19:11:58 +02:00
Ulysses Souza ccd9ca4947 Xfail test_attach_stream_and_cancel on TLS
This test is quite flaky on ssl integration test

Signed-off-by: Ulysses Souza <ulysses.souza@docker.com>
2019-05-18 19:33:48 -07:00
Joffrey F eba8345c37 Update some test dependencies / default values with newer versions
Signed-off-by: Joffrey F <joffrey@docker.com>
2019-05-01 02:36:19 -07:00
Joffrey F 1a4881acd9 Improve low_timeout test resilience
Signed-off-by: Joffrey F <joffrey@docker.com>
2019-05-01 01:15:41 -07:00
Joffrey F 62c8bcbbb6 Increase timeout on test with long sleeps
Signed-off-by: Joffrey F <joffrey@docker.com>
2019-05-01 00:47:16 -07:00
Sebastiaan van Stijn 50d475797a
Remove init_path from create
This option was never functional, and was not intended
to be added to the "container create" API, so let's
remove it, because it has been removed in Docker 17.05,
and was broken in versions before that; see

- https://github.com/moby/moby/issues/32355 --init-path does not seem to work
- https://github.com/moby/moby/pull/32470 remove --init-path from client

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-04-10 02:42:23 +02:00
Ulysses Souza ef043559c4 Add 'sleep 2' to avoid race condition on attach
Signed-off-by: Ulysses Souza <ulysses.souza@docker.com>
2019-04-04 14:09:18 +02:00
Ulysses Souza 15862eacbf Xfail test_attach_stream_and_cancel on TLS
This test is quite flaky on ssl integration test

Signed-off-by: Ulysses Souza <ulysses.souza@docker.com>
2019-03-26 16:04:06 +01:00
Hannes Ljungberg 7143cf02ab Test port lookup with protocols
Signed-off-by: Hannes Ljungberg <hannes@5monkeys.se>
2019-03-18 22:15:49 +01:00
Corentin Henry 5f157bbaca implement stream demultiplexing for exec commands
fixes https://github.com/docker/docker-py/issues/1952

Signed-off-by: Corentin Henry <corentinhenry@gmail.com>
2018-11-27 17:01:48 -08:00
Joffrey F 6bfe2005e0 Clear error for cancellable streams over SSH
Signed-off-by: Joffrey F <joffrey@docker.com>
2018-11-01 15:24:22 -07:00
Joffrey F 1df021ee24 Update tests for ssh protocol compatibility
Signed-off-by: Joffrey F <joffrey@docker.com>
2018-11-01 15:24:22 -07:00
Marco Trillo 098318ad95 Add support for `uts_mode` parameter in `Client.create_host_config`.
This parameter allows to set the UTS namespace of the container, as in
the `--uts=X` Docker CLI parameter:
<https://docs.docker.com/engine/reference/run/#uts-settings---uts>
The only allowed value, if set, is "host".

Signed-off-by: Marco Trillo <martri@arantia.com>
Signed-off-by: Diego Alvarez <dyako.developer@gmail.com>
2018-06-29 14:54:49 +02:00
Joffrey F b4efdc1b28 Fix several integration tests on Windows
Signed-off-by: Joffrey F <joffrey@docker.com>
2018-05-25 10:11:02 -07:00
Joffrey F ae8f77737c Fix session timeout = None case
Signed-off-by: Joffrey F <joffrey@docker.com>
2018-04-25 15:31:26 -07:00
Joffrey F da028d88a2 Total timeout should be HTTP timeout + operation timeout
Signed-off-by: Joffrey F <joffrey@docker.com>
2018-04-25 15:31:26 -07:00
Matthieu Nottale cef9940ed3 stop(), restart(): Adjust request timeout.
Signed-off-by: Matthieu Nottale <matthieu.nottale@docker.com>
2018-04-25 15:31:26 -07:00
Joffrey F 284c3d90d6 Remove redundant single-socket select call
Clean up + use pytest-timeout

Signed-off-by: Joffrey F <joffrey@docker.com>
2018-03-20 09:25:29 +01:00
Viktor Adam 719d4e9e20 Allow cancelling the streams from other threads
Signed-off-by: Viktor Adam <rycus86@gmail.com>
2018-03-20 09:25:29 +01:00
Joffrey F 48e45afe88 Add support for device_cgroup_rules parameter in host config
Signed-off-by: Joffrey F <joffrey@docker.com>
2018-02-13 17:05:16 -08:00
Joffrey F 7fabcdaa4c Update wait to always return a dict
Signed-off-by: Joffrey F <joffrey@docker.com>
2018-01-31 16:52:26 -08:00
Joffrey F df8422d079 Refuse API version < 1.21 ; Remove associated code paths
Signed-off-by: Joffrey F <joffrey@docker.com>
2018-01-31 14:42:01 -08:00
Joffrey F ccbde11c8d Improve separation between auth_configs and general_configs
Signed-off-by: Joffrey F <joffrey@docker.com>
2018-01-30 18:42:38 -08:00
Joffrey F e304f91b46 Update detach tests to work with AF_INET as well
Signed-off-by: Joffrey F <joffrey@docker.com>
2018-01-30 17:16:23 -08:00
Fumiaki MATSUSHIMA dd858648a0 Use config.json for detachKeys
Signed-off-by: Fumiaki Matsushima <mtsmfm@gmail.com>
2018-01-30 17:16:23 -08:00
Joffrey F 3422211309 Use pytest asserts
Signed-off-by: Joffrey F <joffrey@docker.com>
2018-01-30 14:26:24 -08:00
Joffrey F abd60aedc7 Bump default API version to 1.35
Add ContainerSpec.isolation support
Add until support in logs
Add condition support in wait
Add workdir support in exec_create

Signed-off-by: Joffrey F <joffrey@docker.com>
2018-01-26 13:56:01 -08:00
Joffrey F 445cb18723 Add integration test for CPU realtime options
Signed-off-by: Joffrey F <joffrey@docker.com>
2017-12-13 19:06:29 -08:00
Joffrey F 5d1b652246 Add support for mounts in HostConfig
Signed-off-by: Joffrey F <joffrey@docker.com>
2017-11-07 15:18:26 -08:00
Joffrey F 0c2b4e4d3a Always send attach request as streaming
Signed-off-by: Joffrey F <joffrey@docker.com>
2017-08-22 17:00:11 -07:00
Joffrey F 9b9fb0aa01 Make sure data is written in prune test so space can be reclaimed
Signed-off-by: Joffrey F <joffrey@docker.com>
2017-06-20 16:07:15 -07:00
Madhuri Kumari 612c0f3d0d Fix test cases for ``runtime`` config
Signed-off-by: Madhuri Kumari <madhuri.kumari@intel.com>
2017-06-07 10:47:27 +05:30
Madhuri Kumari 6ae24b9e60 Add support for ``runtime`` in container create and run API 2017-06-01 15:09:46 +00:00
Joffrey F bf60e2a330 init_path removed in Engine 17.05
Signed-off-by: Joffrey F <joffrey@docker.com>
2017-05-09 16:16:10 -07:00
Joffrey F c2d114c067 Move LinksTest to appropriate file
Signed-off-by: Joffrey F <joffrey@docker.com>
2017-03-09 16:12:22 -08:00