Skip to content

Commit

Permalink
CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BuonOmo committed Jul 19, 2024
1 parent 4952e5d commit 2007de4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ jobs:
done
cat ${{ github.workspace }}/setup.sql | cockroach sql --insecure
- name: Test
run: bundle exec rake test TESTOPTS='--profile=3 --verbose'
run: bundle exec rake test TESTOPTS='--profile=3 --verbose' TEST_FILES_AR=test/cases/adapters/postgresql/transaction_nested_test.rb
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ group :development, :test do

# Gems used by the ActiveRecord test suite
gem "bcrypt", "~> 3.1.18"
gem "mocha", "~> 1.14.0"
gem "sqlite3", "~> 1.4.4"

gem "minitest", "~> 5.15.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module TransactionManagerMonkeyPatch
def within_new_transaction(isolation: nil, joinable: true, attempts: 0)
super(isolation: isolation, joinable: joinable)
rescue ActiveRecord::ConnectionNotEstablished => error
puts "IN RETRY CASE ! " * 5
raise unless retryable? error
raise if attempts >= @connection.max_transaction_retries

Expand All @@ -37,6 +38,7 @@ def within_new_transaction(isolation: nil, joinable: true, attempts: 0)

within_new_transaction(isolation: isolation, joinable: joinable, attempts: attempts + 1) { yield }
rescue ActiveRecord::StatementInvalid => error
puts "IN RETRY CASE ! " * 5
raise unless retryable? error
raise if attempts >= @connection.max_transaction_retries

Expand All @@ -46,6 +48,8 @@ def within_new_transaction(isolation: nil, joinable: true, attempts: 0)
end

def retryable?(error)
puts "========> In a serialization failure" if error.is_a? ActiveRecord::SerializationFailure
puts "========> In a serialization error" if serialization_error?(error)
return true if serialization_error?(error)
return true if error.is_a? ActiveRecord::SerializationFailure
return retryable? error.cause if error.cause
Expand Down
9 changes: 4 additions & 5 deletions test/cases/connection_adapters/type_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ module CockroachDB
module ConnectionAdapters
class TypeTest < ActiveRecord::TestCase
fixtures :accounts
class SqliteModel < ActiveRecord::Base
class FakeModel < ActiveRecord::Base
establish_connection(
adapter: "sqlite3",
database: "tmp/some"
adapter: "fake"
)
end
def test_type_can_be_used_with_various_db
Expand All @@ -19,8 +18,8 @@ def test_type_can_be_used_with_various_db
ActiveRecord::Type.adapter_name_from(Account)
)
assert_equal(
:sqlite3,
ActiveRecord::Type.adapter_name_from(SqliteModel)
:fake,
ActiveRecord::Type.adapter_name_from(FakeModel)
)
end
end
Expand Down
16 changes: 14 additions & 2 deletions test/excludes/ActiveRecord/PostgresqlTransactionNestedTest.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
exclude :test_deadlock_raises_Deadlocked_inside_nested_SavepointTransaction, "Causes CI to hand. Skip while debugging."
exclude :test_unserializable_transaction_raises_SerializationFailure_inside_nested_SavepointTransaction, "Causes CI to hand. Skip while debugging."

# > In CRDB SERIALIZABLE, reads block on in-progress writes for
# > as long as those writes are in progress. However, PG does
# > not have this "read block on write" behavior, and so rather
# > than allowing the left-hand-side to execute, it must instead
# > abort that transaction. Both are valid ways to implement SERIALIZABLE.
#
# See discussion: https://github.com/cockroachdb/activerecord-cockroachdb-adapter/pull/333
message = "SERIALIZABLE transactions are different in CockroachDB."

# exclude :test_deadlock_raises_Deadlocked_inside_nested_SavepointTransaction, message
# exclude :test_unserializable_transaction_raises_SerializationFailure_inside_nested_SavepointTransaction, message
exclude :test_SerializationFailure_inside_nested_SavepointTransaction_is_recoverable, message
exclude :test_deadlock_inside_nested_SavepointTransaction_is_recoverable, message

0 comments on commit 2007de4

Please sign in to comment.