mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-14 13:32:14 +00:00
[backport/2.1] molecule to ansible-test CI migration (#398)
integration testing migration from molecule to ansible-test
This commit is contained in:
3
tests/integration/targets/lookup_k8s/aliases
Normal file
3
tests/integration/targets/lookup_k8s/aliases
Normal file
@@ -0,0 +1,3 @@
|
||||
context/target
|
||||
time=16
|
||||
k8s
|
||||
54
tests/integration/targets/lookup_k8s/tasks/main.yml
Normal file
54
tests/integration/targets/lookup_k8s/tasks/main.yml
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
- block:
|
||||
# https://github.com/ansible-collections/kubernetes.core/issues/9
|
||||
- name: Create a namespace with label
|
||||
kubernetes.core.k8s:
|
||||
definition:
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: "app-development-one"
|
||||
labels:
|
||||
namespace_label: "app_development"
|
||||
|
||||
- set_fact:
|
||||
namespace_info: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}"
|
||||
|
||||
- name: Check if the returned value is list with a single element
|
||||
assert:
|
||||
that:
|
||||
- namespace_info is iterable
|
||||
- not namespace_info is string
|
||||
- not namespace_info is mapping
|
||||
- namespace_info | length == 1
|
||||
|
||||
- name: Create another namespace with label
|
||||
kubernetes.core.k8s:
|
||||
definition:
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: "app-development-two"
|
||||
labels:
|
||||
namespace_label: "app_development"
|
||||
|
||||
- set_fact:
|
||||
namespace_info: "{{ lookup('kubernetes.core.k8s', kind='Namespace', label_selector='namespace_label=app_development') }}"
|
||||
|
||||
- name: Check if the returned value is list with 2 elements
|
||||
assert:
|
||||
that:
|
||||
- namespace_info is iterable
|
||||
- not namespace_info is string
|
||||
- not namespace_info is mapping
|
||||
- namespace_info | length == 2
|
||||
|
||||
always:
|
||||
- name: Ensure that namespace is removed
|
||||
k8s:
|
||||
kind: Namespace
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- app-development-one
|
||||
- app-development-two
|
||||
Reference in New Issue
Block a user