grosser / parallel_tests

Ruby: 2 CPUs = 2x Testing Speed for RSpec, Test::Unit and Cucumber
3.37k stars 493 forks source link

parallel_tests does not seem to wait for all processes to finish in gitlab-ci #623

Open Schwad opened 6 years ago

Schwad commented 6 years ago

I posted my original query here, but this may be a more appropriate place.

I am attempting to get the parallel_tests gem integrated with gitlab-ci for RSpec.

I have followed the instructions on the README for setup, we are testing this out with 2 cores and therefore it is only needing to spin up two testing DB's.

However, it appears when the tests run, I do have two running in parallel, but one finishes before the other and the remainder of the tests instantly fail with the following:

 xx) My generic test name
  Failure/Error: Capybara.reset_sessions!

  TypeError:
    no implicit conversion of String into Integer
  # ./spec/support/capybara.rb:7:in `block (2 levels) in <top (required)>'

Whereas /spec/support/capybara.rb7 is:

config.before(:each) do
  Capybara.reset_sessions!
end

There was guidance on how to make the specs wait for each other, which I implemented as:

at_exit do
  if ParallelTests.first_process?
    ParallelTests.wait_for_other_processes_to_finish
  end
end

And when the specs still broke I alternated with .last_process? and even trying to include an elsif statement.

Further, I tried to see implementations of this in the wild on Github and attempted some of those approaches, but still have difficulties.

Unfortunately, it still seems that the processes are not waiting for each other. What have you done in your CI, ideally Gitlab if possible, to ensure that your tests all don't crash after the first process finishes?

Versions: Tested on Ruby 2.4.x and 2.3.x Tested on Rails 5.1.x

grosser commented 6 years ago

Disable rails backtrace cleaner to get the full backtrace and see what causes the error It could be something like the first finished test shutting down some server both tests depend on .. ideally reproduce with a minimal repo to narrow down what causes the error

On Wed, Mar 14, 2018, 09:43 Nick Schwaderer notifications@github.com wrote:

I posted my original query here https://stackoverflow.com/questions/49259181/how-should-i-force-the-parallel-tests-gem-to-wait-for-all-processes-to-finish-in, but this may be a more appropriate place.

I am attempting to get the parallel_tests gem integrated with gitlab-ci for RSpec.

I have followed the instructions on the README for setup, we are testing this out with 2 cores and therefore it is only needing to spin up two testing DB's.

However, it appears when the tests run, I do have two running in parallel, but one finishes before the other and the remainder of the tests instantly fail with the following:

xx) My generic test name Failure/Error: Capybara.reset_sessions!

TypeError: no implicit conversion of String into Integer

./spec/support/capybara.rb:7:in `block (2 levels) in <top (required)>'

Whereas /spec/support/capybara.rb7 is:

config.before(:each) do Capybara.reset_sessions!endThere was guidance on how to make the specs wait for each other, which I implemented as:

at_exit do if ParallelTests.first_process? ParallelTests.wait_for_other_processes_to_finish end end

And when the specs still broke I alternated with .last_process? and even trying to include an elsif statement.

Further, I tried to see implementations of this in the wild on Github and attempted some of those approaches, but still have difficulties.

Unfortunately, it still seems that the processes are not waiting for each other. What have you done in your CI, ideally Gitlab if possible, to ensure that your tests all don't crash after the first process finishes?

Versions: Tested on Ruby 2.4.x and 2.3.x Tested on Rails 5.1.x

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/grosser/parallel_tests/issues/623, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAsZ8gLwluLSM7DF5ZsUimZ3UY8wbUrks5teUiigaJpZM4SqyQ9 .

vladhadzhiyski commented 4 years ago

@Schwad - were you able to figure this out?

I'm trying to not get these weird race conditions when it comes to the stdout during the specs executions from the different processes. Any thoughts / ideas?

secp521 commented 4 years ago

I am facing a similar issue. The specs fail with no message after one or more processes finish. No output even with --verbose. No pattern on what specs are running when the other processes are abandoned and considered failures.

grosser commented 4 years ago

maybe add something into each test runner that prints "I'm alive

{ENV["TEST_ENV_NUMBER"]}" every minute or so to see if they die

On Tue, Nov 12, 2019 at 2:57 PM talalatpixlee notifications@github.com wrote:

I am facing a similar issue. The specs fail with no message after one or more processes finish. No output even with --verbose.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/grosser/parallel_tests/issues/623?email_source=notifications&email_token=AAACYZ5IXQCKTOVIPJCUHITQTMYD7A5CNFSM4EVLEQ62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOED4HZRA#issuecomment-553155780, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACYZ2GD7KB4LKU6LIRZ3TQTMYD7ANCNFSM4EVLEQ6Q .

secp521 commented 4 years ago

I added the print statement. Seems like one of the thread dies at some point. I can't seem to understand why yet though. The exit code in the results array at the end is nil. Trying to understand if the CI is OOM killing or it is something else.

secp521 commented 4 years ago

Puffing Billy was erroring out. https://github.com/eventmachine/eventmachine/issues/366

Separating out the cert and cache paths as mentioned here resolved the issue. https://github.com/oesmith/puffing-billy#in-rspec

OxSon commented 3 years ago

@talalatpixlee How did you nail down what was failing? I'm having a similar issue, but not using puffing billy