From 50598d9d47ba9cdc81d91351fbd714fade221c13 Mon Sep 17 00:00:00 2001 From: Maxime Guyot Date: Wed, 5 Aug 2020 22:22:55 +0200 Subject: [PATCH] Fix E306 in tests/ (#6495) --- .../roles/packet-ci/tasks/create-vms.yml | 6 ++++-- tests/testcases/040_check-network-adv.yml | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml b/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml index a39329573..bbbce6e01 100644 --- a/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml +++ b/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml @@ -29,8 +29,10 @@ loop_control: index_var: vm_id -- name: Wait for vms to have ipaddress assigned # noqa 306 - shell: "kubectl get vmis -n {{ test_name }} instance-{{ vm_id }} -o json | jq '.status.interfaces[].ipAddress' | tr -d '\"'" +- name: Wait for vms to have ipaddress assigned + shell: "set -o pipefail && kubectl get vmis -n {{ test_name }} instance-{{ vm_id }} -o json | jq '.status.interfaces[].ipAddress' | tr -d '\"'" + args: + executable: /bin/bash changed_when: false register: vm_ips loop: "{{ range(1, vm_count|int + 1, 1) | list }}" diff --git a/tests/testcases/040_check-network-adv.yml b/tests/testcases/040_check-network-adv.yml index 9cc38cfdb..dacc8d76b 100644 --- a/tests/testcases/040_check-network-adv.yml +++ b/tests/testcases/040_check-network-adv.yml @@ -1,8 +1,10 @@ --- - hosts: kube-node tasks: - - name: Test tunl0 routes # noqa 306 - shell: "! /sbin/ip ro | grep '/26 via' | grep -v tunl0" + - name: Test tunl0 routes + shell: "set -o pipefail && ! /sbin/ip ro | grep '/26 via' | grep -v tunl0" + args: + executable: /bin/bash when: - (ipip|default(true) or cloud_provider is defined) - kube_network_plugin|default('calico') == 'calico' @@ -33,16 +35,20 @@ - import_role: name: cluster-dump - - name: Wait for netchecker server # noqa 306 - shell: "{{ bin_dir }}/kubectl get pods -o wide --namespace {{ netcheck_namespace }} | grep ^netchecker-server" + - name: Wait for netchecker server + shell: "set -o pipefail && {{ bin_dir }}/kubectl get pods -o wide --namespace {{ netcheck_namespace }} | grep ^netchecker-server" + args: + executable: /bin/bash register: ncs_pod until: ncs_pod.stdout.find('Running') != -1 retries: 3 delay: 10 when: inventory_hostname == groups['kube-master'][0] - - name: Wait for netchecker agents # noqa 306 - shell: "{{ bin_dir }}/kubectl get pods -o wide --namespace {{ netcheck_namespace }} | grep '^netchecker-agent-.*Running'" + - name: Wait for netchecker agents + shell: "set -o pipefail && {{ bin_dir }}/kubectl get pods -o wide --namespace {{ netcheck_namespace }} | grep '^netchecker-agent-.*Running'" + args: + executable: /bin/bash register: nca_pod until: nca_pod.stdout_lines|length >= groups['k8s-cluster']|intersect(ansible_play_hosts)|length * 2 retries: 3