Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions _data/toc/cloud-guide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
119 changes: 119 additions & 0 deletions guides/v2.1/cloud/docker/docker-development-testing.md
Original file line number Diff line number Diff line change
@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be helpful to provide hint here --Consider providing link to Versions, or provide example command


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 <TestName>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
```
78 changes: 49 additions & 29 deletions guides/v2.1/cloud/docker/docker-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**<br>PHP-CLI: version 7<br>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
Expand All @@ -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).

Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions guides/v2.1/cloud/release-notes/cloud-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ The release notes include:

- {:.new}<!-- MAGECLOUD-3451 -->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}<!-- MAGECLOUD-3129/3684 -->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}<!-- MAGECLOUD-3668 -->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.
Expand Down
119 changes: 119 additions & 0 deletions guides/v2.2/cloud/docker/docker-development-testing.md
Original file line number Diff line number Diff line change
@@ -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 <TestName>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
```
1 change: 1 addition & 0 deletions guides/v2.3/cloud/docker/docker-development-testing.md