SlideShare uma empresa Scribd logo
1 de 35
3 issues that made 30 test
workers take 40 minutes
brought to you by
Patryk Ptasiński
wroc_love.rb presentation
Optimizing pro tests was inspired by presentation I
watched in person on wroc_love.rb ruby conference. I
highly recommend watching it whole:
https://www.youtube.com/watch?v=xTBBrPUJjGk
2
Starting point
3
Tools and guides
● rspec --profile
● https://test-prof.evilmartians.io/#/
● https://github.com/khasinski/rails-awesome-tests
4
Issue nr 1
5
Issue nr 1
6
Issue nr 1 - very big test file
1. We use 30 test workers and we are splitting test
files among them
2. Some files take very long time to process
3. We cannot split big files*
4. Worker with index 15 always got 2 big rspec files
7
Issue nr 1 - solutions
1. Paid but advanced and really good: Knapsack PRO
2. Quick, simple and easy: change order with built-in
circle ci tool
3. Custom
8
Issue nr 1 - solution 1 Knapsack Pro
9
Issue nr 1 - solution 2
10
Issue nr 1 - solution 3
Write custom splitter - goals:
1. Split big test files (one big file takes many minutes to run)
2. Keep small files together if possible
3. Have control on what is “big” and what is “small”
4. Other benefits:
a. One time cost - implementation
b. No monthly payments
c. We don’t add third party dependencies
i. Reliability
ii. Data/code privacy
11
Issue nr 1 - solution 3
Write custom splitter - goals:
1. Split big test files (one big file takes many minutes to run)
2. Keep small files together if possible
3. Have control on what is “big” and what is “small”
4. Other benefits:
a. One time cost - implementation
b. No monthly payments
c. We don’t add third party dependencies
i. Reliability
ii. Data/code privacy
12
Issue nr 1 - solution 3
Write custom splitter - implementation plan:
1. Exporter - we need to have a “list” of all tests that we want to run
a. Custom RSpec formatter
2. Splitter script - main splitting logic based on exported list
a. Can be pure ruby, it will be really fast this way
3. Hook exporter and splitter into Circle CI
13
Issue nr 1 - solution 3
14
Issue nr 1 - solution 3
15
Issue nr 1 - solution 3
It’s not faster at all?
16
Issue nr 1 - solution 3
We need to add our “special” splitting logic:
Rspec.describe Article, ci_split_example_group: true
17
Issue nr 1 - solution 3
18
Issue nr 2
19
Issue nr 2
20
Issue nr 2
(start_date .. end_date).each do |day|
# some calculations here
end
21
Issue nr 2
# inside test
first_event = create(:event, date: Date.parse(‘2009-12-31’))
start_date = first_event.date
end_date = Date.today
22
Issue nr 2
start_date = Date.parse(‘2009-12-31’)
end_date = Date.today
(start_date .. end_date).each do |day|
# some calculations here
end
23
Issue nr 2 - solution
start_date = 1.month.ago
/
first_event = create(:event, date: 1.month.ago)
24
Issue nr 2 - solution
Test time went down
FROM
450 seconds
TO
15 seconds
25
Issue nr 3
26
Issue nr 3 - biggest spec file
27
Issue nr 3 - biggest spec file
28
Issue nr 3 - solution
rubocop -r 'test_prof/rubocop' --only
RSpec/AggregateExamples -a
spec/models/very_big_file_spec.rb
Source: https://test-prof.evilmartians.io/#/misc/rubocop
29
Issue nr 3
30
Issue nr 3
31
End result
32
End result
33
Recommendations
● Don’t write separate “it” blocks in tests, put them into bigger block so
that “before” runs as little as possible
● In other projects if there is one big test file, either split it into smaller files
or use “custom” splitter
● Be careful when writing tests that operate on dates/time
○ Better to use “20.days.ago” than “2022-10-13”
■ Wrap it up into timecop or other “time travel” solution
○ They can also fail because test scenarios are intended to operate on
specific days like weekdays, end of month or last 30 days span only 2
months - these can fail very unexpectedly if run on weekend, in the
middle of night, just after midnight or around February
34
Thanks for listening!
Any questions?
35

Mais conteúdo relacionado

Semelhante a 3 issues that made 30 test workers take 40 minutes

