1
0
mirror of https://github.com/docker/docs.git synced 2026-11-05 00:14:17 +03:00

split out drivers

more flexibility for testing; not all drivers support the same actions

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett
2015-02-25 20:20:04 -05:00
parent 00a6395667
commit e33558e6a4
4 changed files with 194 additions and 103 deletions

View File

@@ -0,0 +1,84 @@
#!/usr/bin/env bats
load vars
DRIVER=rackspace
NAME="bats-$DRIVER-test"
MACHINE_STORAGE_PATH=/tmp/machine-bats-test-$DRIVER
@test "$DRIVER: machine should not exist" {
run ./docker-machine_$PLATFORM-$ARCH active $NAME
[ "$status" -eq 1 ]
}
@test "$DRIVER: create" {
run ./docker-machine_$PLATFORM-$ARCH create -d $DRIVER $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: active" {
run ./docker-machine_$PLATFORM-$ARCH active $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: ls" {
run ./docker-machine_$PLATFORM-$ARCH ls
[ "$status" -eq 0 ]
[[ ${lines[1]} =~ "$NAME" ]]
[[ ${lines[1]} =~ "*" ]]
}
@test "$DRIVER: url" {
run ./docker-machine_$PLATFORM-$ARCH url $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: ip" {
run ./docker-machine_$PLATFORM-$ARCH ip $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: ssh" {
run ./docker-machine_$PLATFORM-$ARCH ssh $NAME -- ls -lah /
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "total" ]]
}
@test "$DRIVER: stop should fail (unsupported)" {
run ./docker-machine_$PLATFORM-$ARCH stop $NAME
[[ ${lines[1]} =~ "not currently support" ]]
}
@test "$DRIVER: start should fail (unsupported)" {
run ./docker-machine_$PLATFORM-$ARCH start $NAME
[[ ${lines[1]} =~ "not currently support" ]]
}
@test "$DRIVER: restart" {
run ./docker-machine_$PLATFORM-$ARCH restart $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: machine should show running after restart" {
run ./docker-machine_$PLATFORM-$ARCH ls
[ "$status" -eq 0 ]
[[ ${lines[1]} =~ "$NAME" ]]
[[ ${lines[1]} =~ "Running" ]]
}
@test "$DRIVER: remove" {
run ./docker-machine_$PLATFORM-$ARCH rm $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: machine should not exist" {
run ./docker-machine_$PLATFORM-$ARCH active $NAME
[ "$status" -eq 1 ]
}
@test "$DRIVER: cleanup" {
run rm -rf $MACHINE_STORAGE_PATH
[ "$status" -eq 0 ]
}

110
test/driver-virtualbox.bats Normal file
View File

@@ -0,0 +1,110 @@
#!/usr/bin/env bats
load vars
DRIVER=virtualbox
NAME="bats-$DRIVER-test"
MACHINE_STORAGE_PATH=/tmp/machine-bats-test-$DRIVER
@test "$DRIVER: machine should not exist" {
run ./docker-machine_$PLATFORM-$ARCH active $NAME
[ "$status" -eq 1 ]
}
@test "$DRIVER: create" {
run ./docker-machine_$PLATFORM-$ARCH create -d $DRIVER $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: active" {
run ./docker-machine_$PLATFORM-$ARCH active $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: ls" {
run ./docker-machine_$PLATFORM-$ARCH ls
[ "$status" -eq 0 ]
[[ ${lines[1]} =~ "$NAME" ]]
[[ ${lines[1]} =~ "*" ]]
}
@test "$DRIVER: url" {
run ./docker-machine_$PLATFORM-$ARCH url $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: ip" {
run ./docker-machine_$PLATFORM-$ARCH ip $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: ssh" {
run ./docker-machine_$PLATFORM-$ARCH ssh $NAME -- ls -lah /
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "total" ]]
}
@test "$DRIVER: stop" {
run ./docker-machine_$PLATFORM-$ARCH stop $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: machine should show stopped after stop" {
run ./docker-machine_$PLATFORM-$ARCH ls
[ "$status" -eq 0 ]
[[ ${lines[1]} =~ "$NAME" ]]
[[ ${lines[1]} =~ "Stopped" ]]
}
@test "$DRIVER: start" {
run ./docker-machine_$PLATFORM-$ARCH start $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: machine should show running after start" {
run ./docker-machine_$PLATFORM-$ARCH ls
[ "$status" -eq 0 ]
[[ ${lines[1]} =~ "$NAME" ]]
[[ ${lines[1]} =~ "Running" ]]
}
@test "$DRIVER: kill" {
run ./docker-machine_$PLATFORM-$ARCH kill $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: machine should show stopped after kill" {
run ./docker-machine_$PLATFORM-$ARCH ls
[ "$status" -eq 0 ]
[[ ${lines[1]} =~ "$NAME" ]]
[[ ${lines[1]} =~ "Stopped" ]]
}
@test "$DRIVER: restart" {
run ./docker-machine_$PLATFORM-$ARCH restart $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: machine should show running after restart" {
run ./docker-machine_$PLATFORM-$ARCH ls
[ "$status" -eq 0 ]
[[ ${lines[1]} =~ "$NAME" ]]
[[ ${lines[1]} =~ "Running" ]]
}
@test "$DRIVER: remove" {
run ./docker-machine_$PLATFORM-$ARCH rm -f $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: machine should not exist" {
run ./docker-machine_$PLATFORM-$ARCH active $NAME
[ "$status" -eq 1 ]
}
@test "$DRIVER: cleanup" {
run rm -rf $MACHINE_STORAGE_PATH
[ "$status" -eq 0 ]
}

