mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-04-14 21:00:54 +00:00
Move k8s_exec test to a dedicated file
This commit is contained in:
@@ -37,41 +37,6 @@
|
||||
- "'resources' in k8s_info"
|
||||
- not k8s_info.resources
|
||||
|
||||
- name: Create a pod
|
||||
k8s:
|
||||
definition:
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "{{ k8s_pod_name }}"
|
||||
namespace: testing
|
||||
spec: "{{ k8s_pod_spec }}"
|
||||
wait: yes
|
||||
wait_sleep: 1
|
||||
wait_timeout: 30
|
||||
vars:
|
||||
k8s_pod_name: sleep-pod
|
||||
k8s_pod_image: alpine:3.8
|
||||
k8s_pod_command:
|
||||
- /bin/sleep
|
||||
- infinity
|
||||
|
||||
- name: Execute a command
|
||||
k8s_exec:
|
||||
namespace: testing
|
||||
pod: sleep-pod
|
||||
command: cat /etc/os-release
|
||||
register: output
|
||||
|
||||
- name: Show k8s_exec output
|
||||
debug:
|
||||
var: output
|
||||
|
||||
- name: Assert k8s_exec output is correct
|
||||
assert:
|
||||
that:
|
||||
- "'alpine' in output.stdout"
|
||||
|
||||
- name: Create a service
|
||||
k8s:
|
||||
state: present
|
||||
|
||||
41
tests/integration/targets/kubernetes/tasks/test_k8s_exec.yml
Normal file
41
tests/integration/targets/kubernetes/tasks/test_k8s_exec.yml
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
- vars:
|
||||
ns: k8s-exec
|
||||
pod: sleep-pod
|
||||
block:
|
||||
- name: ensure that k8s-log namespace exists
|
||||
k8s:
|
||||
kind: Namespace
|
||||
name: "{{ ns }}"
|
||||
|
||||
- name: Create a pod
|
||||
k8s:
|
||||
definition:
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "{{ pod }}"
|
||||
namespace: "{{ ns }}"
|
||||
spec:
|
||||
containers:
|
||||
- image: busybox
|
||||
command: ["sleep", "infinity"]
|
||||
wait: yes
|
||||
wait_sleep: 1
|
||||
wait_timeout: 30
|
||||
|
||||
- name: Execute a command
|
||||
k8s_exec:
|
||||
pod: "{{ pod }}"
|
||||
namespace: "{{ ns }}"
|
||||
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"
|
||||
Reference in New Issue
Block a user