continuous deployment and testing workshop from better software west

121
Continuous Testing Cory Foy Cory Foy, LLC @Cory_foy

Upload: cory-foy

Post on 03-Aug-2015

502 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: Continuous Deployment and Testing Workshop from Better Software West

Continuous Testing

C o r y F o yC o r y F o y , L L C

@ C o r y _ f o y

Page 2: Continuous Deployment and Testing Workshop from Better Software West

Who am I?

Page 3: Continuous Deployment and Testing Workshop from Better Software West

3

Cofounder of GROWS Methodology

Author Ship It! and Career 2.0

Screencast editor PragProg.com

2nd public signatory of the Agile Manifesto

Started AgileRTP in 2007!

Coach

AgileArtisans.com

Jared Richardson

Page 4: Continuous Deployment and Testing Workshop from Better Software West

4

CTO of Pretty Kool Apps, Founder of Cory Foy, LLC

Helped write the Software Craftsmanship Manifesto

Former Microsoft PFE

Development Clients include MIT, Beats By Dre

Global Agile + Lean Coach

Former Assistant Fire Chief

blog.coryfoy.com

Cory Foy

Page 5: Continuous Deployment and Testing Workshop from Better Software West

Who are you?

Page 6: Continuous Deployment and Testing Workshop from Better Software West

Who’s A User?

Already using continuous integration?

Continuous deployment?

Which tools?

Page 7: Continuous Deployment and Testing Workshop from Better Software West

What would you say you do here?

Roles?

Responsibilities?

Why are you here?

What are your tests for this session?

Page 8: Continuous Deployment and Testing Workshop from Better Software West

Objectives

Understand Continuous Feedback in context of SDLC

Understand the Continuous Paradigm

Understand the basics of Jenkins

Understand an end-to-end Continuous workflow

Miscellaneous practical tips and tricks

Page 9: Continuous Deployment and Testing Workshop from Better Software West

OutlineSDLC

Continuous paradigm

Continuous Integration (benefits & workflow)

Introduction to Jenkins

Continuous Testing (benefits & workflow)

Jenkins as a continuous deployment/testing tool

Miscellaneous tips & tricks

Page 10: Continuous Deployment and Testing Workshop from Better Software West

Breaks

Half-way (90 minutes)?

Each hour ?

Page 11: Continuous Deployment and Testing Workshop from Better Software West

SDLC Feedback

Page 12: Continuous Deployment and Testing Workshop from Better Software West

Requirements

Write Code

The Traditional Approach

Demo

Rewrite

“Discussion”

The architects generate a

document and hand it off

An isolated event, primarily worked by the

customer proxy

Arch

Code like mad! We’re starting late!

Not what we meant! Wrong arch

Ignored my docs etc

so on

Page 13: Continuous Deployment and Testing Workshop from Better Software West

Demo

Write Code

Requirements

The Agile Approach

Rewrite

Before significant time and $$ is

invested

Discuss

Include the Golden Triad

Dev QA

Customer

Page 14: Continuous Deployment and Testing Workshop from Better Software West

Demo

Write Code

Architecture

Proof of Concept

Requirements Arch

Page 15: Continuous Deployment and Testing Workshop from Better Software West

Technical Vision StatementDe

fine

Your

Goal

s

DB

Services

Front End

Design

Page 16: Continuous Deployment and Testing Workshop from Better Software West

System Vision StatementDe

fine

Your

Goal

s

Team

1

Team

2

Team

3

Feat A

Feat B

Feat C

Technical Vision

Busines

s Visio

n

Page 17: Continuous Deployment and Testing Workshop from Better Software West

Technical Product OwnerTe

st a

nd E

xper

imen

t Cont

inuo

usly

Team

1

Team

2

Team

3

Feat A

Feat B

Feat C

Technical Vision

Busines

s Visio

n

Page 18: Continuous Deployment and Testing Workshop from Better Software West

Experimentation

Learn about software by writing software

Can’t study your way into experience

Like riding a bike

3+ experiments

Create feedback loops

flickr.com/photos/schwar/6801765768

Page 19: Continuous Deployment and Testing Workshop from Better Software West

Exercise - Dot Game

Groups of 7

Roles: BA, PM, Developers, Tester

5 Minute Rounds

Page 20: Continuous Deployment and Testing Workshop from Better Software West

Requirements

