diff options
author | Matthew Draper <matthew@trebex.net> | 2016-11-27 16:48:47 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-11-27 16:53:04 +1030 |
commit | f4c24767c9f15a45011a26be29b899631df7f05a (patch) | |
tree | b2cb701e9bcd1dd8da249a4882363d39ae737b67 /activerecord | |
parent | 969339bd0ec2161af3c0830a9008d32a07c59b8b (diff) | |
download | rails-f4c24767c9f15a45011a26be29b899631df7f05a.tar.gz rails-f4c24767c9f15a45011a26be29b899631df7f05a.tar.bz2 rails-f4c24767c9f15a45011a26be29b899631df7f05a.zip |
We expect exceptions; abort will just raise in the wrong place
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/adapters/mysql2/transaction_test.rb | 22 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/transaction_test.rb | 4 |
2 files changed, 17 insertions, 9 deletions
diff --git a/activerecord/test/cases/adapters/mysql2/transaction_test.rb b/activerecord/test/cases/adapters/mysql2/transaction_test.rb index edd5353ee3..b37abd7e2e 100644 --- a/activerecord/test/cases/adapters/mysql2/transaction_test.rb +++ b/activerecord/test/cases/adapters/mysql2/transaction_test.rb @@ -29,26 +29,30 @@ module ActiveRecord test "raises Deadlocked when a deadlock is encountered" do assert_raises(ActiveRecord::Deadlocked) do + barrier = Concurrent::CyclicBarrier.new(2) + s1 = Sample.create value: 1 s2 = Sample.create value: 2 thread = Thread.new do + Thread.current.abort_on_exception = false + Sample.transaction do s1.lock! - sleep 1 + barrier.wait s2.update_attributes value: 1 end end - sleep 0.5 - - Sample.transaction do - s2.lock! - sleep 1 - s1.update_attributes value: 2 + begin + Sample.transaction do + s2.lock! + barrier.wait + s1.update_attributes value: 2 + end + ensure + thread.join end - - thread.join end end end diff --git a/activerecord/test/cases/adapters/postgresql/transaction_test.rb b/activerecord/test/cases/adapters/postgresql/transaction_test.rb index c450524de8..372af6b2be 100644 --- a/activerecord/test/cases/adapters/postgresql/transaction_test.rb +++ b/activerecord/test/cases/adapters/postgresql/transaction_test.rb @@ -33,6 +33,8 @@ module ActiveRecord after = Concurrent::CyclicBarrier.new(2) thread = Thread.new do + Thread.current.abort_on_exception = false + with_warning_suppression do Sample.transaction isolation: :serializable do before.wait @@ -65,6 +67,8 @@ module ActiveRecord s2 = Sample.create value: 2 thread = Thread.new do + Thread.current.abort_on_exception = false + Sample.transaction do s1.lock! barrier.wait |