Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. #!/bin/bash
  2. set -euo pipefail
  3.  
  4. ### public api
  5.  
  6. setup() {
  7. echo "$SSH_USER" > /dev/null
  8. echo "$SSH_ADDRESS" > /dev/null
  9.  
  10. publics="$(detect_public $SSH_USER $SSH_ADDRESS)"
  11. privates="$(detect_private $SSH_USER $SSH_ADDRESS)"
  12.  
  13. set +e
  14. read -r -d '' PROFILE_VAR <<EOF
  15. source /opt/mesosphere/packages/dcos-integration-test--*/util/test_env.export
  16. #dcos_add_user.py ayakovenko@mesosphere.io || echo no dcos_add_user.py
  17. export DCOS_LOGIN_PW=deleteme
  18. export DCOS_LOGIN_UNAME=bootstrapuser
  19. set -o vi
  20. SLAVE_HOSTS=$privates
  21. PUBLIC_SLAVE_HOSTS=$publics
  22. EOF
  23. set -e
  24.  
  25. ssh -o "LogLevel QUIET" \
  26. -o "StrictHostKeyChecking no" \
  27. -o "UserKnownHostsFile /dev/null" \
  28. -A \
  29. "$SSH_USER@$SSH_ADDRESS" \
  30. "echo \"$PROFILE_VAR\" >> ~/.profile"
  31. }
  32.  
  33. # For example: test_networking.py::test_vip
  34. # For example: test_service_discovery.py
  35. run_test() {
  36. echo "$SSH_USER" > /dev/null
  37. echo "$SSH_ADDRESS" > /dev/null
  38.  
  39. teststr="$1"
  40.  
  41. ssh -o "LogLevel QUIET" \
  42. -o "StrictHostKeyChecking no" \
  43. -o "UserKnownHostsFile /dev/null" \
  44. -A -t \
  45. "$SSH_USER@$SSH_ADDRESS" \
  46. "source ~/.profile && cd /opt/mesosphere/active/dcos-integration-test && py.test -s -vv $teststr"
  47. }
  48.  
  49. push_file() {
  50. echo "$SSH_USER" > /dev/null
  51. echo "$SSH_ADDRESS" > /dev/null
  52.  
  53. localfile="$1"
  54. remotefile="$2"
  55.  
  56. scp -o "LogLevel QUIET" \
  57. -o "StrictHostKeyChecking no" \
  58. -o "UserKnownHostsFile /dev/null" \
  59. "$localfile" \
  60. "$SSH_USER@$SSH_ADDRESS:~/tmpfile"
  61.  
  62. ssh -o "LogLevel QUIET" \
  63. -o "StrictHostKeyChecking no" \
  64. -o "UserKnownHostsFile /dev/null" \
  65. -A \
  66. "$SSH_USER@$SSH_ADDRESS" \
  67. "sudo mv ~/tmpfile /opt/mesosphere/active/dcos-integration-test/$remotefile"
  68. }
  69.  
  70. ### private api
  71.  
  72. detect_public() {
  73. user=$1
  74. addr=$2
  75.  
  76. ssh -o "LogLevel QUIET" \
  77. -o "StrictHostKeyChecking no" \
  78. -o "UserKnownHostsFile /dev/null" \
  79. -A \
  80. "$user@$addr" \
  81. "for h in \$(host slave.mesos | cut -d' ' -f4); do curl -s \$h:5051/state | grep '\"default_role\":\"slave_public\"' >/dev/null && printf \",\$h\"; done | cut -d',' -f2-"
  82. }
  83.  
  84. detect_private() {
  85. user=$1
  86. addr=$2
  87.  
  88. ssh -o "LogLevel QUIET" \
  89. -o "StrictHostKeyChecking no" \
  90. -o "UserKnownHostsFile /dev/null" \
  91. -A \
  92. "$user@$addr" \
  93. "for h in \$(host slave.mesos | cut -d' ' -f4); do curl -s \$h:5051/state | grep '\"default_role\":\"slave_public\"' >/dev/null || printf \",\$h\"; done | cut -d',' -f2-"
  94. }
  95.  
  96. ### main
  97.  
  98. "$1" "${@:2}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement