From 34e51ac1cb1f6e946057598da1cc30b28ec35f24 Mon Sep 17 00:00:00 2001 From: Maxime Guyot Date: Thu, 19 Mar 2020 12:09:14 +0100 Subject: [PATCH] Add a test to check that nodes are Ready (#5793) --- tests/scripts/testcases_run.sh | 3 +++ tests/testcases/020_check-nodes-ready.yml | 30 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/testcases/020_check-nodes-ready.yml diff --git a/tests/scripts/testcases_run.sh b/tests/scripts/testcases_run.sh index 81df1a129..0a0eb9015 100755 --- a/tests/scripts/testcases_run.sh +++ b/tests/scripts/testcases_run.sh @@ -60,6 +60,9 @@ ansible-playbook -e ansible_python_interpreter=${PYPATH} --limit "all:!fake_host ## Test that all pods are Running ansible-playbook -e ansible_python_interpreter=${PYPATH} --limit "all:!fake_hosts" tests/testcases/015_check-pods-running.yml $LOG_LEVEL +## Test that all nodes are Ready +ansible-playbook -e ansible_python_interpreter=${PYPATH} --limit "all:!fake_hosts" tests/testcases/020_check-nodes-ready.yml $LOG_LEVEL + ## Test pod creation and ping between them ansible-playbook -e ansible_python_interpreter=${PYPATH} --limit "all:!fake_hosts" tests/testcases/030_check-network.yml $LOG_LEVEL diff --git a/tests/testcases/020_check-nodes-ready.yml b/tests/testcases/020_check-nodes-ready.yml new file mode 100644 index 000000000..d78a5673b --- /dev/null +++ b/tests/testcases/020_check-nodes-ready.yml @@ -0,0 +1,30 @@ +--- +- hosts: kube-master[0] + tasks: + + - name: Force binaries directory for Container Linux by CoreOS and Flatcar + set_fact: + bin_dir: "/opt/bin" + when: ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"] + + - name: Force binaries directory for other hosts + set_fact: + bin_dir: "/usr/local/bin" + when: not ansible_os_family in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"] + + - name: Check kubectl output + shell: "{{ bin_dir }}/kubectl get nodes" + register: get_nodes + no_log: true + + - debug: + msg: "{{ get_nodes.stdout.split('\n') }}" + + - name: Check that all nodes are running and ready + shell: "{{ bin_dir }}/kubectl get nodes --no-headers -o yaml" + register: get_nodes_yaml + until: + # Check that all nodes are Status=Ready + - '(get_nodes_yaml.stdout | from_yaml)["items"] | map(attribute = "status.conditions") | map("items2dict", key_name="type", value_name="status") | map(attribute="Ready") | list | min' + retries: 30 + delay: 10 \ No newline at end of file