Skip to content
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

How to run tests in parallel locally? #70

Closed
tibbon opened this issue Nov 7, 2017 · 6 comments
Closed

How to run tests in parallel locally? #70

tibbon opened this issue Nov 7, 2017 · 6 comments

Comments

@tibbon
Copy link

tibbon commented Nov 7, 2017

I have a machine with 8+ threads. How can I run my tests in parallel with these reports on my local system?

@ArturT
Copy link
Member

ArturT commented Nov 7, 2017

Here is example: https://github.com/ArturT/knapsack#how-to-run-tests-for-particular-ci-node-in-your-development-environment

Could you share more info about your project context. What CI provider do you use? How long is your test suite? RSpec or something else? Why do you want to run test suite in development across threads? Is it small test suite so it's faster in development than pushing to CI?

If you want to run threads using parallel_tests gem then you can take a look on knapsack_pro examples https://github.com/KnapsackPro/knapsack_pro-ruby#how-to-run-knapsack_pro-with-parallel_tests-gem

@tibbon
Copy link
Author

tibbon commented Nov 7, 2017

Thanks for such a fast follow up!

My test suite is a mixture of Minitest (migrating away from) and RSpec. Between the two of them the suite is around 4-5 minutes to run fully, but if I could get that down to under a minute it would be great.

We use CircleCI, which is great. It's only building on pull requests right now, and I probably could just push to a work in progress branch more. Between building a VM and everything it's 5-8 minutes on Circle to complete.

I'll check out those examples

@ArturT
Copy link
Member

ArturT commented Nov 7, 2017

Regarding idea how to lower down the time of builds on CircleCI you could do this:

  1. Use CircleCI 2.0 which is faster. If you need something specific for your project then you can use custom Docker image. Other than that you can use default Docker images provided by CircleCI. I wrote article with an example how to configure CircleCI 2.0 with ruby + capybara
    http://docs.knapsackpro.com/2017/circleci-2-0-capybara-feature-specs-selenium-webdriver-with-chrome-headless

  2. You have at the moment 2 different test runners minitest and RSpec and below setup is something I recommended for a few companies. You can always get optimal test suite split (the fastest time execution of your tests) by doing:

Step 1: run your minitest test suite with bundle exec rake knapsack_pro:minitest
Step 2: run your RSpec test suite with dynamic RSpec allocation across CI nodes (it's called knapsack_pro Queue Mode) bundle exec rake knapsack_pro:queue:rspec. Thanks to that the dynamic RSpec tests allocation will fill timing gaps across CI nodes so your whole build will have optimal time no matter if your tests have random time execution due to some long-running features specs or external requests in tests. No matter the CI nodes random performance.

You can take a look how dynamic RSpec allocation works with knapsack_pro Queue Mode, here is video at https://knapsackpro.com/

And here is explanation how to configure the proper order of knapsack_pro commands: https://github.com/KnapsackPro/knapsack_pro-ruby#what-is-optimal-order-of-test-commands

If you just want to take a look at knapsack_pro configuration options please see:
http://docs.knapsackpro.com/knapsack_pro-ruby/guide/

Let me know if I could help more :)

@adis-io
Copy link

adis-io commented Feb 14, 2019

I don't know, may be somebody already asked about it.
Here is the question, my whole test suit takes huge amount of time. But with parallel_tests (6 cores) it takes about - 30 min. Can I use parallel_tests to generate report?

@ArturT
Copy link
Member

ArturT commented Feb 14, 2019

@ArturT
Copy link
Member

ArturT commented Apr 26, 2019

I added one more example of how to use paralell_tests with knapsack_pro Queue Mode to utilize machine resource on a single CI machine.

https://github.com/KnapsackPro/knapsack_pro-ruby#parallel_tests-with-knapsack_pro-on-single-ci-machine

There are bash scripts that can be reused.

@ArturT ArturT closed this as completed Apr 26, 2019
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

No branches or pull requests

3 participants