mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #102687 from mengjiao-liu/rename-master-to-controlplane
test/integration: Rename master to controlplane
This commit is contained in:
commit
51cbebab1f
@ -75,15 +75,15 @@ func setup(t *testing.T, groupVersions ...schema.GroupVersion) (*httptest.Server
|
|||||||
return setupWithResources(t, groupVersions, nil)
|
return setupWithResources(t, groupVersions, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupWithOptions(t *testing.T, opts *framework.MasterConfigOptions, groupVersions ...schema.GroupVersion) (*httptest.Server, clientset.Interface, framework.CloseFunc) {
|
func setupWithOptions(t *testing.T, opts *framework.ControlPlaneConfigOptions, groupVersions ...schema.GroupVersion) (*httptest.Server, clientset.Interface, framework.CloseFunc) {
|
||||||
return setupWithResourcesWithOptions(t, opts, groupVersions, nil)
|
return setupWithResourcesWithOptions(t, opts, groupVersions, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupWithResources(t *testing.T, groupVersions []schema.GroupVersion, resources []schema.GroupVersionResource) (*httptest.Server, clientset.Interface, framework.CloseFunc) {
|
func setupWithResources(t *testing.T, groupVersions []schema.GroupVersion, resources []schema.GroupVersionResource) (*httptest.Server, clientset.Interface, framework.CloseFunc) {
|
||||||
return setupWithResourcesWithOptions(t, &framework.MasterConfigOptions{}, groupVersions, resources)
|
return setupWithResourcesWithOptions(t, &framework.ControlPlaneConfigOptions{}, groupVersions, resources)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupWithResourcesWithOptions(t *testing.T, opts *framework.MasterConfigOptions, groupVersions []schema.GroupVersion, resources []schema.GroupVersionResource) (*httptest.Server, clientset.Interface, framework.CloseFunc) {
|
func setupWithResourcesWithOptions(t *testing.T, opts *framework.ControlPlaneConfigOptions, groupVersions []schema.GroupVersion, resources []schema.GroupVersionResource) (*httptest.Server, clientset.Interface, framework.CloseFunc) {
|
||||||
controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(opts)
|
controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(opts)
|
||||||
if len(groupVersions) > 0 || len(resources) > 0 {
|
if len(groupVersions) > 0 || len(resources) > 0 {
|
||||||
resourceConfig := controlplane.DefaultAPIResourceConfigSource()
|
resourceConfig := controlplane.DefaultAPIResourceConfigSource()
|
||||||
@ -224,12 +224,12 @@ func Test4xxStatusCodeInvalidPatch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCacheControl(t *testing.T) {
|
func TestCacheControl(t *testing.T) {
|
||||||
controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.MasterConfigOptions{})
|
controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{})
|
||||||
controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
|
controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
|
||||||
master, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
|
instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
|
||||||
defer closeFn()
|
defer closeFn()
|
||||||
|
|
||||||
rt, err := restclient.TransportFor(master.GenericAPIServer.LoopbackClientConfig)
|
rt, err := restclient.TransportFor(instanceConfig.GenericAPIServer.LoopbackClientConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -253,7 +253,7 @@ func TestCacheControl(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, path := range paths {
|
for _, path := range paths {
|
||||||
t.Run(path, func(t *testing.T) {
|
t.Run(path, func(t *testing.T) {
|
||||||
req, err := http.NewRequest("GET", master.GenericAPIServer.LoopbackClientConfig.Host+path, nil)
|
req, err := http.NewRequest("GET", instanceConfig.GenericAPIServer.LoopbackClientConfig.Host+path, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -331,7 +331,7 @@ func TestListOptions(t *testing.T) {
|
|||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.APIListChunking, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.APIListChunking, true)()
|
||||||
etcdOptions := framework.DefaultEtcdOptions()
|
etcdOptions := framework.DefaultEtcdOptions()
|
||||||
etcdOptions.EnableWatchCache = watchCacheEnabled
|
etcdOptions.EnableWatchCache = watchCacheEnabled
|
||||||
s, clientSet, closeFn := setupWithOptions(t, &framework.MasterConfigOptions{EtcdOptions: etcdOptions})
|
s, clientSet, closeFn := setupWithOptions(t, &framework.ControlPlaneConfigOptions{EtcdOptions: etcdOptions})
|
||||||
defer closeFn()
|
defer closeFn()
|
||||||
|
|
||||||
ns := framework.CreateTestingNamespace("list-options", s, t)
|
ns := framework.CreateTestingNamespace("list-options", s, t)
|
||||||
@ -563,7 +563,7 @@ func TestListResourceVersion0(t *testing.T) {
|
|||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.APIListChunking, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.APIListChunking, true)()
|
||||||
etcdOptions := framework.DefaultEtcdOptions()
|
etcdOptions := framework.DefaultEtcdOptions()
|
||||||
etcdOptions.EnableWatchCache = tc.watchCacheEnabled
|
etcdOptions.EnableWatchCache = tc.watchCacheEnabled
|
||||||
s, clientSet, closeFn := setupWithOptions(t, &framework.MasterConfigOptions{EtcdOptions: etcdOptions})
|
s, clientSet, closeFn := setupWithOptions(t, &framework.ControlPlaneConfigOptions{EtcdOptions: etcdOptions})
|
||||||
defer closeFn()
|
defer closeFn()
|
||||||
|
|
||||||
ns := framework.CreateTestingNamespace("list-paging", s, t)
|
ns := framework.CreateTestingNamespace("list-paging", s, t)
|
||||||
|
@ -50,7 +50,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func setup(t testing.TB, groupVersions ...schema.GroupVersion) (*httptest.Server, clientset.Interface, framework.CloseFunc) {
|
func setup(t testing.TB, groupVersions ...schema.GroupVersion) (*httptest.Server, clientset.Interface, framework.CloseFunc) {
|
||||||
opts := framework.MasterConfigOptions{EtcdOptions: framework.DefaultEtcdOptions()}
|
opts := framework.ControlPlaneConfigOptions{EtcdOptions: framework.DefaultEtcdOptions()}
|
||||||
opts.EtcdOptions.DefaultStorageMediaType = "application/vnd.kubernetes.protobuf"
|
opts.EtcdOptions.DefaultStorageMediaType = "application/vnd.kubernetes.protobuf"
|
||||||
controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&opts)
|
controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&opts)
|
||||||
if len(groupVersions) > 0 {
|
if len(groupVersions) > 0 {
|
||||||
@ -2819,14 +2819,14 @@ spec:
|
|||||||
|
|
||||||
func TestStopTrackingManagedFieldsOnFeatureDisabled(t *testing.T) {
|
func TestStopTrackingManagedFieldsOnFeatureDisabled(t *testing.T) {
|
||||||
sharedEtcd := framework.DefaultEtcdOptions()
|
sharedEtcd := framework.DefaultEtcdOptions()
|
||||||
controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.MasterConfigOptions{
|
controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&framework.ControlPlaneConfigOptions{
|
||||||
EtcdOptions: sharedEtcd,
|
EtcdOptions: sharedEtcd,
|
||||||
})
|
})
|
||||||
controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
|
controlPlaneConfig.GenericConfig.OpenAPIConfig = framework.DefaultOpenAPIConfig()
|
||||||
|
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.ServerSideApply, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.ServerSideApply, true)()
|
||||||
_, master, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
|
_, instanceConfig, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
|
||||||
client, err := clientset.NewForConfig(&restclient.Config{Host: master.URL, QPS: -1})
|
client, err := clientset.NewForConfig(&restclient.Config{Host: instanceConfig.URL, QPS: -1})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error in create clientset: %v", err)
|
t.Fatalf("Error in create clientset: %v", err)
|
||||||
}
|
}
|
||||||
@ -2878,8 +2878,8 @@ spec:
|
|||||||
// Restart server with server-side apply disabled
|
// Restart server with server-side apply disabled
|
||||||
closeFn()
|
closeFn()
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.ServerSideApply, false)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.ServerSideApply, false)()
|
||||||
_, master, closeFn = framework.RunAnAPIServer(controlPlaneConfig)
|
_, instanceConfig, closeFn = framework.RunAnAPIServer(controlPlaneConfig)
|
||||||
client, err = clientset.NewForConfig(&restclient.Config{Host: master.URL, QPS: -1})
|
client, err = clientset.NewForConfig(&restclient.Config{Host: instanceConfig.URL, QPS: -1})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error in create clientset: %v", err)
|
t.Fatalf("Error in create clientset: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func setup(t testing.TB, maxReadonlyRequestsInFlight, MaxMutatingRequestsInFlight int) (*httptest.Server, *rest.Config, framework.CloseFunc) {
|
func setup(t testing.TB, maxReadonlyRequestsInFlight, MaxMutatingRequestsInFlight int) (*httptest.Server, *rest.Config, framework.CloseFunc) {
|
||||||
opts := framework.MasterConfigOptions{EtcdOptions: framework.DefaultEtcdOptions()}
|
opts := framework.ControlPlaneConfigOptions{EtcdOptions: framework.DefaultEtcdOptions()}
|
||||||
opts.EtcdOptions.DefaultStorageMediaType = "application/vnd.kubernetes.protobuf"
|
opts.EtcdOptions.DefaultStorageMediaType = "application/vnd.kubernetes.protobuf"
|
||||||
controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&opts)
|
controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&opts)
|
||||||
resourceConfig := controlplane.DefaultAPIResourceConfigSource()
|
resourceConfig := controlplane.DefaultAPIResourceConfigSource()
|
||||||
|
@ -54,7 +54,7 @@ func multiEtcdSetup(t testing.TB) (clientset.Interface, framework.CloseFunc) {
|
|||||||
etcdOptions.EtcdServersOverrides = []string{fmt.Sprintf("/events#%s", etcd1URL)}
|
etcdOptions.EtcdServersOverrides = []string{fmt.Sprintf("/events#%s", etcd1URL)}
|
||||||
etcdOptions.EnableWatchCache = true
|
etcdOptions.EnableWatchCache = true
|
||||||
|
|
||||||
opts := framework.MasterConfigOptions{EtcdOptions: etcdOptions}
|
opts := framework.ControlPlaneConfigOptions{EtcdOptions: etcdOptions}
|
||||||
controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&opts)
|
controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&opts)
|
||||||
// Switch off endpoints reconciler to avoid unnecessary operations.
|
// Switch off endpoints reconciler to avoid unnecessary operations.
|
||||||
controlPlaneConfig.ExtraConfig.EndpointReconcilerType = reconcilers.NoneEndpointReconcilerType
|
controlPlaneConfig.ExtraConfig.EndpointReconcilerType = reconcilers.NoneEndpointReconcilerType
|
||||||
|
@ -119,16 +119,16 @@ func TestServiceAccountTokenCreate(t *testing.T) {
|
|||||||
controlPlaneConfig.ExtraConfig.ServiceAccountJWKSURI = ""
|
controlPlaneConfig.ExtraConfig.ServiceAccountJWKSURI = ""
|
||||||
controlPlaneConfig.ExtraConfig.ServiceAccountPublicKeys = []interface{}{&pk}
|
controlPlaneConfig.ExtraConfig.ServiceAccountPublicKeys = []interface{}{&pk}
|
||||||
|
|
||||||
master, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
|
instanceConfig, _, closeFn := framework.RunAnAPIServer(controlPlaneConfig)
|
||||||
defer closeFn()
|
defer closeFn()
|
||||||
|
|
||||||
cs, err := clientset.NewForConfig(master.GenericAPIServer.LoopbackClientConfig)
|
cs, err := clientset.NewForConfig(instanceConfig.GenericAPIServer.LoopbackClientConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
*gcs = *cs
|
*gcs = *cs
|
||||||
|
|
||||||
rc, err := rest.UnversionedRESTClientFor(master.GenericAPIServer.LoopbackClientConfig)
|
rc, err := rest.UnversionedRESTClientFor(instanceConfig.GenericAPIServer.LoopbackClientConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -59,10 +59,10 @@ import (
|
|||||||
kubeletclient "k8s.io/kubernetes/pkg/kubelet/client"
|
kubeletclient "k8s.io/kubernetes/pkg/kubelet/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config is a struct of configuration directives for NewMasterComponents.
|
// Config is a struct of configuration directives for NewControlPlaneComponents.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// If nil, a default is used, partially filled configs will not get populated.
|
// If nil, a default is used, partially filled configs will not get populated.
|
||||||
MasterConfig *controlplane.Config
|
InstanceConfig *controlplane.Config
|
||||||
StartReplicationManager bool
|
StartReplicationManager bool
|
||||||
// Client throttling qps
|
// Client throttling qps
|
||||||
QPS float32
|
QPS float32
|
||||||
@ -123,7 +123,7 @@ func DefaultOpenAPIConfig() *openapicommon.Config {
|
|||||||
return openAPIConfig
|
return openAPIConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// startAPIServerOrDie starts a kubernetes master and an httpserver to handle api requests
|
// startAPIServerOrDie starts a kubernetes API server and an httpserver to handle api requests
|
||||||
func startAPIServerOrDie(controlPlaneConfig *controlplane.Config, incomingServer *httptest.Server, apiServerReceiver APIServerReceiver) (*controlplane.Instance, *httptest.Server, CloseFunc) {
|
func startAPIServerOrDie(controlPlaneConfig *controlplane.Config, incomingServer *httptest.Server, apiServerReceiver APIServerReceiver) (*controlplane.Instance, *httptest.Server, CloseFunc) {
|
||||||
var m *controlplane.Instance
|
var m *controlplane.Instance
|
||||||
var s *httptest.Server
|
var s *httptest.Server
|
||||||
@ -210,9 +210,9 @@ func startAPIServerOrDie(controlPlaneConfig *controlplane.Config, incomingServer
|
|||||||
m, err = controlPlaneConfig.Complete().New(genericapiserver.NewEmptyDelegate())
|
m, err = controlPlaneConfig.Complete().New(genericapiserver.NewEmptyDelegate())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// We log the error first so that even if closeFn crashes, the error is shown
|
// We log the error first so that even if closeFn crashes, the error is shown
|
||||||
klog.Errorf("error in bringing up the master: %v", err)
|
klog.Errorf("error in bringing up the apiserver: %v", err)
|
||||||
closeFn()
|
closeFn()
|
||||||
klog.Fatalf("error in bringing up the master: %v", err)
|
klog.Fatalf("error in bringing up the apiserver: %v", err)
|
||||||
}
|
}
|
||||||
if apiServerReceiver != nil {
|
if apiServerReceiver != nil {
|
||||||
apiServerReceiver.SetAPIServer(m)
|
apiServerReceiver.SetAPIServer(m)
|
||||||
@ -251,14 +251,14 @@ func startAPIServerOrDie(controlPlaneConfig *controlplane.Config, incomingServer
|
|||||||
return m, s, closeFn
|
return m, s, closeFn
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewIntegrationTestControlPlaneConfig returns the master config appropriate for most integration tests.
|
// NewIntegrationTestControlPlaneConfig returns the control plane config appropriate for most integration tests.
|
||||||
func NewIntegrationTestControlPlaneConfig() *controlplane.Config {
|
func NewIntegrationTestControlPlaneConfig() *controlplane.Config {
|
||||||
return NewIntegrationTestControlPlaneConfigWithOptions(&MasterConfigOptions{})
|
return NewIntegrationTestControlPlaneConfigWithOptions(&ControlPlaneConfigOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewIntegrationTestControlPlaneConfigWithOptions returns the control plane config appropriate for most integration tests
|
// NewIntegrationTestControlPlaneConfigWithOptions returns the control plane config appropriate for most integration tests
|
||||||
// configured with the provided options.
|
// configured with the provided options.
|
||||||
func NewIntegrationTestControlPlaneConfigWithOptions(opts *MasterConfigOptions) *controlplane.Config {
|
func NewIntegrationTestControlPlaneConfigWithOptions(opts *ControlPlaneConfigOptions) *controlplane.Config {
|
||||||
controlPlaneConfig := NewControlPlaneConfigWithOptions(opts)
|
controlPlaneConfig := NewControlPlaneConfigWithOptions(opts)
|
||||||
controlPlaneConfig.GenericConfig.PublicAddress = net.ParseIP("192.168.10.4")
|
controlPlaneConfig.GenericConfig.PublicAddress = net.ParseIP("192.168.10.4")
|
||||||
controlPlaneConfig.ExtraConfig.APIResourceConfigSource = controlplane.DefaultAPIResourceConfigSource()
|
controlPlaneConfig.ExtraConfig.APIResourceConfigSource = controlplane.DefaultAPIResourceConfigSource()
|
||||||
@ -269,8 +269,8 @@ func NewIntegrationTestControlPlaneConfigWithOptions(opts *MasterConfigOptions)
|
|||||||
return controlPlaneConfig
|
return controlPlaneConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// MasterConfigOptions are the configurable options for a new integration test master config.
|
// ControlPlaneConfigOptions are the configurable options for a new integration test control plane config.
|
||||||
type MasterConfigOptions struct {
|
type ControlPlaneConfigOptions struct {
|
||||||
EtcdOptions *options.EtcdOptions
|
EtcdOptions *options.EtcdOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,11 +286,11 @@ func DefaultEtcdOptions() *options.EtcdOptions {
|
|||||||
|
|
||||||
// NewControlPlaneConfig returns a basic control plane config.
|
// NewControlPlaneConfig returns a basic control plane config.
|
||||||
func NewControlPlaneConfig() *controlplane.Config {
|
func NewControlPlaneConfig() *controlplane.Config {
|
||||||
return NewControlPlaneConfigWithOptions(&MasterConfigOptions{})
|
return NewControlPlaneConfigWithOptions(&ControlPlaneConfigOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewControlPlaneConfigWithOptions returns a basic control plane config configured with the provided options.
|
// NewControlPlaneConfigWithOptions returns a basic control plane config configured with the provided options.
|
||||||
func NewControlPlaneConfigWithOptions(opts *MasterConfigOptions) *controlplane.Config {
|
func NewControlPlaneConfigWithOptions(opts *ControlPlaneConfigOptions) *controlplane.Config {
|
||||||
etcdOptions := DefaultEtcdOptions()
|
etcdOptions := DefaultEtcdOptions()
|
||||||
if opts.EtcdOptions != nil {
|
if opts.EtcdOptions != nil {
|
||||||
etcdOptions = opts.EtcdOptions
|
etcdOptions = opts.EtcdOptions
|
||||||
@ -338,7 +338,7 @@ func NewControlPlaneConfigWithOptions(opts *MasterConfigOptions) *controlplane.C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CloseFunc can be called to cleanup the master
|
// CloseFunc can be called to cleanup the API server
|
||||||
type CloseFunc func()
|
type CloseFunc func()
|
||||||
|
|
||||||
// RunAnAPIServer starts a API server with the provided config.
|
// RunAnAPIServer starts a API server with the provided config.
|
||||||
|
Loading…
Reference in New Issue
Block a user