agile bodensee - testautomation & continuous delivery workshop

94
AGILE BODENSEE 2014 TEST AUTOMATION & CONTINUOUS INTEGRATION WORKSHOP Konstanz 01.10.2014 1

Upload: michael-palotas

Post on 05-Dec-2014

284 views

Category:

Software


2 download

DESCRIPTION

Workshop Test Automation & Continuous Integration & Delivery at Agile Bodensee, Oct 2014, Konstanz Germany

TRANSCRIPT

Page 1: Agile Bodensee - Testautomation & Continuous Delivery Workshop

AGILE BODENSEE 2014 TEST AUTOMATION & CONTINUOUS INTEGRATION WORKSHOP

Konstanz 01.10.2014

1

Page 2: Agile Bodensee - Testautomation & Continuous Delivery Workshop

2

WHO AM I? Gridfusion Software Solutions Contact: Michael Palotas Gerbiweg 2 8853 Lachen SWITZERLAND Tel.: +41 79 6690708 Email: [email protected]

Head of Productivity & Test Engineering, eBay

Founder / Principal Consultant Gridfusion Software Solutions

Page 3: Agile Bodensee - Testautomation & Continuous Delivery Workshop

SETTING THE STAGE

Tell me about yourself J

What are your expectations for today?

3

Page 4: Agile Bodensee - Testautomation & Continuous Delivery Workshop

POSSIBLE AGENDA TOPICS

Introduction

CI – what is it, why do we use it, what are we trying to achieve

Automation / Code Quality

Tools

Unit tests

Cobertura

Sonar

E2E Tests

Selenium

Cucumber

Amazon cloud

Pipeline

Integrating mobile

Vagrant - Infrastructure as code

Management / organizational aspect

4

Page 5: Agile Bodensee - Testautomation & Continuous Delivery Workshop

Your setup

How do you build software?

5

Page 6: Agile Bodensee - Testautomation & Continuous Delivery Workshop

WHAT IS SO SPECIAL ABOUT AGILE?

6

Page 7: Agile Bodensee - Testautomation & Continuous Delivery Workshop

WHY CI/CD?

7

Page 8: Agile Bodensee - Testautomation & Continuous Delivery Workshop

WHAT IS IMPORTANT IN AGILE?

8

Page 9: Agile Bodensee - Testautomation & Continuous Delivery Workshop

Agile

=?

Release working software anytime

9

Page 10: Agile Bodensee - Testautomation & Continuous Delivery Workshop

Traditional waterfall model / tools do not support “build and deploy anytime”

10

Page 11: Agile Bodensee - Testautomation & Continuous Delivery Workshop

WHAT IS CI / CD?

CI and CD

=

Automated Build?

Automated Tests?

Automated Quality?

Automated Deployment?

Automated Feedback?

11

Page 12: Agile Bodensee - Testautomation & Continuous Delivery Workshop

WHY CI / CD

Deliver value to the business more frequently

Better Quality

Early Bugs

Bug Prevention instead of late detection

Fast & frequent feedback

12

Page 13: Agile Bodensee - Testautomation & Continuous Delivery Workshop

WHY CI / CD

Automated frequent builds

Automated frequent tests

Automated frequent code quality metrics

(Hopefully) Fewer bugs

Early feedback

Fast feedback

13

Page 14: Agile Bodensee - Testautomation & Continuous Delivery Workshop

WITHOUT CI

Slow / long release cycles

Late testing

Waterfall (WaterScrum)

Bugs

Slow feedback

Complex integration

14

Page 15: Agile Bodensee - Testautomation & Continuous Delivery Workshop

CORE PRINCIPLES

Every build could be a release

Everything should be automated

Stable and trustworthy automated tests

Build pipelines

15

Page 16: Agile Bodensee - Testautomation & Continuous Delivery Workshop

RELEASING IN THE OLD WORLD

16

Coding

Deploy to

QA

QA

Deploy to Production

Production Smoke Tests

Bug Bashes

Page 17: Agile Bodensee - Testautomation & Continuous Delivery Workshop

CI / CD - CORE WORKFLOW

17

Compile

Unit Test

Deploy to QA

Acceptance tests

Deploy to Production

Production Smoke Tests

Code Quality

Page 18: Agile Bodensee - Testautomation & Continuous Delivery Workshop

THE MAIN TASKS

Automated build

Automated code quality

Automated testing

Automated deployment

18

Page 19: Agile Bodensee - Testautomation & Continuous Delivery Workshop

19

Wakaleo.com

Page 20: Agile Bodensee - Testautomation & Continuous Delivery Workshop

