Tycho integration test are not run (but Unit tests are..) - maven

I have a multi module project with a plugin and fragment to test this plugin.
The build is done through maven/tycho. Maven v.3.8.4 and Tycho v2.6.0.
In the fragment I have 3 Unit and 1 Integration test, in the test folder:
test
├── CoreTestConstants.java
├── CoreUtils2Test.java
├── CoreUtils3Test.java
├── CoreUtilsIT.java
└── CoreUtilsTest.java
This is the pom of the fragment plugin:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>4.0.0</modelVersion>
<artifactId>com.tycho.rcp.core.test</artifactId>
<version>0.2.4-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<parent>
<groupId>com.tycho</groupId>
<artifactId>com.tycho.mps</artifactId>
<version>0.3.4-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<executions>
<execution>
<id>it-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
<configuration>
<testSourceDirectory>src</testSourceDirectory>
<testClassesDirectory>target/classes</testClassesDirectory>
<!-- workspace directory -->
<osgiDataDirectory>${mas.test.workspace}</osgiDataDirectory>
<!-- system properties -->
<systemProperties>
<mas.test.archive_location>${mas.test.archive_location}</mas.test.archive_location>
</systemProperties>
<!-- add slf4j implementation dependency from Orbit -->
<dependencies>
<dependency>
<groupId>org.eclipse.orbit.bundles</groupId>
<artifactId>ch.qos.logback.slf4j</artifactId>
<version>1.1.2</version>
<type>eclipse-plugin</type>
</dependency>
</dependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>
The tycho-surefire-plugin is enabled in pluginManagement of the parent project:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho.version}</version>
</plugin>
The 3 Unit test are executed correctly, but the IT test is never run!
This is the relevant part of the output, when I run mvn clean verify inside the fragment project:
[INFO] --- tycho-surefire-plugin:2.6.0:test (default-test) # com.marchesini.mas.rcp.core.test ---
[INFO] Executing Test Runtime with timeout 0, logs (if any) will be placed at: /home/gionata/runtime-EclipseApplication/.metadata/.log
[INFO] Command line:
[/usr/lib/jvm/java-11-openjdk-11.0.9.11-0.fc31.x86_64/bin/java, -Dosgi.noShutdown=false, -Dosgi.os=linux, -Dosgi.ws=gtk, -Dosgi.arch=x86_64, -Dosgi.clean=true, -Dmas.test.archive_location=/home/gionata/ARCHIVIO.BLK, -jar, /home/gionata/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.5.100.v20180827-1352/org.eclipse.equinox.launcher-1.5.100.v20180827-1352.jar, -data, /home/gionata/runtime-EclipseApplication, -install, /home/gionata/Workspace_Eclipse_Maven/MAS/MPS/com.marchesini.mas.rcp.core.test/target/work, -configuration, /home/gionata/Workspace_Eclipse_Maven/MAS/MPS/com.marchesini.mas.rcp.core.test/target/work/configuration, -application, org.eclipse.tycho.surefire.osgibooter.headlesstest, -testproperties, /home/gionata/Workspace_Eclipse_Maven/MAS/MPS/com.marchesini.mas.rcp.core.test/target/surefire.properties]
Running com.marchesini.mas.rcp.core.test.CoreUtils2Test
Logger launcher start...4
2022-02-05 18:36:11,221 DEBUG [main]: CHECKSUM 2 = 340351cde832c00505c88f3fe1a962d4
2022-02-05 18:36:11,442 DEBUG [main]: Workspace = /home/gionata/runtime-EclipseApplication
2022-02-05 18:36:11,442 DEBUG [main]: Archive location = /home/gionata/ARCHIVIO.BLK
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.569 s - in com.marchesini.mas.rcp.core.test.CoreUtils2Test
testCoreUtils2(com.marchesini.mas.rcp.core.test.CoreUtils2Test) Time elapsed: 0.226 s
Running com.marchesini.mas.rcp.core.test.CoreUtilsTest
#################################################################################
REPORT
CHECKSUM = 340351cde832c00505c88f3fe1a962d4
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in com.marchesini.mas.rcp.core.test.CoreUtilsTest
testCoreUtils(com.marchesini.mas.rcp.core.test.CoreUtilsTest) Time elapsed: 0.002 s
Running com.marchesini.mas.rcp.core.test.CoreUtils3Test
Logger launcher start...4
2022-02-05 18:36:11,537 DEBUG [main]: CHECKSUM 3 = 340351cde832c00505c88f3fe1a962d4
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 s - in com.marchesini.mas.rcp.core.test.CoreUtils3Test
testCoreUtils3(com.marchesini.mas.rcp.core.test.CoreUtils3Test) Time elapsed: 0.001 s
Results:
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[INFO] All tests passed!
[INFO]
[INFO] --- tycho-surefire-plugin:2.6.0:integration-test (it-test) # com.marchesini.mas.rcp.core.test ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
The execution it-test simply doesn't run anything! I have been wasting hours on this....
Thankyou for any help.

