diff --git a/pkg/scheduler/plugins/elasticquota/plugin.go b/pkg/scheduler/plugins/elasticquota/plugin.go index 1456b75a8..ed0a67da7 100644 --- a/pkg/scheduler/plugins/elasticquota/plugin.go +++ b/pkg/scheduler/plugins/elasticquota/plugin.go @@ -64,6 +64,7 @@ type PostFilterState struct { func (p *PostFilterState) Clone() framework.StateData { return &PostFilterState{ + skip: p.skip, quotaInfo: p.quotaInfo, used: p.used.DeepCopy(), nonPreemptibleUsed: p.nonPreemptibleUsed.DeepCopy(), diff --git a/pkg/scheduler/plugins/elasticquota/plugin_test.go b/pkg/scheduler/plugins/elasticquota/plugin_test.go index e3c14d254..0855cabb4 100644 --- a/pkg/scheduler/plugins/elasticquota/plugin_test.go +++ b/pkg/scheduler/plugins/elasticquota/plugin_test.go @@ -1333,3 +1333,33 @@ func defaultCreatePod(name string, priority int32, cpu, mem int64) *corev1.Pod { pod.Spec.NodeName = "test-node" return pod } + +func TestPostFilterState(t *testing.T) { + t.Run("test", func(t *testing.T) { + testCycleState := framework.NewCycleState() + p := &Plugin{ + pluginArgs: &config.ElasticQuotaArgs{ + EnableRuntimeQuota: false, + }, + } + + p.skipPostFilterState(testCycleState) + got, err := getPostFilterState(testCycleState) + assert.NoError(t, err) + assert.NotNil(t, got) + cycleStateCopy := testCycleState.Clone() + got1, err := getPostFilterState(cycleStateCopy) + assert.NoError(t, err) + assert.Equal(t, got, got1) + + testCycleState = framework.NewCycleState() + p.snapshotPostFilterState(&core.QuotaInfo{}, testCycleState) + got, err = getPostFilterState(testCycleState) + assert.NoError(t, err) + assert.NotNil(t, got) + cycleStateCopy = testCycleState.Clone() + got1, err = getPostFilterState(cycleStateCopy) + assert.NoError(t, err) + assert.Equal(t, got, got1) + }) +}