run.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. goreman -f /insecure/Procfile start &
  7. # TODO: remove random sleeps
  8. sleep 7s
  9. ETCDCTL_API=3 ./etcdctl \
  10. --endpoints=http://m1.etcd.local:2379 \
  11. endpoint health --cluster
  12. ETCDCTL_API=3 ./etcdctl \
  13. --endpoints=http://m1.etcd.local:2379,http://m2.etcd.local:22379,http://m3.etcd.local:32379 \
  14. put abc def
  15. ETCDCTL_API=3 ./etcdctl \
  16. --endpoints=http://m1.etcd.local:2379,http://m2.etcd.local:22379,http://m3.etcd.local:32379 \
  17. get abc
  18. printf "\nWriting v2 key...\n"
  19. curl \
  20. -L http://127.0.0.1:2379/v2/keys/queue \
  21. -X POST \
  22. -d value=data
  23. printf "\nWriting v2 key...\n"
  24. curl \
  25. -L http://m1.etcd.local:2379/v2/keys/queue \
  26. -X POST \
  27. -d value=data
  28. printf "\nWriting v3 key...\n"
  29. curl \
  30. -L http://127.0.0.1:2379/v3/kv/put \
  31. -X POST \
  32. -d '{"key": "Zm9v", "value": "YmFy"}'
  33. printf "\n\nWriting v3 key...\n"
  34. curl \
  35. -L http://m1.etcd.local:2379/v3/kv/put \
  36. -X POST \
  37. -d '{"key": "Zm9v", "value": "YmFy"}'
  38. printf "\n\nReading v3 key...\n"
  39. curl \
  40. -L http://m1.etcd.local:2379/v3/kv/range \
  41. -X POST \
  42. -d '{"key": "Zm9v"}'
  43. printf "\n\nFetching 'curl http://m1.etcd.local:2379/metrics'...\n"
  44. curl \
  45. -L http://m1.etcd.local:2379/metrics | grep Put | tail -3
  46. name1=$(base64 <<< "/election-prefix")
  47. val1=$(base64 <<< "v1")
  48. data1="{\"name\":\"${name1}\", \"value\":\"${val1}\"}"
  49. printf "\n\nCampaign: ${data1}\n"
  50. result1=$(curl -L http://m1.etcd.local:2379/v3/election/campaign -X POST -d "${data1}")
  51. echo ${result1}
  52. # should not panic servers
  53. val2=$(base64 <<< "v2")
  54. data2="{\"value\": \"${val2}\"}"
  55. printf "\n\nProclaim (wrong-format): ${data2}\n"
  56. curl \
  57. -L http://m1.etcd.local:2379/v3/election/proclaim \
  58. -X POST \
  59. -d "${data2}"
  60. printf "\n\nProclaim (wrong-format)...\n"
  61. curl \
  62. -L http://m1.etcd.local:2379/v3/election/proclaim \
  63. -X POST \
  64. -d '}'
  65. printf "\n\nProclaim (wrong-format)...\n"
  66. curl \
  67. -L http://m1.etcd.local:2379/v3/election/proclaim \
  68. -X POST \
  69. -d '{"value": "Zm9v"}'
  70. printf "\n\nDone!!!\n\n"