How to organize qa process in agile speed
How to organize qa process in agile speedHow to organize qa process in agile speed
How to organize qa process in agile speedSvitlana Dubyk
 
Critical Chain Project Management
Critical Chain Project ManagementCritical Chain Project Management
Critical Chain Project ManagementFred Wiersma
 
Performant Django - Ara Anjargolian
Performant Django - Ara AnjargolianPerformant Django - Ara Anjargolian
Performant Django - Ara AnjargolianHakka Labs
 
Write unit test from scratch
Write unit test from scratchWrite unit test from scratch
Write unit test from scratchWen-Shih Chao
 
Developers’ mDay 2021: Andrea Bjelogrlić, Sysbee – Tips, tricks and debugging...
Developers’ mDay 2021: Andrea Bjelogrlić, Sysbee – Tips, tricks and debugging...Developers’ mDay 2021: Andrea Bjelogrlić, Sysbee – Tips, tricks and debugging...
Developers’ mDay 2021: Andrea Bjelogrlić, Sysbee – Tips, tricks and debugging...mCloud
 
STX Next - Scrum Development Process Overview
STX Next - Scrum Development Process OverviewSTX Next - Scrum Development Process Overview
STX Next - Scrum Development Process OverviewSTX Next
 
Webinar: Performance Tuning + Optimization
Webinar: Performance Tuning + OptimizationWebinar: Performance Tuning + Optimization
Webinar: Performance Tuning + OptimizationMongoDB
 
Sheet1WBSTask Name1Product development1.1 Electronics1.1.1 .docx
Sheet1WBSTask Name1Product development1.1   Electronics1.1.1      .docxSheet1WBSTask Name1Product development1.1   Electronics1.1.1      .docx
Sheet1WBSTask Name1Product development1.1 Electronics1.1.1 .docxlesleyryder69361
 
Agile :what i learnt so far
Agile :what i learnt so farAgile :what i learnt so far
Agile :what i learnt so farRohan Chandane
 
Parser Breakout Session
Parser Breakout SessionParser Breakout Session
Parser Breakout SessionZhipeng Huang
 
End-to-end performance testing, profiling, and analysis at Redis
End-to-end performance testing, profiling, and analysis at RedisEnd-to-end performance testing, profiling, and analysis at Redis
End-to-end performance testing, profiling, and analysis at RedisFilipe Oliveira
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection7mind
 
Multiply your Testing Effectiveness with Parameterized Testing, v1
Multiply your Testing Effectiveness with Parameterized Testing, v1Multiply your Testing Effectiveness with Parameterized Testing, v1
Multiply your Testing Effectiveness with Parameterized Testing, v1Brian Okken
 
Silicon Valley Code Camp 2014 - Advanced MongoDB
Silicon Valley Code Camp 2014 - Advanced MongoDBSilicon Valley Code Camp 2014 - Advanced MongoDB
Silicon Valley Code Camp 2014 - Advanced MongoDBDaniel Coupal
 
Reproducible Research in R and R Studio
Reproducible Research in R and R StudioReproducible Research in R and R Studio
Reproducible Research in R and R StudioSusan Johnston
 
Open source projects with python
Open source projects with pythonOpen source projects with python
Open source projects with pythonroskakori
 

Semelhante a 3 issues that made 30 test workers take 40 minutes (20)

How to organize qa process in agile speed
How to organize qa process in agile speedHow to organize qa process in agile speed
How to organize qa process in agile speed
 
Critical Chain Project Management
Critical Chain Project ManagementCritical Chain Project Management
Critical Chain Project Management
 
Performant Django - Ara Anjargolian
Performant Django - Ara AnjargolianPerformant Django - Ara Anjargolian
Performant Django - Ara Anjargolian
 
Write unit test from scratch
Write unit test from scratchWrite unit test from scratch
Write unit test from scratch
 
Developers’ mDay 2021: Andrea Bjelogrlić, Sysbee – Tips, tricks and debugging...
Developers’ mDay 2021: Andrea Bjelogrlić, Sysbee – Tips, tricks and debugging...Developers’ mDay 2021: Andrea Bjelogrlić, Sysbee – Tips, tricks and debugging...
Developers’ mDay 2021: Andrea Bjelogrlić, Sysbee – Tips, tricks and debugging...
 