Rewrite

Discuss

Development

Developers disagree on

which Javascript toolkit is best

Node.js

Bootstrap

Angular.js

Pick one

SOA

Monolithic

Peer to peer

Pick one

Developers disagree on

which architecture is best

Demo

Revise Rewrite Adjust

Frequent demos discover

communication failures early

Continue until you can demo

Page 21: Continuous Deployment and Testing Workshop from Better Software West

Discuss

Intentional Experimentation Study

Experiment

Learn

Page 22: Continuous Deployment and Testing Workshop from Better Software West

Decide! Learn

Learn Decide!

Two Paths

Page 23: Continuous Deployment and Testing Workshop from Better Software West

Expect Well Less Well Change

What we wanted to happen What went

well

What didn’t go so well

What we want to

try

Page 24: Continuous Deployment and Testing Workshop from Better Software West

ContinuousParadigm

Page 25: Continuous Deployment and Testing Workshop from Better Software West

What Is Software?

Page 26: Continuous Deployment and Testing Workshop from Better Software West

Feedback Loops

Page 27: Continuous Deployment and Testing Workshop from Better Software West

Feedback Loops

Discover What We Need

Discover How to Build ItBuild It

Page 28: Continuous Deployment and Testing Workshop from Better Software West

What Is Agile?

Page 29: Continuous Deployment and Testing Workshop from Better Software West

29

AgileManifesto.org

Page 30: Continuous Deployment and Testing Workshop from Better Software West

30 AgileManifesto.org

Individuals and interactions over processes and tools Working software over comprehensive documentation

Customer collaboration over contract negotiation Responding to change over following a plan

Page 31: Continuous Deployment and Testing Workshop from Better Software West

Feedback Loops

Page 32: Continuous Deployment and Testing Workshop from Better Software West

flickr.com/photos/bobowen/4501875907

Product or system

flickr.com/photos/30691679@N07/3808395213

Module/Sub System

flickr.com/photos/kevino/1438502858

Class

Page 33: Continuous Deployment and Testing Workshop from Better Software West

Feedback Loops are Fractal

flickr.com/photos/dancentury/4579906149

Page 34: Continuous Deployment and Testing Workshop from Better Software West

Pairing

Test FirstDemos

???

Feedback Loops Inside Feedback Loops

???

Page 35: Continuous Deployment and Testing Workshop from Better Software West

Systems are closed

Change is slow

Interdependencies are low

Certainty is high

Variability is low

Newtonian Management Methods Work:

Facilitating Organizational Change: Lessons from Complexity Science

Page 36: Continuous Deployment and Testing Workshop from Better Software West

System Agents

Emergent Patterns

Com

plex Adaptive System

Facilitating Organizational Change: Lessons from Complexity Science

Page 37: Continuous Deployment and Testing Workshop from Better Software West

Agile Is...

Tighter Feedback Loops

Page 38: Continuous Deployment and Testing Workshop from Better Software West

Which Level?

38

Initiative

Themes

Epics

Features

Stories

Page 39: Continuous Deployment and Testing Workshop from Better Software West

39

Initiative

Themes

Epics

Features

Stories Days

Iterations

Months

Quarters

Years

Optional

Optional

Page 40: Continuous Deployment and Testing Workshop from Better Software West

Initiative

Themes

Epics

Features

Stories

Management Level

40

Page 41: Continuous Deployment and Testing Workshop from Better Software West

Initiative

Themes

Epics

Features

Stories

DeveloperLevel

41

Page 42: Continuous Deployment and Testing Workshop from Better Software West

Minimize Dark Times

Code Change

Validation http://flickr.com/photos/bogenfreund/556656621/

Page 43: Continuous Deployment and Testing Workshop from Better Software West

Fast feedback leads to fast fixes

Page 44: Continuous Deployment and Testing Workshop from Better Software West

ExerciseCreate a Value Stream Map

Start with where work comes in to your org

Continue until it is in a customer’s hands

Each step gets a box

Map Time Map Anchors

Page 45: Continuous Deployment and Testing Workshop from Better Software West

One Vision One Voice One Team

Outcomesover

Output

Velocityover

Capacity

Throughputover

Utilization

Leadershipover

Management

286.5 / 1592.5

7 weeks of work40 weeks to do the 7 weeks

Page 46: Continuous Deployment and Testing Workshop from Better Software West

