automatisation in development and testing - within budget
TRANSCRIPT
AutomatisationAutomatisationIn Development and Quality Process
(Within budget)
David LukacSenior Technical Consultant@ Inviqa Ltd. UK
@davidlukachttps://legacy.joind.in/18271
1
2 . 1
2 . 2
2 . 3
https://inviqa.com
3 . 1
Software Engineer @ SiemensSoftware Engineer @ Siemens
Java Consultant @ T-Mobile AustriaJava Consultant @ T-Mobile Austria
CTO @ Mogdesign.euCTO @ Mogdesign.eu
Head of Project Operations @ iKOS Ltd.Head of Project Operations @ iKOS Ltd.
Senior Technical Consultant @ InviqaSenior Technical Consultant @ Inviqa
3 . 2
3 . 3
QuestionsQuestions1. F2. G/V3. DR/DC4. AQA5. C*
4 . 1
4 . 2
Why automate?Why automate?Saves timeStreamline the processEfficiencyQuality / Error rate
5 . 1
5 . 2
Why CI/CD?Why CI/CD?
6 . 1
Why CI/CD?Why CI/CD?What?
MergingImmediate testing & reportingG: Feedback ...... Defects identified and corrected ASAP
6 . 2
Why CI/CD?Why CI/CD?What?
Short cyclesReleasebilityG: Build, test, release ...... fast, frequently
6 . 3
Why CI/CD?Why CI/CD?Business critical functionalityRegressionDRYEase of mindConfidenceTrust
6 . 4
But how!? ... budget?!But how!? ... budget?!
Credit: http://www.dailymail.co.uk/news/article-2103067/Duck-cover--Astonishing-video-shows-U-S-ground-grunt-guinea-pigs-taking-atomic-
bomb-tests-1950s--trenches-protect-radiation.html
7 . 1
Preparation:Preparation:
Unified environmentUnified environmentDrush aliases
7 . 2
Preparation:Preparation:
Unified environmentUnified environmentDrush aliases
$ <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 . 3
Preparation:Preparation:
Unified environmentUnified environmentDrush aliasesStack
DevDesktop
7 . 4
Preparation:Preparation:
Unified environmentUnified environmentDrush aliasesStack
DevDesktopDrupal-VM
7 . 5
Preparation:Preparation:
Unified environmentUnified environmentDrush aliasesStack
DevDesktopDrupal-VMDocker (Drude)
7 . 6
Credit: http://joefleming.net/posts/git-flow/
7 . 7
Local tasksLocal tasksShellShell
>_>_
8 . 1
Shell scriptsShell scripts#!/usr/bin/env bash
# Basic deployment tasks.drush @mysite.${1} cc alldrush @mysite.${1} updatedb -ydrush @mysite.${1} cron
8 . 2
Shell scriptsShell scripts#!/usr/bin/env bash
# Basic deployment tasks.drush @mysite.${1} cc alldrush @mysite.${1} updatedb -ydrush @mysite.${1} cron
# Purge Varnishcurl -X PURGE -H "X-Acquia-Purge:[mysite.com]" -H "Accept-Encoding: gzip" https://mysite.com/about
8 . 3
Shell scriptsShell scripts#!/usr/bin/env bash
# Basic deployment tasks.drush @mysite.${1} cc alldrush @mysite.${1} updatedb -ydrush @mysite.${1} cron
# Purge Varnishcurl -X PURGE -H "X-Acquia-Purge:[mysite.com]" -H "Accept-Encoding: gzip" https://mysite.com/about
# Features# Hidden bonus(?!)drush @mysite.${1} fra -y
8 . 4
Shell scriptsShell scripts#!/usr/bin/env bash
# Basic deployment tasks.drush @mysite.${1} cc alldrush @mysite.${1} updatedb -ydrush @mysite.${1} cron
# Purge Varnishcurl -X PURGE -H "X-Acquia-Purge:[mysite.com]" -H "Accept-Encoding: gzip" https://mysite.com/about
# Features# Hidden bonus(?!)drush @mysite.${1} fra -y
# Pull everythingdrush rsync ${source}:%files/ ${target}:%files/ --mode=ahkvz --progress -ydrush sql-sync ${source} ${target} -y
8 . 5
Shell scriptsShell scripts#!/usr/bin/env bash
# Basic deployment tasks.drush @mysite.${1} cc alldrush @mysite.${1} updatedb -ydrush @mysite.${1} cron
# Purge Varnishcurl -X PURGE -H "X-Acquia-Purge:[mysite.com]" -H "Accept-Encoding: gzip" https://mysite.com/about
# Features# Hidden bonus(?!)drush @mysite.${1} fra -y
# Pull everythingdrush rsync ${source}:%files/ ${target}:%files/ --mode=ahkvz --progress -ydrush sql-sync ${source} ${target} -y
# Testscd behatbin/behat features/
8 . 6
Shell scriptsShell scripts#!/usr/bin/env bash
# Migrationdrush @mysite.${1} en menu_migrate -ydrush @mysite.${1} mi Menu --feedback="100 items"
8 . 7
Shell scriptsShell scripts#!/usr/bin/env bash
# Migrationdrush @mysite.${1} en menu_migrate -ydrush @mysite.${1} mi Menu --feedback="100 items"
# Solrdrush @mysite.${1} solr-delete-indexdrush @mysite.${1} solr-index
8 . 8
Shell scriptsShell scripts#!/usr/bin/env bash
# Deployment script
drush @mysite.$1 fr feature_article -ydrush @mysite.$1 vset my_custom_var 1
8 . 9
Shell scriptsShell scripts#!/usr/bin/env bash
# Deployment script
drush @mysite.$1 fr feature_article -ydrush @mysite.$1 vset my_custom_var 1
drush @mysite.$1 cc css-jsdrush @mysite.$1 cron
8 . 10
OtherOtherEnv. setupDep. managementnpm, bundleToggleChangelogBuild
8 . 11
Local tasksLocal tasksGulpGulp
9 . 1
Gulp tasksGulp taskswatchcompilecopyserve
9 . 2
10
Laravel EnvoyLaravel EnvoyServer side, sshShell
11 . 1
Laravel EnvoyLaravel EnvoyServer side, sshShell
Easy to setupWorks with WebSupport
$ composer global require "laravel/envoy=~1.0"
$ envoy init [email protected]
11 . 2
Laravel EnvoyLaravel EnvoyServer side, sshShellVariablesServersTasksMacrosSetup
11 . 3
EnvoyEnvoyEnvoy.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 }}
drush @mysite.prod sql-dump --result-file --gzip
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
11 . 4
EnvoyEnvoyEnvoy.blade.php---------------
@servers(['s1' => '[email protected] -p 12345'])
@task('deploy-prod', ['on' => 's1']) cd /var/www
drush @mysite.prod sql-dump --result-file --gzip
git checkout master git pull
drush @mysite.prod updb drush @mysite.prod cc all drush @mysite.prod cron@endtask
...
$ envoy run deploy-prod
11 . 5
CapistranoCapistrano
12 . 1
CapistranoCapistranoRemote serverRubyRole, tasks, stages ...
12 . 2
ToolsTools
Credit: http://galilsoftware.com/our-2015-ci-survey-the-results/
13 . 1
ToolsTools
Credit: http://galilsoftware.com/our-2015-ci-survey-the-results/
github.com/ripienaar/free-for-devgithub.com/ripienaar/free-for-dev
13 . 2
QA AutomationQA Automation
14 . 1
14 . 2
QA AutomationQA AutomationTTDUnit Tests...
14 . 3
QA AutomationQA AutomationTTDUnit Tests...pricy?time consuming?ROI?
14 . 4
14 . 5
15 . 1
BehatBehatBehavioural testingGather & test requirementsUser storiesGherkin
15 . 2
BehatBehatBehavioural testingGather & test requirementsUser storiesGherkinCritical functionality
LoginPurchasePost...
15 . 3
BehatBehatBehavioural testingGather & test requirementsUser storiesGherkinDrupal support
15 . 4
BehatBehatdefault: suites: default: contexts: - FeatureContext - Drupal\DrupalExtension\Context\DrupalContext - Drupal\DrupalExtension\Context\MessageContext extensions: Behat\MinkExtension: selenium2: ~ base_url: http://mysite.local Drupal\DrupalExtension: blackbox: ~ api_driver: 'drupal' drupal: drupal_root: '/var/www' text: log_out: "Log out" log_in: "Log in" password_field: "Password" username_field: "Username" selectors: message_selector: '.messages' error_message_selector: '.messages.error' success_message_selector: '.messages.status' warning_message_selector: '.messages.warning' region_map: header_search: ".search-toggle"
15 . 5
BehatBehatDrupalContextcustom context
<?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'); }
...
15 . 6
BehatBehat
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
15 . 7
BehatBehat
Scenario: User can add the content administration Given I am logged in as a user with the "Content Editor" role When I go to "node/add/article" Then I should not see "Page not found" When I fill in "title" with "Behat testing article" And I fill in "media[field_listing_image_und_0]" with "314631" And I press the 'edit-submit' button Then I should see the following success messages: | success messages | | Article Behat testing article has been created. | And I should be able to register my article with title "Behat testing article" for cleanup
15 . 8
BehatBehat
Credit: http://erikaybar.name/building-and-testing-a-restful-api-using-behat-phpunit-and-laravel-part-1/
15 . 9
Ghost InspectorGhost Inspector
16 . 1
Ghost InspectorGhost InspectorAutomated UI testingAutomated UI monitoring
16 . 2
Ghost InspectorGhost InspectorAutomated UI testingAutomated monitoringScreenshotsComparison
16 . 3
Ghost InspectorGhost Inspector
16 . 4
Ghost InspectorGhost Inspector
Credit: http://www.hung-truong.com/blog/
16 . 5
Ghost InspectorGhost InspectorAutomated UI testingAutomated monitoringScreenshotsComparisonStep-by-stepSelectorsRecorderAPI
16 . 6
Ghost InspectorGhost Inspector
Credit: http://www.hung-truong.com/blog/
16 . 7
Ghost InspectorGhost InspectorAPI
$ curl https://api.ghostinspector.com/v1/ suites/jabsdf7283947298374sdf/execute/ ?apiKey=aodjshfas72834970128347ijshdfg
16 . 8
Ghost InspectorGhost Inspector
16 . 9
Effectiveness + QualityConfidence + TrustUnified environmentAutomated TasksAutomated QATime for coffee + $$$
RecapRecap
17
Q & DQ & D
https://legacy.joind.in/18271 @davidlukac18