Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

Optimizing tests in Ruby 4 Today’s theme

Slide 5

Slide 5 text

5 Plan CI/CD pipeline

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Thanks 15

Slide 16

Slide 16 text

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.