-
Notifications
You must be signed in to change notification settings - Fork 542
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
Add failOnFlakeCount option #333
Conversation
maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
Show resolved
Hide resolved
maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
Show resolved
Hide resolved
surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformRerunFailingTestsIT.java
Show resolved
Hide resolved
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
Show resolved
Hide resolved
@oehme |
@oehme |
It's about the whole test set. I've added a clarification to the issue description. I don't understand the point about IDs. I'm not changing anything about test IDs, I'm just adding validation at the end of the execution, similar to failOnError. |
@oehme |
Got it, thanks! So is this option something you'd consider adding? In that case I'd flesh out the PR some more. |
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
Outdated
Show resolved
Hide resolved
@oehme |
1ab3178
to
d2fc069
Compare
I've clarified the documentation and added unit tests. I've removed the integration test, since this feature is not junit-platform specific, but fully contained in SurefireHelper. Are there any other things I should add or modify? |
@@ -139,6 +139,13 @@ | |||
@Parameter( property = "failIfNoTests" ) | |||
private Boolean failIfNoTests; | |||
|
|||
/** | |||
* Set this to a value greater than 0 to fail the whole test set if the cumulative number of flakes reaches | |||
* this threshold. Set to 0 to allow an unlimited number of flakes. |
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.
based on the code a negative number would do the same, right?
Should we maybe rather fail in that case?
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.
@oehme
Actually yes, we should and there is something like "verifyParameters" method.
Have you used the flag to serialize the content in the method getConfigChecksum
?
if ( firstForkException == null && !result.isTimeout() && result.isErrorFree() ) | ||
boolean isError = firstForkException != null || result.isTimeout() || !result.isErrorFree(); | ||
boolean isFlaky = reportParameters.getFailOnFlakeCount() > 0 | ||
&& result.getFlakes() >= reportParameters.getFailOnFlakeCount(); |
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.
minor: could we have getFailOnFlakeCount
on the same side on both cases to simplify comparison?
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.
@paplorinc
What you mean?
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.
Just an observation that X > 0 && X < Y
may be easier to read than X > 0 && Y >= X
.
Don't have strong feelings about it, just a note
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.
@paplorinc
I think result.getFlakes() >= reportParameters.getFailOnFlakeCount()
is okay because it is a condition saying variable >= constant
and we are "watching" variable and not the constant. In maths is the same as you say but it is another wording in the sentence.
@@ -142,7 +142,10 @@ public static void reportExecution( SurefireReportParameters reportParameters, R | |||
PluginConsoleLogger log, Exception firstForkException ) | |||
throws MojoFailureException, MojoExecutionException | |||
{ | |||
if ( firstForkException == null && !result.isTimeout() && result.isErrorFree() ) | |||
boolean isError = firstForkException != null || result.isTimeout() || !result.isErrorFree(); | |||
boolean isFlaky = reportParameters.getFailOnFlakeCount() > 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.
this stores more than whether we're flaky, rather something like: isFlakyError
, 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.
minor i would say
+ "[date].dump, [date]-jvmRun[N].dump and [date].dumpstream." ); | ||
return; | ||
} | ||
fail( "Expected MojoFailureException with message " |
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.
minor: you could add this inside the try in which case we wouldn't need a return in the catch
@@ -286,7 +289,15 @@ private static String createErrorMessage( SurefireReportParameters reportParamet | |||
} | |||
else | |||
{ | |||
msg.append( "There are test failures.\n\nPlease refer to " ) | |||
if ( result.getFailures() > 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.
@oehme
Pls see the class IntegrationTestPlugin
. It reports this text other way. The same messages should be there as well but the solution is different from this one.
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 IntegrationTestMojo does not report this text. The VerifyMojo does and uses the same logic as the SurefirePlugin
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.
@oehme
ok just fine!
+ "[date].dump, [date]-jvmRun[N].dump and [date].dumpstream." ); | ||
return; | ||
} | ||
fail( "Expected MojoFailureException with message " |
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.
@oehme
Pls move this line right after the line 168, and remove the return
. It would behave the same, We normally do it this way.
Pls first use |
24cfe0d
to
d60a67b
Compare
All fixed up |
Thx. Waiting for the CI. |
* Set this to a value greater than 0 to fail the whole test set if the cumulative number of flakes reaches | ||
* this threshold. Set to 0 to allow an unlimited number of flakes. | ||
*/ | ||
@Parameter( property = "surefire.failOnFlakeCount", defaultValue = "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.
Here the property surefire.failOnFlakeCount
must become failsafe.failOnFlakeCount
. See the other properties in this class.
} | ||
else | ||
{ | ||
msg.append( "There are too many flakes." ); |
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.
@oehme
I think this would not be printeted very often even if it could because there is if-else.
We do not have IT test but both messages could be printed along. Why the message There are too many flakes.
does not have the concrete numbers. We have both numbers available and they are the cause why the message is going to be printed. I only want to give the user all reason why the plugin crashed.
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.
Done, both messages are reported now if both conditions are true. Also, the number of flakes and failOnFlakeCount are reported 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.
@oehme
Thx, a good job!
@@ -880,4 +900,20 @@ protected final ForkNodeFactory getForkNode() | |||
{ | |||
return forkNode; | |||
} | |||
|
|||
@Override | |||
boolean verifyParameters() throws MojoFailureException, MojoExecutionException |
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 must not exist in both Plugin classes. See the super method in AbstractSurefireMojo and add a new warn* method and a call which finally calls the abstract method getFailOnFlakeCount.
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.
SurefirePlugin and VerifyMojo do not have a common base 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.
I am not talking about VerifyMojo, nothing but the SurefirePlugin 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.
But why would the super class contain logic that only applies to a single subclass?
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.
Nevermind, I see the if-else in that method now. Moved call up to the base 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.
But why would the super class contain logic that only applies to a single subclass?
Both plugins, Surefire and Failsafe, have 90% the same parameters. So they always contained the method verifyParameters()
in the super class. The VerifyMojo
is an exception and it has never had so many config params before.
@Override | ||
boolean verifyParameters() throws MojoFailureException, MojoExecutionException | ||
{ | ||
if ( failOnFlakeCount < 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.
As in my previous comment, this must be in the abstract class where are all the warning check method calls made in the section:
else
{
ensureEnableProcessChecker();
convertDeprecatedForkMode();
ensureWorkingDirectoryExists();
ensureParallelRunningCompatibility();
ensureThreadCountWithPerThread();
warnIfUselessUseSystemClassLoaderParameter();
warnIfDefunctGroupsCombinations();
warnIfRerunClashes();
warnIfWrongShutdownValue();
warnIfNotApplicableSkipAfterFailureCount();
warnIfIllegalTempDir();
warnIfForkCountIsZero();
printDefaultSeedIfNecessary();
}
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.
See above, this wouldn't make sense because IntegrationTestMojo does not have failOnFlakeCount
. That's in the VerifyMojo, which doesn't have the same base 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.
@oehme
I am not talking about VerifyMojo, nothing but the SurefirePlugin class.
e066d51
to
27a8f9e
Compare
@oehme @eolivelli |
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.
@Tibor17 I don't, but I can easily add one back if you want. I removed it because this feature isn't specific to a particular provider and all the logic could be unit tested, so I didn't feel like an extra integ test was necessary anymore. |
I also believe that it would be fine without IT but we should cover every config param by IT. It would be the highest guarantee that the client would not fire a bug against us that a fresh feature is dead ;-) |
27a8f9e
to
9d1c640
Compare
Added the IT back |
@oehme |
@oehme |
If you want I can send another PR, otherwise I'll let you take care of it. |
@oehme |
I've looked at this and I think it would be inconsistent: Only the SurefirePlugin has both |
We have two plugins: surefire and failsafe. |
I was referring to the additional validation you wanted me to add - That's possible for surefire (both properties in the same Mojo), but as far as I can see not for failsafe (properties spread over two Mojos) |
@oehme |
To clarify https://issues.apache.org/jira/browse/SUREFIRE-1878 for further discussion.