Skip to content
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

upgrade rails pgq-processors #1688

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion pgq-processors/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -15,10 +15,13 @@ 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'
gem 'byebug'
gem 'rspec'
gem 'webmock'
end

46 changes: 32 additions & 14 deletions pgq-processors/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,49 @@ 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)
activesupport (>= 6.0)
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)
Expand All @@ -48,20 +59,24 @@ 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)
domain_name (~> 0.5)
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)
mime-types-data (~> 3.2015)
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)
Expand Down Expand Up @@ -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)
Expand All @@ -109,29 +126,30 @@ 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
bunny
bunny-mock
byebug
http_logger
json (~> 2.9)
net-smtp
pg
pgq!
pony
rake
rest-client
rspec
syslog (~> 0.2.0)
syslog-logger
webmock

BUNDLED WITH
2.6.2
2.6.3
4 changes: 2 additions & 2 deletions pgq-processors/ext/pgq/pgq.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions pgq-processors/pgq_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 17 additions & 12 deletions pgq-processors/spec/processors/cdr_billing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pgq-processors/spec/processors/cdr_stat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down
Loading