Different Levels

Manual acceptance tests

Unit tests

Continuous Testing

Page 47: Continuous Deployment and Testing Workshop from Better Software West

Continuous Feedback

Continuous Integration

Continuous Delivery

Continuous Testing

Page 48: Continuous Deployment and Testing Workshop from Better Software West

Continuous deployment is controversial.

Most people ... think I’m advocating low-quality code

or an undisciplined cowboy-coding

development process.

ERIC RIES radar.oreilly.com/2009/03/continuous-deployment-5-eas.html

Page 49: Continuous Deployment and Testing Workshop from Better Software West

Language is a Tool

Use it

Page 50: Continuous Deployment and Testing Workshop from Better Software West

Continuous Integration

Page 51: Continuous Deployment and Testing Workshop from Better Software West

Continuous Integration

Watch Code

Build product

Run tests

Publish results

Page 52: Continuous Deployment and Testing Workshop from Better Software West

Pros

Fast feedbackKnown stateEasily consumed historyShines a light

52

Page 53: Continuous Deployment and Testing Workshop from Better Software West

Cons

Slows you downNags you after every code changeExposes problemsShares issuesForces you to deal with problemsSmoke alarm 53flickr.com/photos/117168856@N06/12486837493

Page 54: Continuous Deployment and Testing Workshop from Better Software West

54

Work

Time

Perception of Problem Accumulation

Page 55: Continuous Deployment and Testing Workshop from Better Software West

55

Work

Time

Actual Problem Accumulation

Page 56: Continuous Deployment and Testing Workshop from Better Software West

56

Work

Time

Continuous Problem Resolution

Page 57: Continuous Deployment and Testing Workshop from Better Software West

DirectionsAtlasMapsPrinted maps!Navigation softwareWhat’s better?

57

Page 58: Continuous Deployment and Testing Workshop from Better Software West

Feedback Loops

Page 59: Continuous Deployment and Testing Workshop from Better Software West

Sidebar: How We Learn

Dreyfus Model of Skills Acquisition

59

Page 60: Continuous Deployment and Testing Workshop from Better Software West

60

Start

Familiar

Working

Smooth

Teaching

Dreyfus ModelofSkillsAcquisition

en.wikipedia.org/wiki/Dreyfus_model_of_skill_acquisition

Page 61: Continuous Deployment and Testing Workshop from Better Software West

61

Start

Familiar

Working

Smooth

Teaching

Dreyfus ModelofSkillsAcquisition

Steps

Recipes

Intuition

Stuck

Principles

Page 62: Continuous Deployment and Testing Workshop from Better Software West

Key Points

Skills don’t map

62dilbert.com/strip/1990-09-13

Page 63: Continuous Deployment and Testing Workshop from Better Software West

Key Points

Beginners need steps

63

Page 64: Continuous Deployment and Testing Workshop from Better Software West

StepsUse source code management (SCM)Automate the build (script)Acquire a build box (isolated)Install a build environment (dev tools)

64

Skunkworkable

Page 65: Continuous Deployment and Testing Workshop from Better Software West

Java Tooling

Publish results

Page 66: Continuous Deployment and Testing Workshop from Better Software West

Continuous Integration Servers

ManyJenkinsCruise ControlBamboo PulseTFSTravis CI

66

Page 67: Continuous Deployment and Testing Workshop from Better Software West

Jenkins

Open sourceEstablishedSplit from HudsonJava applicationAny application serverSelf contained

67

Page 68: Continuous Deployment and Testing Workshop from Better Software West

Example

Publish results

javac (Oracle & IBM)message brokeretc

ws ejb deploymessage broker toolssshexec (to scripts)

JUnitHP's UFTSelenium

Web pageRSSEmail

Page 69: Continuous Deployment and Testing Workshop from Better Software West

Dependent Builds

Services

Client/GUI

Data Layer

Page 70: Continuous Deployment and Testing Workshop from Better Software West

Dependent Builds

Data Layer

Data Services

Rich Client

Common Libs

Web Portal

Biz Services

Page 71: Continuous Deployment and Testing Workshop from Better Software West

Chained Continuous Integration

Team 1 Team 2 Team 3

Integrationbuild

Page 72: Continuous Deployment and Testing Workshop from Better Software West

Platform Testing

Team 1 Team 3Team 2 Team 4 Team 5