CAN YOU MEASURE AUTOMATED CODE QUALITY? DOES THAT MAKE SENSE?

20

Page 21: Agile Bodensee - Testautomation & Continuous Delivery Workshop

AUTOMATED CODE QUALITY?

Sonar gives you information on:

-  Lines of code

-  % of comments

-  Duplications

-  Complexity

-  Rules compliance

-  Unit test coverage

-  Unit test success rate

-  Unit test duration

-  Hotspots

21

Page 22: Agile Bodensee - Testautomation & Continuous Delivery Workshop

AUTOMATE EVERYTHING?

22

Page 23: Agile Bodensee - Testautomation & Continuous Delivery Workshop

WHAT SHOULD YOU AUTOMATE?

23

Page 24: Agile Bodensee - Testautomation & Continuous Delivery Workshop

WHAT ARE BARRIERS TO CI / CD?

24

Page 25: Agile Bodensee - Testautomation & Continuous Delivery Workshop

WHAT IS CONTIUOUS INTEGRATION?

25

Continuous integration (CI) is the practice, in software engineering, of merging all developer working copies with a shared mainline several times a day. It was first named and proposed as part of extreme programming (XP). Its main aim is to prevent integration problems, referred to as "integration hell" in early descriptions of XP. CI can be seen as an intensification of practices of periodic integration advocated by earlier published methods of incremental and iterative software development, such as the Booch method. CI isn't universally accepted as an improvement over frequent integration, so it is important to distinguish between the two as there is disagreement about the virtues of each.

Page 26: Agile Bodensee - Testautomation & Continuous Delivery Workshop

WHAT IS CONTINUOUS DELIVERY?

26

Continuous Delivery (CD) is a design practice used in software development to automate and improve the process of software delivery. Techniques such as automated testing, continuous integration and continuous deployment allow software to be developed to a high standard and easily packaged and deployed to test environments, resulting in the ability to rapidly, reliably and repeatedly push out enhancements and bug fixes to customers at low risk and with minimal manual overhead. The technique was one of the assumptions of extreme programming but at an enterprise level has developed into a discipline of its own, with job descriptions for roles such as "buildmaster" calling for CD skills as mandatory.

Page 27: Agile Bodensee - Testautomation & Continuous Delivery Workshop

THE MANAGEMENT / ORGANIZATIONAL ASPECT

What are the changes for developers and testers?

What needs to be changed in the organization to enable them to implement CI / CD?

What role has management in creating a devops culture?

27

Page 28: Agile Bodensee - Testautomation & Continuous Delivery Workshop

OUR TOOLS

Version Control System GIT Build Tool MAVEN Unit Test Framework JUNIT / TESTNG End To End Test Framework SELENIUM Build Server / Deployment JENKINS

28

Page 29: Agile Bodensee - Testautomation & Continuous Delivery Workshop

Branching & Merging

Small and Fast

Distributed

Data Assurance

Staging Area

Free and Open Source

VERSION CONTROL: GIT

29

http://git-scm.com/about/

Page 30: Agile Bodensee - Testautomation & Continuous Delivery Workshop

GIT: BRANCHING & MERGING

30

Git-scm.com

Page 31: Agile Bodensee - Testautomation & Continuous Delivery Workshop

GIT: SMALL & FAST

31

Git-scm.com

Page 32: Agile Bodensee - Testautomation & Continuous Delivery Workshop

GIT: THE REST

Distributed

Data Assurance

Staging Area

Free & Open Source

32

Page 33: Agile Bodensee - Testautomation & Continuous Delivery Workshop

GIT

Distributed / local

Download: http://git-scm.com/

Initialize directory: git init

Status: git status

Add files and directories to git: git add file1 dir2

Commit: git commit –am “commit message”

33

Page 34: Agile Bodensee - Testautomation & Continuous Delivery Workshop

SHARE YOUR CODE - GITHUB

Create repository on Github: https://github.com

Create remote: git remote add origin https://…

Push code to Github: git push origin master

Tag your code: git tag –a v0.1 –m “initial version”

Push tag to Github: git push origin v0.1

34

Page 35: Agile Bodensee - Testautomation & Continuous Delivery Workshop

GITHUB

35

Page 36: Agile Bodensee - Testautomation & Continuous Delivery Workshop

CONNECT GIT AND GITHUB

36

Silverpeas.org

Page 37: Agile Bodensee - Testautomation & Continuous Delivery Workshop

MAVEN

37

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.

http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

Page 38: Agile Bodensee - Testautomation & Continuous Delivery Workshop

POM.XML

