automatisation in development and testing - within budget [ironcamp prague 2016-11]

54
AUTOMATIZATION IN DEVELOPMENT AND QUALITY PROCESS (WITHIN BUDGET) David Lukac Senior Technical Consultant Inviqa UK Ltd. @davidlukac

Upload: david-lukac

Post on 18-Feb-2017

61 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

AUTOMATIZATIONIN  DEVELOPMENT  AND  QUALITY  PROCESS

(WITHIN  BUDGET)

David  LukacSenior  Technical  ConsultantInviqa UK  Ltd.@davidlukac

Page 2: Automatisation in development and testing - within budget [IronCamp prague 2016-11]
Page 3: Automatisation in development and testing - within budget [IronCamp prague 2016-11]
Page 4: Automatisation in development and testing - within budget [IronCamp prague 2016-11]
Page 5: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

David  LukacSenior  Technical  ConsultantInviqa UK  Ltd.@davidlukac

Page 6: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

http://inviqa.com

Page 7: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

BACKGROUND

• Software  Engineer  @  Siemens• Java  Consultant  @  T-­‐Mobile  Austria

• CTO  @  Mogdesign.eu• Head  of  Project  Operations  @  I-­‐KOS  Ltd.• Senior  Technical  Consultant  @  Inviqa UK

Page 8: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

Questions1. F

2. G/V3. DR/DC4. AQA5. C*

Page 9: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

WHY  AUTOMATE?

• Saves  time• Streamline  process

• Efficiency• Quality  /  Error  rate

Page 10: Automatisation in development and testing - within budget [IronCamp prague 2016-11]
Page 11: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

WHAT  IS  CI?

• Best  practice  …• Merging  …

• Immediate  testing  and  reporting  …• G:  Rapid  feedback  …

• O:  Defects  identified  and  corrected  ASAP

Page 12: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

WHAT  IS  CD?

• Short  cycles  …• Releasibility …

• G:  Build,  test,  release  …• O:  …  fast,  frequently.

Page 13: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

WHY  CI/CD?

• Business  Critical  Functionality• Regression• DRY

• Ease  of  Mind• Confidence• Trust

Page 14: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

BUT  HOW?!  …  WHAT  ABOUT  THE  BUDGET!?

Page 15: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

PREPARATION  – UNIFIED  ENVIRONMENT

• Drush aliases• Local  Stack• DevDesktop• DrupalVM /  Virtualbox• Docker

Page 16: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

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

Page 17: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

Credit: http://joefleming.net/posts/git-­‐flow/

Page 18: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

LOCAL  TASKSSHELL

>_

Page 19: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

SHELL  SCRIPTS

#!/usr/bin/env bash  

#  Basic  deployment  tasks.  drush @mysite.${1}  cc  all  drush @mysite.${1}  updatedb -­‐y  drush @mysite.${1}  cron

Page 20: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

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

Page 21: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

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

Page 22: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

SHELL  SCRIPTS

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

Page 23: Automatisation in development and testing - within budget [IronCamp prague 2016-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/

Page 24: Automatisation in development and testing - within budget [IronCamp prague 2016-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/

#  Migration  drush @mysite.${1}  en menu_migrate -­‐y  drush @mysite.${1}  mi  Menu  -­‐-­‐feedback="100  items"

Page 25: Automatisation in development and testing - within budget [IronCamp prague 2016-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/

#  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

Page 26: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

DEPLOYMENT  SHELL  SCRIPTS

#!/usr/bin/env bash  

#  Deployment  script  drush @mysite.$1  fr feature_article -­‐y  drush @mysite.$1  vset my_custom_var 1

Page 27: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

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

Page 28: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

OTHER

• Environment  setup• Dependency  management  – npm,  bundle,  compose

• Assets  – gulp• Changelog,  release  notes

• Toggle  modules

Page 29: Automatisation in development and testing - within budget [IronCamp prague 2016-11]
Page 30: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

REMOTE  DEPLOYMENT

Laravel Envoy  (PHP)

• Server  side  (too)

• SSH

• Easy  to  setup

• Servers• Tasks

• Macros

• Setup

Page 31: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

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

Page 32: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

$  envoy  run  deploy-­‐prod

Page 33: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

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

Page 34: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

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")

Page 35: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

REMOTE  DEPLOYMENT

Others

• Laravel Envoy  (PHP)

• Rocketeer  (PHP)

• Fabric  (Python)

• Invoke  (Python)• Ansible (YAML,  Python)

• Capistrano  (Ruby)

Page 36: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

CI/CD  CLOUD  TOOLS

Credit:  http://galilsoftware.com/our-­‐2015-­‐ci-­‐survey-­‐the-­‐results/

Page 37: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

CI/CD  CLOUD  TOOLS

Credit:  http://galilsoftware.com/our-­‐2015-­‐ci-­‐survey-­‐the-­‐results/

GITHUB.COM/RIPIENAAR/FREE-­‐FOR-­‐DEV

Page 38: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

QA  AUTOMATION

Page 39: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

http://inviqa.com

Page 40: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

QA  AUTOMATION

• TDD• Unit  Tests• …• Pricy?• Time  consuming?• ROI?

Page 41: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

DDD  &  BDD

Page 42: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

BEHAT

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

Page 43: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

BEHAT

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

• Describe  and  test  critical  functionality:• Login• Purchase• Editorial• …• Drupal  support

Page 44: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

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

Page 45: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

<?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');  }  

...

Page 46: Automatisation in development and testing - within budget [IronCamp prague 2016-11]
Page 47: Automatisation in development and testing - within budget [IronCamp prague 2016-11]
Page 48: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

GHOST  INSPECTOR

• Automated  UI  testing• Automated  monitoring• Screenshots• Comparison• Browser  actions,  forms

Page 49: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

GHOST  INSPECTOR

• Automated  UI  testing• Automated  monitoring• Screenshots• Comparison• Browser  actions,  forms

• Step  by  Step• Selectors• Recorder• API

Page 50: Automatisation in development and testing - within budget [IronCamp prague 2016-11]
Page 51: Automatisation in development and testing - within budget [IronCamp prague 2016-11]
Page 52: Automatisation in development and testing - within budget [IronCamp prague 2016-11]
Page 53: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

RECAP

• Effectiveness  &  Quality• Confidence  &  Trust• Unified  environment• Automated  tasks• Automated  QA

• Time  for  coffee  +  $$$

Page 54: Automatisation in development and testing - within budget [IronCamp prague 2016-11]

THANK  YOU!

QUESTIONS?