mageops / docker-magento-run-tests

Docker for running integration and unit testsuites

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub Workflow Status

MageSuite Docker Container For Running Magento Tests

Use stable or -stable suffixed docker tags (are built from vX.Y git tags), others may be unstable.

Please see the GitHub Packages mageops/magento-run-tests.

Container timeout

Container will by default exit after 1h to prevent dangling container in CI environments, you can adjust this behavior by changing setting different CONTAINER_TIMEOUT environment variable. Setting CONTAINER_TIMEOUT to no will disable that behavior completely.

Docker tags and software versions

The master branch uses Maria DB 10.2, Elasticsearch 6 and PHP 7.2 which are the latest versions supported by Magento.

Other versions will be avaialble on appropriately named branches / docker tags.

See all tags.

Tag suffixes

  • -latest - built from branch tip
  • -stable - built from tags named vX.Y

Plain tags

  • latest - master branch tip
  • stable - latest tag named vX.Y

Notable versions

Version Docker tag PHP DB Elasticsearch Composer version
php80-es7-mysql80 php80-es7-mysql80-stable 8.0.X Mysql 8.0 7.17.3 2
php81-es7-mysql80 php81-es7-mysql80-stable 8.1.X Mysql 8.0 7.17.3 2
php82-es84-mysql80 php82-es84-mysql80-stable 8.2.X Mysql 8.0 8.4.3 2
php83-es811-mysql80 php83-es811-mysql80-stable 8.3.X Mysql 8.0 8.11.4 2

Note: The exec mount opt on /tmp is needed for elasticsearch because it maps mem to temp files. The image is big and there's not really a way around it since it has a lot of software and is based on CentOS (which we use for local dev / production deployments, so we want to keep everything else close).

Basic usage

Start the container with all services

docker run \
    --rm \
    --detach \
    --name mgs-test \
    --tmpfs /tmp:rw,exec,mode=1777 \
    --tmpfs /var/lib/mysql:rw,mode=777 \
    --tmpfs /var/lib/elasticsearch:rw,mode=777 \
    --tmpfs /var/www/html/generated:rw,mode=777 \
    --tmpfs /var/www/html/var:rw,mode=777 \
    --tmpfs /var/www/html/dev/tests/integration/tmp:rw,mode=777 \
    --volume "$(pwd):/var/www/html" \
    "ghcr.io/mageops/magento-run-tests:php72-es6-mariadb102-stable"

Wait until healthcheck is green

while [[ "$(docker inspect --format='{{json .State.Health.Status}}' mgs-test)" == '"starting"' ]] ; do sleep 1s && echo "Waiting for start"; done

Then later execute your test suite

docker exec \
    --tty \
    mgs-test \
    /usr/bin/mgs-run-tests ci creativestyle "$(id -u)" "$(id -g)"

Alternatively if the internal UID/GID switch doesn't work for you for some reason you can try switching the docker UID/GID:

docker exec \
    --tty \
    --user "$(id -u):$(id -g)" \
    mgs-test \
    /usr/bin/mgs-run-tests ci creativestyle

During the testing you can get into the bash shell to poke around:

docker exec -it mgs-test /bin/bash

Run everthing at once

As an alternative you could run everything at once as the tests will wait for healthcheck to become green before proceeding:

docker run \
    --tty \
    --tmpfs /tmp:rw,exec,mode=1777 \
    --tmpfs /var/lib/mysql:rw,mode=777 \
    --tmpfs /var/lib/elasticsearch:rw,mode=777 \
    --tmpfs /var/www/html/generated:rw,mode=777 \
    --tmpfs /var/www/html/var:rw,mode=777 \
    --tmpfs /var/www/html/dev/tests/integration/tmp:rw,mode=777 \
    --volume "$(pwd):/var/www/html" \
    "ghcr.io/mageops/magento-run-tests:php72-es6-mariadb102-stable" \
    "/usr/bin/elasticsearch-server" \
    "/usr/bin/mysql-server" \
    "/usr/bin/mgs-run-tests ci creativestyle $(id -u) $(id -g)"

Run a bash shell without starting any services

docker run \
    --tty \
    --interactive \
    --tmpfs /tmp:rw,exec,mode=1777 \
    --tmpfs /var/lib/mysql:rw,mode=777 \
    --tmpfs /var/lib/elasticsearch:rw,mode=777 \
    --tmpfs /var/www/html/generated:rw,mode=777 \
    --tmpfs /var/www/html/var:rw,mode=777 \
    --tmpfs /var/www/html/dev/tests/integration/tmp:rw,mode=777 \
    --volume "$(pwd):/var/www/html" \
    "ghcr.io/mageops/magento-run-tests:php72-es6-mariadb102-stable" \
    "/bin/bash"

You can start the services while inside by doing:

/usr/sbin/start-elasticsearch &
/usr/sbin/start-mysql &

About

Docker for running integration and unit testsuites


Languages

Language:Dockerfile 53.8%Language:Shell 46.2%