test: use cancelation from ktesting
The return type of ktesting.NewTestContext is now a TContext. Code which combined it WithCancel often didn't compile anymore (cannot overwrite ktesting.TContext with context.Context). This is a good thing because all of that code can be simplified to let ktesting handle the cancelation.
This commit is contained in:
@@ -48,10 +48,9 @@ const (
|
||||
)
|
||||
|
||||
func setup(t testing.TB, maxReadonlyRequestsInFlight, maxMutatingRequestsInFlight int) (context.Context, *rest.Config, framework.TearDownFunc) {
|
||||
_, ctx := ktesting.NewTestContext(t)
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
tCtx := ktesting.Init(t)
|
||||
|
||||
_, kubeConfig, tearDownFn := framework.StartTestServer(ctx, t, framework.TestServerSetup{
|
||||
_, kubeConfig, tearDownFn := framework.StartTestServer(tCtx, t, framework.TestServerSetup{
|
||||
ModifyServerRunOptions: func(opts *options.ServerRunOptions) {
|
||||
// Ensure all clients are allowed to send requests.
|
||||
opts.Authorization.Modes = []string{"AlwaysAllow"}
|
||||
@@ -61,10 +60,10 @@ func setup(t testing.TB, maxReadonlyRequestsInFlight, maxMutatingRequestsInFligh
|
||||
})
|
||||
|
||||
newTeardown := func() {
|
||||
cancel()
|
||||
tCtx.Cancel("tearing down apiserver")
|
||||
tearDownFn()
|
||||
}
|
||||
return ctx, kubeConfig, newTeardown
|
||||
return tCtx, kubeConfig, newTeardown
|
||||
}
|
||||
|
||||
func TestPriorityLevelIsolation(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user