From 3acc76474d3fe988abf51de4e7f0a49c7954d4fa Mon Sep 17 00:00:00 2001 From: arberkatellari Date: Mon, 13 Jan 2025 14:05:20 +0200 Subject: [PATCH] Apply minor changes to FilterRule function's error handling --- data/conf/samples/dispatchers/all/cgrates.json | 5 +++++ data/conf/samples/dispatchers/all2/cgrates.json | 4 ++++ data/conf/samples/radagent_internal/cgrates.json | 6 +++++- data/conf/samples/radagent_mongo/cgrates.json | 6 +++++- data/conf/samples/radagent_mysql/cgrates.json | 6 +++++- data/conf/samples/radius_coa_disconnect/cgrates.json | 4 ++++ engine/filters.go | 6 ++++++ engine/filters_test.go | 6 +++--- 8 files changed, 37 insertions(+), 6 deletions(-) diff --git a/data/conf/samples/dispatchers/all/cgrates.json b/data/conf/samples/dispatchers/all/cgrates.json index c61859a36..ac00409f4 100644 --- a/data/conf/samples/dispatchers/all/cgrates.json +++ b/data/conf/samples/dispatchers/all/cgrates.json @@ -37,6 +37,11 @@ "enabled": true }, +"filters": { + "apiers_conns": ["*internal"], +}, + + "rals": { "enabled": true }, diff --git a/data/conf/samples/dispatchers/all2/cgrates.json b/data/conf/samples/dispatchers/all2/cgrates.json index 57d16f045..1a3484ff5 100644 --- a/data/conf/samples/dispatchers/all2/cgrates.json +++ b/data/conf/samples/dispatchers/all2/cgrates.json @@ -32,6 +32,10 @@ "enabled": true }, +"filters": { + "apiers_conns": ["*internal"], +}, + "rals": { "enabled": true }, diff --git a/data/conf/samples/radagent_internal/cgrates.json b/data/conf/samples/radagent_internal/cgrates.json index 0e13c2118..e46d5a19b 100644 --- a/data/conf/samples/radagent_internal/cgrates.json +++ b/data/conf/samples/radagent_internal/cgrates.json @@ -3,7 +3,7 @@ // "general": { - "log_level": 6, + "log_level": 7, }, @@ -23,6 +23,10 @@ "db_type": "*internal", }, +"filters": { + "apiers_conns": ["*localhost"], +}, + "rals": { "enabled": true, }, diff --git a/data/conf/samples/radagent_mongo/cgrates.json b/data/conf/samples/radagent_mongo/cgrates.json index e35d2b923..1157d952e 100644 --- a/data/conf/samples/radagent_mongo/cgrates.json +++ b/data/conf/samples/radagent_mongo/cgrates.json @@ -3,7 +3,7 @@ // "general": { - "log_level": 6, + "log_level": 7, }, @@ -27,6 +27,10 @@ "db_password": "", }, +"filters": { + "apiers_conns": ["*localhost"], +}, + "rals": { "enabled": true, }, diff --git a/data/conf/samples/radagent_mysql/cgrates.json b/data/conf/samples/radagent_mysql/cgrates.json index 0e81b40d6..f33662a0c 100644 --- a/data/conf/samples/radagent_mysql/cgrates.json +++ b/data/conf/samples/radagent_mysql/cgrates.json @@ -3,7 +3,7 @@ // "general": { - "log_level": 6, + "log_level": 7, }, @@ -23,6 +23,10 @@ "db_password": "CGRateS.org", // password to use when connecting to stordb }, +"filters": { + "apiers_conns": ["*localhost"], +}, + "rals": { "enabled": true, }, diff --git a/data/conf/samples/radius_coa_disconnect/cgrates.json b/data/conf/samples/radius_coa_disconnect/cgrates.json index 4963f1e85..bccacc991 100644 --- a/data/conf/samples/radius_coa_disconnect/cgrates.json +++ b/data/conf/samples/radius_coa_disconnect/cgrates.json @@ -12,6 +12,10 @@ "db_type": "*internal" }, +"filters": { + "apiers_conns": ["*localhost"], +}, + "rals": { "enabled": true, "thresholds_conns": ["*localhost"] diff --git a/engine/filters.go b/engine/filters.go index da0b7193a..b85f789c7 100644 --- a/engine/filters.go +++ b/engine/filters.go @@ -527,6 +527,9 @@ func (fltr *FilterRule) passTimings(dDP utils.DataProvider) (bool, error) { if err = connMgr.Call(context.TODO(), config.CgrConfig().FilterSCfg().ApierSConns, utils.APIerSv1GetTiming, &utils.ArgsGetTimingID{ID: valTmID}, &tm); err != nil { + if err.Error() != utils.ErrNotFound.Error() { + return false, err + } continue } ritm := &RITiming{ @@ -558,6 +561,9 @@ func (fltr *FilterRule) passDestinations(dDP utils.DataProvider) (bool, error) { if err = connMgr.Call(context.TODO(), config.CgrConfig().FilterSCfg().ApierSConns, utils.APIerSv1GetReverseDestination, &p, &destIDs); err != nil { + if err.Error() != utils.ErrNotFound.Error() { + return false, err + } continue } for _, dID := range destIDs { diff --git a/engine/filters_test.go b/engine/filters_test.go index 9b369aabf..7b9a3b74b 100644 --- a/engine/filters_test.go +++ b/engine/filters_test.go @@ -2046,7 +2046,7 @@ func TestFiltersPassTimingsCallErr(t *testing.T) { } rcv, err := fltr.passTimings(dtP) - if err != nil { + if err.Error() != "MANDATORY_IE_MISSING: [connIDs]" { t.Error(err) } @@ -2106,7 +2106,7 @@ func TestFiltersPassDestinationsCallErr(t *testing.T) { rcv, err := fltr.passDestinations(dtP) - if err != nil { + if err.Error() != "MANDATORY_IE_MISSING: [connIDs]" { t.Error(err) } @@ -2371,7 +2371,7 @@ func TestWeightFromDynamics(t *testing.T) { connMgr: nil, } - if _, err := WeightFromDynamics(dWs, fltrS, "cgrates.org", pEv); err != nil { + if _, err := WeightFromDynamics(dWs, fltrS, "cgrates.org", pEv); err.Error() != "MANDATORY_IE_MISSING: [connIDs]" { t.Error(err) }