Skip to content

Commit

Permalink
Merge pull request #4028 from nojnhuh/update-envtest-k8s
Browse files Browse the repository at this point in the history
update envtest k8s to 1.27
  • Loading branch information
k8s-ci-robot authored Sep 22, 2023
2 parents 41689c9 + 0903135 commit 29a3e68
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)
}

// Stop stops the test environment.
Expand Down

0 comments on commit 29a3e68

Please sign in to comment.