Skip to content

Commit 7b53629

Browse files
committed
feat(e2e): Layer 1 Kind-based E2E — CRDs, operator health, webhooks, CRUD, metrics
Replace scaffold-generated e2e suite with a Helm-based Kind test that installs imp-crds + imp via Helm, then asserts all six CRDs are present, the operator pod reaches Running, the admission webhook rejects invalid ImpVMs, CRUD round-trip succeeds, and /metrics returns 200. Add e2e-kind CI job (helm/kind-action) alongside the existing Talos e2e job so Kind tests run on ubuntu-latest without a self-hosted runner.
1 parent 3b47d41 commit 7b53629

3 files changed

Lines changed: 134 additions & 401 deletions

File tree

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,24 @@ jobs:
105105
- name: Cleanup
106106
if: always()
107107
run: talosctl cluster destroy --name imp-e2e
108+
109+
e2e-kind:
110+
name: E2E (Kind)
111+
runs-on: ${{ vars.E2E_RUNNER_LABEL || 'ubuntu-latest' }}
112+
needs: [lint, build]
113+
steps:
114+
- uses: actions/checkout@v4
115+
116+
- uses: actions/setup-go@v5
117+
with:
118+
go-version-file: go.mod
119+
120+
- uses: helm/kind-action@v1
121+
with:
122+
cluster_name: imp-e2e
123+
124+
- name: Install Helm
125+
uses: azure/setup-helm@v4
126+
127+
- name: Run E2E tests
128+
run: go test -tags e2e ./test/e2e/... -v -timeout 15m

test/e2e/e2e_suite_test.go

Lines changed: 37 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ limitations under the License.
2020
package e2e
2121

2222
import (
23-
"fmt"
24-
"os"
2523
"os/exec"
2624
"testing"
2725

@@ -31,74 +29,50 @@ import (
3129
"github.com/syscode-labs/imp/test/utils"
3230
)
3331

34-
var (
35-
// managerImage is the manager image to be built and loaded for testing.
36-
managerImage = "imp-operator:dev"
37-
// shouldCleanupCertManager tracks whether CertManager was installed by this suite.
38-
shouldCleanupCertManager = false
32+
const (
33+
namespace = "imp-system"
34+
helmRelease = "imp"
35+
helmCRDRelease = "imp-crds"
3936
)
4037

41-
// TestE2E runs the e2e test suite to validate the solution in an isolated environment.
42-
// The default setup requires Kind and CertManager.
43-
//
44-
// To skip CertManager installation, set: CERT_MANAGER_INSTALL_SKIP=true
45-
func TestE2E(t *testing.T) {
46-
RegisterFailHandler(Fail)
47-
_, _ = fmt.Fprintf(GinkgoWriter, "Starting imp e2e test suite\n")
48-
RunSpecs(t, "e2e suite")
49-
}
50-
5138
var _ = BeforeSuite(func() {
52-
By("building the manager image")
53-
cmd := exec.Command("make", "docker-build", fmt.Sprintf("IMG=%s", managerImage)) //nolint:gosec
54-
_, err := utils.Run(cmd)
55-
ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to build the manager image")
56-
57-
By("loading the manager image on Kind")
58-
err = utils.LoadImageToKindClusterWithName(managerImage)
59-
ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to load the manager image into Kind")
60-
61-
// CertManager is only needed for webhooks. Skip unless CERT_MANAGER_INSTALL_SKIP=false.
62-
if os.Getenv("CERT_MANAGER_INSTALL_SKIP") != "false" {
63-
_, _ = fmt.Fprintf(GinkgoWriter, "Skipping CertManager (no webhooks in this build)\n")
64-
return
65-
}
66-
setupCertManager()
39+
By("creating namespace")
40+
nsCmd := exec.Command("kubectl", "create", "ns", namespace)
41+
_, _ = utils.Run(nsCmd) // ignore if already exists
42+
43+
By("installing cert-manager")
44+
Expect(utils.InstallCertManager()).To(Succeed(), "helm install cert-manager failed")
45+
46+
By("installing imp-crds chart")
47+
crdsCmd := exec.Command("helm", "install", helmCRDRelease, "charts/imp-crds",
48+
"--namespace", namespace, "--wait", "--create-namespace")
49+
_, err := utils.Run(crdsCmd)
50+
Expect(err).NotTo(HaveOccurred(), "helm install imp-crds failed")
51+
52+
By("installing imp chart")
53+
impCmd := exec.Command("helm", "install", helmRelease, "charts/imp",
54+
"--namespace", namespace,
55+
"--set", "metrics.serviceMonitor.enabled=false",
56+
"--set", "metrics.podMonitor.enabled=false",
57+
"--wait", "--timeout", "2m")
58+
_, err = utils.Run(impCmd)
59+
Expect(err).NotTo(HaveOccurred(), "helm install imp failed")
6760
})
6861

6962
var _ = AfterSuite(func() {
70-
teardownCertManager()
71-
})
63+
By("uninstalling imp chart")
64+
unimpCmd := exec.Command("helm", "uninstall", helmRelease, "--namespace", namespace)
65+
_, _ = utils.Run(unimpCmd)
7266

73-
// setupCertManager installs CertManager if needed for webhook tests.
74-
// Skips installation if CERT_MANAGER_INSTALL_SKIP=true or if already present.
75-
func setupCertManager() {
76-
if os.Getenv("CERT_MANAGER_INSTALL_SKIP") == "true" {
77-
_, _ = fmt.Fprintf(GinkgoWriter, "Skipping CertManager installation (CERT_MANAGER_INSTALL_SKIP=true)\n")
78-
return
79-
}
80-
81-
By("checking if CertManager is already installed")
82-
if utils.IsCertManagerCRDsInstalled() {
83-
_, _ = fmt.Fprintf(GinkgoWriter, "CertManager is already installed. Skipping installation.\n")
84-
return
85-
}
86-
87-
// Mark for cleanup before installation to handle interruptions and partial installs.
88-
shouldCleanupCertManager = true
89-
90-
By("installing CertManager")
91-
Expect(utils.InstallCertManager()).To(Succeed(), "Failed to install CertManager")
92-
}
67+
By("uninstalling imp-crds chart")
68+
uncrdsCmd := exec.Command("helm", "uninstall", helmCRDRelease, "--namespace", namespace)
69+
_, _ = utils.Run(uncrdsCmd)
9370

94-
// teardownCertManager uninstalls CertManager if it was installed by setupCertManager.
95-
// This ensures we only remove what we installed.
96-
func teardownCertManager() {
97-
if !shouldCleanupCertManager {
98-
_, _ = fmt.Fprintf(GinkgoWriter, "Skipping CertManager cleanup (not installed by this suite)\n")
99-
return
100-
}
101-
102-
By("uninstalling CertManager")
71+
By("uninstalling cert-manager")
10372
utils.UninstallCertManager()
73+
})
74+
75+
func TestE2E(t *testing.T) {
76+
RegisterFailHandler(Fail)
77+
RunSpecs(t, "Imp E2E Suite")
10478
}

0 commit comments

Comments
 (0)