Repository navigation
Migrate kind e2e tests from bash_unit to Ginkgo - #2513
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the kind-based end-to-end test suite from a bash_unit + kubectl/kind CLI flow to a native Go test suite using Ginkgo v2 + Gomega, client-go, and the sigs.k8s.io/kind library. This modernizes the kind e2e infrastructure while keeping the etcd/docker bash_unit suites unchanged.
Changes:
- Replaces
e2e/run-e2e-tests.shand helper scripts with a Goe2e/package gated behind thee2ebuild tag. - Updates
make kind-e2e-testto rungo test -tags e2e ./...and adjusts CI workflow setup accordingly. - Adds Go module dependencies for Ginkgo/Gomega and kind.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| Makefile | Runs kind e2e via go test -tags e2e instead of bash_unit scripts |
| go.mod | Adds Ginkgo/Gomega and kind (plus new indirect deps) |
| go.sum | Updates checksums for newly added dependencies |
| e2e/version.sh | Removes legacy bash tag/arch env setup |
| e2e/run-e2e-tests.sh | Removes legacy bash-driven kind e2e runner |
| e2e/get-kubeconfig.sh | Removes kubeconfig export helper (kind library now used) |
| e2e/e2e-functions.sh | Removes bash polling/helpers (replaced by Go waits) |
| e2e/download-kubectl.sh | Removes kubectl installer (no longer needed for suite) |
| e2e/e2e_suite_test.go | Adds Ginkgo suite bootstrap + env configuration + CNI plugin install |
| e2e/connectivity_test.go | Adds backend connectivity + perf specs in Ginkgo |
| e2e/cluster.go | Adds kind cluster lifecycle, image loading, node exec, CNI plugin install |
| e2e/kube.go | Adds client-go helpers (pods, exec, readiness waits, subnet.env check) |
| e2e/flannel.go | Adds manifest rendering/apply/delete via dynamic client |
| e2e/rules.go | Adds iptables/nftables golden-rule assertions + debug dump |
| CLAUDE.md | Updates repo docs describing the new kind e2e approach |
| .github/workflows/kind-e2eTests.yml | Removes kind CLI install step; relies on Go-based suite |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Could we do a follow-up to separate framework/helpers from specs for maintainability? Or maybe in this PR itself? The same directory includes helper-functions (e.g. in cluster.go) and the tests themselves. I would prefer having two different subdirectories: one for infrahelpers and one for tests |
|
I agree the separation can help once the suite grows, but in Go the current boundary is already the idiomatic one: helpers live in non-_test.go files and specs in _test.go files within the same package. Moving them into subdirectories here would mean a separate package and a fairly noisy export/refactor of the helper surface, so I would prefer to keep this PR as-is and revisit that as a follow-up if the e2e suite grows enough to justify it. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 16 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (5)
e2e/kube.go:189
- waitForNodesReady ignores List errors and keeps polling, which can turn real API failures into opaque timeouts. Propagate the error so the spec fails with the underlying cause.
nodeList, err := kc.client.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
if err != nil {
return false, nil
}
e2e/kube.go:210
- waitForCoreDNS collapses list errors into "not ready" and keeps polling, which can mask API failures behind a timeout. Return the error when the List call fails (still treat an empty list as "not ready").
pods, err := kc.client.CoreV1().Pods("kube-system").List(ctx, metav1.ListOptions{
LabelSelector: "k8s-app=kube-dns",
})
if err != nil || len(pods.Items) == 0 {
return false, nil
}
e2e/connectivity_test.go:91
- Flannel is only deleted at the end of each spec. If any Expect fails before that (e.g., ping/iperf), the suite can proceed with flannel still installed, and later backends may run against the previous net-conf.json because updating the ConfigMap alone doesn’t force a DaemonSet restart. Add a DeferCleanup right after a successful install so flannel is always removed, even on failure.
By("installing flannel with backend " + backend)
Expect(kc.installFlannel(ctx, backend, enableNFT)).To(Succeed())
By("waiting for the flannel DaemonSet to roll out")
Expect(kc.waitForFlannelRollout(ctx, 5*time.Minute)).To(Succeed())
e2e/kube.go:170
- waitForPodReady currently swallows all GET errors and keeps polling. If the error is persistent (e.g., auth/connection), the test will just time out with no root cause. Only ignore NotFound; return other errors so failures are actionable.
This issue also appears in the following locations of the same file:
- line 186
- line 205
pod, err := kc.client.CoreV1().Pods(namespace).Get(ctx, name, metav1.GetOptions{})
if err != nil {
return false, nil
}
e2e/cluster.go:175
- loadImage writes potentially very large image tarballs into the current working directory (".") during tests. Using the system temp directory avoids filling the repo workspace and is more robust in environments where the checkout may be on a small/slow filesystem.
tmp, err := os.CreateTemp(".", "kind-image-*.tar")
f50d73a to
8e52808
Compare
Replace the bash_unit-driven kind e2e suite (e2e/run-e2e-tests.sh) with a native Ginkgo v2 + Gomega suite under e2e/ (build tag `e2e`). The suite drives cluster lifecycle through the sigs.k8s.io/kind library and Kubernetes through client-go, exec-ing into kind node containers for iptables/nftables assertions. - Per-backend kind cluster (Ordered containers) for vxlan, vxlan-nftables, wireguard, host-gw, ipip and udp (udp/perf gated to amd64). - Flannel manifest rendered from Documentation/kube-flannel.yml as a template (image, net-conf.json, udp privileged) and applied via the dynamic client. - Ports connectivity ping tests, iperf3 perf tests, iptables/nftables golden rule checks and the failure debug dump. - Rewrites `make kind-e2e-test` to `go test -tags e2e ./e2e/...` and updates the kind-e2eTests workflow (kind is now a library, not a CLI dependency). - Removes the obsolete bash scripts and updates CLAUDE.md. The dist/functional-test*.sh (etcd/docker) suites remain on bash_unit. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add required license headers to the new e2e Go files and wait for flannel resources to be fully deleted before reinstalling them between ordered specs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reduce duplication in the Ginkgo e2e suite while keeping the same 11 specs: - Derive the iptables/nftables rule check from the backend's EnableNFTables flag instead of carrying a per-backend closure, removing the checkRules struct field and six near-identical closures. - Extract a dynamicResource helper for namespaced vs cluster-scoped resource clients, replacing three copies of the same if/else in install, delete and the deletion wait. - Extract nodeCIDRs so checkIptables and checkNftables share the pod-CIDR lookup loop. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…dumpDebugInfo) - downloadFile: use http.Client with 5-minute timeout instead of http.Get - loadImage: write docker save output to a temp file instead of buffering the entire archive in memory; avoids OOM for large images - dumpDebugInfo: expand to include all pod status, flannel pod describe, previous container logs, crictl images on nodes, and cluster events Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The bash suite created a single cluster (setup/teardown) and ran all backends sequentially within it. The Ginkgo migration accidentally created one cluster per backend (6 total), multiplying cluster create and delete time by 6x. Restore parity: create the cluster once in BeforeSuite, delete it in AfterSuite, and share it across all backend Contexts. Add deleteTestPods called at the start of each prepareTest to clean up pods left over from the previous backend so the shared cluster starts clean for each spec. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reduce duplication in the Ginkgo e2e suite while keeping the same 11 specs: - Derive the iptables/nftables rule check from the backend's EnableNFTables flag instead of carrying a per-backend closure, removing the checkRules struct field and six near-identical closures. - Extract a dynamicResource helper for namespaced vs cluster-scoped resource clients, replacing three copies of the same if/else in install, delete and the deletion wait. - Extract nodeCIDRs so checkIptables and checkNftables share the pod-CIDR lookup loop. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The bash suite created a single cluster (setup/teardown) and ran all backends sequentially within it. The Ginkgo migration accidentally created one cluster per backend (6 total), multiplying cluster create and delete time by 6x. Restore parity: create the cluster once in BeforeSuite, delete it in AfterSuite, and share it across all backend Contexts. Add deleteTestPods called at the start of each prepareTest to clean up pods left over from the previous backend so the shared cluster starts clean for each spec. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2f92347 to
a6bec47
Compare
Description
This is a test-infrastructure change (no product code). It replaces the bash_unit-driven kind e2e suite (
e2e/run-e2e-tests.shand its helpers) with a native Ginkgo v2 + Gomega suite written in Go.Why: the previous suite was a large, hard-to-maintain bash script that shelled out to
kubectl,kind,yqandjq, with ad hoc polling and string assertions. Moving it to Go lets us drive the cluster and Kubernetes through first-class libraries, reuse the module toolchain, and get structured, readable specs and failure output.Approach:
e2e/Go package gated behind thee2ebuild tag, so it never runs duringmake unit-test.sigs.k8s.io/kindlibrary (create, load images viadocker save-> node import, delete, and node exec for rule inspection).kindis now a library dependency rather than a CLI tool.client-go(pod create, IPs, podCIDR,remotecommandexec, logs) and all readiness waits (DaemonSet rollout, nodes, coredns, pods, ping reachability, and/run/flannel/subnet.envon each node).Documentation/kube-flannel.ymlas a template (image,net-conf.json, udp privileged flag) and applied/deleted via the dynamic client, replacing the yq + kubectl flow.Scope note: only the kind suite is migrated. The etcd/docker
dist/functional-test*.shsuites intentionally stay on bash_unit.Components affected: e2e test suite,
make kind-e2e-test, and thekind-e2eTestsGitHub Actions workflow (drops the kind CLI install since the library handles clusters now). Removes 5 obsolete bash scripts and keepse2e/kind-config.yaml.Testing:
go vet -tags e2e ./e2e/is clean, the test binary compiles,gofmtis clean, andgo mod tidyis stable. A--ginkgo.dry-runenumerates 11 specs (6 connectivity + 5 perf), matching the original coverage (udp and its perf variant remain amd64-only). The full run exercises real kind clusters and is covered by thekind-e2eTestsworkflow on CI.Todos
Release Note