Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit 63fde24

Browse files
authored
Merge pull request #127 from erikgb/fix/timeout-stop-api-server
Fix timeout stopping testEnv api-server on K8s 1.20+
2 parents bdaef15 + 01e4767 commit 63fde24

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

internal/integtest/setup.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616
package integtest
1717

1818
import (
19+
"context"
1920
"path/filepath"
2021
"testing"
2122
"time"
@@ -44,8 +45,9 @@ import (
4445
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
4546

4647
var (
47-
K8sClient client.Client
48-
testEnv *envtest.Environment
48+
K8sClient client.Client
49+
testEnv *envtest.Environment
50+
k8sManagerCancelFn context.CancelFunc
4951
)
5052

5153
func HNCRun(t *testing.T, title string) {
@@ -108,12 +110,17 @@ func HNCBeforeSuite() {
108110
Expect(K8sClient).ToNot(BeNil())
109111

110112
go func() {
111-
err = k8sManager.Start(ctrl.SetupSignalHandler())
113+
var ctx context.Context
114+
ctx, k8sManagerCancelFn = context.WithCancel(ctrl.SetupSignalHandler())
115+
err = k8sManager.Start(ctx)
112116
Expect(err).ToNot(HaveOccurred())
113117
}()
114118
}
115119

116120
func HNCAfterSuite() {
121+
if k8sManagerCancelFn != nil {
122+
k8sManagerCancelFn()
123+
}
117124
By("tearing down the test environment")
118125
Expect(testEnv).ToNot(BeNil())
119126
err := testEnv.Stop()

0 commit comments

Comments
 (0)