test-cluster 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash -x
  2. SESSION=etcd-cluster
  3. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  4. ulimit -n unlimited
  5. tmux new-session -d -s $SESSION
  6. mkdir test-cluster
  7. peer_args=
  8. if [ -n "${DISCOVERY_URL}" ]; then
  9. peer_args="-discovery ${DISCOVERY_URL}"
  10. fi
  11. # Setup a window for tailing log files
  12. tmux new-window -t $SESSION:1 -n 'peers'
  13. tmux split-window -h
  14. tmux select-pane -t 0
  15. tmux send-keys "${DIR}/../bin/etcd -peer-addr 127.0.0.1:7001 -addr 127.0.0.1:4001 -data-dir test-cluster/peer1 -name peer1 ${peer_args}" C-m
  16. if [ -z "${peer_args}" ]; then
  17. peer_args="-peers 127.0.0.1:7001"
  18. fi
  19. for i in 2 3; do
  20. tmux select-pane -t 0
  21. tmux split-window -v
  22. tmux send-keys "sleep 2; ${DIR}/../bin/etcd -cors='*' -peer-addr 127.0.0.1:700${i} -addr 127.0.0.1:400${i} -data-dir test-cluster/peer${i} -name peer${i} ${peer_args}" C-m
  23. done
  24. tmux new-window -t $SESSION:2 -n 'proxy'
  25. tmux split-window -h
  26. tmux select-pane -t 0
  27. tmux send-keys "curl -XPUT -H \"Content-Type: application/json\" -d '{\"activeSize\":3, \"removeDelay\":30}' http://127.0.0.1:7001/v2/admin/config" C-m
  28. for i in 4 5 6; do
  29. tmux select-pane -t 0
  30. tmux split-window -v
  31. tmux send-keys "sleep 5; ${DIR}/../bin/etcd -cors='*' -peer-addr 127.0.0.1:700${i} -addr 127.0.0.1:400${i} -data-dir test-cluster/peer${i} -name peer${i} ${peer_args}" C-m
  32. done
  33. # Attach to session
  34. tmux attach-session -t $SESSION