Pass Context to StartTestServer

Signed-off-by: Kante Yin <kerthcet@gmail.com>
This commit is contained in:
Kante Yin
2023-03-31 12:19:26 +08:00
committed by kerthcet
parent 2d866ec2fc
commit a7035f5459
42 changed files with 754 additions and 473 deletions

View File

@@ -59,13 +59,14 @@ type TestServerSetup struct {
type TearDownFunc func()
// StartTestServer runs a kube-apiserver, optionally calling out to the setup.ModifyServerRunOptions and setup.ModifyServerConfig functions
func StartTestServer(t testing.TB, setup TestServerSetup) (client.Interface, *rest.Config, TearDownFunc) {
func StartTestServer(ctx context.Context, t testing.TB, setup TestServerSetup) (client.Interface, *rest.Config, TearDownFunc) {
ctx, cancel := context.WithCancel(ctx)
certDir, err := os.MkdirTemp("", "test-integration-"+strings.ReplaceAll(t.Name(), "/", "_"))
if err != nil {
t.Fatalf("Couldn't create temp dir: %v", err)
}
ctx, cancel := context.WithCancel(context.Background())
var errCh chan error
tearDownFn := func() {
// Calling cancel function is stopping apiserver and cleaning up