mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-06 21:12:37 +00:00
[backport/2.2] Move integration test suite from molecule to ansible-test (#392)
Move integration test suite from molecule to ansible-test
SUMMARY
molecule has been replaced with ansible-test
some test cases have been updated
k8s_apply : remove duplicated tasks increasing the running time of the test
helm: use different namespaces for different test cases in order to wait for the namespace deletion before moving to the next test.
all: remove wait: yes at the end of each test when deleting namespace, the role used to create namespace will ensure that it is deleted before if existing.
ISSUE TYPE
Feature Pull Request
COMPONENT NAME
integration testing
Reviewed-by: Mike Graves mgraves@redhat.com
Reviewed-by: Gonéri Le Bouder goneri@lebouder.net
Reviewed-by: None
(cherry picked from commit fd61f8b)
SUMMARY
ISSUE TYPE
Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request
COMPONENT NAME
ADDITIONAL INFORMATION
This commit is contained in:
148
tests/integration/targets/k8s_diff/tasks/main.yml
Normal file
148
tests/integration/targets/k8s_diff/tasks/main.yml
Normal file
@@ -0,0 +1,148 @@
|
||||
---
|
||||
- block:
|
||||
- set_fact:
|
||||
diff_namespace: "{{ test_namespace }}"
|
||||
|
||||
# Using option 'apply' set to 'yes'
|
||||
- name: Create Pod using apply and diff set to yes
|
||||
k8s:
|
||||
namespace: '{{ diff_namespace }}'
|
||||
apply: yes
|
||||
template: "pod.j2"
|
||||
diff: yes
|
||||
vars:
|
||||
pod_name: "pod-apply"
|
||||
pod_image: "busybox:1.32.0"
|
||||
register: result
|
||||
|
||||
- name: check that result has diff attribute
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.diff is defined
|
||||
|
||||
- name: Update pod definition using apply and diff set to no
|
||||
k8s:
|
||||
namespace: '{{ diff_namespace }}'
|
||||
apply: yes
|
||||
template: "pod.j2"
|
||||
diff: no
|
||||
vars:
|
||||
pod_name: "pod-apply"
|
||||
pod_image: "busybox:1.33.0"
|
||||
register: result
|
||||
|
||||
- name: check that output has no diff attribute
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.diff is not defined
|
||||
|
||||
# Using option 'state=patched'
|
||||
- name: Create Pod using state=present and diff set to yes
|
||||
k8s:
|
||||
namespace: '{{ diff_namespace }}'
|
||||
state: present
|
||||
template: "pod.j2"
|
||||
vars:
|
||||
pod_name: "pod-patch"
|
||||
pod_image: "busybox:1.32.0"
|
||||
register: result
|
||||
|
||||
- name: Update pod definition using state=patched
|
||||
k8s:
|
||||
namespace: '{{ diff_namespace }}'
|
||||
state: patched
|
||||
template: "pod.j2"
|
||||
diff: no
|
||||
vars:
|
||||
pod_name: "pod-patch"
|
||||
pod_image: "busybox:1.33.0"
|
||||
pod_label: "patching"
|
||||
register: result
|
||||
|
||||
- name: check that output has no diff attribute
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.diff is not defined
|
||||
|
||||
- name: Update pod definition using state=patched and diff=yes
|
||||
k8s:
|
||||
namespace: '{{ diff_namespace }}'
|
||||
state: patched
|
||||
template: "pod.j2"
|
||||
diff: yes
|
||||
vars:
|
||||
pod_name: "pod-patch"
|
||||
pod_image: "busybox:1.33.0"
|
||||
pod_label: "running"
|
||||
register: result
|
||||
|
||||
- name: check that output has no diff attribute
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.diff is defined
|
||||
|
||||
# check diff mode using force=yes
|
||||
- name: Create a ConfigMap
|
||||
k8s:
|
||||
kind: ConfigMap
|
||||
name: '{{ diff_configmap }}'
|
||||
namespace: '{{ diff_namespace }}'
|
||||
definition:
|
||||
data:
|
||||
key: "initial value"
|
||||
diff: yes
|
||||
register: result
|
||||
|
||||
- name: check that output has no diff attribute
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.diff is not defined
|
||||
|
||||
- name: Update ConfigMap using force and diff=no
|
||||
k8s:
|
||||
kind: ConfigMap
|
||||
name: '{{ diff_configmap }}'
|
||||
namespace: '{{ diff_namespace }}'
|
||||
force: yes
|
||||
definition:
|
||||
data:
|
||||
key: "update value with diff=no"
|
||||
diff: no
|
||||
register: result
|
||||
|
||||
- name: check that output has no diff attribute
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.diff is not defined
|
||||
|
||||
- name: Update ConfigMap using force and diff=yes
|
||||
k8s:
|
||||
kind: ConfigMap
|
||||
name: '{{ diff_configmap }}'
|
||||
namespace: '{{ diff_namespace }}'
|
||||
force: yes
|
||||
definition:
|
||||
data:
|
||||
key: "update value with diff=yes"
|
||||
diff: yes
|
||||
register: result
|
||||
|
||||
- name: check that output has diff attribute
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.diff is defined
|
||||
|
||||
always:
|
||||
- name: Ensure namespace is deleted
|
||||
k8s:
|
||||
state: absent
|
||||
kind: Namespace
|
||||
name: '{{ diff_namespace }}'
|
||||
ignore_errors: true
|
||||
Reference in New Issue
Block a user