aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/connection_test_mysql.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-05-25 21:09:46 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-05-25 21:09:46 +0000
commit4793c5b808f53cef9c1294818b90a2d617907502 (patch)
tree4f0dbcef3e841974d2a5418c85300a55a3340497 /activerecord/test/connection_test_mysql.rb
parentdef61a200e6021a532cd1bcc28541397fdc984b4 (diff)
downloadrails-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/test/connection_test_mysql.rb')
-rw-r--r--activerecord/test/connection_test_mysql.rb30
1 files changed, 30 insertions, 0 deletions
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