README.md
1# Cluster Test
2
3This directory contains a program you can use to test a cluster.
4
5Here's how:
6
7First, install a cluster of Elasticsearch nodes. You can install them on
8different computers, or start several nodes on a single machine.
9
10Build cluster-test by `go build cluster-test.go` (or build with `make`).
11
12Run `./cluster-test -h` to get a list of flags:
13
14```sh
15$ ./cluster-test -h
16Usage of ./cluster-test:
17 -errorlog="": error log file
18 -healthcheck=true: enable or disable healthchecks
19 -healthchecker=1m0s: healthcheck interval
20 -index="twitter": name of ES index to use
21 -infolog="": info log file
22 -n=5: number of goroutines that run searches
23 -nodes="": comma-separated list of ES URLs (e.g. 'http://192.168.2.10:9200,http://192.168.2.11:9200')
24 -retries=0: number of retries
25 -sniff=true: enable or disable sniffer
26 -sniffer=15m0s: sniffer interval
27 -tracelog="": trace log file
28```
29
30Example:
31
32```sh
33$ ./cluster-test -nodes=http://127.0.0.1:9200,http://127.0.0.1:9201,http://127.0.0.1:9202 -n=5 -index=twitter -retries=5 -sniff=true -sniffer=10s -healthcheck=true -healthchecker=5s -errorlog=error.log
34```
35
36The above example will create an index and start some search jobs on the
37cluster defined by http://127.0.0.1:9200, http://127.0.0.1:9201,
38and http://127.0.0.1:9202.
39
40* It will create an index called `twitter` on the cluster (`-index=twitter`)
41* It will run 5 search jobs in parallel (`-n=5`).
42* It will retry failed requests 5 times (`-retries=5`).
43* It will sniff the cluster periodically (`-sniff=true`).
44* It will sniff the cluster every 10 seconds (`-sniffer=10s`).
45* It will perform health checks periodically (`-healthcheck=true`).
46* It will perform health checks on the nodes every 5 seconds (`-healthchecker=5s`).
47* It will write an error log file (`-errorlog=error.log`).
48
49If you want to test Elastic with nodes going up and down, you can use a
50chaos monkey script like this and run it on the nodes of your cluster:
51
52```sh
53#!/bin/bash
54while true
55do
56 echo "Starting ES node"
57 elasticsearch -d -Xmx4g -Xms1g -Des.config=elasticsearch.yml -p es.pid
58 sleep `jot -r 1 10 300` # wait for 10-300s
59 echo "Stopping ES node"
60 kill -TERM `cat es.pid`
61 sleep `jot -r 1 10 60` # wait for 10-60s
62done
63```
64