mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-13 21:12:05 +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/k8s_exec/aliases
Normal file
3
tests/integration/targets/k8s_exec/aliases
Normal file
@@ -0,0 +1,3 @@
|
||||
k8s_exec
|
||||
k8s
|
||||
time=11
|
||||
1
tests/integration/targets/k8s_exec/defaults/main.yml
Normal file
1
tests/integration/targets/k8s_exec/defaults/main.yml
Normal file
@@ -0,0 +1 @@
|
||||
---
|
||||
64
tests/integration/targets/k8s_exec/tasks/main.yml
Normal file
64
tests/integration/targets/k8s_exec/tasks/main.yml
Normal file
@@ -0,0 +1,64 @@
|
||||
---
|
||||
- vars:
|
||||
exec_namespace: k8s-exec
|
||||
pod: sleep-pod
|
||||
exec_pod_definition:
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "{{ pod }}"
|
||||
namespace: "{{ exec_namespace }}"
|
||||
spec:
|
||||
containers:
|
||||
- name: sleeper
|
||||
image: busybox
|
||||
command: ["sleep", "infinity"]
|
||||
|
||||
block:
|
||||
- name: "Ensure that {{ exec_namespace }} namespace exists"
|
||||
k8s:
|
||||
kind: Namespace
|
||||
name: "{{ exec_namespace }}"
|
||||
|
||||
- name: "Create a pod"
|
||||
k8s:
|
||||
definition: "{{ exec_pod_definition }}"
|
||||
wait: yes
|
||||
wait_sleep: 1
|
||||
wait_timeout: 30
|
||||
|
||||
- name: "Execute a command"
|
||||
k8s_exec:
|
||||
pod: "{{ pod }}"
|
||||
namespace: "{{ exec_namespace }}"
|
||||
command: cat /etc/resolv.conf
|
||||
register: output
|
||||
|
||||
- name: "Show k8s_exec output"
|
||||
debug:
|
||||
var: output
|
||||
|
||||
- name: "Assert k8s_exec output is correct"
|
||||
assert:
|
||||
that:
|
||||
- "'nameserver' in output.stdout"
|
||||
|
||||
- name: Check if rc is returned for the given command
|
||||
k8s_exec:
|
||||
namespace: "{{ exec_namespace }}"
|
||||
pod: "{{ pod }}"
|
||||
command: 'false'
|
||||
register: command_status
|
||||
ignore_errors: True
|
||||
|
||||
- name: Check last command status
|
||||
assert:
|
||||
that:
|
||||
- command_status.return_code != 0
|
||||
|
||||
always:
|
||||
- name: "Cleanup namespace"
|
||||
k8s:
|
||||
kind: Namespace
|
||||
name: "{{ exec_namespace }}"
|
||||
state: absent
|
||||
Reference in New Issue
Block a user