From b1d192f5060cdca322cb9c253f6d45e08f35cbfe Mon Sep 17 00:00:00 2001 From: fallwith Date: Fri, 9 Aug 2024 17:00:08 -0700 Subject: [PATCH 1/2] CI: Rails v8.0 test fix, Rails v7.2 out of beta - Rails v8.0 uses lazy routing, so expect the corresponding middleware metric to be present - Rails v7.2.0 is now released, so switch to using `7.2.0` instead of an alpha/rc release --- test/environments/rails72/Gemfile | 2 +- test/multiverse/suites/rails/Envfile | 2 +- .../suites/rails/action_controller_other_test.rb | 2 +- .../suites/rails/middleware_instrumentation_test.rb | 9 +++++++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/test/environments/rails72/Gemfile b/test/environments/rails72/Gemfile index 24c6e38afe..3b65994ff3 100644 --- a/test/environments/rails72/Gemfile +++ b/test/environments/rails72/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -gem 'rails', '~> 7.2.0.beta2' +gem 'rails', '~> 7.2.0' gem 'bootsnap', '>= 1.4.4', require: false gem 'minitest', '5.2.3' diff --git a/test/multiverse/suites/rails/Envfile b/test/multiverse/suites/rails/Envfile index d26fcad892..d5e9b485b6 100644 --- a/test/multiverse/suites/rails/Envfile +++ b/test/multiverse/suites/rails/Envfile @@ -4,7 +4,7 @@ RAILS_VERSIONS = [ [nil, 3.1], - ['7.2.0.beta3', 3.1], + ['7.2.0', 3.1], ['7.1.0', 2.7], ['7.0.4', 2.7], ['6.1.7', 2.5], diff --git a/test/multiverse/suites/rails/action_controller_other_test.rb b/test/multiverse/suites/rails/action_controller_other_test.rb index 799ed069a8..acc6718d7a 100644 --- a/test/multiverse/suites/rails/action_controller_other_test.rb +++ b/test/multiverse/suites/rails/action_controller_other_test.rb @@ -231,7 +231,7 @@ def controller_class def confirm_key_exists_in_params(node) assertion_failure = "Expected to find the cache key >>#{DataController::CACHE_KEY}<< in the node params!" # Rails v7.2+ stores the URI string, so look for the key on the end of it - if rails_version_at_least?('7.2.0.beta1') + if rails_version_at_least?('7.2.0') assert_match(/#{CGI.escape("/#{DataController::CACHE_KEY}")}/, node.params[:key], assertion_failure) # Rails < v7.2 stores the params in an array, so confirm it includes the key else diff --git a/test/multiverse/suites/rails/middleware_instrumentation_test.rb b/test/multiverse/suites/rails/middleware_instrumentation_test.rb index c1696d8be9..270cc6c3d8 100644 --- a/test/multiverse/suites/rails/middleware_instrumentation_test.rb +++ b/test/multiverse/suites/rails/middleware_instrumentation_test.rb @@ -18,9 +18,14 @@ def test_rails_middleware_records_metrics def test_rails_routeset_is_instrumented get('/') - assert_metrics_recorded( + # Rails v8.0+ uses lazy routing + metric = if rails_version_at_least?('8.0.0.alpha') + 'Middleware/Rack/Rails::Engine::LazyRouteSet/call' + else 'Middleware/Rack/ActionDispatch::Routing::RouteSet/call' - ) + end + + assert_metrics_recorded(metric) end if Rails::VERSION::MAJOR >= 4 From 195aaf72b235d1ea51409a235e121bc98a9647e6 Mon Sep 17 00:00:00 2001 From: fallwith Date: Mon, 12 Aug 2024 11:22:44 -0700 Subject: [PATCH 2/2] CI: stream test - only check for send_test_stream For this Rails v7.2+ test, only check for send_test_stream as the official non-beta release of v7.2.0 and Rails v8.0.0.alpha both only result in send_test_stream being reported --- .../suites/rails/action_controller_other_test.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/multiverse/suites/rails/action_controller_other_test.rb b/test/multiverse/suites/rails/action_controller_other_test.rb index acc6718d7a..7986435cc2 100644 --- a/test/multiverse/suites/rails/action_controller_other_test.rb +++ b/test/multiverse/suites/rails/action_controller_other_test.rb @@ -78,12 +78,11 @@ def test_send_data end def test_send_stream - # rails/rails@ed68af0 now defers all streaming behavior over to Rack (v3+) itself, so test - # only versions >= 7.2 and < 8.0 - skip unless rails_version_at_least?('7.2') && !rails_version_at_least?('8.0.0.alpha') + skip unless rails_version_at_least?('7.2') + get('/data/send_test_stream') - assert_metrics_recorded(['Controller/data/send_test_stream', 'Ruby/ActionController/send_stream']) + assert_metrics_recorded(['Controller/data/send_test_stream']) end def test_halted_callback