Skip to content

Restore async test #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions test/active_record_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,19 @@ class ActiveRecordTest < Minitest::Test
}
)
end
end

it "marks async queries with async: true" do
describe "async queries" do
before do
skip "Not applicable to older rails" if Rails.version.to_f < 7.1
skip "TODO: Fails on Rails 8 because of a missing session." if Rails.version.to_i >= 8
ActiveRecord::Base.asynchronous_queries_tracker.start_session
end

after do
ActiveRecord::Base.asynchronous_queries_tracker.finalize_session
end

it "marks async queries with async: true" do
expected_sql = 'SELECT COUNT(*) FROM "samples"'

messages = semantic_logger_events do
Expand All @@ -209,6 +217,10 @@ class ActiveRecordTest < Minitest::Test
payload_includes: {sql: expected_sql}
)
end

# On Rails prior to 8.0.2, these assertions will mostly pass, but not always.
# https://github.com/rails/rails/pull/54344
skip "Older Rails has flakey async instrumentation" if Rails.version < Gem::Version.new("8.0.2")
refute messages[0].payload.key?(:async)
assert_equal true, messages[1].payload[:async]
end
Expand Down