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

Adds argLine to instrument Integration Tests #17677

Merged

Conversation

bvarner
Copy link
Contributor

@bvarner bvarner commented Jun 3, 2021

For Example, in a project I'm building:

            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <systemPropertyVariables>
                                <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                                <maven.home>${maven.home}</maven.home>
                                <quarkus.test.native-image-profile>it</quarkus.test.native-image-profile>
                                <quarkus.test.argLine>${argLine}</quarkus.test.argLine>
                            </systemPropertyVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Fixes: #17760

@bvarner
Copy link
Contributor Author

bvarner commented Jun 3, 2021

With the code from this PR, I've been able to define my plugins as this:

And get a coverage report containing the results of both the surefire and failsafe coverage.
This is highly helpful, especially when enforcing quality gates.

    <build>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-prepare-agent-integration</id>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/jacoco-quarkus.exec</destFile>
                            <append>true</append>
                            <exclClassLoaders>*QuarkusClassLoader</exclClassLoaders>
                        </configuration>
                    </execution>
                    <execution>
                        <id>report-it</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>${project.build.directory}/jacoco-quarkus.exec</dataFile>
                            <outputDirectory>${project.build.directory}/jacoco-report</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <systemPropertyVariables>
                                <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                                <maven.home>${maven.home}</maven.home>
                                <quarkus.test.native-image-profile>it</quarkus.test.native-image-profile>
                                <quarkus.test.argLine>${argLine}</quarkus.test.argLine>
                            </systemPropertyVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            ...
       </plugins>
   </build>

@bvarner
Copy link
Contributor Author

bvarner commented Jun 3, 2021

@geoand and @glefloch New PR from main, closed #17649.

@@ -39,6 +40,7 @@ private JarLauncher(Path jarPath, Config config) {
config.getValue("quarkus.http.test-port", OptionalInt.class).orElse(DEFAULT_PORT),
config.getValue("quarkus.http.test-ssl-port", OptionalInt.class).orElse(DEFAULT_HTTPS_PORT),
config.getValue("quarkus.test.jar-wait-time", OptionalLong.class).orElse(DEFAULT_JAR_WAIT_TIME),
config.getOptionalValue("quarkus.test.argLine", String.class).orElse(null),
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be added to io.quarkus.deployment.dev.testing.TestConfig so it ends up in the 'all properties' documentation.

It would also be good to include this in the testing documentation, as we don't have any info at the moment on doing code coverage with @QuarkusIntegrationTest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright. So wrt the io.quarkus.deployment.dev.testing.TestConfig I'm a bit confused.
I see in that class

    /**
     * The profile to use when testing the native image
     */
    @ConfigItem(defaultValue = "prod")
    String nativeImageProfile;

Which seems a bit misleading, since it's not prod explicitly as a default -- but rather null.

So, while I patterned the implementation of this OptionalValue off that, I feel like I probably should not define a defaultValue for the @ConfigItem, does that sound right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wrt the testing documentation -- where would I find that, and I'm not convinced I'm your guy for documenting that.

I've found the testing documentation to be a bit ... lacking... especially in the realm of Integration testing, and what-not.

Copy link
Member

Choose a reason for hiding this comment

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

Yea, the default value should be null. Also the property name should be something line quarkus.test.integration-jvm-arg-line to fit in with our naming convention, and also to make it clear where this applies so you have something like:

    /**
     * JVM parameters that are used to launch jar based integration tests.
     */
    @ConfigItem
    String integrationJvmArgLine;

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Documentation and TestConfig updated. Let me know what else I can do, or any other feedback you have.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stuartwdouglas I'm not sure why this is failing, it's also failing locally.
It looks like I needed to add this ConfigItem to other classes as well, but I can't quite seem to put my finger on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wow. How'd I miss that it needs to be Optional<String>? 🤦

@quarkus-bot
Copy link

quarkus-bot bot commented Jun 4, 2021

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building 6d121e4

Status Name Step Test failures Logs Raw logs
Maven Tests - JDK 11 Build Test failures Logs Raw logs

Full information is available in the Build summary check run.

Test Failures

⚙️ Maven Tests - JDK 11 #

📦 integration-tests/maven

io.quarkus.maven.it.DevMojoIT.testThatNewResourcesAreServed line 849 - More details - Source on GitHub

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 a lot!

@geoand geoand requested a review from stuartwdouglas June 4, 2021 14:26
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 4, 2021

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building 122ee10

Status Name Step Test failures Logs Raw logs
Initial JDK 11 Build Build ⚠️ Check → Logs Raw logs

@geoand
Copy link
Contributor

geoand commented Jun 4, 2021

Please squash the commits when you are done

@bvarner bvarner force-pushed the feature/jar-launcher-argline branch from b03843b to 887897e Compare June 4, 2021 19:33
Copy link
Member

@stuartwdouglas stuartwdouglas 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 a lot

@@ -1088,6 +1088,89 @@ Finally, if a container image was created during the build (by using including t

As is the case with `@NativeImageTest`, this is a black box test that supports the same set features and has the same limitations.

=== Code Coverage for Integration Tests
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change pushed.

@geoand geoand added triage/waiting-for-ci Ready to merge when CI successfully finishes triage/backport? labels Jun 8, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 8, 2021

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building c66481c

Status Name Step Test failures Logs Raw logs
Initial JDK 11 Build Build ⚠️ Check → Logs Raw logs

@geoand
Copy link
Contributor

geoand commented Jun 8, 2021

Seems like the imports are not supported. Can you please run mvn process-sources, commit and squash the changes?

Thanks

… documentation, and testing documentation on how to configure.

* Fix quarkusio#7536 by adding the ability to specify an argLine property when running tests.

For Example, in a project I'm building:
```
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <systemPropertyVariables>
                                <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                                <maven.home>${maven.home}</maven.home>
                                <quarkus.test.native-image-profile>it</quarkus.test.native-image-profile>
                                <argLine>${argLine}</argLine>
                            </systemPropertyVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
```
@bvarner bvarner force-pushed the feature/jar-launcher-argline branch from c66481c to e6cd85e Compare June 8, 2021 14:09
@stuartwdouglas stuartwdouglas merged commit de502dc into quarkusio:main Jun 9, 2021
@quarkus-bot quarkus-bot bot added this to the 2.1 - main milestone Jun 9, 2021
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jun 9, 2021
@gsmet gsmet modified the milestones: 2.1 - main, 2.0.0.Final Jun 10, 2021
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.

QuarkusIntegrationTest on java jar, should support Jacoco Quarkus code coverage with failsafe
4 participants