View File

@@ -1,101 +0,0 @@
#!/usr/bin/env bats
load vars
if [ -z "$DRIVER" ]; then
echo "You must set the DRIVER environment variable"
exit 1
fi
NAME="bats-$DRIVER-test"
MACHINE_STORAGE_PATH=/tmp/machine-bats-test-$DRIVER
@test "$DRIVER: machine should not exist" {
run ./docker-machine_$PLATFORM-$ARCH active $NAME
[ "$status" -eq 1 ]
}
@test "$DRIVER: create" {
run ./docker-machine_$PLATFORM-$ARCH create -d $DRIVER $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: active" {
run ./docker-machine_$PLATFORM-$ARCH active $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: ls" {
run ./docker-machine_$PLATFORM-$ARCH ls
[ "$status" -eq 0 ]
[[ ${lines[1]} =~ "$NAME" ]]
[[ ${lines[1]} =~ "*" ]]
}
@test "$DRIVER: url" {
run ./docker-machine_$PLATFORM-$ARCH url $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: ip" {
run ./docker-machine_$PLATFORM-$ARCH ip $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: ssh" {
run ./docker-machine_$PLATFORM-$ARCH ssh $NAME -- ls -lah /
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "total" ]]
}
case "$DRIVER" in
[digitalocean,amazonec2,virtualbox]*)
@test "$DRIVER: stop" {
run ./docker-machine_$PLATFORM-$ARCH stop $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: machine should show stopped" {
run ./docker-machine_$PLATFORM-$ARCH ls
[ "$status" -eq 0 ]
[[ ${lines[1]} =~ "$NAME" ]]
[[ ${lines[1]} =~ "Stopped" ]]
}
@test "$DRIVER: start" {
run ./docker-machine_$PLATFORM-$ARCH start $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: machine should show running after start" {
run ./docker-machine_$PLATFORM-$ARCH ls
[ "$status" -eq 0 ]
[[ ${lines[1]} =~ "$NAME" ]]
[[ ${lines[1]} =~ "Running" ]]
}
@test "$DRIVER: restart" {
run ./docker-machine_$PLATFORM-$ARCH restart $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: machine should show running after restart" {
run ./docker-machine_$PLATFORM-$ARCH ls
[ "$status" -eq 0 ]
[[ ${lines[1]} =~ "$NAME" ]]
[[ ${lines[1]} =~ "Running" ]]
}
;;
esac
@test "$DRIVER: remove" {
run ./docker-machine_$PLATFORM-$ARCH rm $NAME
[ "$status" -eq 0 ]
}
@test "$DRIVER: machine should not exist" {
run ./docker-machine_$PLATFORM-$ARCH active $NAME
[ "$status" -eq 1 ]
}

View File

@@ -8,5 +8,3 @@ if [ "$ARCH" = "x86_64" ]; then
else
ARCH="386"
fi
DRIVER=${DRIVER:-}