1
0
mirror of https://github.com/jcwimer/startup-infrastructure synced 2026-03-24 22:34:42 +00:00

Create swarm and test swarm creation. test function needed renamed because test is a bash thing already

This commit is contained in:
2018-10-10 14:24:42 -04:00
parent 2c0ca361de
commit 9f4b12185a
8 changed files with 127 additions and 28 deletions

View File

@@ -12,7 +12,8 @@ chosen_timezone: "America/New_York"
# this will allow automatic dns for for things like dokuwiki.test.com and portainer.test.com
root_domain: test.com
# interface for the swarm network
swarm_network_interface: enp0s8
### Persistent storage if you are doing a single machine deploy, local is an option. If you are doing multi instance deploy, choose one of the following:
# nfs

View File

@@ -5,7 +5,7 @@ green=`tput setaf 2`
reset=`tput sgr0`
#echo "${red}red text ${green}green text${reset}"
function test {
function testbash() {
local name="${1}"
shift
local command="${@}"

View File

@@ -8,19 +8,42 @@ function main {
run-tests
destroy-infrastructure
}
function run-tests {
trap "destroy-infrastructure; exit 1" ERR
echo Building vagrant infrastructure
vagrant up
test "Running command on a vagrant node should not fail." \
testbash "Running command on a vagrant node should not fail." \
"vagrant ssh client -c 'ls /vagrant'"
test "Client vagrant machine can ssh into bootstrap." \
testbash "Client vagrant machine can ssh into bootstrap." \
"vagrant ssh client -c 'ssh -o StrictHostKeyChecking=no -i /home/vagrant/test_rsa vagrant@192.168.254.2 ls'"
test "Running deploy script should not fail." \
testbash "Running deploy script should not fail." \
"vagrant ssh client -c 'bash /vagrant/tests/files/run-test-deploy.sh'"
local -r node_ls_output=$(vagrant ssh bootstrap \
-c "docker node ls --format '{{.Hostname}} {{.Status}} {{.Availability}} {{.ManagerStatus}}'"
)
echo docker node ls output is:
echo $node_ls_output
local -r number_of_docker_leaders=$(echo "${node_ls_output}" \
| grep -v 'Connection' \
| awk '{ print $4 }' \
| grep '^Leader$' \
| wc -l)
local -r number_of_docker_nodes=$(echo "${node_ls_output}" \
| grep -v 'Connection' \
| awk '{ print $1 }' \
| wc -l)
testbash "There are 2 docker swarm nodes" \
"test ${number_of_docker_nodes} -eq 2"
testbash "The swarm has a leader" \
"test ${number_of_docker_leaders} -eq 1"
}
function destroy-infrastructure {