enterprise REST a case study twitter:@BrandonByars the eight - - PowerPoint PPT Presentation

enterprise rest a case study
SMART_READER_LITE
LIVE PREVIEW

enterprise REST a case study twitter:@BrandonByars the eight - - PowerPoint PPT Presentation

enterprise REST a case study twitter:@BrandonByars the eight fallacies of distributed programming the network is reliable topology doesnt change latency is zero there is one administrator bandwidth is infinite


slide-1
SLIDE 1
slide-2
SLIDE 2

enterprise REST a case study

twitter:@BrandonByars

slide-3
SLIDE 3

the eight fallacies of distributed programming

  • the network is reliable
  • latency is zero
  • bandwidth is infinite
  • the network is secure
  • topology doesn’t change
  • there is one administrator
  • transport cost is zero
  • the network is

homogenous

slide-4
SLIDE 4

POX URI

Resources

HTTP

Standard Interface

HATEOA S

Forcing people to use your links RPC / SOAP

slide-5
SLIDE 5

Most REST mistakes happen over here…

versioning deployment testing service granularity POX URI HTTP HATEOA S

slide-6
SLIDE 6

REST

slide-7
SLIDE 7

a story about a billing system...

slide-8
SLIDE 8

a story about a legacy rewrite...

slide-9
SLIDE 9

dramatis personae

slide-10
SLIDE 10

dramatis personae

  • rder ¡

management ¡

  • rder ¡

entry ¡ provisioning ¡ product ¡ catalog ¡ customer ¡ field ¡force ¡ management ¡ address ¡ billing ¡ inventory: ¡ physical ¡ inventory: ¡ telephony ¡

CSR ¡ UI ¡ Web ¡

slide-11
SLIDE 11

Choreography... ...not orchestration

slide-12
SLIDE 12

define logical environments for isolation

slide-13
SLIDE 13

Shared Integration VM Bob’s Workstation

Order O1 Product P1

Mary’s Workstation

Order O1 Customer C1

slide-14
SLIDE 14

Shared Integration VM Bob’s Workstation

Order O1 Product P2

Mary’s Workstation

Order O1 Customer C1 Product P1 Customer C2

slide-15
SLIDE 15

Shared Integration VM Bob’s Workstation

Order O1 Product P2

Mary’s Workstation

Order O1 Customer C1 Product P1 Customer C2

slide-16
SLIDE 16

Shared Integration VM Bob’s Workstation

Order O1 Product P2

Mary’s Workstation

Order O1 Customer C1 Product P1 Customer C2

Bob’s Environment Mary’s Environment

slide-17
SLIDE 17

coordinated deployments

slide-18
SLIDE 18
  • rder-bob:

product: webServers: [s1.test.dev]

  • url: http://s1.test.dev:8000/products

dbServer: s1.test.dev dbName: OrderBobProducts customer: webServers: [s1.test.dev] url: http://s1.test.dev:8001/customers dbServer: s1.test.dev dbName: OrderBobCustomers

  • rder-mary:

product: webServers: [s1.test.dev] url: http://s1.test.dev:8002/products

slide-19
SLIDE 19
  • rder-bob:

product: webServers: [s1.test.dev]

  • url: http://s1.test.dev:8000/products

dbServer: s1.test.dev dbName: OrderBobProducts customer: webServers: [s1.test.dev] url: http://s1.test.dev:8001/customers dbServer: s1.test.dev dbName: OrderBobCustomers

  • rder-mary:

product: webServers: [s1.test.dev] url: http://s1.test.dev:8002/products

slide-20
SLIDE 20

version as a last resort

slide-21
SLIDE 21

5.13.3 4.1.1

Product Order Entry UI Billing

slide-22
SLIDE 22

{ "customer": { "firstName": "Fred", "LastName": "Flinstone" } } { "customer": { "firstName": "Fred", "lastName": "Flinstone" } }

speling mistaeks

slide-23
SLIDE 23

@RequestMapping(method=POST, produces=application/json) @ResponseBody public OrderResource createOrder( @RequestBody Order order, HttpServletResponse response ) throws OrderException { ... ... }

Postel’s Law

slide-24
SLIDE 24

separate functional testing from integration testing

slide-25
SLIDE 25

Automated Tests Showcase SIT Pre-prod Production Commit 2.16.1 3.0.6 3.0.6 3.1.3 3.1.11 3.1.12

deployment pipeline

slide-26
SLIDE 26

Isolated Pipelines SIT Pre-prod Production 2.16.1 3.0.6 3.0.6 3.1.3 Order Entry Billing Product UI 4.1.1 4.1.2 4.2.0 4.2.3 7.2.0 7.2.0 7.2.0 7.2.6 2.1.33 2.2.0 2.2.0 2.2.5

deployment pipelines...

slide-27
SLIDE 27

Isolation Tests … … … … Commit 2.16.1 3.0.6 3.0.6 3.1.3 3.1.11 3.1.12

early stages stub ruthlessly

slide-28
SLIDE 28

System Under Test Tests Stub Server

hand-crafted stubs

slide-29
SLIDE 29

System Under Test Tests Stub Server

record and replay stubs

Real Dependency

slide-30
SLIDE 30

System Under Test Tests Stub Server

general purpose stubs

Stub Setup

slide-31
SLIDE 31

Moco: https://github.com/dreamhead/moco vcr: https://github.com/vcr/vcr

  • βetamax: https://github.com/robfletcher/betamax
  • stubby4j: https://github.com/azagniotov/stubby4j
  • mountebank: http://www.mbtest.org/
slide-32
SLIDE 32

Isolation Tests … … … … Commit 2.16.1 3.0.6 3.0.6 3.1.3 3.1.11 3.1.12

early stages

slide-33
SLIDE 33

Isolation Tests … … … … Commit 2.16.1 3.0.6 3.0.6 3.1.3 3.1.11 3.1.12

early stages

Contract Tests

slide-34
SLIDE 34

Isolated Pipelines Contract Tests Pre-prod Production 2.16.1 3.0.6 3.0.6 3.1.3 Order Entry Billing Product UI 4.1.1 4.1.2 4.2.0 4.2.3 7.2.0 7.2.0 7.2.0 7.2.6 2.1.33 2.2.0 2.2.0 2.2.5

slide-35
SLIDE 35

Contract Tests Artifacts Isolated Pipelines Tests 3.1.2 Order Entry Billing Product UI 3.1.3 Tests 4.2.3 7.2.6 Tests 2.2.5

slide-36
SLIDE 36

Contract Tests Artifacts Isolated Pipelines Tests 3.1.3 Order Entry Billing Product UI 3.1.3 Tests 4.2.3 7.2.6 Tests 2.2.5

slide-37
SLIDE 37

7.2.6 4.2.3

Product Order Entry UI Billing

slide-38
SLIDE 38

Contract Tests Artifacts Isolated Pipelines Tests 3.1.3 Order Entry Billing Product UI Tests 4.2.3 7.2.6 Tests 2.2.5 Order Entry-3.1.3 Billing-4.2.3 Product-7.2.6 UI-2.2.5

slide-39
SLIDE 39

Contract Tests Artifacts Isolated Pipelines Tests 3.1.3 Order Entry Billing Product UI Tests 4.2.3 7.2.6 Tests 2.2.5

slide-40
SLIDE 40

[Test] ¡ public ¡void ¡ValidateProductAttributes() ¡ { ¡ ¡ ¡ ¡ ¡var ¡url ¡= ¡UrlForTestProduct(); ¡ ¡ ¡ ¡ ¡var ¡response ¡= ¡new ¡HttpResource(url) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡.ThatAccepts("application/xml") ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡.Get(); ¡ ¡ ¡ ¡ ¡ ¡Assert.That(response.StatusCode, ¡Is.EqualTo(200)); ¡ ¡ ¡ ¡ ¡AssertHasXPath(response.Body, ¡"//productCode"); ¡ ¡ ¡ ¡ ¡AssertHasXPath(response.Body, ¡"//description"); ¡ ¡ ¡ ¡ ¡AssertHasXPath(response.Body, ¡"//monthlyCharge"); ¡ ¡ ¡ ¡ ¡AssertNumeric(ValueFor(response.Body, ¡"//monthlyCharge")); ¡ } ¡

slide-41
SLIDE 41

use bounded contexts to control complexity

slide-42
SLIDE 42

Rates CSR UI Provisioning Finance Billing Invoicing Marketing / Website Product Catalog

slide-43
SLIDE 43

data rationalization

slide-44
SLIDE 44

Conway’s Law

Organizations which design systems ... are constrained to produce designs which are copies of the communication structures of these

  • rganizations

In every organization there will always be one person who knows what is going on. This person must be fired.

slide-45
SLIDE 45
slide-46
SLIDE 46

product finance invoice billing

create record event get events augment augment augment

slide-47
SLIDE 47

twitter:@BrandonByars http://martinfowler.com/articles/enterpriseREST.html

slide-48
SLIDE 48