-
Notifications
You must be signed in to change notification settings - Fork 16
[java] implement performance support in session #270
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
base: main
Are you sure you want to change the base?
Conversation
f85c1ad
to
436fdfa
Compare
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 like this approach
PerformanceResults results = session.performance().getResults();
I think that the API usage makes sense and I also like having the performance stored in a separate object Performance
.
java/main/src/main/java/com/saucelabs/saucebindings/performance/Performance.java
Show resolved
Hide resolved
@@ -0,0 +1,6 @@ | |||
"https://www.saucedemo.com": |
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.
@titusfortner can you please explain what this is and it's intended usage?
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.
So, for JS they use JSON; I wanted to implement something that uses a Map, so you can convert either yaml or json into the map it will work. I didn't want to use JSON because I don't want to deal with Jackson library, yet. :) More info: https://docs.saucelabs.com/performance/transitions#defining-a-performance-budget
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.
@titusfortner I worry that this feature is unnecessarily making the code complicated and overengineered. From my experience, customers aren't advanced enough to handle such a use case (or even me 😂). Instead they are only interested in 3 use cases. Specifically they like multiPagePerformanceExample()
and the simplePerformanceTest()
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.
Yeah, We have docs for it with code examples, so I thought we should provide support for it. I'm not sure how much it would be used. I had some thoughts on expanding it later, but definitely not the thing that should be holding us up.
This is the kind of feature I wouldn't make an issue out of in the Sauce Bindings Documentation, but would have example code in the Sauce Docs with it for people who are interested in playing with it. As such, the confusion factor of the average user shouldn't really matter. It's the same kind of thing with the mergeCapabilities()
in SauceOptions.
java/main/src/test/java/com/saucelabs/saucebindings/integration/PerformanceTest.java
Show resolved
Hide resolved
public void performanceDetails() { | ||
driver.get("https://www.saucedemo.com"); | ||
|
||
PerformanceMetrics performanceMetrics = session.performance().getMetrics(); |
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.
This confuses me. I don't understand the difference between a PerformanceMetrics
and PerformanceResults
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.
Maybe we rename PerformanceMetrics to PerformanceLog.
PerformanceResults uses Sauce Labs magic AI values. You can pass in specific metrics you care about and Sauce will pass/fail it based on whether we think it is in range.
If you want to assert on anything based on a hard coded value instead of our magic, you need to first get the log.
I mean, maybe this should be:
PerformanceLogs performanceLogs = session.logs().getPerformance();
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.
Makes sense. The API call would be what you said or session.performance().getLogs()
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.
The other part of this is that it isn't all the logs, just the logs for the last page transition. session.logs()
should be getting all the logs for something, so maybe session.performance().getLastLog()
?
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.
@titusfortner so if it's just for the last page transition then maybe?
session.performance().getLastPageTransitionLog()
java/main/src/test/java/com/saucelabs/saucebindings/integration/PerformanceTest.java
Show resolved
Hide resolved
public void performanceMetricResults() { | ||
driver.get("https://www.saucedemo.com"); | ||
|
||
PerformanceResults performanceResults = session.performance().getResults("firstInteractive"); |
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.
@titusfortner should we move the parameter values into an enum? They've remained the same forever and it should improve usability
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.
Yeah, so long as we have getRawResults()
I don't think there's a problem doing enums for this.
@@ -75,6 +77,13 @@ public Results getAccessibilityResults(AxeBuilder builder) { | |||
return builder.analyze(driver); | |||
} | |||
|
|||
public Performance performance() { | |||
if (!sauceOptions.sauce().getCapturePerformance()) { |
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.
what does this do for non-Chrome which doesn't have this method?
* | ||
* @param metrics A List of values for which performance metrics to evaluate | ||
* @return PerformanceResults is a wrapper of the HashMap results to make it easier to work with them | ||
* @see <a href="https://docs.saucelabs.com/performance/transitions#implementing-the-performance-command-assertion">Implementing the Performance Command Assertion</a> |
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 links are wrong for anchors, they need to be /#
without index.html
/** | ||
* This measures the performance output against a baseline of previously accepted performance values | ||
* | ||
* @return PerformanceResults is a wrapper of the HashMap results to make it easier to work with them |
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.
specify this is passed
, reason
, and details
* @return PerformanceResults is a wrapper of the HashMap results to make it easier to work with them | ||
* @see <a href="https://docs.saucelabs.com/performance/transitions#implementing-the-performance-command-assertion">Implementing the Performance Command Assertion</a> | ||
*/ | ||
public PerformanceResults getResults() { |
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.
probably needs to be getAllResults()
to better differentiate from other method
Three options here.
The one I did for Accessibility was like:
The one that is probably "most Java" is:
The one I implemented here is:
Thoughts/Preferences?