Scrum - twice as much, twice as fast
Scrum - twice as much, twice as fastScrum - twice as much, twice as fast
Scrum - twice as much, twice as fast
 
STX Next - Scrum Development Process Overview
STX Next - Scrum Development Process OverviewSTX Next - Scrum Development Process Overview
STX Next - Scrum Development Process Overview
 
Webinar: Performance Tuning + Optimization
Webinar: Performance Tuning + OptimizationWebinar: Performance Tuning + Optimization
Webinar: Performance Tuning + Optimization
 
Sheet1WBSTask Name1Product development1.1 Electronics1.1.1 .docx
Sheet1WBSTask Name1Product development1.1   Electronics1.1.1      .docxSheet1WBSTask Name1Product development1.1   Electronics1.1.1      .docx
Sheet1WBSTask Name1Product development1.1 Electronics1.1.1 .docx
 
Agile :what i learnt so far
Agile :what i learnt so farAgile :what i learnt so far
Agile :what i learnt so far
 
Parser Breakout Session
Parser Breakout SessionParser Breakout Session
Parser Breakout Session
 
tip oopt pse-summit2017
tip oopt pse-summit2017tip oopt pse-summit2017
tip oopt pse-summit2017
 
CC - Project Work Diary
CC - Project Work DiaryCC - Project Work Diary
CC - Project Work Diary
 
End-to-end performance testing, profiling, and analysis at Redis
End-to-end performance testing, profiling, and analysis at RedisEnd-to-end performance testing, profiling, and analysis at Redis
End-to-end performance testing, profiling, and analysis at Redis
 
ScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency InjectionScalaUA - distage: Staged Dependency Injection
ScalaUA - distage: Staged Dependency Injection
 
Multiply your Testing Effectiveness with Parameterized Testing, v1
Multiply your Testing Effectiveness with Parameterized Testing, v1Multiply your Testing Effectiveness with Parameterized Testing, v1
Multiply your Testing Effectiveness with Parameterized Testing, v1
 
18CSL48.pdf
18CSL48.pdf18CSL48.pdf
18CSL48.pdf
 
Silicon Valley Code Camp 2014 - Advanced MongoDB
Silicon Valley Code Camp 2014 - Advanced MongoDBSilicon Valley Code Camp 2014 - Advanced MongoDB
Silicon Valley Code Camp 2014 - Advanced MongoDB
 
Reproducible Research in R and R Studio
Reproducible Research in R and R StudioReproducible Research in R and R Studio
Reproducible Research in R and R Studio
 
Open source projects with python
Open source projects with pythonOpen source projects with python
Open source projects with python
 

Mais de Visuality

Czego nie robić przy pisaniu testów
Czego nie robić przy pisaniu testówCzego nie robić przy pisaniu testów
Czego nie robić przy pisaniu testówVisuality
 
Introduction to Domain-Driven Design in Ruby on Rails
Introduction to Domain-Driven Design in Ruby on RailsIntroduction to Domain-Driven Design in Ruby on Rails
Introduction to Domain-Driven Design in Ruby on RailsVisuality
 
Active Record .includes - do you use it consciously?
Active Record .includes - do you use it consciously?Active Record .includes - do you use it consciously?
Active Record .includes - do you use it consciously?Visuality
 
Introduction to Event Storming
Introduction to Event StormingIntroduction to Event Storming
Introduction to Event StormingVisuality
 
Jak programowanie może pomóc na co dzień?
Jak programowanie może pomóc na co dzień?Jak programowanie może pomóc na co dzień?
Jak programowanie może pomóc na co dzień?Visuality
 
SVG Overview - How To Draw, Use and Animate
SVG Overview - How To Draw, Use and AnimateSVG Overview - How To Draw, Use and Animate
SVG Overview - How To Draw, Use and AnimateVisuality
 
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...Visuality
 
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał ŁęcickiHow to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał ŁęcickiVisuality
 
What is NOT machine learning - Burak Aybar
What is NOT machine learning - Burak AybarWhat is NOT machine learning - Burak Aybar
What is NOT machine learning - Burak AybarVisuality
 
Do you really need to reload?
Do you really need to reload?Do you really need to reload?
Do you really need to reload?Visuality
 
How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)Visuality
 
Fantastic stresses and where to find them
Fantastic stresses and where to find themFantastic stresses and where to find them
Fantastic stresses and where to find themVisuality
 
