Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -euo pipefail
- ### public api
- setup() {
- echo "$SSH_USER" > /dev/null
- echo "$SSH_ADDRESS" > /dev/null
- publics="$(detect_public $SSH_USER $SSH_ADDRESS)"
- privates="$(detect_private $SSH_USER $SSH_ADDRESS)"
- set +e
- read -r -d '' PROFILE_VAR <<EOF
- source /opt/mesosphere/packages/dcos-integration-test--*/util/test_env.export
- #dcos_add_user.py ayakovenko@mesosphere.io || echo no dcos_add_user.py
- export DCOS_LOGIN_PW=deleteme
- export DCOS_LOGIN_UNAME=bootstrapuser
- set -o vi
- SLAVE_HOSTS=$privates
- PUBLIC_SLAVE_HOSTS=$publics
- EOF
- set -e
- ssh -o "LogLevel QUIET" \
- -o "StrictHostKeyChecking no" \
- -o "UserKnownHostsFile /dev/null" \
- -A \
- "$SSH_USER@$SSH_ADDRESS" \
- "echo \"$PROFILE_VAR\" >> ~/.profile"
- }
- # For example: test_networking.py::test_vip
- # For example: test_service_discovery.py
- run_test() {
- echo "$SSH_USER" > /dev/null
- echo "$SSH_ADDRESS" > /dev/null
- teststr="$1"
- ssh -o "LogLevel QUIET" \
- -o "StrictHostKeyChecking no" \
- -o "UserKnownHostsFile /dev/null" \
- -A -t \
- "$SSH_USER@$SSH_ADDRESS" \
- "source ~/.profile && cd /opt/mesosphere/active/dcos-integration-test && py.test -s -vv $teststr"
- }
- push_file() {
- echo "$SSH_USER" > /dev/null
- echo "$SSH_ADDRESS" > /dev/null
- localfile="$1"
- remotefile="$2"
- scp -o "LogLevel QUIET" \
- -o "StrictHostKeyChecking no" \
- -o "UserKnownHostsFile /dev/null" \
- "$localfile" \
- "$SSH_USER@$SSH_ADDRESS:~/tmpfile"
- ssh -o "LogLevel QUIET" \
- -o "StrictHostKeyChecking no" \
- -o "UserKnownHostsFile /dev/null" \
- -A \
- "$SSH_USER@$SSH_ADDRESS" \
- "sudo mv ~/tmpfile /opt/mesosphere/active/dcos-integration-test/$remotefile"
- }
- ### private api
- detect_public() {
- user=$1
- addr=$2
- ssh -o "LogLevel QUIET" \
- -o "StrictHostKeyChecking no" \
- -o "UserKnownHostsFile /dev/null" \
- -A \
- "$user@$addr" \
- "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-"
- }
- detect_private() {
- user=$1
- addr=$2
- ssh -o "LogLevel QUIET" \
- -o "StrictHostKeyChecking no" \
- -o "UserKnownHostsFile /dev/null" \
- -A \
- "$user@$addr" \
- "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-"
- }
- ### main
- "$1" "${@:2}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement