Your SlideShare is downloading. ×
0
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
VodQA_Parallelizingcukes_AmanKing
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

VodQA_Parallelizingcukes_AmanKing

486

Published on

This was a full-length talk presented by Aman King in vodQA-3 : A QA Meet held in ThoughtWorks, Pune.

This was a full-length talk presented by Aman King in vodQA-3 : A QA Meet held in ThoughtWorks, Pune.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
486
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • * Green icon represents a stable green CI build * Orange icon represents a CI build in progress * Red icon represents a broken CI build
  • * It is good to immediately know where you stand: whether all is good or something is broken * That’d enable you to fix something almost as soon as you break it
  • * High functional coverage implies that almost all functionality of the system is tested and any error introduced would be caught * Short CI build time implies that quick feedback is in place and any error introduced in the covered functionality would be immediately highlighted
  • * A website with a lot of content that comes from various sources, with a focus on creating an online community of people with similar interests
  • * Failures not caused by programmatic errors: possible reasons could include AJAX response delays, unpredictable browser responsiveness, network slowness, etc
  • * If a build is broken on what appears to be non-deterministic failure, someone will have to manually trigger another build in hope of the error not reoccurring * A retriggered build will take long again, further delaying feedback
  • * One main process will fork multiple sub-processes in parallel, each running only a subset of the original collection of test scenarios * When all sub-processes complete, the union of their results will be the final result of the entire test run * If the sub-processes are run on the same machine, a powerful multicore machine is desirable *Another approach is to run the sub-processes on different machines on a grid
  • * Chart of build times vs build numbers: the drastic drop is when parallelization was implemented * Slight variances in build times, including minor drops, also occur based on memory and CPU load at the time
  • * Used a Ruby library called parallel_tests to fork multiple Ruby processes, each running a subset of Cucumber features * This also involved coming up with custom rake tasks, including multiple pre-steps and post-steps * Instead of using parallel_tests to parallelize on the same machine, Selenium Grid is an alternate option to leverage grid computing
  • * Capture each forked process’s results independently * Generate consolidated HTML report as after-step when all forked processes finish
  • * Rails’ database.yml was modified to suffix process number to the name of the database
  • * Sunspot gem’s sunspot.yml was modified to suffix process number to the paths that Solr was to use * Monkey-patched Sunspot code to allow above parameterization in sunspot.yml
  • * Although each sub-process starts its independent Firefox instance, Selenium uses a shared set of ephemeral ports to communicate with the browsers * Contention occurs for these ephemeral ports which get locked when in use for a particular Firefox instance * Monkey-patched Capybara’s Selenium driver code to retry communicating with Firefox if a couple of attempts fail
  • * A particular machine can only allow so much parallelization based on its hardware specifications * Beyond a certain number of sub-processes, the non-deterministic failures will increase * After a few tries, we stabilized on having 6 concurrent sub-processes on the machine we were using
  • * Cucumber provides a rerun mode which retries all failed tests one more time before deciding the final status of the test suite run * Customized a rake task to invoke Cucumber’s rerun sequentially, after the parallel results come in
  • * We stubbed some external calls to return known values to cut down on communication delays * Used a Ruby library called WebMock * Examples: authentication servers, email servers, Facebook, Twitter, etc
  • * It helps to reduce the number of independent tests without reducing the functionality coverage * Example: if during sign up, email and zipcode are mandatory, they don’t need independent tests; there can be one test that begins by leaving email and zipcode empty, verifies that error messages are displayed for email and zipcode, and then adds email and zipcode, and proceeds with valid sign up scenarios * The above reduces browser clearing steps, visiting a certain page repeatedly without it contributing to the test steps, and so on
  • * There are multiple benefits of having quick feedback; implementing parallelization is one approach to achieve that * A complementary approach is to introspect and work on improving performance and responsiveness of the app itself, reducing build time by reducing waiting time * Being aware of build times and improving the same continuously is a good habit; even with parallelization in place, as more functionality gets added, build times will creep up
  • Transcript

    1. Saturday, 26 th March, 2011
    2. Reducing build time when patience is not a virtue <ul><li>Aman King </li></ul><ul><li>Application Developer </li></ul><ul><li>Thought Works </li></ul>
    3. Recognize these?
    4. Rank these
    5. Did you choose this? 1 3 2
    6. Or did you choose this? 1 2 3
    7. Patience is not always a virtue!
    8. Fail fast! quick feedback
    9. Rank these <ul><li>High functional coverage </li></ul><ul><li>Short build time </li></ul>
    10. Did you choose this? <ul><li>High functional coverage </li></ul><ul><li>Short build time </li></ul>
    11. Or did you choose this? <ul><li>Short build time </li></ul><ul><li>High functional coverage </li></ul>
    12. You can choose both! <ul><li>Short build time </li></ul><ul><li>High functional coverage </li></ul>
    13. But before we see how…
    14. Project background
    15. Content driven, community oriented website
    16. Ruby on Rails Cucumber + Capybara + Selenium
    17. 4 : 1 ratio of Dev : QA Everyone writes functional tests in a common automation suite Acceptance Test Driven Development (ATDD)
    18. Our problems
    19. Long build time ~ 55 minutes
    20. Non-deterministic failures
    21. Manual reruns needed
    22. Our solution: Parallelization
    23. Basic idea
    24. Reduced build time ~ 5 minutes
    25. Build time chart
    26. What we did
    27. Parallelization on a single multicore machine used Ruby library parallel_tests
    28. Report generation in parallel wrote custom report formatter
    29. Isolating databases each process needs its own database
    30. database.yml test: &test adapter: mysql2 encoding: utf8 reconnect: false database: myapp_test<%= ENV['TEST_ENV_NUMBER'] %> pool: 5 username: root password:
    31. Isolating external dependencies (Solr) each process needs its own Solr instance
    32. sunspot.yml test: solr: hostname: localhost port: <%= 8982 - ENV['TEST_ENV_NUMBER'].to_i %> log_level: INFO #WARNING log_file: <%= File.join(::Rails.root, 'log', &quot;solr_#{ENV['TEST_ENV_NUMBER'].to_i}.log&quot;) %> data_path: <%= File.join(::Rails.root, 'solr', 'data’, &quot;#{ENV['TEST_ENV_NUMBER'].to_i}&quot;) %> pid_path: <%= File.join(::Rails.root, 'solr', 'pids', &quot;#{ENV['TEST_ENV_NUMBER'].to_i}&quot;) %>
    33. Handling multiple Firefox instances and Selenium’s use of shared ephemeral ports
    34. Monitoring Memory and CPU usage adjust number of parallel process accordingly
    35. Auto rerunning failed tests non-deterministic failures are likelier with the CPU under stress
    36. Beyond parallelization…
    37. Stubbing external calls reduce dependency-related delays where avoidable
    38. Consolidating scenarios combine similar test scenarios into single runs instead of separate tests
    39. Maintaining conventions when writing automated tests avoid time-based wait statements, use test framework APIs that take lesser time, etc
    40. Conclusion
    41. Resources <ul><li>http://cukes.info </li></ul><ul><li>http://rubygems.org/gems/capybara </li></ul><ul><li>http://seleniumhq.org/projects/remote-control </li></ul><ul><li>http://rubygems.org/gems/parallel_tests </li></ul><ul><li>http://selenium-grid.seleniumhq.org </li></ul><ul><li>http://test-load-balancer.github.com </li></ul><ul><li>http://github.com/bblimke/webmock </li></ul><ul><li>http://testing.thoughtworks.com </li></ul>
    42. Thank you <ul><li>[email_address] </li></ul><ul><li>http://www.wikyblog.com/AmanKing </li></ul>

    ×