-
Notifications
You must be signed in to change notification settings - Fork 50
[Yaroslavzev] #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[Yaroslavzev] #43
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
account { Account.first || create(:account) } | ||
end | ||
``` | ||
Из интересного было обнаружено, что Resolv.getaddress(host) занимает до 20 секунд на выполнение, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
интересно, откуда он вызывался
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У нас проект хостится в k8s и у нас есть сервис, который собирает трейсы от разных API endpoint-ов.
И вот при инициализации клиента у используется Resolv.getaddress
, которые ищет dns адрес. Когда адреса нет(например, в CI или локалхосте), то работа метода занимает до 20 секунд
Для ускорения создания ассоциаций было внесены изменения в фабрики как на примере ниже: | ||
```ruby | ||
factory :user do | ||
account { Account.first || create(:account) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в таких случаях ещё можно any_fixture использовать
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
спасибо за предложение. Добавить решение выше оказалось проще, потому что меньше правок вносить в кодовую базу
и правильный мок метода позволил ускорить выполнение тестов. | ||
|
||
После оптимизации тестов среднее время выполнения тестов 12 минут. | ||
Таким образом, скорость выполнения тестов ускорена на 40 процентов. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
PR содержит case-study с описанием оптимизации test suit-а рабочем проекта