-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Testing] Dockerized test suite (#2430)
* Removing spaces from test suite names Having spaces in test suite names makes it difficult to call phpunit from wrapper scripts, which are needed for the docker-based test suite. * Skipping broken tests * Replacing .click with .submit .click was not executing form submit and was causing the test to fail * Add missing xsi:nil property to fixture * Allow a selenium host/port to be specified via config file * Add docker-based test suite and required scripts * Add note about creating Docker group * Rename Dockerfiles * Use linting scripts in .travis.yml
- v26.0.4
- v26.0.3
- v26.0.2
- v26.0.1
- v26.0.0
- v25.0.2
- v25.0.1
- v25.0.0
- v24.1.7
- v24.1.6
- v24.1.5
- v24.1.4
- v24.1.3
- v24.1.2
- v24.1.1
- v24.1.0
- v24.0.3
- v24.0.2
- v24.0.1
- v24.0.0
- v23.0.12
- v23.0.11
- v23.0.10
- v23.0.9
- v23.0.8
- v23.0.7
- v23.0.6
- v23.0.5
- v23.0.4
- v23.0.3
- v23.0.2
- v23.0.1
- v23.0.0
- v22.0.4
- v22.0.3
- v22.0.2
- v22.0.1
- v22.0.0
- v21.0.7
- v21.0.6
- v21.0.5
- v21.0.4
- v21.0.3
- v21.0.2
- v21.0.1
- v21.0.0
- v21.0.0-rc1
- v20.3.1
- v20.3.0
- v20.2.1
- v20.2.0
- v20.1.2
- v20.1.1
- v20.1.0
- v20.0.2
- v20.0.1
- v20.0.0
- v19.1.2
- v19.1.1
- v19.1.0
- v19.0.2
- v19.0.1
- v19.0.0
- v19.0.0-rc1
- v18.0.5
- v18.0.4
- v18.0.3
- v18.0.2
- v18.0.1
- v18.0.0
- v18.0.0a
- v18.0.0-rc3
- v18.0.0-rc2
- v18.0.0-rc1
- DOI
1 parent
c71ca5c
commit 706268f
Showing
21 changed files
with
556 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM mysql:5.7 | ||
|
||
ARG BASE_DIR | ||
|
||
COPY SQL/0000-00-00-schema.sql /0000-00-00-schema.sql | ||
COPY SQL/0000-00-01-Permission.sql /0000-00-01-Permission.sql | ||
COPY SQL/0000-00-02-Menus.sql /0000-00-02-Menus.sql | ||
COPY SQL/0000-00-03-ConfigTables.sql /0000-00-03-ConfigTables.sql | ||
COPY SQL/0000-00-04-Help.sql /0000-00-04-Help.sql | ||
COPY SQL/0000-00-99-indexes.sql /0000-00-99-indexes.sql | ||
|
||
COPY test/sql/CreateTestUser.sql /0000-01-00-TestUser.sql | ||
COPY docs/instruments/radiology_review.sql /radiology_review.sql | ||
|
||
RUN echo "Use LorisTest;" | cat - \ | ||
0000-00-00-schema.sql \ | ||
0000-00-01-Permission.sql \ | ||
0000-00-02-Menus.sql \ | ||
0000-00-03-ConfigTables.sql \ | ||
0000-00-04-Help.sql \ | ||
0000-00-99-indexes.sql \ | ||
0000-01-00-TestUser.sql \ | ||
radiology_review.sql > /docker-entrypoint-initdb.d/0000-compiled.sql | ||
|
||
RUN echo "Use LorisTest;" >> /docker-entrypoint-initdb.d/0001-paths.sql | ||
RUN echo "UPDATE Config SET Value='${BASE_DIR}/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='base');" >> /docker-entrypoint-initdb.d/0001-paths.sql | ||
RUN echo "UPDATE Config SET Value='http://web:8000' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='url');" >> /docker-entrypoint-initdb.d/0001-paths.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM php:7.0 | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y mysql-client zlib1g-dev | ||
|
||
# Install extensions through the scripts the container provides | ||
RUN docker-php-ext-install pdo_mysql zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM php:7.0 | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y mysql-client zlib1g-dev | ||
|
||
RUN yes | pecl install xdebug-2.4.1 | ||
RUN echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini | ||
RUN echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini | ||
RUN echo "xdebug.remote_autostart=on" >> /usr/local/etc/php/conf.d/xdebug.ini | ||
|
||
# Install extensions through the scripts the container provides | ||
RUN docker-php-ext-install pdo_mysql zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
version: '2' | ||
services: | ||
db: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.test.db | ||
args: | ||
BASE_DIR: /app/ | ||
environment: | ||
- MYSQL_DATABASE=LorisTest | ||
- MYSQL_RANDOM_ROOT_PASSWORD=yes | ||
|
||
selenium: | ||
image: selenium/standalone-firefox-debug:2.53.1 | ||
ports: | ||
- "5900:5900" | ||
|
||
web: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.test.php7 | ||
volumes: | ||
- ./:/app | ||
environment: | ||
- LORIS_DB_CONFIG=/app/test/config.xml | ||
depends_on: | ||
- db | ||
command: php -S 0.0.0.0:8000 -t /app/htdocs /app/htdocs/router.php | ||
|
||
unit-tests: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.test.php7 | ||
volumes: | ||
- ./:/app | ||
working_dir: /app | ||
environment: | ||
- LORIS_DB_CONFIG=test/config.xml | ||
depends_on: | ||
- db | ||
entrypoint: /app/test/wait-for-services.sh | ||
|
||
integration-tests: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.test.php7 | ||
volumes: | ||
- ./:/app | ||
working_dir: /app | ||
environment: | ||
- LORIS_DB_CONFIG=test/config.xml | ||
- SELENIUM_REQUIRED=true | ||
depends_on: | ||
- db | ||
- selenium | ||
- web | ||
entrypoint: /app/test/wait-for-services.sh | ||
|
||
selenium-debug: | ||
image: selenium/standalone-firefox-debug:2.53.1 | ||
links: | ||
- web-debug:web | ||
ports: | ||
- "5901:5900" | ||
|
||
web-debug: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.test.php7.debug | ||
volumes: | ||
- ./:/app | ||
environment: | ||
- LORIS_DB_CONFIG=/app/test/config.xml | ||
- XDEBUG_CONFIG=remote_host=${XDEBUG_REMOTE_HOST} | ||
- PHP_IDE_CONFIG=serverName=LorisTests | ||
depends_on: | ||
- db | ||
command: php -S 0.0.0.0:8000 -t /app/htdocs /app/htdocs/router.php | ||
|
||
unit-tests-debug: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.test.php7.debug | ||
volumes: | ||
- ./:/app | ||
working_dir: /app | ||
environment: | ||
- LORIS_DB_CONFIG=test/config.xml | ||
- XDEBUG_CONFIG=remote_host=${XDEBUG_REMOTE_HOST} | ||
- PHP_IDE_CONFIG=serverName=LorisTests | ||
depends_on: | ||
- db | ||
entrypoint: /app/test/wait-for-services.sh | ||
|
||
integration-tests-debug: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.test.php7.debug | ||
volumes: | ||
- ./:/app | ||
working_dir: /app | ||
environment: | ||
- LORIS_DB_CONFIG=test/config.xml | ||
- SELENIUM_REQUIRED=true | ||
- XDEBUG_CONFIG=remote_host=${XDEBUG_REMOTE_HOST} | ||
- PHP_IDE_CONFIG=serverName=LorisTests | ||
links: | ||
- db | ||
- selenium-debug:selenium | ||
- web-debug:web | ||
entrypoint: /app/test/wait-for-services.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Dockerized Test Suite | ||
|
||
## Requirements | ||
You will need Docker Engine, Docker Compose, and NodeJS. | ||
|
||
Please follow the directions [here](https://docs.docker.com/engine/installation/) to install Docker Engine. Be sure to also [create a Docker group](https://docs.docker.com/engine/installation/linux/ubuntulinux/#/create-a-docker-group) so Docker can be run without using `sudo`. | ||
|
||
Next, install Docker Compose: | ||
|
||
``` | ||
curl -L https://github.com/docker/compose/releases/download/1.8.1/docker-compose-`uname -s`-`uname -m` > ~/docker-compose | ||
chmod +x ~/docker-compose | ||
sudo mv ~/docker-compose /usr/local/bin/docker-compose | ||
``` | ||
|
||
Make sure you have NodeJS installed. If not, follow the instructions [here](https://nodejs.org/en/download/package-manager/). | ||
|
||
Finally, run `npm install` in the root folder (this is only required for Javascript linting). | ||
|
||
## Basic Workflow | ||
|
||
**To run all the unit tests:** | ||
|
||
``` | ||
npm run tests:unit | ||
``` | ||
|
||
**To run all of the integration tests:** | ||
|
||
``` | ||
npm run tests:integration | ||
``` | ||
|
||
You can see the integration tests in action by connecting your VNC viewer to `<host>:5900` and supplying the password `secret`. | ||
|
||
|
||
**To run PHP linting:** | ||
|
||
``` | ||
npm run lint:php | ||
``` | ||
|
||
**To run Javascript linting:** | ||
|
||
``` | ||
npm run lint:javascript | ||
``` | ||
|
||
## Advanced Workflow | ||
|
||
#### Command-Line Options | ||
You can pass any [PHPUnit command-line options](https://phpunit.de/manual/current/en/textui.html) by appending `--` followed by the options. For example, say you only wanted to run the unit tests contained in the `CandidateTest` class. To achieve this you could run the following command: | ||
|
||
``` | ||
npm run tests:unit -- --filter CandidateTest | ||
``` | ||
|
||
Or, to run a specific test within `CandidateTest`: | ||
|
||
``` | ||
npm run tests:unit -- --filter CandidateTest::testValidatePSCID | ||
``` | ||
|
||
#### Debugging | ||
|
||
Both the unit and integration tests can be run with XDebug enabled. | ||
|
||
``` | ||
npm run tests:unit:debug | ||
``` | ||
Or | ||
``` | ||
npm run tests:integration:debug | ||
``` | ||
|
||
You must specify a remote host for XDebug to connect to via the `XDEBUG_REMOTE_HOST` environment variable when using either of these commands. | ||
|
||
|
||
## Todo | ||
|
||
- Run integration tests in parallel | ||
|
||
## Issues | ||
|
||
- By default npm will output some irrelevant info when a script returns a non-zero error code, as described [here](https://github.com/npm/npm/issues/8821). To prevent this pass `-s` or `--silent` to `npm run`, e.g. `npm run -s tests:unit`. | ||
|
||
- Running the entire integration test suite with XDebug enabled sometimes results in a segmentation fault. This appears to be an issue with XDebug itself. |
Oops, something went wrong.