Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
Continuous Integration/
Continuous Delivery веб-приложения
Evgeniy Kuzmin, CTO Smart Gamma
Agile attributes
- Continuous integration with codebase
- Development with autotests
- Continuous feedback
- Bugfix first
...
Goal
Use CI/CD not only for big
teams
Initial Conditions
- workstationhealth.com
- Laravel framework
- 3 in house devs
- A...
CI/CD Journey
Trunc-based flow - “pure” CI
Feature / task branching GIT flow
Is this CI?
- small team
- short-lived branches
- force integration with develop in the
...
Force developers for faster integration
Docker local development
docker-compose.yml
docker-compose-local.yml
https://gist.github.com/Evgenas/c6da523eb2462d848d93505ef
603208b
$ docker-compose -f docker-compose.yml -f docker-compose...
Auto-testing
“Одним только тестированием качества не
добиться. Рецепт получения высокого качества:
смешивайте разработку и тестирование...
100% покрытие vs избирательное
тестирование
Модульные тесты (лёгкие)
dependencies
amount
Algorithmic
complexity
Mediators
...
Функциональные тесты (средние)
Attributes
Database connection
Request modeling
Response assertion
Database assertion
Goals...
Testing code coverage
phpdbg – allows get test code coverage faster then
xdebug
find tests/ -name '*Test.php' |
./vendor/l...
Etalon Datas
Data loading variation:
- Inline in each test
- Preload before suite
Laravel:
- Seeds / factories
- Organize ...
Domain Data Builders
Transactions in phpunit
Restore DB to the initial state after each test is completed
How to get faster feedback?
Goal-keep Limits:
- 5 mins for unit/functional tests
- 20 mins for UI tests
Benchmark for 1 th...
Multithreading tests
Tool:
Fastest - https://github.com/liuggio/fastest
find tests/ -name '*Test.php' |
./vendor/liuggio/f...
Seeds reload optimization
Optimization result
5 minutes 52 seconds vs 59 seconds
Phing - build automation tool
Goal: One step build
Tool: https://www.phing.info/
Sample: https://gist.github.com/Evgenas/9...
Jenkins
Trigger light tests suite build (ergoblitz-build-minimal)
BitBucket Plugin: https://plugins.jenkins.io/bitbucket
Bitbucket...
Phing Plugin:
https://plugins.jenkins.io/phing
Tests feedback notifications
Slack Notification Plugin: https://plugins.jenkins.io/slack
Trigger next level tests
Parameterized Trigger Plugin:
https://plugins.jenkins.io/parameterized-trigger
UI/User Stories testing automation - end2end tests
Behat - what is inside?
BDD or not BDD?
Jenkins behat job config
Run upstream behat job from build-ci-minimal job
Jenkins behat job config
Clean up end2end. environment
Reseed / redeploy before testing
Run tests with fastest for multithreading
Success result
Trace failed tests
Linked screenshot
Jira releases
Jenkins prepare release job
How to stick Jenkins build to Jira release
Jira Plugin: https://plugins.jenkins.io/jira
Merge develop to master
Prepare docker images for production
Amazon ECR
Jenkins Docker build
DockerCommon Plugin:
https://plugins.jenkins.io/docker-commons
CloudBees Docker Build and Publish Plu...
Preproduction
deployment
Amazon Elastic Beanstalk
Multicontainer Docker Environment
Beanstalk Environments
Blue/Green deploy
BlueGreen
deploy settings
AWS Elastic Beanstalk Plugin: https://plugins.jenkins.io/awseb-deployment-plugin
How to connect Jenkins and AWS Beanstalk
AWS Beanstalk configuration files
App deployment: /Dockerrun.aws.json
DB Migrations: ./ebextensions/my-scripts.config
Cron...
Dockerrun.aws.json
Cronjob setup on deploy
Run migration on deploy
Blue-Green Deployment execution
Migrations rules for blue-green deployments
https://wiki.openstack.org/wiki/DBMigrationBestPractices
Additional preproduction auto-testing with BrowserStack
Deploy to production
Production / preproduction errors monitoring with Slack
evgeniy.k@smart-gamma.com
https://www.linkedin.com/in/evgeniy-kuzmin-03816a52/
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Nächste SlideShare
Wird geladen in …5
×

Continuous Integration/ Continuous Delivery of web applications

102 Aufrufe

Veröffentlicht am

Smart Gamma use case of implementation Continuous Integration/ Continuous Delivery for Laravel web app, tested by phpunit and Behat, build automation with Jenkins, blue-green deploy on AWS Beanstalk

Veröffentlicht in: Technologie

