-
Notifications
You must be signed in to change notification settings - Fork 103
Running Cassandra for integration tests from IntelliJ
NOTE: This guide might have some useful applications, but in general, I think it's simple enough to use Docker containers for Cassandra and Elasticsearch for integrations tests. See the 10 Minute Guide for appropriate Docker commands.
Blueflood integration tests need a running instance of cassandra in order to
work. It is possible to use the maven verify
lifecycle phase from IntelliJ,
which uses the maven-cassandra-plugin to start an instance of cassandra so the
integration tests work, to run the integration tests, but this has several
problems:
- There is no way to run only a single test, or only the tests that appear in a single file. (At least if there is, I haven't been able to figure it out)
- In order to run the integration tests for a blueflood module that depends on other blueflod modules, you must either install the required modules into your local maven repository, or you must run the tests on those modules as well (which can be very time consuming).
- It is difficult and awkward to use the IntelliJ builtin debugger to debug failing tests when tests are run under maven.
Installing and running your own cassandra instance is possible, but requires a bunch of work.
The easiest solution is to just have IntelliJ spin up an instance of cassandra.
- Requires blueflood OSS repository to be past the commit d91b1178d8faa7ee5fd167b73421afb796bc5b8c. This commit has been merged into master, so if you create your feature branch off of the most recent copy of master you'll be fine.
- Assumes reader is familiar with IntelliJ.
- Instructions written using IntelliJ 12.1.6 using builtin maven module. Instructions should work with other versions of IntelliJ, but some things may have been rearranged.
- Expand 'Maven Projects' sidebar
- Expand trees Blueflood->Plugins->cassandra
- Right click on the
cassandra:run
maven goal and select the popup item with the gear icon with the text that starts with "Create 'blueflood" - Change the name of the run configuration to "Cassandra 1.1"
- Check the 'Single instance only' checkbox.
- Add to the command line field
-pl com.rackspacecloud:blueflood -Dcassandra.skip=false -Dcassandra.rpcPort=19180
- Click on the green + sign under "Before launch" and select "Run Maven Goal"
- Expand trees Blueflood->Plugins->cassandra, highlight the
cassandra:delete
goal, and click the OK button. - Click the Apply and OK buttons to finish and save.
- Do the steps for Cassandra 1.1
- Click on the Run menu and select "Edit Configurations"
- Highlight the "Cassandra 1.1" configuration and then click on the copy icon (looks like 2 sheets of paper) next to the red - sign.
- Rename the new copy to "Cassandra 1.2"
- Check the 'Single instance only' checkbox.
- Add the text "cassandra-1.2" to the Profiles.
- Update the Command line by changing "org.codehaus.mojo:cassandra-maven-plugin:1.1.0-1:run" to "org.codehaus.mojo:cassandra-maven-plugin:1.2.1-1:run"
- Click the Apply and OK buttons to finish and save.
To use select one of the cassandra profiles and click on the green arrow to run it. The db from the last run will be deleted, cassandra will start up and automaticaly load the schema. When you see the text "Cassandra started in 3s", cassandra is ready for use.
When you are done with cassandra open up cassandra's run window and hit enter.