Fuzzy search in Ruby
Fuzzy search in RubyFuzzy search in Ruby
Fuzzy search in RubyVisuality
 
Rfc process in visuality
Rfc process in visualityRfc process in visuality
Rfc process in visualityVisuality
 
GraphQL in Ruby on Rails - basics
GraphQL in Ruby on Rails - basicsGraphQL in Ruby on Rails - basics
GraphQL in Ruby on Rails - basicsVisuality
 
Consumer Driven Contracts
Consumer Driven ContractsConsumer Driven Contracts
Consumer Driven ContractsVisuality
 
How do we use CircleCi in Laterallink?
How do we use CircleCi in Laterallink?How do we use CircleCi in Laterallink?
How do we use CircleCi in Laterallink?Visuality
 
React Native - Short introduction
React Native - Short introductionReact Native - Short introduction
React Native - Short introductionVisuality
 
Risk in project management
Risk in project managementRisk in project management
Risk in project managementVisuality
 
Ruby formatters
Ruby formattersRuby formatters
Ruby formattersVisuality
 

Mais de Visuality (20)

Czego nie robić przy pisaniu testów
Czego nie robić przy pisaniu testówCzego nie robić przy pisaniu testów
Czego nie robić przy pisaniu testów
 
Introduction to Domain-Driven Design in Ruby on Rails
Introduction to Domain-Driven Design in Ruby on RailsIntroduction to Domain-Driven Design in Ruby on Rails
Introduction to Domain-Driven Design in Ruby on Rails
 
Active Record .includes - do you use it consciously?
Active Record .includes - do you use it consciously?Active Record .includes - do you use it consciously?
Active Record .includes - do you use it consciously?
 
Introduction to Event Storming
Introduction to Event StormingIntroduction to Event Storming
Introduction to Event Storming
 
Jak programowanie może pomóc na co dzień?
Jak programowanie może pomóc na co dzień?Jak programowanie może pomóc na co dzień?
Jak programowanie może pomóc na co dzień?
 
SVG Overview - How To Draw, Use and Animate
SVG Overview - How To Draw, Use and AnimateSVG Overview - How To Draw, Use and Animate
SVG Overview - How To Draw, Use and Animate
 
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
 
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał ŁęcickiHow to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
 
What is NOT machine learning - Burak Aybar
What is NOT machine learning - Burak AybarWhat is NOT machine learning - Burak Aybar
What is NOT machine learning - Burak Aybar
 
Do you really need to reload?
Do you really need to reload?Do you really need to reload?
Do you really need to reload?
 
How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)
 
Fantastic stresses and where to find them
Fantastic stresses and where to find themFantastic stresses and where to find them
Fantastic stresses and where to find them
 
Fuzzy search in Ruby
Fuzzy search in RubyFuzzy search in Ruby
Fuzzy search in Ruby
 
Rfc process in visuality
Rfc process in visualityRfc process in visuality
Rfc process in visuality
 
GraphQL in Ruby on Rails - basics
GraphQL in Ruby on Rails - basicsGraphQL in Ruby on Rails - basics
GraphQL in Ruby on Rails - basics
 
Consumer Driven Contracts
Consumer Driven ContractsConsumer Driven Contracts
Consumer Driven Contracts
 
How do we use CircleCi in Laterallink?
How do we use CircleCi in Laterallink?How do we use CircleCi in Laterallink?
How do we use CircleCi in Laterallink?
 
React Native - Short introduction
React Native - Short introductionReact Native - Short introduction
React Native - Short introduction
 
Risk in project management
Risk in project managementRisk in project management
Risk in project management
 
Ruby formatters
Ruby formattersRuby formatters
Ruby formatters
 

Último

IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024vaibhav130304
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024Shane Coughlan
 
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1KnowledgeSeed
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...rajkumar669520
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfVictor Lopez
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfMehmet Akar
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfFurqanuddin10
 
What need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersWhat need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersEmilyJiang23
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...naitiksharma1124
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...Alluxio, Inc.
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems ApproachNeo4j
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignNeo4j
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationHelp Desk Migration
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Gáspár Nagy
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationWave PLM
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfQ-Advise
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Andrea Goulet
 

Último (20)

IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024
 
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdf
 
