diff --git a/pgq-processors/Gemfile b/pgq-processors/Gemfile index 9bf3e8f0d..2a6421eb1 100644 --- a/pgq-processors/Gemfile +++ b/pgq-processors/Gemfile @@ -2,7 +2,7 @@ source 'http://rubygems.org' -gem 'activemodel', '~> 6.1.7.1' +gem 'activemodel', '~> 7.1.0' gem 'activeresource' gem 'activeresource-persistent', require: 'active_resource/persistent' gem 'bundler' @@ -15,6 +15,8 @@ gem 'pony' gem 'rake' gem 'rest-client' gem 'syslog-logger' +gem "syslog", "~> 0.2.0" +gem 'json', '~> 2.9' group :test, :development do gem 'bunny-mock' @@ -22,3 +24,4 @@ group :test, :development do gem 'rspec' gem 'webmock' end + diff --git a/pgq-processors/Gemfile.lock b/pgq-processors/Gemfile.lock index 214d7d1a9..f97593b7b 100644 --- a/pgq-processors/Gemfile.lock +++ b/pgq-processors/Gemfile.lock @@ -2,22 +2,23 @@ PATH remote: ext/pgq specs: pgq (0.1.3) - activerecord (>= 4.0.2) - activesupport (>= 4.0.2) + activerecord (~> 7.1.0) + activesupport (~> 7.1.0) pg GEM remote: http://rubygems.org/ specs: - activemodel (6.1.7.8) - activesupport (= 6.1.7.8) + activemodel (7.1.5.1) + activesupport (= 7.1.5.1) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) - activerecord (6.1.7.8) - activemodel (= 6.1.7.8) - activesupport (= 6.1.7.8) + activerecord (7.1.5.1) + activemodel (= 7.1.5.1) + activesupport (= 7.1.5.1) + timeout (>= 0.4.0) activeresource (6.0.0) activemodel (>= 6.0) activemodel-serializers-xml (~> 1.0) @@ -25,15 +26,25 @@ GEM activeresource-persistent (0.2.0) activeresource (>= 2.3.0) net-http-persistent (>= 2.5) - activesupport (6.1.7.8) + activesupport (7.1.5.1) + base64 + benchmark (>= 0.3) + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) + mutex_m + securerandom (>= 0.3) tzinfo (~> 2.0) - zeitwerk (~> 2.3) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) amq-protocol (2.3.2) + base64 (0.2.0) + benchmark (0.4.0) + bigdecimal (3.1.9) builder (3.2.4) bunny (2.20.3) amq-protocol (~> 2.3, >= 2.3.1) @@ -48,6 +59,7 @@ GEM diff-lcs (1.5.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) + drb (2.2.1) hashdiff (1.0.1) http-accept (1.7.0) http-cookie (1.0.4) @@ -55,6 +67,8 @@ GEM http_logger (0.7.0) i18n (1.8.11) concurrent-ruby (~> 1.0) + json (2.9.1) + logger (1.6.5) mail (2.7.1) mini_mime (>= 0.1.1) mime-types (3.4.1) @@ -62,6 +76,7 @@ GEM mime-types-data (3.2022.0105) mini_mime (1.1.2) minitest (5.15.0) + mutex_m (0.3.0) net-http-persistent (4.0.1) connection_pool (~> 2.2) net-protocol (0.2.1) @@ -94,12 +109,14 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.3) - set (1.0.3) + securerandom (0.4.1) + set (1.1.1) sorted_set (1.0.3) rbtree set (~> 1.0) + syslog (0.2.0) syslog-logger (1.6.8) - timeout (0.3.2) + timeout (0.4.3) tzinfo (2.0.4) concurrent-ruby (~> 1.0) unf (0.1.4) @@ -109,13 +126,12 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - zeitwerk (2.5.3) PLATFORMS ruby DEPENDENCIES - activemodel (~> 6.1.7.1) + activemodel (~> 7.1.0) activeresource activeresource-persistent bundler @@ -123,6 +139,7 @@ DEPENDENCIES bunny-mock byebug http_logger + json (~> 2.9) net-smtp pg pgq! @@ -130,8 +147,9 @@ DEPENDENCIES rake rest-client rspec + syslog (~> 0.2.0) syslog-logger webmock BUNDLED WITH - 2.6.2 + 2.6.3 diff --git a/pgq-processors/ext/pgq/pgq.gemspec b/pgq-processors/ext/pgq/pgq.gemspec index 5f5022b9e..830c185bb 100644 --- a/pgq-processors/ext/pgq/pgq.gemspec +++ b/pgq-processors/ext/pgq/pgq.gemspec @@ -17,8 +17,8 @@ Gem::Specification.new do |s| s.require_paths = ['lib'] - s.add_dependency 'activerecord', '>= 4.0.2' - s.add_dependency 'activesupport', '>= 4.0.2' + s.add_dependency 'activerecord', '~> 7.1.0' + s.add_dependency 'activesupport', '~> 7.1.0' s.add_dependency 'pg' s.add_development_dependency 'rake' diff --git a/pgq-processors/pgq_env.rb b/pgq-processors/pgq_env.rb index 7b197f6d6..2b1822d12 100644 --- a/pgq-processors/pgq_env.rb +++ b/pgq-processors/pgq_env.rb @@ -34,6 +34,7 @@ def initialize @config = ::PgqConfig.new(ENV['config_file'], ENV['processor']) ActiveRecord::Base.establish_connection(@config['source_database']) @logger = build_logger + ActiveRecord::Base.logger = @logger HttpLogger.logger = @logger Pgq::Worker.logger = @logger diff --git a/pgq-processors/spec/processors/cdr_billing_spec.rb b/pgq-processors/spec/processors/cdr_billing_spec.rb index c493b6192..df7d7223c 100644 --- a/pgq-processors/spec/processors/cdr_billing_spec.rb +++ b/pgq-processors/spec/processors/cdr_billing_spec.rb @@ -6,23 +6,26 @@ require File.join(File.dirname(__FILE__), '../../models/routing_base') RSpec.describe CdrBilling do - CONFIG = begin - f = YAML.safe_load(ERB.new(File.read('../config/database.yml')).result, aliases: true) - { - 'mode' => 'test', - 'databases' => f.to_h - } - end # fake models, since we have no access to main project class Account < ::RoutingBase self.table_name = 'billing.accounts' + + CONFIG = begin + f = YAML.safe_load(ERB.new(File.read('../config/database.yml')).result, aliases: true) + { + 'mode' => 'test', + 'databases' => f.to_h + } + end + establish_connection(CONFIG['databases']['test']['primary']) end class Contractor < ::RoutingBase self.table_name = 'public.contractors' - establish_connection(CONFIG['databases']['test']['primary']) + + establish_connection(Account::CONFIG['databases']['test']['primary']) end let(:cdrs) do @@ -43,10 +46,12 @@ class Contractor < ::RoutingBase let(:customer_reverse) { false } let(:consumer) do - described_class.new(TestContext.logger, - 'cdr_billing', - 'cdr_billin', - CONFIG) + described_class.new( + TestContext.logger, + 'cdr_billing', + 'cdr_billin', + Account::CONFIG + ) end let(:contractor) do diff --git a/pgq-processors/spec/processors/cdr_stat_spec.rb b/pgq-processors/spec/processors/cdr_stat_spec.rb index 67a2a6a63..39dc227eb 100644 --- a/pgq-processors/spec/processors/cdr_stat_spec.rb +++ b/pgq-processors/spec/processors/cdr_stat_spec.rb @@ -10,7 +10,7 @@ consumer.perform_batch end - CONFIG = begin + cfg = begin f = YAML.safe_load(ERB.new(File.read('../config/database.yml')).result, aliases: true) { 'mode' => 'test', @@ -20,13 +20,13 @@ end let(:consumer) do - described_class.new(TestContext.logger, nil, nil, CONFIG) + described_class.new(TestContext.logger, nil, nil, cfg) end let(:database_config) do - CONFIG['databases']['test']['cdr'] + cfg['databases']['test']['cdr'] end let(:expected_sql) do - "SELECT processed_records FROM #{CONFIG['stored_procedure']}()" + "SELECT processed_records FROM #{cfg['stored_procedure']}()" end before do