First of all, you shouldn't add any specific configuration if you follow the default conventions. Moreover, parameters like <testSourceDirectory>src</testSourceDirectory> are not read by the tycho surefire plugin. Moreover, there's no need to create products or features for what you need. The reason why it's not working it's because of a bug:
https://github.com/eclipse/tycho/issues/643
On a side note, I've updated the RELEASE notes
https://github.com/eclipse/tycho/pull/641
trying to document better the rationale behind the new goal (but, again, it does not work due to a bug)

Related

How do I run Maven integration tests in alphabetical order?

I'm using Maven 3.3.3 with Java 1.8. How do I get my integration tests to run in alphabetaical order, by class name (or file, whatever's easier)? I thought "runOrder" might help me so I created this plugin configuration ...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<reuseForks>true</reuseForks>
<argLine>-Xmx4096m -XX:MaxPermSize=512M -noverify -XX:-UseSplitVerifier ${itCoverageAgent}</argLine>
<runOrder>alphabetical</runOrder>
<skipTests>${skipAllTests}</skipTests>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
but as the integration tests are run, they are still not being run in order. Notice a file beginning with "V" precedess one beginnign with "G" ...
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option UseSplitVerifier; support was removed in 8.0
Running org.mainco.subco.antivirus.queue.repo.VirusScanQueueDaoIT
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.196 sec - in org.mainco.subco.antivirus.queue.repo.VirusScanQueueDaoIT
Running org.mainco.subco.antivirus.queue.service.VirusScanQueueServiceIT
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.055 sec - in org.mainco.subco.antivirus.queue.service.VirusScanQueueServiceIT
Running org.mainco.subco.classroom.repo.GroupDaoIT
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.181 sec - in org.mainco.subco.classroom.repo.GroupDaoIT
Running org.mainco.subco.classroom.service.GroupServiceIT
Tests run: 21, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.114 sec - in org.mainco.subco.classroom.service.GroupServiceIT
Running org.mainco.subco.core.repo.CategoryDaoIT
The ITs are run with respect to the alphabetical order... of the fully qualified name of the class. The following list
org.mainco.subco.antivirus.queue.repo.VirusScanQueueDaoIT
org.mainco.subco.antivirus.queue.service.VirusScanQueueServiceIT
org.mainco.subco.classroom.repo.GroupDaoIT
org.mainco.subco.classroom.service.GroupServiceIT
org.mainco.subco.core.repo.CategoryDaoIT
follows this ordering. There are currently no run orders working with just the class name.

jacoco as surefire argLine - The command line is too long

