mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Populate OpenAPI in all integration tests
This commit is contained in:
		@@ -93,7 +93,6 @@ func setupWithResourcesWithOptions(t testing.TB, opts *framework.ControlPlaneCon
 | 
				
			|||||||
		resourceConfig.EnableResources(resources...)
 | 
							resourceConfig.EnableResources(resources...)
 | 
				
			||||||
		controlPlaneConfig.ExtraConfig.APIResourceConfigSource = resourceConfig
 | 
							controlPlaneConfig.ExtraConfig.APIResourceConfigSource = resourceConfig
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
 | 
					 | 
				
			||||||
	_, s, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
						_, s, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	clientSet, err := clientset.NewForConfig(&restclient.Config{Host: s.URL, QPS: -1})
 | 
						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) {
 | 
					func TestCacheControl(t *testing.T) {
 | 
				
			||||||
	controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{})
 | 
						controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{})
 | 
				
			||||||
	controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
 | 
					 | 
				
			||||||
	instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
						instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
				
			||||||
	defer closeFn()
 | 
						defer closeFn()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -274,7 +272,6 @@ func TestCacheControl(t *testing.T) {
 | 
				
			|||||||
// Tests that the apiserver returns HSTS headers as expected.
 | 
					// Tests that the apiserver returns HSTS headers as expected.
 | 
				
			||||||
func TestHSTS(t *testing.T) {
 | 
					func TestHSTS(t *testing.T) {
 | 
				
			||||||
	controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{})
 | 
						controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{})
 | 
				
			||||||
	controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
 | 
					 | 
				
			||||||
	controlPlaneConfig.GenericConfig.HSTSDirectives = []string{"max-age=31536000", "includeSubDomains"}
 | 
						controlPlaneConfig.GenericConfig.HSTSDirectives = []string{"max-age=31536000", "includeSubDomains"}
 | 
				
			||||||
	instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
						instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
				
			||||||
	defer closeFn()
 | 
						defer closeFn()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,7 +58,6 @@ func setup(t testing.TB, groupVersions ...schema.GroupVersion) (*httptest.Server
 | 
				
			|||||||
		resourceConfig.EnableVersions(groupVersions...)
 | 
							resourceConfig.EnableVersions(groupVersions...)
 | 
				
			||||||
		controlPlaneConfig.ExtraConfig.APIResourceConfigSource = resourceConfig
 | 
							controlPlaneConfig.ExtraConfig.APIResourceConfigSource = resourceConfig
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
 | 
					 | 
				
			||||||
	_, s, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
						_, s, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	clientSet, err := clientset.NewForConfig(&restclient.Config{Host: s.URL, QPS: -1})
 | 
						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{
 | 
						controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{
 | 
				
			||||||
		EtcdOptions: sharedEtcd,
 | 
							EtcdOptions: sharedEtcd,
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.ServerSideApply, true)()
 | 
						defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.ServerSideApply, true)()
 | 
				
			||||||
	_, instanceConfig, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
						_, instanceConfig, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,7 +60,6 @@ func setup(t testing.TB, maxReadonlyRequestsInFlight, MaxMutatingRequestsInFligh
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
	controlPlaneConfig.GenericConfig.MaxRequestsInFlight = maxReadonlyRequestsInFlight
 | 
						controlPlaneConfig.GenericConfig.MaxRequestsInFlight = maxReadonlyRequestsInFlight
 | 
				
			||||||
	controlPlaneConfig.GenericConfig.MaxMutatingRequestsInFlight = MaxMutatingRequestsInFlight
 | 
						controlPlaneConfig.GenericConfig.MaxMutatingRequestsInFlight = MaxMutatingRequestsInFlight
 | 
				
			||||||
	controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
 | 
					 | 
				
			||||||
	controlPlaneConfig.ExtraConfig.APIResourceConfigSource = resourceConfig
 | 
						controlPlaneConfig.ExtraConfig.APIResourceConfigSource = resourceConfig
 | 
				
			||||||
	_, s, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
						_, s, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,7 +56,6 @@ func TestEnablingOpenAPIEnumTypes(t *testing.T) {
 | 
				
			|||||||
			defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.OpenAPIEnums, tc.featureEnabled)()
 | 
								defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.OpenAPIEnums, tc.featureEnabled)()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{})
 | 
								controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{})
 | 
				
			||||||
			controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
 | 
					 | 
				
			||||||
			controlPlaneConfig.GenericConfig.OpenAPIConfig.GetDefinitions = openapi.GetOpenAPIDefinitionsWithoutDisabledFeatures(func(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
 | 
								controlPlaneConfig.GenericConfig.OpenAPIConfig.GetDefinitions = openapi.GetOpenAPIDefinitionsWithoutDisabledFeatures(func(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
 | 
				
			||||||
				defs := generated.GetOpenAPIDefinitions(ref)
 | 
									defs := generated.GetOpenAPIDefinitions(ref)
 | 
				
			||||||
				def := defs[typeToAddEnum]
 | 
									def := defs[typeToAddEnum]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,6 @@ import (
 | 
				
			|||||||
func TestOpenAPIV3SpecRoundTrip(t *testing.T) {
 | 
					func TestOpenAPIV3SpecRoundTrip(t *testing.T) {
 | 
				
			||||||
	defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.OpenAPIV3, true)()
 | 
						defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.OpenAPIV3, true)()
 | 
				
			||||||
	controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{})
 | 
						controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{})
 | 
				
			||||||
	controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
 | 
					 | 
				
			||||||
	instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
						instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
				
			||||||
	defer closeFn()
 | 
						defer closeFn()
 | 
				
			||||||
	paths := []string{
 | 
						paths := []string{
 | 
				
			||||||
@@ -200,7 +199,6 @@ func TestOpenAPIV3ProtoRoundtrip(t *testing.T) {
 | 
				
			|||||||
	t.Skip("Skipping OpenAPI V3 Proto roundtrip test")
 | 
						t.Skip("Skipping OpenAPI V3 Proto roundtrip test")
 | 
				
			||||||
	defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.OpenAPIV3, true)()
 | 
						defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.OpenAPIV3, true)()
 | 
				
			||||||
	controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{})
 | 
						controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{})
 | 
				
			||||||
	controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
 | 
					 | 
				
			||||||
	instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
						instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
				
			||||||
	defer closeFn()
 | 
						defer closeFn()
 | 
				
			||||||
	rt, err := restclient.TransportFor(instanceConfig.GenericAPIServer.LoopbackClientConfig)
 | 
						rt, err := restclient.TransportFor(instanceConfig.GenericAPIServer.LoopbackClientConfig)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -535,7 +535,6 @@ func TestRBAC(t *testing.T) {
 | 
				
			|||||||
			"limitrange-patcher":               {Name: "limitrange-patcher"},
 | 
								"limitrange-patcher":               {Name: "limitrange-patcher"},
 | 
				
			||||||
			"user-with-no-permissions":         {Name: "user-with-no-permissions"},
 | 
								"user-with-no-permissions":         {Name: "user-with-no-permissions"},
 | 
				
			||||||
		})))
 | 
							})))
 | 
				
			||||||
		controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
 | 
					 | 
				
			||||||
		_, s, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
							_, s, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
 | 
				
			||||||
		defer closeFn()
 | 
							defer closeFn()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -285,6 +285,11 @@ func NewIntegrationTestControlPlaneConfigWithOptions(opts *ControlPlaneConfigOpt
 | 
				
			|||||||
	// TODO: get rid of these tests or port them to secure serving
 | 
						// TODO: get rid of these tests or port them to secure serving
 | 
				
			||||||
	controlPlaneConfig.GenericConfig.SecureServing = &genericapiserver.SecureServingInfo{Listener: fakeLocalhost443Listener{}}
 | 
						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
 | 
						return controlPlaneConfig
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user