Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Yu Jiang <yu_jiang@intuit.com>
  • Loading branch information
Yu Jiang committed Jan 8, 2024
1 parent 3781c70 commit 8adfd2b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion controllers/common/common_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ var k8sClient client.Client
var k8sCl k8s.Client
var testEnv *envtest.Environment
var mockWavefront *mock_wavefront.MockInterface
var mgrCtx context.Context

// https://github.com/kubernetes-sigs/controller-runtime/issues/1571
var cancelFunc context.CancelFunc

func TestCommon(t *testing.T) {
RegisterFailHandler(Fail)
Expand Down Expand Up @@ -94,14 +98,17 @@ var _ = BeforeSuite(func() {
Expect(err).ToNot(HaveOccurred())

go func() {
err = k8sManager.Start(ctrl.SetupSignalHandler())
mgrCtx, cancelFunc = context.WithCancel(context.Background())
err = k8sManager.Start(mgrCtx)
Expect(err).ToNot(HaveOccurred())
}()

}, 60)

var _ = AfterSuite(func() {
By("tearing down the test environment")
cancelFunc()

err := testEnv.Stop()
Expect(err).NotTo(HaveOccurred())
})
9 changes: 8 additions & 1 deletion controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ var cfg *rest.Config
var k8sClient client.Client
var testEnv *envtest.Environment
var mockWavefront *mock_wavefront.MockInterface
var mgrCtx context.Context

// https://github.com/kubernetes-sigs/controller-runtime/issues/1571
var cancelFunc context.CancelFunc

func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)
Expand Down Expand Up @@ -120,14 +124,17 @@ var _ = BeforeSuite(func() {
Expect(err).ToNot(HaveOccurred())

go func() {
err = k8sManager.Start(ctrl.SetupSignalHandler())
mgrCtx, cancelFunc = context.WithCancel(context.Background())
err = k8sManager.Start(mgrCtx)
Expect(err).ToNot(HaveOccurred())
}()

})

var _ = AfterSuite(func() {
By("tearing down the test environment")
cancelFunc()

err := testEnv.Stop()
Expect(err).ToNot(HaveOccurred())
})

0 comments on commit 8adfd2b

Please sign in to comment.