more integration test robustness

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett 2015-03-07 18:19:15 -05:00
parent a26f59ddcd
commit ed4fa09311
No known key found for this signature in database
GPG Key ID: A519480096146526
17 changed files with 60 additions and 47 deletions

View File

@ -128,7 +128,7 @@ BATS (use that link). Then run `./script/build` to generate the binary. Once
you have the binary, you can run test against a specified driver:
```
$ bats integration-tests/driver-virtualbox.bats
$ bats test/integration/driver-virtualbox.bats
✓ virtualbox: machine should not exist
✓ virtualbox: VM should not exist
✓ virtualbox: create
@ -154,7 +154,7 @@ $ bats integration-tests/driver-virtualbox.bats
You can also run the general `cli` tests:
```
$ bats integration-tests/cli.bats
$ bats test/integration/cli.bats
✓ cli: show info
✓ cli: show active help
✓ cli: show config help

View File

@ -1,2 +0,0 @@
// stub for coverage
package test

View File

@ -1,14 +0,0 @@
#!/bin/bash
PLATFORM=`uname -s | tr '[:upper:]' '[:lower:]'`
ARCH=`uname -m`
if [ "$ARCH" = "x86_64" ]; then
ARCH="amd64"
else
ARCH="386"
fi
function machine() {
./docker-machine_$PLATFORM-$ARCH $@
}

View File

@ -41,7 +41,7 @@ fi
# Script will bomb out on some dirs if there are no buildable source files,
# we shouldn't be checking these anyway so skip over them.
EXCLUDED_DIRS="${DIR}/Godeps ${DIR}/integration-tests ${DIR}/docs ${DIR}/script"
EXCLUDED_DIRS="${DIR}/Godeps ${DIR}/test ${DIR}/docs ${DIR}/script"
generate_coverage_for_dir ${DIR}
echo "Done checking and generating coverage!"

View File

@ -1,106 +1,106 @@
#!/usr/bin/env bats
load vars
load helpers
@test "cli: show info" {
run ./docker-machine_$PLATFORM-$ARCH
run machine
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "NAME:" ]]
[[ ${lines[1]} =~ "Create and manage machines running Docker" ]]
}
@test "cli: show active help" {
run ./docker-machine_$PLATFORM-$ARCH active -h
run machine active -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command active" ]]
}
@test "cli: show config help" {
run ./docker-machine_$PLATFORM-$ARCH config -h
run machine config -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command config" ]]
}
@test "cli: show inspect help" {
run ./docker-machine_$PLATFORM-$ARCH inspect -h
run machine inspect -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command inspect" ]]
}
@test "cli: show ip help" {
run ./docker-machine_$PLATFORM-$ARCH ip -h
run machine ip -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command ip" ]]
}
@test "cli: show kill help" {
run ./docker-machine_$PLATFORM-$ARCH kill -h
run machine kill -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command kill" ]]
}
@test "cli: show ls help" {
run ./docker-machine_$PLATFORM-$ARCH ls -h
run machine ls -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command ls" ]]
}
@test "cli: show restart help" {
run ./docker-machine_$PLATFORM-$ARCH restart -h
run machine restart -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command restart" ]]
}
@test "cli: show rm help" {
run ./docker-machine_$PLATFORM-$ARCH rm -h
run machine rm -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command rm" ]]
}
@test "cli: show env help" {
run ./docker-machine_$PLATFORM-$ARCH env -h
run machine env -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command env" ]]
}
@test "cli: show ssh help" {
run ./docker-machine_$PLATFORM-$ARCH ssh -h
run machine ssh -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command ssh" ]]
}
@test "cli: show start help" {
run ./docker-machine_$PLATFORM-$ARCH start -h
run machine start -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command start" ]]
}
@test "cli: show stop help" {
run ./docker-machine_$PLATFORM-$ARCH stop -h
run machine stop -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command stop" ]]
}
@test "cli: show upgrade help" {
run ./docker-machine_$PLATFORM-$ARCH upgrade -h
run machine upgrade -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command upgrade" ]]
}
@test "cli: show url help" {
run ./docker-machine_$PLATFORM-$ARCH url -h
run machine url -h
[ "$status" -eq 0 ]
[[ ${lines[3]} =~ "command url" ]]
}
@test "flag: show version" {
run ./docker-machine_$PLATFORM-$ARCH -v
run machine -v
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "version" ]]
}
@test "flag: show help" {
run ./docker-machine_$PLATFORM-$ARCH --help
run machine --help
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "NAME" ]]
}

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bats
load vars
load helpers
export DRIVER=amazonec2
export NAME="bats-$DRIVER-test"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bats
load vars
load helpers
export DRIVER=azure
export NAME="bats-$DRIVER-test"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bats
load vars
load helpers
export DRIVER=digitalocean
export NAME="bats-$DRIVER-test"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bats
load vars
load helpers
export DRIVER=google
export NAME="bats-$DRIVER-test"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bats
load vars
load helpers
export DRIVER=hyperv
export NAME="bats-$DRIVER-test"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bats
load vars
load helpers
export DRIVER=rackspace
export NAME="bats-$DRIVER-test"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bats
load vars
load helpers
export DRIVER=softlayer
export NAME="bats-$DRIVER-test"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bats
load vars
load helpers
export DRIVER=virtualbox
export NAME="bats-$DRIVER-test"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bats
load vars
load helpers
export DRIVER=vmwarefusion
export NAME="bats-$DRIVER-test"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bats
load vars
load helpers
export DRIVER=vmwarevcloudair
export NAME="bats-$DRIVER-test"

View File

@ -0,0 +1,29 @@
#!/bin/bash
# Root directory of the repository.
MACHINE_ROOT=${BATS_TEST_DIRNAME}/../..
PLATFORM=`uname -s | tr '[:upper:]' '[:lower:]'`
ARCH=`uname -m`
if [ "$ARCH" = "x86_64" ]; then
ARCH="amd64"
else
ARCH="386"
fi
MACHINE_BIN_NAME=docker-machine_$PLATFORM-$ARCH
build_machine() {
pushd $MACHINE_ROOT >/dev/null
godep go build -o $MACHINE_BIN_NAME
popd >/dev/null
}
# build machine binary if needed
if [ ! -e $MACHINE_ROOT/$MACHINE_BIN_NAME ]; then
build_machine
fi
function machine() {
${MACHINE_ROOT}/$MACHINE_BIN_NAME "$@"
}