Skip to content

test: add unit, e2e, manifest, and performance test infrastructure#165

Open
stevensbkang wants to merge 4 commits into
developfrom
feat/ci-test-gate
Open

test: add unit, e2e, manifest, and performance test infrastructure#165
stevensbkang wants to merge 4 commits into
developfrom
feat/ci-test-gate

Conversation

@stevensbkang

Copy link
Copy Markdown
Member

Introduce a layered testing setup and wire it into CI, moving from ~8% ad-hoc coverage with no test gate to enforced unit tests plus containerized end-to-end, manifest, and performance suites.

CI / build:

  • ci.yaml: add test (go test + coverage report) and lint (golangci-lint) jobs on every push/PR to develop; add e2e smoke jobs on native amd64 (ubuntu-24.04) and arm64 (ubuntu-24.04-arm), gated on the built image — no QEMU.
  • nightly.yaml: scheduled perf, soak, and conformance-lite suites.
  • Makefile: add test, test-race, lint-ci, test-e2e, bench, soak targets; .golangci.yml with a lenient high-signal linter set.
  • testify added as the only new (test-scope) dependency.

Unit tests:

  • types CIDR/IP invariants, runtime/network IP+resolv.conf logic, core/pki cert validation, cli semver/runmode, kubelet config (container/edge/full modes), and component manifest builders.
  • pkg/components builders now take kubernetes.Interface instead of *kubernetes.Clientset so they can be tested with a fake clientset. Exported Deploy() entrypoints are unchanged — fully backward compatible (callers still pass a *Clientset).

E2E (test/e2e): kubesoloctl-driven harness that boots KubeSolo as a container, gates on readiness, runs smoke checks and five manifest deployment tiers (workload, storage, config/identity, controllers, DNS/LoadBalancer), and always tears down.

Performance (test/perf): boot-time / idle-RSS / image-size / pod- density baseline with relative regression gating (report-only until a baseline is committed); soak loop (leak/restart detector); and a single-node-safe focused upstream conformance subset via Sonobuoy.

Introduce a layered testing setup and wire it into CI, moving from
~8% ad-hoc coverage with no test gate to enforced unit tests plus
containerized end-to-end, manifest, and performance suites.

CI / build:
- ci.yaml: add `test` (go test + coverage report) and `lint`
  (golangci-lint) jobs on every push/PR to develop; add e2e smoke
  jobs on native amd64 (ubuntu-24.04) and arm64 (ubuntu-24.04-arm),
  gated on the built image — no QEMU.
- nightly.yaml: scheduled perf, soak, and conformance-lite suites.
- Makefile: add test, test-race, lint-ci, test-e2e, bench, soak
  targets; .golangci.yml with a lenient high-signal linter set.
- testify added as the only new (test-scope) dependency.

Unit tests:
- types CIDR/IP invariants, runtime/network IP+resolv.conf logic,
  core/pki cert validation, cli semver/runmode, kubelet config
  (container/edge/full modes), and component manifest builders.
- pkg/components builders now take kubernetes.Interface instead of
  *kubernetes.Clientset so they can be tested with a fake clientset.
  Exported Deploy() entrypoints are unchanged — fully backward
  compatible (callers still pass a *Clientset).

E2E (test/e2e): kubesoloctl-driven harness that boots KubeSolo as a
container, gates on readiness, runs smoke checks and five manifest
deployment tiers (workload, storage, config/identity, controllers,
DNS/LoadBalancer), and always tears down.

Performance (test/perf): boot-time / idle-RSS / image-size / pod-
density baseline with relative regression gating (report-only until
a baseline is committed); soak loop (leak/restart detector); and a
single-node-safe focused upstream conformance subset via Sonobuoy.

.gitignore: exclude generated test artifacts (coverage.out,
result.*.json, sonobuoy tarballs); test sources and perf baselines
stay tracked.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a layered automated testing stack (unit + containerized e2e + manifest-tier suites + nightly performance/soak/conformance-lite) and wires it into GitHub Actions CI to enforce a test gate and improve confidence in KubeSolo changes.

Changes:

  • Adds unit-test coverage across core areas (types/network/PKI/CLI/kubelet config and component manifest builders) and introduces testify.
  • Adds a Bash-driven e2e harness that boots KubeSolo as a container, runs smoke checks plus tiered manifest deployments, and ensures teardown.
  • Adds nightly performance/soak/conformance-lite workflows plus Makefile targets and golangci-lint CI plumbing.

Reviewed changes

