Skip to content

Commit

Permalink
tests: fix kube-apiserver teardown timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
paullaffitte committed Feb 2, 2023
1 parent 4205726 commit 548e414
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import (
var cfg *rest.Config
var k8sClient client.Client
var testEnv *envtest.Environment
var ctx context.Context
var cancel context.CancelFunc
var registryContainerId string

func TestAPIs(t *testing.T) {
Expand Down Expand Up @@ -102,6 +104,8 @@ func removeRegistry() {
var _ = BeforeSuite(func() {
logf.SetLogger(zap.New(zap.WriteTo(os.Stdout), zap.UseDevMode(true)))

ctx, cancel = context.WithCancel(context.TODO())

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
Expand Down Expand Up @@ -149,12 +153,13 @@ var _ = BeforeSuite(func() {

go func() {
defer GinkgoRecover()
err = k8sManager.Start(ctrl.SetupSignalHandler())
err = k8sManager.Start(ctx)
Expect(err).ToNot(HaveOccurred(), "failed to run manager")
}()
})

var _ = AfterSuite(func() {
cancel()
By("tearing down the test environment")
err := testEnv.Stop()
Expect(err).NotTo(HaveOccurred())
Expand Down

0 comments on commit 548e414

Please sign in to comment.