Continuous Integration/ Continuous Delivery of web applications

  1. 1. Continuous Integration/ Continuous Delivery веб-приложения Evgeniy Kuzmin, CTO Smart Gamma
  2. 2. Agile attributes - Continuous integration with codebase - Development with autotests - Continuous feedback - Bugfix first - Feature planning & releases Goals - Increase development speed - Increase product quality - Decrease risk - Improve feedback - Increase time-to-market
  3. 3. Goal Use CI/CD not only for big teams Initial Conditions - workstationhealth.com - Laravel framework - 3 in house devs - AWS - Jira - bitbucket - QA/DevOps consulting
  4. 4. CI/CD Journey
  5. 5. Trunc-based flow - “pure” CI
  6. 6. Feature / task branching GIT flow Is this CI? - small team - short-lived branches - force integration with develop in the task branch “in-progress” state Requirements
  7. 7. Force developers for faster integration
  8. 8. Docker local development
  9. 9. docker-compose.yml
  10. 10. docker-compose-local.yml
  11. 11. https://gist.github.com/Evgenas/c6da523eb2462d848d93505ef 603208b $ docker-compose -f docker-compose.yml -f docker-compose.local.yml up Or use Makefile $ make up
  12. 12. Auto-testing
  13. 13. “Одним только тестированием качества не добиться. Рецепт получения высокого качества: смешивайте разработку и тестирование в блендере, пока они не станут единой субстанцией.” “Вся ответственность за качество лежит на плечах тех, кто пишет код. Разработчик отвечает за качество всего кода, к которому он прикасается: пишет, исправляет или вносит изменения.” Роли: разработчик, разработчик в тестировании, инженер по тестированию Типы тестов: лёгкие, средние, долгие, супердолгие
  14. 14. 100% покрытие vs избирательное тестирование Модульные тесты (лёгкие) dependencies amount Algorithmic complexity Mediators бизнес-логика Простой код без зависимостей God Object / Spaghetti
  15. 15. Функциональные тесты (средние) Attributes Database connection Request modeling Response assertion Database assertion Goals API layer stability Business logic Testing code coverage (over unit testing coverage) Laravel pros Easy HOW TO START documentation Phpunit wrapper Transaction support “from the box”
  16. 16. Testing code coverage phpdbg – allows get test code coverage faster then xdebug find tests/ -name '*Test.php' | ./vendor/liuggio/fastest/fastest -o -p 4 -x phpunit.xml 'phpdbg -qrr ./vendor/phpunit/phpunit/phpunit {} -- coverage-php ./tests/_reports/logs/{n}.cov;' phpcov – allows merge test coverage from threads phpdbg -qrr ./vendor/bin/phpcov merge tests/_reports/logs/ --clover tests/_reports/logs/clover.xml
  17. 17. Etalon Datas Data loading variation: - Inline in each test - Preload before suite Laravel: - Seeds / factories - Organize domain data builders - Transactions
  18. 18. Domain Data Builders
  19. 19. Transactions in phpunit Restore DB to the initial state after each test is completed
  20. 20. How to get faster feedback? Goal-keep Limits: - 5 mins for unit/functional tests - 20 mins for UI tests Benchmark for 1 thread Tests: 632, Assertions: 6765: 5 minutes 21 seconds Optimizations: - tests multithreading execution - seeds reload optimization - selective build code coverage (only in development branch)
  21. 21. Multithreading tests Tool: Fastest - https://github.com/liuggio/fastest find tests/ -name '*Test.php' | ./vendor/liuggio/fastest/fastest -o -p 4 -x phpunit.xml 'phpdbg -qrr ./vendor/phpunit/phpunit/phpunit {} --coverage-php ./tests/_reports/logs/{n}.cov;'
  22. 22. Seeds reload optimization
  23. 23. Optimization result 5 minutes 52 seconds vs 59 seconds
  24. 24. Phing - build automation tool Goal: One step build Tool: https://www.phing.info/ Sample: https://gist.github.com/Evgenas/97fc0bfb
  25. 25. Jenkins
  26. 26. Trigger light tests suite build (ergoblitz-build-minimal) BitBucket Plugin: https://plugins.jenkins.io/bitbucket Bitbucket Pullrequest Builder: https://plugins.jenkins.io/bitbucket-pullrequest-builder
  27. 27. Phing Plugin: https://plugins.jenkins.io/phing
  28. 28. Tests feedback notifications Slack Notification Plugin: https://plugins.jenkins.io/slack
  29. 29. Trigger next level tests Parameterized Trigger Plugin: https://plugins.jenkins.io/parameterized-trigger
  30. 30. UI/User Stories testing automation - end2end tests
  31. 31. Behat - what is inside? BDD or not BDD?
  32. 32. Jenkins behat job config
  33. 33. Run upstream behat job from build-ci-minimal job
  34. 34. Jenkins behat job config
  35. 35. Clean up end2end. environment
  36. 36. Reseed / redeploy before testing
  37. 37. Run tests with fastest for multithreading
  38. 38. Success result
  39. 39. Trace failed tests
  40. 40. Linked screenshot
  41. 41. Jira releases
  42. 42. Jenkins prepare release job
  43. 43. How to stick Jenkins build to Jira release Jira Plugin: https://plugins.jenkins.io/jira
  44. 44. Merge develop to master
  45. 45. Prepare docker images for production
  46. 46. Amazon ECR
  47. 47. Jenkins Docker build DockerCommon Plugin: https://plugins.jenkins.io/docker-commons CloudBees Docker Build and Publish Plugin: https://plugins.jenkins.io/docker-build-publish Amazon ECR Plugin: https://plugins.jenkins.io/amazon-ecr
  48. 48. Preproduction deployment
  49. 49. Amazon Elastic Beanstalk Multicontainer Docker Environment
  50. 50. Beanstalk Environments
  51. 51. Blue/Green deploy
  52. 52. BlueGreen deploy settings
  53. 53. AWS Elastic Beanstalk Plugin: https://plugins.jenkins.io/awseb-deployment-plugin How to connect Jenkins and AWS Beanstalk
  54. 54. AWS Beanstalk configuration files App deployment: /Dockerrun.aws.json DB Migrations: ./ebextensions/my-scripts.config Cron: ./ebextensions/cronjob.config https://gist.github.com/Evgenas/8bdf43a1
  55. 55. Dockerrun.aws.json
  56. 56. Cronjob setup on deploy
  57. 57. Run migration on deploy
  58. 58. Blue-Green Deployment execution
  59. 59. Migrations rules for blue-green deployments https://wiki.openstack.org/wiki/DBMigrationBestPractices
  60. 60. Additional preproduction auto-testing with BrowserStack
  61. 61. Deploy to production
  62. 62. Production / preproduction errors monitoring with Slack
  63. 63. evgeniy.k@smart-gamma.com https://www.linkedin.com/in/evgeniy-kuzmin-03816a52/

×