Testing Storm components with Groovy and Spock

31
TESTING STORM COMPONENTS WITH GROOVY AND SPOCK

description

Ho to use Groovy and Spock framework for testing Java projects. Examples of using Storm testing facility.

Transcript of Testing Storm components with Groovy and Spock

Page 1: Testing Storm components with Groovy and Spock

TESTING STORM COMPONENTSWITH GROOVY AND SPOCK

Page 2: Testing Storm components with Groovy and Spock

About Me

Architect @WebMD

Java Developer

Big Data and NoSQL enthusiast

NYC Storm meetup organizer

@edvorkin

Page 3: Testing Storm components with Groovy and Spock

Testing is annoying to the typical programmer.

Programmers are driven to create things, build products, add features, and make things work.

Testing is just the opposite. It's about finding weaknesses, exploiting edge cases and making it breaks.

"It works on my machine"

Page 4: Testing Storm components with Groovy and Spock

How to make testing Java applications easy and fast?

"It works on my machine"

Page 5: Testing Storm components with Groovy and Spock

Groovy - more productive Java

Compiles to byte code

Easy to pick up by Java developers

Reuse of Java semantics and API

Page 6: Testing Storm components with Groovy and Spock

Concise syntax

Page 7: Testing Storm components with Groovy and Spock

Concise syntax

Page 8: Testing Storm components with Groovy and Spock

Differences from Java

Optional typing

Optional Exception handling

Optional parentheses

meta programming

Page 9: Testing Storm components with Groovy and Spock

Lambdas -> Closures• Closures are blocks of code that can be treated as

first-class objects: passed around as references, stored, executed at arbitrary times, and so on.

Page 10: Testing Storm components with Groovy and Spock

Groovy CollectionsA lot of syntax sugar and convenience methods on collections

Page 11: Testing Storm components with Groovy and Spock

JsonSlupper and XmlSlupper

Builders - Xml, Json, HTTP

Page 12: Testing Storm components with Groovy and Spock

Easy to work with SQL

Page 13: Testing Storm components with Groovy and Spock

IDE Support

Page 14: Testing Storm components with Groovy and Spock

How to get started?

Page 15: Testing Storm components with Groovy and Spock

How to get started?

Write tests!

Not a production code, easy to get approval.

Page 16: Testing Storm components with Groovy and Spock

WHICH TESTING FRAMEWORK CAN I USE

WITH GROOVY?

SPOCK - BEHAVIOR-DRIVEN TESTING FRAMEWORK

Page 17: Testing Storm components with Groovy and Spock

Spock Testing Framework

Expressive testing language

Easy to Learn

Reduce the line of test code

Leverage Groovy

Productivity

Structural blocks - BDD style -context, stimulus, expectation

Page 18: Testing Storm components with Groovy and Spock

BDD Style

Page 19: Testing Storm components with Groovy and Spock

BDD Style

Page 20: Testing Storm components with Groovy and Spock

Mock and Interaction verification

Page 21: Testing Storm components with Groovy and Spock

StubbingStubbing is the act of making collaborators respond to method calls in a certain way.

Page 22: Testing Storm components with Groovy and Spock

Testing Storm components

Page 23: Testing Storm components with Groovy and Spock

Testing Storm components

Page 24: Testing Storm components with Groovy and Spock

Bolt under the test

Page 25: Testing Storm components with Groovy and Spock

Demo

Page 26: Testing Storm components with Groovy and Spock

Test Code

Page 27: Testing Storm components with Groovy and Spock

Test Code

Page 28: Testing Storm components with Groovy and Spock

Some ideas

Treat Storm components as regular functions

Use backtype.storm.Testing

Use Spock Mocks, Stubs and Interactions

https://github.com/xumingming/storm-lib/blob/master/src/jvm/storm/TestingApiDemo.java

Page 29: Testing Storm components with Groovy and Spock

Resources

Page 30: Testing Storm components with Groovy and Spock

Resources

http://docs.spockframework.org/en/latest/

http://groovy.codehaus.org/

http://vimeo.com/43808772 - Venkat Subramaniam - Caring about Code Quality

Storm Real-time Processing Cookbook by Quinton Anderson

Page 31: Testing Storm components with Groovy and Spock

THANKS.