Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[Money Forward x Shippio] BaySide-Tech-Nite (May 19, 2023)

[Money Forward x Shippio] BaySide-Tech-Nite (May 19, 2023)

A LT presented at 【Money Forward x Shippio】 BaySide Tech Nite, May 19, 2023(https://moneyforward.connpass.com/event/281065/)

More Decks by Takayuki WATANABE (渡辺 喬之)

Other Decks in Programming

Transcript

  1. Optimizing tests in Ruby
    May 19, 2023
    Presented by Takayuki Watanabe
    BaySide Tech Nite

    View full-size slide

  2. Who are you?
    ▶ Takayuki Watanabe
    ▶ Software Engineer (Launchable, Inc.)
    ▶ SNS
    ▶ Blog: https://blog.takanabe.tokyo
    ▶ GitHub: takanabe
    ▶ Twitter: @takanabe_w
    ▶ Expertise
    ▶ Developer Productivity
    ▶ Site Reliability
    2

    View full-size slide

  3. Why are you here?
    3
    https://blog.takanabe.tokyo/2021/12/1338a4bc-1a89-41bb-bbaa-64546af7cfc2/

    View full-size slide

  4. Optimizing tests in Ruby
    4
    Today’s theme

    View full-size slide

  5. 5
    Plan
    CI/CD pipeline

    View full-size slide

  6. 6
    Test-heavy CI/CD pipeline
    What do you do if tests are the bottleneck in delivery pipelines?

    View full-size slide

  7. How many minutes(hours) can
    you wait for tests in CI/CD?
    7
    QUESTION

    View full-size slide

  8. 8
    Tests in different phases
    pre-merge post-merge pre-release
    minutes
    hours
    days
    E.g. tests running in pre-merge, post-merge, and pre-release
    Smaller size = smaller test suite
    Bigger size = bigger test suite

    View full-size slide

  9. 9
    Approach: Parallelization
    pre-merge post-merge pre-release
    minutes
    hours
    days
    w/ optimizations
    w/o optimizations
    Reduce time
    Reduce time
    Reduce time

    View full-size slide

  10. 10
    Approach: Parallelization in Ruby
    ▶ Use Ruby on Rails’ test parallelization (Rails 6 or later version + Minitest)
    ▶ Use third-party gems such as parallel_tests, rrrspec
    ▶ Use SaaS supporting parallel tests such as CircleCI

    View full-size slide

  11. 11
    Approach: Shift-left testing
    pre-merge post-merge pre-release
    minutes
    hours
    days
    w/ optimizations
    w/o optimizations
    Reduce time
    shift-left
    Reduce time
    Reduce time & shift-left

    View full-size slide

  12. 12
    Approach: Shift-left testing
    ▶ For Rspec, use filtering function
    ▶ E.g. grouping test suites into small, medium, and large or domain expert groups
    # To run tests only having :small tag
    $ rspec --tag small
    # To run tests only having :large tag
    $ rspec --tag large

    View full-size slide

  13. 13
    AI based approach
    pre-merge post-merge pre-release
    minutes
    hours
    days
    w/ optimizations
    w/o optimizations
    Reduce time
    shift-left
    Reduce time
    Reduce time & shift-left
    AI based test optimization is language agnostic and interesting as for new solution

    View full-size slide

  14. 14
    AI based test optimization like what Launchable does is language-agnostic
    https://speakerdeck.com/takanabe/developers-summit-2023-evolution-of-software-testing-by-machine-learning
    AI based approach

    View full-size slide

  15. 16
    Launchable is hiring new members!
    ▶ We are hiring a few software engineers who want to work in English.
    ▶ If you are interested in the position, please DM me or reach out to me later.

    View full-size slide