-
Notifications
You must be signed in to change notification settings - Fork 340
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
[JENKINS-37598] Inaccurate aggregation of multiple xmls containing case information about the same testsuite #54
Conversation
// retrieve the class duration from these cases' suite time | ||
duration = 0; | ||
for (SuiteResult s : suites) { | ||
duration += s.getDuration(); |
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.
Seems like the simpler patch would just be
-if(duration == 0){
- duration = r.getSuiteResult().getDuration();
-}
+duration += r.getSuiteResult().getDuration();
right?
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.
BTW neither of the test cases seem to check that
<testsuites name="Automation Tests" tests="2" errors="0" failures="0" ignored="0">
<testsuite name="test.fs.FileSystemTests">
<testcase name="testPrefix1" classname="test.fs.FileSystemTest1" time="10"/>
<testcase name="testPrefix1" classname="test.fs.FileSystemTest2" time="10"/>
</testsuite>
<testsuite name="test.fs.FileSystemTests">
<testcase name="testPrefix2" classname="test.fs.FileSystemTest1" time="10"/>
</testsuite>
</testsuites>
sums to 30.
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'm afraid not...and a change like that would be caught by the one of my new tests
in case not...i should add a case for this too ;)
..the for cycle is running thru cases...and the old trick was to only use the case runtime when the total is 0...the new code collects all the unique suites and aggregates there sum time
I've updated the testcases - should I squash my changes - instead of adding more commits? About the mixed cases - i can detect it...but not sure what to do when that happens...throw an exception; or insert a "notice testcase" into the unit results?
|
No need to do it. GitHub allows squashing during the merge
Exception is unlikely a good approach. I would merge with warning |
c27b280
to
0ddde97
Compare
@oleg-nenashev i've updated the changes; and included an exception for the mixed case (plus a test case for this mixed case too) cheers |
@oleg-nenashev: Can you please take a look at the updated changes? |
@oleg-nenashev can you please take a look at this change? |
@kgyrtkirk sorry, I was snowed under the stuff. Will try to review today. |
…e information about the same testsuite
0ddde97
to
8f3473b
Compare
@jglick @oleg-nenashev - i've fixed the merge-conflict. |
@@ -72,8 +72,8 @@ | |||
/** Optional ID attribute of a test suite. E.g., Eclipse plug-ins tests always have the name 'tests' but a different id. **/ | |||
private String id; | |||
|
|||
/** Optional time attribute of a test suite. E.g., Suites can use their own time attribute or the sum of their cases' times as before.**/ | |||
private String time; |
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.
If the class is being persisted on the disk, it requires a migration logic in readResolve()
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.
Removal of this field will probably result in old data warnings. Should be made deprecated and transient 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.
Oh...I wasn't aware of this; in this case I think the best would be to live with existing 'time' field; and use it
/** | ||
* Merges another SuiteResult into this one. | ||
* | ||
* @param sr |
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.
If you define the parameter in Javadoc, please add its description. Otherwise Javadoc linters will grumble
*/ | ||
public void merge(SuiteResult sr) { | ||
if (sr.hasTimeAttr ^ hasTimeAttr){ | ||
throw new IllegalStateException("Merging of suiteresults with incompatible time attribute usage is not supported.( "+getFile()+", "+sr.getFile()+")"); |
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.
Since you introduce a new method, it would be preferable to propagate a non-RunTime exception and to make the code above handle it. If you want to stick to IllegalStateException
, it should be documented at least
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've changed this exception into a logger call...since the severity of this is not really critical - and theres no proper way to handle this elsewhere...so it will log a warning in this case.
@oleg-nenashev could you please take a look at this? I think the latest changes will look more promising :) |
@oleg-nenashev , @jglick, @jenkinsci/code-reviewers could you please take a look at this patch? |
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.
Looks good to me. Sorry for missing the previous ping
Could someone merge this? I would like to use this if possible from the next release (and drop the usage of a custom built plugin) |
When running Android tests the <testsuite> in the generated xml file can contain multiple classes. Thus setting the test class duration to the value of the test-suite is wrong. Instead the class duration is now calculated as sum its test cases. This is the same way it was done before jenkinsci#35 was merged. Reverting parts of both jenkinsci#35 and jenkinsci#54 did not break any existing tests.
since jenkinsci/junit-plugin#54 was merged, it should not be needed anymore.
since jenkinsci/junit-plugin#54 was merged, it should not be needed anymore.
since jenkinsci/junit-plugin#54 was merged, it should not be needed anymore.
JENKINS-37598
ClassResult
TestSuite
merging code fromTestResult
toTestSuite.merge()
TestSuite.time
field with a booleanTestResultTest
(because ofTestSuite.merge()
call location)