-
Notifications
You must be signed in to change notification settings - Fork 18
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
test: add ThreadSchedTests #47
Conversation
verifies parsed procfiles are correctly read into TidKVMap adds VisibleForTesting methods to ThreadSched Signed-off-by: Kartavya Vashishtha <[email protected]>
i.e. added testing for calculateSchedLatency Signed-off-by: Kartavya Vashishtha <[email protected]>
71d086a
to
7cb3cae
Compare
@@ -37,6 +39,27 @@ public static class SchedMetrics { | |||
this.contextSwitchRate = contextSwitchRate; | |||
} | |||
|
|||
@Override | |||
public int hashCode() { |
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.
Why are those functions needed? Also if these functions will only be used in the unit tests, let's try adding some similar util functions in the test itself instead of adding new functions for the class.
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.
These functions are used to implement equality, which is used to verify that the setSchedMetric
is called with a ThreadSched.SchedMetrics
that has the correct values.
i.e.
verify(linuxSchedMetricsGenerator)
.setSchedMetric("3", new ThreadSched.SchedMetrics(0.002, 0.002, 100.0));
Would you prefer something that uses the Reflection API instead?
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.
@ansjcy Does that explain why I implemented equality?
return schedLatencyMap; | ||
} | ||
|
||
@VisibleForTesting | ||
public Map<String, Map<String, Object>> getTidKVMap() { |
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.
I think we can keep this one to verify the TidKVMap.
|
||
@RunWith(PowerMockRunner.class) | ||
@PowerMockIgnore("javax.management.*") | ||
@SuppressStaticInitializationFor({"org.opensearch.performanceanalyzer.commons.os.OSGlobals"}) |
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.
Nice! it make perfect sense to avoid initializing the static classes imported from this class.
Let's add the output of the unit test in the PR description as well. |
Running
Is this what you meant by that? Or is it pasting the assertions that the unit test makes about the class being tested? |
Alternatives to implementing
Out of which implementing equality seemed the simplest. Turns out the test class does not meet the requirements to access a private member of |
Is your feature request related to a problem? Please provide an existing Issue # , or describe.
Add tests for
os/ThreadSched.java
.Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.