Does "mvn verify" starts ccm?

34 views
Skip to first unread message

Ricke

unread,
Apr 27, 2023, 7:53:32 PM4/27/23
to DataStax Java Driver for Apache Cassandra User Mailing List
Hi, I am trying to run integration tests by "mvn verify". All tests have passed but I am not seeing CCM has ever been run. Could anyone tell me what the proper command to run all integration tests by using CCM? Thank you.

Ricke

Bret McGuire

unread,
Apr 28, 2023, 2:03:30 AM4/28/23
to DataStax Java Driver for Apache Cassandra User Mailing List, Ricke
   Hey Ricke, thanks for the question!

   I can confirm that "mvn verify" will run integration tests, including those integration tests which leverage ccm to manage their backing cluster.  The Java driver includes an integration test framework which will invoke ccm behind the scenes to create and tear down a ccm cluster for tests which require such a thing.  You can find more details in the CcmBridge class within the project.

   If you want to see extensive details on what ccm is doing you can change the CcmBridge class to force debug logging for everything it executes.  The following patch (against 4.x as of this writing) will make it happen:

diff --git a/test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/CcmBridge.java b/test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/CcmBridge.java
index cef9e13c4..4dcb9ee5c 100644
--- a/test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/CcmBridge.java
+++ b/test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/CcmBridge.java
@@ -339,7 +339,7 @@ public class CcmBridge implements AutoCloseable {
   }
 
   private void execute(CommandLine cli) {
-    execute(cli, false);
+    execute(cli, true);
   }
 
   private void executeCheckLogError() {

   If you then run "mvn verify" you should see a considerable amount of ccm logging.  This logging can get quite verbose quite quickly, however, so you may want to execute just a single test:

mvn verify -Dtest="com.datastax.oss.driver.core.metadata.SchemaAgreementIT" -DfailIfNoTests=false

   Thanks again for the question!

   - Bret -

Ricke

unread,
Apr 28, 2023, 2:59:27 AM4/28/23
to DataStax Java Driver for Apache Cassandra User Mailing List, Bret McGuire, Ricke
Hi Bret, thank you for the clarification. I tried to run “mvn verify” but didn’t see any running process of CCM. All the tests passed. Then I tried to run “mvn verify -P short” under cassandra-java-clients/, I noticed CCM was started and “ps” shows the process. But some of my tests failed.  Do you know what’s the difference between the two commands? Thank you!

Ricke

unread,
Apr 28, 2023, 12:29:00 PM4/28/23
to DataStax Java Driver for Apache Cassandra User Mailing List, Ricke, Bret McGuire
By the way, the code I am working on is based on 3.6.0.

Ricke

unread,
Apr 28, 2023, 1:49:50 PM4/28/23
to DataStax Java Driver for Apache Cassandra User Mailing List, Bret McGuire, Ricke
I added some logging in CCMBridge class. "mvn verify" only run tests tagged by {groups = "unit") and all "short" group tests are skipped. It seems that only tests in "short" group use CCM, which can be run by "mvn verify -P short".

On Thursday, April 27, 2023 at 11:03:30 PM UTC-7 Bret McGuire wrote:

Bret McGuire

unread,
Apr 28, 2023, 6:07:00 PM4/28/23
to DataStax Java Driver for Apache Cassandra User Mailing List, Ricke, Bret McGuire
   You have the gist of it Ricke.  A "-P" argument to Maven identifies one or more profiles that should be used when executing the specified task.  In 3.6.0 we were still using profiles to group test cases together.  Individual test cases were assigned to a group by way of an extra arg in the TestNG test annotation (as in this example).  Note that this annotation is applied on an individual test method; even if you include the class that contains this method you won't run the method unless you also include the profile.  So in my example this command would not execute the test:

mvn verify -Dtest="SchemaAgreementTest" -DfailIfNoTests=false

   while this command would:

mvn verify -P short -Dtest="SchemaAgreementTest" -DfailIfNoTests=false

   I don't think there's any specific correlation between tests which use ccm and a given Maven profile.  A better guide would be to see if the test has a CCMConfig annotation and extends CCMTestsSupport.  If that's the case you can very reasonably expect the test to spin up a ccm cluster before it executes any test methods and shut it down when it's done.

   Finally, I'll note that we moved away from most (all?) of this infrastructure later in the 3.x line (and very definitely in 4.x).

  - Bret -

Ricke

unread,
May 1, 2023, 1:41:31 AM5/1/23
to DataStax Java Driver for Apache Cassandra User Mailing List, Bret McGuire, Ricke
Thank you, Bret. Do you still remember what the test groups of “short”, “isolated” mean in 3.6.0? I checked many of tests in “short” and most of them use CCM. 

Bret McGuire

unread,
May 3, 2023, 12:32:57 AM5/3/23
to DataStax Java Driver for Apache Cassandra User Mailing List, Ricke, Bret McGuire
   I'm not aware of hard and fast rules on this point Ricke.  Clearly the "unit" profile runs only the unit tests while "short" and "long" appear to run (relatively) quick vs. longer-running integration tests (respectively).

   I did come across some older documentation which seems to support this:

unit # the default run of tests that don't require Cassanda clusters and therefore do not use CCM
short # a nice combination of unit tests and short integration tests
long # the goto test for all unit tests and integration tests

"The main difference between short and long tests is that short tests require CCM and tend to run very quickly, ideally not longer than 20 seconds per test. long tests can take up to 12 minutes for a single test and close to an hour for the full test suite."

   That's the best answer I've been able to find, but as mentioned above I wouldn't bank on these rules always being rigorously enforced.  It would not surprise me at all if there were a few tests in "short" which wind up running for some time and/or some tests in "long" which exit quickly.

  - Bret -
Reply all
Reply to author
Forward
0 new messages