Last active
August 29, 2015 14:01
-
-
Save lalyos/9395064c8b70474e37e9 to your computer and use it in GitHub Desktop.
boot2docker test in bats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### | |
# curl -Ls j.mp/b2d-test | bash | |
#### | |
# checks for bats | |
bats -v &>/dev/null || ( echo "bats (Bash Automated Testing System) missing, installing it ..." ; brew install bats ) | |
echo [DEBUG] lets create a bash test script in /tmp | |
cat > /tmp/b2d-test << "ENDOFTEST" | |
#!/usr/bin/env bats | |
checkVersion() { | |
docker version |sed -n "s/$1 version: //p" | |
} | |
@test "docker client is 0.11.1" { | |
run checkVersion Client | |
[ "$output" = "0.11.1" ] | |
} | |
@test "docker server is 0.11.1" { | |
run checkVersion Server | |
[ "$output" = "0.11.1" ] | |
} | |
@test "b2d has bridge0" { | |
run bash -c "boot2docker ssh ifconfig bridge0>/dev/null" | |
[ "$status" -eq 0 ] | |
} | |
@test "docker daemon using bridge0" { | |
run bash -c "boot2docker ssh sh -c 'ps -ef|grep bin/docker|grep bridge0'>/dev/null" | |
[ "$status" -eq 0 ] | |
} | |
@test "host has route entry 172.xxx into b2d" { | |
run bash -c " netstat -nr| grep '^172.*vboxnet$' >/dev/null" | |
[ "$status" -eq 0 ] | |
} | |
@test "b2d has internet" { | |
run boot2docker ssh ping -W 1 -c 1 google.com | |
[ "$status" -eq 0 ] | |
} | |
@test "passwordless ssh into boot2docker" { | |
run bash -c "boot2docker ssh hostname 2>/dev/null" | |
[ "$status" -eq 0 ] | |
[ "$output" = "boot2docker" ] | |
} | |
ENDOFTEST | |
chmod +x /tmp/b2d-test | |
cat << "USAGE" | |
now you can run the checks anytime by creating an alias | |
########### | |
# alias b2d-test=/tmp/b2d-test | |
########### | |
USAGE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment