summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRyan Chu <ryan.chu@qt.io>2018-10-20 11:59:34 +0200
committerRyan Chu <ryan.chu@qt.io>2018-10-23 05:26:31 +0000
commit0107b695f0be8024523250c7d8be475c6f6747e6 (patch)
tree6eb651386a080e8253c398558b6d404f39d943f1 /tests
parent17f4adfe1840f507ada69fa6f25238c4c72064c3 (diff)
Make sure docker machine is both created and running before test
Before reading the configuration of a docker machine, the machine shall be created and started. Otherwise, the docker command will complain about "cannot connect to the Docker daemon". If the docker machine has not been created, the make check will be immediately terminated, and then print the error message. If its status is not running, the machine will be turned on by a start command. Change-Id: I7f4c322e7bdf29e4e4203e0e1bbc2e5c8cf677be Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/testserver.pri16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/testserver.pri b/tests/auto/testserver.pri
index a50ffd9bd6..7dd32db0af 100644
--- a/tests/auto/testserver.pri
+++ b/tests/auto/testserver.pri
@@ -85,6 +85,22 @@ equals(QMAKE_HOST.os, Windows)|isEmpty(TESTSERVER_VERSION) {
testserver_pretest.commands = $(info "testserver:" $$TESTSERVER_VERSION)
testserver_pretest.commands += $(if $$TESTSERVER_COMPOSE_FILE,,$(error $$FILE_PRETEST_MSG))
+ # Make sure docker-machine is both created and running. The docker_machine
+ # script is used to deploy the docker environment into VirtualBox.
+ # Example: qt5/coin/provisioning/common/shared/testserver/docker_machine.sh
+ !isEmpty(MACHINE_CONFIG) {
+ MACHINE_LIST_CMD = docker-machine ls -q --filter "Name=^qt-test-server$"
+ MACHINE_LIST_MSG = "Docker machine qt-test-server not found"
+ testserver_pretest.commands += \
+ $(if $(shell $$MACHINE_LIST_CMD),,$(error $$MACHINE_LIST_MSG))
+
+ MACHINE_STATE_CMD = \
+ docker-machine ls -q --filter "State=Running" --filter "Name=^qt-test-server$"
+ MACHINE_START_CMD = docker-machine start qt-test-server
+ testserver_pretest.commands += \
+ $(if $(shell $$MACHINE_STATE_CMD),,$(shell $$MACHINE_START_CMD > /dev/null))
+ }
+
# Before starting the test servers, it requires the user to run the setup
# script (coin/provisioning/.../testserver/docker_testserver.sh) in advance.
IMAGE_PRETEST_CMD = docker $$MACHINE_CONFIG images -aq "qt-test-server-*"