Commit f646cad7 authored by Tobias Munk's avatar Tobias Munk

updated base images, stack-, test-setup and docs

parent a139a9dd
Pipeline #1414 failed with stage
FROM phundament/php:5.6-cli-dev
FROM phundament/php:5.6-cli-4.0.0-rc1-dev
# Clean eventually orphaned files and remove installation source
RUN rm -rf /app/src /app/web /app-src
......@@ -19,3 +19,6 @@ ADD yii Dockerfile docker-compose.yml /app/
ADD web /app/web
ADD src /app/src
# Create folder writable by the application (non-persistent data)
RUN mkdir /app/web/assets /app/runtime && \
chmod 777 /app/web/assets /app/runtime
......@@ -24,6 +24,7 @@ include $(DOMA_DIR)/phundament/4.0/Makefile
# Local development config targets
# --------------------------------
.PHONY: TEST CI STAGING
TEST: ##@config configure application for local testing
$(eval COMPOSE_FILE := build/stacks-gen/test.yml)
......
#!/usr/bin/env bash
mkdir /app/web/assets /app/runtime
chmod 777 /app/web/assets /app/runtime
composer install
./yii app/create-mysql-db
./yii migrate
./yii app/setup-admin-user
\ No newline at end of file
./yii migrate --interactive=0
./yii app/setup-admin-user --interactive=0
echo "\nApplication initialized"
tail -f /dev/null
\ No newline at end of file
adamhaproxy:
environment:
BACKEND_PORT: 80
VIRTUAL_HOST: staging.adam.192.168.59.103.xip.io
image: tutum/haproxy
links:
- 'appnginx:appnginx'
ports:
- '80'
appcli:
build: .
command: 'sh /root/tutum.sh'
environment:
APP_MIGRATION_LOOKUP: '@app/migrations'
DB_ENV_MYSQL_DATABASE: adambase-staging-1
DB_ENV_MYSQL_DATABASE: myapp-staging-1
image: 'phundament/app:latest'
links:
- 'appnginx:WEB'
......@@ -22,7 +14,7 @@ appfpm:
environment:
APP_ASSET_FORCE_PUBLISH: 0
APP_PRETTY_URLS: 1
DB_ENV_MYSQL_DATABASE: adambase-staging-1
DB_ENV_MYSQL_DATABASE: myapp-staging-1
YII_DEBUG: 1
YII_ENV: prod
image: 'phundament/php:5.6-fpm-dev'
......@@ -32,7 +24,7 @@ appfpm:
- appsrc
appnginx:
environment:
VIRTUAL_HOST: staging.adam.192.168.59.103.xip.io
VIRTUAL_HOST: staging.myapp.192.168.59.103.xip.io
image: 'schmunk42/nginx:1.7'
links:
- 'appfpm:PHPFPM'
......
......@@ -3,16 +3,14 @@ appbuilder:
volumes:
- '/Volumes/storage/runner-test-b/builds/project-21:/app'
appcli:
command: 'tail -f /dev/null'
build: ../..
command: 'sh /app/build/container-files/init.sh'
environment:
APP_MIGRATION_LOOKUP: '@app/migrations'
YII_ENV: test
image: adam_appsrc
links:
- 'appnginx:WEB'
- 'mariadb:DB'
- 'seleniumhub:HUB'
- 'mariadb:DB'
volumes:
- '/Volumes/storage/runner-test-b/builds/project-21/tests:/app/tests'
- '/Volumes/storage/runner-test-b/builds/project-21/codeception.yml:/app/codeception.yml'
......@@ -23,10 +21,9 @@ appfpm:
environment:
YII_DEBUG: 1
YII_ENV: test
image: 'phundament/php:5.6-fpm-dev'
image: 'phundament/php:5.6-fpm-4.0.0-rc1-dev'
links:
- 'mariadb:DB'
- 'mariadb:DB'
volumes_from:
- appsrc
appnginx:
......
appcli:
command: 'tail -f /dev/null'
build: ../..
command: 'sh /app/build/container-files/init.sh'
environment:
APP_MIGRATION_LOOKUP: '@app/migrations'
YII_ENV: test
image: adam_appsrc
links:
- 'appnginx:WEB'
- 'mariadb:DB'
- 'seleniumhub:HUB'
- 'mariadb:DB'
volumes:
- '../..:/app'
- '../../src:/app/src'
- '../../tests:/app/tests'
- '../../codeception.yml:/app/codeception.yml'
- '../../_output:/app/_output'
appfpm:
environment:
YII_DEBUG: 1
YII_ENV: test
image: 'phundament/php:5.6-fpm-dev'
image: 'phundament/php:5.6-fpm-4.0.0-rc1-dev'
links:
- 'mariadb:DB'
- 'mariadb:DB'
volumes:
- '../..:/app'
appnginx:
environment:
VIRTUAL_HOST: ~^dev\.khf\.com
VIRTUAL_HOST: ~^dev\.myapp\.
image: 'schmunk42/nginx:1.7'
links:
- 'appfpm:PHPFPM'
......@@ -32,7 +32,7 @@ appnginx:
volumes:
- '../..:/app'
appsrc:
build: .
build: ../..
command: 'tail -f /dev/null'
volumes:
- '../..:/app'
......
......@@ -9,7 +9,7 @@ appcli:
image: phundament/app:latest
environment:
APP_MIGRATION_LOOKUP: '@app/migrations'
DB_ENV_MYSQL_DATABASE: 'adambase-staging-1'
DB_ENV_MYSQL_DATABASE: 'myapp-staging-1'
command: "sh /root/tutum.sh"
.volumes: CLEAN
volumes_from:
......@@ -22,24 +22,14 @@ appfpm:
YII_ENV: prod
APP_PRETTY_URLS: 1
APP_ASSET_FORCE_PUBLISH: 0
DB_ENV_MYSQL_DATABASE: 'adambase-staging-1'
DB_ENV_MYSQL_DATABASE: 'myapp-staging-1'
.volumes: CLEAN
volumes_from:
- 'appsrc'
appnginx:
environment:
VIRTUAL_HOST: 'staging.adam.192.168.59.103.xip.io'
VIRTUAL_HOST: 'staging.myapp.192.168.59.103.xip.io'
.volumes: CLEAN
volumes_from:
- appsrc
adamhaproxy:
image: tutum/haproxy
links:
- appnginx:appnginx
ports:
- "80"
environment:
BACKEND_PORT: 80
VIRTUAL_HOST: 'staging.adam.192.168.59.103.xip.io'
\ No newline at end of file
# docker-compose configuration for local development
appsrc:
build: %APP_DOCKERFILE_PATH%
.volumes: CLEAN
volumes:
- %APP_DOCKERFILE_PATH%:/app
......@@ -10,24 +11,22 @@ appnginx:
- %APP_DOCKERFILE_PATH%:/app
appcli:
image: adam_appsrc
build: %APP_DOCKERFILE_PATH%
environment:
YII_ENV: test
.external_links: CLEAN
links:
- 'seleniumhub:HUB'
- 'mariadb:DB'
.volumes: CLEAN
volumes:
- %APP_DOCKERFILE_PATH%:/app
- %APP_DOCKERFILE_PATH%/src:/app/src
- %APP_DOCKERFILE_PATH%/tests:/app/tests
- %APP_DOCKERFILE_PATH%/codeception.yml:/app/codeception.yml
- %APP_DOCKERFILE_PATH%/_output:/app/_output
appfpm:
environment:
YII_ENV: test
YII_DEBUG: 1
.external_links: CLEAN
links:
- 'mariadb:DB'
.volumes: CLEAN
volumes:
- %APP_DOCKERFILE_PATH%:/app
......
......@@ -6,28 +6,19 @@
# container to run one-off commands - a dockerized shell
appcli:
# should be replaced with: image: <project_name>_appsrc
image: project_appsrc
# should be replaced with image, eg. <project_name>_appsrc
build: .
# host-volume for local development
volumes:
- '.:/app'
links:
- 'appnginx:WEB'
- 'mariadb:DB'
environment:
APP_MIGRATION_LOOKUP: '@app/migrations'
command: 'tail -f /dev/null'
appsrc:
build: .
# host-volume for local development
volumes:
- '.:/app'
command: 'tail -f /dev/null'
command: 'sh /app/build/container-files/init.sh'
# The php-fpm server for interpreting php code
appfpm:
image: phundament/php:5.6-fpm-dev
image: phundament/php:5.6-fpm-4.0.0-rc1-dev
# host-volume for local development
volumes:
- '.:/app'
......@@ -46,7 +37,15 @@ appnginx:
ports:
- '80'
environment:
VIRTUAL_HOST: '~^dev\.khf\.com'
VIRTUAL_HOST: '~^dev\.myapp\.'
# Build-container with CLI and source-code
appsrc:
build: .
command: 'tail -f /dev/null'
# host-volume for local development
volumes:
- '.:/app'
# Data Services
# -------------
......
Testing
=======
### Running in isolated Docker containers
### Running in isolated Docker stacks
Creating and running a test environment can be a cumbersome task, since you have to take care about several specific tasks, like executing your tests in a separate database. Therefore the Phundament 4 `:development` images contain fully pre-installed Yii 2.0 Framework codeception test-suites for unit-, functional- and acceptance-testing.
Creating and running a test environment can be a cumbersome task, since you have to take care about several specific tasks, like executing your tests in a separate database. Therefore the Phundament 4 Docker images contain pre-installed Yii 2.0 Framework codeception test-suites for unit-, functional- and acceptance-testing.
In `docker-compose.yml` two additional containers `testweb` and `testdb` are defined which are used to run the test-suites. To get started, bring up the test containers and execute tests suites with docker.
We are using `Makefile` with `schmunk42/doma`-templates to control the test-stack.
```
docker-compose up -d testweb
docker exec app_testweb_1 codecept build
docker exec app_testweb_1 codecept run
```
> Note: Replace `app_testweb_1` with your container name.
>
> You need to run `codecept build` only before the first `run` or after changes to the test classes.
>
> Since acceptance tests are executed against a running webserver we need to use `docker exec` for conveniently running the test-suites in the container.
### Basic usage
Before starting tests, it's recommended to build all images in the default development stack
The following commands can be used to determine the container name to use with docker...
make docker-build
```
docker ps
```
Next step is to get a clean stack selected and configured by using `TEST` target.
Or to rebuild the codeception classes...
make TEST docker-kill docker-rm docker-up
```
docker exec app_testweb_1 codecept build
```
Before the test-suites can be run, we need to setup the application, like during development setup, but also in the test-stack.
### Running with a local webserver
make TEST app-setup
> Note! This setup requires an additional database and a modified setup with ENV variables.
> It is recommended to use the `docker-compose` setup above.
Finally we can execute the tests.
Update `url` in `tests/codeception/acceptance.suite.yml`
make TEST app-run-tests
Install required packages and build test classes
### Advanced usage
```
./yii app/setup-tests
```
To run specific tests you can use the `OPTS` environment variable
Run all suites in all applications
make TEST app-run-tests OPTS='acceptance dev/MyCept --steps'
If you need to customize the codeception setup you can rebuild the tester classes with
make TEST app-build-tests
```
./yii app/run-tests
```
## Alternative testing setup
### docker-compose
tbd
### Running with a local webserver
> Note! This setup requires an additional database and a modified setup with ENV variables.
> It is recommended to use the `docker-compose` setup above.
Update `url` in `tests/codeception/acceptance.suite.yml`
Install required packages and build test classes
```
./yii app/setup-tests
```
Run all suites in all applications
```
./yii app/run-tests
```
......@@ -22,7 +22,7 @@ class LoginPage extends BasePage
$this->actor->fillField('input[name="login-form[password]"]', $password);
$this->actor->click('Sign in');
if (method_exists($this->actor,'waitForElement')) {
$this->actor->waitForElement('#link-logout', 4);
$this->actor->waitForElement('#link-logout', 5);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment