Skip to content

Commit 7b0d0db

Browse files
committed
refactor: Replace custom maxFloat64 function with lo.Max from samber/lo for improved readability in timeaware tests
1 parent d448cea commit 7b0d0db

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

test/e2e/suites/timeaware/timeaware_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/NVIDIA/KAI-scheduler/test/e2e/modules/wait"
2222
. "github.com/onsi/ginkgo/v2"
2323
. "github.com/onsi/gomega"
24+
"github.com/samber/lo"
2425
v1 "k8s.io/api/core/v1"
2526
"k8s.io/apimachinery/pkg/api/resource"
2627
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -107,7 +108,7 @@ var _ = Describe("Time Aware Fairness", Label("timeaware", "nightly"), Ordered,
107108
values, qErr := queryPrometheusInstant(ctx, testCtx.KubeClientset, fmt.Sprintf("kai_queue_allocated_gpus{queue_name=\"%s\"}", queueA.Name))
108109
g.Expect(qErr).NotTo(HaveOccurred())
109110
g.Expect(values).NotTo(BeEmpty(), "Expected Prometheus to return at least one sample for queue-a")
110-
g.Expect(maxFloat64(values)).To(BeNumerically(">=", float64(idleGPUs)), "Expected queue-a to be allocating all idle GPUs")
111+
g.Expect(lo.Max(values)).To(BeNumerically(">=", float64(idleGPUs)), "Expected queue-a to be allocating all idle GPUs")
111112
}, prometheusUsageTimeout, 5*time.Second).Should(Succeed())
112113

113114
By("Submitting a competing job from queue-b (requires reclaim to schedule)")

test/e2e/suites/timeaware/utils.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,3 @@ func queryPrometheusInstant(ctx context.Context, kubeClient kubernetes.Interface
6666
}
6767
return values, nil
6868
}
69-
70-
func maxFloat64(values []float64) float64 {
71-
if len(values) == 0 {
72-
return 0
73-
}
74-
max := values[0]
75-
for _, v := range values[1:] {
76-
if v > max {
77-
max = v
78-
}
79-
}
80-
return max
81-
}

0 commit comments

Comments
 (0)