Skip to content

Commit

Permalink
fail if stop was not successful
Browse files Browse the repository at this point in the history
Signed-off-by: Inteon <42113979+inteon@users.noreply.github.com>
  • Loading branch information
inteon committed Aug 6, 2021
1 parent 3cad738 commit 8ec405e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
17 changes: 4 additions & 13 deletions test/integration/framework/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,6 @@ func RunControlPlane(t *testing.T) (*rest.Config, StopFunc) {
}

webhookOpts, stopWebhook := webhooktesting.StartWebhookServer(t, []string{"--api-server-host=" + config.Host})
stopFn := func() {
defer stopWebhook()
stopControlPlane()
}

initialised := false
defer func() {
if !initialised {
stopFn()
}
}()

crdsDir := apitesting.CRDDirectory(t)
crds := readCustomResourcesAtPath(t, crdsDir)
Expand Down Expand Up @@ -97,8 +86,10 @@ func RunControlPlane(t *testing.T) (*rest.Config, StopFunc) {
t.Fatal(err)
}

initialised = true
return config, stopFn
return config, func() {
defer stopWebhook()
stopControlPlane()
}
}

var (
Expand Down
2 changes: 1 addition & 1 deletion test/internal/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func RunBareControlPlane(t *testing.T) (*envtest.Environment, StopFunc) {

return env, func() {
if err := env.Stop(); err != nil {
t.Logf("failed to shut down control plane, not failing test: %v", err)
t.Fatalf("failed to shut down control plane: %v", err)
}
}
}

0 comments on commit 8ec405e

Please sign in to comment.