From ad48d910fc6e4f8cf2770a9540969b94c7bde914 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Thu, 6 Feb 2020 20:19:17 +0000 Subject: [PATCH] Add k8s_exec test --- molecule/default/tasks/full.yml | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/molecule/default/tasks/full.yml b/molecule/default/tasks/full.yml index b99f0d3a..2a0c1f9d 100644 --- a/molecule/default/tasks/full.yml +++ b/molecule/default/tasks/full.yml @@ -37,6 +37,41 @@ - "'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