Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added dockerized test setup #13360

Merged
merged 25 commits into from
Mar 6, 2017
Merged

Conversation

schmunk42
Copy link
Contributor

@schmunk42 schmunk42 commented Jan 10, 2017

Q A
Is bugfix? no
New feature? yes
Breaks BC? yes
Tests pass? it's about testing
Fixed issues relates #13047

essential

  • base-image (rela
  • mssql stack
  • cubrid stack
  • host-volumes (yes/no?)
  • reports

optional

  • additonal tools/dev-image(?)
  • isolation in GitLab CI

related: Codeception/Codeception#3739

- POSTGRES_PASSWORD=postgres

#sqlsrv:
# image: microsoft/mssql-server-linux
Copy link
Member

Choose a reason for hiding this comment

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

Are you going to enable it as well?

Copy link
Contributor Author

@schmunk42 schmunk42 Jan 10, 2017

Choose a reason for hiding this comment

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

Yes, I tried, but you need to install some additional system packages first - it just did not work right away. Let me know if you've some input here, I've never worked with MSSQL.

Copy link
Member

Choose a reason for hiding this comment

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

I have no experience with dockerizing it or even running it under Linux.

@cebe cebe self-assigned this Jan 12, 2017
@cebe cebe added the type:test label Jan 12, 2017
@schmunk42
Copy link
Contributor Author

TL;dr

So, theoretically this is a complete setup. You can view an example GitHub build here - they're not green yet.

I've split the setup into 3 stacks: default, mssql and cubrid. We can add more later. There are 4 test jobs, which are run in parallel. Whenever possible I've used pre-built images.

Currently there are different base-images, I intentionally left it in this state, because it shows a few issues we should sort out, before continuing.

Choosing a base image

There are several options how to create a Docker image for testing. You can build from different base-images, like php, composer or codeception/codeception or debian, ubuntu, ....
Currently there's no official Yii image, another option.

Basically you need to install the required PHP-extensions for Yii (that's why some tests fail, because this is just a vanilla PHP) and for some suites also additional extensions.

I'd say it's not really possible to build a Yii image with all extensions (pdo_mssql, pdo_cubrid, xcache etc...) just because some are not available for debian, etc... So I'd just choose what works, i.e. codemix base-image, custom build for cubrid, pre-build for mssql.

In tests, there are dependencies from i.e. log suite to db, which make tests fail which would actually run on a vanilla PHP. I thought about also putting them into group db, WDYT?
These components might also be reviewed for decoupling.

Depending on how you wanna build the image you also need composer and some other tools, like npm or yarn, i.e. for testing asset bundling via webpack. But that's a separate topic.

Tests do not pass on Travis now, this is just because of changed DB credentials and hosts (should be easy to fix)


While I could easily write 5x times more :) I'd like stop here and also CC: @mikehaertl and @motin - your experience and feedback about Docker, PHP & Yii is very welcome.

Would be really nice if you could give it a try and just report if the things start to work.

@SilverFire SilverFire added this to the website and infrastructure milestone Jan 14, 2017
@motin
Copy link

motin commented Jan 19, 2017

Love it. Every open source project should offer a way of running database-dependent tests without having to follow extensive complicated instructions on how to set up databases and credentials. @schmunk42, please supply a single shell-script that will run all tests with all database engines in sequence and I'll verify that it works over here :)

Squashed commits:
[c42f30c] updated base image, added docs & local test script
[88f0c40] debug
[6220c94] fixed network isolation
[c63c7c3] test mssql only on test/mssql branch
[74efc78] fixed isolation in after_script
[02b895b] updated test setup
[3335f39] updated retry
[bd123b2] updated service checks
[45e4c90] updated build
[d54da7a] updated after_script
[5a4c726] 🏭 wait for mysql
[08db878] fixed typo
[ea53c1e] updated build stages
[9807ce3] fixed typos
[cf9f64e] fixed mssql testing
[08001d6] added db create for mssql
[62f6b65] run travis (gitlab simulation) only in travis branch
[cf63da4] streamlined build
[76808ac] updated test jobs
[18d79b5] fixed test error
[7b2bce6] updated build & composer.lock
[244623a] updated build
[86bd71b] fixed cleanup
[86ab2e8] fixed cleanup
[091d4b8] fixed tests
[2d315b5] fixed build config
[2913644] fixed project names
[f53b823] refactored build config
[5a791fb] refactored docker db-tests
[b4479b0] revert
[a975fa5] updated gitlab build
[4e4e5e4] updated mssql setup
[d6ff03b] added sleep workaround
[578b102] removed host volumes in test
[928f50b] fixed path
[967ab10] updated tests
[520f317] bootstrap cubrid
[5f245e1] 🏭 fixed cubrid tests
[940dbbc] 🏭 pinned cubrid version 9.3.6.0002
[8d5ea69] 📝 dockerized test commands
[9954b54] updated cubrid
[fb3afac] updated docs
[3f63ced] updated isolation
[bdc3c83] 🏭 build cubrid
[b777911] 🏭 disabled mssql, updated cubrid
[36534e7] added travis-a-like stage
[6546f02] updated GitLab build
[c046096] updated test setup
- added mssql and cubrid stack
[5a0e635] disabled host-volume
[75cf342] fixed test
[8de0794] fixed testing
[465d27a] added stages
[63aa950] added script
[68eecef] fixed typo
[00e4b88] updated Docker build
[f9072cc] added dockerized test setup
@schmunk42 schmunk42 force-pushed the feature/docker-testing branch from 45e4c90 to f5ab85c Compare January 19, 2017 17:01
@schmunk42
Copy link
Contributor Author

This should be ready to try out locally.
Let me know if you've questions...

@schmunk42
Copy link
Contributor Author

Example build pipelines

- added git files to dockerignore
- updated local testing
- updated build on branches
@schmunk42 schmunk42 force-pushed the feature/docker-testing branch from 2b702dd to 7718868 Compare January 24, 2017 14:42
@@ -16,29 +16,29 @@
$config = [
'databases' => [
'cubrid' => [
'dsn' => 'cubrid:dbname=demodb;host=localhost;port=33000',
'dsn' => 'cubrid:dbname=demodb;host=cubrid;port=33000',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cebe @samdark How should we handle this? Using a separate file for Docker tests. It's theoretically possible to fake this with Docker, but we would loose a lot of isolation & stability.

Copy link
Member

Choose a reason for hiding this comment

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

What is the problem here?

@schmunk42
Copy link
Contributor Author

Example build: https://git.hrzg.de/schmunk42/yii2/pipelines/18450/builds

@schmunk42
Copy link
Contributor Author

schmunk42 commented Jan 28, 2017 via email

@samdark
Copy link
Member

samdark commented Jan 28, 2017

Yes, we can. Why not?

@schmunk42
Copy link
Contributor Author

schmunk42 commented Jan 28, 2017 via email

@schmunk42
Copy link
Contributor Author

About composer.lock - https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file

You should update it from time to time and always for a release. A developer who wants to run update can still do so. You also need it for some CI related tasks, here and there.

@@ -1,6 +1,10 @@
<?php
namespace yiiunit\framework\console\controllers;

/**
* @group db
Copy link
Member

Choose a reason for hiding this comment

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

this must be on the class phpdoc, not here.

@dynasource dynasource removed their request for review February 16, 2017 15:06
@schmunk42
Copy link
Contributor Author

@schmunk42
Copy link
Contributor Author

Anything more?

@samdark
Copy link
Member

samdark commented Feb 20, 2017

I think it's OK to merge. @cebe ?

@cebe cebe merged commit 2339e2f into yiisoft:master Mar 6, 2017
@cebe
Copy link
Member

cebe commented Mar 6, 2017

Merged, thank you for this great addition! :)

@schmunk42
Copy link
Contributor Author

You're welcome :)

Auto-pull also works already, see: https://gitlab.com/yiisoft-contrib/yii2/pipelines/6851144
Do these tests also fail in Travis? I need to look that up.

I'll look after the tests from time to time. db, cache and mysql are green AFAIR.

You can push i.e. to tests/pgsql on gitlab.com to trigger the PostgreTest suite.

The "exotic" databases still need some testing of the testing...

@samdark
Copy link
Member

samdark commented Mar 6, 2017

@schmunk42 is there a way to integrate these tests with GitHub? Some failures are about differences in intl/ICU data used. gitlab has newer version. Tests should be adjusted.

@schmunk42
Copy link
Contributor Author

bildschirmfoto 2017-03-06 um 20 40 07

It's set up to sync hourly.

@samdark
Copy link
Member

samdark commented Mar 6, 2017

Yes, I know. I've meant displaying links and results in pull requests etc.

@schmunk42
Copy link
Contributor Author

schmunk42 commented Mar 6, 2017

Hmm, there's a build badge, but further integration is limited AFAIR.
Related: https://gitlab.com/gitlab-org/gitlab-ce/issues/2595

[update]
Asked this question in an issue ... https://gitlab.com/gitlab-org/gitlab-ce/issues/29099

@schmunk42
Copy link
Contributor Author

is there a way to integrate these tests with GitHub? Some failures are about differences in intl/ICU data used. gitlab has newer version. Tests should be adjusted.

@samdark You could run tests also on Travis, but we didn't want to touch the existing Travis setup.
Looks like there's no support for multiple files: travis-ci/travis-ci#3540

Could work with a travis/docker branch though.

@samdark
Copy link
Member

samdark commented Mar 10, 2017

I see. I'd let travis alone as it is. It is sometimes weird but that gives additional cases to fix which is good.

@schmunk42
Copy link
Contributor Author

OK, we'll be able to see these issues better, when we have the base images. Since we then can test multiple versions easily.

CC: @mikehaertl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants