Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Automatisation in development and testing - wit...

Automatisation in development and testing - within budget [IronCamp Prague 2016-11]

Working on client projects with very strict budget and resource restrictions, tight deadlines and pressure, many times does not allow for full blown Test Driven Development, Continuous Delivery and other software engineering goodness we would love to have. We will show you easily accessible and quickly implementable options, that allow you to automate your development and testing process, or at least the most painful parts, without blowing the budget. Finally you can relax during deployments of the code to production! :-)

Avatar for David Lukac

David Lukac

November 25, 2016

More Decks by David Lukac

Other Decks in Programming

Transcript

  1. AUTOMATIZATION IN  DEVELOPMENT  AND  QUALITY  PROCESS (WITHIN  BUDGET) David  Lukac

    Senior  Technical  Consultant Inviqa UK  Ltd. @davidlukac
  2. BACKGROUND • Software  Engineer  @  Siemens • Java  Consultant  @

     T-­‐Mobile  Austria • CTO  @  Mogdesign.eu • Head  of  Project  Operations  @  I-­‐KOS  Ltd. • Senior  Technical  Consultant  @  Inviqa UK
  3. WHAT  IS  CI? • Best  practice  … • Merging  …

    • Immediate  testing  and  reporting  … • G:  Rapid  feedback  … • O:  Defects  identified  and  corrected  ASAP
  4. WHAT  IS  CD? • Short  cycles  … • Releasibility …

    • G:  Build,  test,  release  … • O:  …  fast,  frequently.
  5. PREPARATION  – UNIFIED  ENVIRONMENT • Drush aliases • Local  Stack

    • DevDesktop • DrupalVM /  Virtualbox • Docker
  6. 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
  7. SHELL  SCRIPTS #!/usr/bin/env bash   #  Basic  deployment  tasks.  

    drush @mysite.${1}  cc  all   drush @mysite.${1}  updatedb -­‐y   drush @mysite.${1}  cron
  8. 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
  9. 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
  10. SHELL  SCRIPTS #  Pull  everything   drush rsync ${source}:%files/  ${target}:%files/

     -­‐-­‐mode=ahkvz -­‐-­‐progress  -­‐y   drush sql-­‐sync  ${source}  ${target}  –y
  11. SHELL  SCRIPTS #  Pull  everything   drush rsync ${source}:%files/  ${target}:%files/

     -­‐-­‐mode=ahkvz -­‐-­‐progress  -­‐y   drush sql-­‐sync  ${source}  ${target}  –y #  Tests   bin/behat features/
  12. 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"
  13. 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” #  Solr drush @mysite.${1}  solr-­‐delete-­‐index   drush @mysite.${1}  solr-­‐index
  14. DEPLOYMENT  SHELL  SCRIPTS #!/usr/bin/env bash   #  Deployment  script  

    drush @mysite.$1  fr feature_article -­‐y   drush @mysite.$1  vset my_custom_var 1
  15. 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-­‐js drush @mysite.$1  cron
  16. OTHER • Environment  setup • Dependency  management  – npm,  bundle,

     compose • Assets  – gulp • Changelog,  release  notes • Toggle  modules
  17. REMOTE  DEPLOYMENT Laravel Envoy  (PHP) • Server  side  (too) •

    SSH • Easy  to  setup • Servers • Tasks • Macros • Setup
  18. 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 updb drush @mysite.prod cc  all   drush @mysite.prod cron @endtask @macro('deploy')   deploy-­‐prod   clean-­‐up @endmacro
  19. 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
  20. Fabfile.py -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐ from  fabric.api import  run,  local,  cd,  env,  task

    import  ConfigParser import  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")
  21. REMOTE  DEPLOYMENT Others • Laravel Envoy  (PHP) • Rocketeer  (PHP)

    • Fabric  (Python) • Invoke  (Python) • Ansible (YAML,  Python) • Capistrano  (Ruby)
  22. QA  AUTOMATION • TDD • Unit  Tests • … •

    Pricy? • Time  consuming? • ROI?
  23. BEHAT • Behavioral  testing • Gather  and  describe   business

     requirements • Test  business  requirements • User  stories • Gherkin
  24. BEHAT • Behavioral  testing • Gather  and  describe   business

     requirements • Test  business  requirements • User  stories • Gherkin • Describe  and  test  critical   functionality: • Login • Purchase • Editorial • … • Drupal  support
  25. Feature:  Homepage   I  want  to  see  a  home  page

    As  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
  26. <?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');   }   ...
  27. GHOST  INSPECTOR • Automated  UI  testing • Automated  monitoring •

    Screenshots • Comparison • Browser  actions,  forms
  28. GHOST  INSPECTOR • Automated  UI  testing • Automated  monitoring •

    Screenshots • Comparison • Browser  actions,  forms • Step  by  Step • Selectors • Recorder • API
  29. RECAP • Effectiveness  &  Quality • Confidence  &  Trust •

    Unified  environment • Automated  tasks • Automated  QA • Time  for  coffee  +  $$$