Skip to content

Commit 57490d5

Browse files
authored
Merge pull request #11793 from VannTen/cleanup/ci_testcases_better_callback
Use debug stdout callback in ci rather than manual debug
2 parents 5af3a34 + 86a949d commit 57490d5

File tree

6 files changed

+82
-192
lines changed

6 files changed

+82
-192
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ variables:
1010
FAILFASTCI_NAMESPACE: 'kargo-ci'
1111
GITLAB_REPOSITORY: 'kargo-ci/kubernetes-sigs-kubespray'
1212
ANSIBLE_FORCE_COLOR: "true"
13+
ANSIBLE_STDOUT_CALLBACK: "debug"
1314
MAGIC: "ci check this"
1415
GS_ACCESS_KEY_ID: $GS_KEY
1516
GS_SECRET_ACCESS_KEY: $GS_SECRET

tests/testcases/010_check-apiserver.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
delay: 5
1414
until: apiserver_response is success
1515

16-
- debug: # noqa name[missing]
17-
msg: "{{ apiserver_response.json }}"
18-
1916
- name: Check API servers version
2017
assert:
2118
that:

tests/testcases/015_check-nodes-ready.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
---
22
- name: Testcases checking nodes
33
hosts: kube_control_plane[0]
4+
vars:
5+
bin_dir: /usr/local/bin
46
tasks:
57

6-
- name: Force binaries directory for Flatcar Container Linux by Kinvolk
7-
set_fact:
8-
bin_dir: "/opt/bin"
9-
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
10-
11-
- name: Force binaries directory for other hosts
12-
set_fact:
13-
bin_dir: "/usr/local/bin"
14-
when: not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
15-
168
- import_role: # noqa name[missing]
179
name: cluster-dump
1810

@@ -21,9 +13,6 @@
2113
changed_when: false
2214
register: get_nodes
2315

24-
- debug: # noqa name[missing]
25-
msg: "{{ get_nodes.stdout.split('\n') }}"
26-
2716
- name: Check that all nodes are running and ready
2817
command: "{{ bin_dir }}/kubectl get nodes --no-headers -o yaml"
2918
changed_when: false
Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
---
22
- name: Testcases checking pods
33
hosts: kube_control_plane[0]
4+
vars:
5+
bin_dir: /usr/local/bin
46
tasks:
57

6-
- name: Force binaries directory for Flatcar Container Linux by Kinvolk
7-
set_fact:
8-
bin_dir: "/opt/bin"
9-
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
10-
11-
- name: Force binaries directory for other hosts
12-
set_fact:
13-
bin_dir: "/usr/local/bin"
14-
when: not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
15-
168
- import_role: # noqa name[missing]
179
name: cluster-dump
1810

1911
- name: Check kubectl output
2012
command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
2113
changed_when: false
22-
register: get_pods
23-
24-
- debug: # noqa name[missing]
25-
msg: "{{ get_pods.stdout.split('\n') }}"
2614

2715
- name: Check that all pods are running and ready
2816
command: "{{ bin_dir }}/kubectl get pods --all-namespaces --no-headers -o yaml"
@@ -35,13 +23,7 @@
3523
- '(run_pods_log.stdout | from_yaml)["items"] | map(attribute = "status.containerStatuses") | map("map", attribute = "ready") | map("min") | min'
3624
retries: 30
3725
delay: 10
38-
failed_when: false
3926

4027
- name: Check kubectl output
4128
command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
4229
changed_when: false
43-
register: get_pods
44-
45-
- debug: # noqa name[missing]
46-
msg: "{{ get_pods.stdout.split('\n') }}"
47-
failed_when: not run_pods_log is success

tests/testcases/030_check-network.yml

Lines changed: 25 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@
44
vars:
55
test_image_repo: registry.k8s.io/e2e-test-images/agnhost
66
test_image_tag: "2.40"
7+
bin_dir: "/usr/local/bin"
78

89
tasks:
9-
- name: Force binaries directory for Flatcar Container Linux by Kinvolk
10-
set_fact:
11-
bin_dir: "/opt/bin"
12-
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
13-
14-
- name: Force binaries directory for other hosts
15-
set_fact:
16-
bin_dir: "/usr/local/bin"
17-
when: not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
1810

1911
- name: Check kubelet serving certificates approved with kubelet_csr_approver
2012
when:
@@ -29,9 +21,6 @@
2921
register: csr_json
3022
changed_when: false
3123

32-
- debug: # noqa name[missing]
33-
var: csrs
34-
3524
- name: Check there are csrs
3625
assert:
3726
that: csrs | length > 0
@@ -67,17 +56,13 @@
6756
when: get_csr.stdout_lines | length > 0
6857
changed_when: certificate_approve.stdout
6958

70-
- debug: # noqa name[missing]
71-
msg: "{{ certificate_approve.stdout.split('\n') }}"
72-
73-
7459
- name: Create test namespace
7560
command: "{{ bin_dir }}/kubectl create namespace test"
7661
changed_when: false
7762

7863
- name: Run 2 agnhost pods in test ns
7964
command:
80-
cmd: "{{ bin_dir }}/kubectl apply -f -"
65+
cmd: "{{ bin_dir }}/kubectl apply --namespace test -f -"
8166
stdin: |
8267
apiVersion: apps/v1
8368
kind: Deployment
@@ -107,52 +92,35 @@
10792
type: RuntimeDefault
10893
changed_when: false
10994

110-
- import_role: # noqa name[missing]
111-
name: cluster-dump
112-
11395
- name: Check that all pods are running and ready
96+
vars:
97+
pods: "{{ (pods_json.stdout | from_json)['items'] }}"
11498
block:
11599
- name: Check Deployment is ready
116-
command: "{{ bin_dir }}/kubectl rollout status deploy --namespace test agnhost --timeout=180"
100+
command: "{{ bin_dir }}/kubectl rollout status deploy --namespace test agnhost --timeout=180s"
117101
changed_when: false
118-
rescue:
119102
- name: Get pod names
120103
command: "{{ bin_dir }}/kubectl get pods -n test -o json"
121104
changed_when: false
122-
register: pods
105+
register: pods_json
123106

124-
- name: Get running pods
125-
command: "{{ bin_dir }}/kubectl get pods -n test -o
126-
jsonpath='{range .items[?(.status.phase==\"Running\")]}{.metadata.name} {.status.podIP} {.status.containerStatuses} {end}'"
127-
changed_when: false
128-
register: running_pods
107+
- name: Check pods IP are in correct network
108+
assert:
109+
that: pods
110+
| selectattr('status.phase', '==', 'Running')
111+
| selectattr('status.podIP', 'ansible.utils.in_network', kube_pods_subnet)
112+
| length == 2
113+
114+
- name: Curl between pods is working
115+
command: "{{ bin_dir }}/kubectl -n test exec {{ item[0].metadata.name }} -- curl {{ item[1].status.podIP }}:8080"
116+
with_nested:
117+
- "{{ pods }}"
118+
- "{{ pods }}"
119+
rescue:
120+
- name: List pods cluster-wide
121+
command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
122+
changed_when: false
129123

130-
- name: Check kubectl output
131-
command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
132-
changed_when: false
133-
register: get_pods
134-
135-
- debug: # noqa name[missing]
136-
msg: "{{ get_pods.stdout.split('\n') }}"
137-
138-
- name: Set networking facts
139-
set_fact:
140-
kube_pods_subnet: 10.233.64.0/18
141-
pod_names: "{{ (pods.stdout | from_json)['items'] | map(attribute='metadata.name') | list }}"
142-
pod_ips: "{{ (pods.stdout | from_json)['items'] | selectattr('status.podIP', 'defined') | map(attribute='status.podIP') | list }}"
143-
pods_running: |
144-
{% set list = running_pods.stdout.split(" ") %}
145-
{{ list }}
146-
147-
- name: Check pods IP are in correct network
148-
assert:
149-
that: item | ansible.utils.ipaddr(kube_pods_subnet)
150-
when:
151-
- item in pods_running
152-
with_items: "{{ pod_ips }}"
153-
154-
- name: Curl between pods is working
155-
command: "{{ bin_dir }}/kubectl -n test exec {{ item[0] }} -- curl {{ item[1] }}:8080"
156-
with_nested:
157-
- "{{ pod_names }}"
158-
- "{{ pod_ips }}"
124+
- import_role: # noqa name[missing]
125+
name: cluster-dump
126+
- fail: # noqa name[missing]

0 commit comments

Comments
 (0)