diff --git a/internal/scheduler/context/scheduling_test.go b/internal/scheduler/context/scheduling_test.go index 28c94717da4..8bef8d51ef6 100644 --- a/internal/scheduler/context/scheduling_test.go +++ b/internal/scheduler/context/scheduling_test.go @@ -59,11 +59,11 @@ func TestSchedulingContextAccounting(t *testing.T) { } func TestCalculateFairShares(t *testing.T) { - zeroCpu := nCpu(0) - oneCpu := nCpu(1) - fortyCpu := nCpu(40) - oneHundredCpu := nCpu(100) - oneThousandCpu := nCpu(1000) + zeroCpu := cpu(0) + oneCpu := cpu(1) + fortyCpu := cpu(40) + oneHundredCpu := cpu(100) + oneThousandCpu := cpu(1000) tests := map[string]struct { availableResources schedulerobjects.ResourceList queueCtxs map[string]*QueueSchedulingContext @@ -206,44 +206,44 @@ func TestCalculateFairnessError(t *testing.T) { expected float64 }{ "one queue, no error": { - availableResources: nCpu(100), + availableResources: cpu(100), queueCtxs: map[string]*QueueSchedulingContext{ - "queueA": {Allocated: nCpu(50), AdjustedFairShare: 0.5}, + "queueA": {Allocated: cpu(50), AdjustedFairShare: 0.5}, }, expected: 0, }, "two queues, no error": { - availableResources: nCpu(100), + availableResources: cpu(100), queueCtxs: map[string]*QueueSchedulingContext{ - "queueA": {Allocated: nCpu(50), AdjustedFairShare: 0.5}, - "queueB": {Allocated: nCpu(50), AdjustedFairShare: 0.5}, + "queueA": {Allocated: cpu(50), AdjustedFairShare: 0.5}, + "queueB": {Allocated: cpu(50), AdjustedFairShare: 0.5}, }, expected: 0, }, "one queue with error": { - availableResources: nCpu(100), + availableResources: cpu(100), queueCtxs: map[string]*QueueSchedulingContext{ - "queueA": {Allocated: nCpu(40), AdjustedFairShare: 0.5}, + "queueA": {Allocated: cpu(40), AdjustedFairShare: 0.5}, }, expected: 0.1, }, "two queues with error": { - availableResources: nCpu(100), + availableResources: cpu(100), queueCtxs: map[string]*QueueSchedulingContext{ - "queueA": {Allocated: nCpu(40), AdjustedFairShare: 0.5}, - "queueB": {Allocated: nCpu(10), AdjustedFairShare: 0.5}, + "queueA": {Allocated: cpu(40), AdjustedFairShare: 0.5}, + "queueB": {Allocated: cpu(10), AdjustedFairShare: 0.5}, }, expected: 0.5, }, "above fair share is not counted": { - availableResources: nCpu(100), + availableResources: cpu(100), queueCtxs: map[string]*QueueSchedulingContext{ - "queueA": {Allocated: nCpu(100), AdjustedFairShare: 0.5}, + "queueA": {Allocated: cpu(100), AdjustedFairShare: 0.5}, }, expected: 0.0, }, "empty": { - availableResources: nCpu(100), + availableResources: cpu(100), queueCtxs: map[string]*QueueSchedulingContext{}, expected: 0.0, }, @@ -278,7 +278,7 @@ func testSmallCpuJobSchedulingContext(queue, priorityClassName string) *JobSched } } -func nCpu(n int) schedulerobjects.ResourceList { +func cpu(n int) schedulerobjects.ResourceList { return schedulerobjects.ResourceList{ Resources: map[string]resource.Quantity{"cpu": resource.MustParse(fmt.Sprintf("%d", n))}, } diff --git a/internal/scheduler/metrics/cycle_metrics_test.go b/internal/scheduler/metrics/cycle_metrics_test.go index 2e78bc63611..2f86dcb9c91 100644 --- a/internal/scheduler/metrics/cycle_metrics_test.go +++ b/internal/scheduler/metrics/cycle_metrics_test.go @@ -21,7 +21,7 @@ const epsilon = 1e-6 func TestReportStateTransitions(t *testing.T) { fairnessCostProvider, err := fairness.NewDominantResourceFairness( - nCpu(100), + cpu(100), configuration.SchedulingConfig{DominantResourceFairnessResourcesToConsider: []string{"cpu"}}) require.NoError(t, err) result := schedulerresult.SchedulerResult{ @@ -31,9 +31,9 @@ func TestReportStateTransitions(t *testing.T) { FairnessCostProvider: fairnessCostProvider, QueueSchedulingContexts: map[string]*context.QueueSchedulingContext{ "queue1": { - Allocated: nCpu(10), - Demand: nCpu(20), - CappedDemand: nCpu(15), + Allocated: cpu(10), + Demand: cpu(20), + CappedDemand: cpu(15), AdjustedFairShare: 0.15, SuccessfulJobSchedulingContexts: map[string]*context.JobSchedulingContext{ "job1": { @@ -78,7 +78,7 @@ func TestReportStateTransitions(t *testing.T) { assert.InDelta(t, 0.05, fairnessError, epsilon, "fairnessError") } -func nCpu(n int) schedulerobjects.ResourceList { +func cpu(n int) schedulerobjects.ResourceList { return schedulerobjects.ResourceList{ Resources: map[string]resource.Quantity{"cpu": resource.MustParse(fmt.Sprintf("%d", n))}, } diff --git a/internal/scheduler/metrics/state_metrics.go b/internal/scheduler/metrics/state_metrics.go index 09172712881..ce3894436a7 100644 --- a/internal/scheduler/metrics/state_metrics.go +++ b/internal/scheduler/metrics/state_metrics.go @@ -62,35 +62,35 @@ func newJobStateMetrics(errorRegexes []*regexp.Regexp, trackedResourceNames []v1 jobStateSecondsByQueue := prometheus.NewCounterVec( prometheus.CounterOpts{ Name: prefix + "job_state_seconds_by_queue", - Help: "time spend in different states at the queue level", + Help: "time spent in different states at the queue level", }, []string{queueLabel, poolLabel, stateLabel, priorStateLabel}, ) jobStateSecondsByNode := prometheus.NewCounterVec( prometheus.CounterOpts{ Name: prefix + "job_state_seconds_by_node", - Help: "time spend in different states at the node level", + Help: "time spent in different states at the node level", }, []string{nodeLabel, poolLabel, clusterLabel, stateLabel, priorStateLabel}, ) jobStateResourceSecondsByQueue := prometheus.NewCounterVec( prometheus.CounterOpts{ Name: prefix + "job_state_resource_seconds_by_queue", - Help: "Resource-seconds spend in different states at the queue level", + Help: "Resource-seconds spent in different states at the queue level", }, []string{queueLabel, poolLabel, stateLabel, priorStateLabel, resourceLabel}, ) jobStateResourceSecondsByNode := prometheus.NewCounterVec( prometheus.CounterOpts{ Name: prefix + "job_state_resource_seconds_by_node", - Help: "Resource-seconds spend in different states at the node level", + Help: "Resource-seconds spent in different states at the node level", }, []string{nodeLabel, poolLabel, clusterLabel, stateLabel, priorStateLabel, resourceLabel}, ) jobErrorsByQueue := prometheus.NewCounterVec( prometheus.CounterOpts{ Name: prefix + "job_error_classification_by_queue", - Help: "Failed jobs ey error classification at the queue level", + Help: "Failed jobs by error classification at the queue level", }, []string{queueLabel, poolLabel, errorCategoryLabel, errorSubcategoryLabel}, )