DatabaseCleaner / database_cleaner-sequel

MIT License
17 stars 11 forks source link

FiberError with minitest's parallelize_me! with sequel #5

Open bbozo opened 8 years ago

bbozo commented 8 years ago

It fails non-deterministically, line 46 in test_helpers.rb is:

DatabaseCleaner.clean
FiberError: fiber called across threads
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/database_cleaner-1.5.3/lib/database_cleaner/sequel/transaction.rb:32:in `resume'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/database_cleaner-1.5.3/lib/database_cleaner/sequel/transaction.rb:32:in `clean'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/database_cleaner-1.5.3/lib/database_cleaner/base.rb:92:in `clean'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:79:in `block in clean'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:79:in `each'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:79:in `clean'
    /home/bbozo/infosig/InfoSwitch/Gateway/test/test_helpers.rb:46:in `block in <class:UnitTest>'

this is going in unit tests, so no parallel thread wacky stuff going on like with the integration tests. I'm using database_cleaner (1.5.3), let me know if I can assist more

ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]

    activesupport (4.2.6)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    coderay (1.1.1)
    concurrent-ruby (1.0.2)
    connection_pool (2.2.0)
    database_cleaner (1.5.3)
    dotenv (2.1.1)
    dry-configurable (0.1.4)
      concurrent-ruby (~> 1.0)
    dry-container (0.3.1)
      concurrent-ruby (~> 1.0)
      dry-configurable (~> 0.1, >= 0.1.3)
    dry-equalizer (0.2.0)
    dry-logic (0.2.2)
      dry-container (~> 0.2, >= 0.2.6)
      dry-equalizer (~> 0.2)
    dry-types (0.7.1)
      concurrent-ruby (~> 1.0)
      dry-configurable (~> 0.1)
      dry-container (~> 0.3)
      dry-equalizer (~> 0.2)
      dry-logic (~> 0.2, >= 0.2.0)
      inflecto (~> 0.0.0, >= 0.0.2)
      kleisli (~> 0.2)
    dry-validation (0.7.4)
      concurrent-ruby (~> 1.0)
      dry-configurable (~> 0.1, >= 0.1.3)
      dry-container (~> 0.2, >= 0.2.8)
      dry-equalizer (~> 0.2)
      dry-logic (~> 0.2, >= 0.2.2)
      dry-types (~> 0.6, >= 0.6.0)
    faraday (0.9.2)
      multipart-post (>= 1.2, < 3)
    foreman (0.81.0)
      thor (~> 0.19.1)
    i18n (0.7.0)
    inflecto (0.0.2)
    json (1.8.3)
    kleisli (0.2.7)
    m (1.5.0)
      method_source (>= 0.6.7)
      rake (>= 0.9.2.2)
    method_source (0.8.2)
    mini_portile2 (2.0.0)
    minitest (5.8.4)
    minitest-around (0.3.2)
      minitest (~> 5.0)
    multipart-post (2.0.0)
    nokogiri (1.6.7.2)
      mini_portile2 (~> 2.0.0.rc2)
    pg (0.18.4)
    pry (0.10.3)
      coderay (~> 1.1.0)
      method_source (~> 0.8.1)
      slop (~> 3.4)
    puma (3.4.0)
    rack (1.6.4)
    rack-test (0.6.3)
      rack (>= 1.0)
    rake (11.1.2)
    redis (3.3.0)
    roda (2.13.0)
      rack
    sequel (4.33.0)
    sidekiq (4.1.2)
      concurrent-ruby (~> 1.0)
      connection_pool (~> 2.2, >= 2.2.0)
      redis (~> 3.2, >= 3.2.1)
    slop (3.6.0)
    thor (0.19.1)
    thread_safe (0.3.5)
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    vcr (3.0.1)
bbozo commented 8 years ago

Update, checking around the failing code, I noticed the part of the code that tests if fibers are broken so I tried the #around mode and did:

DatabaseCleaner.clean_with(:truncation)
DatabaseCleaner.strategy = :transaction

class UnitTest < MiniTest::Spec

  around do |tests|
    DatabaseCleaner.cleaning(&tests)
  end

end

now I get non-deterministic (on all tests, every time):

FiberError: double resume
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-around-0.3.2/lib/minitest/around/spec.rb:23:in `resume'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-around-0.3.2/lib/minitest/around/spec.rb:23:in `block in around'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-around-0.3.2/lib/minitest/around/spec.rb:32:in `instance_exec'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-around-0.3.2/lib/minitest/around/spec.rb:32:in `block (2 levels) in after'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-around-0.3.2/lib/minitest/around/spec.rb:32:in `block (2 levels) in after'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-5.8.4/lib/minitest/test.rb:113:in `block (4 levels) in run'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-5.8.4/lib/minitest/test.rb:205:in `capture_exceptions'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-5.8.4/lib/minitest/test.rb:112:in `block (3 levels) in run'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-5.8.4/lib/minitest/test.rb:111:in `each'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-5.8.4/lib/minitest/test.rb:111:in `block (2 levels) in run'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-5.8.4/lib/minitest/test.rb:256:in `time_it'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-5.8.4/lib/minitest/test.rb:104:in `block in run'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-5.8.4/lib/minitest.rb:331:in `on_signal'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-5.8.4/lib/minitest/test.rb:276:in `with_info_handler'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-5.8.4/lib/minitest/test.rb:103:in `run'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-around-0.3.2/lib/minitest/around/unit.rb:11:in `run'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-5.8.4/lib/minitest.rb:778:in `run_one_method'
    /home/bbozo/.rvm/gems/ruby-2.2.4/gems/minitest-5.8.4/lib/minitest/parallel.rb:32:in `block (2 levels) in start'