Skip to content

Add envtest integration tests for kube controller#2487

Merged
AryanP123 merged 3 commits into
skupperproject:mainfrom
AryanP123:add-kube-controller-envtest
Jun 30, 2026
Merged

Add envtest integration tests for kube controller#2487
AryanP123 merged 3 commits into
skupperproject:mainfrom
AryanP123:add-kube-controller-envtest

Conversation

@AryanP123

@AryanP123 AryanP123 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #2486

Summary by CodeRabbit

  • Documentation
    • Added an integration testing README covering envtest setup, expected layout, and how to run integration tests.
  • Tests
    • Added a Kubernetes controller integration test harness using envtest with shared lifecycle management.
    • Added new integration coverage for Site and Site with Listener, plus reusable controller test helpers.
  • New Features
    • Introduced a test-integration Make target with configurable TESTFLAGS and ENVTEST_K8S_VERSION.
  • Chores
    • Updated Go module dependencies to newer versions, including additional indirect tooling for envtest/controller-runtime.

@AryanP123

Copy link
Copy Markdown
Contributor Author

@ajssmith @fgiorgetti @c-kruse Thoughts on this set up? For now just added integration tests for skupper/internal/kube/controller/controller.go. Didn't want to crowd the location of production files with more test files as unit tests typically already exist there.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggest a separate issue/pr for changes to NewClient as scope separate/independent from envtest integration

@AryanP123 AryanP123 Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

issue: #2506
pr: #2507

Comment thread tests/integration/kube-controller/suite_test.go Outdated
Comment thread Makefile Outdated
Comment thread tests/integration/README.md
Comment thread Makefile Outdated

.PHONY: test-integration
test-integration:
@assets=$$(PATH="$$HOME/go/bin:$$PATH" setup-envtest use 1.33.0 -p path 2>/dev/null || PATH="$$HOME/go/bin:$$PATH" setup-envtest use -p path 2>/dev/null); \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion for the setup-envtest tool and envtest system dependencies.

We should look at using a go tool to pin a setup-envtest version so that everyone doesn't immediately begin to drift and we don't need to make assumptions about the go binary path.

@AryanP123 AryanP123 force-pushed the add-kube-controller-envtest branch from 43674c5 to 313002e Compare June 23, 2026 16:05
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f2865e52-0684-4f56-9188-9e5794a3e14d

📥 Commits

Reviewing files that changed from the base of the PR and between cfeb6ad and 5f9067a.

📒 Files selected for processing (1)
  • tests/integration/README.md
✅ Files skipped from review due to trivial changes (1)
  • tests/integration/README.md

📝 Walkthrough

Walkthrough

Adds envtest-based integration testing for the Skupper Kubernetes controller, including dependency updates, a shared test harness, controller integration tests, a Makefile target, and documentation.

Changes

Kube Controller Integration Tests

Layer / File(s) Summary
Go module dependencies for controller-runtime and envtest
go.mod
Updates github.com/spf13/pflag to v1.0.6, adds indirect dependencies github.com/blang/semver/v4, github.com/evanphx/json-patch/v5, github.com/spf13/afero, go.uber.org/multierr, go.uber.org/zap, and sigs.k8s.io/controller-runtime, and adds the setup-envtest tool directive.
envtest suite bootstrap and controller lifecycle
tests/integration/kube/controller/suite_test.go
TestMain starts envtest with CRD base paths, starts a shared controller, and shuts both down after the test run. startSharedController configures the controller environment, creates the envtest-backed client, ensures the installation namespace exists, and runs the controller in a goroutine. stopSharedController closes the stop channel and waits for shutdown. testContext, setup(t), and createNamespace provide per-test access to the shared client and namespace creation.
Test helper utilities
tests/integration/kube/controller/helpers_test.go
Adds waitFor for retry-based polling, retryOnNotFound for Kubernetes NotFound handling, listenerWithHostPort for Listener fixtures, routerSelector for router label selection, and verifyStatus for checking status type, message, and expected conditions.
Site and Listener integration tests
tests/integration/kube/controller/site_test.go, tests/integration/kube/controller/listener_test.go
TestSimpleSite creates a Site, waits for the configured condition, and validates the resulting Site status and router Deployment labels/container count. TestSiteWithListener creates a Listener, waits for the listener and Service, then checks the Site status, router Deployment label, Service selector and port, listener label, and router ConfigMap transport configuration.
Makefile test-integration target and environment variables
tests/Makefile
Adds SKUPPER_ROOT, TESTFLAGS, and ENVTEST_K8S_VERSION, and introduces the test-integration target that resolves envtest assets, exports KUBEBUILDER_ASSETS, and runs the integration controller test package with -tags=integration.
Integration test documentation
tests/integration/README.md
Documents the envtest-based integration test purpose, repository layout, setup-envtest prerequisites and version pinning, run instructions from different working directories, USE_EXISTING_CLUSTER=true usage, and expected runtime and teardown notes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding envtest integration tests for the kube controller.
Linked Issues check ✅ Passed The PR matches #2486 by adding envtest-based integration tests, starting with the kube controller as requested.
Out of Scope Changes check ✅ Passed The dependency, Makefile, and README updates support the envtest integration test work and are in scope.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 5


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b474ac35-816d-4f5e-bd02-4f19abb97778

📥 Commits

Reviewing files that changed from the base of the PR and between 6f4f2b3 and 313002e.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (7)
  • go.mod
  • tests/Makefile
  • tests/integration/README.md
  • tests/integration/kube/controller/helpers_test.go
  • tests/integration/kube/controller/listener_test.go
  • tests/integration/kube/controller/site_test.go
  • tests/integration/kube/controller/suite_test.go

Comment thread tests/integration/kube/controller/listener_test.go
Comment thread tests/integration/kube/controller/site_test.go
Comment thread tests/integration/kube/controller/suite_test.go Outdated
Comment thread tests/integration/README.md Outdated
Comment thread tests/Makefile Outdated
@AryanP123 AryanP123 force-pushed the add-kube-controller-envtest branch from 313002e to cf0464d Compare June 23, 2026 16:16
@ajssmith

Copy link
Copy Markdown
Member

will need to rebase once #2507 is merged

@AryanP123 AryanP123 force-pushed the add-kube-controller-envtest branch from 5d804b1 to cfeb6ad Compare June 29, 2026 14:57
@AryanP123 AryanP123 requested a review from c-kruse June 29, 2026 18:04

@c-kruse c-kruse left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me!

Comment thread tests/Makefile
@@ -1,4 +1,7 @@
ROOT_PATH := $(shell pwd)
SKUPPER_ROOT := $(abspath $(ROOT_PATH)/..)
TESTFLAGS ?= -v -race -short

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggest we add -count=1 to disable test caching. If I run this today make test-integration; make test-integration ENVTEST_K8S_VERSION=1.30.0 the go tests only runs once (assuming it passes a first time).

Also -short does nothing right now, although it could be interesting to have short and long timeouts for local vs CI or something. I could go either way on enabling -race detection.

@ajssmith ajssmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good to me, thanks.

A suggestion would be to document in the README the USE_EXISTING_CLUSTER env var that can run the integration test against full cluster.

@AryanP123 AryanP123 merged commit fbeae37 into skupperproject:main Jun 30, 2026
3 checks passed
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.

Add integration testing

3 participants