Skip to content

Commit

Permalink
Reset the db connections
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanharan committed Nov 8, 2023
1 parent 38f0277 commit 425dda4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ services:
ci:
environment:
- ACTIVERECORD_UNITTEST_HOST=sqlserver
- SQLSERVER_CI=true
build:
context: .
dockerfile: Dockerfile.ci
Expand Down
6 changes: 3 additions & 3 deletions test/cases/transaction_test_sqlserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class TransactionTestSQLServer < ActiveRecord::TestCase

describe "when READ_COMMITTED_SNAPSHOT is set" do
it "should use READ COMMITTED as an isolation level" do
skip "This test sometimes causes subsequent tests to fail with error 'DBPROCESS is dead or not enabled'. The test passes if run alone." if ENV["SQLSERVER_CI"]

connection.execute "ALTER DATABASE [#{connection.current_database}] SET ALLOW_SNAPSHOT_ISOLATION ON"
connection.execute "ALTER DATABASE [#{connection.current_database}] SET READ_COMMITTED_SNAPSHOT ON WITH ROLLBACK IMMEDIATE"

Expand All @@ -69,10 +67,12 @@ class TransactionTestSQLServer < ActiveRecord::TestCase
# "READ COMMITTED", and that no exception was raised (it's reported back
# by SQL Server as "read committed snapshot").
_(connection.user_options_isolation_level).must_match "read committed snapshot"

ensure
connection.execute "ALTER DATABASE [#{connection.current_database}] SET ALLOW_SNAPSHOT_ISOLATION OFF"
connection.execute "ALTER DATABASE [#{connection.current_database}] SET READ_COMMITTED_SNAPSHOT OFF WITH ROLLBACK IMMEDIATE"

# Reset all connections. Otherwise, the next test may fail with error 'DBPROCESS is dead or not enabled'. Not sure why.
ActiveRecord::Base.connection_handler.clear_all_connections!
end
end

Expand Down

0 comments on commit 425dda4

Please sign in to comment.