Remove RunAnAPIServer from integration tests

This commit is contained in:
Wojciech Tyczyński
2022-07-25 12:18:44 +02:00
parent c633f7124d
commit 5b042f0bf4
8 changed files with 46 additions and 404 deletions

View File

@@ -635,7 +635,7 @@ func runWorkload(b *testing.B, tc *testCase, w *workload) []DataItem {
b.Fatalf("validate scheduler config file failed: %v", err)
}
}
finalFunc, podInformer, client, dynClient := mustSetupScheduler(cfg)
finalFunc, podInformer, client, dynClient := mustSetupScheduler(b, cfg)
b.Cleanup(finalFunc)
var mu sync.Mutex

View File

@@ -26,12 +26,12 @@ import (
"os"
"path"
"sort"
"testing"
"time"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/dynamic"
coreinformers "k8s.io/client-go/informers/core/v1"
@@ -41,6 +41,7 @@ import (
"k8s.io/component-base/metrics/testutil"
"k8s.io/klog/v2"
"k8s.io/kube-scheduler/config/v1beta2"
"k8s.io/kubernetes/cmd/kube-apiserver/app/options"
"k8s.io/kubernetes/pkg/scheduler/apis/config"
kubeschedulerscheme "k8s.io/kubernetes/pkg/scheduler/apis/config/scheme"
"k8s.io/kubernetes/test/integration/framework"
@@ -74,23 +75,26 @@ func newDefaultComponentConfig() (*config.KubeSchedulerConfiguration, error) {
// remove resources after finished.
// Notes on rate limiter:
// - client rate limit is set to 5000.
func mustSetupScheduler(config *config.KubeSchedulerConfiguration) (util.ShutdownFunc, coreinformers.PodInformer, clientset.Interface, dynamic.Interface) {
func mustSetupScheduler(b *testing.B, config *config.KubeSchedulerConfiguration) (util.ShutdownFunc, coreinformers.PodInformer, clientset.Interface, dynamic.Interface) {
// Run API server with minimimal logging by default. Can be raised with -v.
framework.MinVerbosity = 0
apiURL, apiShutdown := util.StartApiserver()
var err error
_, kubeConfig, tearDownFn := framework.StartTestServer(b, framework.TestServerSetup{
ModifyServerRunOptions: func(opts *options.ServerRunOptions) {
// Disable ServiceAccount admission plugin as we don't have serviceaccount controller running.
opts.Admission.GenericAdmission.DisablePlugins = []string{"ServiceAccount", "TaintNodesByCondition", "Priority"}
},
})
// TODO: client connection configuration, such as QPS or Burst is configurable in theory, this could be derived from the `config`, need to
// support this when there is any testcase that depends on such configuration.
cfg := &restclient.Config{
Host: apiURL,
ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}},
QPS: 5000.0,
Burst: 5000,
}
cfg := restclient.CopyConfig(kubeConfig)
cfg.QPS = 5000.0
cfg.Burst = 5000
// use default component config if config here is nil
if config == nil {
var err error
config, err = newDefaultComponentConfig()
if err != nil {
klog.Fatalf("Error creating default component config: %v", err)
@@ -105,13 +109,13 @@ func mustSetupScheduler(config *config.KubeSchedulerConfiguration) (util.Shutdow
_, podInformer, schedulerShutdown := util.StartScheduler(client, cfg, config)
fakePVControllerShutdown := util.StartFakePVController(client)
shutdownFunc := func() {
shutdownFn := func() {
fakePVControllerShutdown()
schedulerShutdown()
apiShutdown()
tearDownFn()
}
return shutdownFunc, podInformer, client, dynClient
return shutdownFn, podInformer, client, dynClient
}
// Returns the list of scheduled pods in the specified namespaces.