Skip to content

Commit a160a7f

Browse files
Merge pull request #2240 from thomasferrandiz/fix-test-workflows
test: fix e2e tests in CI workflows and don't run the workflows on "push" events
2 parents 63ec92d + bb1de23 commit a160a7f

File tree

8 files changed

+36
-10
lines changed

8 files changed

+36
-10
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: build flannel
22

3-
on: [push, pull_request]
3+
on: pull_request
44

55
env:
66
GO_VERSION: "1.23"

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
name: "CodeQL"
1313

1414
on:
15-
push:
16-
branches: [ "master" ]
1715
pull_request:
1816
# The branches below must be a subset of the branches above
1917
branches: [ "master" ]

.github/workflows/e2eTests.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: e2e tests for flannel
22

3-
on: [push, pull_request]
3+
on: pull_request
44

55
jobs:
66
e2e-test:
@@ -16,6 +16,9 @@ jobs:
1616
- name: Check out code into the Go module directory
1717
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
1818

19+
- name: set up modules
20+
run: sudo modprobe br_netfilter overlay
21+
1922
- name: Run tests
2023
id: testing
2124
continue-on-error: true

.github/workflows/golangci-lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: run golangci-lint
22

3-
on: [push, pull_request]
3+
on: pull_request
44

55
jobs:
66
golangci:

.github/workflows/k3s-e2eTests.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
name: e2e tests for flannel
1+
name: k3s e2e tests for flannel
22

3-
on: [push, pull_request]
3+
on: pull_request
44

55
env:
66
ARCH: amd64
@@ -20,6 +20,9 @@ jobs:
2020
with:
2121
go-version: ${{ env.GO_VERSION }}
2222

23+
- name: set up modules
24+
run: sudo modprobe br_netfilter overlay
25+
2326
- name: build flannel image
2427
run: make image
2528

.github/workflows/trivy.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
name: Vulnerability scan
77

88
on:
9-
push:
10-
branches: [ "master" ]
119
pull_request:
1210
# The branches below must be a subset of the branches above
1311
branches: [ "master" ]

e2e/e2e-functions.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ e2e-wait-for-services() {
5252
}
5353
export -f e2e-wait-for-services
5454

55+
e2e-get-flannel-pod() {
56+
local node_name=$1
57+
kubectl --kubeconfig="${HOME}/.kube/config" get pods --field-selector "spec.nodeName=${node_name}" -n kube-flannel --no-headers
58+
}
59+
export -f e2e-get-flannel-pod
60+
5561
e2e-wait-for-test-pods() {
5662
for pod in ${WAIT_FOR_PODS:="multitool1 multitool2"}; do
5763
while [[ "$(e2e-pod-ready $pod)" != 'true' ]]; do

e2e/run-e2e-tests.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ get_pod_cidr() {
8383
kubectl --kubeconfig="${HOME}/.kube/config" get node ${node_name} --template '{{.spec.podCIDR}}'
8484
}
8585

86-
# get_flannel_logs()
86+
get_pod_logs() {
87+
local pod_name=$1
88+
kubectl --kubeconfig="${HOME}/.kube/config" logs $pod_name -n kube-flannel
89+
}
8790

8891
pings() {
8992
create_test_pod multitool1 local-worker
@@ -96,6 +99,10 @@ pings() {
9699
if [ $retVal -ne 0 ]; then
97100
echo "test pods not ready in time. Checking their status..."
98101
kubectl --kubeconfig="${HOME}/.kube/config" get events --sort-by='.lastTimestamp' -A
102+
echo "*****************************"
103+
echo "flannel pod log:"
104+
flannel_pod=$(e2e-get-flannel-pod local-worker)
105+
echo "$(get_pod_logs $flannel_pod)"
99106
exit $retVal
100107
fi
101108

@@ -136,8 +143,19 @@ prepare_test() {
136143
write-flannel-conf ${backend} ${enable_nftables}
137144

138145
install-flannel
146+
139147
# wait for nodes to be ready
140148
timeout --foreground 5m bash -c "e2e-wait-for-nodes"
149+
retVal=$?
150+
if [ $retVal -ne 0 ]; then
151+
echo "test nodes not ready in time. Checking their status..."
152+
kubectl --kubeconfig="${HOME}/.kube/config" get events --sort-by='.lastTimestamp' -A
153+
echo "*****************************"
154+
echo "flannel pod log:"
155+
flannel_pod=$(e2e-get-flannel-pod local-worker)
156+
echo "$(get_pod_logs $flannel_pod)"
157+
exit $retVal
158+
fi
141159
# wait for services to be ready
142160
echo "wait for services to be ready..."
143161
timeout --foreground 5m bash -c "e2e-wait-for-services"

0 commit comments

Comments
 (0)