diff --git a/_data/toc/cloud-guide.yml b/_data/toc/cloud-guide.yml index 0da95222453..d6853a57b47 100644 --- a/_data/toc/cloud-guide.yml +++ b/_data/toc/cloud-guide.yml @@ -108,6 +108,9 @@ pages: - label: Connect to the database url: /cloud/docker/docker-database.html + - label: Functional testing in Docker + url: /cloud/docker/docker-development-testing.html + - label: Docker quick reference url: /cloud/docker/docker-quick-reference.html diff --git a/guides/v2.1/cloud/docker/docker-development-testing.md b/guides/v2.1/cloud/docker/docker-development-testing.md new file mode 100644 index 00000000000..82c1e7d3b21 --- /dev/null +++ b/guides/v2.1/cloud/docker/docker-development-testing.md @@ -0,0 +1,119 @@ +--- +group: cloud-guide +title: Functional testing in Docker +functional_areas: + - Cloud + - Docker + - Configuration +--- + +You can use the `{{site.data.var.ct}}` package to run functional tests in the Docker environment. Functional tests are in the `src/Test/Functional/Acceptance` folder. See an example in the [ece-tools repository](https://github.com/magento/ece-tools/tree/develop/src/Test/Functional/Acceptance). + +## Prerequisites + +Before you run functional tests, you must prepare your environment with the following steps. + +1. Stop all services that use the following ports: + + - `80`—varnish + - `443`—web, tls + - `3306`—apache, mysql + +1. Switch to the preferred PHP version for running tests. + +1. Update the project dependencies. + + ```bash + composer update + ``` + +1. Add credentials to the Docker environment. + + ```bash + echo "COMPOSER_MAGENTO_USERNAME=your_public_key" >> ./.docker/composer.env + ``` + + ```bash + echo "COMPOSER_MAGENTO_PASSWORD=your_private_key" >> ./.docker/composer.env + ``` + +## Run tests + +The `codeception.dist.yml` file in the `{{site.data.var.ct}}` root directory contains the global testing configuration. See the [`{{site.data.var.ct}}` repository](https://github.com/magento/ece-tools/blob/develop/codeception.dist.yml). + +By default, functional tests produce a short output. You can receive a more detailed output by editing the `codeception.dist.yml` file to set the `printOutput:` property to `true`. + +```yaml +modules: + config: + Magento\MagentoCloud\Test\Functional\Codeception\Docker: + ... + printOutput: true +``` +{:.no-copy} + +### Run a specific test + +Use the following command format to run a specific functional test: + +```bash +./vendor/bin/codecept run Acceptance Cest +``` + +For example, the following test verifies that the post-deploy task runs successfully. + +```bash +./vendor/bin/codecept run Acceptance PostDeployCest +``` + +Sample response: + +```terminal +Codeception PHP Testing Framework v2.5.6 +Powered by PHPUnit 6.5.14 by Sebastian Bergmann and contributors. +Running with seed: +Acceptance Tests (1) ----------------------------------------------------------------------------------------------- +-------------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------- +PostDeployCest: Test post deploy | {"ADMIN_EMAIL":"admin@example.com"} + [Magento\MagentoCloud\Test\Functional\Robo\Tasks\GenerateDockerCompose] Running ./bin/ece-tools docker:build + --mode=functional --php=7.2 +... +... +✔ PostDeployCest: Test post deploy | {"ADMIN_EMAIL":"admin@example.com"} (210.41s) +``` +{: .no-copy} + +### Run all tests + +The following list provides the commands to run all available tests for each version of PHP. + +- **PHP 7.0** + + ```bash + ./vendor/bin/codecept run -g php70 --steps + ``` + +- **PHP 7.1** + + ```bash + ./vendor/bin/codecept run -g php71 --steps + ``` + +- **PHP 7.2** + + ```bash + ./tests/travis/prepare_functional_parallel.sh + ``` + + ```bash + ./vendor/bin/codecept run -g php72parallel_1 --steps + ``` + + ```bash + ./vendor/bin/codecept run -g php72parallel_2 --steps + ``` + + ```bash + ./vendor/bin/codecept run -g php72parallel_3 --steps + ``` diff --git a/guides/v2.1/cloud/docker/docker-development.md b/guides/v2.1/cloud/docker/docker-development.md index 289052a86de..898c72da09a 100644 --- a/guides/v2.1/cloud/docker/docker-development.md +++ b/guides/v2.1/cloud/docker/docker-development.md @@ -9,30 +9,28 @@ functional_areas: {{site.data.var.ece}} provides a Docker environment option for those who use their local environment for development, test, or automation tasks. The {{site.data.var.ece}} Docker environment requires three, essential components: a {{site.data.var.ee}} v2 template, Docker Compose, and the {{site.data.var.ece}} `{{site.data.var.ct}}` package. See the instructions in [Launch Docker]({{page.baseurl}}/cloud/docker/docker-config.html). -The [Magento Cloud Docker repository](https://github.com/magento/magento-cloud-docker) contains build information for the following Docker images: - -Image | Docker link -:------------------ | :------------------------------------------- -**DB** | [mariadb:10.0](https://hub.docker.com/_/mariadb) -**FPM**
PHP-CLI: version 7
PHP-FPM: version 7 | [magento/magento-cloud-docker-php](https://hub.docker.com/r/magento/magento-cloud-docker-php) -**ElasticSearch** | [magento/magento-cloud-docker-elasticsearch](https://hub.docker.com/r/magento/magento-cloud-docker-elasticsearch) -**NGINX** |[magento/magento-cloud-docker-nginx](https://hub.docker.com/r/magento/magento-cloud-docker-nginx) -**Node** | [official Node Docker image](https://hub.docker.com/_/node/) -**RabbitMQ** | [rabbitmq](https://hub.docker.com/_/rabbitmq) -**Redis** | [magento/magento-cloud-docker-redis](https://hub.docker.com/r/magento/magento-cloud-docker-redis) -**TLS** | [magento/magento-cloud-docker-tls](https://hub.docker.com/r/magento/magento-cloud-docker-tls) -**Varnish** | [magento/magento-cloud-docker-varnish](https://hub.docker.com/r/magento/magento-cloud-docker-varnish) +The [Magento Cloud Docker repository](https://github.com/magento/magento-cloud-docker) contains build information for the following Docker containers. -{:.bs-callout .bs-callout-info} -See the [service version values available]({{page.baseurl}}/cloud/docker/docker-config.html) for use when launching Docker. +## Database container + +The database container is based on the [mariadb](https://hub.docker.com/_/mariadb) image. + +- Port: 3306 +- Volumes: + - `/var/lib/mysql` + - `./docker/mysql` + +#### To import a database dump: -## Web container +Place the SQL file into the `.docker/mysql/docker-entrypoint-initdb.d` folder. -The web container works with the [PHP-FPM](https://php-fpm.org) to serve PHP code, the **DB** image for the local database, and the **Varnish** image to send requests and cache the results. +The `{{site.data.var.ct}}` package imports and processes the SQL file the next time you build and start the Docker environment using the `docker-compose up` command. + +Although it is a more complex approach, you can use GZIP by _sharing_ the `.sql.gz` file using the `.docker/mnt` directory and importing it inside the Docker container. ## CLI containers -The following CLI containers, which are based on a PHP-CLI image, provide `magento-cloud` and `{{site.data.var.ct}}` commands to perform file system operations: +The following CLI containers, which are based on a [PHP-CLI version 7 image](https://hub.docker.com/r/magento/magento-cloud-docker-php), provide `magento-cloud` and `{{site.data.var.ct}}` commands to perform file system operations: - `build`—extends the CLI container to perform operations with writable filesystem, similar to the build phase - `deploy`—extends the CLI container to use read-only file system, similar to the deploy phase @@ -56,7 +54,7 @@ The configured state is not ideal ``` {: .no-copy} -## Cron container +### Cron container The Cron container is based on PHP-CLI images, and executes operations in the background immediately after the Docker environment start. It uses the cron configuration defined in the [`crons` property of the `.magento.app.yaml` file]({{page.baseurl}}/cloud/project/project-conf-files_magento-app.html#crons). @@ -66,28 +64,50 @@ The Cron container is based on PHP-CLI images, and executes operations in the ba docker-compose run deploy bash -c "cat /app/var/cron.log" ``` -## Node Container +### Node container -The Node container is based on the [official Node Docker image](https://hub.docker.com/_/node/). It can be used to install NPM dependencies or run any Node-based command line tools. +The Node container is based on the [official Node Docker image](https://hub.docker.com/_/node/). It can be used to install NPM dependencies, such as Gulp, or run any Node-based command line tools. -## Database container +## PHP-FPM container -The database container is based on the `mariadb:10` image. +The PHP-FPM container is based on the [magento/magento-cloud-docker-php](https://hub.docker.com/r/magento/magento-cloud-docker-php) image. -#### To import a database dump: +- Port: 9000 +- Read-only volumes: + - `/app` + - `/app/vendor` + - `/app/generated` + - `/app/setup` +- Read/Write volumes: + - `/app/var` + - `/app/app/etc` + - `/app/pub/static` + - `/app/pub/media` -Place the SQL file into the `.docker/mysql/docker-entrypoint-initdb.d` folder. +### Web container -The `{{site.data.var.ct}}` package imports and processes the SQL file the next time you build and start the Docker environment using the `docker-compose up` command. +The web container works with the [PHP-FPM](https://php-fpm.org) to serve PHP code, the [**DB** image](#database-container) for the local database, and the **Varnish** image to send requests and cache the results. -Although it is a more complex approach, you can use GZIP by _sharing_ the `.sql.gz` file using the `.docker/mnt` directory and importing it inside the Docker container. +### Varnish container -## Varnish container +The Varnish container is based on the [magento/magento-cloud-docker-varnish](https://hub.docker.com/r/magento/magento-cloud-docker-varnish) image. Varnish works on port 80. -The Varnish container is based on the `magento-cloud-docker-varnish` image. Varnish works on port 80. +### TLS container The TLS termination proxy container, based on the [magento/magento-cloud-docker-tls](https://hub.docker.com/r/magento/magento-cloud-docker-tls) image, facilitates the Varnish SSL termination over HTTPS. +## Service containers + +Service | Image +------- | ----- +**ElasticSearch** | [magento/magento-cloud-docker-elasticsearch](https://hub.docker.com/r/magento/magento-cloud-docker-elasticsearch) +**NGINX** | [magento/magento-cloud-docker-nginx](https://hub.docker.com/r/magento/magento-cloud-docker-nginx) +**RabbitMQ** | [rabbitmq](https://hub.docker.com/_/rabbitmq) +**Redis** | [magento/magento-cloud-docker-redis](https://hub.docker.com/r/magento/magento-cloud-docker-redis) + +{:.bs-callout .bs-callout-info} +See the [service version values available]({{page.baseurl}}/cloud/docker/docker-config.html) for use when launching Docker. + ## Sharing data between host machine and container You can share files easily between your machine and a Docker container by placing the files in the `.docker/mnt` directory. You can find the files in the `/mnt` directory the next time you build and start the Docker environment using the `docker-compose up` command. diff --git a/guides/v2.1/cloud/release-notes/cloud-tools.md b/guides/v2.1/cloud/release-notes/cloud-tools.md index bb1f7f3291c..57e7cea0fba 100644 --- a/guides/v2.1/cloud/release-notes/cloud-tools.md +++ b/guides/v2.1/cloud/release-notes/cloud-tools.md @@ -37,6 +37,8 @@ The release notes include: - {:.new}Added a new command to the `{{site.data.var.ct}}` package that displays environment services, routes, or variables. See [Services, routes, and variable]({{page.baseurl}}/cloud/reference/ece-tools-reference.html#services-routes-and-variables). [Feature submitted by Vladimir Kerkhoff](https://github.com/magento/ece-tools/pull/486). +- {:.new}You can now perform functional testing using the `{{site.data.var.ct}}` package in the Docker environment. See [Functional testing in Docker]({{page.baseurl}}/cloud/docker/docker-development-testing.html). + ## v2002.0.19 - {:.fix}Fixed an issue that overwrites the `env.php` file during a deploy, resulting in a loss of custom configurations. This update ensures that {{site.data.var.ece}} updates the `env.php` file with every deployment, while preserving custom configurations. diff --git a/guides/v2.2/cloud/docker/docker-development-testing.md b/guides/v2.2/cloud/docker/docker-development-testing.md new file mode 100644 index 00000000000..82c1e7d3b21 --- /dev/null +++ b/guides/v2.2/cloud/docker/docker-development-testing.md @@ -0,0 +1,119 @@ +--- +group: cloud-guide +title: Functional testing in Docker +functional_areas: + - Cloud + - Docker + - Configuration +--- + +You can use the `{{site.data.var.ct}}` package to run functional tests in the Docker environment. Functional tests are in the `src/Test/Functional/Acceptance` folder. See an example in the [ece-tools repository](https://github.com/magento/ece-tools/tree/develop/src/Test/Functional/Acceptance). + +## Prerequisites + +Before you run functional tests, you must prepare your environment with the following steps. + +1. Stop all services that use the following ports: + + - `80`—varnish + - `443`—web, tls + - `3306`—apache, mysql + +1. Switch to the preferred PHP version for running tests. + +1. Update the project dependencies. + + ```bash + composer update + ``` + +1. Add credentials to the Docker environment. + + ```bash + echo "COMPOSER_MAGENTO_USERNAME=your_public_key" >> ./.docker/composer.env + ``` + + ```bash + echo "COMPOSER_MAGENTO_PASSWORD=your_private_key" >> ./.docker/composer.env + ``` + +## Run tests + +The `codeception.dist.yml` file in the `{{site.data.var.ct}}` root directory contains the global testing configuration. See the [`{{site.data.var.ct}}` repository](https://github.com/magento/ece-tools/blob/develop/codeception.dist.yml). + +By default, functional tests produce a short output. You can receive a more detailed output by editing the `codeception.dist.yml` file to set the `printOutput:` property to `true`. + +```yaml +modules: + config: + Magento\MagentoCloud\Test\Functional\Codeception\Docker: + ... + printOutput: true +``` +{:.no-copy} + +### Run a specific test + +Use the following command format to run a specific functional test: + +```bash +./vendor/bin/codecept run Acceptance Cest +``` + +For example, the following test verifies that the post-deploy task runs successfully. + +```bash +./vendor/bin/codecept run Acceptance PostDeployCest +``` + +Sample response: + +```terminal +Codeception PHP Testing Framework v2.5.6 +Powered by PHPUnit 6.5.14 by Sebastian Bergmann and contributors. +Running with seed: +Acceptance Tests (1) ----------------------------------------------------------------------------------------------- +-------------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------- +PostDeployCest: Test post deploy | {"ADMIN_EMAIL":"admin@example.com"} + [Magento\MagentoCloud\Test\Functional\Robo\Tasks\GenerateDockerCompose] Running ./bin/ece-tools docker:build + --mode=functional --php=7.2 +... +... +✔ PostDeployCest: Test post deploy | {"ADMIN_EMAIL":"admin@example.com"} (210.41s) +``` +{: .no-copy} + +### Run all tests + +The following list provides the commands to run all available tests for each version of PHP. + +- **PHP 7.0** + + ```bash + ./vendor/bin/codecept run -g php70 --steps + ``` + +- **PHP 7.1** + + ```bash + ./vendor/bin/codecept run -g php71 --steps + ``` + +- **PHP 7.2** + + ```bash + ./tests/travis/prepare_functional_parallel.sh + ``` + + ```bash + ./vendor/bin/codecept run -g php72parallel_1 --steps + ``` + + ```bash + ./vendor/bin/codecept run -g php72parallel_2 --steps + ``` + + ```bash + ./vendor/bin/codecept run -g php72parallel_3 --steps + ``` diff --git a/guides/v2.3/cloud/docker/docker-development-testing.md b/guides/v2.3/cloud/docker/docker-development-testing.md new file mode 120000 index 00000000000..e6d5e401e69 --- /dev/null +++ b/guides/v2.3/cloud/docker/docker-development-testing.md @@ -0,0 +1 @@ +../../../v2.2/cloud/docker/docker-development-testing.md \ No newline at end of file