Repository navigation
test(scheduler): add unit tests for YuniKorn resource usage calculations - #3231
vikas-saxena02 wants to merge 6 commits into
Conversation
|
In general we should match the behaviour Java has? |
|
@nabuskey @vjanelle @tariq-hasan While reviewing this PR with Claude, it flagged that 1. Scala applications get a different overhead factor. 2. The webhook's byte parser is unanchored. 3. Fractional memory values are unreachable. 4. None of this is covered. @vjanelle this may be the same question you raised about matching Java's behaviour — the off-heap string comparison looks like one instance of a broader pattern rather than a one-off. Happy to open an issue for the behaviour differences, and to follow up with tests for |
76033c2 to
081da4e
Compare
|
/approve |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: vjanelle The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
New changes are detected. LGTM label has been removed. |
Signed-off-by: Vikas Saxena <Vikas.Saxena.2006@gmail.com>
Signed-off-by: Vikas Saxena <Vikas.Saxena.2006@gmail.com>
Signed-off-by: Vikas Saxena <Vikas.Saxena.2006@gmail.com>
Signed-off-by: Vikas Saxena <Vikas.Saxena.2006@gmail.com>
Signed-off-by: Vikas Saxena <Vikas.Saxena.2006@gmail.com>
7219994 to
053c48f
Compare
…file Signed-off-by: Vikas Saxena <Vikas.Saxena.2006@gmail.com>
Purpose of this PR
internal/scheduler/yunikorn/resourceusagehad 16.5% statement coverage. OnlybyteStringAsBytes,bytesToMiandcpuRequesthad direct tests. The entire memory calculation chain — the part that decides what CPU and memory YuniKorn actually reserves for driver and executor pods — was exercised only indirectly, throughTestSchedulein the parent package.This adds direct table tests for that chain. Coverage goes from 16.5% to 97.8%. No production code is touched.
Part of #3202.
Proposed changes:
memory_test.goforisJavaApp,getMemoryOverheadFactor,memoryRequestBytes,executorPysparkMemoryBytes,sparkOffHeapMemoryBytes,driverMemoryRequestandexecutorMemoryRequest, including their error paths.resource_usage_test.goforDriverPodRequestsandExecutorPodRequests, covering defaults,coreRequestprecedence overcores, and error propagation.Change Category
Rationale
These functions encode Spark's memory-overhead semantics, which are easy to get wrong and currently unpinned by any test. The cases added lock down:
memoryOverheadandmemoryOverheadFactorover the type-derived defaults;spark.executor.pyspark.memory, matching Spark's documented behaviour;BasicDriverFeatureStep/BasicExecutorFeatureStep.Expected values were derived from the Spark semantics rather than from current output, so these are regression tests, not a snapshot of existing behaviour.
Checklist
Additional Notes
Local run:
The residual ~2% is the
strconv.ParseInterror branch inbyteStringAsBytes, which is unreachable because the preceding regex already guarantees the capture group is digits.@nabuskey @vjanelle @tariq-hasan One observation found while writing these, not addressed here:
sparkOffHeapMemoryBytescomparesspark.memory.offHeap.enabledagainst the exact string"false", so"False"or"FALSE"would be treated as enabled. Spark parses this case-insensitively. I deliberately did not add a test for it, since that would pin the current behaviour rather than flag it. Happy to open a separate issue if maintainers agree it's worth fixing.