exploratory study to assess rehearsal and tdd...

51
Exploratory Study to assess Rehearsal and TDD methodology for web service choreographies Training stage Felipe Besson

Upload: dokhuong

Post on 06-Mar-2018

219 views

Category:

Documents


2 download

TRANSCRIPT

Exploratory Study to assess Rehearsal and TDD methodology for web service choreographies

Training stageFelipe Besson

2

SCA

3

SCA

Service Component Architecture

4

Composite Example

5

OW2 FraSCAti

● Open source implementation of SCA● Dynamic reconfiguration support

● implementation types: Java, Groovy, JavaScript, JRuby, Jython, Scala, …

● binding types: Java RMI, SOAP, REST, …● interface types: Java, WSDL, …

6

FraSCAti Demo

● A simple orchestration of 2 web services● Service A: GreetingAWS

Input: “john” Output: “hi john, ”

● Service B: GreetingBWS

Input: “john” Output: “john how are you bro?”–

● A + B for input “john”: “hi john, how are you bro?”

7

FraSCAti Demo

8

FraSCAti Demo

Step 01● Develop the component interface

– Greeting.java

Step 02● Develop the implementation (business flow)

– Orchestration.java

9

FraSCAti Demo

Step 03● Integrate serviceA into the flow

– Create the service A ● GreetingAWS.java

– Bind the service (through stubs)● $ frascati wsdl2java -u <wsdl_uri> -o <src_dir>

– Create the @References● Orchestrator.java

10

FraSCAti Demo

Step 04● Integrate serviceb into the flow

– Create the service B ● GreetingBWS.java

– Bind the service (through stubs)● $ frascati wsdl2java -u <wsdl_uri> -o <src_dir>

– Create the @References● Orchestrator.java

11

FraSCAti Demo

Step 05● Compiling the SCA application

– $frascati compile <src_dir> <jar_file_name>

– $frascati run <composite> -libpath <jar_file>

● See http://localhost:9080/greeting?wsdl

12

(Choreographies in SCA)

Choreographies● Distributed coordination (roles)

– Set of distributed orchestrations● Each orchestration is a role

– In SCA● Orchestration = Composite =>● Composite = Role

13

How to test the composite

Invoke the composite service and test it as a black box:

– And the internal services?● As black boxes too

● There are tools for doing that:

– SoapUI, Eclipse web service plugins, stubs...

● But if the contract is not available or change often?● How to maintain the automated test cases?

14

How to test the composite

How to validate the internal message flow:

– Monitoring by using an ESB

– Create and deploy proxies for the services that are only published in your test cases

How to test a composition where the services are not available in a testing environment?

– Mock!

15

Rehearsal

16

Dynamic generation of clients

Help the developer to invoke Soap web services

– Test cases are written before having a contract (WSDL file)

In the context of choreographies:- Unit and acceptance test

17

Dynamic generation of clients

WSClient: our client !

18

Dynamic generation of clients

Types:

<soap:envelope … > <soap:body>

<getProductStatus><id>42</id><name>kindle</name><status>shipped</status>

</getProductStatus> </soap:body></soap:envelope>

Primitive type<soap:envelope … > <soap:body>

<getProductStatus><product> <id>42</id> <name>kindle</name> <status>shipped</status>

</product> </getProductStatus> </soap:body></soap:envelope>

Complex type

19

Dynamic generation of clients

20

Dynamic generation of clients

DemonstrationTesting greetingAWS web service

21

But first ….

Setting up$ cd ~/workspace/rehearsal-study/ $ git checkout master$ git pull

Open eclipse and import the project rehearsal-study/ /training/sand_box

Item explorer: ~/workspace/rehearsal-study/start_explorer

Divide the pairs

22

Dynamic generation of clients

Your TurnTesting the operation: getWeather (cityName, countryName)

23

Message interceptor

Intercepting, storing and validating the messages exchanged among services

– Using proxies!

In the context of choreographies:- Integration test

24

Message interceptor

25

