automatisation in development and testing - within budget [ironcamp prague 2016-11]
TRANSCRIPT
AUTOMATIZATIONIN DEVELOPMENT AND QUALITY PROCESS
(WITHIN BUDGET)
David LukacSenior Technical ConsultantInviqa UK Ltd.@davidlukac
David LukacSenior Technical ConsultantInviqa UK Ltd.@davidlukac
http://inviqa.com
BACKGROUND
• Software Engineer @ Siemens• Java Consultant @ T-‐Mobile Austria
• CTO @ Mogdesign.eu• Head of Project Operations @ I-‐KOS Ltd.• Senior Technical Consultant @ Inviqa UK
Questions1. F
2. G/V3. DR/DC4. AQA5. C*
WHY AUTOMATE?
• Saves time• Streamline process
• Efficiency• Quality / Error rate
WHAT IS CI?
• Best practice …• Merging …
• Immediate testing and reporting …• G: Rapid feedback …
• O: Defects identified and corrected ASAP
WHAT IS CD?
• Short cycles …• Releasibility …
• G: Build, test, release …• O: … fast, frequently.
WHY CI/CD?
• Business Critical Functionality• Regression• DRY
• Ease of Mind• Confidence• Trust
BUT HOW?! … WHAT ABOUT THE BUDGET!?
PREPARATION – UNIFIED ENVIRONMENT
• Drush aliases• Local Stack• DevDesktop• DrupalVM / Virtualbox• Docker
PREPARATION – UNIFIED ENVIRONMENT
$ <project root>/drush/mysite.aliases.drushrc.php
<?php$aliases['mysite.local'] = array( .... ); $aliases['mysite.stage'] = array( .... ); $aliases['mysite.uat'] = array( .... ); $aliases['mysite.prod'] = array( .... );
...
$ ln -‐s ${DIR}/mysite.aliases.drushrc.php ~/.drush/mysite.aliases.drushrc.php
Credit: http://joefleming.net/posts/git-‐flow/
LOCAL TASKSSHELL
>_
SHELL SCRIPTS
#!/usr/bin/env bash
# Basic deployment tasks. drush @mysite.${1} cc all drush @mysite.${1} updatedb -‐y drush @mysite.${1} cron
SHELL SCRIPTS
#!/usr/bin/env bash
# Basic deployment tasks. drush @mysite.${1} cc all drush @mysite.${1} updatedb -‐y drush @mysite.${1} cron
# Purge Varnish curl -‐X PURGE -‐H "X-‐Acquia-‐Purge:[mysite.com]”
-‐H "Accept-‐Encoding: gzip" https://mysite.com/about
SHELL SCRIPTS
#!/usr/bin/env bash
# Basic deployment tasks. drush @mysite.${1} cc all drush @mysite.${1} updatedb -‐y drush @mysite.${1} cron
# Purge Varnish curl -‐X PURGE -‐H "X-‐Acquia-‐Purge:[mysite.com]”
-‐H "Accept-‐Encoding: gzip" https://mysite.com/about
# Features # Hidden bonus(?!) drush @mysite.${1} fra -‐y
SHELL SCRIPTS
# Pull everything drush rsync ${source}:%files/ ${target}:%files/ -‐-‐mode=ahkvz -‐-‐progress -‐y drush sql-‐sync ${source} ${target} –y
SHELL SCRIPTS
# Pull everything drush rsync ${source}:%files/ ${target}:%files/ -‐-‐mode=ahkvz -‐-‐progress -‐y drush sql-‐sync ${source} ${target} –y
# Tests bin/behat features/
SHELL SCRIPTS
# Pull everything drush rsync ${source}:%files/ ${target}:%files/ -‐-‐mode=ahkvz -‐-‐progress -‐y drush sql-‐sync ${source} ${target} –y
# Tests bin/behat features/
# Migration drush @mysite.${1} en menu_migrate -‐y drush @mysite.${1} mi Menu -‐-‐feedback="100 items"
SHELL SCRIPTS
# Pull everything drush rsync ${source}:%files/ ${target}:%files/ -‐-‐mode=ahkvz -‐-‐progress -‐y drush sql-‐sync ${source} ${target} –y
# Tests bin/behat features/
# Migration drush @mysite.${1} en menu_migrate -‐y drush @mysite.${1} mi Menu -‐-‐feedback="100 items”
# Solrdrush @mysite.${1} solr-‐delete-‐index drush @mysite.${1} solr-‐index
DEPLOYMENT SHELL SCRIPTS
#!/usr/bin/env bash
# Deployment script drush @mysite.$1 fr feature_article -‐y drush @mysite.$1 vset my_custom_var 1
DEPLOYMENT SHELL SCRIPTS
#!/usr/bin/env bash
# Deployment script drush @mysite.$1 fr feature_article -‐y drush @mysite.$1 vset my_custom_var 1
drush @mysite.$1 cc css-‐jsdrush @mysite.$1 cron
OTHER
• Environment setup• Dependency management – npm, bundle, compose
• Assets – gulp• Changelog, release notes
• Toggle modules
REMOTE DEPLOYMENT
Laravel Envoy (PHP)
• Server side (too)
• SSH
• Easy to setup
• Servers• Tasks
• Macros
• Setup
Envoy.blade.php-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐@servers(['s1' => '[email protected] -‐p 12345'])
@setup $now = new DateTime(); $environment = isset($env) ? $env : "testing";
@endsetup
@task('deploy-‐prod', ['on' => 's1']) cd /var/www; echo {{ $now }}; echo {{ $environment }} git checkout master; git pull drush @mysite.prod updbdrush @mysite.prod cc all drush @mysite.prod cron
@endtask
@macro('deploy') deploy-‐prod clean-‐up
@endmacro
$ envoy run deploy-‐prod
REMOTE DEPLOYMENT
Laravel Envoy (PHP)
• Server side (too)
• SSH
• Easy to setup
• Servers• Tasks
• Macros
• Setup
Fabric (Python)
• Server side (too)
• SSH
• Easy to setup• Inventory
• Tasks
• Parallel execution
• Strength of Python ecosystem
Fabfile.py-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐from fabric.api import run, local, cd, env, taskimport ConfigParserimport os
env.hosts = [’devops@tergetserver’]
@task()def deploy():
local("git fetch")local("git checkout master")local("git pull")local("git push {r} HEAD".format(r=git_remote_name))prod_dir = ’/var/www/project’with cd(prod_dir):
run("git fetch")run("git checkout master")run("git pull")run("composer install -‐-‐no-‐dev -‐-‐no-‐progress -‐-‐no-‐suggest
-‐-‐optimize-‐autoloader -‐-‐no-‐interaction")
REMOTE DEPLOYMENT
Others
• Laravel Envoy (PHP)
• Rocketeer (PHP)
• Fabric (Python)
• Invoke (Python)• Ansible (YAML, Python)
• Capistrano (Ruby)
CI/CD CLOUD TOOLS
Credit: http://galilsoftware.com/our-‐2015-‐ci-‐survey-‐the-‐results/
CI/CD CLOUD TOOLS
Credit: http://galilsoftware.com/our-‐2015-‐ci-‐survey-‐the-‐results/
GITHUB.COM/RIPIENAAR/FREE-‐FOR-‐DEV
QA AUTOMATION
http://inviqa.com
QA AUTOMATION
• TDD• Unit Tests• …• Pricy?• Time consuming?• ROI?
DDD & BDD
BEHAT
• Behavioral testing• Gather and describe business requirements• Test business requirements• User stories• Gherkin
BEHAT
• Behavioral testing• Gather and describe business requirements• Test business requirements• User stories• Gherkin
• Describe and test critical functionality:• Login• Purchase• Editorial• …• Drupal support
Feature: Homepage I want to see a home pageAs a user So I can see the latest featured content on the site.
Background: Given I am not logged in When I visit "/"
Scenario: User can see Main header Then I should see the text "welcome to our site”And I should see the subheading
Scenario: User can see Latest Articles Then I should see 11 latest homepage articles
<?php
class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext{
...
/** * @Then I should see the subheading */
public function iShouldSeeSubHeading() { $this-‐>countElements('.taxonomy-‐term.vocabulary-‐sections
.field-‐name-‐field-‐body .field-‐item', 1, 'Homepage subheading'); }
...
GHOST INSPECTOR
• Automated UI testing• Automated monitoring• Screenshots• Comparison• Browser actions, forms
GHOST INSPECTOR
• Automated UI testing• Automated monitoring• Screenshots• Comparison• Browser actions, forms
• Step by Step• Selectors• Recorder• API
RECAP
• Effectiveness & Quality• Confidence & Trust• Unified environment• Automated tasks• Automated QA
• Time for coffee + $$$
THANK YOU!
QUESTIONS?