Skip to content

Commit

Permalink
fix support for many stacks in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Dec 5, 2020
1 parent 49b3c03 commit f75cc14
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 22 deletions.
7 changes: 4 additions & 3 deletions .euts.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@

### Containers Runtime Settings

# The project name is used as prefix for the name of the containers that will be built.
# This allows to build and run different copies of the stack in parallel
#TESTSTACK_PROJECT_NAME=euts
# The project name is used as prefix for the name of the containers and images that will be built.
# This allows to build and run different copies of the stack in parallel.
# It is also used as part of the name of the custom composer 'vendor' dir that will be used.
#COMPOSE_PROJECT_NAME=euts

# Custom Timezone for the containers. Use 'none' as null value
#TESTSTACK_TZ=none
Expand Down
7 changes: 7 additions & 0 deletions WHATSNEW.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 0.3 (unreleased)
========================

* fix: make it possible to run multiple copies of the stack in parallel.
In order to achieve this, env var TESTSTACK_PROJECT_NAME has been replaced with COMPOSE_PROJECT_NAME in config file .euts.env.
In order to retain Backwards Compatibility, the old variable name is still accepted if the new one is not used.

Version 0.2
===========

Expand Down
6 changes: 3 additions & 3 deletions bin/setup/composer-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Install dependencies using Composer
# We do not rely on the requirements set in composer.json, but install a different eZ version depending on the test matrix (env vars)
#
# Uses env vars: EZ_COMPOSER_LOCK, EZ_PACKAGES, TESTSTACK_PROJECT_NAME, TRAVIS
# Uses env vars: EZ_COMPOSER_LOCK, EZ_PACKAGES, COMPOSE_PROJECT_NAME, TRAVIS

# @todo generate and echo a hash which can be used to determine in the future if we need to run composer again (as it
# would install different packages compared to the ones installed currently)
Expand All @@ -29,8 +29,8 @@ if [ -n "${EZ_COMPOSER_LOCK}" ]; then
else
echo "Installing packages via Composer: the ones in composer.json plus ${EZ_PACKAGES}..."

if [ -n "${TESTSTACK_PROJECT_NAME}" ]; then
export COMPOSER="composer_${TESTSTACK_PROJECT_NAME}.json"
if [ -n "${COMPOSE_PROJECT_NAME}" ]; then
export COMPOSER="composer_${COMPOSE_PROJECT_NAME}.json"
cp composer.json ${COMPOSER}
fi
# we split require from update to (hopefully) save some ram
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Example TesStack configuration for testing Kaliop eZMigration Bundle on eZ Platform 1

# Use a specific project name - always a good idea when you plan to test the same bundle in different configurations
TESTSTACK_PROJECT_NAME=kezmbt_113
COMPOSE_PROJECT_NAME=kezmbt_113
# Debian Stretch comes with php 7.0 by default. We need php 7.1 minimum for ezplatform-matrix-fieldtype
TESTSTACK_DEBIAN_VERSION=stretch
TESTSTACK_PHP_VERSION=7.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Example TesStack configuration for testing Kaliop eZMigration Bundle on eZ Platform 2.3

# Use a specific project name - always a good idea when you plan to test the same bundle in different configurations
TESTSTACK_PROJECT_NAME=kezmbt_23
COMPOSE_PROJECT_NAME=kezmbt_23
# We use Debian Buster which comes with php 7.3 by default
TESTSTACK_DEBIAN_VERSION=buster

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Example TesStack configuration for testing Kaliop eZMigration Bundle on eZ Platform 2.3

# Use a specific project name - always a good idea when you plan to test the same bundle in different configurations
TESTSTACK_PROJECT_NAME=kezmbt_25
COMPOSE_PROJECT_NAME=kezmbt_25
# We use Debian Buster (which comes with php 7.3 by default) and php 7.4
TESTSTACK_DEBIAN_VERSION=buster
TESTSTACK_PHP_VERSION=7.4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Example TesStack configuration for testing Kaliop eZMigration Bundle on eZ Community Project (5.4)

# Use a specific project name - always a good idea when you plan to test the same bundle in different configurations
TESTSTACK_PROJECT_NAME=kezmbt_cp
COMPOSE_PROJECT_NAME=kezmbt_cp
# Use Debian Jessie for the container OS as it comes with php 5.6 by default
TESTSTACK_DEBIAN_VERSION=jessie

Expand Down
6 changes: 3 additions & 3 deletions docker/docker-compose-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ version: '3'
services:

mysql:
image: ${TESTSTACK_PROJECT_NAME:-euts}_mysql
image: ${COMPOSE_PROJECT_NAME:-euts}_mysql
build:
context: images/mysql
args:
do_update_os: ${TESTSTACK_UPDATE_OS_ON_BUILD:-true}
# note: Travis Xenial and Bionic images come with mysql 5.7 by default; Focal comes with mysql 8.0
# But mysql 5.6 is not recommended for EZP 5.4, so we default to 5.6
mysql_version: ${MYSQL_VERSION:-5.6}
project_name: ${TESTSTACK_PROJECT_NAME:-euts}
project_name: ${COMPOSE_PROJECT_NAME:-euts}
timezone: ${TESTSTACK_TZ:-none}
hostname: mysql
container_name: ${TESTSTACK_PROJECT_NAME:-euts}_mysql
container_name: ${COMPOSE_PROJECT_NAME:-euts}_mysql
environment:
- CONTAINER_USER_UID=${CONTAINER_USER_UID:-1000}
- CONTAINER_USER_GID=${CONTAINER_USER_GID:-1000}
Expand Down
6 changes: 3 additions & 3 deletions docker/docker-compose-postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ version: '3'
services:

postgresql:
image: ${TESTSTACK_PROJECT_NAME:-euts}_postgresql
image: ${COMPOSE_PROJECT_NAME:-euts}_postgresql
build:
context: images/postgresql
args:
do_update_os: ${TESTSTACK_UPDATE_OS_ON_BUILD:-true}
# note: Travis Xenial images come with PG 9.4-9.6,10; Bionic with 9.3-9.6,10,11 and Focal with 12
# We go with 9.5 as default because it is the lowest upstream supported version as of 11/2020...
postgresql_version: ${POSTGRESQL_VERSION:-9.5}
project_name: ${TESTSTACK_PROJECT_NAME:-euts}
project_name: ${COMPOSE_PROJECT_NAME:-euts}
timezone: ${TESTSTACK_TZ:-none}
hostname: postgresql
container_name: ${TESTSTACK_PROJECT_NAME:-euts}_postgresql
container_name: ${COMPOSE_PROJECT_NAME:-euts}_postgresql
environment:
- CONTAINER_USER_UID=${CONTAINER_USER_UID:-1000}
- CONTAINER_USER_GID=${CONTAINER_USER_GID:-1000}
Expand Down
8 changes: 4 additions & 4 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ version: '3'
services:

ez:
image: ${TESTSTACK_PROJECT_NAME:-euts}_ez
image: ${COMPOSE_PROJECT_NAME:-euts}_ez
build:
context: images/ez
args:
debian_mirror: ${TESTSTACK_DEBIAN_MIRROR:-none}
debian_version: ${TESTSTACK_DEBIAN_VERSION:-buster}
do_update_os: ${TESTSTACK_UPDATE_OS_ON_BUILD:-true}
php_version: ${TESTSTACK_PHP_VERSION:-default}
project_name: ${TESTSTACK_PROJECT_NAME:-euts}
project_name: ${COMPOSE_PROJECT_NAME:-euts}
timezone: ${TESTSTACK_TZ:-none}
hostname: ez
container_name: ${TESTSTACK_PROJECT_NAME:-euts}_ez
container_name: ${COMPOSE_PROJECT_NAME:-euts}_ez
environment:
## Configuration used by the boot/setup scripts
- COMPOSER_AUTH
- CONTAINER_USER_UID=${CONTAINER_USER_UID:-1000}
- CONTAINER_USER_GID=${CONTAINER_USER_GID:-1000}
- http_proxy
- https_proxy
- TESTSTACK_PROJECT_NAME
- COMPOSE_PROJECT_NAME
- TESTSTACK_SETUP_APP_ON_BOOT
## Database configuration
- DB_TYPE=${DB_TYPE:-mysql}
Expand Down
2 changes: 1 addition & 1 deletion docker/images/ez/root/boot/symlinkvendors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CONTAINER_USER_HOME=$(echo "$ORIGPASSWD" | cut -f6 -d:)
# # @todo to avoid generating uselessly different variations, we should as well sort EZ_PACKAGES
# TESTSTACK_VENDOR_DIR=vendor_$(echo "${P_V} ${EZ_PACKAGES}" | md5sum | awk '{print $1}')
#fi
TESTSTACK_VENDOR_DIR="vendor_${TESTSTACK_PROJECT_NAME}"
TESTSTACK_VENDOR_DIR="vendor_${COMPOSE_PROJECT_NAME}"

# @todo we assume that /home/test/bundle/vendor is never a file...

Expand Down
7 changes: 6 additions & 1 deletion teststack
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ dotenv() {
set -a
. "${1}"
set +a

# BC with versions 0.1 - 0.2
if [ -z "${COMPOSE_PROJECT_NAME}" -a -n "${TESTSTACK_PROJECT_NAME}" ]; then
export COMPOSE_PROJECT_NAME="${TESTSTACK_PROJECT_NAME}"
fi
}

load_config() {
Expand Down Expand Up @@ -442,7 +447,7 @@ cd $(dirname -- ${BASH_SOURCE[0]})/docker

# Since the line below relies on knowing the contents of the yml file anyway, let's be more efficient...
#WEB_CONTAINER=$(${DOCKER_TESTSTACK_QUIET} config | grep 'container_name: .*_ez$' | sed -e 's/ \+container_name: \+//g')
WEB_CONTAINER=${TESTSTACK_PROJECT_NAME:-euts}_ez
WEB_CONTAINER=${COMPOSE_PROJECT_NAME:-euts}_ez

case "${COMMAND}" in
build)
Expand Down

0 comments on commit f75cc14

Please sign in to comment.