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:
@@ -136,9 +136,7 @@ func TestClientCARecreate(t *testing.T) {
|
||||
}
|
||||
|
||||
func testClientCA(t *testing.T, recreate bool) {
|
||||
_, ctx := ktesting.NewTestContext(t)
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
tCtx := ktesting.Init(t)
|
||||
|
||||
frontProxyCA, err := newTestCAWithClient(
|
||||
pkix.Name{
|
||||
@@ -175,7 +173,7 @@ func testClientCA(t *testing.T, recreate bool) {
|
||||
clientCAFilename := ""
|
||||
frontProxyCAFilename := ""
|
||||
|
||||
kubeClient, kubeconfig, tearDownFn := framework.StartTestServer(ctx, t, framework.TestServerSetup{
|
||||
kubeClient, kubeconfig, tearDownFn := framework.StartTestServer(tCtx, t, framework.TestServerSetup{
|
||||
ModifyServerRunOptions: func(opts *options.ServerRunOptions) {
|
||||
opts.GenericServerRunOptions.MaxRequestBodyBytes = 1024 * 1024
|
||||
clientCAFilename = opts.Authentication.ClientCert.ClientCA
|
||||
@@ -305,7 +303,7 @@ func testClientCA(t *testing.T, recreate bool) {
|
||||
}
|
||||
|
||||
// Call an endpoint to make sure we are authenticated
|
||||
_, err = testClient.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
|
||||
_, err = testClient.CoreV1().Nodes().List(tCtx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -473,13 +471,11 @@ func TestServingCertRecreate(t *testing.T) {
|
||||
}
|
||||
|
||||
func testServingCert(t *testing.T, recreate bool) {
|
||||
_, ctx := ktesting.NewTestContext(t)
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
tCtx := ktesting.Init(t)
|
||||
|
||||
var servingCertPath string
|
||||
|
||||
_, kubeconfig, tearDownFn := framework.StartTestServer(ctx, t, framework.TestServerSetup{
|
||||
_, kubeconfig, tearDownFn := framework.StartTestServer(tCtx, t, framework.TestServerSetup{
|
||||
ModifyServerRunOptions: func(opts *options.ServerRunOptions) {
|
||||
opts.GenericServerRunOptions.MaxRequestBodyBytes = 1024 * 1024
|
||||
servingCertPath = opts.SecureServing.ServerCert.CertDirectory
|
||||
@@ -518,11 +514,9 @@ func testServingCert(t *testing.T, recreate bool) {
|
||||
func TestSNICert(t *testing.T) {
|
||||
var servingCertPath string
|
||||
|
||||
_, ctx := ktesting.NewTestContext(t)
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
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) {
|
||||
opts.GenericServerRunOptions.MaxRequestBodyBytes = 1024 * 1024
|
||||
servingCertPath = opts.SecureServing.ServerCert.CertDirectory
|
||||
|
Reference in New Issue
Block a user