run.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. rm -rf /tmp/m1.data /tmp/m2.data /tmp/m3.data
  3. /etc/init.d/bind9 start
  4. # get rid of hosts so go lookup won't resolve 127.0.0.1 to localhost
  5. cat /dev/null >/etc/hosts
  6. echo "127.0.0.1 m1.etcd.local" >> /etc/hosts
  7. echo "127.0.0.1 m2.etcd.local" >> /etc/hosts
  8. echo "127.0.0.1 m3.etcd.local" >> /etc/hosts
  9. goreman -f /certs-san-dns/Procfile start &
  10. # TODO: remove random sleeps
  11. sleep 7s
  12. ETCDCTL_API=3 ./etcdctl \
  13. --cacert=/certs-san-dns/ca.crt \
  14. --cert=/certs-san-dns/server-1.crt \
  15. --key=/certs-san-dns/server-1.key.insecure \
  16. --endpoints=https://m1.etcd.local:2379,https://m2.etcd.local:22379,https://m3.etcd.local:32379 \
  17. endpoint health --cluster
  18. printf "\nPut abc \n"
  19. ETCDCTL_API=3 ./etcdctl \
  20. --cacert=/certs-san-dns/ca.crt \
  21. --cert=/certs-san-dns/server-2.crt \
  22. --key=/certs-san-dns/server-2.key.insecure \
  23. --endpoints=https://m1.etcd.local:2379,https://m2.etcd.local:22379,https://m3.etcd.local:32379 \
  24. put abc def
  25. printf "\nGet abc \n"
  26. ETCDCTL_API=3 ./etcdctl \
  27. --cacert=/certs-san-dns/ca.crt \
  28. --cert=/certs-san-dns/server-3.crt \
  29. --key=/certs-san-dns/server-3.key.insecure \
  30. --endpoints=https://m1.etcd.local:2379,https://m2.etcd.local:22379,https://m3.etcd.local:32379 \
  31. get abc
  32. printf "\nKill etcd server 1...\n"
  33. kill $(lsof -t -i:2379)
  34. sleep 7s
  35. printf "\nGet abc after killing server 1\n"
  36. ETCDCTL_API=3 ./etcdctl \
  37. --cacert=/certs-san-dns/ca.crt \
  38. --cert=/certs-san-dns/server-2.crt \
  39. --key=/certs-san-dns/server-2.key.insecure \
  40. --endpoints=https://m1.etcd.local:2379,https://m2.etcd.local:22379,https://m3.etcd.local:32379 \
  41. get abc
  42. printf "\n\nDone!!!\n\n"