Merge 020_check and 030_check (#4623)

* Merge 020_check and 030_check

* Fix pods output and fail if test pods is not ready
This commit is contained in:
Maxime Guyot
2019-04-24 01:12:00 +02:00
committed by Kubernetes Prow Robot
parent 76db060afb
commit 6df8111cd4
3 changed files with 16 additions and 35 deletions

View File

@@ -1,30 +0,0 @@
---
- hosts: kube-master[0]
vars:
test_image_repo: busybox
test_image_tag: latest
tasks:
- name: Force binaries directory for Container Linux by CoreOS
set_fact:
bin_dir: "/opt/bin"
when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- set_fact:
bin_dir: "/usr/local/bin"
when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- name: Create test namespace
shell: "{{bin_dir}}/kubectl create namespace test"
- name: Run a replica controller composed of 2 pods in test ns
shell: "{{bin_dir}}/kubectl run test --image={{test_image_repo}}:{{test_image_tag}} --namespace test --replicas=2 --command -- tail -f /dev/null"
- name: Pods are running
shell: "{{bin_dir}}/kubectl get pods --namespace test --no-headers -o json"
register: run_pods_log
until: [ '(run_pods_log.stdout | from_json)["items"] | map(attribute = "status.phase") | join(",") == "Running,Running"' ]
retries: 18
delay: 10

View File

@@ -1,8 +1,10 @@
---
- hosts: kube-master[0]
vars:
test_image_repo: busybox
test_image_tag: latest
tasks:
- name: Force binaries directory for Container Linux by CoreOS
set_fact:
bin_dir: "/opt/bin"
@@ -12,6 +14,12 @@
bin_dir: "/usr/local/bin"
when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
- name: Create test namespace
shell: "{{bin_dir}}/kubectl create namespace test"
- name: Run a replica controller composed of 2 pods in test ns
shell: "{{bin_dir}}/kubectl run test --image={{test_image_repo}}:{{test_image_tag}} --namespace test --replicas=2 --command -- tail -f /dev/null"
- name: Check that all pods are running and ready
shell: "{{bin_dir}}/kubectl get pods --namespace test --no-headers -o yaml"
register: run_pods_log
@@ -30,6 +38,9 @@
register: pods
no_log: true
- debug: msg="{{pods.stdout.split('\n')}}"
failed_when: not run_pods_log is success
- name: Get hostnet pods
command: "{{bin_dir}}/kubectl get pods -n test -o
jsonpath='{range .items[?(.spec.hostNetwork)]}{.metadata.name} {.status.podIP} {.status.containerStatuses} {end}'"
@@ -79,3 +90,6 @@
with_nested:
- "{{pod_names}}"
- "{{pod_ips}}"
- name: Delete test namespace
shell: "{{bin_dir}}/kubectl delete namespace test"