$30 off During Our Annual Pro Sale. View Details »

Distributed RSpec

Kenta Murata
September 16, 2012

Distributed RSpec

COOKPAD's approach to reduce spending times of developer-tests and CI.

Kenta Murata

September 16, 2012
Tweet

More Decks by Kenta Murata

Other Decks in Technology

Transcript

  1. Distributed RSpec
    Kenta Murata@COOKPAD
    Sunday, September 16, 12

    View Slide

  2. Sunday, September 16, 12

    View Slide

  3. Self-introduction
    Sunday, September 16, 12

    View Slide

  4. Photo by Masahiro Ihara
    Sunday, September 16, 12

    View Slide

  5. Photo by Masahiro Ihara
    Kenta Murata
    @mrkn
    COOKPAD Inc.
    Development Infrastructure Engineer
    CRuby committer
    bigdecimal support
    Asakusa.rb
    RubySapporo
    RailsGirlsTokyo (coach)
    Sunday, September 16, 12

    View Slide

  6. My responsibilities in
    COOKPAD
    • Testing environment
    • CI environment
    • Ruby and Rails version up
    Sunday, September 16, 12

    View Slide

  7. Dev-infra team
    Boss Full-time Part-time
    Sunday, September 16, 12

    View Slide

  8. Dev-infra team
    Boss Full-time Part-time
    Sunday, September 16, 12

    View Slide

  9. Distributed RSpec
    Kenta Murata@COOKPAD
    Sunday, September 16, 12

    View Slide

  10. Sunday, September 16, 12

    View Slide

  11. Monthly visitors are over 20M
    Recipes are over 1,200k
    Sunday, September 16, 12

    View Slide

  12. $ ree_be rake stats
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Controllers | 16708 | 13381 | 154 | 1153 | 7 | 9 |
    | Helpers | 6228 | 5179 | 0 | 508 | 0 | 8 |
    | Models | 38665 | 30777 | 861 | 3248 | 3 | 7 |
    | Libraries | 29363 | 23740 | 238 | 2189 | 9 | 8 |
    | Functional tests | 9 | 7 | 1 | 0 | 0 | 0 |
    | Unit tests | 72 | 54 | 10 | 0 | 0 | 0 |
    | Integration specs | 21207 | 17381 | 2 | 83 | 41 | 207 |
    | Chanko specs | 15700 | 13030 | 1 | 103 | 103 | 124 |
    | Model specs | 22247 | 18297 | 3 | 35 | 11 | 520 |
    | Controller specs | 17061 | 14080 | 6 | 49 | 8 | 285 |
    | Helper specs | 588 | 507 | 0 | 0 | 0 | 0 |
    | Routing specs | 128 | 102 | 1 | 1 | 1 | 100 |
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Total | 167976 | 136535 | 1277 | 7369 | 5 | 16 |
    +----------------------+-------+-------+---------+---------+-----+-------+
    Code LOC: 73077 Test LOC: 63458 Code to Test Ratio: 1:0.9
    Sunday, September 16, 12

    View Slide

  13. $ ree_be rake stats
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Controllers | 16708 | 13381 | 154 | 1153 | 7 | 9 |
    | Helpers | 6228 | 5179 | 0 | 508 | 0 | 8 |
    | Models | 38665 | 30777 | 861 | 3248 | 3 | 7 |
    | Libraries | 29363 | 23740 | 238 | 2189 | 9 | 8 |
    | Functional tests | 9 | 7 | 1 | 0 | 0 | 0 |
    | Unit tests | 72 | 54 | 10 | 0 | 0 | 0 |
    | Integration specs | 21207 | 17381 | 2 | 83 | 41 | 207 |
    | Chanko specs | 15700 | 13030 | 1 | 103 | 103 | 124 |
    | Model specs | 22247 | 18297 | 3 | 35 | 11 | 520 |
    | Controller specs | 17061 | 14080 | 6 | 49 | 8 | 285 |
    | Helper specs | 588 | 507 | 0 | 0 | 0 | 0 |
    | Routing specs | 128 | 102 | 1 | 1 | 1 | 100 |
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Total | 167976 | 136535 | 1277 | 7369 | 5 | 16 |
    +----------------------+-------+-------+---------+---------+-----+-------+
    Code LOC: 73077 Test LOC: 63458 Code to Test Ratio: 1:0.9
    Sunday, September 16, 12

    View Slide

  14. $ ree_be rake stats
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Controllers | 16708 | 13381 | 154 | 1153 | 7 | 9 |
    | Helpers | 6228 | 5179 | 0 | 508 | 0 | 8 |
    | Models | 38665 | 30777 | 861 | 3248 | 3 | 7 |
    | Libraries | 29363 | 23740 | 238 | 2189 | 9 | 8 |
    | Functional tests | 9 | 7 | 1 | 0 | 0 | 0 |
    | Unit tests | 72 | 54 | 10 | 0 | 0 | 0 |
    | Integration specs | 21207 | 17381 | 2 | 83 | 41 | 207 |
    | Chanko specs | 15700 | 13030 | 1 | 103 | 103 | 124 |
    | Model specs | 22247 | 18297 | 3 | 35 | 11 | 520 |
    | Controller specs | 17061 | 14080 | 6 | 49 | 8 | 285 |
    | Helper specs | 588 | 507 | 0 | 0 | 0 | 0 |
    | Routing specs | 128 | 102 | 1 | 1 | 1 | 100 |
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Total | 167976 | 136535 | 1277 | 7369 | 5 | 16 |
    +----------------------+-------+-------+---------+---------+-----+-------+
    Code LOC: 73077 Test LOC: 63458 Code to Test Ratio: 1:0.9
    861 Models
    Sunday, September 16, 12

    View Slide

  15. $ ree_be rake stats
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Controllers | 16708 | 13381 | 154 | 1153 | 7 | 9 |
    | Helpers | 6228 | 5179 | 0 | 508 | 0 | 8 |
    | Models | 38665 | 30777 | 861 | 3248 | 3 | 7 |
    | Libraries | 29363 | 23740 | 238 | 2189 | 9 | 8 |
    | Functional tests | 9 | 7 | 1 | 0 | 0 | 0 |
    | Unit tests | 72 | 54 | 10 | 0 | 0 | 0 |
    | Integration specs | 21207 | 17381 | 2 | 83 | 41 | 207 |
    | Chanko specs | 15700 | 13030 | 1 | 103 | 103 | 124 |
    | Model specs | 22247 | 18297 | 3 | 35 | 11 | 520 |
    | Controller specs | 17061 | 14080 | 6 | 49 | 8 | 285 |
    | Helper specs | 588 | 507 | 0 | 0 | 0 | 0 |
    | Routing specs | 128 | 102 | 1 | 1 | 1 | 100 |
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Total | 167976 | 136535 | 1277 | 7369 | 5 | 16 |
    +----------------------+-------+-------+---------+---------+-----+-------+
    Code LOC: 73077 Test LOC: 63458 Code to Test Ratio: 1:0.9
    17381 Integration spec LOC
    Sunday, September 16, 12

    View Slide

  16. $ ree_be rake stats
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Controllers | 16708 | 13381 | 154 | 1153 | 7 | 9 |
    | Helpers | 6228 | 5179 | 0 | 508 | 0 | 8 |
    | Models | 38665 | 30777 | 861 | 3248 | 3 | 7 |
    | Libraries | 29363 | 23740 | 238 | 2189 | 9 | 8 |
    | Functional tests | 9 | 7 | 1 | 0 | 0 | 0 |
    | Unit tests | 72 | 54 | 10 | 0 | 0 | 0 |
    | Integration specs | 21207 | 17381 | 2 | 83 | 41 | 207 |
    | Chanko specs | 15700 | 13030 | 1 | 103 | 103 | 124 |
    | Model specs | 22247 | 18297 | 3 | 35 | 11 | 520 |
    | Controller specs | 17061 | 14080 | 6 | 49 | 8 | 285 |
    | Helper specs | 588 | 507 | 0 | 0 | 0 | 0 |
    | Routing specs | 128 | 102 | 1 | 1 | 1 | 100 |
    +----------------------+-------+-------+---------+---------+-----+-------+
    | Total | 167976 | 136535 | 1277 | 7369 | 5 | 16 |
    +----------------------+-------+-------+---------+---------+-----+-------+
    Code LOC: 73077 Test LOC: 63458 Code to Test Ratio: 1:0.9
    13030 Chanko spec LOC
    Sunday, September 16, 12

    View Slide

  17. Chanko
    How COOKPAD safely releases
    multiple feature prototypes - in production -
    for test segments of their 15 million engaged users
    @mrkn (Kenta Murata), @shingo (Shingo Morita)
    http://www.flickr.com/photos/june29/3396011694/
    http://www.confreaks.com/events/railsconf2012
    https://speakerdeck.com/u/mrkn/p/chanko
    Sunday, September 16, 12

    View Slide

  18. After Chanko
    IDEA
    BUILD
    Limited release
    IDEA
    MEASURE
    Public release
    RELEASE
    http://photozou.jp/photo/show/606813/95100763 http://photozou.jp/photo/show/276167/58451178
    BUILD
    LEARN
    https://speakerdeck.com/u/mrkn/p/chanko?slide=20
    Sunday, September 16, 12

    View Slide

  19. About 10 teams
    1-3 developers per team
    Sunday, September 16, 12

    View Slide

  20. After Chanko
    IDEA
    BUILD
    Limited release
    IDEA
    MEASURE
    Public release
    RELEASE
    http://photozou.jp/photo/show/606813/95100763 http://photozou.jp/photo/show/276167/58451178
    BUILD
    LEARN
    https://speakerdeck.com/u/mrkn/p/chanko?slide=20
    Sunday, September 16, 12

    View Slide

  21. How to shorten the waiting
    time until a change gets
    deployable?
    Sunday, September 16, 12

    View Slide

  22. Continuous Integration
    should be enough fast
    Necessary condition
    Sunday, September 16, 12

    View Slide

  23. git push git push
    CI
    git
    Sunday, September 16, 12

    View Slide

  24. git push
    build #k
    10min
    git push
    CI
    git
    Sunday, September 16, 12

    View Slide

  25. git push
    build #k build #k+1
    10min 10min
    git push
    CI
    git
    Sunday, September 16, 12

    View Slide

  26. git push
    build #k build #k+1
    10min 10min
    git push
    CI
    git
    This commit can be deployed after 20min
    Sunday, September 16, 12

    View Slide

  27. git push
    build #k build #k+1
    N min N min
    git push
    CI
    git
    This commit can be deployed after 2N min
    Sunday, September 16, 12

    View Slide

  28. The maximum CI waiting minutes 2N min
    Prescribed working time
    8 hours
    == 480 min
    The maximum count of deploy
    480 / 2N
    == 240 / N
    N : The CI waiting time to deploy 40 times
    240 / 40
    == 6 min
    Sunday, September 16, 12

    View Slide

  29. The maximum CI waiting minutes 2N min
    Prescribed working time
    8 hours
    == 480 min
    The maximum count of deploy
    480 / 2N
    == 240 / N
    N : The CI waiting time to deploy 40 times
    240 / 40
    == 6 min
    Sunday, September 16, 12

    View Slide

  30. The maximum CI waiting minutes 2N min
    Prescribed working time
    8 hours
    == 480 min
    The maximum count of deploy
    480 / 2N
    == 240 / N
    N : The CI waiting time to deploy 40 times
    240 / 40
    == 6 min
    Sunday, September 16, 12

    View Slide

  31. The maximum CI waiting minutes 2N min
    Prescribed working time
    8 hours
    == 480 min
    The maximum count of deploy
    480 / 2N
    == 240 / N
    N : The CI waiting time to deploy 40 times
    240 / 40
    == 6 min
    Sunday, September 16, 12

    View Slide

  32. Developers should guarantee their
    changes doesn’t break any tests
    when they pushes the changes
    into the master branch.
    Sunday, September 16, 12

    View Slide

  33. The test system for the developers
    should provide an environment
    which isn’t broken by
    simultaneous test executions.
    Necessary condition
    Sunday, September 16, 12

    View Slide

  34. Of course developer testing
    should be enough fast, too.
    Necessary condition
    Sunday, September 16, 12

    View Slide

  35. Three conditions
    • CI should be fast
    • Developer-testing environment should be
    available for simultaneous executions
    • Developer-testing should be fast
    Sunday, September 16, 12

    View Slide

  36. 6000
    6500
    7000
    7500

































    ● ●





































































































    ● ●●




























































































































    ● ●●●

























































































































    ● ●


    ●●





















































































































































    ●●
    ● ●




















































































































    ● ●






















    ●●
































































































    ● ●




































































































    ●●
    ● ●




















































































































    ● ●





























    05/01 06/01 07/01
    Ti
    Examples count
    6000
    6500
    7000
    7500

































    ● ●





































































































    ● ●●




























































































































    ● ●●●

























































































































    ● ●


    ●●





















































































































































    ●●
    ● ●




















































































































    ● ●






















    ●●
































































































    ● ●




































































































    ●●
    ● ●




















































































































    ● ●


































    05/01 06/01 07/01
    Ti
    Examples count
    The number of examples in
    COOKPAD’s spec les
    Sunday, September 16, 12

    View Slide

  37. ●●●

























































































































    ● ●


    ●●





















































































































































    ●●
    ● ●




















































































































    ● ●






















    ●●
































































































    ● ●




































































































    ●●
    ● ●




















































































































    ● ●











































































































    ● ●





































































































    ●●

    ● ●


























































































    ● ●








































































































    ● ●







































































































    06/01 07/01 08/01
    Timestamp
    6000
    6500
    7000
    7500

































    ● ●





































































































    ● ●●




























































































































    ● ●●●

























































































































    ● ●


    ●●





















































































































































    ●●
    ● ●




















































































































    ● ●






















    ●●
































































































    ● ●




































































































    ●●
    ● ●




















































































































    ● ●


































    05/01 06/01 07/01
    Ti
    Examples count
    The number of examples in
    COOKPAD’s spec les
    Sunday, September 16, 12

    View Slide




















  38. ● ●





































































































    ●●

    ● ●


























































































    ● ●








































































































    ● ●






































































































    ● ●



































    ●●








































    ● ●


















































































    ●●









    ● ●






































































    ● ●






















































    ●●











    ● ● ●













































































    ● ●






























    08/01 09/01
    estamp
    6000
    6500
    7000
    7500

































    ● ●





































































































    ● ●●




























































































































    ● ●●●

























































































































    ● ●


    ●●





















































































































































    ●●
    ● ●




















































































































    ● ●






















    ●●
































































































    ● ●




































































































    ●●
    ● ●




















































































































    ● ●


































    05/01 06/01 07/01
    Ti
    Examples count
    The number of examples in
    COOKPAD’s spec les
    Sunday, September 16, 12

    View Slide

  39. ThreeFour conditions
    • CI should be fast
    • Developer-testing environment should be
    available for simultaneous executions
    • Developer-testing should be fast
    • The system should be able to scale out for
    increasing tests
    Sunday, September 16, 12

    View Slide

  40. Remote spec
    and
    Distributed CI
    The solutions in COOKPAD
    Sunday, September 16, 12

    View Slide

  41. ͍·Կ͔࣌ͳʁ
    Distributed RSpec in
    COOKPAD
    Sunday, September 16, 12

    View Slide

  42. From here
    • The mechanisms of the current remote spec
    • The problems of the current remote spec
    • The future remote spec
    Sunday, September 16, 12

    View Slide

  43. Big Procedural Flow
    1. Rsync the application’s code tree
    2. Prepare workers’ environment
    • MySQL and Solr
    3. Run RSpec remotely
    Sunday, September 16, 12

    View Slide

  44. 1. Grouping spec les so that each the group has
    almost same execution time based on the last
    execution time log
    2. Executing RSpec for each the group on the
    remote workers via ssh
    3. Results of RSpec is collected via pipe, and
    displayed so that the user can easily distinguish
    which worker makes the results.
    How to distribute
    Sunday, September 16, 12

    View Slide

  45. spec_execution_times.log
    ./spec/models/country_spec.rb:0.239013
    ./spec/integration/pr/event_spec.rb:11.48333
    ./spec/integration/recipes_spec.rb:159.893117
    ./spec/integration/device/info_spec.rb:3.592802
    ./spec/libs/symboliclink_check_spec.rb:2.024438
    ./spec/controllers/advertisement_module_2_spec.rb:27.125839
    ./spec/libs/mail_functions_spec.rb:0.123556
    ./spec/models/generic_recipe_spec.rb:0.716866
    ./spec/libs/ruby_syntax_spec.rb:18.92995
    ./spec/libs/cookpad_logger_spec.rb:0.233645
    ./spec/controllers/device/myfolder_controller_spec.rb:7.037313
    ./spec/integration/trend_keyword_spec.rb:1.224577
    ./spec/models/search_category_recipe_spec.rb:2.82474
    ./spec/controllers/hello_controller_spec.rb:0.846888
    ./spec/controllers/api_controller_spec.rb:0.936871
    ./spec/integration/recipes_hot_notification_spec.rb:27.260698
    ./spec/models/diary_mailer_spec.rb:1.156989
    (snip)
    Sunday, September 16, 12

    View Slide

  46. spec_execution_times.log
    • Execution times are recorded for each
    spec le.
    • An execution time of a spec le is de ned
    as one of the top-level example group in
    the spec le.
    Sunday, September 16, 12

    View Slide

  47. Condition Execution time
    single rspec too long; unmeasurable
    8-core parallel_tests over 1 hour
    5 workers,
    each have 6-cores
    about 15 min
    Sunday, September 16, 12

    View Slide

  48. 6000
    6500
    7000
    7500

































    ● ●





































































































    ● ●●




























































































































    ● ●●●

























































































































    ● ●


    ●●





















































































































































    ●●
    ● ●




















































































































    ● ●






















    ●●
































































































    ● ●




































































































    ●●
    ● ●




















































































































    ● ●





























    05/01 06/01 07/01
    Ti
    Examples count
    6000
    6500
    7000
    7500

































    ● ●





































































































    ● ●●




























































































































    ● ●●●

























































































































    ● ●


    ●●





















































































































































    ●●
    ● ●




















































































































    ● ●






















    ●●
































































































    ● ●




































































































    ●●
    ● ●




















































































































    ● ●


































    05/01 06/01 07/01
    Ti
    Examples count
    The number of examples in
    COOKPAD’s spec les
    Sunday, September 16, 12

    View Slide







































































































  49. ●●

    ● ●


























































































    ● ●








































































































    ● ●






































































































    ● ●



































    ●●








































    ● ●


















































































    ●●









    ● ●






































































    ● ●






















































    ●●











    ● ● ●













































































    ● ●






























    08/01 09/01
    stamp
    6000
    6500
    7000
    7500

































    ● ●





































































































    ● ●●




























































































































    ● ●●●

























































































































    ● ●


    ●●





















































































































































    ●●
    ● ●




















































































































    ● ●






















    ●●
































































































    ● ●




































































































    ●●
    ● ●




















































































































    ● ●


































    05/01 06/01 07/01
    Ti
    Examples count
    The number of examples in
    COOKPAD’s spec les
    Sunday, September 16, 12

    View Slide

  50. Sunday, September 16, 12

    View Slide

  51. Real execution time
    $ grep cookpad:spec ci.log
    (11) cookpad:spec --> 0.020000 0.130000 495.010000 (164.655632)
    (07) cookpad:spec --> 0.020000 0.120000 493.490000 (166.317008)
    (03) cookpad:spec --> 0.020000 0.120000 604.060000 (217.101263)
    (12) cookpad:spec --> 0.020000 0.130000 711.730000 (217.371807)
    (10) cookpad:spec --> 0.020000 0.130000 550.990000 (224.883867)
    (08) cookpad:spec --> 0.020000 0.130000 632.330000 (226.134510)
    (04) cookpad:spec --> 0.010000 0.130000 615.030000 (233.176576)
    (06) cookpad:spec --> 0.020000 0.120000 592.900000 (232.820875)
    (01) cookpad:spec --> 0.020000 0.130000 562.510000 (242.002139)
    (13) cookpad:spec --> 0.020000 0.130000 560.200000 (241.834410)
    (09) cookpad:spec --> 0.030000 0.120000 750.040000 (268.914216)
    (00) cookpad:spec --> 0.020000 0.130000 692.820000 (280.803856)
    (05) cookpad:spec --> 0.020000 0.140000 726.640000 (289.625570)
    (02) cookpad:spec --> 0.010000 0.130000 679.850000 (437.498087)
    Sunday, September 16, 12

    View Slide

  52. Wrong balancing
    • The execution time on each worker was
    varied.
    • Runtime conditions of servers affected the
    execution times.
    • I retired the way to divide spec les into
    groups before executing RSpec.
    Sunday, September 16, 12

    View Slide

  53. Dynamic distributing
    • I need the method to distribute spec les
    dynamically according to runtime
    conditions of workers
    • The answer is Producer-Consumer pattern
    Sunday, September 16, 12

    View Slide

  54. Producer-Consumer pattern
    • The basic way to implement parallel task
    processing.
    • Producers produce tasks and enqueue
    them into a queue.
    • Consumers dequeue tasks from the
    queue, and processes them.
    Sunday, September 16, 12

    View Slide

  55. The Producer-Consumer Pattern
    Sunday, September 16, 12

    View Slide

  56. By this pattern
    • Slow workers process fewer tasks than the
    others.
    • Fast workers process much more tasks
    than the others.
    • As a result the execution times of workers
    are almost same.
    Sunday, September 16, 12

    View Slide

  57. The Producer-Consumer Pattern
    spec le
    spec
    le
    Sunday, September 16, 12

    View Slide

  58. I implemented it
    • Using dRuby and Rinda::TupleSpace
    • Producer and consumers communicate
    with each other via a queue represented
    by Rinda::TupleSpace
    • On workers, dRuby gateway is executed
    via ssh, and the gateway process launches
    each consumer DRbObject.
    Sunday, September 16, 12

    View Slide

  59. Consumer process
    • A consumer takes a spec le from a queue,
    a TupleSpace, and execute it.
    • I want to avoid spending time for
    generating a new process and loading and
    initializing Rails environment by executing
    “rspec” command.
    • I need to use rspec abnormally.
    Sunday, September 16, 12

    View Slide

  60. Time is up
    Sunday, September 16, 12

    View Slide

  61. RSpec::Core::CommandLine#run
    def run
    ...
    @configuration.load_spec_files
    @world.announce_filters
    @configuration.reporter.report(...) do |reporter|
    begin
    @configuration.run_hook(:before, :suite)
    @world.example_groups.ordered.map {|g|
    g.run(reporter)
    }.all? ? 0 : @configuration.failure_exit_code
    ensure
    @configuration.run_hook(:after, :suite)
    end
    end
    end
    Sunday, September 16, 12

    View Slide

  62. RSpec::Core::CommandLine#run
    def run
    ...
    @configuration.load_spec_files
    @world.announce_filters
    @configuration.reporter.report(...) do |reporter|
    begin
    @configuration.run_hook(:before, :suite)
    @world.example_groups.ordered.map {|g|
    g.run(reporter)
    }.all? ? 0 : @configuration.failure_exit_code
    ensure
    @configuration.run_hook(:after, :suite)
    end
    end
    end
    Sunday, September 16, 12

    View Slide

  63. RSpec::Core::CommandLine#run
    def run
    ...
    @configuration.load_spec_files
    @world.announce_filters
    @configuration.reporter.report(...) do |reporter|
    begin
    @configuration.run_hook(:before, :suite)
    @world.example_groups.ordered.map {|g|
    g.run(reporter)
    }.all? ? 0 : @configuration.failure_exit_code
    ensure
    @configuration.run_hook(:after, :suite)
    end
    end
    end
    Sunday, September 16, 12

    View Slide

  64. RSpec::Core::CommandLine#initialize
    # RSpec::Core::CommandLine#initialize
    def initialize(options,
    configuration=RSpec::configuration,
    world=RSpec::world)
    ...
    @world = world
    end
    # RSpec::Core::Runner.run
    def run(...)
    ...
    CommandLine.new(options).run(err, out)
    ...
    end
    # RSpec.world
    def self.world
    @world ||= RSpec::Core::World.new
    end
    Sunday, September 16, 12

    View Slide

  65. Normally RSpec
    • Example groups are de ned in global
    RSpec::Core::World object
    • Running example groups in the global
    RSpec::Core::World object is running
    examples.
    Sunday, September 16, 12

    View Slide

  66. Abnormally RSpec
    • Need to load a single spec le, run
    example groups only de ned in the spec
    le, and clear the all example groups from
    the global RSpec environment.
    • RSpec::Core::World#clear does it.
    Sunday, September 16, 12

    View Slide

  67. Consumer’s main loop
    def main
    loop do
    _, spec_file = @tuple_space.take [:spec_file, String]
    load File.expand_path(spec_file)
    begin
    @configuration.run_hook(:before, :suite)
    @world.example_groups.ordered.map {|g|
    g.run(reporter)
    }.all? ? 0 : @configuration.failure_exit_code
    ensure
    @configuration.run_hook(:after, :suite)
    @world.clear
    end
    end
    end
    Sunday, September 16, 12

    View Slide

  68. remote_spec.gem
    Sunday, September 16, 12

    View Slide

  69. remote_spec.gem
    com
    ing
    soon
    Sunday, September 16, 12

    View Slide

  70. Conclusion
    • Testing facilities in COOKPAD are
    introduced
    • The mechanisms of distributed RSpec in
    COOKPAD are introduced
    • My current attempts don’t get in time.
    • remote_spec.gem is coming soon.
    Sunday, September 16, 12

    View Slide