diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-25 21:09:46 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-25 21:09:46 +0000 |
commit | 4793c5b808f53cef9c1294818b90a2d617907502 (patch) | |
tree | 4f0dbcef3e841974d2a5418c85300a55a3340497 /activerecord | |
parent | def61a200e6021a532cd1bcc28541397fdc984b4 (diff) | |
download | rails-4793c5b808f53cef9c1294818b90a2d617907502.tar.gz rails-4793c5b808f53cef9c1294818b90a2d617907502.tar.bz2 rails-4793c5b808f53cef9c1294818b90a2d617907502.zip |
Test reconnection after MySQL client timeout. References #428.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6838 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/connection_test_firebird.rb | 4 | ||||
-rw-r--r-- | activerecord/test/connection_test_mysql.rb | 30 |
2 files changed, 32 insertions, 2 deletions
diff --git a/activerecord/test/connection_test_firebird.rb b/activerecord/test/connection_test_firebird.rb index 4760a46dbc..715e695518 100644 --- a/activerecord/test/connection_test_firebird.rb +++ b/activerecord/test/connection_test_firebird.rb @@ -1,6 +1,6 @@ -require 'abstract_unit' +require "#{File.dirname(__FILE__)}/abstract_unit" -class ConnectionTest < Test::Unit::TestCase +class FirebirdConnectionTest < Test::Unit::TestCase def test_charset_properly_set fb_conn = ActiveRecord::Base.connection.instance_variable_get(:@connection) assert_equal 'UTF8', fb_conn.database.character_set diff --git a/activerecord/test/connection_test_mysql.rb b/activerecord/test/connection_test_mysql.rb new file mode 100644 index 0000000000..e3f589c4af --- /dev/null +++ b/activerecord/test/connection_test_mysql.rb @@ -0,0 +1,30 @@ +require "#{File.dirname(__FILE__)}/abstract_unit" + +class MysqlConnectionTest < Test::Unit::TestCase + def setup + @connection = ActiveRecord::Base.connection + end + + def test_no_automatic_reconnection_after_timeout + assert @connection.active? + @connection.update('set @@wait_timeout=1') + sleep 2 + assert !@connection.active? + end + + def test_successful_reconnection_after_timeout_with_manual_reconnect + assert @connection.active? + @connection.update('set @@wait_timeout=1') + sleep 2 + @connection.reconnect! + assert @connection.active? + end + + def test_successful_reconnection_after_timeout_with_verify + assert @connection.active? + @connection.update('set @@wait_timeout=1') + sleep 2 + @connection.verify!(0) + assert @connection.active? + end +end |