Skip to content

Commit 0df8f7c

Browse files
committed
Improve dev environnement
Without this patch, while developping (on uncommitted work), the image with previous SHA gets overriden, which leads to mishaps. This fixes it by ensuring only the kured:dev tags (full path and short one) are used everywhere. At the same time, it cleans up the main_test to be more flexible by passing more of the main features as options. Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
1 parent 4687d88 commit 0df8f7c

File tree

2 files changed

+71
-13
lines changed

2 files changed

+71
-13
lines changed

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bootstrap-tools: $(HACKDIR)
2424
clean:
2525
rm -rf ./dist
2626

27-
kured: bootstrap-tools
27+
kured: clean bootstrap-tools
2828
$(GORELEASER_CMD) build --clean --single-target --snapshot
2929

3030
kured-all: bootstrap-tools
@@ -39,8 +39,9 @@ kured-release-snapshot: bootstrap-tools
3939
image: kured
4040
$(SUDO) docker buildx build --no-cache --load -t ghcr.io/$(DH_ORG)/kured:$(VERSION) .
4141

42-
dev-image: image
43-
$(SUDO) docker tag ghcr.io/$(DH_ORG)/kured:$(VERSION) kured:dev
42+
dev-image: kured
43+
$(SUDO) docker buildx build --no-cache --load -t ghcr.io/$(DH_ORG)/kured:dev .
44+
$(SUDO) docker tag ghcr.io/$(DH_ORG)/kured:dev kured:dev
4445

4546
dev-manifest:
4647
# basic e2e scenario

tests/kind/main_test.go

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,27 @@ func LocalImage(nameTag string) Option {
8484
}
8585
}
8686