Copilot reviewed 52 out of 53 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
types/const_test.go Adds invariants-based tests for default CIDR/IP relationships.
test/perf/README.md Documents perf baseline goals, metrics, and baselining workflow.
test/perf/bench.sh Adds container boot/footprint/density measurement with optional regression gating.
test/e2e/teardown.sh Adds best-effort, idempotent teardown for container-mode e2e runs.
test/e2e/soak.sh Adds nightly soak loop to detect restarts/crashloops/RSS growth.
test/e2e/smoke.sh Adds core smoke checks: scheduling, DNS, and pod egress.
test/e2e/run.sh Adds per-PR e2e entrypoint (boot → smoke → manifests → teardown).
test/e2e/README.md Documents the e2e harness, scripts, tiers, and tunables.
test/e2e/manifests/05-dns-lb/dns-lb.yaml Adds Tier 5 manifests (cross-namespace DNS + LoadBalancer webhook).
test/e2e/manifests/04-controllers/controllers.yaml Adds Tier 4 manifests (Job/CronJob/DaemonSet/StatefulSet).
test/e2e/manifests/03-config/config.yaml Adds Tier 3 manifests (ConfigMap/Secret/projected SA token).
test/e2e/manifests/02-storage/pvc.yaml Adds Tier 2 namespace + PVC manifest for storage persistence checks.
test/e2e/manifests/02-storage/writer.yaml Adds Tier 2 writer Job to persist data into the PVC.
test/e2e/manifests/02-storage/reader.yaml Adds Tier 2 reader Pod to validate persistence across pods.
test/e2e/manifests/01-workload/workload.yaml Adds Tier 1 manifests (Deployment + ClusterIP + NodePort).
test/e2e/manifests.sh Adds tier runner with readiness gates and namespace cleanup/wait.
test/e2e/lib.sh Adds shared harness helpers (kubectl context resolution, polling, diagnostics, RSS sampling).
test/e2e/conformance.sh Adds nightly Sonobuoy-based conformance-lite runner with focus/skip filters.
test/e2e/boot.sh Adds container-mode boot + readiness gating for node/CoreDNS/local-path.
pkg/kubernetes/kubelet/config_test.go Adds unit tests for kubelet config generation across run modes.
pkg/components/portainer/service.go Refactors component builder to accept kubernetes.Interface for testing.
pkg/components/portainer/rbac.go Refactors RBAC builders to accept kubernetes.Interface for testing.
pkg/components/portainer/namespace.go Refactors namespace builder to accept kubernetes.Interface for testing.
pkg/components/portainer/deployment.go Refactors deployment builder to accept kubernetes.Interface for testing.
pkg/components/portainer/configuration.go Refactors ConfigMap/Secret builders to accept kubernetes.Interface for testing.
pkg/components/localpath/storageclass.go Refactors StorageClass builder to accept kubernetes.Interface for testing.
pkg/components/localpath/storageclass_test.go Adds unit tests for local-path StorageClass creation/idempotency.
pkg/components/localpath/rbac.go Refactors RBAC builders to accept kubernetes.Interface for testing.
pkg/components/localpath/namespace.go Refactors namespace builder to accept kubernetes.Interface for testing.
pkg/components/localpath/deployment.go Refactors deployment builder to accept kubernetes.Interface for testing.
pkg/components/localpath/configmap.go Refactors ConfigMap builder to accept kubernetes.Interface for testing.
pkg/components/d2k/service.go Refactors Service builder to accept kubernetes.Interface for testing.
pkg/components/d2k/secret.go Refactors Secret builder to accept kubernetes.Interface for testing.
pkg/components/d2k/rbac.go Refactors RBAC builders to accept kubernetes.Interface for testing.
pkg/components/d2k/namespace.go Refactors namespace builder to accept kubernetes.Interface for testing.
pkg/components/d2k/deployment.go Refactors deployment builder to accept kubernetes.Interface for testing.
pkg/components/coredns/service.go Refactors Service builder to accept kubernetes.Interface for testing.
pkg/components/coredns/rbac.go Refactors RBAC builders to accept kubernetes.Interface for testing.
pkg/components/coredns/manifests_test.go Adds unit tests for CoreDNS manifests (deployment/service/config/RBAC).
pkg/components/coredns/deployment.go Refactors deployment builder to accept kubernetes.Interface for testing.
pkg/components/coredns/coredns.go Refactors readiness wait helper to accept kubernetes.Interface for testing.
pkg/components/coredns/configuration.go Refactors ConfigMap builder to accept kubernetes.Interface for testing.
pkg/components/coredns/configuration_test.go Adds unit tests for Corefile invariants/forwarder/v6 toggle behavior.
Makefile Adds test, test-race, lint-ci, test-e2e, bench, soak targets.
internal/runtime/network/ip_test.go Adds unit tests for IP/DNS/resolv.conf validation & sanitization logic.
internal/core/pki/validate_test.go Adds unit tests for PKI invalidation/removal behaviors.
internal/cli/semver_test.go Adds unit tests for CLI semver parsing/comparison.
internal/cli/runmode_test.go Adds unit tests for runmode arg insertion logic.
go.mod Adds github.com/stretchr/testify dependency for tests.
.golangci.yml Adds initial golangci-lint configuration (focused linters + gofmt).
.gitignore Ignores generated coverage/perf/sonobuoy artifacts while keeping baselines tracked.
.github/workflows/nightly.yaml Adds nightly perf/soak/conformance-lite workflows across amd64/arm64.
.github/workflows/ci.yaml Adds unit-test + lint jobs and native-runner e2e smoke jobs gated on built images.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/e2e/lib.sh Outdated
Comment thread .github/workflows/ci.yaml Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 79 out of 80 changed files in this pull request and generated 3 comments.

go func() {
log.Debug().Msg("Starting pprof server on :6060")
http.ListenAndServe(":6060", nil)
_ = http.ListenAndServe(":6060", nil)
Comment thread test/e2e/manifests.sh
Comment on lines +33 to +34
kc apply -f "$MANIFESTS/01-workload/workload.yaml" >/dev/null
kc -n tier1-workload rollout status deployment/web --timeout="$WAIT"
Comment thread test/e2e/manifests.sh
Comment on lines +109 to +111
kc apply -f "$MANIFESTS/05-dns-lb/dns-lb.yaml" >/dev/null
kc -n tier5-a rollout status deployment/web --timeout="$WAIT"
kc -n tier5-b wait --for=condition=Ready pod/dns-client --timeout="$WAIT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants