ad31%!usingcomponent!testingfor ultra%fast!builds! - cochrane.pdfanti-patterns 12 unit test - deploy...

Post on 25-May-2020

3 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

 

     AD31  DevOps  Engineering  10:00  AM            

AD31  -­‐  Using  Component  Testing  for  Ultra-­‐Fast  Builds  

 Presented  by:    

   

Timothy  Cochran      Thoughtworks  

 Brought  to  you  by:    

       

   888-­‐-­‐-­‐268-­‐-­‐-­‐8770  ·∙·∙  904-­‐-­‐-­‐278-­‐-­‐-­‐0524  -­‐  info@techwell.com  -­‐  https://agiledevopswest.techwell.com/    

 

Timothy  Cochran    Tim  Cochrancurrently  works  for  ThoughtWorks  NYC,  and  has  been  full  stack  developer  and  architect  for  over  15  years.  Working  on  everything  from  large  distributed  enterprise  projects  to  small  NGO  visualization  apps.  He  recently  has  been  helping  companies  with  digital  transformation,  moving  towards  continuous  delivery  and  building  a  DevOps  culture.  He  also  is  an  automated  testing  zealot,  practices  TDD  almost  exclusively,  he  builds  test  strategy  using  the  right  combinations  of  unit,  E2E  and  functional  testing  for  clients.  

11

Utilizing Component Testing for Ultra fast Builds

©ThoughtWorks 2019 Commercial in Confidence

GLOBAL SOFTWARE CONSULTANCY

2©ThoughtWorks 2019 Commercial in Confidence

Tech Radar

ThoughtMobile

ThoughtWorks Incorporated

1993

2000

2005

1996

2004

2006

2008

2010

2014

2016, 2017, 2018

2018

500+ ThoughtWorkers

ThoughtWorks University

ThoughtWorks was one of the first

companies to run distributed agile

projects successfully

3000+ ThoughtWorkers

5000+ThoughtWorkers

2001

free, open-source software

Top 10 contributor in open source

Why Automated Testing

4

Cost of QA

Productivity

Functional & Non-Functional Problems

User Sentiment

The Problem

5

Software Design

6

Software Design

7

8

Black Box

9

E2E tests

Black Box

10

Download code Compile Linting / Unit Test Code Coverage Upload Artifact

2 min 5 min 10 min 20 min 5 min

Build / Test pipeline (30 mins)

Prepare E2E tests

5 min 2 hour

E2E / Regression test pipeline (2 hours 5 mins)

Deployment pipeline (15 mins)

Copy binaries Restart Services Health Checks

5 min 5 mins3 mins

Schema Changes

1 min

11

Download code Compile Linting / Unit Test Code Coverage Upload Artifact

2 min 5 min 10 min 20 min 5 min

Build / Test pipeline (30 mins)

Prepare

5 min

E2E / Regression test pipeline (35 mins)

Deployment pipeline (14 mins)

Copy binaries Restart Services Health Checks

5 min 5 mins3 mins

Schema Changes

1 min

30 mins

E2E tests

Anti-patterns

12

Unit test - Deploy - Regression are separate pipelines, owned by different teams

Flakey tests, Fails one in 5 tests

Build is never green, Deploying with failing tests

Environments that don’t reflect Prod, Software still breaks in production

Broken Environments, Tests aren’t run because env is down or misconfigured

13

UI

Service

Unit

Component Testing

15

Software Design

16

17

18

E2E tests

Component Testing

19

tests

tests

tests teststests

Types of Components

20

A code module

A data pipeline

Third party service

UI Component

Microservice

21

What goes wrong?

Dev Prod-Like Prod

Integration with other systems

Edge Data Cases

Misunderstanding of Requirements

More edge cases

User unsatisfied

Misconfigured

NFR problems

22

E2E tests Component / Service

Edge Cases

Functionality (Acceptance)

Integration between components

Critical Path

Configuration

23

What is a Component?

Code

DB IO External APIs

A microservice?

24

25

What is a Component? A service

Code

DB IO External APIs

Service

CartService

OrderService

AddToCartService

PostReviewService

Domain Model

26

How to test? - Out of Process

27

Component

Test

Stub dependencies using service virtualization

How to test? - In Process

28

Component

Test

Stub dependencies using service virtualization

Or use in-memory stubs

29

I use subcutaneous test to mean a test that operates just under the UI of an application.

Contrived Example

30

Contrived Example

31

UIReact

BFFNode.JS

ChargeServiceNode.JS

OtherServiceNode.JS

http

http

32

UIReact

BFFNode.JS

ChargeServiceNode.JS

OtherServiceNode.JS

http

http

Test

33

~1000ms: headless, locally

34

UIReact

BFFNode.JS

ChargeServiceNode.JS

OtherServiceNode.JS

http

http

Test

35

~50ms: locally

36

How to test?

Advantage Disadvantage

In Process: Executed through Code

Fastest, Deterministic Doesn’t tests all the code (e.g. network, controller)

Out of Process: Executed through the API

Fast, Deterministic

Forces API based ecosystem

Retests boiler plate code, network layer

Unit test

Unit test

Unit test

Unit test

37

Checkout Build

2 min 3 min

3 min

Linting

3 min

Test Coverage

5 min

In-Process Tests

5 min Deploy App

7 mins

Time for dev feedback - 22 mins

5 mins

Unit test

Out of Process tests

5 mins

E2E

How to find entry points?

38

Understand what your application does, what capabilities does it provide?

Where is the complexity in your domain?

Talk to your engineers and business

Domain Driven Design (DDD) techniques is good way, establish the domain events, bounded contexts, entities, behaviour, values.

39

UI testing

API

40

UI testing

Service virtualization

41

UI testing

Component test

42

UI testinghttps://blog.pragmatists.com/genuine-guide-to-testing-react-redux-applications-6f3265c11f63

43

E2E tests

44

Culture

Quality is everyone’s responsibility

Cross functional teams

Deliberately design your application to be testable,

Think about testing from day one

Thank youtcochran@thoughtworks.com

46©ThoughtWorks 2019 Commercial in Confidence

top related