The pom.xml file is the core of a project's configuration in Maven. It is a single

configuration file that contains the majority of information required to build a project in just

the way you want.

38

Page 39: Agile Bodensee - Testautomation & Continuous Delivery Workshop

POM.XML

39

Page 40: Agile Bodensee - Testautomation & Continuous Delivery Workshop

MAVEN TARGETS

validate: validate the project is correct and all necessary information is available

compile: compile the source code of the project

test: test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed

package: take the compiled code and package it in its distributable format, such as a JAR.

integration-test: process and deploy the package if necessary into an environment where integration tests can be run

verify: run any checks to verify the package is valid and meets quality criteria

install: install the package into the local repository, for use as a dependency in other projects locally

deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.

clean: cleans up artifacts created by prior builds

40

Page 41: Agile Bodensee - Testautomation & Continuous Delivery Workshop

EXAMPLES

mvn clean

mvn compile

mvn test

41

Page 42: Agile Bodensee - Testautomation & Continuous Delivery Workshop

OUR APPLICATION TODAY

42

Page 43: Agile Bodensee - Testautomation & Continuous Delivery Workshop

APPLICATION STRUCTURE

It is a super complex application …

2 text fields

1 submit button

1 very complex calculation

43

Page 44: Agile Bodensee - Testautomation & Continuous Delivery Workshop

OUR ENTRY PAGE

44

Page 45: Agile Bodensee - Testautomation & Continuous Delivery Workshop

RESULT PAGE

45

Page 46: Agile Bodensee - Testautomation & Continuous Delivery Workshop

CALCULATOR CLASS

46

Page 47: Agile Bodensee - Testautomation & Continuous Delivery Workshop

CALCULATOR TESTS

47

Page 48: Agile Bodensee - Testautomation & Continuous Delivery Workshop

RUN UNIT TESTS

1.  Run in Eclipse

2.  Run via maven

48

Page 49: Agile Bodensee - Testautomation & Continuous Delivery Workshop

COBERTURA

mvn clean cobertura:cobertura –Dgroup=unit

49

TMFSydney2014/target/site/cobertura/index.html

Page 50: Agile Bodensee - Testautomation & Continuous Delivery Workshop

SONAR

50

http://localhost:9000/dashboard/index/net.gridfusion.dobcalc:tmf2

Page 51: Agile Bodensee - Testautomation & Continuous Delivery Workshop

END TO END TESTS (E2E)

Selenium

Selenium Grid

51

Page 52: Agile Bodensee - Testautomation & Continuous Delivery Workshop

TEST AUTOMATION

Unit Tests

E2E Tests

Manual Tests

Integration Tests

Page 53: Agile Bodensee - Testautomation & Continuous Delivery Workshop

WHAT IS SELENIUM?

Selenium automates browsers

that’s it

Page 54: Agile Bodensee - Testautomation & Continuous Delivery Workshop

E2E / UAT AUTOMATION WITH SELENIUM

54

CLIENT

SERVER JSON Wire Protocol

BROWSER

Page 55: Agile Bodensee - Testautomation & Continuous Delivery Workshop

SELENIUM 2 / WEBDRIVER

JSON WIRE PROTOCOL

Client

Java

C#

Ruby

Python

Server

i.e. Selendroid, iOS-Driver

Server

Server

Page 56: Agile Bodensee - Testautomation & Continuous Delivery Workshop

CLIENT

Is seen as „Selenium“ by the users

Generates HTTP requests which are received by the server

Is called by the test framework or the CI server

Supported languages: Java, C#, Python, Ruby, Perl, PHP,

JS

Page 57: Agile Bodensee - Testautomation & Continuous Delivery Workshop

SERVER

Receives HTTP requests

Start and teardown of browser

Translates requests into browser specific commands

Communicates back to the client

Page 58: Agile Bodensee - Testautomation & Continuous Delivery Workshop

SELENIUM GRID

Test 1 Test 2 Test …

Test 4500

Execution Time

Test 3

Parallel Execution

Test Test Test

Execution Time

Test

Test Test Test Test

Test Test Test Test

Par

alle

l Exe

cutio

n

Par

alle

l Exe

cutio

n

Page 59: Agile Bodensee - Testautomation & Continuous Delivery Workshop

SCALING – SELENIUM GRID

CI

DEV

….

SELENIUM GRID HUB

IOS ANDROID

LINUX

WINDOWS

OSX

Page 60: Agile Bodensee - Testautomation & Continuous Delivery Workshop

TEST INFRASTRUCTURE

AUT

DB

API

Browsers Mobiles

CLIENT