I'm running Jacoco as an agent to surefire
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<argLine>${jacoco.agent.argLine}</argLine>
</configuration>
</plugin>
I'm configuring Jacoco with a large list of exclusions (constants and my deprecated classes) for my build-breaker.
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<configuration>
<excludes>
<exclude>*/*Test</exclude>
<exclude>*/*Constants*</exclude>
<exclude>${jacoco.exclusions.list}</exclude>
</excludes>
</configuration>
What I'm getting is that when I go to run the tests I get the error:
T E S T S
-------------------------------------------------------
The command line is too long.
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
Is there another way to pass the exclusions list to Jacoco than on the agent parameter arglist on the command line? (Looking at the code it doesn't look like it)
My question is: How to pass the list of exclusions to the Jacoco agent running in surefire other than on the command line?
As of today JaCoCo Java Agent doesn't allow reading of options from files.
However you can specify agent via environment variable JAVA_TOOL_OPTIONS, which supposed to have bigger size limit than command line.
Also JaCoCo in offline mode (without agent) allows to provide configuration via file jacoco-agent.properties.

Jmeter Maven Plugin - Remote server config with parameters in pom.xml

I am trying to execute a jmeter test using the maven plugin on a remote server leveraging a pom.xml file that is completely parameterized as below.(I was able to successfully run a maven-jmeter remote test, where the servername, port, protocol and other info are all hard coded in the jmx file.
My pom.xml file is below
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jmeter-demo</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>jmeter-demo</name>
<url>http://maven.apache.org</url>
<description>
Executes a JMeter test.
</description>
<properties>
<webapp.protocol>http</webapp.protocol>
<!--<webapp.host>www.mozilla.com</webapp.host>-->
<webapp.host>fsa-mia-dev2.fsalabs.io</webapp.host>
<webapp.port>80</webapp.port>
<test.duration>30</test.duration>
<test.threads>10</test.threads>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.9.0</version>
<executions>
<execution>
<!--
1)
first test run warms up the webserver.
Used to fill caches.
With a different set of properties since it runs much shorter than a normal test
and also the rate of requests/second may be much lower.
Maybe also use a different URL set.
-->
<id>warmup</id>
<phase>integration-test</phase>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<propertiesUser>
<!--Accesses urls for warmup (compiles JSPs, fills caches, ...)-->
<!--************Setup Config for Threadgroup 23***************-->
<threadgroup23.name>S23_SFA_Org_CO</threadgroup23.name>
<threadgroup23.Transactionname>T23_SFA_Org_CO</threadgroup23.Transactionname>
<threadgroup23.ThinkTime>5000</threadgroup23.ThinkTime>
<threadgroup23.comment>T23_SFA_Org_CO</threadgroup23.comment>
<!--number of threads to use-->
<threadgroup23.numberOfThreads>5</threadgroup23.numberOfThreads>
<!--delay of the test in seconds-->
<threadgroup23.scheduledDelay>0</threadgroup23.scheduledDelay>
<!--duration of the test in seconds-->
<threadgroup23.scheduledDuration>60</threadgroup23.scheduledDuration>
<!--how long till all threads are up and running in seconds-->
<threadgroup23.rampUp>1</threadgroup23.rampUp>
<threadgroup23.dataFile>/home/ubuntu/mproj/data/S23_SFA_Org_CO.dat</threadgroup23.dataFile>
</propertiesUser>
</configuration>
</execution>
</executions>
<configuration>
<testFilesIncluded>
<testFilesIncluded>01_SA_CU_GetCPS.jmx</testFilesIncluded>
</testFilesIncluded>
<!-- protocol, server and port of tested webapp -->
<propertiesUser>
<protocol>${webapp.protocol}</protocol>
<server>${webapp.host}</server>
<port>${webapp.port}</port>
</propertiesUser>
<resultsFileFormat>csv</resultsFileFormat>
<testResultsTimestamp>false</testResultsTimestamp>
<ignoreResultFailures>true</ignoreResultFailures>
<remoteConfig>
<startServersBeforeTests>true</startServersBeforeTests>
<serverList>10.36.14.170</serverList>
</remoteConfig>
<suppressJMeterOutput>false</suppressJMeterOutput>
<propertiesSystem>
</propertiesSystem>
<propertiesJMeter><log_level.jmeter>DEBUG</log_level.jmeter></propertiesJMeter>
</configuration>
</plugin>
</plugins>
</build>
</project>
The issue is.. jmeter-server detects a request to execute and almost immediately stops.
Here is the info from log file post run
[debug] JMeter is called with the following command line arguments: -n -t /home/ubuntu/mProj/src/test/jmeter/01_SA_CU_GetCPS.jmx -l /home/ubuntu/mProj/target/jmeter/results/01_SA_CU_GetCPS.csv -d /home/ubuntu/mProj/target/jmeter -j /home/ubuntu/mProj/target/jmeter/logs/01_SA_CU_GetCPS.jmx.log -r -R 10.36.14.170
[info] Executing test: 01_SA_CU_GetCPS.jmx
[info] Created the tree successfully using /home/ubuntu/mProj/src/test/jmeter/01_SA_CU_GetCPS.jmx
[info] Configuring remote engine for 10.36.14.170
[info] Using remote object: UnicastRef [liveRef: [endpoint:[10.36.14.170:37913](remote),objID:[-10468c89:14fba100421:-7fff, -1854422229136130507]]]
[info] Starting remote engines
[info] Starting the test # Fri Sep 11 01:42:27 UTC 2015 (1441935747716)
[info] Remote engines have been started
[info] Waiting for possible shutdown message on port 4445
[info] Tidying up remote # Fri Sep 11 01:42:29 UTC 2015 (1441935749973)
[info] Completed Test: 01_SA_CU_GetCPS.jmx
[INFO]
[INFO] Test Results:
[INFO]
[INFO] Tests Run: 1, Failures: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25.280s
[INFO] Finished at: Fri Sep 11 01:42:35 UTC 2015
[INFO] Final Memory: 11M/57M
[INFO] ------------------------------------------------------------------------
(The pom-file works well without the remoteConfig - in localhost)
(There's no networking issues any where and the remote server is able to access the host and works when servername, port, protocol is hardcoded in jmx files)
Is this a known limitation of the maven-jmeter plugin?
First use a recent version of jmeter-maven-plugin, 2.8.3 as of 15th january 2019.
To pass parameters, enter in pom.xml as child of configuration:
<propertiesJMeter>
<BUILD_TAG>${project.version}</BUILD_TAG>
<threads>7</threads>
<duration>30</duration>
</propertiesJMeter>
And in jmeter, to use threads for example, you would use __P function:
${__P(threads,5)
This blog explains the whole process.

nexus-staging-maven-plugin refuse to upload after deferred deployment

I have a multi-module project that has nexus-staging-maven-plugin configured in parent pom.xml:
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.6</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<!--<autoReleaseAfterClose>true</autoReleaseAfterClose>-->
</configuration>
</plugin>
By default it should be inherited by all submodules (except those disabled using technique in How to disable nexus-staging-maven-plugin in sub-modules)
However, when I start deployment:
mvn clean deploy -DskipTests=true -Prelease-sign-artifacts -Dgpg.passphrase=*****
I see the following message:
[INFO] Installing Nexus Staging features:
[INFO] ... total of 5 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
...
[INFO] --- nexus-staging-maven-plugin:1.6.6:deploy (injected-nexus-deploy) # spookystuff-core ---
[INFO] Performing deferred deploys (gathering into "/home/peng/git/spookystuff/target/nexus-staging/deferred")...
[INFO] Installing /home/peng/git/spookystuff/core/target/spookystuff-core-0.3.2-SNAPSHOT.jar to /home/peng/git/spookystuff/target/nexus-staging/deferred/com/tribbloids/spookystuff/spookystuff-core/0.3.2-SNAPSHOT/spookystuff-core-0.3.2-SNAPSHOT.jar
...
[INFO] Reactor Summary:
...
[INFO] BUILD SUCCESS
No upload happens whatsoever. The artifact that should be uploaded to nexus were still cached under:
/target/nexus-staging/deferred
but neither the log nor nexus server record indicates that it has been uploaded. What has been wrong here and what should I do to fix it?

Maven surefire 2.12 does not run a specific test using -Dtest parameter

After upgrading all my Maven plugins version for a project, I encountered the following problem: when I run the basic command mvn test -Dtest=SomeTest, the build finishes with no test executed at all. In fact, I am not able to run any test using -Dtest parameter (of course the test exist, and is run when I simply execute mvn test).
After some searches, it appears that the problem is due to the usage of surefire 2.12 plugin. I've tested several versions of Maven (2.2.1 / 3.0.2) and JUnit (4.7.x, 4.8, 4.10, or even 3.8.x), but they have no impact on my issue.
So maybe my project has some specific configurations that may have an impact on that? Anyway, I created a new project, using mvn archetype:generate (using the basic org.apache.maven.archetypes:maven-archetype-quickstart).
I modified only 2 things in the pom.xml: using JUnit 4.10 (but it didn't change anything, I've tried with others versions), and defining the version of surefire:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
</plugin>
</plugins>
</build>
</project>
I run mvn test -Dtest=AppTest (the default JUnit test created by the archetype):
------------------------------------------------------- T E S T S
------------------------------------------------------- Running foo.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time
elapsed: 0.031 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO]
Now, I modify the pom.xml to use version 2.12 for Surefire and run the command again:
------------------------------------------------------- T E S T S
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 0.907s [INFO] Finished at: Fri Mar 02 10:37:12 CET
2012 [INFO] Final Memory: 3M/15M [INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:2.12:test
(default-test) on project bar: No tests were executed! (Set -D
failIfNoTests=false to ignore this error.) -> [Help 1]
The test is not run this time :(
As far as I am concerned, I think it's a regression, but that's quite surprising. Indeed, a JIRA defect is logged on Surefire 2.12 version, and in this description, they succeed in using -Dtest parameter.
Am I doing something wrong? Or is it a real regression (in this case, I will create the JIRA)?
Thanks.
It's a bug in 2.12 version - SUREFIRE-827.

Resources