| 1 | # Contributing guidelines |
| 2 | |
| 3 | ## Working on an issue |
| 4 | |
| 5 | Before starting to work on something, please comment in JIRA or ask on the mailing list |
| 6 | to make sure nobody else is working on it. |
| 7 | |
| 8 | If your fix applies to multiple branches, base your work on the lowest active branch |
| 9 | (currently 3.0.x for bug fixes and 3.0 for new features, but ask for confirmation). |
| 10 | We regularly merge changes to higher branches. |
| 11 | |
| 12 | Before you send your pull request, make sure that: |
| 13 | |
| 14 | - you have a unit test that failed before the fix and succeeds after. |
| 15 | - the fix is mentioned in `changelog/README.md`. |
| 16 | - the commit message include the reference of the JIRA ticket for automatic linking |
| 17 | (example: `JAVA-503: Fix NPE when a connection fails during pool construction.`). |
| 18 | |
| 19 | As long as your pull request is not merged, it's OK to rebase your branch and push with |
| 20 | `--force`. |
| 21 | |
| 22 | If you want to contribute but don't have a specific issue in mind, the [lhf](https://datastax-oss.atlassian.net/secure/IssueNavigator.jspa?reset=true&mode=hide&jqlQuery=project%20%3D%20JAVA%20AND%20status%20in%20(Open%2C%20Reopened)%20AND%20labels%20%3D%20lhf) |
| 23 | label in JIRA is a good place to start: it marks "low hanging fruits" that don't require |
| 24 | in-depth knowledge of the codebase. |
| 25 | |
| 26 | ## Editor configuration |
| 27 | |
| 28 | We use IntelliJ IDEA with the default formatting options, with one exception: check |
| 29 | "Enable formatter markers in comments" in Preferences > Editor > Code Style. |
| 30 | |
| 31 | Please format your code and organize imports before submitting your changes. |
| 32 | |
| 33 | ## Running the tests |
| 34 | |
| 35 | We use TestNG. There are 3 test categories: |
| 36 | |
| 37 | - "unit": pure Java unit tests. |
| 38 | - "short" and "long": integration tests that launch Cassandra instances. |
| 39 | |
| 40 | The Maven build uses profiles named after the categories to choose which tests to run: |
| 41 | |
| 42 | ``` |
| 43 | mvn test -Pshort |
| 44 | ``` |
| 45 | |
| 46 | The default is "unit". Each profile runs the ones before it ("short" runs unit, etc.) |
| 47 | |
| 48 | Integration tests use [CCM](https://github.com/pcmanus/ccm) to bootstrap Cassandra instances. |
| 49 | Two Maven properties control its execution: |
| 50 | |
| 51 | - `cassandra.version`: the Cassandra version. This has a default value in the root POM, |
| 52 | you can override it on the command line (`-Dcassandra.version=...`). |
| 53 | - `ipprefix`: the prefix of the IP addresses that the Cassandra instances will bind to (see |
| 54 | below). This defaults to `127.0.1.`. |
| 55 | |
| 56 | |
| 57 | CCM launches multiple Cassandra instances on localhost by binding to different addresses. The |
| 58 | driver uses up to 10 different instances (127.0.1.1 to 127.0.1.10 with the default prefix). |
| 59 | You'll need to define loopback aliases for this to work, on Mac OS X your can do it with: |
| 60 | |
| 61 | ``` |
| 62 | sudo ifconfig lo0 alias 127.0.1.1 up |
| 63 | sudo ifconfig lo0 alias 127.0.1.2 up |
| 64 | ... |
| 65 | ``` |