Mocking the cloud
Michael Neale
@michaelneale
github.com/michaelneale
@cloudbees
 Hosted apps (PaaS a la GAE etc)
 Jenkins/hudson “as a service”
 lotsa elastic servers, variable load
 in production !
Where scala:
 Provisioning:
 Build servers, masters, new hosts, allocation
 “cloud controller” app
 Some Play! framework, some maven
CloudBees

     controller                  providore      storage


App pool    DB clusters   Master pool   Slave pool




                  scala
Why scala?
 Easy !
 * Saved time (early startup - I had to wear
 lots of hats)
 * Types help hard to reach (test) places
 * And why not
Result?
 New staff come on, able to contribute,
 maintain.
 No issues.
 But they aren’t idiots.
Next time?
Seriously look at scala “native” things (akka)

Avoid faux-oo
 - instead use objects as namespaces

Monadic IO - Monadic server/cloud
operations?
server = do
        instance = launch_server "image-id"
        volume = create_volume_for instance "10G"
        return attach_volume instance volume
To the cloud
 (jclouds + scala)

 Avert your eyes children...
CloudClient
 “Discovered” semantics:
 Start, Stop, List, Status, Volume Create,
 Attach etc..
 Create own easily mockable cloud api (trait)
 Don’t try this at home...

 (EBS sob stories for another time - pushed
 provisioning api to the limit)
Mockito + Scalatest
 Runs nicely in IDEA runner

 TestX extends ShouldMatchers (scalatest)
 import org.mockito.{Matchers, ArgumentCaptor}
Also: the REPL
 Invaluable:

 Controlled “live” testing
 Explore api behaviors, inspect
 Data in “hazelcast” - reload new version, continue
 Testing with real things == expensive

Scala sydoct2011

  • 1.
    Mocking the cloud MichaelNeale @michaelneale github.com/michaelneale
  • 3.
    @cloudbees Hosted apps(PaaS a la GAE etc) Jenkins/hudson “as a service” lotsa elastic servers, variable load in production !
  • 4.
    Where scala: Provisioning: Build servers, masters, new hosts, allocation “cloud controller” app Some Play! framework, some maven
  • 5.
    CloudBees controller providore storage App pool DB clusters Master pool Slave pool scala
  • 6.
    Why scala? Easy! * Saved time (early startup - I had to wear lots of hats) * Types help hard to reach (test) places * And why not
  • 7.
    Result? New staffcome on, able to contribute, maintain. No issues. But they aren’t idiots.
  • 8.
    Next time? Seriously lookat scala “native” things (akka) Avoid faux-oo - instead use objects as namespaces Monadic IO - Monadic server/cloud operations?
  • 9.
    server = do instance = launch_server "image-id" volume = create_volume_for instance "10G" return attach_volume instance volume
  • 10.
    To the cloud (jclouds + scala) Avert your eyes children...
  • 12.
    CloudClient “Discovered” semantics: Start, Stop, List, Status, Volume Create, Attach etc.. Create own easily mockable cloud api (trait) Don’t try this at home... (EBS sob stories for another time - pushed provisioning api to the limit)
  • 13.
    Mockito + Scalatest Runs nicely in IDEA runner TestX extends ShouldMatchers (scalatest) import org.mockito.{Matchers, ArgumentCaptor}
  • 20.
    Also: the REPL Invaluable: Controlled “live” testing Explore api behaviors, inspect Data in “hazelcast” - reload new version, continue Testing with real things == expensive