Closed christopherhein closed 12 years ago
Hi Christopher, can you please try running your tests with the latest version of em-synchrony? Just merged some changes that could resolve your problem.
Unfortunately no luck, I just realized this is the same issue thats coming up here, https://github.com/igrigorik/async-rails/issues/13 and I've confirmed by forking async-rails and updating it to Rails 3.1 and adding one single functional test. you can see what I've done in this commit:
https://github.com/christopherhein/async-rails/commit/52c9b4acf1d4282e1b6ffc620e68fd91c4ab0db1
EDIT: forgot to add when you do use em-synchony at the "1.0.0" like @guilleiguaran says it fails because of the column defaults when you run the tests as well, but I'm pretty sure I saw you fixed that. when this https://github.com/igrigorik/em-synchrony/issues/55 got closed.
Just tested without luck
As a heads up, I found a work around for the running rake test
the issues are being brought up from ActiveSupport trying to run setup and teardown callbacks before the Reactor is running, and MySQL2's lib/em.rb
query method when the reactor is not running it falls back to super which is causing the issue... so my current work around is ripping out SetupAndTeardown methods and adding it to the test_helper.rb and running the reactor around it. As you can see here:
https://github.com/christopherhein/async-rails/commit/7ffb3f3997021b3aac22062fa3a6fc1563403966
Hope this helps a little.
I'll try to let everyone know if I find a more elegant solution since this only really helps this one instance
EDIT: The SetupAndTeardown hack only actually helps with the functional tests, not unit tests. (sort of important lol)
RE:EDIT: Oddly enough it works perfect with autotest...
Hey @guilleiguaran for the problems you were having with async-rails and running migrations take a peep at this:
http://blog.carbonfive.com/2011/02/03/raking-and-testing-with-eventmachine/
The solution he has for rake will solve the problem for running rake db:migrate
and rake db:create
but testing isn't working with it.
Cheers.
Hmm, this is a gnarly problem.
@christopherhein: what if we include all of the patches Michael suggests in his article as part of the AR require. It obviously does not address all the problems, but its a start (even if a brittle one).
And test/incorporate the suggestions in the comments as well. Using the "around" support in RSpec and Cucumber would be nice, if it works.
I also added a reply to @christopherhein's comment about minitest: http://blog.carbonfive.com/2011/02/03/raking-and-testing-with-eventmachine/#comment-3933
Sorry guys, I've been focusing on some other stuff leaving this to the sidelines, @mwynholds this is great, that works perfect for me, as well.
This also seems to happen for normal apps: I'm using thin and when any gem loads a model while initializing and mysql executes SET SQL_AUTO_IS_NULL=0, NAMES 'utf8', @@wait_timeout = 259200
(for example) it just crashes
When I try to run my test suite using Rails 3.1.0 I with:
gem "em-synchrony", git: "git://github.com/igrigorik/em-synchrony.git", require: [ "em-synchrony", "em-synchrony/em-http", "em-synchrony/activerecord" ]
in my Gemfile, and using the
em_mysql2
driver it errors before when it tries to run the first test and aborts. although if I revert back tomysql2
driver it works perfectly, this is the full trace on the testsbundle exec rake test --trace * Invoke test (first_time) * Execute test * Invoke test:units (first_time) * Invoke test:prepare (first_time) * Invoke db:test:prepare (first_time) * Invoke db:abort_if_pending_migrations (first_time) * Invoke environment (first_time) * Execute environment * Execute db:abort_if_pending_migrations * Invoke test:functionals (first_time) * Invoke test:prepare * Execute test:functionals Loaded suite /Users/ChristopherHein/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/rake_test_loader Started
PagesControllerTest: ERROR should get index (0.03s) NoMethodError: undefined method
callback' for nil:NilClass /Users/ChristopherHein/.rvm/gems/ruby-1.9.2-p290@chrishein/gems/activesupport-3.1.0/lib/active_support/whiny_nil.rb:48:in
method_missing'Finished in 0.036990 seconds.
1 tests, 0 assertions, 0 failures, 2 errors, 0 skips * Invoke test:integration (first_time) * Invoke test:prepare \ Execute test:integration Errors running test:units, test:functionals!
I might be missing something, but it seems to work fine when I'm using rails 3.1.0.rc4 like your Async-Rails but it seems to be something with the full release of rails...
Any input/suggestions would be greatly appreciated. Thanks for all the amazing things you hack on btw!