Message interceptor

DemonstrationIntercepting the messages sent to

greetingBWS

26

Message interceptor

Your TurnIntercepting the messages sent to

GlobalWeather

27

Service Mocking

Simulate a real service● Regular behavior● Faulty scenarios

In the context of choreographies:- Integration test

28

Service Mocking

29

Service Mocking

DemonstrationMocking GreetingAWS

30

Service Mocking

Your TurnMocking GlobalWeather WS without

defining mock conditions

31

Abstraction of choreography

Map choreography elements into Java objects● Help to write test cases● Interact with modeling diagrams

Service airline1 = bookTrip.getServicesByRole(“airline”).get(0);WSClient ws = new WSClient (airline1.getWSDL());

32

Abstraction of choreography

Choreography Descriptorroles: - role: &1 name: supermarket contractUri: file:///home/besson/workspace/futureMarket/roles/supermarket.wsdl - role: &2 name: customer contractUri: file:///home/besson/workspace/futureMarket/roles/customer.wsdl

services: - uri: http://localhost:8084/petals/services/customer?wsdl role: *2 participants: - uri: http://localhost:1234/customerWS?wsdl - uri: http://localhost:1234/smregistry?wsdl - uri: http://localhost:8084/petals/services/supermarket1?wsdl role: *1 participants: - uri: http://localhost:4321/SM1?wsdl

33

Abstraction of choreography

34

TDD Methodology

35

TDD Methodology

Why Test-Driven Development (TDD)?● Services are units● Test-Driven approach for compositions

– Test early as possible– Define and document contracts– Exercise choreography features in an offline

environment (development-time)– Refactor whenever is possible

36

Methodology steps

37

TDD Methodology

Choreography development scenarios

1) A role or a set of roles must be developed for the choreography

2) Roles are defined (via contracts) and developers must provide only the web services to implement the role

3) The choreography is being developed from scratch

38

TDD Methodology

Phase 01

Creation or adaptation of atomic web services– In the case of S1 and S3

● Contract is defined by the tests– In the case of S2

● Tests guide the development

– Tests are an executable documentation– WSClient!

39

TDD Methodology

Phase 01

Creation or adaptation of atomic web services

40

TDD Methodology

Phase 02

Integration of services to compose the choreography roles– Validate the messages exchanged inside the

executable processes● Mocking real dependencies● Using the Message Interceptor for

inspecting the messages

– Detect binding problems early

41

TDD Methodology

Phase 03

Integration of roles to compose the choreography

– Validate the messages exchanged among the executable processes

● Roles are available as atomic services– Mocking third-party roles– Using the Message Interceptor for

inspecting the messages

42

TDD Methodology

Phase 04

Acceptance and Scalability Testing– Validate all choreography features from the

user point of view● Without interceptors● Trying to use an environment closed to

production– Assess the choreography scalability

● large workload and different choreography configurations

43

TDD Methodology

Why performing this in development-time?

Build a choreography is not trivial!– Change choreographies all the time

● Create, deploy, integrate services– Infrastructure and tools for composing services are not

consolidate – Dependent of third-party services– Scalability

Imagine deal with these issues only at runtime

44

Developmenttasks

45

The choreography

Based on CHOReOS Passenger-friendly choreography● Better serve passengers

– Departure and arrive procedures– booking and shopping facilities– Plans arising from flight delays or cancellations

● Selected scenario: Arrival at the airport

46

The choreographyAfter booking a car park reservation, when the passenger arrives at the airport:

47

The choreography

48

Development Tasks

Each task corresponds to a methodology phase

1) Wrap the legacy system into a web service

2) Create the process to provide the choreography roles

3) Integrate the choreography roles

4) Apply acceptance tests

49

Development Tasks

50

Development Tasks

Example of test case

51

Development Tasks

That is it =]

Have fun:http://www.ime.usp.br/~besson/rehearsal-study/instructions

General information:http://www.ime.usp.br/~besson/rehearsal-study/instructions/info.html