mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-18 12:52:37 +00:00
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:
parent
560bf1d3a3
commit
155a8b4ba9
@ -251,7 +251,7 @@ stages:
|
||||
testFormat: devel/rhel/{0}
|
||||
targets:
|
||||
- test: '7.9'
|
||||
- test: '8.5'
|
||||
- test: '8.5/pypi-latest'
|
||||
groups:
|
||||
- 1
|
||||
- 2
|
||||
|
||||
@ -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
|
||||
|
||||
@ -7,20 +7,33 @@ IFS='/:' read -ra args <<< "$1"
|
||||
|
||||
platform="${args[0]}"
|
||||
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]}/"
|
||||
else
|
||||
target="shippable/posix/"
|
||||
fi
|
||||
|
||||
stage="${S:-prod}"
|
||||
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
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
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}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user