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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 38 deletions

View File

@ -251,7 +251,7 @@ stages:
testFormat: devel/rhel/{0} testFormat: devel/rhel/{0}
targets: targets:
- test: '7.9' - test: '7.9'
- test: '8.5' - test: '8.5/pypi-latest'
groups: groups:
- 1 - 1
- 2 - 2

View File

@ -21,10 +21,10 @@
ignore_errors: yes ignore_errors: yes
register: output register: output
- name: assert failure when called with no name - name: Assert failure when called with no name
assert: assert:
that: that:
- 'output.failed' - 'output is failed'
- 'output.msg == "missing required arguments: name"' - 'output.msg == "missing required arguments: name"'
- name: Test parameters - name: Test parameters
@ -34,10 +34,10 @@
ignore_errors: yes ignore_errors: yes
register: output register: output
- name: assert failure when called with no data - name: Assert failure when called with no data
assert: assert:
that: that:
- 'output.failed' - 'output is failed'
- 'output.msg == "state is present but any of the following are missing: data, data_src"' - 'output.msg == "state is present but any of the following are missing: data, data_src"'
- name: Create config - name: Create config
@ -56,9 +56,10 @@
register: inspect register: inspect
ignore_errors: yes ignore_errors: yes
- debug: var=inspect - debug:
var: inspect
- name: assert config creation succeeded - name: Assert config creation succeeded
assert: assert:
that: that:
- "'db_password' in inspect.stdout" - "'db_password' in inspect.stdout"
@ -76,10 +77,10 @@
state: present state: present
register: output register: output
- name: assert create config is idempotent - name: Assert create config is idempotent
assert: assert:
that: that:
- not output.changed - output is not changed
- name: Write config into file - name: Write config into file
copy: copy:
@ -94,10 +95,10 @@
state: present state: present
register: output register: output
- name: assert create config is idempotent - name: Assert create config is idempotent
assert: assert:
that: that:
- not output.changed - output is not changed
- name: Create config again (base64) - name: Create config again (base64)
docker_config: docker_config:
@ -107,10 +108,10 @@
state: present state: present
register: output register: output
- name: assert create config (base64) is idempotent - name: Assert create config (base64) is idempotent
assert: assert:
that: that:
- not output.changed - output is not changed
- name: Update config - name: Update config
docker_config: docker_config:
@ -119,10 +120,10 @@
state: present state: present
register: output register: output
- name: assert config was updated - name: Assert config was updated
assert: assert:
that: that:
- output.changed - output is changed
- output.config_id != config_id - output.config_id != config_id
- name: Remove config - name: Remove config
@ -135,10 +136,10 @@
register: output register: output
ignore_errors: yes ignore_errors: yes
- name: assert config was removed - name: Assert config was removed
assert: assert:
that: that:
- output.failed - output is failed
- name: Remove config - name: Remove config
docker_config: docker_config:
@ -146,10 +147,10 @@
state: absent state: absent
register: output register: output
- name: assert remove config is idempotent - name: Assert remove config is idempotent
assert: assert:
that: that:
- not output.changed - output is not changed
# Rolling update # Rolling update
@ -170,9 +171,10 @@
register: inspect register: inspect
ignore_errors: yes ignore_errors: yes
- debug: var=inspect - debug:
var: inspect
- name: assert config creation succeeded - name: Assert config creation succeeded
assert: assert:
that: that:
- "'rolling_password' in inspect.stdout" - "'rolling_password' in inspect.stdout"
@ -193,10 +195,10 @@
state: present state: present
register: new_output register: new_output
- name: assert that new version is created - name: Assert that new version is created
assert: assert:
that: that:
- new_output.changed - new_output is changed
- new_output.config_id != original_output.config_id - new_output.config_id != original_output.config_id
- new_output.config_name != original_output.config_name - new_output.config_name != original_output.config_name
- new_output.config_name == 'rolling_password_v2' - new_output.config_name == 'rolling_password_v2'
@ -212,20 +214,20 @@
register: output register: output
ignore_errors: yes ignore_errors: yes
- name: assert config was removed - name: Assert config was removed
assert: assert:
that: that:
- output.failed - output is failed
- name: Check that config is removed - name: Check that config is removed
command: "docker config inspect {{ new_output.config_id }}" command: "docker config inspect {{ new_output.config_id }}"
register: output register: output
ignore_errors: yes ignore_errors: yes
- name: assert config was removed - name: Assert config was removed
assert: assert:
that: that:
- output.failed - output is failed
# template_driver tests # template_driver tests
@ -263,7 +265,7 @@
- name: Assert failure when called with invalid template_driver - name: Assert failure when called with invalid template_driver
assert: assert:
that: that:
- 'output.failed' - 'output is failed'
- 'output.msg == "value of template_driver must be one of: golang, got: not a template driver"' - 'output.msg == "value of template_driver must be one of: golang, got: not a template driver"'
- name: Create config again - name: Create config again
@ -296,12 +298,13 @@
debug: debug:
var: inspect var: inspect
- name: assert config creation succeeded - name: Assert config creation succeeded
assert: assert:
that: that:
- "'db_password' in inspect.stdout" - "'db_password' in inspect.stdout"
- "'ansible_key' 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" - "'Templating' in inspect.stdout"
- "'\"Name\": \"golang\"' in inspect.stdout" - "'\"Name\": \"golang\"' in inspect.stdout"
@ -318,7 +321,7 @@
- name: Assert config was removed - name: Assert config was removed
assert: assert:
that: that:
- output.failed - output is failed
always: always:
- name: Remove a Swarm cluster - name: Remove a Swarm cluster

