Skip to content
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

Introduce QuarkusTestProfileAwareClassOrderer for efficient @TestProfile ordering #20156

Merged
merged 1 commit into from
Sep 27, 2021
Merged

Conversation

famod
Copy link
Member

@famod famod commented Sep 14, 2021

Update: Finalized, resolves #20117

@geoand & @stuartwdouglas this is a very early draft for #20117.

I haven't tested it yet but I wanted to get some early feedback:

  • see TODOs
  • package; util or somewhere else?
  • extensibility through the two protected methods

W.r.t. extensibility, one use-case I have in mind for my current project is to also group/sort ArchUnit tests.
Others might want to execute simple unit tests before QuarkusTests (which they could also do by swapping the values of those two junit properties).

Btw, I will add some javadoc and inline comments as well. In case it's hard to see right now: The first QuarkusTestProfile class that is found receives the order number 1, which is added to the base number (1000). The next different QuarkusTestProfile class receives 2 and so on.

PS: I'll probably have to check for @QuarkusIntegrationTest as well.

TODOs:

  • rethink number based approach for more similarity to continuous testing
  • cover QuarkusIntegrationTest
  • add javadoc and extend testing docs

@famod
Copy link
Member Author

famod commented Sep 14, 2021

Btw, I will add some javadoc and inline comments as well.

...and of course I will add something to the testing docs.

public void orderClasses(ClassOrdererContext context) {
AtomicInteger testProfileCounter = new AtomicInteger();
Map<Class<? extends QuarkusTestProfile>, Integer> testProfileNumberMap = new HashMap<>();
Function<Class<? extends QuarkusTestProfile>, Integer> testProfileNumberProvider = desc -> testProfileNumberMap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like the counter approach, as I would prefer something stable between runs.

Ideally this would match the continuous testing sort order (ideally with a shared implementation):

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's stable between runs because e.g. surefire will not change the order randomly unless you tell it to do so.

But I will have a look at what you suggested.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is stable then I think the approach is probably fine.

Copy link
Member Author

@famod famod Sep 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I aligned it a bit more with what you suggested (profile FQCN infix), but I don't really see much value in trying to unify it more since the constraints are different: The orderer has a single list with all tests, the runner in continuous testing has two separate ones. I also wanted to give users the choice to reconfigure the order (or even subclass it).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, I quickly tried this with continuous testing and users might be surprised to see a different ordering there.
But I think we can always follow up with further unifications later.

@famod
Copy link
Member Author

famod commented Sep 15, 2021

FWIW in my current project (with Quarkus 2.2.3 and overridden JUnit) we are now using a slightly simpler version of this orderer and it's working: In one module we save over 20s!

@famod
Copy link
Member Author

famod commented Sep 22, 2021

@geoand I'm almost done revamping this, but let's say I won't make it before Sunday: I suppose this would then be still in time for 2.3.0.Final?

@geoand
Copy link
Contributor

geoand commented Sep 22, 2021

To have this in for Final, we would need it in by Tuesday the latest

@famod famod marked this pull request as ready for review September 26, 2021 20:25
@famod famod changed the title WIP QuarkusTestProfileAwareClassOrderer Introduce QuarkusTestProfileAwareClassOrderer for efficient @TestProfile ordering Sep 26, 2021

protected static final String DEFAULT_ORDER_PREFIX_QUARKUS_TEST = "20_";
protected static final String DEFAULT_ORDER_PREFIX_QUARKUS_TEST_WITH_PROFILE = "40_";
protected static final String DEFAULT_ORDER_PREFIX_NON_QUARKUS_TEST = "60_";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The "number spacing" might seem odd, but I wanted to leave some gaps for users to fill in their own orderings.

* Limitations:
* <ul>
* <li>This orderer does not (yet) consider {@linkplain io.quarkus.test.common.QuarkusTestResource#restrictToAnnotatedClass()
* test resources that are restricted to the annotated class}.</li>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a future improvement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR: #20420

@quarkus-bot
Copy link

quarkus-bot bot commented Sep 27, 2021

Failing Jobs - Building a6883fe

Status Name Step Failures Logs Raw logs
MicroProfile TCKs Tests Verify Failures Logs Raw logs

Full information is available in the Build summary check run.

Failures

⚙️ MicroProfile TCKs Tests #

- Failing: tcks/resteasy-reactive 

📦 tcks/resteasy-reactive

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (test) on project quarkus-tck-resteasy-reactive: Command execution failed.

📦 tcks/resteasy-reactive/target/testsuite/tests

com.sun.ts.tests.jaxrs.platform.container.completioncallback.JAXRSClient0164.argumentIsNullWhenRegistredClassTest line 209 - More details - Source on GitHub

com.sun.ts.tests.jaxrs.common.JAXRSCommonClient$Fault: Unexpected response content No name has been set yet expecting NULL
	at com.sun.ts.tests.jaxrs.platform.container.completioncallback.JAXRSClient0164.assertString(JAXRSClient0164.java:458)
	at com.sun.ts.tests.jaxrs.platform.container.completioncallback.JAXRSClient0164.argumentIsNullWhenRegistredClassTest(JAXRSClient0164.java:209)

@famod
Copy link
Member Author

famod commented Sep 27, 2021

TCKs Tests cannot be related.

@geoand do you want to have a look? I'd like to merge this soon so that it ends up in 2.3.0.Final.

Copy link
Contributor

@geoand geoand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@geoand geoand merged commit 9e15c37 into quarkusio:main Sep 27, 2021
@quarkus-bot quarkus-bot bot added this to the 2.4 - main milestone Sep 27, 2021
@famod famod deleted the test-orderer branch September 27, 2021 12:25
@stuartwdouglas
Copy link
Member

quarkusio/resteasy-reactive-testsuite@a43f921 should fix the intermittent failure.

@geoand geoand modified the milestones: 2.4 - main, 2.3.0.Final Sep 28, 2021
@famod
Copy link
Member Author

famod commented Sep 28, 2021

@famod
Copy link
Member Author

famod commented Sep 28, 2021

#20437 is taking care of using the latest ref of resteasy-reactive-testsuite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide JUnit 5.8 test class orderer for efficient ordering of @TestProfile
3 participants