Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YUNIKORN-2845] Remove SchedulerConf.TestMode #923

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions pkg/cache/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"github.com/apache/yunikorn-k8shim/pkg/common/constants"
"github.com/apache/yunikorn-k8shim/pkg/common/events"
"github.com/apache/yunikorn-k8shim/pkg/common/utils"
"github.com/apache/yunikorn-k8shim/pkg/conf"
"github.com/apache/yunikorn-k8shim/pkg/dispatcher"
"github.com/apache/yunikorn-k8shim/pkg/locking"
"github.com/apache/yunikorn-scheduler-interface/lib/go/api"
Expand Down Expand Up @@ -132,8 +131,6 @@ func TestFailApplication(t *testing.T) {
lock: &locking.RWMutex{},
}
ms := &mockSchedulerAPI{}
// set test mode
conf.GetSchedulerConf().SetTestMode(true)
// set Recorder to mocked type
mr := events.NewMockedRecorder()
mr.OnEventf = func() {
Expand Down Expand Up @@ -228,8 +225,6 @@ func TestSetUnallocatedPodsToFailedWhenFailApplication(t *testing.T) {
context.apiProvider.GetAPIs().KubeClient = mockClient

ms := &mockSchedulerAPI{}
// set test mode
conf.GetSchedulerConf().SetTestMode(true)
// set Recorder to mocked type
mr := events.NewMockedRecorder()
events.SetRecorder(mr)
Expand Down Expand Up @@ -336,8 +331,6 @@ func TestSetUnallocatedPodsToFailedWhenRejectApplication(t *testing.T) {
defer mgr.Stop()

ms := &mockSchedulerAPI{}
// set test mode
conf.GetSchedulerConf().SetTestMode(true)
// set Recorder to mocked type
mr := events.NewMockedRecorder()
events.SetRecorder(mr)
Expand Down
7 changes: 0 additions & 7 deletions pkg/cache/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import (
"github.com/apache/yunikorn-k8shim/pkg/common/events"
"github.com/apache/yunikorn-k8shim/pkg/common/test"
"github.com/apache/yunikorn-k8shim/pkg/common/utils"
"github.com/apache/yunikorn-k8shim/pkg/conf"
"github.com/apache/yunikorn-k8shim/pkg/dispatcher"
"github.com/apache/yunikorn-k8shim/pkg/log"
siCommon "github.com/apache/yunikorn-scheduler-interface/lib/go/common"
Expand Down Expand Up @@ -103,7 +102,6 @@ func initContextForTest() *Context {
}

func initContextAndAPIProviderForTest() (*Context, *client.MockedAPIProvider) {
conf.GetSchedulerConf().SetTestMode(true)
apis := client.NewMockedAPIProvider(false)
context := NewContext(apis)
return context, apis
Expand Down Expand Up @@ -1160,7 +1158,6 @@ func TestGetTask(t *testing.T) {
}

func TestNodeEventFailsPublishingWithoutNode(t *testing.T) {
conf.GetSchedulerConf().SetTestMode(true)
recorder, ok := events.GetRecorder().(*k8sEvents.FakeRecorder)
if !ok {
t.Fatal("the EventRecorder is expected to be of type FakeRecorder")
Expand Down Expand Up @@ -1189,7 +1186,6 @@ func TestNodeEventFailsPublishingWithoutNode(t *testing.T) {
}

func TestNodeEventPublishedCorrectly(t *testing.T) {
conf.GetSchedulerConf().SetTestMode(true)
recorder, ok := events.GetRecorder().(*k8sEvents.FakeRecorder)
if !ok {
t.Fatal("the EventRecorder is expected to be of type FakeRecorder")
Expand Down Expand Up @@ -1250,7 +1246,6 @@ func TestNodeEventPublishedCorrectly(t *testing.T) {
}

func TestFilteredEventsNotPublished(t *testing.T) {
conf.GetSchedulerConf().SetTestMode(true)
recorder, ok := events.GetRecorder().(*k8sEvents.FakeRecorder)
if !ok {
t.Fatal("the EventRecorder is expected to be of type FakeRecorder")
Expand Down Expand Up @@ -1335,7 +1330,6 @@ func TestFilteredEventsNotPublished(t *testing.T) {
}

func TestPublishEventsWithNotExistingAsk(t *testing.T) {
conf.GetSchedulerConf().SetTestMode(true)
recorder, ok := events.GetRecorder().(*k8sEvents.FakeRecorder)
if !ok {
t.Fatal("the EventRecorder is expected to be of type FakeRecorder")
Expand Down Expand Up @@ -1376,7 +1370,6 @@ func TestPublishEventsWithNotExistingAsk(t *testing.T) {
}

func TestPublishEventsCorrectly(t *testing.T) {
conf.GetSchedulerConf().SetTestMode(true)
recorder, ok := events.GetRecorder().(*k8sEvents.FakeRecorder)
if !ok {
t.Fatal("the EventRecorder is expected to be of type FakeRecorder")
Expand Down
2 changes: 0 additions & 2 deletions pkg/cache/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ func TestGetTaskMetadata(t *testing.T) {
}

func TestGetAppMetadata(t *testing.T) { //nolint:funlen
conf.GetSchedulerConf().SetTestMode(true)

defer utils.SetPluginMode(false)
defer func() { conf.GetSchedulerConf().GenerateUniqueAppIds = false }()
utils.SetPluginMode(false)
Expand Down
3 changes: 0 additions & 3 deletions pkg/cache/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/apache/yunikorn-k8shim/pkg/common/constants"
"github.com/apache/yunikorn-k8shim/pkg/common/events"
"github.com/apache/yunikorn-k8shim/pkg/common/utils"
"github.com/apache/yunikorn-k8shim/pkg/conf"
"github.com/apache/yunikorn-k8shim/pkg/locking"

"github.com/apache/yunikorn-scheduler-interface/lib/go/si"
Expand Down Expand Up @@ -521,7 +520,6 @@ func TestHandleSubmitTaskEvent(t *testing.T) {
time: int64(0),
lock: &locking.RWMutex{},
}
conf.GetSchedulerConf().SetTestMode(true)
mr := events.NewMockedRecorder()
mr.OnEventf = func() {
rt.lock.Lock()
Expand Down Expand Up @@ -621,7 +619,6 @@ func TestSimultaneousTaskCompleteAndAllocate(t *testing.T) {
mockedAPIProvider, ok := mockedContext.apiProvider.(*client.MockedAPIProvider)
assert.Equal(t, ok, true)

conf.GetSchedulerConf().SetTestMode(true)
resources := make(map[v1.ResourceName]resource.Quantity)
containers := make([]v1.Container, 0)
containers = append(containers, v1.Container{
Expand Down
15 changes: 0 additions & 15 deletions pkg/conf/schedulerconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ type SchedulerConf struct {
Interval time.Duration `json:"schedulingIntervalSecond"`
KubeConfig string `json:"absoluteKubeConfigFilePath"`
VolumeBindTimeout time.Duration `json:"volumeBindTimeout"`
TestMode bool `json:"testMode"`
EventChannelCapacity int `json:"eventChannelCapacity"`
DispatchTimeout time.Duration `json:"dispatchTimeout"`
KubeQPS int `json:"kubeQPS"`
Expand Down Expand Up @@ -145,7 +144,6 @@ func (conf *SchedulerConf) Clone() *SchedulerConf {
Interval: conf.Interval,
KubeConfig: conf.KubeConfig,
VolumeBindTimeout: conf.VolumeBindTimeout,
TestMode: conf.TestMode,
EventChannelCapacity: conf.EventChannelCapacity,
DispatchTimeout: conf.DispatchTimeout,
KubeQPS: conf.KubeQPS,
Expand Down Expand Up @@ -257,18 +255,6 @@ func SetSchedulerConf(conf *SchedulerConf) {
confHolder.Store(conf)
}

func (conf *SchedulerConf) SetTestMode(testMode bool) {
conf.Lock()
defer conf.Unlock()
conf.TestMode = testMode
}

func (conf *SchedulerConf) IsTestMode() bool {
conf.RLock()
defer conf.RUnlock()
return conf.TestMode
}

func (conf *SchedulerConf) IsConfigReloadable() bool {
conf.RLock()
defer conf.RUnlock()
Expand Down Expand Up @@ -321,7 +307,6 @@ func CreateDefaultConfig() *SchedulerConf {
Interval: DefaultSchedulingInterval,
KubeConfig: GetDefaultKubeConfigPath(),
VolumeBindTimeout: DefaultVolumeBindTimeout,
TestMode: false,
EventChannelCapacity: DefaultEventChannelCapacity,
DispatchTimeout: DefaultDispatchTimeout,
KubeQPS: DefaultKubeQPS,
Expand Down
5 changes: 0 additions & 5 deletions pkg/plugin/predicates/predicate_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
"k8s.io/kubernetes/pkg/util/taints"

"github.com/apache/yunikorn-k8shim/pkg/client"
"github.com/apache/yunikorn-k8shim/pkg/conf"
"github.com/apache/yunikorn-k8shim/pkg/log"
"github.com/apache/yunikorn-k8shim/pkg/plugin/support"
)
Expand All @@ -56,7 +55,6 @@ var (
)

func TestPreemptionPredicatesEmpty(t *testing.T) {
conf.GetSchedulerConf().SetTestMode(true)
clientSet := clientSet()
informerFactory := informerFactory(clientSet)
lister := lister()
Expand All @@ -74,7 +72,6 @@ func TestPreemptionPredicatesEmpty(t *testing.T) {
}

func TestPreemptionPredicates(t *testing.T) {
conf.GetSchedulerConf().SetTestMode(true)
clientSet := clientSet()
informerFactory := informerFactory(clientSet)
lister := lister()
Expand Down Expand Up @@ -127,7 +124,6 @@ func TestPreemptionPredicates(t *testing.T) {
}

func TestEventsToRegister(t *testing.T) {
conf.GetSchedulerConf().SetTestMode(true)
clientSet := clientSet()
informerFactory := informerFactory(clientSet)
lister := lister()
Expand All @@ -154,7 +150,6 @@ func TestEventsToRegister(t *testing.T) {
}

func TestPodFitsHost(t *testing.T) {
conf.GetSchedulerConf().SetTestMode(true)
clientSet := clientSet()
informerFactory := informerFactory(clientSet)
lister := lister()
Expand Down
1 change: 0 additions & 1 deletion pkg/shim/scheduler_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ type MockScheduler struct {
}

func (fc *MockScheduler) init() {
conf.GetSchedulerConf().SetTestMode(true)
fc.stopChan = make(chan struct{})
serviceContext := entrypoint.StartAllServices()
fc.rmProxy = serviceContext.RMProxy
Expand Down
Loading