Run some tests with the latest PyPi version of Docker SDK for Python (#348)

* Run some tests with the latest PyPi version of Docker SDK for Python.

* Use new enough Python so we can actually install the latest Docker SDK for Python.

* Ansibilize

* Fix test.

* Fix two stupid errors by myself.
This commit is contained in:
Felix Fontein
2022-05-13 22:06:51 +02:00
committed by GitHub
parent 560bf1d3a3
commit 155a8b4ba9
4 changed files with 54 additions and 38 deletions
@@ -21,10 +21,10 @@
ignore_errors: yes
register: output
- name: assert failure when called with no name
- name: Assert failure when called with no name
assert:
that:
- 'output.failed'
- 'output is failed'
- 'output.msg == "missing required arguments: name"'
- name: Test parameters
@@ -34,10 +34,10 @@
ignore_errors: yes
register: output
- name: assert failure when called with no data
- name: Assert failure when called with no data
assert:
that:
- 'output.failed'
- 'output is failed'
- 'output.msg == "state is present but any of the following are missing: data, data_src"'
- name: Create config
@@ -56,9 +56,10 @@
register: inspect
ignore_errors: yes
- debug: var=inspect
- debug:
var: inspect
- name: assert config creation succeeded
- name: Assert config creation succeeded
assert:
that:
- "'db_password' in inspect.stdout"
@@ -76,10 +77,10 @@
state: present
register: output
- name: assert create config is idempotent
- name: Assert create config is idempotent
assert:
that:
- not output.changed
- output is not changed
- name: Write config into file
copy:
@@ -94,10 +95,10 @@
state: present
register: output
- name: assert create config is idempotent
- name: Assert create config is idempotent
assert:
that:
- not output.changed
- output is not changed
- name: Create config again (base64)
docker_config:
@@ -107,10 +108,10 @@
state: present
register: output
- name: assert create config (base64) is idempotent
- name: Assert create config (base64) is idempotent
assert:
that:
- not output.changed
- output is not changed
- name: Update config
docker_config:
@@ -119,10 +120,10 @@
state: present
register: output
- name: assert config was updated
- name: Assert config was updated
assert:
that:
- output.changed
- output is changed
- output.config_id != config_id
- name: Remove config
@@ -135,10 +136,10 @@
register: output
ignore_errors: yes
- name: assert config was removed
- name: Assert config was removed
assert:
that:
- output.failed
- output is failed
- name: Remove config
docker_config:
@@ -146,10 +147,10 @@
state: absent
register: output
- name: assert remove config is idempotent
- name: Assert remove config is idempotent
assert:
that:
- not output.changed
- output is not changed
# Rolling update
@@ -170,9 +171,10 @@
register: inspect
ignore_errors: yes
- debug: var=inspect
- debug:
var: inspect
- name: assert config creation succeeded
- name: Assert config creation succeeded
assert:
that:
- "'rolling_password' in inspect.stdout"
@@ -193,10 +195,10 @@
state: present
register: new_output
- name: assert that new version is created
- name: Assert that new version is created
assert:
that:
- new_output.changed
- new_output is changed
- new_output.config_id != original_output.config_id
- new_output.config_name != original_output.config_name
- new_output.config_name == 'rolling_password_v2'
@@ -212,20 +214,20 @@
register: output
ignore_errors: yes
- name: assert config was removed
- name: Assert config was removed
assert:
that:
- output.failed
- output is failed
- name: Check that config is removed
command: "docker config inspect {{ new_output.config_id }}"
register: output
ignore_errors: yes
- name: assert config was removed
- name: Assert config was removed
assert:
that:
- output.failed
- output is failed
# template_driver tests
@@ -263,7 +265,7 @@
- name: Assert failure when called with invalid template_driver
assert:
that:
- 'output.failed'
- 'output is failed'
- 'output.msg == "value of template_driver must be one of: golang, got: not a template driver"'
- name: Create config again
@@ -296,12 +298,13 @@
debug:
var: inspect
- name: assert config creation succeeded
- name: Assert config creation succeeded
assert:
that:
- "'db_password' in inspect.stdout"
- "'ansible_key' in inspect.stdout"
- "'\"Data\": \"default\"' in inspect.stdout"
# According to the API docs, 'Data' is "Base64-url-safe-encoded (RFC 4648) config data."
- "'\"Data\": \"e3sgLlNlcnZpY2UuTmFtZSB9fQ==\"' in inspect.stdout"
- "'Templating' in inspect.stdout"
- "'\"Name\": \"golang\"' in inspect.stdout"
@@ -318,7 +321,7 @@
- name: Assert config was removed
assert:
that:
- output.failed
- output is failed
always:
- name: Remove a Swarm cluster
@@ -50,11 +50,11 @@
docker_pip_package_limit: '<4.3.0'
when: (docker_api_version_stdout.stdout | default('0.0')) is version('1.39', '<')
- name: Install Python requirements
- name: Install/upgrade Python requirements
pip:
state: present
name: "{{ [docker_pip_package ~ docker_pip_package_limit] + docker_pip_extra_packages }}"
extra_args: "-c {{ remote_constraints }}"
state: "{{ 'latest' if force_docker_sdk_for_python_pypi | default(false) else 'present' }}"
notify: cleanup docker
# Detect docker CLI, API and docker-py versions