|
| 1 | +ringpop-admin tests |
| 2 | +=================== |
| 3 | + |
| 4 | +ringpop-admin tests are written using [cram](https://bitheap.org/cram/). Cram runs rinpop-admin commands and compares the output to known good output. |
| 5 | + |
| 6 | +In order to run ringpop-admin commands, the test runner spins up a test cluster using `tick-cluster.js` (from ringpop-node). |
| 7 | + |
| 8 | + |
| 9 | +Prerequisites |
| 10 | +------------- |
| 11 | + |
| 12 | + * cram (tested with v0.6) (`sudo pip install cram`) |
| 13 | + |
| 14 | +Tested on Mac OS X. |
| 15 | + |
| 16 | +Note that `tick-cluster.js` uses TCP ports 2999-3005. Please ensure these ports are free before running the tests. |
| 17 | + |
| 18 | + |
| 19 | +Running the tests |
| 20 | +----------------- |
| 21 | + |
| 22 | +You can run the tests by doing: |
| 23 | + |
| 24 | + ./run-tests |
| 25 | + |
| 26 | +Modifying existing tests |
| 27 | +------------------------ |
| 28 | + |
| 29 | +If you've modified the output of ringpop-admin and you want to update the "known good" data, call `run-tests` with the `--update` flag: |
| 30 | + |
| 31 | + ./run-tests --update |
| 32 | + |
| 33 | +This will pass the `-i` flag to cram. When the test fails, a diff will be displayed and you will have the option to accept the new output, e.g.: |
| 34 | + |
| 35 | + $ ./run-tests --update |
| 36 | + ... |
| 37 | + ringpop-admin.t: failed |
| 38 | + --- ringpop-admin.t |
| 39 | + +++ ringpop-admin.t.err |
| 40 | + @@ -20,6 +20,7 @@ |
| 41 | + leave Makes node leave the cluster |
| 42 | + list List member information |
| 43 | + lookup Lookup a key in the ring |
| 44 | + + join Makes node (re)join the cluster |
| 45 | + status Status of members in ring |
| 46 | + partitions Show partition information of a ring |
| 47 | + top General membership information |
| 48 | + Accept this change? [yN] |
| 49 | + |
| 50 | + |
| 51 | +When you press 'Y' the test file will automatically be updated. You should commit the updated file to the repository. |
| 52 | + |
| 53 | +Creating new tests |
| 54 | +------------------ |
| 55 | + |
| 56 | +There is a tool to help you get started creating new tests. |
| 57 | + |
| 58 | +Call this script with an optional description and then the command you want to test: |
| 59 | + |
| 60 | + ./create-cram-test "Test help output" -- ringpop-admin --help |
| 61 | + |
| 62 | +The script will output a valid cram test to stdout. |
0 commit comments