Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions operator/internal/testutils/setup_envtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,18 @@ func (e *RedpandaTestEnv) StartRedpandaTestEnv(withWebhook bool) (*rest.Config,
Paths: []string{filepath.Join(configPath, "webhook")},
}
}

cfg, err := e.Start()
if err != nil {
return nil, err
}

// Ideally we'd plumb in testing.T here to ensure that clean up is run.
// This seems to run ~80% of the time which is a dramatic improvement.
runtime.AddCleanup(cfg, func(e *RedpandaTestEnv) {
_ = e.Stop()
}, e)

return cfg, err
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/kube/envexpander_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func TestEnvExpander(t *testing.T) {
cfg, err := env.Start()
require.NoError(t, err)

t.Cleanup(func() { _ = env.Stop() })

c, err := client.New(cfg, client.Options{})
require.NoError(t, err)

Expand Down