Skip to content

[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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Yaroslavzev
Copy link

PR содержит case-study с описанием оптимизации test suit-а рабочем проекта

Copy link
Collaborator

@spajic spajic left a 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 секунд на выполнение,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

интересно, откуда он вызывался

Copy link
Author

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) }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в таких случаях ещё можно any_fixture использовать

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

спасибо за предложение. Добавить решение выше оказалось проще, потому что меньше правок вносить в кодовую базу

и правильный мок метода позволил ускорить выполнение тестов.

После оптимизации тестов среднее время выполнения тестов 12 минут.
Таким образом, скорость выполнения тестов ускорена на 40 процентов.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants