Merge pull request #754 from ehazlett/integration-test-updates

more integration test robustness
This commit is contained in:
Evan Hazlett 2015-03-07 18:24:45 -05:00
commit 9d7c6874fe
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: 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: machine should not exist
✓ virtualbox: VM should not exist ✓ virtualbox: VM should not exist
✓ virtualbox: create ✓ virtualbox: create
@ -154,7 +154,7 @@ $ bats integration-tests/driver-virtualbox.bats
You can also run the general `cli` tests: You can also run the general `cli` tests:
``` ```
$ bats integration-tests/cli.bats $ bats test/integration/cli.bats
✓ cli: show info ✓ cli: show info
✓ cli: show active help ✓ cli: show active help
✓ cli: show config 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, # 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. # 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} generate_coverage_for_dir ${DIR}
echo "Done checking and generating coverage!" echo "Done checking and generating coverage!"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load vars load helpers
export DRIVER=vmwarevcloudair export DRIVER=vmwarevcloudair
export NAME="bats-$DRIVER-test" 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 "$@"
}