Page 61: Agile Bodensee - Testautomation & Continuous Delivery Workshop

A SIMPLE SELENIUM TEST

61

Page 62: Agile Bodensee - Testautomation & Continuous Delivery Workshop

A SIMPLE SELENIUM TEST

62

Page 63: Agile Bodensee - Testautomation & Continuous Delivery Workshop

SELENIUM – MORE ADVANCED TESTS

63

Page 64: Agile Bodensee - Testautomation & Continuous Delivery Workshop

DATA PROVIDER

64

Page 65: Agile Bodensee - Testautomation & Continuous Delivery Workshop

URL FACTORY

65

Page 66: Agile Bodensee - Testautomation & Continuous Delivery Workshop

CONTINUOUS INTEGRATION - JENKINS

Download at http://jenkins-ci.org/

66

Page 67: Agile Bodensee - Testautomation & Continuous Delivery Workshop

RECAP

WHAT DO WE EXPECT

THE CI SYSTEM TO DO?

67

Page 68: Agile Bodensee - Testautomation & Continuous Delivery Workshop

68

Page 69: Agile Bodensee - Testautomation & Continuous Delivery Workshop

WHAT JENKINS DOES

Jenkins checks out the workspace from Github

Builds and runs tests locally according to POM

Runs maven targets according to POM description

69

Page 70: Agile Bodensee - Testautomation & Continuous Delivery Workshop

A SIMPLE BUILD JOB

70

Page 71: Agile Bodensee - Testautomation & Continuous Delivery Workshop

A SIMPLE BUILD JOB

1.  (Push to Github repository)

2.  Let Jenkins pick up the change

3.  Perform “mvn test –Dgroup=unit”

71

Page 72: Agile Bodensee - Testautomation & Continuous Delivery Workshop

LET’S CREATE A BUILD / DEPLOYMENT PIPELINE

72

Page 73: Agile Bodensee - Testautomation & Continuous Delivery Workshop

THE MASTER JOB

73

Unit Test

Deploy to QA

Acceptance tests

Deploy to Production

Production Smoke Tests

Code Coverage

Page 74: Agile Bodensee - Testautomation & Continuous Delivery Workshop

UNIT TESTS

74

Page 75: Agile Bodensee - Testautomation & Continuous Delivery Workshop

UNIT TESTS

75

Page 76: Agile Bodensee - Testautomation & Continuous Delivery Workshop

UNIT TESTS

76

Page 77: Agile Bodensee - Testautomation & Continuous Delivery Workshop

UNIT TESTS - RESULT

77

Page 78: Agile Bodensee - Testautomation & Continuous Delivery Workshop

DEPLOY TO QA

78

Page 79: Agile Bodensee - Testautomation & Continuous Delivery Workshop

DEPLOY TO QA

79

Page 80: Agile Bodensee - Testautomation & Continuous Delivery Workshop

DEPLOY TO QA - RESULT

80

Page 81: Agile Bodensee - Testautomation & Continuous Delivery Workshop

E2E TESTS

81

Page 82: Agile Bodensee - Testautomation & Continuous Delivery Workshop

E2E TESTS

82

Page 83: Agile Bodensee - Testautomation & Continuous Delivery Workshop

E2E TESTS - RESULT

83

Page 84: Agile Bodensee - Testautomation & Continuous Delivery Workshop

E2E TESTS - RESULT

84

Page 85: Agile Bodensee - Testautomation & Continuous Delivery Workshop

DEPLOY TO PRODUCTION

85

Page 86: Agile Bodensee - Testautomation & Continuous Delivery Workshop

DEPLOY TO PRODUCTION

86

Page 87: Agile Bodensee - Testautomation & Continuous Delivery Workshop

PRODUCTION SMOKE TESTS

87

Page 88: Agile Bodensee - Testautomation & Continuous Delivery Workshop

LET’S GO MOBILE

88

Page 89: Agile Bodensee - Testautomation & Continuous Delivery Workshop

INFRASTRUCTURE AS CODE

Consistent Infrastructure

Efficient Change Management

Simple to rebuild

89

Page 90: Agile Bodensee - Testautomation & Continuous Delivery Workshop

TOOLS

90

Page 91: Agile Bodensee - Testautomation & Continuous Delivery Workshop

VAGRANT EXAMPLE

91

Page 92: Agile Bodensee - Testautomation & Continuous Delivery Workshop

BOOTSTRAP.SH

92

Page 93: Agile Bodensee - Testautomation & Continuous Delivery Workshop

93

Page 94: Agile Bodensee - Testautomation & Continuous Delivery Workshop

THANK YOU!

94