diff options
author | Ryan Chu <ryan.chu@qt.io> | 2019-03-22 16:20:52 +0100 |
---|---|---|
committer | Ryan Chu <ryan.chu@qt.io> | 2019-04-25 15:32:57 +0000 |
commit | 713f77176e5de34503bd265e00f665b7f6ef05b4 (patch) | |
tree | 7be1f245a087bca7385676b2af6d038461a48d38 /tests/auto/testserver.pri | |
parent | 0c404fd6f34c7ca75400324e95e44842152bdd87 (diff) |
Support multi-stage builds to provision the configurations and test data
In order to reuse the test server to the external modules, it is much
easier to share the common configurations (scripts) and test data via
Dockerfile. In addition, the external module can create more layers
depending on their needs. Therefore, supporting multi-stage builds is
needed. The disadvantage is that the docker-compose needs to re-build
the images every time. However, it is just a one-time effort. If the
Dockerfile doesn't get changed, the extra build time can be ignored.
Because of multi-stage builds, the test server will keep a Dockerfile at
least. Therefore, the volume sharing is no more needed. The test data of
a service can be added into the images by using COPY/ADD commands.
NOTE:
This patch relies on docker-compose v1.21.0 (docker-compose build now
supports the use of Dockerfile from outside the build context).
Change-Id: Ib3f6a5fcf6979732ae8a40a494a1360fca4ac7bf
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests/auto/testserver.pri')
-rw-r--r-- | tests/auto/testserver.pri | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/auto/testserver.pri b/tests/auto/testserver.pri index 455f88fa5d..1b7ccf5757 100644 --- a/tests/auto/testserver.pri +++ b/tests/auto/testserver.pri @@ -102,6 +102,7 @@ isEmpty(TESTSERVER_VERSION) { # The environment variables passed to the docker-compose file TEST_ENV = 'MACHINE_IP=$(shell docker-machine ip qt-test-server)' TEST_ENV += 'TEST_DOMAIN=$$DNSDOMAIN' + TEST_ENV += 'SHARED_DATA=$$PWD' TEST_CMD = env } else:equals(QMAKE_HOST.os, Windows) { # There is no docker bridge on Windows. It is impossible to ping a container. @@ -115,6 +116,7 @@ isEmpty(TESTSERVER_VERSION) { # The environment variables passed to the docker-compose file TEST_ENV = '\$\$env:MACHINE_IP = docker-machine ip qt-test-server;' TEST_ENV += '\$\$env:TEST_DOMAIN = $$shell_quote(\"$$DNSDOMAIN\");' + TEST_ENV += '\$\$env:SHARED_DATA = $$shell_quote(\"$$PWD\");' # Docker-compose CLI environment variables: # Enable path conversion from Windows-style to Unix-style in volume definitions. @@ -127,6 +129,7 @@ isEmpty(TESTSERVER_VERSION) { $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml # The environment variables passed to the docker-compose file TEST_ENV = 'TEST_DOMAIN=$$DNSDOMAIN' + TEST_ENV += 'SHARED_DATA=$$PWD' TEST_CMD = env } !exists($$TESTSERVER_COMPOSE_FILE): error("Invalid TESTSERVER_COMPOSE_FILE specified") @@ -200,7 +203,7 @@ isEmpty(TESTSERVER_VERSION) { # Bring up test servers and make sure the services are ready. !isEmpty(TEST_CMD): testserver_test.commands = $$TEST_CMD $$TEST_ENV testserver_test.commands += docker-compose $$MACHINE_CONFIG -f $$TESTSERVER_COMPOSE_FILE up \ - --detach --force-recreate --timeout 1 $${QT_TEST_SERVER_LIST} && + --build -d --force-recreate --timeout 1 $${QT_TEST_SERVER_LIST} && # Check test cases with docker-based test servers. testserver_test.commands += $(MAKE) -f $(MAKEFILE) check_network && |