What need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersWhat need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java Developers
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data Migration
 
Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 
AI Hackathon.pptx
AI                        Hackathon.pptxAI                        Hackathon.pptx
AI Hackathon.pptx
 

3 issues that made 30 test workers take 40 minutes

  • 1. 3 issues that made 30 test workers take 40 minutes brought to you by Patryk Ptasiński
  • 2. wroc_love.rb presentation Optimizing pro tests was inspired by presentation I watched in person on wroc_love.rb ruby conference. I highly recommend watching it whole: https://www.youtube.com/watch?v=xTBBrPUJjGk 2
  • 4. Tools and guides ● rspec --profile ● https://test-prof.evilmartians.io/#/ ● https://github.com/khasinski/rails-awesome-tests 4
  • 7. Issue nr 1 - very big test file 1. We use 30 test workers and we are splitting test files among them 2. Some files take very long time to process 3. We cannot split big files* 4. Worker with index 15 always got 2 big rspec files 7
  • 8. Issue nr 1 - solutions 1. Paid but advanced and really good: Knapsack PRO 2. Quick, simple and easy: change order with built-in circle ci tool 3. Custom 8
  • 9. Issue nr 1 - solution 1 Knapsack Pro 9
  • 10. Issue nr 1 - solution 2 10
  • 11. Issue nr 1 - solution 3 Write custom splitter - goals: 1. Split big test files (one big file takes many minutes to run) 2. Keep small files together if possible 3. Have control on what is “big” and what is “small” 4. Other benefits: a. One time cost - implementation b. No monthly payments c. We don’t add third party dependencies i. Reliability ii. Data/code privacy 11
  • 12. Issue nr 1 - solution 3 Write custom splitter - goals: 1. Split big test files (one big file takes many minutes to run) 2. Keep small files together if possible 3. Have control on what is “big” and what is “small” 4. Other benefits: a. One time cost - implementation b. No monthly payments c. We don’t add third party dependencies i. Reliability ii. Data/code privacy 12
  • 13. Issue nr 1 - solution 3 Write custom splitter - implementation plan: 1. Exporter - we need to have a “list” of all tests that we want to run a. Custom RSpec formatter 2. Splitter script - main splitting logic based on exported list a. Can be pure ruby, it will be really fast this way 3. Hook exporter and splitter into Circle CI 13
  • 14. Issue nr 1 - solution 3 14
  • 15. Issue nr 1 - solution 3 15
  • 16. Issue nr 1 - solution 3 It’s not faster at all? 16
  • 17. Issue nr 1 - solution 3 We need to add our “special” splitting logic: Rspec.describe Article, ci_split_example_group: true 17
  • 18. Issue nr 1 - solution 3 18
  • 21. Issue nr 2 (start_date .. end_date).each do |day| # some calculations here end 21
  • 22. Issue nr 2 # inside test first_event = create(:event, date: Date.parse(‘2009-12-31’)) start_date = first_event.date end_date = Date.today 22
  • 23. Issue nr 2 start_date = Date.parse(‘2009-12-31’) end_date = Date.today (start_date .. end_date).each do |day| # some calculations here end 23
  • 24. Issue nr 2 - solution start_date = 1.month.ago / first_event = create(:event, date: 1.month.ago) 24
  • 25. Issue nr 2 - solution Test time went down FROM 450 seconds TO 15 seconds 25
  • 27. Issue nr 3 - biggest spec file 27
  • 28. Issue nr 3 - biggest spec file 28
  • 29. Issue nr 3 - solution rubocop -r 'test_prof/rubocop' --only RSpec/AggregateExamples -a spec/models/very_big_file_spec.rb Source: https://test-prof.evilmartians.io/#/misc/rubocop 29
  • 34. Recommendations ● Don’t write separate “it” blocks in tests, put them into bigger block so that “before” runs as little as possible ● In other projects if there is one big test file, either split it into smaller files or use “custom” splitter ● Be careful when writing tests that operate on dates/time ○ Better to use “20.days.ago” than “2022-10-13” ■ Wrap it up into timecop or other “time travel” solution ○ They can also fail because test scenarios are intended to operate on specific days like weekdays, end of month or last 30 days span only 2 months - these can fail very unexpectedly if run on weekend, in the middle of night, just after midnight or around February 34
  • 35. Thanks for listening! Any questions? 35