PoiBlackTea commented on code in PR #1107:
URL: https://github.com/apache/yunikorn-core/pull/1107#discussion_r3666480070
##########
pkg/scheduler/objects/queue_test.go:
##########
@@ -3590,6 +3590,18 @@ func TestQueue_setPreemptionTime(t *testing.T) {
{"max lowered again",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"},
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 110}), 10,
10, true, false},
{"max lowered again but usage is lesser than newer max",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"},
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 5}), 10, 10,
true, true},
{"max lowered again 2nd",
resources.NewResourceFromMap(map[string]resources.Quantity{"test": 100}),
map[string]string{"test": "10"}, nil, 10, 5, true, true},
+ {"res type in max not in usage - usage below max",
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 100000,
"memory": 1000}), map[string]string{"vcore": "100", "memory": "1000"},
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 50000}), 0,
10, false, false},
+ {"res type in max not in usage - usage exceeds max",
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 100000,
"memory": 1000}), map[string]string{"vcore": "100", "memory": "1000"},
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 150000}),
0, 10, false, true},
+ {"res type in usage not in max - usage below max",
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 100000}),
map[string]string{"vcore": "100"},
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 50000,
"memory": 500}), 0, 10, false, false},
+ {"res type in usage not in max - usage exceeds max",
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 100000}),
map[string]string{"vcore": "100"},
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 150000,
"memory": 500}), 0, 10, false, true},
+ {"disjoint res types between max and usage",
resources.NewResourceFromMap(map[string]resources.Quantity{"gpu": 2}),
map[string]string{"gpu": "2"},
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 50000,
"memory": 500}), 0, 10, false, false},
+ {"multi res types - one exceeds, one below",
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 100000,
"memory": 1000}), map[string]string{"vcore": "100", "memory": "1000"},
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 50000,
"memory": 1500}), 0, 10, false, true},
+ {"multi res types - quota lowered for one type",
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 100000,
"memory": 1000}), map[string]string{"vcore": "50", "memory": "1000"},
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 80000,
"memory": 500}), 10, 10, false, true},
+ {"multi res types - disjoint oldMax and max res",
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 100000,
"memory": 1000}), map[string]string{"gpu": "2"},
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 50000,
"memory": 500}), 10, 10, false, false},
+ {"multi res types - oldMax strictly greater than max across
types", resources.NewResourceFromMap(map[string]resources.Quantity{"vcore":
100000, "memory": 2000}), map[string]string{"vcore": "50", "memory": "1000"},
resources.NewResourceFromMap(map[string]resources.Quantity{"vcore": 80000,
"memory": 1500}), 10, 10, false, true},
Review Comment:
Hi @manirajv06 , thanks for the feedback.
I added these test cases to cover multi-resource vectors and type mismatches
not addressed by legacy single-resource tests.
Also, string CPU values (e.g., "100") parse into milli-vcores (100000),
which might look similar to single-resource tests at a glance. My focus here is
on multi-resource vector behavior:
- Disjoint: Quota set on gpu while usage contains vcore+memory.
- Partial Violation: 1 resource type exceeds quota while others stay below.
- Vector Lowering: Multi-resource dominance checking in
StrictlyGreaterThan(oldMax, newMax).
Please let me know if my rationale makes sense or if you have suggestions.
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]