View File

@ -50,11 +50,11 @@
docker_pip_package_limit: '<4.3.0' docker_pip_package_limit: '<4.3.0'
when: (docker_api_version_stdout.stdout | default('0.0')) is version('1.39', '<') when: (docker_api_version_stdout.stdout | default('0.0')) is version('1.39', '<')
- name: Install Python requirements - name: Install/upgrade Python requirements
pip: pip:
state: present
name: "{{ [docker_pip_package ~ docker_pip_package_limit] + docker_pip_extra_packages }}" name: "{{ [docker_pip_package ~ docker_pip_package_limit] + docker_pip_extra_packages }}"
extra_args: "-c {{ remote_constraints }}" extra_args: "-c {{ remote_constraints }}"
state: "{{ 'latest' if force_docker_sdk_for_python_pypi | default(false) else 'present' }}"
notify: cleanup docker notify: cleanup docker
# Detect docker CLI, API and docker-py versions # Detect docker CLI, API and docker-py versions

View File

@ -7,20 +7,33 @@ IFS='/:' read -ra args <<< "$1"
platform="${args[0]}" platform="${args[0]}"
version="${args[1]}" version="${args[1]}"
target="shippable/posix/"
if [ "${#args[@]}" -gt 2 ]; then force_python=""
if [ "${#args[@]}" -gt 3 ]; then
if [ "${args[2]}" == "pypi-latest" ]; then
echo 'force_docker_sdk_for_python_pypi: true' >> tests/integration/interation_config.yml
if [ "${platform}" == "rhel" ] && [[ "${version}" =~ ^8\. ]]; then
# Use Python 3.8 on RHEL 8.x - TODO: this might be no longer necessary for high enough minor version! Check!
force_python="--python 3.8"
fi
else
echo "Invalid Docker SDK for Python version: '${args[2]}'"
exit 254
fi
target="shippable/posix/group${args[3]}/"
elif [ "${#args[@]}" -gt 2 ]; then
target="shippable/posix/group${args[2]}/" target="shippable/posix/group${args[2]}/"
else
target="shippable/posix/"
fi fi
stage="${S:-prod}" stage="${S:-prod}"
provider="${P:-default}" provider="${P:-default}"
if [ "${platform}" == "rhel" ] && [[ "${version}" =~ ^8 ]]; then if [ "${platform}" == "rhel" ] && [[ "${version}" =~ ^8\. ]]; then
echo "pynacl >= 1.4.0, < 1.5.0; python_version == '3.6'" >> tests/utils/constraints.txt echo "pynacl >= 1.4.0, < 1.5.0; python_version == '3.6'" >> tests/utils/constraints.txt
fi fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \ ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
--remote "${platform}/${version}" --remote-terminate always --remote-stage "${stage}" --remote-provider "${provider}" --remote "${platform}/${version}" --remote-terminate always --remote-stage "${stage}" --remote-provider "${provider}" ${force_python}