thinkaurelius/titan — pull request #337 by dalaro (2013-07-29 20:46:00+00:00)
Title: Cassandra test refactoring

I enabled [maven-surefire-plugin's parallel execution of test classes](http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#parallel) for Cassandra.

This reduced the wall-clock runtime of the Cassandra suite from about 22 minutes to 6 on my Ivy Bridge quadcore box.

Before my changes, each Cassandra test class ran in a separate fork. Some classes used a cassandra.yaml file with ByteOrderedPartitioner while others used RandomPartitioner.

After my changes, titan-cassandra runs two executions of the maven-surefire-plugin in series. The execution ids are:

1. bop-test
1. rp-test

Each execution forks once. The forked child creates 2 * corecount threads to run test classes. The methods in each test class are executed by only one thread, so test classes can still assume their methods are executed serially. Includes and excludes under each execution config run only the test classes appropriate to the execution's partitioner.

I changed each test class to use a unique keyspace. All test classes in an execution share a single embedded Cassandra daemon and run in the same process. The only thing keeping them from interfering is the fact that they all use different keyspaces (and, in tests where applicable, local lock mediators).

I found a problem with this double-execution approach. When I ran mvn test -Dtest=..., the specified test or tests would run twice, once for each execution. This was repetition served no purpose. I worked around this using profiles. The double-surefire-executions are wrapped in a profile with

```

!test

```

There's a third execution in a profile wrapped with

```

test

```

I don't know the pom.xml changes in this pull are going to interact with people's IDEs. Eclipse + m2e appears to have no problem, but I think we have at least two IDEA users.