mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-07-30 03:14:40 +00:00
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 <None>
This commit is contained in:
2
tests/integration/targets/k8s_crd/aliases
Normal file
2
tests/integration/targets/k8s_crd/aliases
Normal file
@@ -0,0 +1,2 @@
|
||||
time=22
|
||||
k8s
|
||||
2
tests/integration/targets/k8s_crd/defaults/main.yml
Normal file
2
tests/integration/targets/k8s_crd/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
test_namespace: "crd"
|
||||
21
tests/integration/targets/k8s_crd/files/crd-resource.yml
Normal file
21
tests/integration/targets/k8s_crd/files/crd-resource.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
apiVersion: certmanager.k8s.io/v1alpha1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: acme-crt
|
||||
spec:
|
||||
secretName: acme-crt-secret
|
||||
dnsNames:
|
||||
- foo.example.com
|
||||
- bar.example.com
|
||||
acme:
|
||||
config:
|
||||
- ingressClass: nginx
|
||||
domains:
|
||||
- foo.example.com
|
||||
- bar.example.com
|
||||
issuerRef:
|
||||
name: letsencrypt-prod
|
||||
# We can reference ClusterIssuers by changing the kind here.
|
||||
# The default value is Issuer (i.e. a locally namespaced Issuer)
|
||||
kind: Issuer
|
||||
15
tests/integration/targets/k8s_crd/files/setup-crd.yml
Normal file
15
tests/integration/targets/k8s_crd/files/setup-crd.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: certificates.certmanager.k8s.io
|
||||
spec:
|
||||
group: certmanager.k8s.io
|
||||
version: v1alpha1
|
||||
scope: Namespaced
|
||||
names:
|
||||
kind: Certificate
|
||||
plural: certificates
|
||||
shortNames:
|
||||
- cert
|
||||
- certs
|
||||
3
tests/integration/targets/k8s_crd/meta/main.yml
Normal file
3
tests/integration/targets/k8s_crd/meta/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- setup_namespace
|
||||
61
tests/integration/targets/k8s_crd/tasks/main.yml
Normal file
61
tests/integration/targets/k8s_crd/tasks/main.yml
Normal file
@@ -0,0 +1,61 @@
|
||||
---
|
||||
- block:
|
||||
- name: Install custom resource definitions
|
||||
k8s:
|
||||
definition: "{{ lookup('file', 'setup-crd.yml') }}"
|
||||
|
||||
- name: Pause 5 seconds to avoid race condition
|
||||
pause:
|
||||
seconds: 5
|
||||
|
||||
- name: Create custom resource definition
|
||||
k8s:
|
||||
definition: "{{ lookup('file', 'crd-resource.yml') }}"
|
||||
namespace: "{{ test_namespace }}"
|
||||
apply: "{{ create_crd_with_apply | default(omit) }}"
|
||||
register: create_crd
|
||||
|
||||
- name: Patch custom resource definition
|
||||
k8s:
|
||||
definition: "{{ lookup('file', 'crd-resource.yml') }}"
|
||||
namespace: "{{ test_namespace }}"
|
||||
register: recreate_crd
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Assert that recreating crd is as expected
|
||||
assert:
|
||||
that:
|
||||
- recreate_crd is not failed
|
||||
|
||||
- block:
|
||||
- name: Recreate custom resource definition with merge_type
|
||||
k8s:
|
||||
definition: "{{ lookup('file', 'crd-resource.yml') }}"
|
||||
merge_type:
|
||||
- merge
|
||||
namespace: "{{ test_namespace }}"
|
||||
register: recreate_crd_with_merge
|
||||
|
||||
- name: Recreate custom resource definition with merge_type list
|
||||
k8s:
|
||||
definition: "{{ lookup('file', 'crd-resource.yml') }}"
|
||||
merge_type:
|
||||
- strategic-merge
|
||||
- merge
|
||||
namespace: "{{ test_namespace }}"
|
||||
register: recreate_crd_with_merge_list
|
||||
when: recreate_crd is successful
|
||||
|
||||
|
||||
- name: Remove crd
|
||||
k8s:
|
||||
definition: "{{ lookup('file', 'crd-resource.yml') }}"
|
||||
namespace: "{{ test_namespace }}"
|
||||
state: absent
|
||||
|
||||
always:
|
||||
- name: Remove crd namespace
|
||||
k8s:
|
||||
kind: Namespace
|
||||
name: "{{ test_namespace }}"
|
||||
state: absent
|
||||
Reference in New Issue
Block a user