diff options
author | Ryan Chu <ryan.chu@qt.io> | 2019-03-25 18:04:26 +0100 |
---|---|---|
committer | Ryan Chu <ryan.chu@qt.io> | 2019-04-25 15:33:06 +0000 |
commit | 658f12d7354e82ae552703fa928e1c94315c3a6a (patch) | |
tree | 7133e51cc0cac91850c0a5829032898fdbf79ddb /tests | |
parent | 713f77176e5de34503bd265e00f665b7f6ef05b4 (diff) |
Expose docker test server as an internal config to all modules
Before testserver becomes a stable feature, let's keep testserver.prf in
"mkspecs/features/unsupported". The test server's shared files will be
stored in "mkspecs/features/data/testserver".
Because the path of testserver has been changed, all the tests relying
on the docker servers should be updated as well.
Change-Id: Id2494d2b58ee2a9522d99ae61c6236021506b876
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests')
13 files changed, 11 insertions, 260 deletions
diff --git a/tests/auto/Dockerfile b/tests/auto/Dockerfile deleted file mode 100644 index 8fb664a1d2..0000000000 --- a/tests/auto/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -# This Dockerfile is used to provision the shared scripts (e.g. startup.sh) and configurations. It -# relies on the arguments passed by docker-compose file to build additional images for each service. -# To lean more how it works, please check the topic "Use multi-stage builds". -# https://docs.docker.com/develop/develop-images/multistage-build/ - -ARG provisioningImage -FROM $provisioningImage as testserver_tier2 - -# Add and merge the testdata into service folder -ARG serviceDir -ARG shareDir=$serviceDir -COPY $serviceDir $shareDir service/ - -# create the shared script of testserver -RUN echo "#!/usr/bin/env bash\n" \ - "set -ex\n" \ - "for RUN_CMD; do \$RUN_CMD; done\n" \ - "service dbus restart\n" \ - "service avahi-daemon restart\n" \ - "sleep infinity\n" > startup.sh -RUN chmod +x startup.sh - -# rewrite the default configurations of avahi-daemon -ARG test_domain -RUN sed -i -e "s,#domain-name=local,domain-name=${test_domain:-test-net.qt.local}," \ - -e "s,#publish-aaaa-on-ipv4=yes,publish-aaaa-on-ipv4=no," \ - /etc/avahi/avahi-daemon.conf diff --git a/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro b/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro index bdd9d4eb7e..c722100ead 100644 --- a/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro +++ b/tests/auto/network/access/qabstractnetworkcache/qabstractnetworkcache.pro @@ -5,5 +5,5 @@ SOURCES += tst_qabstractnetworkcache.cpp TESTDATA += tests/* +CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = apache2 -include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) diff --git a/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro index 69a4a50144..84e6f857a1 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro +++ b/tests/auto/network/access/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -5,6 +5,5 @@ requires(qtConfig(private_tests)) QT = core-private network-private testlib +CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = apache2 -include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) - diff --git a/tests/auto/network/access/qnetworkreply/test/test.pro b/tests/auto/network/access/qnetworkreply/test/test.pro index 9d36352abc..4cc1f6431e 100644 --- a/tests/auto/network/access/qnetworkreply/test/test.pro +++ b/tests/auto/network/access/qnetworkreply/test/test.pro @@ -15,5 +15,5 @@ TESTDATA += ../empty ../rfc3252.txt ../resource ../bigfile ../*.jpg ../certs \ !android:!winrt: TEST_HELPER_INSTALLS = ../echo/echo +CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = vsftpd apache2 ftp-proxy danted squid -include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) diff --git a/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro b/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro index 492bb6aa8d..63f41f4eb7 100644 --- a/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro +++ b/tests/auto/network/socket/qhttpsocketengine/qhttpsocketengine.pro @@ -12,6 +12,6 @@ QT = core-private network-private testlib # TODO: For now linux-only, because cyrus is linux-only atm ... linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = squid danted cyrus apache2 - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro b/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro index ca9e44873c..243eab9480 100644 --- a/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro +++ b/tests/auto/network/socket/qsocks5socketengine/qsocks5socketengine.pro @@ -14,6 +14,6 @@ requires(qtConfig(private_tests)) # Only on Linux until cyrus has been added to docker-compose-for-{windows,macOS}.yml and tested linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = danted apache2 cyrus - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/socket/qtcpserver/test/test.pro b/tests/auto/network/socket/qtcpserver/test/test.pro index ac4ed9a989..de02fb032d 100644 --- a/tests/auto/network/socket/qtcpserver/test/test.pro +++ b/tests/auto/network/socket/qtcpserver/test/test.pro @@ -19,6 +19,6 @@ MOC_DIR=tmp # Only on Linux until cyrus has been added to docker-compose-for-{windows,macOS}.yml and tested linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = danted cyrus squid ftp-proxy - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/socket/qtcpsocket/test/test.pro b/tests/auto/network/socket/qtcpsocket/test/test.pro index 29d9414b03..05699bbe4e 100644 --- a/tests/auto/network/socket/qtcpsocket/test/test.pro +++ b/tests/auto/network/socket/qtcpsocket/test/test.pro @@ -18,6 +18,6 @@ win32 { # Only on Linux until cyrus has been added to docker-compose-for-{windows,macOS}.yml and tested linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = danted squid apache2 ftp-proxy vsftpd iptables cyrus - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/socket/qudpsocket/test/test.pro b/tests/auto/network/socket/qudpsocket/test/test.pro index 0fdb97ba27..969e4d72cf 100644 --- a/tests/auto/network/socket/qudpsocket/test/test.pro +++ b/tests/auto/network/socket/qudpsocket/test/test.pro @@ -20,6 +20,6 @@ TARGET = tst_qudpsocket # Only on Linux until 'echo' has been added to docker-compose-for-{windows,macOS}.yml and tested linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = danted echo - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/ssl/qsslsocket/qsslsocket.pro b/tests/auto/network/ssl/qsslsocket/qsslsocket.pro index 03fbe89002..51fcff9a8d 100644 --- a/tests/auto/network/ssl/qsslsocket/qsslsocket.pro +++ b/tests/auto/network/ssl/qsslsocket/qsslsocket.pro @@ -22,6 +22,6 @@ requires(qtConfig(private_tests)) # DOCKERTODO: it's 'linux' because it requires cyrus, which # is linux-only for now ... linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = squid danted cyrus apache2 echo - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro index 3e3ebeb358..8585a3c861 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro @@ -20,6 +20,6 @@ requires(qtConfig(private_tests)) # DOCKERTODO: linux, docker is disabled on macOS/Windows. linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = squid danted - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro index 1ad42b309e..158ecbee37 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro @@ -19,6 +19,6 @@ requires(qtConfig(private_tests)) #DOCKERTODO Linux, docker is disabled on macOS and Windows. linux { + CONFIG += unsupported/testserver QT_TEST_SERVER_LIST = squid danted - include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri) } diff --git a/tests/auto/testserver.pri b/tests/auto/testserver.pri deleted file mode 100644 index 1b7ccf5757..0000000000 --- a/tests/auto/testserver.pri +++ /dev/null @@ -1,221 +0,0 @@ -# Integrating docker-based test servers into Qt Test framework -# -# This file adds support for docker-based test servers built by testcase -# projects that need them. To enable this feature, any automated test can -# include testserver.pri in its project file. This instructs qmake to insert -# additional targets into the generated Makefile. The 'check' target then brings -# up test servers before running the testcase, and shuts them down afterwards. -# -# TESTSERVER_COMPOSE_FILE -# - Contains the path of docker-compose file -# This configuration file defines the services used for autotests. It tells the -# docker engine how to build up the docker images and containers. In qtbase, a -# shared docker-compose file is located in the tests folder. -# Example: TESTSERVER_COMPOSE_FILE = \ -# $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml -# -# The user must run the provisioning scripts in advance before attempting to -# build the test servers. The docker_testserver.sh script is used to build up -# the docker images into the docker-cache. It handles the immutable parts of the -# server installation that rarely need adjustment, such as downloading packages. -# Example: qt5/coin/provisioning/.../testserver/docker_testserver.sh -# -# QT_TEST_SERVER_LIST -# - A list of test servers to bring up for this testcase -# These test servers should be defined in $$TESTSERVER_COMPOSE_FILE. Each -# testcase can define the test servers it depends on. -# Example: QT_TEST_SERVER_LIST = apache2 squid vsftpd ftp-proxy danted -# -# Pre-processor defines needed for the application: -# QT_TEST_SERVER -# - A preprocessor macro used for testcase to change testing parameters at -# compile time -# This macro is predefined for docker-based test servers and is passed as a -# compiler option (-DQT_TEST_SERVER). The testcase can then check whether -# docker-based servers are in use and change the testing parameters, such as -# host name or port number, at compile time. An example can be found in -# network-settings.h. -# -# Example: -# #if defined(QT_TEST_SERVER) -# Change the testing parameters at compile time -# #endif -# -# QT_TEST_SERVER_DOMAIN -# - A preprocessor macro that holds the server domain name -# Provided for the helper functions in network-settings.h. Use function -# serverDomainName() in your application instead. -# -# Additional make targets: -# 1. check_network - A renamed target from the check target of testcase feature. -# 2. testserver_clean - Clean up server containers/images and tidy away related -# files. - -# The docker test server should only be integrated in the leaf Makefile. -# If debug_and_release option is in use, skip the meta-Makefile except for -# Makefile.Debug and Makefile.Release. -debug_and_release:!build_pass: return() - -DOCKER_ENABLED = 1 - -equals(QMAKE_HOST.os, Darwin) | equals(QMAKE_HOST.os, Windows) { - DOCKER_ENABLED = 0 - message("Not using docker network test server on macOS and Windows, see QTQAINFRA-2717 and QTQAINFRA-2750") -} - -TESTSERVER_VERSION = "" - -equals(DOCKER_ENABLED, 1) { - TESTSERVER_VERSION = $$system(docker-compose --version) -} - -isEmpty(TESTSERVER_VERSION) { - # Make check with server "qt-test-server.qt-test-net" as a fallback -} else { - # Make check with docker test servers - equals(QMAKE_HOST.os, Linux) { - # For the platform supporting docker bridge network, each container is - # assigned a unique hostname and connected to the same network domain - # to communicate with the others. - DEFINES += QT_TEST_SERVER_NAME - DNSDOMAIN = test-net.qt.local - } else { - # For the others, the containers are deployed into a virtual machine - # using the host network. All the containers share the same hostname of - # the virtual machine, and they are connected to the same network domain. - # NOTE: In Windows, Apple Bonjour only works within a single local domain. - DNSDOMAIN = local - } - - equals(QMAKE_HOST.os, Darwin) { - # There is no docker bridge on macOS. It is impossible to ping a container. - # Docker docs recommends using port mapping to connect to a container; - # but it causes a port conflict if the user is running a service that - # binds the same port on the host. An alternative solution is to deploy - # the docker environment into VirtualBox using docker-machine. - isEmpty(TESTSERVER_COMPOSE_FILE): TESTSERVER_COMPOSE_FILE = \ - $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-for-macOS.yml - - # The connection configuration for the target machine - MACHINE_CONFIG = $(shell docker-machine config qt-test-server) - - # 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. - # Use docker-machine to deploy the docker environment into VirtualBox. - isEmpty(TESTSERVER_COMPOSE_FILE): TESTSERVER_COMPOSE_FILE = \ - $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-for-windows.yml - - # The connection configuration for the target machine - MACHINE_CONFIG = (docker-machine config qt-test-server) - - # 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. - TEST_ENV += '\$\$env:COMPOSE_CONVERT_WINDOWS_PATHS = $$shell_quote(\"true\");' - - TEST_CMD = 'PowerShell -noprofile' - CONFIG += PowerShell - } else { - isEmpty(TESTSERVER_COMPOSE_FILE): TESTSERVER_COMPOSE_FILE = \ - $$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") - - - # The domain name is relevant to https keycert (qnetworkreply/crts/qt-test-net-cacert.pem). - DEFINES += QT_TEST_SERVER QT_TEST_SERVER_DOMAIN=$$shell_quote(\"$${DNSDOMAIN}\") - - # Ensure that the docker-compose file is provided. It is a configuration - # file which is mandatory for all docker-compose commands. You can get more - # detail from the description of TESTSERVER_COMPOSE_FILE above. There is - # also an example showing how to configure it manually. - FILE_PRETEST_MSG = "Project variable 'TESTSERVER_COMPOSE_FILE' is not set" - PowerShell { - testserver_pretest.commands = echo $$TESTSERVER_VERSION && - testserver_pretest.commands += \ - $$TEST_CMD if ([String]::IsNullOrEmpty($$shell_quote(\"$$TESTSERVER_COMPOSE_FILE\"))) \ - {Write-Error $$shell_quote(\"$$FILE_PRETEST_MSG\")} && - } else { - 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" - PowerShell { - testserver_pretest.commands += $$TEST_CMD if (!($$MACHINE_LIST_CMD)) \ - {Write-Error $$shell_quote(\"$$MACHINE_LIST_MSG\")} && - } else { - 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 - MACHINE_RECERT = docker-machine regenerate-certs -f qt-test-server - PowerShell { - testserver_pretest.commands += \ - $$TEST_CMD if (!($$MACHINE_STATE_CMD)) {$$MACHINE_START_CMD; $$MACHINE_RECERT} && - } else { - testserver_pretest.commands += \ - $(if $(shell $$MACHINE_STATE_CMD),,\ - $(shell $$MACHINE_START_CMD > /dev/null && $$MACHINE_RECERT > /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-*" - IMAGE_PRETEST_MSG = "Docker image qt-test-server-* not found" - PowerShell { - testserver_pretest.commands += $$TEST_CMD if (!($$IMAGE_PRETEST_CMD)) \ - {Write-Error $$shell_quote(\"$$IMAGE_PRETEST_MSG\")} - } else { - testserver_pretest.commands += \ - $(if $(shell $$IMAGE_PRETEST_CMD),,$(error $$IMAGE_PRETEST_MSG)) - } - - # Rename the check target of testcase feature - check.target = check_network - testserver_test.target = check - - # Pretesting test servers environment - testserver_test.depends = testserver_pretest - - # 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 \ - --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 && - - # Stop and remove test servers after testing. - !isEmpty(TEST_CMD): testserver_test.commands += $$TEST_CMD $$TEST_ENV - testserver_test.commands += docker-compose $$MACHINE_CONFIG -f $$TESTSERVER_COMPOSE_FILE down \ - --timeout 1 - - # Destroy test servers and tidy away related files. - testserver_clean.commands = docker-compose $$MACHINE_CONFIG -f $$TESTSERVER_COMPOSE_FILE down \ - --rmi all - - QMAKE_EXTRA_TARGETS += testserver_pretest testserver_test testserver_clean -} |