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

Add start/stop methods for QuarkusProdModeTest and do not setup RestAssured.port if it's configured randomly #14961

Closed
Sgitario opened this issue Feb 10, 2021 · 6 comments · Fixed by #15073

Comments

@Sgitario
Copy link
Contributor

Description
The JAVA process that is created as part of QuarkusProdModeTest follows the JUnit extension lifecycle. However, sometimes is desired to manually control the state to cope with more scenarios within the same test case.

Implementation ideas
I will provide implementation ideas. Also, I would like to provide a solution for this enhancement by myself.

@Sgitario Sgitario added the kind/enhancement New feature or request label Feb 10, 2021
@ghost ghost added the triage/needs-triage label Feb 10, 2021
@Sgitario Sgitario changed the title Add start/stop methods for QuarkusProdModeTest Add start/stop methods for QuarkusProdModeTest and do not setup RestAssured.port if it's configured randomly Feb 10, 2021
@geoand
Copy link
Contributor

geoand commented Feb 10, 2021

I don't really understand this, can you explain more?

@Sgitario
Copy link
Contributor Author

Sgitario commented Feb 15, 2021

I don't really understand this, can you explain more?

Mostly, in order to cope with test scenarios of failover cases. Example:

@RegisterExtension
static final QuarkusProdModeTest nodeApp = new QuartzNodeApplicationResource();

@RegisterExtension
static final QuarkusProdModeTest masterApp = new QuartzMasterApplicationResource();

@Test
public void testFailover() {
    assertMasterIsConnectedWithNode();

    // simulate node failover
    nodeApp.stop();
    assertMasterIsNotConnectedWithNode();

    nodeApp.start();
    assertMasterIsConnectedWithNode();
}

Also, about the rest assured, when we want to start our Quarkus application using a random port (quarkus.http.port=0), the QuarkusProdModeTest is setting RestAssured.defaultPort = 0 which is invalid (if you try to do given() in your test case, you will get an exception.

@Sgitario
Copy link
Contributor Author

@geoand I've proposed a PR to address this issue.

@geoand
Copy link
Contributor

geoand commented Feb 15, 2021

I see, thanks for the example.

To be honest, QuarkusProdModeTest was never meant to work when having multiple test extensions registered... I am surprised that is does work but I am not sure I want to explicitly support this...

@stuartwdouglas WDYT?

@stuartwdouglas
Copy link
Member

I think this is a corner case, but it does seem relatively simple to support so maybe it is ok. I would like some tests for this in the PR thought.

@Sgitario
Copy link
Contributor Author

I think this is a corner case, but it does seem relatively simple to support so maybe it is ok. I would like some tests for this in the PR thought.

This module was lacking of test units. However, I've added one to support this simple use case. The PR is updated.

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

Successfully merging a pull request may close this issue.

3 participants