summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Chu <ryan.chu@qt.io>2019-04-11 16:04:06 +0200
committerRyan Chu <ryan.chu@qt.io>2019-07-01 01:09:42 +0200
commit57055ffafd9c32168e2ee94ba73655126fbaac38 (patch)
treec370ab63947ff08c47bc6132d601f8192323adb8
parent889b44043ee92f77c6bb21abff556688354193d2 (diff)
Share the common configurations among different modules
This change is used to generalize a template docker-compose file for all modules. Ideally, the leaf module only need to keep a docker compose file for all platforms (docker-compose.yml). NOTE: The version of docker-compose file downgrades from 3.4 to 2.1 because the 'extends' keyword is not supported in Compose version 3.x. Change-Id: I2e36fd9236eda86cb5fcf940d787ccefe9200696 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
-rw-r--r--mkspecs/features/data/testserver/Dockerfile2
-rw-r--r--mkspecs/features/data/testserver/docker-compose-common.yml38
-rw-r--r--mkspecs/features/unsupported/testserver.prf16
-rw-r--r--tests/testserver/docker-compose-bridge-network.yml (renamed from tests/testserver/docker-compose.yml)68
-rw-r--r--tests/testserver/docker-compose-for-windows.yml113
-rw-r--r--tests/testserver/docker-compose-host-network.yml (renamed from tests/testserver/docker-compose-for-macOS.yml)53
6 files changed, 108 insertions, 182 deletions
diff --git a/mkspecs/features/data/testserver/Dockerfile b/mkspecs/features/data/testserver/Dockerfile
index 8fb664a1d2..a20d289d3f 100644
--- a/mkspecs/features/data/testserver/Dockerfile
+++ b/mkspecs/features/data/testserver/Dockerfile
@@ -21,7 +21,9 @@ RUN echo "#!/usr/bin/env bash\n" \
RUN chmod +x startup.sh
# rewrite the default configurations of avahi-daemon
+# Disable IPv6 of avahi-daemon to resolve the unstable connections on Windows
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," \
+ -e "s,use-ipv6=yes,use-ipv6=no," \
/etc/avahi/avahi-daemon.conf
diff --git a/mkspecs/features/data/testserver/docker-compose-common.yml b/mkspecs/features/data/testserver/docker-compose-common.yml
new file mode 100644
index 0000000000..58282c1273
--- /dev/null
+++ b/mkspecs/features/data/testserver/docker-compose-common.yml
@@ -0,0 +1,38 @@
+version: '2.1'
+
+# This is a template docker-compose file shared with all modules. It is based
+# on 'extending services' feature of compose file version 2.1.
+# See https://docs.docker.com/compose/extends/#extending-services for details.
+#
+# Example: testserver/docker-compose.yml
+# services:
+# foo:
+# extends:
+# file: ${SHARED_DATA}/docker-compose-common.yml
+# service: ${SHARED_SERVICE}
+# container_name: qt-test-server-foo
+# hostname: ${HOST_NAME:-foo}
+# build:
+# context: .
+# args:
+# provisioningImage: qt-test-server-foo:537fe302f61851d1663...
+# serviceDir: ./foo
+# command: service/foo.sh
+
+x-services:
+ &default-service
+ domainname: ${TEST_DOMAIN}
+ build:
+ context: .
+ dockerfile: ${SHARED_DATA}/Dockerfile
+ args:
+ test_domain: ${TEST_DOMAIN}
+ entrypoint: ./startup.sh
+
+services:
+ bridge-network: *default-service
+ host-network:
+ << : *default-service
+ network_mode: "host"
+ extra_hosts:
+ - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}"
diff --git a/mkspecs/features/unsupported/testserver.prf b/mkspecs/features/unsupported/testserver.prf
index 6507a360c5..32bd4df30c 100644
--- a/mkspecs/features/unsupported/testserver.prf
+++ b/mkspecs/features/unsupported/testserver.prf
@@ -94,29 +94,33 @@ isEmpty(TESTSERVER_VERSION) {
# 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
+ $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-host-network.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 += 'HOST_NAME=qt-test-server'
TEST_ENV += 'TEST_DOMAIN=$$DNSDOMAIN'
TEST_ENV += 'SHARED_DATA=$$PWD/../data/testserver'
+ TEST_ENV += 'SHARED_SERVICE=host-network'
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
+ $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-host-network.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:HOST_NAME = $$shell_quote(\"qt-test-server\");'
TEST_ENV += '\$\$env:TEST_DOMAIN = $$shell_quote(\"$$DNSDOMAIN\");'
TEST_ENV += '\$\$env:SHARED_DATA = $$shell_quote(\"$$PWD/../data/testserver\");'
+ TEST_ENV += '\$\$env:SHARED_SERVICE = $$shell_quote(\"host-network\");'
# Docker-compose CLI environment variables:
# Enable path conversion from Windows-style to Unix-style in volume definitions.
@@ -126,12 +130,18 @@ isEmpty(TESTSERVER_VERSION) {
CONFIG += PowerShell
} else {
isEmpty(TESTSERVER_COMPOSE_FILE): TESTSERVER_COMPOSE_FILE = \
- $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml
+ $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-bridge-network.yml
# The environment variables passed to the docker-compose file
TEST_ENV = 'TEST_DOMAIN=$$DNSDOMAIN'
TEST_ENV += 'SHARED_DATA=$$PWD/../data/testserver'
+ TEST_ENV += 'SHARED_SERVICE=bridge-network'
TEST_CMD = env
}
+
+ # If $$TESTSERVER_COMPOSE_FILE defined by platform doesn't exist, the default
+ # docker-compose.yml is used as a fallback.
+ !exists($$TESTSERVER_COMPOSE_FILE): TESTSERVER_COMPOSE_FILE = \
+ $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml
!exists($$TESTSERVER_COMPOSE_FILE): error("Invalid TESTSERVER_COMPOSE_FILE specified")
diff --git a/tests/testserver/docker-compose.yml b/tests/testserver/docker-compose-bridge-network.yml
index 75e8a0fea2..2cabeee1dc 100644
--- a/tests/testserver/docker-compose.yml
+++ b/tests/testserver/docker-compose-bridge-network.yml
@@ -1,35 +1,37 @@
-version: '3.4'
+version: '2.1'
# The tag of images is used by docker compose file to launch the corresponding
# docker containers. The value of tag comes from the provisioning script
# (coin/provisioning/.../testserver/docker_testserver.sh). The script gets SHA-1
# of each server context as the tag of docker images. If one of the server
# contexts gets changes, please make sure to update this compose file as well.
-# You can run command 'docker images' to list all the tag of test server images.
+# You can run command 'docker images' to list all the tags of test server images.
# For example:
# REPOSITORY TAG
# qt-test-server-apache2 537fe302f61851d1663f41495230d8e3554a4a13
services:
apache2:
+ extends:
+ file: ${SHARED_DATA}/docker-compose-common.yml
+ service: ${SHARED_SERVICE}
container_name: qt-test-server-apache2
- domainname: ${TEST_DOMAIN}
- hostname: apache2
+ hostname: ${HOST_NAME:-apache2}
build:
context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
args:
provisioningImage: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13
shareDir: ./common
serviceDir: ./apache2
- test_domain: ${TEST_DOMAIN}
entrypoint: service/startup.sh
command: [service/ssl.sh, service/apache2.sh]
squid:
+ extends:
+ file: ${SHARED_DATA}/docker-compose-common.yml
+ service: ${SHARED_SERVICE}
container_name: qt-test-server-squid
- domainname: ${TEST_DOMAIN}
- hostname: squid
+ hostname: ${HOST_NAME:-squid}
depends_on:
- apache2
external_links:
@@ -40,53 +42,53 @@ services:
- echo:echo.${TEST_DOMAIN}
build:
context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
args:
provisioningImage: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c
shareDir: ./common
serviceDir: ./squid
- test_domain: ${TEST_DOMAIN}
entrypoint: service/startup.sh
command: service/squid.sh
vsftpd:
+ extends:
+ file: ${SHARED_DATA}/docker-compose-common.yml
+ service: ${SHARED_SERVICE}
container_name: qt-test-server-vsftpd
- domainname: ${TEST_DOMAIN}
- hostname: vsftpd
+ hostname: ${HOST_NAME:-vsftpd}
build:
context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
args:
provisioningImage: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e
shareDir: ./common
serviceDir: ./vsftpd
- test_domain: ${TEST_DOMAIN}
entrypoint: service/startup.sh
command: service/vsftpd.sh
ftp-proxy:
+ extends:
+ file: ${SHARED_DATA}/docker-compose-common.yml
+ service: ${SHARED_SERVICE}
container_name: qt-test-server-ftp-proxy
- domainname: ${TEST_DOMAIN}
- hostname: ftp-proxy
+ hostname: ${HOST_NAME:-ftp-proxy}
depends_on:
- vsftpd
external_links:
- vsftpd:vsftpd.${TEST_DOMAIN}
build:
context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
args:
provisioningImage: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae
shareDir: ./common
serviceDir: ./ftp-proxy
- test_domain: ${TEST_DOMAIN}
entrypoint: service/startup.sh
command: service/ftp-proxy.sh
danted:
+ extends:
+ file: ${SHARED_DATA}/docker-compose-common.yml
+ service: ${SHARED_SERVICE}
container_name: qt-test-server-danted
- domainname: ${TEST_DOMAIN}
- hostname: danted
+ hostname: ${HOST_NAME:-danted}
depends_on:
- apache2
- vsftpd
@@ -99,42 +101,40 @@ services:
- echo:echo.${TEST_DOMAIN}
build:
context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
args:
provisioningImage: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5
shareDir: ./common
serviceDir: ./danted
- test_domain: ${TEST_DOMAIN}
entrypoint: service/startup.sh
command: service/danted.sh
cyrus:
+ extends:
+ file: ${SHARED_DATA}/docker-compose-common.yml
+ service: ${SHARED_SERVICE}
container_name: qt-test-server-cyrus
- domainname: ${TEST_DOMAIN}
- hostname: cyrus
+ hostname: ${HOST_NAME:-cyrus}
build:
context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
args:
provisioningImage: qt-test-server-cyrus:c8d72754abc0e501afd624ce838e4df35505abc9
shareDir: ./common
serviceDir: ./cyrus
- test_domain: ${TEST_DOMAIN}
entrypoint: service/startup.sh
command: [service/ssl.sh, service/cyrus.sh]
iptables:
+ extends:
+ file: ${SHARED_DATA}/docker-compose-common.yml
+ service: ${SHARED_SERVICE}
container_name: qt-test-server-iptables
- domainname: ${TEST_DOMAIN}
- hostname: iptables
+ hostname: ${HOST_NAME:-iptables}
build:
context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
args:
provisioningImage: qt-test-server-iptables:cb7a8bd6d28602085a88c8ced7d67e28e75781e2
shareDir: ./common
serviceDir: ./iptables
- test_domain: ${TEST_DOMAIN}
entrypoint: service/startup.sh
command: service/iptables.sh
cap_add:
@@ -142,16 +142,16 @@ services:
- NET_RAW
echo:
+ extends:
+ file: ${SHARED_DATA}/docker-compose-common.yml
+ service: ${SHARED_SERVICE}
container_name: qt-test-server-echo
- domainname: ${TEST_DOMAIN}
- hostname: echo
+ hostname: ${HOST_NAME:-echo}
build:
context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
args:
provisioningImage: qt-test-server-echo:b29ad409e746a834c1055fd0f7a55fd5056da6ea
shareDir: ./common
serviceDir: ./echo
- test_domain: ${TEST_DOMAIN}
entrypoint: service/startup.sh
command: service/echo.sh
diff --git a/tests/testserver/docker-compose-for-windows.yml b/tests/testserver/docker-compose-for-windows.yml
deleted file mode 100644
index c5348e27b6..0000000000
--- a/tests/testserver/docker-compose-for-windows.yml
+++ /dev/null
@@ -1,113 +0,0 @@
-version: '3.4'
-
-# The tag of images is used by docker compose file to launch the corresponding
-# docker containers. The value of tag comes from the provisioning script
-# (coin/provisioning/.../testserver/docker_testserver.sh). The script gets SHA-1
-# of each server context as the tag of docker images. If one of the server
-# contexts gets changes, please make sure to update this compose file as well.
-# You can run command 'docker images' to list all the tags of test server images.
-# For example:
-# REPOSITORY TAG
-# qt-test-server-apache2 537fe302f61851d1663f41495230d8e3554a4a13
-
-services:
- apache2:
- container_name: qt-test-server-apache2
- domainname: ${TEST_DOMAIN}
- build:
- context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
- args:
- provisioningImage: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13
- shareDir: ./common
- serviceDir: ./apache2
- test_domain: ${TEST_DOMAIN}
- entrypoint: service/startup.sh
- command: [service/ssl.sh, service/apache2.sh]
- network_mode: "host"
- extra_hosts:
- - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}"
- environment:
- - test_cert="qt-test-server-host-network-cacert.pem"
-
- squid:
- container_name: qt-test-server-squid
- domainname: ${TEST_DOMAIN}
- depends_on:
- - apache2
- build:
- context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
- args:
- provisioningImage: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c
- shareDir: ./common
- serviceDir: ./squid
- test_domain: ${TEST_DOMAIN}
- entrypoint: service/startup.sh
- command: service/squid.sh
- network_mode: "host"
- extra_hosts:
- - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}"
-
- vsftpd:
- container_name: qt-test-server-vsftpd
- domainname: ${TEST_DOMAIN}
- build:
- context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
- args:
- provisioningImage: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e
- shareDir: ./common
- serviceDir: ./vsftpd
- test_domain: ${TEST_DOMAIN}
- entrypoint: service/startup.sh
- command: service/vsftpd.sh
- network_mode: "host"
- extra_hosts:
- - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}"
-
- ftp-proxy:
- container_name: qt-test-server-ftp-proxy
- domainname: ${TEST_DOMAIN}
- depends_on:
- - vsftpd
- build:
- context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
- args:
- provisioningImage: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae
- shareDir: ./common
- serviceDir: ./ftp-proxy
- test_domain: ${TEST_DOMAIN}
- entrypoint: service/startup.sh
- command: service/ftp-proxy.sh
- network_mode: "host"
- extra_hosts:
- - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}"
-
- danted:
- container_name: qt-test-server-danted
- domainname: ${TEST_DOMAIN}
- depends_on:
- - apache2
- - vsftpd
- - ftp-proxy
- build:
- context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
- args:
- provisioningImage: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5
- shareDir: ./common
- serviceDir: ./danted
- test_domain: ${TEST_DOMAIN}
- entrypoint: service/startup.sh
- command: service/danted.sh
- network_mode: "host"
- extra_hosts:
- - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}"
- environment:
- - danted_internal=${MACHINE_IP}
- - danted_external=${MACHINE_IP}
- - danted_auth_internal=${MACHINE_IP}
- - danted_auth_external=${MACHINE_IP}
-
diff --git a/tests/testserver/docker-compose-for-macOS.yml b/tests/testserver/docker-compose-host-network.yml
index c5348e27b6..4b2e1ebdab 100644
--- a/tests/testserver/docker-compose-for-macOS.yml
+++ b/tests/testserver/docker-compose-host-network.yml
@@ -1,4 +1,4 @@
-version: '3.4'
+version: '2.1'
# The tag of images is used by docker compose file to launch the corresponding
# docker containers. The value of tag comes from the provisioning script
@@ -12,102 +12,91 @@ version: '3.4'
services:
apache2:
+ extends:
+ file: ${SHARED_DATA}/docker-compose-common.yml
+ service: ${SHARED_SERVICE}
container_name: qt-test-server-apache2
- domainname: ${TEST_DOMAIN}
+ hostname: ${HOST_NAME:-apache2}
build:
context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
args:
provisioningImage: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13
shareDir: ./common
serviceDir: ./apache2
- test_domain: ${TEST_DOMAIN}
entrypoint: service/startup.sh
command: [service/ssl.sh, service/apache2.sh]
- network_mode: "host"
- extra_hosts:
- - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}"
environment:
- test_cert="qt-test-server-host-network-cacert.pem"
squid:
+ extends:
+ file: ${SHARED_DATA}/docker-compose-common.yml
+ service: ${SHARED_SERVICE}
container_name: qt-test-server-squid
- domainname: ${TEST_DOMAIN}
+ hostname: ${HOST_NAME:-squid}
depends_on:
- apache2
build:
context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
args:
provisioningImage: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c
shareDir: ./common
serviceDir: ./squid
- test_domain: ${TEST_DOMAIN}
entrypoint: service/startup.sh
command: service/squid.sh
- network_mode: "host"
- extra_hosts:
- - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}"
vsftpd:
+ extends:
+ file: ${SHARED_DATA}/docker-compose-common.yml
+ service: ${SHARED_SERVICE}
container_name: qt-test-server-vsftpd
- domainname: ${TEST_DOMAIN}
+ hostname: ${HOST_NAME:-vsftpd}
build:
context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
args:
provisioningImage: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e
shareDir: ./common
serviceDir: ./vsftpd
- test_domain: ${TEST_DOMAIN}
entrypoint: service/startup.sh
command: service/vsftpd.sh
- network_mode: "host"
- extra_hosts:
- - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}"
ftp-proxy:
+ extends:
+ file: ${SHARED_DATA}/docker-compose-common.yml
+ service: ${SHARED_SERVICE}
container_name: qt-test-server-ftp-proxy
- domainname: ${TEST_DOMAIN}
+ hostname: ${HOST_NAME:-ftp-proxy}
depends_on:
- vsftpd
build:
context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
args:
provisioningImage: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae
shareDir: ./common
serviceDir: ./ftp-proxy
- test_domain: ${TEST_DOMAIN}
entrypoint: service/startup.sh
command: service/ftp-proxy.sh
- network_mode: "host"
- extra_hosts:
- - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}"
danted:
+ extends:
+ file: ${SHARED_DATA}/docker-compose-common.yml
+ service: ${SHARED_SERVICE}
container_name: qt-test-server-danted
- domainname: ${TEST_DOMAIN}
+ hostname: ${HOST_NAME:-danted}
depends_on:
- apache2
- vsftpd
- ftp-proxy
build:
context: .
- dockerfile: ${SHARED_DATA}/Dockerfile
args:
provisioningImage: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5
shareDir: ./common
serviceDir: ./danted
- test_domain: ${TEST_DOMAIN}
entrypoint: service/startup.sh
command: service/danted.sh
- network_mode: "host"
- extra_hosts:
- - "qt-test-server.${TEST_DOMAIN}:${MACHINE_IP}"
environment:
- danted_internal=${MACHINE_IP}
- danted_external=${MACHINE_IP}
- danted_auth_internal=${MACHINE_IP}
- danted_auth_external=${MACHINE_IP}
-