From 59ec680383e8ccef94489f9e6be548023ee2b981 Mon Sep 17 00:00:00 2001 From: Bastian Bartmann Date: Fri, 7 Feb 2025 10:12:42 +0100 Subject: [PATCH] Drop support for EOL AR v6.1 (#178) --- .github/workflows/test.yml | 2 +- .ruby-version | 2 +- Appraisals | 5 -- gemfiles/activerecord_6.1.gemfile | 8 --- gemfiles/activerecord_6.1.gemfile.lock | 80 ------------------------- lib/lhm/throttler/replica_lag.rb | 19 +----- spec/unit/throttler/replica_lag_spec.rb | 6 +- 7 files changed, 4 insertions(+), 118 deletions(-) delete mode 100644 gemfiles/activerecord_6.1.gemfile delete mode 100644 gemfiles/activerecord_6.1.gemfile.lock diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 318e8c18..09977bc4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false max-parallel: 8 matrix: - activerecord: ["6.1", "7.2", "8.0", "head"] + activerecord: ["7.2", "8.0", "head"] ruby: ["3.1", "3.2", "3.3", "head"] mysql: ["5.7", "8.0"] adapter: ["mysql2", "trilogy"] diff --git a/.ruby-version b/.ruby-version index be94e6f5..9c25013d 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.2.2 +3.3.6 diff --git a/Appraisals b/Appraisals index 871ce2f8..5ac75187 100644 --- a/Appraisals +++ b/Appraisals @@ -1,8 +1,3 @@ -appraise "activerecord-6.1" do - gem "activerecord", "6.1.0" - gem "activerecord-trilogy-adapter" -end - appraise "activerecord-7.2" do gem "activerecord", "7.2.2.1" end diff --git a/gemfiles/activerecord_6.1.gemfile b/gemfiles/activerecord_6.1.gemfile deleted file mode 100644 index 226ae919..00000000 --- a/gemfiles/activerecord_6.1.gemfile +++ /dev/null @@ -1,8 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "activerecord", "6.1.0" -gem "activerecord-trilogy-adapter" - -gemspec path: "../" diff --git a/gemfiles/activerecord_6.1.gemfile.lock b/gemfiles/activerecord_6.1.gemfile.lock deleted file mode 100644 index 14f230f3..00000000 --- a/gemfiles/activerecord_6.1.gemfile.lock +++ /dev/null @@ -1,80 +0,0 @@ -PATH - remote: .. - specs: - lhm-shopify (4.4.2) - retriable (>= 3.0.0) - -GEM - remote: https://rubygems.org/ - specs: - activemodel (6.1.0) - activesupport (= 6.1.0) - activerecord (6.1.0) - activemodel (= 6.1.0) - activesupport (= 6.1.0) - activerecord-trilogy-adapter (3.1.2) - activerecord (>= 6.0.a, < 7.1.a) - trilogy (>= 2.4.0) - activesupport (6.1.0) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - after_do (0.4.0) - appraisal (2.5.0) - bundler - rake - thor (>= 0.14.0) - byebug (11.1.3) - concurrent-ruby (1.2.2) - docile (1.4.0) - i18n (1.14.1) - concurrent-ruby (~> 1.0) - logger (1.6.1) - minitest (5.22.2) - mocha (2.1.0) - ruby2_keywords (>= 0.0.5) - mysql2 (0.5.5) - ostruct (0.6.1) - rake (13.0.6) - retriable (3.1.2) - ruby2_keywords (0.0.5) - simplecov (0.22.0) - docile (~> 1.1) - simplecov-html (~> 0.11) - simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) - simplecov_json_formatter (0.1.4) - thor (1.3.2) - toxiproxy (2.0.2) - trilogy (2.6.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - zeitwerk (2.6.12) - -PLATFORMS - arm64-darwin-21 - arm64-darwin-22 - x86_64-darwin-20 - x86_64-linux - -DEPENDENCIES - activerecord (= 6.1.0) - activerecord-trilogy-adapter - after_do - appraisal - byebug - lhm-shopify! - logger - minitest - mocha - mysql2 - ostruct - rake - simplecov - toxiproxy - trilogy - -BUNDLED WITH - 2.2.22 diff --git a/lib/lhm/throttler/replica_lag.rb b/lib/lhm/throttler/replica_lag.rb index 0d6784b6..b88485c8 100644 --- a/lib/lhm/throttler/replica_lag.rb +++ b/lib/lhm/throttler/replica_lag.rb @@ -134,7 +134,7 @@ def prepare_connection_config(config_proc) raise ArgumentError, "Expected #{config_proc.inspect} to respond to `call`" end else - db_config + ActiveRecord::Base.connection_pool.db_config.configuration_hash.dup end config.deep_symbolize_keys! config[:host] = @host @@ -147,23 +147,6 @@ def query_connection(query, result) Lhm.logger.info "Unable to connect and/or query #{host}: #{e}" [nil] end - - private - - def db_config - if ar_supports_db_config? - ActiveRecord::Base.connection_pool.db_config.configuration_hash.dup - else - ActiveRecord::Base.connection_pool.spec.config.dup - end - end - - def ar_supports_db_config? - # https://api.rubyonrails.org/v6.0/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html <-- has spec - # vs - # https://api.rubyonrails.org/v6.1/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html <-- has db_config - ActiveRecord::VERSION::MAJOR > 6 || ActiveRecord::VERSION::MAJOR == 6 && ActiveRecord::VERSION::MINOR >= 1 - end end end end diff --git a/spec/unit/throttler/replica_lag_spec.rb b/spec/unit/throttler/replica_lag_spec.rb index c7fb0fbe..31dbd18e 100644 --- a/spec/unit/throttler/replica_lag_spec.rb +++ b/spec/unit/throttler/replica_lag_spec.rb @@ -66,11 +66,7 @@ describe 'with active record config' do it 'logs and creates client' do active_record_config = { username: 'user', password: 'pw', database: 'db' } - if ActiveRecord::VERSION::MAJOR > 6 || ActiveRecord::VERSION::MAJOR == 6 && ActiveRecord::VERSION::MINOR >= 1 - ActiveRecord::Base.stubs(:connection_pool).returns(stub(db_config: stub(configuration_hash: active_record_config))) - else - ActiveRecord::Base.stubs(:connection_pool).returns(stub(spec: stub(config: active_record_config))) - end + ActiveRecord::Base.stubs(:connection_pool).returns(stub(db_config: stub(configuration_hash: active_record_config))) DATABASE.client.stubs(:new).returns(mock())