* [#2197] Created E2E testing environment Created docker-based end-to-end testing environment, which allows for testing more complex scenarios. Additionally added FunctionE2ETest class that contains test scenario for `run` function with placeholders. Closes #2197 * [#2197] Moved docker to test dir & separated e2e tests from unit-tests The docker directory has been moved into test/ directory. Additionally the e2e tests have been separated from the unit-test files: * AbstractE2ETest class is directly inheriting from TestCase, dropping relation to the AbstractTest * Separate bootstrap.php file for e2e test was created * Separate phpunit-e2e.xml.dist file was created to configure PHPUnit for just the e2e tests * deployer docker service now runs only e2e tests by default * [#2197] Added E2E tests to GH actions Added E2E tests steps to GH actions: * building the docker-compose stack (building images) * starting the stack to run the tests If E2E tests fail, then docker-compose up will end with non-zero exit code, thus the workflow will be marked as failed. * [#2197] Fixed no output when using run() with sudo Fixed a discrepancy in the `run()` function, where there would be no output when the command was being executed with a sudo. * [#2197] Added testcases for running commands with sudo Added two testcases for e2e tests, that verify: * that sudo command can be ran with password provided interactively * that sudo command can be ran with password passed via argument To allow for these tests to happen, the Dockerfile for server service had to be modified - the deployer user will require a password, when running command with sudo. * [#2197] Added Laravel-boilerplate deploy E2E test Added a very simple E2E test that checks whether the Laravel-boilerplate deploys successfully to the testing server. The testing scenario will deploy the app, copy sample .env file, generate the app key and finally try to get the main page contents to verify that the expected string is visible in the page source. * [#2197] Moved E2E tests to separate job Moved E2E tests to separate job and added docker-compose cache to slightly improve stack build times. * [#2197] Using deployphp test-laravel repo for E2E tests Updated the laravel-boilerplate deploy config to use the repository that belongs to deployphp organization. Co-authored-by: Bartlomiej Sacharski <beton@cementowina.org>
Deployer E2E testing environment
This directory contains an end-to-end testing environment for Deployer.
All commands mentioned in this readme, should be executed in the docker
directory.
Requirements
- Docker
- docker-compose
Running tests
The E2E are started when running the docker-compose up
command.
This will start the server
container that has the Apache, OpenSSH & PHP 7.3 enabled.
Once the server
is up and running, the deployer
container will be started and alongside it
the tests will be ran.
Adding new E2E tests
The E2E test should be a part of the e2e
test suite.
Each e2e
test class should inherit from AbstractE2ETest
class.
Note: E2E tests will only run in an environment where env variable E2E_ENV
has been set and has a truthy value.
Manually accessing the deployer
container.
The container can be accessed by running:
docker-compose run deployer sh
This command will spawn a sh
shell inside the deployer
container.
About containers
deployer
container
The deployer
container contains:
- git
- PHP 7.3 with XDebug enabled
- rsync
- SSH client
It is possible to access the server
container via ssh by running:
ssh deployer@server
root
's public key has been added to authorized keys for deployer
user.
Enabling XDebug
To enable XDebug create a docker-compose.override.yml
file with following content:
services:
deployer:
environment:
# See https://docs.docker.com/docker-for-mac/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host
# See https://github.com/docker/for-linux/issues/264
# The `remote_host` below may optionally be replaced with `remote_connect_back=1`
XDEBUG_CONFIG: >-
remote_enable=1
remote_host=${XDEBUG_HOST:-host.docker.internal}
remote_autostart=1
remote_port=9000
idekey=PHPSTORM
# This should correspond to the server declared in PHPStorm `Preferences | Languages & Frameworks | PHP | Servers`
# Then PHPStorm will use the corresponding path mappings
PHP_IDE_CONFIG: serverName=deployer-e2e
Note: you may want to set the XDEBUG_HOST
env variable to point to your IP address when running tests in Linux.
server
container
The server
container contains:
- Apache (with the
DocumentRoot
set to/var/www/html/current
) - git
- PHP 7.3
- SSH server with
- sudo (user
deployer
can usesudo
after providing a password:deployer
)