Skip to content

Commit 2daf277

Browse files
committed
Test: refactor check-network to hydrophone
Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
1 parent 0c4f6bf commit 2daf277

2 files changed

Lines changed: 4 additions & 63 deletions

File tree

tests/testcases/030_check-network.yml

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,10 @@
11
---
2-
- name: Create test namespace
3-
command: "{{ bin_dir }}/kubectl create namespace test"
4-
changed_when: false
5-
6-
- name: Run 2 agnhost pods in test ns
7-
command:
8-
cmd: "{{ bin_dir }}/kubectl apply --namespace test -f -"
9-
stdin: |
10-
apiVersion: apps/v1
11-
kind: Deployment
12-
metadata:
13-
name: agnhost
14-
spec:
15-
replicas: 2
16-
selector:
17-
matchLabels:
18-
app: agnhost
19-
template:
20-
metadata:
21-
labels:
22-
app: agnhost
23-
spec:
24-
containers:
25-
- name: agnhost
26-
image: {{ test_image_repo }}:{{ test_image_tag }}
27-
command: ['/agnhost', 'netexec', '--http-port=8080']
28-
securityContext:
29-
allowPrivilegeEscalation: false
30-
capabilities:
31-
drop: ['ALL']
32-
runAsUser: 1000
33-
runAsNonRoot: true
34-
seccompProfile:
35-
type: RuntimeDefault
36-
changed_when: false
37-
38-
- name: Check that all pods are running and ready
2+
- name: Run the hydrophone checks
393
vars:
40-
pods: "{{ (pods_json.stdout | from_json)['items'] }}"
4+
networking_check: "\\[sig-network\\] Networking Granular Checks.+\\[Conformance\\]"
415
block:
42-
- name: Check Deployment is ready
43-
command: "{{ bin_dir }}/kubectl rollout status deploy --namespace test agnhost --timeout=180s"
44-
changed_when: false
45-
- name: Get pod names
46-
command: "{{ bin_dir }}/kubectl get pods -n test -o json"
47-
changed_when: false
48-
register: pods_json
49-
50-
- name: Check pods IP are in correct network
51-
assert:
52-
that: pods
53-
| selectattr('status.phase', '==', 'Running')
54-
| selectattr('status.podIP', 'ansible.utils.in_network', kube_pods_subnet)
55-
| length == 2
56-
57-
- name: Curl between pods is working
58-
command: "{{ bin_dir }}/kubectl -n test exec {{ item[0].metadata.name }} -- curl {{ item[1].status.podIP | ansible.utils.ipwrap}}:8080"
59-
with_nested:
60-
- "{{ pods }}"
61-
- "{{ pods }}"
62-
loop_control:
63-
label: "{{ item[0].metadata.name + ' --> ' + item[1].metadata.name }}"
6+
- name: Run the networking granular checks
7+
command: "{{ hydrophone_path }} --focus=\"{{ networking_check }}\" --parallel {{ hydrophone_parallel }}"
648
rescue:
659
- name: List pods cluster-wide
6610
command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"

tests/testcases/tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
- name: Testcases for network
3030
import_tasks: 030_check-network.yml
3131
when: ('macvlan' not in testcase)
32-
vars:
33-
test_image_repo: registry.k8s.io/e2e-test-images/agnhost
34-
test_image_tag: "2.40"
3532
- name: Testcases for calico / advanced network
3633
import_tasks: 040_check-network-adv.yml
3734
when:

0 commit comments

Comments
 (0)