docker-local-agent.sh 966 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. <<COMMENT
  3. # run 3 agents for 3-node local etcd cluster
  4. ./scripts/docker-local-agent.sh 1
  5. ./scripts/docker-local-agent.sh 2
  6. ./scripts/docker-local-agent.sh 3
  7. COMMENT
  8. if ! [[ "${0}" =~ "scripts/docker-local-agent.sh" ]]; then
  9. echo "must be run from functional"
  10. exit 255
  11. fi
  12. if [[ -z "${GO_VERSION}" ]]; then
  13. GO_VERSION=1.12.9
  14. fi
  15. echo "Running with GO_VERSION:" ${GO_VERSION}
  16. if [[ -z ${1} ]]; then
  17. echo "Expected second argument: 1, 2, or 3"
  18. exit 255
  19. else
  20. case ${1} in
  21. 1) ;;
  22. 2) ;;
  23. 3) ;;
  24. *) echo "Expected second argument 1, 2, or 3, got" \"${1}\"
  25. exit 255 ;;
  26. esac
  27. AGENT_NAME="agent-${1}"
  28. AGENT_ADDR_FLAG="--network tcp --address 127.0.0.1:${1}9027"
  29. fi
  30. echo "AGENT_NAME:" ${AGENT_NAME}
  31. echo "AGENT_ADDR_FLAG:" ${AGENT_ADDR_FLAG}
  32. docker run \
  33. --rm \
  34. --net=host \
  35. --name ${AGENT_NAME} \
  36. gcr.io/etcd-development/etcd-functional:go${GO_VERSION} \
  37. /bin/bash -c "./bin/etcd-agent ${AGENT_ADDR_FLAG}"