From d7f71b35555990580ab21b1f891db982f1e4ac55 Mon Sep 17 00:00:00 2001 From: Gabe <15304068+gabesaba@users.noreply.github.com> Date: Thu, 27 Jun 2024 10:00:48 +0000 Subject: [PATCH 1/4] Define ResourceQuotaWrapper; improve documentation --- pkg/util/testing/wrappers.go | 48 ++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/pkg/util/testing/wrappers.go b/pkg/util/testing/wrappers.go index 64fe90aaa6..43ebc4c631 100644 --- a/pkg/util/testing/wrappers.go +++ b/pkg/util/testing/wrappers.go @@ -758,25 +758,57 @@ func (f *FlavorQuotasWrapper) Obj() *kueue.FlavorQuotas { return &f.FlavorQuotas } +// Resource takes ResourceName, followed by the optional NominalQuota, BorrowingLimit, LendingLimit. func (f *FlavorQuotasWrapper) Resource(name corev1.ResourceName, qs ...string) *FlavorQuotasWrapper { - rq := kueue.ResourceQuota{ - Name: name, - } + resourceWrapper := f.ResourceQuotaWrapper(name) if len(qs) > 0 { - rq.NominalQuota = resource.MustParse(qs[0]) + resourceWrapper.NominalQuota(qs[0]) } if len(qs) > 1 && len(qs[1]) > 0 { - rq.BorrowingLimit = ptr.To(resource.MustParse(qs[1])) + resourceWrapper.BorrowingLimit(qs[1]) } if len(qs) > 2 && len(qs[2]) > 0 { - rq.LendingLimit = ptr.To(resource.MustParse(qs[2])) + resourceWrapper.LendingLimit(qs[2]) } if len(qs) > 3 { panic("Must have at most 3 quantities for nominalQuota, borrowingLimit and lendingLimit") } + return resourceWrapper.Append() +} + +// ResourceQuotaWrapper allows creation the creation of a Resource in a type-safe manner. +func (f *FlavorQuotasWrapper) ResourceQuotaWrapper(name corev1.ResourceName) *resourceQuotaWrapper { + rq := kueue.ResourceQuota{ + Name: name, + } + return &resourceQuotaWrapper{parent: f, ResourceQuota: rq} +} + +// resourceQuotaWrapper wraps a ResourceQuota object. +type resourceQuotaWrapper struct { + parent *FlavorQuotasWrapper + kueue.ResourceQuota +} + +func (rq *resourceQuotaWrapper) NominalQuota(quantity string) *resourceQuotaWrapper { + rq.ResourceQuota.NominalQuota = resource.MustParse(quantity) + return rq +} + +func (rq *resourceQuotaWrapper) BorrowingLimit(quantity string) *resourceQuotaWrapper { + rq.ResourceQuota.BorrowingLimit = ptr.To(resource.MustParse(quantity)) + return rq +} + +func (rq *resourceQuotaWrapper) LendingLimit(quantity string) *resourceQuotaWrapper { + rq.ResourceQuota.LendingLimit = ptr.To(resource.MustParse(quantity)) + return rq +} - f.Resources = append(f.Resources, rq) - return f +// Append appends the ResourceQuotaWrapper to its parent +func (rq *resourceQuotaWrapper) Append() *FlavorQuotasWrapper { + rq.parent.Resources = append(rq.parent.Resources, rq.ResourceQuota) + return rq.parent } // ResourceFlavorWrapper wraps a ResourceFlavor. From 8c94d7e720f1aaa478ef02d0e9897d4db5f1b17a Mon Sep 17 00:00:00 2001 From: Gabe <15304068+gabesaba@users.noreply.github.com> Date: Wed, 26 Jun 2024 13:05:32 +0000 Subject: [PATCH 2/4] Update FlavorAssignerTest to use ClusterQueue API types --- .../flavorassigner/flavorassigner_test.go | 1610 ++++++----------- 1 file changed, 603 insertions(+), 1007 deletions(-) diff --git a/pkg/scheduler/flavorassigner/flavorassigner_test.go b/pkg/scheduler/flavorassigner/flavorassigner_test.go index 0357705b44..16b96774bd 100644 --- a/pkg/scheduler/flavorassigner/flavorassigner_test.go +++ b/pkg/scheduler/flavorassigner/flavorassigner_test.go @@ -17,6 +17,7 @@ limitations under the License. package flavorassigner import ( + "context" "fmt" "testing" @@ -26,8 +27,6 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/utils/ptr" kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1" "sigs.k8s.io/kueue/pkg/cache" @@ -37,11 +36,12 @@ import ( "sigs.k8s.io/kueue/pkg/workload" ) +type cohortResources struct { + requestableResources resources.FlavorResourceQuantitiesFlat + usage resources.FlavorResourceQuantitiesFlat +} + func TestAssignFlavors(t *testing.T) { - defaultFlavorFungibility := kueue.FlavorFungibility{ - WhenCanBorrow: kueue.Borrow, - WhenCanPreempt: kueue.TryNextFlavor, - } resourceFlavors := map[kueue.ResourceFlavorReference]*kueue.ResourceFlavor{ "default": { ObjectMeta: metav1.ObjectMeta{Name: "default"}, @@ -61,7 +61,9 @@ func TestAssignFlavors(t *testing.T) { cases := map[string]struct { wlPods []kueue.PodSet wlReclaimablePods []kueue.ReclaimablePod - clusterQueue cache.ClusterQueue + clusterQueue kueue.ClusterQueue + clusterQueueUsage resources.FlavorResourceQuantitiesFlat + cohortResources *cohortResources wantRepMode FlavorAssignmentMode wantAssignment Assignment enableLendingLimit bool @@ -74,18 +76,13 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceMemory, "1Mi"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourceMemory), - Flavors: []cache.FlavorQuotas{{ - Name: "default", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 1000}, - corev1.ResourceMemory: {Nominal: 2 * utiltesting.Mi}, - }, - }}, - }}, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("default"). + Resource(corev1.ResourceCPU, "1000m"). + Resource(corev1.ResourceMemory, "2Mi"). + FlavorQuotas, + ).ClusterQueue, wantRepMode: Fit, wantAssignment: Assignment{ PodSets: []PodSetAssignment{ @@ -120,17 +117,13 @@ func TestAssignFlavors(t *testing.T) { }). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "tainted", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }}, - }}, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("tainted"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + ).ClusterQueue, + wantRepMode: Fit, wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ @@ -154,19 +147,14 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "2"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "default", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }}, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "default", Resource: corev1.ResourceCPU}: 3_000, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("default"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + ).ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "default", Resource: corev1.ResourceCPU}: 3_000, }, wantRepMode: Preempt, wantAssignment: Assignment{ @@ -195,44 +183,24 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceMemory, "10Mi"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{ - { - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{ - { - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 2000}, - }, - }, - { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - }, - }, - { - CoveredResources: sets.New(corev1.ResourceMemory), - Flavors: []cache.FlavorQuotas{ - { - Name: "b_one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceMemory: {Nominal: utiltesting.Gi}, - }, - }, - { - Name: "b_two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceMemory: {Nominal: 5 * utiltesting.Gi}, - }, - }, - }, - }, - }, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "2000m"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + ). + ResourceGroup( + utiltesting.MakeFlavorQuotas("b_one"). + Resource(corev1.ResourceMemory, "1Gi"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("b_two"). + Resource(corev1.ResourceMemory, "5Gi"). + FlavorQuotas, + ). + ClusterQueue, wantRepMode: Fit, wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ @@ -260,31 +228,21 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceMemory, "10Mi"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{ - { - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 3000}, - }, - }}, - }, - { - CoveredResources: sets.New(corev1.ResourceMemory), - Flavors: []cache.FlavorQuotas{{ - Name: "b_one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceMemory: {Nominal: utiltesting.Mi}, - }, - }}, - }, - }, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 1000, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "3000m"). + FlavorQuotas, + ).ResourceGroup( + utiltesting.MakeFlavorQuotas("b_one"). + Resource(corev1.ResourceMemory, "1Mi"). + FlavorQuotas, + ).ClusterQueue, + + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 1000, }, + wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ Name: "main", @@ -310,46 +268,25 @@ func TestAssignFlavors(t *testing.T) { Request("example.com/gpu", "3"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{ - { - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourceMemory), - Flavors: []cache.FlavorQuotas{ - { - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 2000}, - corev1.ResourceMemory: {Nominal: utiltesting.Gi}, - }, - }, - { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - corev1.ResourceMemory: {Nominal: 15 * utiltesting.Mi}, - }, - }, - }, - }, - { - CoveredResources: sets.New[corev1.ResourceName]("example.com/gpu"), - Flavors: []cache.FlavorQuotas{ - { - Name: "b_one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - "example.com/gpu": {Nominal: 4}, - }, - }, - { - Name: "b_two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - "example.com/gpu": {Nominal: 2}, - }, - }, - }, - }, - }, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "2000m"). + Resource(corev1.ResourceMemory, "1Gi"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceMemory, "15Mi"). + FlavorQuotas, + ).ResourceGroup( + utiltesting.MakeFlavorQuotas("b_one"). + Resource("example.com/gpu", "4"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("b_two"). + Resource("example.com/gpu", "2"). + FlavorQuotas, + ).ClusterQueue, + wantRepMode: Fit, wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ @@ -381,52 +318,36 @@ func TestAssignFlavors(t *testing.T) { Request("example.com/gpu", "3"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{ - { - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourceMemory), - Flavors: []cache.FlavorQuotas{ - { - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 2000}, - corev1.ResourceMemory: {Nominal: utiltesting.Gi}, - }, - }, - { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - corev1.ResourceMemory: {Nominal: 15 * utiltesting.Mi}, - }, - }, - }, - }, - { - CoveredResources: sets.New[corev1.ResourceName]("example.com/gpu"), - Flavors: []cache.FlavorQuotas{{ - Name: "b_one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - "example.com/gpu": {Nominal: 4}, - }, - }}, - }, - }, - Usage: resources.FlavorResourceQuantitiesFlat{ + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "2000m"). + Resource(corev1.ResourceMemory, "1Gi"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceMemory, "15Mi"). + FlavorQuotas, + ).ResourceGroup( + utiltesting.MakeFlavorQuotas("b_one"). + Resource("example.com/gpu", "4"). + FlavorQuotas, + ).Cohort("test-cohort"). + ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "two", Resource: corev1.ResourceMemory}: 10 * utiltesting.Mi, + }, + cohortResources: &cohortResources{ + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceMemory}: utiltesting.Gi, + {Flavor: "two", Resource: corev1.ResourceCPU}: 4000, + {Flavor: "two", Resource: corev1.ResourceMemory}: 15 * utiltesting.Mi, + {Flavor: "b_one", Resource: "example.com/gpu"}: 4, + }, + usage: resources.FlavorResourceQuantitiesFlat{ {Flavor: "two", Resource: corev1.ResourceMemory}: 10 * utiltesting.Mi, - }.Unflatten(), - Cohort: &cache.Cohort{ - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - {Flavor: "one", Resource: corev1.ResourceMemory}: utiltesting.Gi, - {Flavor: "two", Resource: corev1.ResourceCPU}: 4000, - {Flavor: "two", Resource: corev1.ResourceMemory}: 15 * utiltesting.Mi, - {Flavor: "b_one", Resource: "example.com/gpu"}: 4, - }.Unflatten(), - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "two", Resource: corev1.ResourceMemory}: 10 * utiltesting.Mi, - {Flavor: "b_one", Resource: "example.com/gpu"}: 2, - }.Unflatten(), + {Flavor: "b_one", Resource: "example.com/gpu"}: 2, }, }, wantRepMode: Preempt, @@ -466,29 +387,17 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceMemory, "10Mi"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{ - { - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourceMemory), - Flavors: []cache.FlavorQuotas{ - { - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 2000}, - corev1.ResourceMemory: {Nominal: utiltesting.Gi}, - }, - }, - { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - corev1.ResourceMemory: {Nominal: 5 * utiltesting.Mi}, - }, - }, - }, - }, - }, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "2000m"). + Resource(corev1.ResourceMemory, "1Gi"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceMemory, "5Mi"). + FlavorQuotas, + ).ClusterQueue, wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ Name: "main", @@ -513,71 +422,15 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "3"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{ - { - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{ - { - Name: "tainted", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - }, - }, - }, - }, - wantRepMode: Fit, - wantAssignment: Assignment{ - PodSets: []PodSetAssignment{{ - Name: "main", - Flavors: ResourceAssignment{ - corev1.ResourceCPU: {Name: "two", Mode: Fit, TriedFlavorIdx: -1}, - }, - Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("3000m"), - }, - Count: 1, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "two", Resource: corev1.ResourceCPU}: 3000, - }.Unflatten(), - }, - }, - "multiple flavors, skip missing ResourceFlavor": { - wlPods: []kueue.PodSet{ - *utiltesting.MakePodSet("main", 1). - Request(corev1.ResourceCPU, "3"). - Obj(), - }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{ - { - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{ - { - Name: "nonexistent-flavor", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - }, - }, - }, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("tainted"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + ).ClusterQueue, wantRepMode: Fit, wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ @@ -627,33 +480,15 @@ func TestAssignFlavors(t *testing.T) { }, }, }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{ - { - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{ - { - Name: "non-existent", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - { - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - }, - }, - }, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + ).ClusterQueue, wantRepMode: Fit, wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ @@ -702,29 +537,18 @@ func TestAssignFlavors(t *testing.T) { }, }, }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{ - { - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourceMemory), - Flavors: []cache.FlavorQuotas{ - { - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - corev1.ResourceMemory: {Nominal: utiltesting.Gi}, - }, - }, - { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - corev1.ResourceMemory: {Nominal: utiltesting.Gi}, - }, - }, - }, - }, - }, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceMemory, "1Gi"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceMemory, "1Gi"). + FlavorQuotas, + ).ClusterQueue, + wantRepMode: Fit, wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ @@ -787,27 +611,16 @@ func TestAssignFlavors(t *testing.T) { }, }, }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{ - { - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{ - { - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - }, - }, - }, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + ).ClusterQueue, + wantRepMode: Fit, wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ @@ -854,27 +667,16 @@ func TestAssignFlavors(t *testing.T) { }, }, }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{ - { - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{ - { - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - }, - }, - }, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + ).ClusterQueue, + wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ Name: "main", @@ -901,27 +703,16 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "3"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{ - { - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{ - { - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 10_000}, - }, - }, - }, - }, - }, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "10000m"). + FlavorQuotas, + ).ClusterQueue, + wantRepMode: Fit, wantAssignment: Assignment{ PodSets: []PodSetAssignment{ @@ -963,22 +754,19 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceMemory, "4Gi"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourceMemory), - Flavors: []cache.FlavorQuotas{{ - Name: "default", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 2000, BorrowingLimit: ptr.To[int64](98_000)}, - corev1.ResourceMemory: {Nominal: 2 * utiltesting.Gi}, - }, - }}, - }}, - Cohort: &cache.Cohort{ - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "default", Resource: corev1.ResourceCPU}: 200_000, - {Flavor: "default", Resource: corev1.ResourceMemory}: 200 * utiltesting.Gi, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("default"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("2000m").BorrowingLimit("98000m").Append(). + Resource(corev1.ResourceMemory, "2Gi"). + FlavorQuotas, + ).Cohort("test-cohort"). + ClusterQueue, + + cohortResources: &cohortResources{ + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "default", Resource: corev1.ResourceCPU}: 200_000, + {Flavor: "default", Resource: corev1.ResourceMemory}: 200 * utiltesting.Gi, }, }, wantRepMode: Fit, @@ -1022,23 +810,19 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "2"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 1000}, - }, - }}, - }}, - Cohort: &cache.Cohort{ - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, - }.Unflatten(), - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 9_000, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "1000m"). + FlavorQuotas, + ).Cohort("test-cohort").ClusterQueue, + + cohortResources: &cohortResources{ + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, + }, + usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 9_000, }, }, wantAssignment: Assignment{ @@ -1061,26 +845,22 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "2"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 2000, BorrowingLimit: ptr.To[int64](8_000)}, - }, - }}, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("2000m").BorrowingLimit("8000m").Append(). + FlavorQuotas, + ).Cohort("test-cohort"). + ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 9_000, + }, + cohortResources: &cohortResources{ + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 100_000, + }, + usage: resources.FlavorResourceQuantitiesFlat{ {Flavor: "one", Resource: corev1.ResourceCPU}: 9_000, - }.Unflatten(), - Cohort: &cache.Cohort{ - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 100_000, - }.Unflatten(), - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 9_000, - }.Unflatten(), }, }, wantRepMode: Preempt, @@ -1110,19 +890,14 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "2"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 2000}, - }, - }}, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 1_000, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "2000m"). + FlavorQuotas, + ).ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 1_000, }, wantRepMode: Preempt, wantAssignment: Assignment{ @@ -1150,26 +925,21 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "2"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 3000}, - }, - }}, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, - }.Unflatten(), - Cohort: &cache.Cohort{ - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, - }.Unflatten(), - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "3000m"). + FlavorQuotas, + ).Cohort("test-cohort").ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, + }, + cohortResources: &cohortResources{ + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, + }, + usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, }, }, wantRepMode: Preempt, @@ -1207,28 +977,18 @@ func TestAssignFlavors(t *testing.T) { }, }, }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{ - { - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - }, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 3000, - {Flavor: "two", Resource: corev1.ResourceCPU}: 3000, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + ).ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 3000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 3000, }, wantRepMode: Preempt, wantAssignment: Assignment{ @@ -1268,28 +1028,18 @@ func TestAssignFlavors(t *testing.T) { }). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{ - { - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }, - { - Name: "tainted", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 10_000}, - }, - }, - }, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 3000, - {Flavor: "tainted", Resource: corev1.ResourceCPU}: 3000, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("tainted"). + Resource(corev1.ResourceCPU, "10000m"). + FlavorQuotas, + ).ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 3000, + {Flavor: "tainted", Resource: corev1.ResourceCPU}: 3000, }, wantRepMode: Preempt, wantAssignment: Assignment{ @@ -1339,17 +1089,12 @@ func TestAssignFlavors(t *testing.T) { Request("example.com/gpu", "2"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 4000}, - }, - }}, - }}, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "4000m"). + FlavorQuotas, + ).ClusterQueue, wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ Name: "main", @@ -1364,55 +1109,20 @@ func TestAssignFlavors(t *testing.T) { Usage: resources.FlavorResourceQuantities{}, }, }, - "flavor not found": { - wlPods: []kueue.PodSet{ - *utiltesting.MakePodSet("main", 1). - Request(corev1.ResourceCPU, "1"). - Obj(), - }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "nonexistent-flavor", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 1000}, - }, - }}, - }}, - }, - wantAssignment: Assignment{ - PodSets: []PodSetAssignment{{ - Name: "main", - Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("1000m"), - }, - Status: &Status{ - reasons: []string{"flavor nonexistent-flavor not found"}, - }, - Count: 1, - }}, - Usage: resources.FlavorResourceQuantities{}, - }, - }, "num pods fit": { wlPods: []kueue.PodSet{ *utiltesting.MakePodSet("main", 3). Request(corev1.ResourceCPU, "1"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourcePods), - Flavors: []cache.FlavorQuotas{{ - Name: "default", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 3}, - corev1.ResourceCPU: {Nominal: 10000}, - }, - }}, - }}, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("default"). + Resource(corev1.ResourcePods, "3"). + Resource(corev1.ResourceCPU, "10000m"). + FlavorQuotas, + ).ClusterQueue, + wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ Name: "main", @@ -1440,18 +1150,14 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "1"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourcePods), - Flavors: []cache.FlavorQuotas{{ - Name: "default", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 2}, - corev1.ResourceCPU: {Nominal: 10000}, - }, - }}, - }}, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("default"). + Resource(corev1.ResourcePods, "2"). + Resource(corev1.ResourceCPU, "10000m"). + FlavorQuotas, + ).ClusterQueue, + wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ Name: "main", @@ -1479,18 +1185,13 @@ func TestAssignFlavors(t *testing.T) { Count: 2, }, }, - clusterQueue: cache.ClusterQueue{ - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourcePods), - Flavors: []cache.FlavorQuotas{{ - Name: "default", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 3}, - corev1.ResourceCPU: {Nominal: 10000}, - }, - }}, - }}, - }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("default"). + Resource(corev1.ResourcePods, "3"). + Resource(corev1.ResourceCPU, "10000m"). + FlavorQuotas, + ).ClusterQueue, wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ Name: "main", @@ -1518,30 +1219,20 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "9"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - FlavorFungibility: kueue.FlavorFungibility{ - WhenCanBorrow: kueue.Borrow, - WhenCanPreempt: kueue.Preempt, - }, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourcePods), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 10000}, - }, - }, { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 10000}, - }, - }}, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + FlavorFungibility(kueue.FlavorFungibility{WhenCanBorrow: kueue.Borrow, WhenCanPreempt: kueue.Preempt}). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourcePods, "10"). + Resource(corev1.ResourceCPU, "10000m"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourcePods, "10"). + Resource(corev1.ResourceCPU, "10000m"). + FlavorQuotas, + ).ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, }, wantRepMode: Preempt, wantAssignment: Assignment{ @@ -1572,27 +1263,19 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "9"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - FlavorFungibility: defaultFlavorFungibility, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourcePods), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 10000}, - }, - }, { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 10000}, - }, - }}, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourcePods, "10"). + Resource(corev1.ResourceCPU, "10000m"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourcePods, "10"). + Resource(corev1.ResourceCPU, "10000m"). + FlavorQuotas, + ).ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, }, wantRepMode: Fit, wantAssignment: Assignment{ @@ -1620,41 +1303,32 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "9"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - Cohort: &cache.Cohort{ - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, - {Flavor: "one", Resource: corev1.ResourcePods}: 10, - {Flavor: "two", Resource: corev1.ResourceCPU}: 1000, - {Flavor: "two", Resource: corev1.ResourcePods}: 10, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + FlavorFungibility(kueue.FlavorFungibility{WhenCanBorrow: kueue.TryNextFlavor, WhenCanPreempt: kueue.TryNextFlavor}). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourcePods, "10"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").BorrowingLimit("1000m").Append(). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourcePods, "10"). + Resource(corev1.ResourceCPU, "1000m"). + FlavorQuotas, + ).Cohort("test-cohort"). + ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + }, + cohortResources: &cohortResources{ + usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, }, - FlavorFungibility: kueue.FlavorFungibility{ - WhenCanBorrow: kueue.TryNextFlavor, - WhenCanPreempt: kueue.TryNextFlavor, + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, + {Flavor: "one", Resource: corev1.ResourcePods}: 10, + {Flavor: "two", Resource: corev1.ResourceCPU}: 1000, + {Flavor: "two", Resource: corev1.ResourcePods}: 10, }, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourcePods), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 10000, BorrowingLimit: ptr.To[int64](1000)}, - }, - }, { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 1000}, - }, - }}, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), }, wantRepMode: Fit, wantAssignment: Assignment{ @@ -1683,41 +1357,33 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "9"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - Cohort: &cache.Cohort{ - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, - {Flavor: "one", Resource: corev1.ResourcePods}: 10, - {Flavor: "two", Resource: corev1.ResourceCPU}: 10000, - {Flavor: "two", Resource: corev1.ResourcePods}: 10, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + FlavorFungibility(kueue.FlavorFungibility{WhenCanBorrow: kueue.TryNextFlavor, WhenCanPreempt: kueue.TryNextFlavor}). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourcePods, "10"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").BorrowingLimit("1000m").Append(). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourcePods, "10"). + Resource(corev1.ResourceCPU, "10000m"). + FlavorQuotas, + ).Cohort("test-cohort"). + ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + }, + + cohortResources: &cohortResources{ + usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, }, - FlavorFungibility: kueue.FlavorFungibility{ - WhenCanBorrow: kueue.TryNextFlavor, - WhenCanPreempt: kueue.TryNextFlavor, + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, + {Flavor: "one", Resource: corev1.ResourcePods}: 10, + {Flavor: "two", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "two", Resource: corev1.ResourcePods}: 10, }, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourcePods), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 10000, BorrowingLimit: ptr.To[int64](1000)}, - }, - }, { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 10000}, - }, - }}, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), }, wantRepMode: Fit, wantAssignment: Assignment{ @@ -1745,38 +1411,32 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "9"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - Cohort: &cache.Cohort{ - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, - {Flavor: "one", Resource: corev1.ResourcePods}: 10, - {Flavor: "two", Resource: corev1.ResourceCPU}: 10000, - {Flavor: "two", Resource: corev1.ResourcePods}: 10, - }.Unflatten(), - }, - FlavorFungibility: defaultFlavorFungibility, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourcePods), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 10000, BorrowingLimit: ptr.To[int64](1000)}, - }, - }, { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 10000}, - }, - }}, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourcePods, "10"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").BorrowingLimit("1000m").Append(). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourcePods, "10"). + Resource(corev1.ResourceCPU, "10000m"). + FlavorQuotas, + ).Cohort("test-cohort"). + ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + }, + + cohortResources: &cohortResources{ + usage: resources.FlavorResourceQuantitiesFlat{ {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), + }, + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, + {Flavor: "one", Resource: corev1.ResourcePods}: 10, + {Flavor: "two", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "two", Resource: corev1.ResourcePods}: 10, + }, }, wantRepMode: Fit, wantAssignment: Assignment{ @@ -1805,40 +1465,34 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "12"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - Preemption: kueue.ClusterQueuePreemption{ + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + Preemption(kueue.ClusterQueuePreemption{ ReclaimWithinCohort: kueue.PreemptionPolicyLowerPriority, BorrowWithinCohort: &kueue.BorrowWithinCohort{ Policy: kueue.BorrowWithinCohortPolicyLowerPriority, }, - }, - Cohort: &cache.Cohort{ - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, - }.Unflatten(), - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 12000, - {Flavor: "two", Resource: corev1.ResourceCPU}: 12000, - }.Unflatten(), - }, - FlavorFungibility: kueue.FlavorFungibility{ + }). + FlavorFungibility(kueue.FlavorFungibility{ WhenCanBorrow: kueue.Borrow, WhenCanPreempt: kueue.Preempt, + }). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("0").BorrowingLimit("12000m").Append(). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "12000m"). + FlavorQuotas, + ).Cohort("test-cohort").ClusterQueue, + + cohortResources: &cohortResources{ + usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, + }, + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 12000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 12000, }, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 0, BorrowingLimit: ptr.To[int64](12000)}, - }, - }, { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 12000}, - }, - }}, - }}, }, wantRepMode: Preempt, wantAssignment: Assignment{ @@ -1867,40 +1521,33 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "12"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - Preemption: kueue.ClusterQueuePreemption{ + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + Preemption(kueue.ClusterQueuePreemption{ ReclaimWithinCohort: kueue.PreemptionPolicyLowerPriority, BorrowWithinCohort: &kueue.BorrowWithinCohort{ Policy: kueue.BorrowWithinCohortPolicyLowerPriority, }, - }, - Cohort: &cache.Cohort{ - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, - }.Unflatten(), - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 12000, - {Flavor: "two", Resource: corev1.ResourceCPU}: 12000, - }.Unflatten(), - }, - FlavorFungibility: kueue.FlavorFungibility{ + }). + FlavorFungibility(kueue.FlavorFungibility{ WhenCanBorrow: kueue.Borrow, WhenCanPreempt: kueue.Preempt, + }). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "0"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "12000m"). + FlavorQuotas, + ).Cohort("test-cohort").ClusterQueue, + cohortResources: &cohortResources{ + usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, + }, + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 12000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 12000, }, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 0}, - }, - }, { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 12000}, - }, - }}, - }}, }, wantRepMode: Preempt, wantAssignment: Assignment{ @@ -1929,40 +1576,34 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "12"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - Preemption: kueue.ClusterQueuePreemption{ + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + Preemption(kueue.ClusterQueuePreemption{ ReclaimWithinCohort: kueue.PreemptionPolicyLowerPriority, BorrowWithinCohort: &kueue.BorrowWithinCohort{ Policy: kueue.BorrowWithinCohortPolicyLowerPriority, }, - }, - Cohort: &cache.Cohort{ - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, - }.Unflatten(), - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 12000, - {Flavor: "two", Resource: corev1.ResourceCPU}: 12000, - }.Unflatten(), - }, - FlavorFungibility: kueue.FlavorFungibility{ + }). + FlavorFungibility(kueue.FlavorFungibility{ WhenCanBorrow: kueue.TryNextFlavor, WhenCanPreempt: kueue.Preempt, + }). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("0").BorrowingLimit("12000m").Append(). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "12000m"). + FlavorQuotas, + ).Cohort("test-cohort"). + ClusterQueue, + cohortResources: &cohortResources{ + usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, + }, + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 12000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 12000, }, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 0, BorrowingLimit: ptr.To[int64](12000)}, - }, - }, { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 12000}, - }, - }}, - }}, }, wantRepMode: Fit, wantAssignment: Assignment{ @@ -1987,32 +1628,27 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "12"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - Preemption: kueue.ClusterQueuePreemption{ + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + Preemption(kueue.ClusterQueuePreemption{ ReclaimWithinCohort: kueue.PreemptionPolicyLowerPriority, BorrowWithinCohort: &kueue.BorrowWithinCohort{ Policy: kueue.BorrowWithinCohortPolicyLowerPriority, }, + }). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("0").BorrowingLimit("12000m").Append(). + FlavorQuotas, + ).Cohort("test-cohort").ClusterQueue, + cohortResources: &cohortResources{ + usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, + }, + requestableResources: resources.FlavorResourceQuantitiesFlat{ + { + // below the borrowingLimit required to admit + Flavor: "one", Resource: corev1.ResourceCPU}: 11000, }, - Cohort: &cache.Cohort{ - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, - }.Unflatten(), - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - { - // below the borrowingLimit required to admit - Flavor: "one", Resource: corev1.ResourceCPU}: 11000, - }.Unflatten(), - }, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 0, BorrowingLimit: ptr.To[int64](12000)}, - }, - }}, - }}, }, wantRepMode: NoFit, wantAssignment: Assignment{ @@ -2037,45 +1673,32 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "9"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - Cohort: &cache.Cohort{ - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, - {Flavor: "one", Resource: corev1.ResourcePods}: 10, - {Flavor: "two", Resource: corev1.ResourceCPU}: 10000, - {Flavor: "two", Resource: corev1.ResourcePods}: 10, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + FlavorFungibility(kueue.FlavorFungibility{WhenCanBorrow: kueue.TryNextFlavor, WhenCanPreempt: kueue.TryNextFlavor}). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourcePods, "10"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").LendingLimit("1000m").Append(). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourcePods, "10"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").LendingLimit("0").Append(). + FlavorQuotas, + ).Cohort("test-cohort"). + ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + }, + cohortResources: &cohortResources{ + usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, }, - FlavorFungibility: kueue.FlavorFungibility{ - WhenCanBorrow: kueue.TryNextFlavor, - WhenCanPreempt: kueue.TryNextFlavor, + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, + {Flavor: "one", Resource: corev1.ResourcePods}: 10, + {Flavor: "two", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "two", Resource: corev1.ResourcePods}: 10, }, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourcePods), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 10_000, LendingLimit: ptr.To[int64](1000)}, - }, - }, { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 10_000, LendingLimit: ptr.To[int64](0)}, - }, - }}, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), - GuaranteedQuota: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: "cpu"}: 9, - {Flavor: "two", Resource: "cpu"}: 10, - }.Unflatten(), }, wantRepMode: Fit, wantAssignment: Assignment{ @@ -2104,45 +1727,32 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "9"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - Cohort: &cache.Cohort{ - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, - {Flavor: "one", Resource: corev1.ResourcePods}: 10, - {Flavor: "two", Resource: corev1.ResourceCPU}: 1000, - {Flavor: "two", Resource: corev1.ResourcePods}: 10, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + FlavorFungibility(kueue.FlavorFungibility{WhenCanBorrow: kueue.TryNextFlavor, WhenCanPreempt: kueue.TryNextFlavor}). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourcePods, "10"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").LendingLimit("1000m").Append(). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourcePods, "10"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("1000m").LendingLimit("0").Append(). + FlavorQuotas, + ).Cohort("test-cohort"). + ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + }, + cohortResources: &cohortResources{ + usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, }, - FlavorFungibility: kueue.FlavorFungibility{ - WhenCanBorrow: kueue.TryNextFlavor, - WhenCanPreempt: kueue.TryNextFlavor, + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, + {Flavor: "one", Resource: corev1.ResourcePods}: 10, + {Flavor: "two", Resource: corev1.ResourceCPU}: 1000, + {Flavor: "two", Resource: corev1.ResourcePods}: 10, }, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourcePods), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 10_000, LendingLimit: ptr.To[int64](1000)}, - }, - }, { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 1_000, LendingLimit: ptr.To[int64](0)}, - }, - }}, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), - GuaranteedQuota: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: "cpu"}: 9, - {Flavor: "two", Resource: "cpu"}: 1, - }.Unflatten(), }, wantRepMode: Fit, wantAssignment: Assignment{ @@ -2166,36 +1776,30 @@ func TestAssignFlavors(t *testing.T) { }, enableLendingLimit: true, }, - "lendingLimit exceeded, but can preempt in cohort and ClusterQueue": { + "quota exhausted, but can preempt in cohort and ClusterQueue": { wlPods: []kueue.PodSet{ *utiltesting.MakePodSet("main", 1). Request(corev1.ResourceCPU, "9"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - Cohort: &cache.Cohort{ - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, - {Flavor: "one", Resource: corev1.ResourcePods}: 10, - }.Unflatten(), + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourcePods, "10"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").LendingLimit("0").Append(). + FlavorQuotas, + ).Cohort("test-cohort").ClusterQueue, + clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + }, + cohortResources: &cohortResources{ + usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, + }, + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "one", Resource: corev1.ResourcePods}: 10, }, - FlavorFungibility: defaultFlavorFungibility, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU, corev1.ResourcePods), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourcePods: {Nominal: 10}, - corev1.ResourceCPU: {Nominal: 10_000, LendingLimit: ptr.To[int64](0)}, - }, - }}, - }}, - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - }.Unflatten(), }, wantRepMode: Preempt, wantAssignment: Assignment{ @@ -2228,37 +1832,25 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "12"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - Preemption: kueue.ClusterQueuePreemption{ - ReclaimWithinCohort: kueue.PreemptionPolicyAny, - }, - Cohort: &cache.Cohort{ - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, - }.Unflatten(), - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 12_000, - {Flavor: "two", Resource: corev1.ResourceCPU}: 12_000, - }.Unflatten(), - }, - FlavorFungibility: kueue.FlavorFungibility{ - WhenCanBorrow: kueue.Borrow, - WhenCanPreempt: kueue.Preempt, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + Preemption(kueue.ClusterQueuePreemption{ReclaimWithinCohort: kueue.PreemptionPolicyAny}). + FlavorFungibility(kueue.FlavorFungibility{WhenCanBorrow: kueue.Borrow, WhenCanPreempt: kueue.Preempt}). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "0"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "12000m"). + FlavorQuotas, + ).Cohort("test-cohort").ClusterQueue, + cohortResources: &cohortResources{ + usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, + }, + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 12_000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 12_000, }, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 0}, - }, - }, { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 12000}, - }, - }}, - }}, }, wantRepMode: Preempt, wantAssignment: Assignment{ @@ -2288,37 +1880,25 @@ func TestAssignFlavors(t *testing.T) { Request(corev1.ResourceCPU, "12"). Obj(), }, - clusterQueue: cache.ClusterQueue{ - Preemption: kueue.ClusterQueuePreemption{ - ReclaimWithinCohort: kueue.PreemptionPolicyNever, - }, - Cohort: &cache.Cohort{ - Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, - }.Unflatten(), - RequestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 12_000, - {Flavor: "two", Resource: corev1.ResourceCPU}: 12_000, - }.Unflatten(), - }, - FlavorFungibility: kueue.FlavorFungibility{ - WhenCanBorrow: kueue.Borrow, - WhenCanPreempt: kueue.Preempt, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + Preemption(kueue.ClusterQueuePreemption{ReclaimWithinCohort: kueue.PreemptionPolicyNever}). + FlavorFungibility(kueue.FlavorFungibility{WhenCanBorrow: kueue.Borrow, WhenCanPreempt: kueue.Preempt}). + ResourceGroup( + utiltesting.MakeFlavorQuotas("one"). + Resource(corev1.ResourceCPU, "0"). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("two"). + Resource(corev1.ResourceCPU, "12000m"). + FlavorQuotas, + ).Cohort("test-cohort").ClusterQueue, + cohortResources: &cohortResources{ + usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, + }, + requestableResources: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "one", Resource: corev1.ResourceCPU}: 12_000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 12_000, }, - ResourceGroups: []cache.ResourceGroup{{ - CoveredResources: sets.New(corev1.ResourceCPU), - Flavors: []cache.FlavorQuotas{{ - Name: "one", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 0}, - }, - }, { - Name: "two", - Resources: map[corev1.ResourceName]*cache.ResourceQuota{ - corev1.ResourceCPU: {Nominal: 12_000}, - }, - }}, - }}, }, wantRepMode: Fit, wantAssignment: Assignment{ @@ -2352,15 +1932,31 @@ func TestAssignFlavors(t *testing.T) { ReclaimablePods: tc.wlReclaimablePods, }, }) - if tc.clusterQueue.FlavorFungibility.WhenCanBorrow == "" { - tc.clusterQueue.FlavorFungibility.WhenCanBorrow = kueue.Borrow + + cache := cache.New(utiltesting.NewFakeClient()) + if err := cache.AddClusterQueue(context.Background(), &tc.clusterQueue); err != nil { + t.Fatalf("Failed to add CQ to cache") + } + for _, rf := range resourceFlavors { + cache.AddOrUpdateResourceFlavor(rf) } - if tc.clusterQueue.FlavorFungibility.WhenCanPreempt == "" { - tc.clusterQueue.FlavorFungibility.WhenCanPreempt = kueue.TryNextFlavor + + clusterQueue := cache.Snapshot().ClusterQueues[tc.clusterQueue.Name] + + if clusterQueue == nil { + t.Fatalf("Failed to create CQ snapshot") } - tc.clusterQueue.UpdateWithFlavors(resourceFlavors) - tc.clusterQueue.UpdateRGByResource() - flvAssigner := New(wlInfo, &tc.clusterQueue, resourceFlavors, tc.enableFairSharing) + + if tc.cohortResources != nil { + if clusterQueue.Cohort == nil { + t.Fatalf("Test case has cohort resources, but cluster queue doesn't have cohort") + } + clusterQueue.Cohort.Usage = tc.cohortResources.usage.Unflatten() + clusterQueue.Cohort.RequestableResources = tc.cohortResources.requestableResources.Unflatten() + } + clusterQueue.Usage = tc.clusterQueueUsage.Unflatten() + + flvAssigner := New(wlInfo, clusterQueue, resourceFlavors, tc.enableFairSharing) assignment := flvAssigner.Assign(log, nil) if repMode := assignment.RepresentativeMode(); repMode != tc.wantRepMode { t.Errorf("e.assignFlavors(_).RepresentativeMode()=%s, want %s", repMode, tc.wantRepMode) From 2c556015328e7d606f241fcef0c894c9d514f21b Mon Sep 17 00:00:00 2001 From: Gabe <15304068+gabesaba@users.noreply.github.com> Date: Fri, 28 Jun 2024 15:24:33 +0000 Subject: [PATCH 3/4] Add tests for deleted flavor --- .../flavorassigner/flavorassigner_test.go | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/pkg/scheduler/flavorassigner/flavorassigner_test.go b/pkg/scheduler/flavorassigner/flavorassigner_test.go index 16b96774bd..715388e9ed 100644 --- a/pkg/scheduler/flavorassigner/flavorassigner_test.go +++ b/pkg/scheduler/flavorassigner/flavorassigner_test.go @@ -1969,6 +1969,128 @@ func TestAssignFlavors(t *testing.T) { } } +// Tests the case where the Cache's flavors and CQs flavors +// fall out of sync, so that the CQ has flavors which no-longer exist. +func TestDeletedFlavors(t *testing.T) { + cases := map[string]struct { + wlPods []kueue.PodSet + wlReclaimablePods []kueue.ReclaimablePod + clusterQueue kueue.ClusterQueue + wantRepMode FlavorAssignmentMode + wantAssignment Assignment + }{ + "multiple flavors, skip missing ResourceFlavor": { + wlPods: []kueue.PodSet{ + *utiltesting.MakePodSet("main", 1). + Request(corev1.ResourceCPU, "3"). + Obj(), + }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("deleted-flavor"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("4000m").Append(). + FlavorQuotas, + utiltesting.MakeFlavorQuotas("flavor"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("4000m").Append(). + FlavorQuotas, + ).ClusterQueue, + wantRepMode: Fit, + wantAssignment: Assignment{ + PodSets: []PodSetAssignment{{ + Name: "main", + Flavors: ResourceAssignment{ + corev1.ResourceCPU: {Name: "flavor", Mode: Fit, TriedFlavorIdx: -1}, + }, + Requests: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("3000m"), + }, + Count: 1, + }}, + Usage: resources.FlavorResourceQuantitiesFlat{ + {Flavor: "flavor", Resource: corev1.ResourceCPU}: 3000, + }.Unflatten(), + }, + }, + "flavor not found": { + wlPods: []kueue.PodSet{ + *utiltesting.MakePodSet("main", 1). + Request(corev1.ResourceCPU, "1"). + Obj(), + }, + clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). + ResourceGroup( + utiltesting.MakeFlavorQuotas("deleted-flavor"). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("4000m").Append(). + FlavorQuotas, + ).ClusterQueue, + wantAssignment: Assignment{ + PodSets: []PodSetAssignment{{ + Name: "main", + Requests: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("1000m"), + }, + Status: &Status{ + reasons: []string{"flavor deleted-flavor not found"}, + }, + Count: 1, + }}, + Usage: resources.FlavorResourceQuantities{}, + }, + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + log := testr.NewWithOptions(t, testr.Options{ + Verbosity: 2, + }) + wlInfo := workload.NewInfo(&kueue.Workload{ + Spec: kueue.WorkloadSpec{ + PodSets: tc.wlPods, + }, + Status: kueue.WorkloadStatus{ + ReclaimablePods: tc.wlReclaimablePods, + }, + }) + + cache := cache.New(utiltesting.NewFakeClient()) + if err := cache.AddClusterQueue(context.Background(), &tc.clusterQueue); err != nil { + t.Fatalf("Failed to add CQ to cache") + } + + flavorMap := map[kueue.ResourceFlavorReference]*kueue.ResourceFlavor{ + "flavor": utiltesting.MakeResourceFlavor("flavor").Obj(), + "deleted-flavor": utiltesting.MakeResourceFlavor("deleted-flavor").Obj(), + } + + // we have to add the deleted flavor to the cache before snapshot, + // or else snapshot will fail + for _, flavor := range flavorMap { + cache.AddOrUpdateResourceFlavor(flavor) + } + clusterQueue := cache.Snapshot().ClusterQueues[tc.clusterQueue.Name] + if clusterQueue == nil { + t.Fatalf("Failed to create CQ snapshot") + } + + // and we delete it + cache.DeleteResourceFlavor(flavorMap["deleted-flavor"]) + delete(flavorMap, "deleted-flavor") + + flvAssigner := New(wlInfo, clusterQueue, flavorMap, false) + + assignment := flvAssigner.Assign(log, nil) + if repMode := assignment.RepresentativeMode(); repMode != tc.wantRepMode { + t.Errorf("e.assignFlavors(_).RepresentativeMode()=%s, want %s", repMode, tc.wantRepMode) + } + + if diff := cmp.Diff(tc.wantAssignment, assignment, cmpopts.IgnoreUnexported(Assignment{}, FlavorAssignment{}), cmpopts.IgnoreFields(Assignment{}, "LastState")); diff != "" { + t.Errorf("Unexpected assignment (-want,+got):\n%s", diff) + } + }) + } +} + func TestLastAssignmentOutdated(t *testing.T) { type args struct { wl *workload.Info From 005c37f5734d9a27bf21718d6d2f7c95307eb8a0 Mon Sep 17 00:00:00 2001 From: Gabe <15304068+gabesaba@users.noreply.github.com> Date: Tue, 2 Jul 2024 10:31:00 +0000 Subject: [PATCH 4/4] Improve readability of test quantities --- .../flavorassigner/flavorassigner_test.go | 374 +++++++++--------- 1 file changed, 187 insertions(+), 187 deletions(-) diff --git a/pkg/scheduler/flavorassigner/flavorassigner_test.go b/pkg/scheduler/flavorassigner/flavorassigner_test.go index 715388e9ed..8aee312979 100644 --- a/pkg/scheduler/flavorassigner/flavorassigner_test.go +++ b/pkg/scheduler/flavorassigner/flavorassigner_test.go @@ -79,7 +79,7 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("default"). - Resource(corev1.ResourceCPU, "1000m"). + Resource(corev1.ResourceCPU, "1"). Resource(corev1.ResourceMemory, "2Mi"). FlavorQuotas, ).ClusterQueue, @@ -93,15 +93,15 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceMemory: {Name: "default", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("1000m"), + corev1.ResourceCPU: resource.MustParse("1"), corev1.ResourceMemory: resource.MustParse("1Mi"), }, Count: 1, }, }, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "default", Resource: corev1.ResourceCPU}: 1000, - {Flavor: "default", Resource: corev1.ResourceMemory}: 1 * 1024 * 1024, + {Flavor: "default", Resource: corev1.ResourceCPU}: 1_000, + {Flavor: "default", Resource: corev1.ResourceMemory}: utiltesting.Mi, }.Unflatten(), }, }, @@ -120,7 +120,7 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("tainted"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, ).ClusterQueue, @@ -132,12 +132,12 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "tainted", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("1000m"), + corev1.ResourceCPU: resource.MustParse("1"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "tainted", Resource: corev1.ResourceCPU}: 1000, + {Flavor: "tainted", Resource: corev1.ResourceCPU}: 1_000, }.Unflatten(), }, }, @@ -150,7 +150,7 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("default"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, ).ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ @@ -164,7 +164,7 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "default", Mode: Preempt, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("2000m"), + corev1.ResourceCPU: resource.MustParse("2"), }, Status: &Status{ reasons: []string{"insufficient unused quota for cpu in flavor default, 1 more needed"}, @@ -172,7 +172,7 @@ func TestAssignFlavors(t *testing.T) { Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "default", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "default", Resource: corev1.ResourceCPU}: 2_000, }.Unflatten(), }, }, @@ -186,10 +186,10 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "2000m"). + Resource(corev1.ResourceCPU, "2"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, ). ResourceGroup( @@ -210,14 +210,14 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceMemory: {Name: "b_one", Mode: Fit, TriedFlavorIdx: 0}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("3000m"), + corev1.ResourceCPU: resource.MustParse("3"), corev1.ResourceMemory: resource.MustParse("10Mi"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "two", Resource: corev1.ResourceCPU}: 3000, - {Flavor: "b_one", Resource: corev1.ResourceMemory}: 10 * 1024 * 1024, + {Flavor: "two", Resource: corev1.ResourceCPU}: 3_000, + {Flavor: "b_one", Resource: corev1.ResourceMemory}: 10 * utiltesting.Mi, }.Unflatten(), }, }, @@ -231,7 +231,7 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "3000m"). + Resource(corev1.ResourceCPU, "3"). FlavorQuotas, ).ResourceGroup( utiltesting.MakeFlavorQuotas("b_one"). @@ -240,14 +240,14 @@ func TestAssignFlavors(t *testing.T) { ).ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 1000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 1_000, }, wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ Name: "main", Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("3000m"), + corev1.ResourceCPU: resource.MustParse("3"), corev1.ResourceMemory: resource.MustParse("10Mi"), }, Status: &Status{ @@ -271,11 +271,11 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "2000m"). + Resource(corev1.ResourceCPU, "2"). Resource(corev1.ResourceMemory, "1Gi"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). Resource(corev1.ResourceMemory, "15Mi"). FlavorQuotas, ).ResourceGroup( @@ -297,15 +297,15 @@ func TestAssignFlavors(t *testing.T) { "example.com/gpu": {Name: "b_one", Mode: Fit, TriedFlavorIdx: 0}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("3000m"), + corev1.ResourceCPU: resource.MustParse("3"), corev1.ResourceMemory: resource.MustParse("10Mi"), "example.com/gpu": resource.MustParse("3"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "two", Resource: corev1.ResourceCPU}: 3000, - {Flavor: "two", Resource: corev1.ResourceMemory}: 10 * 1024 * 1024, + {Flavor: "two", Resource: corev1.ResourceCPU}: 3_000, + {Flavor: "two", Resource: corev1.ResourceMemory}: 10 * utiltesting.Mi, {Flavor: "b_one", Resource: "example.com/gpu"}: 3, }.Unflatten(), }, @@ -321,11 +321,11 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "2000m"). + Resource(corev1.ResourceCPU, "2"). Resource(corev1.ResourceMemory, "1Gi"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). Resource(corev1.ResourceMemory, "15Mi"). FlavorQuotas, ).ResourceGroup( @@ -339,9 +339,9 @@ func TestAssignFlavors(t *testing.T) { }, cohortResources: &cohortResources{ requestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, {Flavor: "one", Resource: corev1.ResourceMemory}: utiltesting.Gi, - {Flavor: "two", Resource: corev1.ResourceCPU}: 4000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 4_000, {Flavor: "two", Resource: corev1.ResourceMemory}: 15 * utiltesting.Mi, {Flavor: "b_one", Resource: "example.com/gpu"}: 4, }, @@ -360,7 +360,7 @@ func TestAssignFlavors(t *testing.T) { "example.com/gpu": {Name: "b_one", Mode: Preempt, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("3000m"), + corev1.ResourceCPU: resource.MustParse("3"), corev1.ResourceMemory: resource.MustParse("10Mi"), "example.com/gpu": resource.MustParse("3"), }, @@ -374,8 +374,8 @@ func TestAssignFlavors(t *testing.T) { Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "two", Resource: corev1.ResourceCPU}: 3000, - {Flavor: "two", Resource: corev1.ResourceMemory}: 10 * 1024 * 1024, + {Flavor: "two", Resource: corev1.ResourceCPU}: 3_000, + {Flavor: "two", Resource: corev1.ResourceMemory}: 10 * utiltesting.Mi, {Flavor: "b_one", Resource: "example.com/gpu"}: 3, }.Unflatten(), }, @@ -390,11 +390,11 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "2000m"). + Resource(corev1.ResourceCPU, "2"). Resource(corev1.ResourceMemory, "1Gi"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). Resource(corev1.ResourceMemory, "5Mi"). FlavorQuotas, ).ClusterQueue, @@ -402,7 +402,7 @@ func TestAssignFlavors(t *testing.T) { PodSets: []PodSetAssignment{{ Name: "main", Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("3000m"), + corev1.ResourceCPU: resource.MustParse("3"), corev1.ResourceMemory: resource.MustParse("10Mi"), }, Status: &Status{ @@ -425,10 +425,10 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("tainted"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, ).ClusterQueue, wantRepMode: Fit, @@ -439,12 +439,12 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "two", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("3000m"), + corev1.ResourceCPU: resource.MustParse("3"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "two", Resource: corev1.ResourceCPU}: 3000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 3_000, }.Unflatten(), }, }, @@ -483,10 +483,10 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, ).ClusterQueue, wantRepMode: Fit, @@ -497,12 +497,12 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "two", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("1000m"), + corev1.ResourceCPU: resource.MustParse("1"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "two", Resource: corev1.ResourceCPU}: 1000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 1_000, }.Unflatten(), }, }, @@ -540,11 +540,11 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). Resource(corev1.ResourceMemory, "1Gi"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). Resource(corev1.ResourceMemory, "1Gi"). FlavorQuotas, ).ClusterQueue, @@ -558,14 +558,14 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceMemory: {Name: "two", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("1000m"), + corev1.ResourceCPU: resource.MustParse("1"), corev1.ResourceMemory: resource.MustParse("1Mi"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "two", Resource: corev1.ResourceCPU}: 1000, - {Flavor: "two", Resource: corev1.ResourceMemory}: 1 * 1024 * 1024, + {Flavor: "two", Resource: corev1.ResourceCPU}: 1_000, + {Flavor: "two", Resource: corev1.ResourceMemory}: utiltesting.Mi, }.Unflatten(), }, }, @@ -614,10 +614,10 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, ).ClusterQueue, @@ -629,12 +629,12 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "one", Mode: Fit, TriedFlavorIdx: 0}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("1000m"), + corev1.ResourceCPU: resource.MustParse("1"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 1000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 1_000, }.Unflatten(), }, }, @@ -670,10 +670,10 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, ).ClusterQueue, @@ -681,7 +681,7 @@ func TestAssignFlavors(t *testing.T) { PodSets: []PodSetAssignment{{ Name: "main", Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("1000m"), + corev1.ResourceCPU: resource.MustParse("1"), }, Status: &Status{ reasons: []string{ @@ -706,10 +706,10 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "10000m"). + Resource(corev1.ResourceCPU, "10"). FlavorQuotas, ).ClusterQueue, @@ -722,7 +722,7 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "two", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("5000m"), + corev1.ResourceCPU: resource.MustParse("5"), }, Count: 1, }, @@ -732,14 +732,14 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "one", Mode: Fit, TriedFlavorIdx: 0}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("3000m"), + corev1.ResourceCPU: resource.MustParse("3"), }, Count: 1, }, }, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 3000, - {Flavor: "two", Resource: corev1.ResourceCPU}: 5000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 3_000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 5_000, }.Unflatten(), }, }, @@ -757,7 +757,7 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("default"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("2000m").BorrowingLimit("98000m").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("2").BorrowingLimit("98").Append(). Resource(corev1.ResourceMemory, "2Gi"). FlavorQuotas, ).Cohort("test-cohort"). @@ -779,7 +779,7 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceMemory: {Name: "default", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("4000m"), + corev1.ResourceCPU: resource.MustParse("4"), corev1.ResourceMemory: resource.MustParse("1Gi"), }, Count: 1, @@ -791,7 +791,7 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceMemory: {Name: "default", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("6000m"), + corev1.ResourceCPU: resource.MustParse("6"), corev1.ResourceMemory: resource.MustParse("4Gi"), }, Count: 1, @@ -799,8 +799,8 @@ func TestAssignFlavors(t *testing.T) { }, Borrowing: true, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "default", Resource: corev1.ResourceCPU}: 10000, - {Flavor: "default", Resource: corev1.ResourceMemory}: 5 * 1024 * 1024 * 1024, + {Flavor: "default", Resource: corev1.ResourceCPU}: 10_000, + {Flavor: "default", Resource: corev1.ResourceMemory}: 5 * utiltesting.Gi, }.Unflatten(), }, }, @@ -813,7 +813,7 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "1000m"). + Resource(corev1.ResourceCPU, "1"). FlavorQuotas, ).Cohort("test-cohort").ClusterQueue, @@ -829,7 +829,7 @@ func TestAssignFlavors(t *testing.T) { PodSets: []PodSetAssignment{{ Name: "main", Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("2000m"), + corev1.ResourceCPU: resource.MustParse("2"), }, Status: &Status{ reasons: []string{"insufficient unused quota in cohort for cpu in flavor one, 1 more needed"}, @@ -848,7 +848,7 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("2000m").BorrowingLimit("8000m").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("2").BorrowingLimit("8").Append(). FlavorQuotas, ).Cohort("test-cohort"). ClusterQueue, @@ -871,7 +871,7 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "one", Mode: Preempt, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("2000m"), + corev1.ResourceCPU: resource.MustParse("2"), }, Status: &Status{ @@ -880,7 +880,7 @@ func TestAssignFlavors(t *testing.T) { Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }.Unflatten(), }, }, @@ -893,7 +893,7 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "2000m"). + Resource(corev1.ResourceCPU, "2"). FlavorQuotas, ).ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ @@ -907,7 +907,7 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "one", Mode: Preempt, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("2000m"), + corev1.ResourceCPU: resource.MustParse("2"), }, Status: &Status{ reasons: []string{"insufficient unused quota for cpu in flavor one, 1 more needed"}, @@ -915,7 +915,7 @@ func TestAssignFlavors(t *testing.T) { Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }.Unflatten(), }, }, @@ -928,7 +928,7 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "3000m"). + Resource(corev1.ResourceCPU, "3"). FlavorQuotas, ).Cohort("test-cohort").ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ @@ -950,7 +950,7 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "one", Mode: Preempt, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("2000m"), + corev1.ResourceCPU: resource.MustParse("2"), }, Status: &Status{ reasons: []string{"insufficient unused quota in cohort for cpu in flavor one, 2 more needed"}, @@ -958,7 +958,7 @@ func TestAssignFlavors(t *testing.T) { Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }.Unflatten(), }, }, @@ -980,15 +980,15 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, ).ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 3000, - {Flavor: "two", Resource: corev1.ResourceCPU}: 3000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 3_000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 3_000, }, wantRepMode: Preempt, wantAssignment: Assignment{ @@ -998,7 +998,7 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "two", Mode: Preempt, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("2000m"), + corev1.ResourceCPU: resource.MustParse("2"), }, Status: &Status{ reasons: []string{ @@ -1009,7 +1009,7 @@ func TestAssignFlavors(t *testing.T) { Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "two", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 2_000, }.Unflatten(), }, }, @@ -1031,15 +1031,15 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, utiltesting.MakeFlavorQuotas("tainted"). - Resource(corev1.ResourceCPU, "10000m"). + Resource(corev1.ResourceCPU, "10"). FlavorQuotas, ).ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 3000, - {Flavor: "tainted", Resource: corev1.ResourceCPU}: 3000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 3_000, + {Flavor: "tainted", Resource: corev1.ResourceCPU}: 3_000, }, wantRepMode: Preempt, wantAssignment: Assignment{ @@ -1050,7 +1050,7 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "one", Mode: Preempt, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("2000m"), + corev1.ResourceCPU: resource.MustParse("2"), }, Status: &Status{ reasons: []string{ @@ -1066,7 +1066,7 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "tainted", Mode: Preempt, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("10000m"), + corev1.ResourceCPU: resource.MustParse("10"), }, Status: &Status{ reasons: []string{ @@ -1078,8 +1078,8 @@ func TestAssignFlavors(t *testing.T) { }, }, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, - {Flavor: "tainted", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, + {Flavor: "tainted", Resource: corev1.ResourceCPU}: 10_000, }.Unflatten(), }, }, @@ -1092,7 +1092,7 @@ func TestAssignFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - Resource(corev1.ResourceCPU, "4000m"). + Resource(corev1.ResourceCPU, "4"). FlavorQuotas, ).ClusterQueue, wantAssignment: Assignment{ @@ -1119,7 +1119,7 @@ func TestAssignFlavors(t *testing.T) { ResourceGroup( utiltesting.MakeFlavorQuotas("default"). Resource(corev1.ResourcePods, "3"). - Resource(corev1.ResourceCPU, "10000m"). + Resource(corev1.ResourceCPU, "10"). FlavorQuotas, ).ClusterQueue, @@ -1132,14 +1132,14 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourcePods: &FlavorAssignment{Name: "default", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("3000m"), + corev1.ResourceCPU: resource.MustParse("3"), corev1.ResourcePods: resource.MustParse("3"), }, Count: 3, }}, Usage: resources.FlavorResourceQuantitiesFlat{ {Flavor: "default", Resource: corev1.ResourcePods}: 3, - {Flavor: "default", Resource: corev1.ResourceCPU}: 3000, + {Flavor: "default", Resource: corev1.ResourceCPU}: 3_000, }.Unflatten(), }, wantRepMode: Fit, @@ -1154,7 +1154,7 @@ func TestAssignFlavors(t *testing.T) { ResourceGroup( utiltesting.MakeFlavorQuotas("default"). Resource(corev1.ResourcePods, "2"). - Resource(corev1.ResourceCPU, "10000m"). + Resource(corev1.ResourceCPU, "10"). FlavorQuotas, ).ClusterQueue, @@ -1162,7 +1162,7 @@ func TestAssignFlavors(t *testing.T) { PodSets: []PodSetAssignment{{ Name: "main", Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("3000m"), + corev1.ResourceCPU: resource.MustParse("3"), corev1.ResourcePods: resource.MustParse("3"), }, Status: &Status{ @@ -1189,7 +1189,7 @@ func TestAssignFlavors(t *testing.T) { ResourceGroup( utiltesting.MakeFlavorQuotas("default"). Resource(corev1.ResourcePods, "3"). - Resource(corev1.ResourceCPU, "10000m"). + Resource(corev1.ResourceCPU, "10"). FlavorQuotas, ).ClusterQueue, wantAssignment: Assignment{ @@ -1201,14 +1201,14 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourcePods: &FlavorAssignment{Name: "default", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("3000m"), + corev1.ResourceCPU: resource.MustParse("3"), corev1.ResourcePods: resource.MustParse("3"), }, Count: 3, }}, Usage: resources.FlavorResourceQuantitiesFlat{ {Flavor: "default", Resource: corev1.ResourcePods}: 3, - {Flavor: "default", Resource: corev1.ResourceCPU}: 3000, + {Flavor: "default", Resource: corev1.ResourceCPU}: 3_000, }.Unflatten(), }, wantRepMode: Fit, @@ -1224,15 +1224,15 @@ func TestAssignFlavors(t *testing.T) { ResourceGroup( utiltesting.MakeFlavorQuotas("one"). Resource(corev1.ResourcePods, "10"). - Resource(corev1.ResourceCPU, "10000m"). + Resource(corev1.ResourceCPU, "10"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). Resource(corev1.ResourcePods, "10"). - Resource(corev1.ResourceCPU, "10000m"). + Resource(corev1.ResourceCPU, "10"). FlavorQuotas, ).ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }, wantRepMode: Preempt, wantAssignment: Assignment{ @@ -1243,7 +1243,7 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourcePods: {Name: "one", Mode: Fit, TriedFlavorIdx: 0}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("9000m"), + corev1.ResourceCPU: resource.MustParse("9"), corev1.ResourcePods: resource.MustParse("1"), }, Status: &Status{ @@ -1252,7 +1252,7 @@ func TestAssignFlavors(t *testing.T) { Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: "cpu"}: 9000, + {Flavor: "one", Resource: "cpu"}: 9_000, {Flavor: "one", Resource: "pods"}: 1, }.Unflatten(), }, @@ -1267,15 +1267,15 @@ func TestAssignFlavors(t *testing.T) { ResourceGroup( utiltesting.MakeFlavorQuotas("one"). Resource(corev1.ResourcePods, "10"). - Resource(corev1.ResourceCPU, "10000m"). + Resource(corev1.ResourceCPU, "10"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). Resource(corev1.ResourcePods, "10"). - Resource(corev1.ResourceCPU, "10000m"). + Resource(corev1.ResourceCPU, "10"). FlavorQuotas, ).ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }, wantRepMode: Fit, wantAssignment: Assignment{ @@ -1286,13 +1286,13 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourcePods: {Name: "two", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("9000m"), + corev1.ResourceCPU: resource.MustParse("9"), corev1.ResourcePods: resource.MustParse("1"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "two", Resource: "cpu"}: 9000, + {Flavor: "two", Resource: "cpu"}: 9_000, {Flavor: "two", Resource: "pods"}: 1, }.Unflatten(), }, @@ -1308,25 +1308,25 @@ func TestAssignFlavors(t *testing.T) { ResourceGroup( utiltesting.MakeFlavorQuotas("one"). Resource(corev1.ResourcePods, "10"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").BorrowingLimit("1000m").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10").BorrowingLimit("1").Append(). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). Resource(corev1.ResourcePods, "10"). - Resource(corev1.ResourceCPU, "1000m"). + Resource(corev1.ResourceCPU, "1"). FlavorQuotas, ).Cohort("test-cohort"). ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }, cohortResources: &cohortResources{ usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }, requestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 11_000, {Flavor: "one", Resource: corev1.ResourcePods}: 10, - {Flavor: "two", Resource: corev1.ResourceCPU}: 1000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 1_000, {Flavor: "two", Resource: corev1.ResourcePods}: 10, }, }, @@ -1340,13 +1340,13 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourcePods: {Name: "one", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("9000m"), + corev1.ResourceCPU: resource.MustParse("9"), corev1.ResourcePods: resource.MustParse("1"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 9000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 9_000, {Flavor: "one", Resource: corev1.ResourcePods}: 1, }.Unflatten(), }, @@ -1362,26 +1362,26 @@ func TestAssignFlavors(t *testing.T) { ResourceGroup( utiltesting.MakeFlavorQuotas("one"). Resource(corev1.ResourcePods, "10"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").BorrowingLimit("1000m").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10").BorrowingLimit("1").Append(). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). Resource(corev1.ResourcePods, "10"). - Resource(corev1.ResourceCPU, "10000m"). + Resource(corev1.ResourceCPU, "10"). FlavorQuotas, ).Cohort("test-cohort"). ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }, cohortResources: &cohortResources{ usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }, requestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 11_000, {Flavor: "one", Resource: corev1.ResourcePods}: 10, - {Flavor: "two", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 10_000, {Flavor: "two", Resource: corev1.ResourcePods}: 10, }, }, @@ -1394,13 +1394,13 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourcePods: {Name: "two", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("9000m"), + corev1.ResourceCPU: resource.MustParse("9"), corev1.ResourcePods: resource.MustParse("1"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "two", Resource: corev1.ResourceCPU}: 9000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 9_000, {Flavor: "two", Resource: corev1.ResourcePods}: 1, }.Unflatten(), }, @@ -1415,26 +1415,26 @@ func TestAssignFlavors(t *testing.T) { ResourceGroup( utiltesting.MakeFlavorQuotas("one"). Resource(corev1.ResourcePods, "10"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").BorrowingLimit("1000m").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10").BorrowingLimit("1").Append(). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). Resource(corev1.ResourcePods, "10"). - Resource(corev1.ResourceCPU, "10000m"). + Resource(corev1.ResourceCPU, "10"). FlavorQuotas, ).Cohort("test-cohort"). ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }, cohortResources: &cohortResources{ usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }, requestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 11_000, {Flavor: "one", Resource: corev1.ResourcePods}: 10, - {Flavor: "two", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 10_000, {Flavor: "two", Resource: corev1.ResourcePods}: 10, }, }, @@ -1448,13 +1448,13 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourcePods: {Name: "one", Mode: Fit, TriedFlavorIdx: 0}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("9000m"), + corev1.ResourceCPU: resource.MustParse("9"), corev1.ResourcePods: resource.MustParse("1"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: "cpu"}: 9000, + {Flavor: "one", Resource: "cpu"}: 9_000, {Flavor: "one", Resource: "pods"}: 1, }.Unflatten(), }, @@ -1478,20 +1478,20 @@ func TestAssignFlavors(t *testing.T) { }). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("0").BorrowingLimit("12000m").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("0").BorrowingLimit("12").Append(). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "12000m"). + Resource(corev1.ResourceCPU, "12"). FlavorQuotas, ).Cohort("test-cohort").ClusterQueue, cohortResources: &cohortResources{ usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, }, requestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 12000, - {Flavor: "two", Resource: corev1.ResourceCPU}: 12000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 12_000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 12_000, }, }, wantRepMode: Preempt, @@ -1506,12 +1506,12 @@ func TestAssignFlavors(t *testing.T) { reasons: []string{"insufficient unused quota in cohort for cpu in flavor one, 10 more needed"}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("12000m"), + corev1.ResourceCPU: resource.MustParse("12"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 12000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 12_000, }.Unflatten(), }, }, @@ -1537,16 +1537,16 @@ func TestAssignFlavors(t *testing.T) { Resource(corev1.ResourceCPU, "0"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "12000m"). + Resource(corev1.ResourceCPU, "12"). FlavorQuotas, ).Cohort("test-cohort").ClusterQueue, cohortResources: &cohortResources{ usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, }, requestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 12000, - {Flavor: "two", Resource: corev1.ResourceCPU}: 12000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 12_000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 12_000, }, }, wantRepMode: Preempt, @@ -1561,12 +1561,12 @@ func TestAssignFlavors(t *testing.T) { reasons: []string{"insufficient unused quota in cohort for cpu in flavor one, 10 more needed"}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("12000m"), + corev1.ResourceCPU: resource.MustParse("12"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 12000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 12_000, }.Unflatten(), }, }, @@ -1589,20 +1589,20 @@ func TestAssignFlavors(t *testing.T) { }). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("0").BorrowingLimit("12000m").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("0").BorrowingLimit("12").Append(). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "12000m"). + Resource(corev1.ResourceCPU, "12"). FlavorQuotas, ).Cohort("test-cohort"). ClusterQueue, cohortResources: &cohortResources{ usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, }, requestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 12000, - {Flavor: "two", Resource: corev1.ResourceCPU}: 12000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 12_000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 12_000, }, }, wantRepMode: Fit, @@ -1613,12 +1613,12 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "two", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("12000m"), + corev1.ResourceCPU: resource.MustParse("12"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "two", Resource: corev1.ResourceCPU}: 12000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 12_000, }.Unflatten(), }, }, @@ -1637,17 +1637,17 @@ func TestAssignFlavors(t *testing.T) { }). ResourceGroup( utiltesting.MakeFlavorQuotas("one"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("0").BorrowingLimit("12000m").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("0").BorrowingLimit("12").Append(). FlavorQuotas, ).Cohort("test-cohort").ClusterQueue, cohortResources: &cohortResources{ usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, }, requestableResources: resources.FlavorResourceQuantitiesFlat{ { // below the borrowingLimit required to admit - Flavor: "one", Resource: corev1.ResourceCPU}: 11000, + Flavor: "one", Resource: corev1.ResourceCPU}: 11_000, }, }, wantRepMode: NoFit, @@ -1660,7 +1660,7 @@ func TestAssignFlavors(t *testing.T) { reasons: []string{"insufficient unused quota in cohort for cpu in flavor one, 11 more needed"}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("12000m"), + corev1.ResourceCPU: resource.MustParse("12"), }, Count: 1, }, @@ -1678,25 +1678,25 @@ func TestAssignFlavors(t *testing.T) { ResourceGroup( utiltesting.MakeFlavorQuotas("one"). Resource(corev1.ResourcePods, "10"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").LendingLimit("1000m").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10").LendingLimit("1").Append(). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). Resource(corev1.ResourcePods, "10"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").LendingLimit("0").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10").LendingLimit("0").Append(). FlavorQuotas, ).Cohort("test-cohort"). ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }, cohortResources: &cohortResources{ usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }, requestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 11_000, {Flavor: "one", Resource: corev1.ResourcePods}: 10, - {Flavor: "two", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 10_000, {Flavor: "two", Resource: corev1.ResourcePods}: 10, }, }, @@ -1709,13 +1709,13 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourcePods: {Name: "two", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("9000m"), + corev1.ResourceCPU: resource.MustParse("9"), corev1.ResourcePods: resource.MustParse("1"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "two", Resource: corev1.ResourceCPU}: 9000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 9_000, {Flavor: "two", Resource: corev1.ResourcePods}: 1, }.Unflatten(), }, @@ -1732,25 +1732,25 @@ func TestAssignFlavors(t *testing.T) { ResourceGroup( utiltesting.MakeFlavorQuotas("one"). Resource(corev1.ResourcePods, "10"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").LendingLimit("1000m").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10").LendingLimit("1").Append(). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). Resource(corev1.ResourcePods, "10"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("1000m").LendingLimit("0").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("1").LendingLimit("0").Append(). FlavorQuotas, ).Cohort("test-cohort"). ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }, cohortResources: &cohortResources{ usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }, requestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 11000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 11_000, {Flavor: "one", Resource: corev1.ResourcePods}: 10, - {Flavor: "two", Resource: corev1.ResourceCPU}: 1000, + {Flavor: "two", Resource: corev1.ResourceCPU}: 1_000, {Flavor: "two", Resource: corev1.ResourcePods}: 10, }, }, @@ -1763,14 +1763,14 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourcePods: {Name: "one", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("9000m"), + corev1.ResourceCPU: resource.MustParse("9"), corev1.ResourcePods: resource.MustParse("1"), }, Count: 1, }}, Borrowing: true, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 9000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 9_000, {Flavor: "one", Resource: corev1.ResourcePods}: 1, }.Unflatten(), }, @@ -1786,18 +1786,18 @@ func TestAssignFlavors(t *testing.T) { ResourceGroup( utiltesting.MakeFlavorQuotas("one"). Resource(corev1.ResourcePods, "10"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10000m").LendingLimit("0").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("10").LendingLimit("0").Append(). FlavorQuotas, ).Cohort("test-cohort").ClusterQueue, clusterQueueUsage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 2000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 2_000, }, cohortResources: &cohortResources{ usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, }, requestableResources: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 10000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 10_000, {Flavor: "one", Resource: corev1.ResourcePods}: 10, }, }, @@ -1810,7 +1810,7 @@ func TestAssignFlavors(t *testing.T) { corev1.ResourcePods: {Name: "one", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("9000m"), + corev1.ResourceCPU: resource.MustParse("9"), corev1.ResourcePods: resource.MustParse("1"), }, Status: &Status{ @@ -1819,7 +1819,7 @@ func TestAssignFlavors(t *testing.T) { Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 9000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 9_000, {Flavor: "one", Resource: corev1.ResourcePods}: 1, }.Unflatten(), }, @@ -1840,7 +1840,7 @@ func TestAssignFlavors(t *testing.T) { Resource(corev1.ResourceCPU, "0"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "12000m"). + Resource(corev1.ResourceCPU, "12"). FlavorQuotas, ).Cohort("test-cohort").ClusterQueue, cohortResources: &cohortResources{ @@ -1869,7 +1869,7 @@ func TestAssignFlavors(t *testing.T) { Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "one", Resource: corev1.ResourceCPU}: 12000, + {Flavor: "one", Resource: corev1.ResourceCPU}: 12_000, }.Unflatten(), }, }, @@ -1888,7 +1888,7 @@ func TestAssignFlavors(t *testing.T) { Resource(corev1.ResourceCPU, "0"). FlavorQuotas, utiltesting.MakeFlavorQuotas("two"). - Resource(corev1.ResourceCPU, "12000m"). + Resource(corev1.ResourceCPU, "12"). FlavorQuotas, ).Cohort("test-cohort").ClusterQueue, cohortResources: &cohortResources{ @@ -1988,10 +1988,10 @@ func TestDeletedFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("deleted-flavor"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("4000m").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("4").Append(). FlavorQuotas, utiltesting.MakeFlavorQuotas("flavor"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("4000m").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("4").Append(). FlavorQuotas, ).ClusterQueue, wantRepMode: Fit, @@ -2002,12 +2002,12 @@ func TestDeletedFlavors(t *testing.T) { corev1.ResourceCPU: {Name: "flavor", Mode: Fit, TriedFlavorIdx: -1}, }, Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("3000m"), + corev1.ResourceCPU: resource.MustParse("3"), }, Count: 1, }}, Usage: resources.FlavorResourceQuantitiesFlat{ - {Flavor: "flavor", Resource: corev1.ResourceCPU}: 3000, + {Flavor: "flavor", Resource: corev1.ResourceCPU}: 3_000, }.Unflatten(), }, }, @@ -2020,14 +2020,14 @@ func TestDeletedFlavors(t *testing.T) { clusterQueue: utiltesting.MakeClusterQueue("test-clusterqueue"). ResourceGroup( utiltesting.MakeFlavorQuotas("deleted-flavor"). - ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("4000m").Append(). + ResourceQuotaWrapper(corev1.ResourceCPU).NominalQuota("4").Append(). FlavorQuotas, ).ClusterQueue, wantAssignment: Assignment{ PodSets: []PodSetAssignment{{ Name: "main", Requests: corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("1000m"), + corev1.ResourceCPU: resource.MustParse("1"), }, Status: &Status{ reasons: []string{"flavor deleted-flavor not found"},