mirror of https://github.com/docker/docs.git
Cleanup machines only at the end
Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
parent
17b1e571f2
commit
a708bf7e6c
|
@ -2,6 +2,9 @@
|
|||
|
||||
load ${BASE_TEST_DIR}/helpers.bash
|
||||
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(unique_machine_name)"
|
||||
fi
|
||||
|
||||
@test "$DRIVER: create" {
|
||||
run machine create --tls-san foo.bar.tld --tls-san 10.42.42.42 -d $DRIVER $NAME
|
||||
|
|
|
@ -2,17 +2,15 @@
|
|||
|
||||
load ${BASE_TEST_DIR}/helpers.bash
|
||||
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(shared_machine_name)"
|
||||
fi
|
||||
|
||||
@test "$DRIVER: machine should not exist" {
|
||||
run machine inspect $NAME
|
||||
run machine inspect UNKNOWN
|
||||
echo ${output}
|
||||
[ "$status" -eq 1 ]
|
||||
[[ ${lines[0]} =~ "Host does not exist: \"$NAME\"" ]]
|
||||
}
|
||||
|
||||
@test "$DRIVER: create" {
|
||||
run machine create -d $DRIVER $NAME
|
||||
echo ${output}
|
||||
[ "$status" -eq 0 ]
|
||||
[[ ${lines[0]} =~ "Host does not exist: \"UNKNOWN\"" ]]
|
||||
}
|
||||
|
||||
@test "$DRIVER: appears with ls" {
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
load ${BASE_TEST_DIR}/helpers.bash
|
||||
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(unique_machine_name)"
|
||||
fi
|
||||
|
||||
@test "$DRIVER: create with supported engine options" {
|
||||
run machine create -d $DRIVER \
|
||||
--engine-label spam=eggs \
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
load ${BASE_TEST_DIR}/helpers.bash
|
||||
|
||||
@test "$DRIVER: create" {
|
||||
run machine create -d $DRIVER $NAME
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(shared_machine_name)"
|
||||
fi
|
||||
|
||||
@test "$DRIVER: test basic bash / zsh notation" {
|
||||
run machine env $NAME
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
load ${BASE_TEST_DIR}/helpers.bash
|
||||
|
||||
@test "$DRIVER: create" {
|
||||
run machine create -d $DRIVER $NAME
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(shared_machine_name)"
|
||||
fi
|
||||
|
||||
@test "$DRIVER: inspect format template" {
|
||||
run machine inspect -f '{{.DriverName}}' $NAME
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
load ${BASE_TEST_DIR}/helpers.bash
|
||||
|
||||
@test "$DRIVER: create" {
|
||||
run machine create -d $DRIVER $NAME
|
||||
}
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(shared_machine_name)"
|
||||
fi
|
||||
|
||||
@test "$DRIVER: regenerate the certs" {
|
||||
run machine regenerate-certs -f $NAME
|
||||
|
|
|
@ -2,12 +2,10 @@
|
|||
|
||||
load ${BASE_TEST_DIR}/helpers.bash
|
||||
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(shared_machine_name)"
|
||||
export SECOND_MACHINE="$NAME-2"
|
||||
|
||||
@test "$DRIVER: create" {
|
||||
run machine create -d $DRIVER $NAME
|
||||
[[ ${status} -eq 0 ]]
|
||||
}
|
||||
fi
|
||||
|
||||
@test "$DRIVER: test machine scp command from remote to host" {
|
||||
machine ssh $NAME 'echo A file created remotely! >/tmp/foo.txt'
|
||||
|
|
|
@ -2,12 +2,9 @@
|
|||
|
||||
load ${BASE_TEST_DIR}/helpers.bash
|
||||
|
||||
# Basic smoke test for SSH backends
|
||||
|
||||
@test "$DRIVER: create SSH test box" {
|
||||
run machine create -d $DRIVER $NAME
|
||||
[[ "$status" -eq 0 ]]
|
||||
}
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(shared_machine_name)"
|
||||
fi
|
||||
|
||||
@test "$DRIVER: test external ssh backend" {
|
||||
run machine ssh $NAME df -h
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo_to_log() {
|
||||
function echo_to_log {
|
||||
echo "$BATS_TEST_NAME
|
||||
----------
|
||||
$output
|
||||
|
@ -9,27 +9,38 @@ $output
|
|||
" >> ${BATS_LOG}
|
||||
}
|
||||
|
||||
teardown() {
|
||||
function teardown {
|
||||
echo_to_log
|
||||
}
|
||||
|
||||
function errecho () {
|
||||
function errecho {
|
||||
>&2 echo "$@"
|
||||
}
|
||||
|
||||
function only_if_env () {
|
||||
function only_if_env {
|
||||
if [[ ${!1} != "$2" ]]; then
|
||||
errecho "This test requires the $1 environment variable to be set to $2. Skipping..."
|
||||
skip
|
||||
fi
|
||||
}
|
||||
|
||||
function require_env () {
|
||||
function require_env {
|
||||
if [[ -z ${!1} ]]; then
|
||||
errecho "This test requires the $1 environment variable to be set in order to run."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function unique_machine_name {
|
||||
echo "bats-$DRIVER-test-$(date +%s)"
|
||||
}
|
||||
|
||||
function shared_machine_name {
|
||||
if [[ $(machine ls -q --filter name=$SHARED_NAME | wc -l) -eq 0 ]]; then
|
||||
machine create -d $DRIVER $SHARED_NAME &>/dev/null
|
||||
fi
|
||||
echo "$SHARED_NAME"
|
||||
}
|
||||
|
||||
# Make sure these aren't set while tests run (can cause confusing behavior)
|
||||
unset DOCKER_HOST DOCKER_TLS_VERIFY DOCKER_CERT_DIR
|
||||
|
|
|
@ -14,9 +14,11 @@ function quiet_run () {
|
|||
}
|
||||
|
||||
function cleanup_machines() {
|
||||
if [[ $(machine ls -q | wc -l) -ne 0 ]]; then
|
||||
quiet_run machine rm -f $(machine ls -q)
|
||||
for MACHINE_NAME in $(machine ls -q); do
|
||||
if [[ "$MACHINE_NAME" != "$SHARED_NAME" ]] || [[ "$1" == "ALL" ]]; then
|
||||
quiet_run machine rm -f $MACHINE_NAME
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function cleanup_store() {
|
||||
|
@ -26,18 +28,15 @@ function cleanup_store() {
|
|||
}
|
||||
|
||||
function machine() {
|
||||
export PATH="$MACHINE_ROOT"/bin:$PATH
|
||||
"$MACHINE_ROOT"/bin/"$MACHINE_BIN_NAME" "$@"
|
||||
}
|
||||
|
||||
function run_bats() {
|
||||
for bats_file in $(find "$1" -name \*.bats); do
|
||||
export NAME="bats-$DRIVER-test-$(date +%s)"
|
||||
|
||||
# BATS returns non-zero to indicate the tests have failed, we shouldn't
|
||||
# neccesarily bail in this case, so that's the reason for the e toggle.
|
||||
echo "=> $bats_file"
|
||||
|
||||
# BATS returns non-zero to indicate the tests have failed, we shouldn't
|
||||
# necessarily bail in this case, so that's the reason for the e toggle.
|
||||
set +e
|
||||
bats "$bats_file"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
|
@ -88,13 +87,14 @@ export MACHINE_STORAGE_PATH="/tmp/machine-bats-test-$DRIVER"
|
|||
export MACHINE_BIN_NAME=docker-machine
|
||||
export BATS_LOG="$MACHINE_ROOT/bats.log"
|
||||
export B2D_LOCATION=~/.docker/machine/cache/boot2docker.iso
|
||||
export SHARED_NAME="bats-$DRIVER-test-shared-$(date +%s)"
|
||||
|
||||
# This function gets used in the integration tests, so export it.
|
||||
export -f machine
|
||||
|
||||
> "$BATS_LOG"
|
||||
|
||||
cleanup_machines
|
||||
cleanup_machines "ALL"
|
||||
cleanup_store
|
||||
|
||||
if [[ -f "$B2D_LOCATION" ]]; then
|
||||
|
@ -108,6 +108,7 @@ fi
|
|||
|
||||
run_bats "$BATS_FILE"
|
||||
|
||||
cleanup_machines "ALL"
|
||||
cleanup_store
|
||||
|
||||
exit ${EXIT_STATUS}
|
||||
|
|
|
@ -4,6 +4,10 @@ load ${BASE_TEST_DIR}/helpers.bash
|
|||
|
||||
only_if_env DRIVER virtualbox
|
||||
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(unique_machine_name)"
|
||||
fi
|
||||
|
||||
export BAD_URL="http://dev.null:9111/bad.iso"
|
||||
|
||||
@test "$DRIVER: Should not allow machine creation with bad ISO" {
|
||||
|
|
|
@ -4,9 +4,9 @@ load ${BASE_TEST_DIR}/helpers.bash
|
|||
|
||||
only_if_env DRIVER virtualbox
|
||||
|
||||
@test "$DRIVER: create" {
|
||||
run machine create -d $DRIVER $NAME
|
||||
}
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(shared_machine_name)"
|
||||
fi
|
||||
|
||||
@test "$DRIVER: verify that server cert checksum matches local checksum" {
|
||||
# TODO: This test is tightly coupled to VirtualBox right now, but should be
|
||||
|
|
|
@ -4,6 +4,10 @@ load ${BASE_TEST_DIR}/helpers.bash
|
|||
|
||||
only_if_env DRIVER virtualbox
|
||||
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(unique_machine_name)"
|
||||
fi
|
||||
|
||||
# Default memsize is 1024MB and disksize is 20000MB
|
||||
# These values are defined in drivers/virtualbox/virtualbox.go
|
||||
export DEFAULT_MEMSIZE=1024
|
||||
|
|
|
@ -4,6 +4,10 @@ load ${BASE_TEST_DIR}/helpers.bash
|
|||
|
||||
only_if_env DRIVER virtualbox
|
||||
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(unique_machine_name)"
|
||||
fi
|
||||
|
||||
@test "$DRIVER: Create a vm with a dns proxy set" {
|
||||
run machine create -d $DRIVER --virtualbox-dns-proxy=true $NAME
|
||||
[[ ${status} -eq 0 ]]
|
||||
|
|
|
@ -4,10 +4,9 @@ load ${BASE_TEST_DIR}/helpers.bash
|
|||
|
||||
only_if_env DRIVER virtualbox
|
||||
|
||||
@test "$DRIVER: create" {
|
||||
run machine create -d $DRIVER $NAME
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(shared_machine_name)"
|
||||
fi
|
||||
|
||||
@test "$DRIVER: VBoxManage pause" {
|
||||
run VBoxManage controlvm $NAME pause
|
||||
|
|
|
@ -4,6 +4,10 @@ load ${BASE_TEST_DIR}/helpers.bash
|
|||
|
||||
only_if_env DRIVER virtualbox
|
||||
|
||||
if [[ -z "$NAME" ]]; then
|
||||
export NAME="$(unique_machine_name)"
|
||||
fi
|
||||
|
||||
export OLD_ISO_URL="https://github.com/boot2docker/boot2docker/releases/download/v1.4.1/boot2docker.iso"
|
||||
|
||||
@test "$DRIVER: create for upgrade" {
|
||||
|
|
Loading…
Reference in New Issue