From eb8f6fe0f94e330100269a64ea2baac6df626d05 Mon Sep 17 00:00:00 2001 From: Jefftree Date: Tue, 25 Jan 2022 12:08:52 -0800 Subject: [PATCH] Populate OpenAPI in all integration tests --- test/integration/apiserver/apiserver_test.go | 3 --- test/integration/apiserver/apply/apply_test.go | 2 -- test/integration/apiserver/flowcontrol/concurrency_test.go | 1 - test/integration/apiserver/openapi_test.go | 1 - test/integration/apiserver/openapiv3_test.go | 2 -- test/integration/auth/rbac_test.go | 1 - test/integration/framework/controlplane_utils.go | 5 +++++ 7 files changed, 5 insertions(+), 10 deletions(-) diff --git a/test/integration/apiserver/apiserver_test.go b/test/integration/apiserver/apiserver_test.go index b1ba28d06d5..e171f437ebc 100644 --- a/test/integration/apiserver/apiserver_test.go +++ b/test/integration/apiserver/apiserver_test.go @@ -93,7 +93,6 @@ func setupWithResourcesWithOptions(t testing.TB, opts *framework.ControlPlaneCon resourceConfig.EnableResources(resources...) controlPlaneConfig.ExtraConfig.APIResourceConfigSource = resourceConfig } - controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig() _, s, closeFn := framework.RunAnAPIServer(controlPlaneConfig) clientSet, err := clientset.NewForConfig(&restclient.Config{Host: s.URL, QPS: -1}) @@ -227,7 +226,6 @@ func Test4xxStatusCodeInvalidPatch(t *testing.T) { func TestCacheControl(t *testing.T) { controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{}) - controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig() instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig) defer closeFn() @@ -274,7 +272,6 @@ func TestCacheControl(t *testing.T) { // Tests that the apiserver returns HSTS headers as expected. func TestHSTS(t *testing.T) { controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{}) - controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig() controlPlaneConfig.GenericConfig.HSTSDirectives = []string{"max-age=31536000", "includeSubDomains"} instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig) defer closeFn() diff --git a/test/integration/apiserver/apply/apply_test.go b/test/integration/apiserver/apply/apply_test.go index aec9e9ea138..412ce1cbe0a 100644 --- a/test/integration/apiserver/apply/apply_test.go +++ b/test/integration/apiserver/apply/apply_test.go @@ -58,7 +58,6 @@ func setup(t testing.TB, groupVersions ...schema.GroupVersion) (*httptest.Server resourceConfig.EnableVersions(groupVersions...) controlPlaneConfig.ExtraConfig.APIResourceConfigSource = resourceConfig } - controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig() _, s, closeFn := framework.RunAnAPIServer(controlPlaneConfig) clientSet, err := clientset.NewForConfig(&restclient.Config{Host: s.URL, QPS: -1}) @@ -2822,7 +2821,6 @@ func TestStopTrackingManagedFieldsOnFeatureDisabled(t *testing.T) { controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{ EtcdOptions: sharedEtcd, }) - controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig() defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.ServerSideApply, true)() _, instanceConfig, closeFn := framework.RunAnAPIServer(controlPlaneConfig) diff --git a/test/integration/apiserver/flowcontrol/concurrency_test.go b/test/integration/apiserver/flowcontrol/concurrency_test.go index 7c5a11be9d4..2f9b297239c 100644 --- a/test/integration/apiserver/flowcontrol/concurrency_test.go +++ b/test/integration/apiserver/flowcontrol/concurrency_test.go @@ -60,7 +60,6 @@ func setup(t testing.TB, maxReadonlyRequestsInFlight, MaxMutatingRequestsInFligh }) controlPlaneConfig.GenericConfig.MaxRequestsInFlight = maxReadonlyRequestsInFlight controlPlaneConfig.GenericConfig.MaxMutatingRequestsInFlight = MaxMutatingRequestsInFlight - controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig() controlPlaneConfig.ExtraConfig.APIResourceConfigSource = resourceConfig _, s, closeFn := framework.RunAnAPIServer(controlPlaneConfig) diff --git a/test/integration/apiserver/openapi_test.go b/test/integration/apiserver/openapi_test.go index 6d320f42779..a6f89e92283 100644 --- a/test/integration/apiserver/openapi_test.go +++ b/test/integration/apiserver/openapi_test.go @@ -56,7 +56,6 @@ func TestEnablingOpenAPIEnumTypes(t *testing.T) { defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.OpenAPIEnums, tc.featureEnabled)() controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{}) - controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig() controlPlaneConfig.GenericConfig.OpenAPIConfig.GetDefinitions = openapi.GetOpenAPIDefinitionsWithoutDisabledFeatures(func(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { defs := generated.GetOpenAPIDefinitions(ref) def := defs[typeToAddEnum] diff --git a/test/integration/apiserver/openapiv3_test.go b/test/integration/apiserver/openapiv3_test.go index 105da645963..4a621b39c08 100644 --- a/test/integration/apiserver/openapiv3_test.go +++ b/test/integration/apiserver/openapiv3_test.go @@ -46,7 +46,6 @@ import ( func TestOpenAPIV3SpecRoundTrip(t *testing.T) { defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.OpenAPIV3, true)() controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{}) - controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig() instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig) defer closeFn() paths := []string{ @@ -200,7 +199,6 @@ func TestOpenAPIV3ProtoRoundtrip(t *testing.T) { t.Skip("Skipping OpenAPI V3 Proto roundtrip test") defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.OpenAPIV3, true)() controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{}) - controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig() instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig) defer closeFn() rt, err := restclient.TransportFor(instanceConfig.GenericAPIServer.LoopbackClientConfig) diff --git a/test/integration/auth/rbac_test.go b/test/integration/auth/rbac_test.go index 029873d9f78..b158f569819 100644 --- a/test/integration/auth/rbac_test.go +++ b/test/integration/auth/rbac_test.go @@ -535,7 +535,6 @@ func TestRBAC(t *testing.T) { "limitrange-patcher": {Name: "limitrange-patcher"}, "user-with-no-permissions": {Name: "user-with-no-permissions"}, }))) - controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig() _, s, closeFn := framework.RunAnAPIServer(controlPlaneConfig) defer closeFn() diff --git a/test/integration/framework/controlplane_utils.go b/test/integration/framework/controlplane_utils.go index 9513a9fa4e1..8b1421f8f12 100644 --- a/test/integration/framework/controlplane_utils.go +++ b/test/integration/framework/controlplane_utils.go @@ -285,6 +285,11 @@ func NewIntegrationTestControlPlaneConfigWithOptions(opts *ControlPlaneConfigOpt // TODO: get rid of these tests or port them to secure serving controlPlaneConfig.GenericConfig.SecureServing = &genericapiserver.SecureServingInfo{Listener: fakeLocalhost443Listener{}} + // Enable OpenAPI and Server Side Apply in integration tests + if controlPlaneConfig.GenericConfig.OpenAPIConfig == nil { + controlPlaneConfig.GenericConfig.OpenAPIConfig = DefaultOpenAPIConfig() + } + return controlPlaneConfig }