Skip to content

Commit

Permalink
config to control the behavior of the CallsMonitoring job
Browse files Browse the repository at this point in the history
introduces new configuration options in yeti_web.yml to control
the behavior of the CallsMonitoring job when dealing with
disabled customer
authentication and termination gateways:

- calls_monitoring.teardown_on_disabled_customer_auth
- calls_monitoring.teardown_on_disabled_term_gw

The CallsMonitoring class has been updated to use
these configurations in the
relevant methods. If the configs are not present,
the current behavior (terminating
calls for disabled customer auth and termination
gateways) is maintained.

The calls_monitoring_spec.rb file has been updated
with new test cases for the
introduced configurations.
  • Loading branch information
Ivanov-Anton committed Aug 9, 2024
1 parent e67ab7c commit e1067f2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/jobs/jobs/calls_monitoring.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ def detect_vendors_calls_to_reject
# drop calls where `customer_auth_id`
# is linked to `CustomersAuth#reject_calls = true`
def detect_customers_auth_calls_to_reject
return unless CallsMonitoring.teardown_on_disabled_customer_auth?

flatten_calls.each do |call|
customers_auth_id = call[:customer_auth_id]
customers_auth = active_customers_auths_reject_calls[customers_auth_id]
Expand All @@ -286,10 +288,21 @@ def detect_customers_auth_calls_to_reject
end
end

def self.teardown_on_disabled_customer_auth?
YetiConfig.calls_monitoring.teardown_on_disabled_customer_auth.nil? || YetiConfig.calls_monitoring.teardown_on_disabled_customer_auth
end

def self.teardown_on_disabled_term_gw?
YetiConfig.calls_monitoring.teardown_on_disabled_term_gw.nil? || YetiConfig.calls_monitoring.teardown_on_disabled_term_gw
end

# detect gateway is disabled by orig_gw_id and term_gw_id
def detect_gateway_calls_to_reject
flatten_calls.each do |call|
if disabled_orig_gw_active_calls.key?(call[:orig_gw_id]) || disabled_term_gw_active_calls.key?(call[:term_gw_id])
if disabled_orig_gw_active_calls.key?(call[:orig_gw_id])
local_tag = call[:local_tag]
@terminate_calls[local_tag] = call
elsif CallsMonitoring.teardown_on_disabled_term_gw? && disabled_term_gw_active_calls.key?(call[:term_gw_id])
local_tag = call[:local_tag]
@terminate_calls[local_tag] = call
end
Expand Down
2 changes: 2 additions & 0 deletions config/yeti_web.yml.ci
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ site_title_image: "yeti.png"
calls_monitoring:
write_account_stats: true
write_gateway_stats: true
teardown_on_disabled_customer_auth: false
teardown_on_disabled_term_gw: false
api:
token_lifetime: 600 # jwt token lifetime in seconds, empty string means permanent tokens
cdr_export:
Expand Down
2 changes: 2 additions & 0 deletions config/yeti_web.yml.development
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ site_title_image: "yeti.png"
calls_monitoring:
write_account_stats: true
write_gateway_stats: true
teardown_on_disabled_customer_auth: false
teardown_on_disabled_term_gw: false
api:
token_lifetime: 600 # jwt token lifetime in seconds, empty string means permanent tokens
cdr_export:
Expand Down
2 changes: 2 additions & 0 deletions config/yeti_web.yml.distr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ site_title_image: "yeti.png"
calls_monitoring:
write_account_stats: true
write_gateway_stats: true
teardown_on_disabled_customer_auth: false
teardown_on_disabled_term_gw: false
api:
token_lifetime: 600 # jwt token lifetime in seconds, empty string means permanent tokens
cdr_export:
Expand Down
4 changes: 4 additions & 0 deletions spec/jobs/jobs/calls_monitoring_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@
end
end

context 'when YetiConfig.calls_monitoring.teardown_on_disabled_customer_auth' do

end

context 'when YetiConfig.calls_monitoring.write_gateway_stats=false' do
before do
expect(YetiConfig.calls_monitoring).to receive(:write_gateway_stats).and_return(false)
Expand Down

0 comments on commit e1067f2

Please sign in to comment.