23

Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as
Page 2: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Frictionless integration testing in the Cloud

Adrian Cole Aslak Knutsen

Arquillianjclouds

Page 3: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Agenda

• Introduction

• Arquillian• jclouds

• Demo• Open Discussion

Page 4: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Why don't we test?

Page 5: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

The “testing bandgap” and compounding effort

Unit Tests Integration Tests Functional Tests

Functional complexity

Configuration complexity

Tho

ught

and

Eff

ort

Page 6: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Common integration testing challenges

• Start a container environment• Run a build to create/deploy application

archive

• Mock dependent components

• Configure application to use test data source(s)

• Deal with (lack of) classpath isolation

Page 7: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Arquillian's testing continuum

Unit Tests Integration Tests Functional Tests

Functional complexity

Configuration complexity

Tho

ught

and

Eff

ort

Reducing enterprise testing to child's play

Page 8: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

What if integration testing could be...

• as easy as writing a unit test• run in the IDE, leveraging incremental

builds

• limited to select components running in isolation– ...avoiding the “big bang” integration

roadblock

Page 9: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Step 1: Liberate tests from the build!

• Adds overhead to development cycle • Slows down test execution

• Uses coarse-grained classpath/package

• Keep it manageable!

– Well-defined “unit”– Classpath control

Page 10: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Step 2: Gut the plumbing!

• Manage lifecycle of container• Enrich test class

• Package test archive• Deploy test archive

• Invoke tests• Capture test results

• What's left?– Pure test logic

Page 11: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Prove it.@RunWith(Arquillian.class)public class GreeterTestCase {

@Deployment public static Archive<?> createDeployment() { return ShrinkWrap.create(JavaArchive.class) .addClasses(Greeter.class, GreeterBean.class); } @EJB private Greeter greeter; @Test public void shouldBeAbleToInvokeEJB() throws Exception { assertEquals("Hello, Earthlings", greeter.greet("Earthlings")); }}

Page 12: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

jclouds

• Adrian Cole (@jclouds)

• Founded jclouds last march

• Contributor on many cloud programs

Page 13: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Compute Cloud

• Infrastructure as a service

• Soft and hardware catalog

• On demand machines• Priced per hour

Page 14: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Face meets palm

• Deal with Errors

• Deal with Constant Updates

• Deal with Complexity

Page 15: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

jclouds

• Open source (github jclouds/jclouds)

• Feels like java (and clojure)

• Portability between clouds• Unit testable

• Strong ecosystem

Page 16: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Java overview

// initcontext = new ComputeServiceContextFactory(). createContext("gogrid", apikey, secret, singleton(new JschSshClientModule()));

compute = context.getComputeService();

// create a couple nodes and open a couple portsnodes = compute.runNodesWithTag(“web-prod”, 2, runScript(bootstrap). InboundPorts(22, 8080));

// gather my ip addressesfor (NodeMetadata node : nodes) { node.getPublicAddresses(); node.getPrivateAddresses();}

Page 17: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Clojure overview

(with-compute-service [“trmk-vcloudexpress” email pass :ssh]  (def nodes    (run-nodes “web-prod” 2       (build-template compute :inbound-ports [22,8080] :run-script bootstrap)))  (pprint nodes))

Page 18: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Who's integrating?

Whirr...

Page 19: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

What's next?

• Mounted volume support

• Existing node management

• Cloning / Backups

Page 20: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

DEMO

Multi Threaded integration tests against a pool of cloud

nodes

Page 21: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Open Discussion

Page 22: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Get involved!

• Participate with us!

– Share ideas on the forums (or IRC)

– Give us feedback on releases – still in alpha!

• Fork us!

– http://github.com/arquillian

• Meet us!

– #jbosstesting channel on irc.freenode.net

• Write for us!

– Share your stories – Blog! Tweet!

– Document how it works

Page 23: Frictionless integration - JBoss · Unit Tests Integration Tests Functional Tests Functional complexity Configuration complexity T h o u g h t a n d E f f o r t. ... • as easy as

Hackfest

Join the fun