diff --git a/data/conf/samples/gocs/au_site/cgrates.json b/data/conf/samples/gocs/au_site/cgrates.json index 943188256..bbf54daf3 100644 --- a/data/conf/samples/gocs/au_site/cgrates.json +++ b/data/conf/samples/gocs/au_site/cgrates.json @@ -50,7 +50,8 @@ "*dispatcher_profiles":{"remote":true}, "*dispatcher_hosts":{"remote":true}, "*filter_indexes" :{"remote":true}, - "*load_ids":{"remote":true} + "*load_ids":{"remote":true}, + "*indexes":{"remote":true} } }, diff --git a/data/conf/samples/gocs/us_site/cgrates.json b/data/conf/samples/gocs/us_site/cgrates.json index 9495d33e8..ddd8b878f 100644 --- a/data/conf/samples/gocs/us_site/cgrates.json +++ b/data/conf/samples/gocs/us_site/cgrates.json @@ -56,7 +56,8 @@ "*dispatcher_profiles":{"replicate":false}, "*dispatcher_hosts":{"replicate":false}, "*filter_indexes" :{"replicate":false}, - "*load_ids":{"replicate":false} + "*load_ids":{"replicate":false}, + "*indexes":{"replicate":false} } }, diff --git a/data/tutorial_tests/kamevapi/cgrates/etc/cgrates/cgrates.json b/data/tutorial_tests/kamevapi/cgrates/etc/cgrates/cgrates.json index e7042fa9c..13a0ea78c 100644 --- a/data/tutorial_tests/kamevapi/cgrates/etc/cgrates/cgrates.json +++ b/data/tutorial_tests/kamevapi/cgrates/etc/cgrates/cgrates.json @@ -37,6 +37,7 @@ "cdrs": { "enabled": true, "stats_conns": ["*localhost"], + "chargers_conns": ["*internal"], "rals_conns": ["*localhost"], "sessions_cost_retries": 5, }, @@ -59,7 +60,7 @@ "thresholds_conns": ["*localhost"], "chargers_conns": ["*localhost"], "debit_interval": "5s", - "channel_sync_interval":"7s", + "channel_sync_interval":"7s", }, @@ -101,6 +102,7 @@ "enabled": true, "resources_conns": ["*internal"], "stats_conns": ["*internal"], + "rals_conns": ["*internal"], "string_indexed_fields": ["Account"], }, diff --git a/data/tutorial_tests/kamevapi/kamailio/etc/kamailio/kamailio.cfg b/data/tutorial_tests/kamevapi/kamailio/etc/kamailio/kamailio.cfg index 85672bced..452cd9d0d 100644 --- a/data/tutorial_tests/kamevapi/kamailio/etc/kamailio/kamailio.cfg +++ b/data/tutorial_tests/kamevapi/kamailio/etc/kamailio/kamailio.cfg @@ -217,14 +217,12 @@ route[CGRATES_SESSIONAUTH_REPLY] { $dlg_var(cgrDestination) = $rU; $dlg_var(paypalAccount) = $avp(PaypalAccount); - if $var(cgrMaxUsage) != -1 { - if $var(cgrMaxUsage) == 0 { // Not enough balance, do not allow the call to go through - sl_send_reply("403","Insufficient credit"); - exit; - } else if !dlg_set_timeout("$var(cgrMaxUsage)") { - sl_send_reply("503","CGR_MAX_USAGE_ERROR"); - exit; - } + if $var(cgrMaxUsage) == 0 { // Not enough balance, do not allow the call to go through + sl_send_reply("403","Insufficient credit"); + exit; + } else if !dlg_set_timeout("$var(cgrMaxUsage)") { + sl_send_reply("503","CGR_MAX_USAGE_ERROR"); + exit; } if $var(cgrSuppliers) != "" { # Enforce the supplier variable to the first one received from CGRateS, here more for demo purposes diff --git a/data/tutorials/kamevapi/cgrates/etc/cgrates/cgrates.json b/data/tutorials/kamevapi/cgrates/etc/cgrates/cgrates.json index fc5a1ea35..4e1c4122d 100644 --- a/data/tutorials/kamevapi/cgrates/etc/cgrates/cgrates.json +++ b/data/tutorials/kamevapi/cgrates/etc/cgrates/cgrates.json @@ -37,6 +37,7 @@ "cdrs": { "enabled": true, "stats_conns": ["*localhost"], + "chargers_conns": ["*internal"], "rals_conns": ["*localhost"], "sessions_cost_retries": 5, }, @@ -101,6 +102,7 @@ "enabled": true, "resources_conns": ["*internal"], "stats_conns": ["*internal"], + "rals_conns": ["*internal"], "string_indexed_fields": ["Account"], }, diff --git a/dispatchers/sessions_it_test.go b/dispatchers/sessions_it_test.go index bd5ac3a6e..303e9c94b 100755 --- a/dispatchers/sessions_it_test.go +++ b/dispatchers/sessions_it_test.go @@ -703,12 +703,20 @@ func testDspSessionProcessEvent2(t *testing.T) { func testDspSessionReplicate(t *testing.T) { allEngine.initDataDb(t) allEngine.resetStorDb(t) + var reply string + // reload cache in order to corectly cahce the indexes + if err := allEngine.RPC.Call(utils.CacheSv1Clear, &utils.AttrCacheIDsWithArgDispatcher{ + CacheIDs: nil, + }, &reply); err != nil { + t.Error(err) + } else if reply != utils.OK { + t.Error("Reply: ", reply) + } allEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "testit")) testDspSessionAddBalacne(t) testDspSessionAuthorize(t) testDspSessionInit(t) - var reply string if err := dispEngine.RPC.Call(utils.SessionSv1ReplicateSessions, &ArgsReplicateSessionsWithApiKey{ ArgDispatcher: &utils.ArgDispatcher{ APIKey: utils.StringPointer("ses12345"), @@ -789,7 +797,7 @@ func testDspSessionPassive(t *testing.T) { utils.Usage: 5 * time.Minute, }), SRuns: []*sessions.SRun{ - &sessions.SRun{ + { Event: engine.NewMapEvent(map[string]interface{}{ "RunID": "CustomerCharges", utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf", diff --git a/engine/resources.go b/engine/resources.go index 76b809e7f..f9afe5097 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -549,9 +549,7 @@ func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREvent, break } } - if errCh := Cache.Set(utils.CacheEventResources, evUUID, rs.resIDsMp(), nil, true, ""); errCh != nil { - return nil, errCh - } + err = Cache.Set(utils.CacheEventResources, evUUID, rs.resIDsMp(), nil, true, "") return } diff --git a/engine/tpreader.go b/engine/tpreader.go index 951b51389..da88c5e1e 100644 --- a/engine/tpreader.go +++ b/engine/tpreader.go @@ -552,7 +552,7 @@ func (tpr *TpReader) LoadActionPlans() (err error) { return err } storAps := MapTPActionTimings(tps) - for atId, ats := range storAps { + for atID, ats := range storAps { for _, at := range ats { _, exists := tpr.actions[at.ActionsId] @@ -569,9 +569,9 @@ func (tpr *TpReader) LoadActionPlans() (err error) { return fmt.Errorf("[ActionPlans] Could not load the timing for tag: %v", at.TimingId) } var actPln *ActionPlan - if actPln, exists = tpr.actionPlans[atId]; !exists { + if actPln, exists = tpr.actionPlans[atID]; !exists { actPln = &ActionPlan{ - Id: atId, + Id: atID, } } actPln.ActionTimings = append(actPln.ActionTimings, &ActionTiming{ @@ -589,7 +589,7 @@ func (tpr *TpReader) LoadActionPlans() (err error) { ActionsID: at.ActionsId, }) - tpr.actionPlans[atId] = actPln + tpr.actionPlans[atID] = actPln } } return nil @@ -1796,7 +1796,7 @@ func (tpr *TpReader) ShowStatistics() { prefixDist := make(map[int]int, 50) prefixCount := 0 for _, d := range tpr.destinations { - prefixDist[len(d.Prefixes)] += 1 + prefixDist[len(d.Prefixes)]++ prefixCount += len(d.Prefixes) } log.Print("Avg Prefixes: ", prefixCount/destCount) @@ -1810,7 +1810,7 @@ func (tpr *TpReader) ShowStatistics() { destRatesDist := make(map[int]int, 50) destRatesCount := 0 for _, rpl := range tpr.ratingPlans { - destRatesDist[len(rpl.DestinationRates)] += 1 + destRatesDist[len(rpl.DestinationRates)]++ destRatesCount += len(rpl.DestinationRates) } log.Print("Avg Destination Rates: ", destRatesCount/rplCount) @@ -1824,7 +1824,7 @@ func (tpr *TpReader) ShowStatistics() { activDist := make(map[int]int, 50) activCount := 0 for _, rpf := range tpr.ratingProfiles { - activDist[len(rpf.RatingPlanActivations)] += 1 + activDist[len(rpf.RatingPlanActivations)]++ activCount += len(rpf.RatingPlanActivations) } log.Print("Avg Activations: ", activCount/rpfCount) diff --git a/engine/units_counter_test.go b/engine/units_counter_test.go index fc3ea7f4e..1e60fce4d 100644 --- a/engine/units_counter_test.go +++ b/engine/units_counter_test.go @@ -38,23 +38,15 @@ func TestUnitCounterClone(t *testing.T) { uc = &UnitCounter{ CounterType: "testCounterType", Counters: []*CounterFilter{ - &CounterFilter{ - Value: 0.7, - }, - &CounterFilter{ - Value: 0.8, - }, + {Value: 0.7}, + {Value: 0.8}, }, } eOut = &UnitCounter{ CounterType: "testCounterType", Counters: []*CounterFilter{ - &CounterFilter{ - Value: 0.7, - }, - &CounterFilter{ - Value: 0.8, - }, + {Value: 0.7}, + {Value: 0.8}, }, } if rcv := uc.Clone(); !reflect.DeepEqual(eOut, rcv) { diff --git a/utils/errors.go b/utils/errors.go index d964481c4..05dd09b7e 100644 --- a/utils/errors.go +++ b/utils/errors.go @@ -173,7 +173,7 @@ func NewErrResourceS(err error) error { } func NewErrSupplierS(err error) error { - return fmt.Errorf("SUPPLIERS_ERROR:%s", err) + return fmt.Errorf("ROUTES_ERROR:%s", err) } func NewErrAttributeS(err error) error { diff --git a/utils/errors_test.go b/utils/errors_test.go index 98ba2fc73..c431d4193 100644 --- a/utils/errors_test.go +++ b/utils/errors_test.go @@ -116,8 +116,8 @@ func TestNewErrResourceS(t *testing.T) { func TestNewErrSupplierS(t *testing.T) { cgrError := NewCGRError("context", "apiError", "shortError", "longError") - if rcv := NewErrSupplierS(cgrError); rcv.Error() != "SUPPLIERS_ERROR:shortError" { - t.Errorf("Expecting: SUPPLIERS_ERROR:shortError, received: %+v", rcv) + if rcv := NewErrSupplierS(cgrError); rcv.Error() != "ROUTES_ERROR:shortError" { + t.Errorf("Expecting: ROUTES_ERROR:shortError, received: %+v", rcv) } } func TestNewErrAttributeS(t *testing.T) {