87+
// Deploy can be passed to NewKind to deploy extra components, in addition to the base deployment.
88+
func WithClusterName(name string) Option {
89+
return func(k *KindTest) {
90+
k.clusterName = name
91+
}
92+
}
93+
94+
func ForTestInstance(t *testing.T) Option {
95+
return func(k *KindTest) {
96+
k.testInstance = t
97+
}
98+
}
99+
87100
// NewKind creates a kind cluster given a name and set of Option instances.
88-
func NewKindTester(kindClusterName string, filePath string, t *testing.T, options ...Option) *KindTest {
101+
func NewKindTester(config string, options ...Option) *KindTest {
89102

90103
k := &KindTest{
91-
clusterName: kindClusterName,
104+
clusterName: "kured",
92105
timeout: 10 * time.Minute,
93-
kindConfigPath: filePath,
94-
testInstance: t,
106+
kindConfigPath: config,
107+
testInstance: nil,
95108
}
96109
for _, option := range options {
97110
option(k)
@@ -157,7 +170,14 @@ func TestE2EWithCommand(t *testing.T) {
157170
kindClusterConfigFile := fmt.Sprintf("../../.github/kind-cluster-%v.yaml", version)
158171
kindContext := fmt.Sprintf("kind-%v", kindClusterName)
159172

160-
k := NewKindTester(kindClusterName, kindClusterConfigFile, t, LocalImage(kuredDevImage), Deploy("../../kured-rbac.yaml"), Deploy("testfiles/kured-ds.yaml"))
173+
k := NewKindTester(
174+
kindClusterConfigFile,
175+
ForTestInstance(t),
176+
WithClusterName(kindClusterName),
177+
LocalImage(kuredDevImage),
178+
Deploy("../../kured-rbac.yaml"),
179+
Deploy("testfiles/kured-ds.yaml"),
180+
)
161181
defer k.FlushLog()
162182

163183
err := k.Create()
@@ -207,7 +227,14 @@ func TestE2EWithSignal(t *testing.T) {
207227
kindClusterConfigFile := fmt.Sprintf("../../.github/kind-cluster-%v.yaml", version)
208228
kindContext := fmt.Sprintf("kind-%v", kindClusterName)
209229

210-
k := NewKindTester(kindClusterName, kindClusterConfigFile, t, LocalImage(kuredDevImage), Deploy("../../kured-rbac.yaml"), Deploy("testfiles/kured-ds-signal.yaml"))
230+
k := NewKindTester(
231+
kindClusterConfigFile,
232+
ForTestInstance(t),
233+
WithClusterName(kindClusterName),
234+
LocalImage(kuredDevImage),
235+
Deploy("../../kured-rbac.yaml"),
236+
Deploy("testfiles/kured-ds-signal.yaml"),
237+
)
211238
defer k.FlushLog()
212239

213240
err := k.Create()
@@ -257,7 +284,14 @@ func TestE2EConcurrentWithCommand(t *testing.T) {
257284
kindClusterConfigFile := fmt.Sprintf("../../.github/kind-cluster-%v.yaml", version)
258285
kindContext := fmt.Sprintf("kind-%v", kindClusterName)
259286

260-
k := NewKindTester(kindClusterName, kindClusterConfigFile, t, LocalImage(kuredDevImage), Deploy("../../kured-rbac.yaml"), Deploy("testfiles/kured-ds-concurrent-command.yaml"))
287+
k := NewKindTester(
288+
kindClusterConfigFile,
289+
ForTestInstance(t),
290+
WithClusterName(kindClusterName),
291+
LocalImage(kuredDevImage),
292+
Deploy("../../kured-rbac.yaml"),
293+
Deploy("testfiles/kured-ds-concurrent-command.yaml"),
294+
)
261295
defer k.FlushLog()
262296

263297
err := k.Create()
@@ -307,7 +341,14 @@ func TestE2EConcurrentWithSignal(t *testing.T) {
307341
kindClusterConfigFile := fmt.Sprintf("../../.github/kind-cluster-%v.yaml", version)
308342
kindContext := fmt.Sprintf("kind-%v", kindClusterName)
309343

310-
k := NewKindTester(kindClusterName, kindClusterConfigFile, t, LocalImage(kuredDevImage), Deploy("../../kured-rbac.yaml"), Deploy("testfiles/kured-ds-concurrent-signal.yaml"))
344+
k := NewKindTester(
345+
kindClusterConfigFile,
346+
ForTestInstance(t),
347+
WithClusterName(kindClusterName),
348+
LocalImage(kuredDevImage),
349+
Deploy("../../kured-rbac.yaml"),
350+
Deploy("testfiles/kured-ds-concurrent-signal.yaml"),
351+
)
311352
defer k.FlushLog()
312353

313354
err := k.Create()
@@ -362,7 +403,16 @@ func TestCordonningIsKept(t *testing.T) {
362403
} else {
363404
manifest = "testfiles/kured-ds-concurrent-signal.yaml"
364405
}
365-
k := NewKindTester(kindClusterName, kindClusterConfigFile, t, LocalImage(kuredDevImage), Deploy("../../kured-rbac.yaml"), Deploy(manifest))
406+
407+
k := NewKindTester(
408+
kindClusterConfigFile,
409+
ForTestInstance(t),
410+
WithClusterName(kindClusterName),
411+
LocalImage(kuredDevImage),
412+
Deploy("../../kured-rbac.yaml"),
413+
Deploy(manifest),
414+
)
415+
366416
defer k.FlushLog()
367417

368418
err := k.Create()
@@ -405,7 +455,14 @@ func TestE2EBlocker(t *testing.T) {
405455
kindClusterConfigFile := "../../.github/kind-cluster-next.yaml"
406456
kindContext := fmt.Sprintf("kind-%v", kindClusterName)
407457

408-
k := NewKindTester(kindClusterName, kindClusterConfigFile, t, LocalImage(kuredDevImage), Deploy("../../kured-rbac.yaml"), Deploy(fmt.Sprintf("testfiles/kured-ds-%v.yaml", variant)))
458+
k := NewKindTester(
459+
kindClusterConfigFile,
460+
ForTestInstance(t),
461+
WithClusterName(kindClusterName),
462+
LocalImage(kuredDevImage),
463+
Deploy("../../kured-rbac.yaml"),
464+
Deploy(fmt.Sprintf("testfiles/kured-ds-%v.yaml", variant)),
465+
)
409466
defer k.FlushLog()
410467

411468
err := k.Create()

0 commit comments

Comments
 (0)