0

I am using parallel_tests gem and more specifically parallel_rspec. I have 2 sets of tests that can't run in parallel as they interfere with the state of some other tests.

Currently I am doing parallel_rspec spec --single 'spec/set_A'

I now have the need to also run set_B non-parallely but how do I ensure that it runs in its own process and not with set_A's process above?

I have tried parallel_rspec spec --single 'spec/set_A|set_B' but it runs both sets in a single process which makes that process run for a really long time. Passing to separate --single flags also doesn't seem to achieve that.

Rahul
  • 321
  • 2
  • 14
  • 1
    *"I have 2 sets of tests that can't run in parallel as they interfere with the state of some other tests"* -- Can you elaborate on this point? Ideally, the best solution would be to simply change these tests to that they don't interfere with one another! – Tom Lord Sep 17 '18 at 20:10
  • I'm not clear whether running the tests in different processes would even solve the problem... (And so I'm concerned you may be asking an XY problem) – Tom Lord Sep 17 '18 at 20:18
  • @TomLord these are end to end tests. Test 1 goes to a school page and checks that a report is displayed with correct data for all students. Test 2 requires some students to be removed from the school and then go to the same page and check that the correct report is displayed for the remaining students. If these 2 tests are running at the same time and against the same school then the state of the report can't be determined. Keeping these tests within a single process to ensure that they run one after the other and between each test the state of the school will be reset. – Rahul Sep 17 '18 at 20:19
  • A better solution, Rahul, is to run each each process **with a different database**. As you will see in [the `parallel_tests` README](https://github.com/grosser/parallel_tests#setup-for-rails), it is recommended to define your test database name with `<%= ENV['TEST_ENV_NUMBER'] %>` for precisely this reason. – Tom Lord Sep 17 '18 at 21:11
  • Each process uses a unique database. So for example if you run 10 processes then there will be 10 databases. Schools being added/edited/deleted within one process do not affect the other processes. – Tom Lord Sep 17 '18 at 21:13
  • Thanks @TomLord. Unfortunately I am testing end to end on an application that uses CosmosDB and I am not using a rails setup. I am not sure I have the option of doing what you are suggesting. It's not a test databased that I control. – Rahul Sep 18 '18 at 09:43
  • Oh...yeah, that makes things difficult. Again, I could ask "why can't you be in control of the *test* database?", but I don't want to go down a rabbit hole here. You're going to hit all sorts of problems running tests against a third party, online database that you're not in control of. (For example, what happens when a second developer joins the project, and you try running tests at the same time??) – Tom Lord Sep 18 '18 at 10:14
  • Taking [a quick glance at the source code](https://github.com/grosser/parallel_tests/blob/06656a00f5a18a5703e7728ed8614827d3ec0409/lib/parallel_tests/cli.rb#L186), I think you can just supply multiple `--single` options?? I.e. `parallel_rspec spec --single 'spec/set_A' --single 'spec/set_B'`? – Tom Lord Sep 18 '18 at 10:20
  • Yep that's the first thing I tried. Even if I supply multiple --single flags it clubs all of those together in a single process not separate single processes. This is my actual question. – Rahul Sep 18 '18 at 10:41
  • `--isolate`? I'm just going off the README here. – Tom Lord Sep 18 '18 at 10:44
  • Yeah, that just ensures that no other tests are run in that single process. It doesn't affect the tests that actually go in the process in the first place – Rahul Sep 18 '18 at 10:45

0 Answers0