Integration Build

Platform1 Plat 3Plat 2 Plat 4 Plat 5

Page 73: Continuous Deployment and Testing Workshop from Better Software West

See JenkinsSample project Add to JenkinsExplore the GUI

73

Travis CI

RSpec / Guard

Page 74: Continuous Deployment and Testing Workshop from Better Software West

Continuous Testing

Page 75: Continuous Deployment and Testing Workshop from Better Software West

Continuous Integration

Watch Code

Build product

Run tests

Publish results

Page 76: Continuous Deployment and Testing Workshop from Better Software West

Continuous Testing

Watch CI

Deploy product

Integration tests

Publish results

Page 77: Continuous Deployment and Testing Workshop from Better Software West

Continuous Testing

CI CT

Compile & unit test

Deploy &integration

test

Page 78: Continuous Deployment and Testing Workshop from Better Software West

Continuous Testing

Build in CI (compile & unit tests)

Deploy to dev (staging)

Run integration tests

Page 79: Continuous Deployment and Testing Workshop from Better Software West

What does this tell us?

If it works

Page 80: Continuous Deployment and Testing Workshop from Better Software West

What's this look like?

Page 81: Continuous Deployment and Testing Workshop from Better Software West

Continuous Testing

CI CT

Compile & unit test

Deploy &integration

test

Page 82: Continuous Deployment and Testing Workshop from Better Software West

Multiplatform Deploys

CICD Win7

CD Linux

CD OS X

Page 83: Continuous Deployment and Testing Workshop from Better Software West

ExerciseRemember your SDLC bottlenecks? What could continuous integration solve? What could continuous testing solve?Regroup with your team and discussBring your top 3 solutions

83

Cut Anchors

Page 84: Continuous Deployment and Testing Workshop from Better Software West

As We Explore a Continuous World...

84

Page 85: Continuous Deployment and Testing Workshop from Better Software West

What Concepts Emerge?

85

Page 86: Continuous Deployment and Testing Workshop from Better Software West

Not Just CodeDatabasesServersHardware

86

A Continuous Paradigm affects all portions of our

ecosystem

Page 87: Continuous Deployment and Testing Workshop from Better Software West

Nuke and PaveReset (completely)Start overCompletely Scripted

87

Page 88: Continuous Deployment and Testing Workshop from Better Software West

BinariesNuke & PaveDeleteRecompileDeployUse

88flickr.com/photos/x-ray_delta_one/4152356464

Page 89: Continuous Deployment and Testing Workshop from Better Software West

DataNuke & PaveDelete schemaDrop tablesRecreateRestockRailsLiquibase

89flickr.com/photos/x-ray_delta_one/4152356464

Page 90: Continuous Deployment and Testing Workshop from Better Software West

Operating System

Nuke & PaveVirtualizeRecreate

90flickr.com/photos/x-ray_delta_one/4152356464

Page 91: Continuous Deployment and Testing Workshop from Better Software West

DatabasesDataSchemaBusiness Logic (Stored Procs)

91

Page 92: Continuous Deployment and Testing Workshop from Better Software West

Data UpdatesETL ProcessesData MappingMigrating Data

92

How can we apply continuous

paradigms here?Script Changes

Script Deploy

Write Tests

Page 93: Continuous Deployment and Testing Workshop from Better Software West

Schema / Stored ProcsTable StructureIndexesTriggersStored Procs

93

How can we apply continuous

paradigms here?Script Changes

Script Deploy

Write Tests

Page 94: Continuous Deployment and Testing Workshop from Better Software West

Raw SQL

CREATE TABLE products (   id int(11) NOT NULL auto_increment,   name varchar(255),   PRIMARY KEY  (id));

94

Page 95: Continuous Deployment and Testing Workshop from Better Software West

SQL Server Data Tools

95

SQL Server Data Tools

http://www.infoq.com/articles/tdd-dbpro-Foy

Page 96: Continuous Deployment and Testing Workshop from Better Software West

Rails ActiveRecord

change_table :card_deck do |table| table.remove :description, :name table.string :first_name table.index :part_number table.rename :list_name, :last_name end

96

Page 97: Continuous Deployment and Testing Workshop from Better Software West

Rails ActiveRecordrake db:migrate

Determines the best way to migratePreserves the dataIs reversible (rake db:rollback)

97

Page 98: Continuous Deployment and Testing Workshop from Better Software West

ActiveRecordrake db:reset

Drops schemaRecreates schema

98

Page 99: Continuous Deployment and Testing Workshop from Better Software West

Steps for a New OS

Install VirtualBoxInstall Vagrantvagrant init hashicorp/precise32vagrant up

99

Page 100: Continuous Deployment and Testing Workshop from Better Software West

Steps for a New OS

100

Page 101: Continuous Deployment and Testing Workshop from Better Software West

Benefits

Scriptable

Reproducible environment

Solid results

Fast results

Repeatable results

Page 102: Continuous Deployment and Testing Workshop from Better Software West

Immutable Infrastructure

“IT operations teams realized that it is far more expensive to debug and fix a faulty virtual server than to replace it with a new server”

Hidden Jobs One Off Processes

Production Hacks

Page 103: Continuous Deployment and Testing Workshop from Better Software West

When?

The best time is day one

The second best time is today

Page 104: Continuous Deployment and Testing Workshop from Better Software West

“If you don’t do it on Day One,you probably won’t”

Andy Hunt

104andy.pragprog.com

Page 105: Continuous Deployment and Testing Workshop from Better Software West

Easy?

No

Difficult

Necessary

Use agility in your approach!

Page 106: Continuous Deployment and Testing Workshop from Better Software West

Costs Move to Zero

Once scripted…

What changes?

Page 107: Continuous Deployment and Testing Workshop from Better Software West

How do We Improve Our Feedback Loops?

Page 108: Continuous Deployment and Testing Workshop from Better Software West

Developers

Devs write code normally

SCM

Code is shared via a source code management

tool

Continuous Testing

Providing immediate

feedback and a shared

environment for a QA “First Look”

Triggered Deploy to QA

QA team members trigger

this deploy

Manual Testing

A stable environment for

manual and exploratory testing

Page 109: Continuous Deployment and Testing Workshop from Better Software West

SCMDevelopers

Watch

Build

Unit Tests

Deploy to Dev

Integration Tests

First Look

Continuous Testing

On Demand Deploy to QA

Manual Testing

Rapid feedbackPair Dev & QA

Page 110: Continuous Deployment and Testing Workshop from Better Software West

First Look• QA can see what’s been coded immediately

• Differences in opinions can be discussed quickly

• Fewer problems during the larger testing cycles

• Keeps QA & Dev working together as partners

• Minimizes feedback for the previous iteration

• Faster feedback for QA

Page 111: Continuous Deployment and Testing Workshop from Better Software West

Continuous Testing

• Includes QA in the continuous feedback cycle

• Retains a traditional QA stable testing environment

• Dev & QA should both review all tests (unit & int.)

• QA requests trigger the QA env. deployment

Page 112: Continuous Deployment and Testing Workshop from Better Software West

Write Code

Requirements

The Traditional Approach

DemoDiscuss

Rewrite

Typically a confrontation &

argument

The demo forces a

discussion of the requirements

An isolated event, primarily worked by the customer proxy

Page 113: Continuous Deployment and Testing Workshop from Better Software West

Demo

Write Code

Requirements

The Agile Approach

Rewrite

Discuss before significant time is

invested

Include the Golden Triad

Discuss

Page 114: Continuous Deployment and Testing Workshop from Better Software West

Alternatives

Page 115: Continuous Deployment and Testing Workshop from Better Software West

flickr.com/photos/lightsinthedark/5810724330/

Work in a vacuum

Page 116: Continuous Deployment and Testing Workshop from Better Software West

Ruthlessly Automate!

Builds

Deploys

Tests

flickr.com/photos/pmillera4/9317924474

Page 117: Continuous Deployment and Testing Workshop from Better Software West

IN Summary...

Page 118: Continuous Deployment and Testing Workshop from Better Software West

Culture Change

Fundamental change in development

Page 119: Continuous Deployment and Testing Workshop from Better Software West

StepsAutomate builds

Continuous Integration

Add unit tests

Automate deployments

Continuous Delivery

Add integration testsflickr.com/photos/untitlism/2547423465

Page 120: Continuous Deployment and Testing Workshop from Better Software West

Your move

Page 121: Continuous Deployment and Testing Workshop from Better Software West

Thank you!

Cory Foy

[email protected]

@cory_foy