-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[YUNIKORN-2997] add unit test for tryPlaceholderAllocate #1004
Conversation
No code coverage report as the previous commit was a non code change (e2e test change) The commit did not submit a coverage report to diff against. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kousei47747, thanks for the nice patch.
Could we add one more test case to cover the path "allocate placeholder to non-placeholder node"? It occurs when node.preReserveConditions(request) != nil.
-
if node != nil && node.preReserveConditions(request) == nil { -
yunikorn-core/pkg/scheduler/objects/application.go
Lines 1261 to 1276 in 149820f
// allocation worked: on a non placeholder node update resultType and return // double link to make it easier to find // alloc (the real one) releases points to the placeholder in the releases list reqFit.SetRelease(phFit) // placeholder point to the real one in the releases list phFit.SetRelease(reqFit) // mark placeholder as released phFit.SetReleased(true) // bind node here so it will be handled properly upon replacement reqFit.SetBindTime(time.Now()) reqFit.SetNodeID(node.NodeID) reqFit.SetInstanceType(node.GetInstanceType()) result := newReplacedAllocationResult(node.NodeID, reqFit) allocResult = result return false
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1004 +/- ##
==========================================
+ Coverage 81.97% 82.15% +0.17%
==========================================
Files 97 97
Lines 15621 15621
==========================================
+ Hits 12806 12833 +27
+ Misses 2537 2510 -27
Partials 278 278 ☔ View full report in Codecov by Sentry. |
@chenyulin0719 thanks for reviewing! I've added the test case, please check. yunikorn-core/pkg/scheduler/objects/application_test.go Lines 3557 to 3598 in a2829b0
|
assertPlaceholderData(t, app, tg1, 1, 0, 0, res) | ||
|
||
// predicate check fails on node1 and passes on node2 | ||
mockPlugin := mockCommon.NewPredicatePlugin(false, map[string]int{nodeID1: 0}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the beginning, I'm confused about why using {nodeID1: 0}) (fail always)
instead of {nodeID1: -1}) (fail reserve)
. After rethinking it, I realize it's reasonable because if we set {nodeID1: -1})
, nodeID1
will be picked again in the following try all nodes
check , the preAllocateCheck() will pass.
So it make sense to me now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM +1
Closes: apache#1004 Signed-off-by: Yu-Lin Chen <[email protected]> (cherry picked from commit a351764)
What is this PR for?
Add unit test for tryPlaceholderAllocate, including 4 test cases:
What type of PR is it?
What is the Jira issue?
https://issues.apache.org/jira/browse/YUNIKORN-2997