summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Fix container.stats infinite blocking on stream mode (#3120)6.1.1RazCrimson2023-05-071-0/+11
| | | | | | | fix: api - container.stats infinite blocking on stream mode Includes additional test for no streaming Signed-off-by: Bharath Vignesh J K <52282402+RazCrimson@users.noreply.github.com>
* deps: compatiblity with requests ≥ 2.29.0 and urllib3 2.x (#3116)6.1.0Felix Fontein2023-05-051-1/+1
| | | | | | Requirements are the same, so it's still possible to use `urllib3 < 2` or `requests == 2.28.2` for example. Signed-off-by: Felix Fontein <felix@fontein.de>
* api: add `status` parameter to services list (#3093)Lorin Bucher2023-02-161-0/+14
| | | Signed-off-by: Lorin Bucher <lorin@lbtec.dev>
* api: add `one-shot` option to container `stats` (#3089)Andy Roxby2023-02-161-1/+12
| | | Signed-off-by: Andy Roxby <107427605+aroxby-wayscript@users.noreply.github.com>
* Merge branch 'master'Milas Bowman2023-01-271-1/+83
|\ | | | | | | (Old PR unintentionally went to the `master` branch.)
| * client: add `network_driver_opt` to container run and create (#3083)Mariano Scazzariello2023-01-271-1/+83
| | | | | | Signed-off-by: Mariano Scazzariello <marianoscazzariello@gmail.com>
* | fix(store): warn on init instead of throw (#3080)Yanlong Wang2023-01-101-0/+7
| | | | | | Signed-off-by: yanlong.wang <yanlong.wang@naiver.org>
* | volume: do not strip trailing characters from names (#3073)loicleyendecker2022-12-021-3/+3
| | | | | | | | | | | | Only remove `:ro` or `:rw` suffixes in their entirety; do not strip arbitrary `r` / `o` / `w` / `:` characters individually. Signed-off-by: Loïc Leyendecker <loic.leyendecker@gmail.com>
* | test: use anonymous volume for prune (#3051)Brian Goff2022-10-051-4/+3
| | | | | | | | | | | | | | This is related to https://github.com/moby/moby/pull/44216 Prunes will, by default, no longer prune named volumes, only anonymous ones. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* | api: add support for floats to docker logs params since / until (#3031)Rhiza2022-08-191-1/+17
| | | | | | | | | | | | | | | | Add support for floats to docker logs params `since` / `until` since the Docker Engine APIs support it. This allows using fractional seconds for greater precision. Signed-off-by: Archi Moebius <poerhiz@gmail.com>
* | ci: use latest stable syntax for Dockerfiles (#3035)Sebastiaan van Stijn2022-08-193-5/+11
|/ | | | | | | | | | | | I noticed one Dockerfile was pinned to 1.4; given that there's a backward compatibility guarantee on the stable syntax, the general recommendation is to use `dockerfile:1`, which makes sure that the latest stable release of the Dockerfile syntax is pulled before building. While changing, I also made some minor changes to some Dockerfiles to reduce some unneeded layers. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* test: add additional tests for cgroupns option (#3024)6.0.0Milas Bowman2022-08-122-0/+33
| | | | | See #2930. Signed-off-by: Milas Bowman <milas.bowman@docker.com>
* swarm: add support for DataPathPort on init (#2987)Chris Hand2022-08-121-0/+5
| | | | | | Adds support for setting the UDP port used for VXLAN traffic between swarm nodes Signed-off-by: Chris Hand <dexteradeus@users.noreply.github.com>
* Merge remote-tracking branch 'upstream/main' into connect-with-macMilas Bowman2022-08-1260-613/+2073
|\
| * swarm: add sysctl support for services (#3029)Quentin Mathorel2022-08-122-2/+23
| | | | | | Signed-off-by: Quentin Mathorel <quentin.mathorel@outlook.fr>
| * docs: add changelog for 6.0.0 (#3019)6.0.0b2Milas Bowman2022-08-111-1/+1
| | | | | | Signed-off-by: Milas Bowman <milas.bowman@docker.com>
| * Support `global-job` and `replicated-job` modes in Docker Swarm (#3016)Leonard Kinday2022-08-113-1/+50
| | | | | | | | | | | | | | Add `global-job` and `replicated-job` modes Fixes #2829. Signed-off-by: Leonard Kinday <leonard@kinday.ru>
| * credentials: eliminate distutils deprecation warnings (#3028)Ningú2022-08-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | While removing any usage of the deprecated `distutils` package, ("The distutils package is deprecated and slated for removal in Python 3.12.") this internal utility can be removed straightaway because the `shutil.which` replacement for `distutils.spawn.find_executable` already honors the `PATHEXT` environment variable in windows systems. See https://docs.python.org/3/library/shutil.html#shutil.which Signed-off-by: Daniel Möller <n1ngu@riseup.net>
| * ci: add workflow for releases (#3018)Milas Bowman2022-07-301-4/+9
| | | | | | | | | | | | | | | | | | | | | | GitHub Actions workflow to create a release: will upload to PyPI and create a GitHub release with the `sdist` and `bdist_wheel` as well. The version code is switched to `setuptools_scm` to work well with this flow (e.g. avoid needing to write a script that does a `sed` on the version file and commits as part of release). Signed-off-by: Milas Bowman <milas.bowman@docker.com>
| * build: trim trailing whitespace from dockerignore entries (#2733)Clément Loiselet2022-07-291-0/+9
| | | | | | | | | | fix(dockerignore): trim trailing whitespace Signed-off-by: Clément Loiselet <clement.loiselet@capgemini.com>
| * model: add remove() to Image (#3026)Milas Bowman2022-07-291-0/+10
| | | | | | | | | | | | | | | | Allow an Image to be deleted by calling the remove() method on it, just like a Volume. Signed-off-by: Ahmon Dancy <dancy@dancysoft.com> Signed-off-by: Milas Bowman <milas.bowman@docker.com> Co-authored-by: Ahmon Dancy <dancy@dancysoft.com>
| * api: add rollback_config to service create (#2917)ercildoune2022-07-292-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | `rollback_config` was not in the list of `CREATE_SERVICE_KWARGS` which prevented it from being an argument when creating services. It has now been added and the problem fixed, allowing services to have a rollback_config during creation and updating. Fixes #2832. Signed-off-by: Fraser Patten <pattenf00@gmail.com> Signed-off-by: Milas Bowman <milas.bowman@docker.com> Co-authored-by: Milas Bowman <milas.bowman@docker.com>
| * api: add force to plugin disable (#2843)Till!2022-07-291-2/+2
| | | | | | Signed-off-by: till <till@php.net>
| * api: add cgroupns option to container create (#2930)David2022-07-291-0/+2
| | | | | | Signed-off-by: David Otto <ottodavid@gmx.net>
| * api: add platform to container create (#2927)Felix Fontein2022-07-292-0/+45
| | | | | | | | | | | | | | Add platform parameter for container creation/run Signed-off-by: Felix Fontein <felix@fontein.de> Signed-off-by: Milas Bowman <milas.bowman@docker.com> Co-authored-by: Milas Bowman <milas.bowman@docker.com>
| * deps: upgrade websocket-client to latest (#3022)Milas Bowman2022-07-291-1/+20
| | | | | | | | | | | | * Upgrade websocket-client to latest * Add basic integration test for streaming logs via websocket Signed-off-by: Milas Bowman <milas.bowman@docker.com>
| * client: use 12 character short IDs (#2862)Ben Fasoli2022-07-296-74/+92
| | | | | | | | | | | | Use 12 characters for Docker resource IDs for consistency with the Docker CLI. Signed-off-by: Ben Fasoli <benfasoli@gmail.com>
| * ci: run SSH integration tests (#3012)Milas Bowman2022-07-2713-17/+55
| | | | | | | | | | | | | | | | | | | | | | | | Fix & enable SSH integration test suite. This also adds a new test for connecting to unknown hosts when using the Python SSH implementation (Paramiko). See #2932 for more info. Because of the above, some of the config/static key files have been moved around and adjusted. Signed-off-by: Milas Bowman <milas.bowman@docker.com>
| * lint: fix deprecation warnings from threading package (#2823)Karthikeyan Singaravelan2022-07-272-3/+3
| | | | | | | | | | | | Set `daemon` attribute instead of using `setDaemon` method that was deprecated in Python 3.10. Signed-off-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>
| * deps: remove backports.ssl_match_hostname (#3011)Milas Bowman2022-07-271-10/+3
| | | | | | | | | | | | This is no longer needed as it exists in every supported (non-EOL) version of Python that we target. Signed-off-by: Milas Bowman <milas.bowman@docker.com>
| * deps: test on Python 3.10 by default (#3010)Milas Bowman2022-07-273-4/+4
| | | | | | | | | | | | | | * Upgrade to latest Sphinx / recommonmark * Small CSS fix for issue in new version of Alabaster theme * Fix `Makefile` target for macOS Signed-off-by: Milas Bowman <milas.bowman@docker.com>
| * Merge pull request #3009 from milas/lint-flake8Milas Bowman2022-07-263-13/+14
| |\ | | | | | | ci: add flake8 job
| | * lint: fix outstanding flake8 violationsMilas Bowman2022-07-263-13/+14
| | | | | | | | | | | | | | | | | | | | | Since flake8 wasn't actually being run in CI, we'd accumulated some violations. Signed-off-by: Milas Bowman <milas.bowman@docker.com>
| * | test: mark invalid test as xfailMilas Bowman2022-07-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This test looks for some behavior on non-chunked HTTP requests. It now fails because it looks like recent versions of Docker Engine ALWAYS return chunked responses (or perhaps this specific response changed somehow to now trigger chunking whereas it did not previously). The actual logic it's trying to test is also unusual because it's trying to hackily propagate errors under the assumption that it'd get a non-chunked response on failure, which is...not reliable. Arguably, the chunked reader should be refactored somehow but that's a refactor we can't really commit to (and it's evidently been ok enough as is up until now). Signed-off-by: Milas Bowman <milas.bowman@docker.com>
| * | test: fix flaky container log testMilas Bowman2022-07-261-0/+2
| |/ | | | | | | | | | | | | | | | | | | 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>
| * test: fix for cgroupv2 (#2940)Sebastiaan van Stijn2022-07-261-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * utils: fix IPv6 address w/ port parsing (#3006)Milas Bowman2022-07-261-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | This was using a deprecated function (`urllib.splitnport`), ostensibly to work around issues with brackets on IPv6 addresses. Ironically, its usage was broken, and would result in mangled IPv6 addresses if they had a port specified in some instances. Usage of the deprecated function has been eliminated and extra test cases added where missing. All existing cases pass as-is. (The only other change to the test was to improve assertion messages.) Signed-off-by: Milas Bowman <milas.bowman@docker.com>
| * Don't install mock backportHugo van Kemenade2021-10-1110-51/+10
| | | | | | | | Signed-off-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
| * Merge pull request #2809 from feliperuhland/add-service-capabilityAnca Iordache2021-10-082-0/+68
| |\ | | | | | | Add service capability
| | * Add `CapabilityAdd` and `CapabilityDrop` toFelipe Ruhland2021-04-072-0/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ContainerSpec Docker Engine v1.41 added `CapAdd` and `CapDrop` as part of the ContainerSpec, and `docker-py` should do the same. ``` GET /services now returns CapAdd and CapDrop as part of the ContainerSpec. GET /services/{id} now returns CapAdd and CapDrop as part of the ContainerSpec. POST /services/create now accepts CapAdd and CapDrop as part of the ContainerSpec. POST /services/{id}/update now accepts CapAdd and CapDrop as part of the ContainerSpec. GET /tasks now returns CapAdd and CapDrop as part of the ContainerSpec. GET /tasks/{id} now returns CapAdd and CapDrop as part of the ContainerSpec. ``` I added capabilities on docstrings, `service.create` init method and create tests for that. That change was mention in issue #2802. Signed-off-by: Felipe Ruhland <felipe.ruhland@gmail.com>
| * | Merge branch 'master' into feat/add_templating_parameter_docker_configAnca Iordache2021-10-0741-356/+304
| |\ \
| | * | use python3.6+ constructsAnthony Sottile2021-07-0541-356/+304
| | |/ | | | | | | | | | Signed-off-by: Anthony Sottile <asottile@umich.edu>
| * | Add the possibility to set a templating driver when creating a new Docker configSebastiano Mariani2021-06-031-0/+13
| |/ | | | | | | Signed-off-by: Sebastiano Mariani <smariani@vmware.com>
| * Merge pull request #2476 from feliperuhland/add-search-images-limitAnca Iordache2021-04-061-0/+5
| |\ | | | | | | Add limit parameter to image search endpoint
| | * Add limit parameter to image search endpointFelipe Ruhland2021-02-241-0/+5
| | | | | | | | | | | | Signed-off-by: Felipe Ruhland <felipe.ruhland@gmail.com>
| * | Merge pull request #2788 from docker/set-minimal-python-to-3_6Anca Iordache2021-03-255-54/+37
| |\ \ | | | | | | | | Make python 3.6 the minimum version
| | * | Remove support to pre python 3.6set-minimal-python-to-3_6Ulysses Souza2021-03-225-54/+37
| | | | | | | | | | | | | | | | Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
| * | | Fix `KeyError` when creating a new secretFelipe Ruhland2021-03-243-0/+22
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | How to reproduce the issue: ```py >>> import docker >>> cli = docker.from_env() >>> cli.secrets.create(name="any_name", data="1") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/docker-py/docker/models/secrets.py", line 10, in __repr__ return "<%s: '%s'>" % (self.__class__.__name__, self.name) File "/home/docker-py/docker/models/secrets.py", line 14, in name return self.attrs['Spec']['Name'] KeyError: 'Spec' ``` The exception raises because create secrets API `/secrets/create` only return the `id` attribute: https://docs.docker.com/engine/api/v1.41/#operation/SecretCreate The secret model is created using just the `id` attribute and fails when looking for Spec.Name attribute. ```py def __repr__(self): return "<%s: '%s'>" % (self.__class__.__name__, self.name) ``` ```py @property def name(self): return self.attrs['Spec']['Name'] ``` I came up with a ugly solution but will prevent the problem to happen again: ```py def create(self, **kwargs): obj = self.client.api.create_secret(**kwargs) + obj.setdefault("Spec", {})["Name"] = kwargs.get("name") return self.prepare_model(obj) ``` After the API call, I added the name attribute to the right place to be used on the property name. ```py >>> import docker >>> cli = docker.from_env() >>> cli.secrets.create(name="any_name", data="1") <Secret: 'any_name'> ``` It isn't the most elegant solution, but it will do the trick. I had a previous PR #2517 when I propose using the `id` attribute instead of `name` on the `__repr__` method, but I think this one will be better. That fixes #2025 Signed-off-by: Felipe Ruhland <felipe.ruhland@gmail.com>
| * | relax PORT_SPEC regex so it accept and ignore square bracketsNicolas De Loof2021-03-101-0/+6
| |/ | | | | | | Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
| * Fix SSH port parsing and add regression testsaiordache2021-02-181-0/+32
| | | | | | | | Signed-off-by: aiordache <anca.iordache@docker.com>