Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Oscon 2012 tdd_cassandra

1,343 views

Published on

Test driven development with maven, JUnit and Apache Cassandra (and distributed systems in general)

Published in: Technology, Business
  • Be the first to comment

Oscon 2012 tdd_cassandra

  1. 1. TDD With Apache CassandraNate Mccall@zznate
  2. 2. Hi.
  3. 3. We are talking abouttwo things...
  4. 4. 1. Test DrivenDevelopment(TDD)
  5. 5. 2. Apache Cassandra
  6. 6. ...and how difficult itis to put themtogether
  7. 7. TDD
  8. 8. Unit testing (Integration Testing)
  9. 9. Unit Testing: F.I.R.S.T.
  10. 10. F astI solatedR epeatableS elf-validatingT imely
  11. 11. Integration Testing
  12. 12. Run less oftenFewer of them
  13. 13. Cassandra
  14. 14. (not an acronym)
  15. 15. Distributed, highperformancedatabase
  16. 16. Two problems withthat...
  17. 17. 1. “Distributed”
  18. 18. 2. “Database”
  19. 19. Specifically
  20. 20. Configurations andbehavior tied toenvironment
  21. 21. Heavy weightresourcerequirements
  22. 22. Failures difficult tosimulate
  23. 23. Applying TDD
  24. 24. But first: a dirtysecret to share...
  25. 25. I’m Doing it wrong
  26. 26. 3 minutes for onemodule
  27. 27. The Culprit:EmbeddedCassandraHelper
  28. 28. Easy to setupKnown state per testClient setup is easy
  29. 29. SlowwwwwLots of fixture codeHacking cassandra lifecycle
  30. 30. mvn install -DskipTests
  31. 31. mvn install -DskipTestsFail.
  32. 32. How can I solve this?
  33. 33. “Refactoring tests”
  34. 34. Pro tip:propose it as aconference topic :)
  35. 35. So some time hasbeen weaseled...
  36. 36. What other tools areavailable?
  37. 37. cassandra-maven-plugincassandra-unit
  38. 38. 2nd dirty secret...
  39. 39. I’ve contributed to bothprojects :(
  40. 40. Cassandra Unit
  41. 41. Easy data loading (no fixtures)Multiple formatsClient setup provided
  42. 42. Cassandra instance in processSlow on large data setsExternal instance support(not a pro for my use case)
  43. 43. Cassandra Maven Plugin
  44. 44. Cassandra(s) in forkedJVM(s)Setup/teardown (still) inmaven lifecycleMulti-node support FTW!
  45. 45. No easy means of loading bulk dataCode level fixturesManual client setup
  46. 46. Back to original issue
  47. 47. What to focus on first
  48. 48. 1. Separate unit testsfrom integration tests
  49. 49. Maven test plugins
  50. 50. Maven test plugins:surefirefailsafe
  51. 51. Maven test plugins:failfiresuresafe
  52. 52. Maven test plugins:surefailfiresafe?
  53. 53. Failsafe:For integration tests.Keeps going even if there are failures
  54. 54. Failsafe:Fails to make it easy tofind your mistake
  55. 55. Configuringexclusions
  56. 56. While i’m there...
  57. 57. There’s got to bemore to do
  58. 58. Remember the Goals:Avoid fixture codeNo per-developer configsNot in process
  59. 59. Is it just choosingbetween differenttools?
  60. 60. You got your fixturesin my plugin!
  61. 61. Cassandra-unit +cassandra-maven-plugin = WIN
  62. 62. Benefits:Maven lifecycleNo fixturesRunListeners@Rule for special case-ing
  63. 63. Maven configuration: failsafe
  64. 64. Maven configuration: Cassandra
  65. 65. RunListener code
  66. 66. Parallel *allthethings*
  67. 67. I can has cluster!
  68. 68. $ sudo ifconfig lo0 alias 127.0.0.2 up$ sudo ifconfig lo0 alias 127.0.0.3 up$ sudo ifconfig lo0 alias 127.0.0.4 up
  69. 69. $ mvn cassandra:start-cluster cassandra:run
  70. 70. Next Steps...
  71. 71. Next Steps...(am i really this psyched abouttesting?)
  72. 72. Instrumentation...
  73. 73. Gradle(or: How I sat next to TimBerglund at lunch)
  74. 74. Gradle... found my next proposal :)
  75. 75. aws-java-sdk.jar +cassandra launcher =AWESOME
  76. 76. ... yep, this one too.
  77. 77. Continue to contribute
  78. 78. ContinuetoContribute
  79. 79. Questions?

×