Skip to content

Commit

Permalink
update envtest k8s to 1.27
Browse files Browse the repository at this point in the history
  • Loading branch information
nojnhuh committed Sep 22, 2023
1 parent b195e9a commit 0903135
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export GOPROXY
export GO111MODULE=on

# Kubebuilder.
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.20.2
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.27
export KUBEBUILDER_CONTROLPLANE_START_TIMEOUT ?= 60s
export KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT ?= 60s

Expand Down
9 changes: 7 additions & 2 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import (
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.

var (
testEnv *env.TestEnvironment
testEnv *env.TestEnvironment
testEnvCancel func()
)

func TestAPIs(t *testing.T) {
Expand Down Expand Up @@ -64,10 +65,13 @@ var _ = BeforeSuite(func() {

// +kubebuilder:scaffold:scheme

ctx, cancel := context.WithCancel(context.Background())
testEnvCancel = cancel

By("starting the manager")
go func() {
defer GinkgoRecover()
Expect(testEnv.StartManager()).To(Succeed())
Expect(testEnv.StartManager(ctx)).To(Succeed())
}()

Eventually(func() bool {
Expand All @@ -80,6 +84,7 @@ var _ = BeforeSuite(func() {
})

var _ = AfterSuite(func() {
testEnvCancel()
if testEnv != nil {
By("tearing down the test environment")
Expect(testEnv.Stop()).To(Succeed())
Expand Down
9 changes: 7 additions & 2 deletions exp/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import (
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.

var (
testEnv *env.TestEnvironment
testEnv *env.TestEnvironment
testEnvCancel func()
)

func TestAPIs(t *testing.T) {
Expand All @@ -60,10 +61,13 @@ var _ = BeforeSuite(func() {

// +kubebuilder:scaffold:scheme

mgrCtx, mgrCancel := context.WithCancel(context.Background())
testEnvCancel = mgrCancel

By("starting the manager")
go func() {
defer GinkgoRecover()
Expect(testEnv.StartManager()).To(Succeed())
Expect(testEnv.StartManager(mgrCtx)).To(Succeed())
}()

Eventually(func() bool {
Expand All @@ -76,6 +80,7 @@ var _ = BeforeSuite(func() {
})

var _ = AfterSuite(func() {
testEnvCancel()
if testEnv != nil {
By("tearing down the test environment")
Expect(testEnv.Stop()).To(Succeed())
Expand Down
4 changes: 2 additions & 2 deletions internal/test/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ func NewTestEnvironment() *TestEnvironment {
}

// StartManager starts the test environment manager and blocks until the context is canceled.
func (t *TestEnvironment) StartManager() error {
return t.Manager.Start(context.Background())
func (t *TestEnvironment) StartManager(ctx context.Context) error {
return t.Manager.Start(ctx)

Check warning on line 123 in internal/test/env/env.go

View check run for this annotation

Codecov / codecov/patch

internal/test/env/env.go#L122-L123

Added lines #L122 - L123 were not covered by tests
}

// Stop stops the test environment.
Expand Down

0 comments on commit 0903135

Please sign in to comment.