diff --git a/apier/v1/apier.go b/apier/v1/apier.go index 8a8d59851..7510d3e5e 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -1073,8 +1073,8 @@ func (self *ApierV1) GetCacheStats(attrs utils.AttrCacheStats, reply *utils.Cach // GetCacheKeys returns a list of keys available in cache based on query arguments // If keys are provided in arguments, they will be checked for existence func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache) (err error) { - var ids []string if args.DestinationIDs != nil { + var ids []string if len(*args.DestinationIDs) != 0 { for _, id := range *args.DestinationIDs { if _, hasIt := cache.Get(utils.DESTINATION_PREFIX + id); hasIt { @@ -1092,7 +1092,7 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache } } if args.ReverseDestinationIDs != nil { - ids = nil // reset it + var ids []string if len(*args.ReverseDestinationIDs) != 0 { for _, id := range *args.ReverseDestinationIDs { if _, hasIt := cache.Get(utils.REVERSE_DESTINATION_PREFIX + id); hasIt { @@ -1110,7 +1110,7 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache } } if args.RatingPlanIDs != nil { - ids = nil + var ids []string if len(*args.RatingPlanIDs) != 0 { for _, id := range *args.RatingPlanIDs { if _, hasIt := cache.Get(utils.RATING_PLAN_PREFIX + id); hasIt { @@ -1128,7 +1128,7 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache } } if args.RatingProfileIDs != nil { - ids = nil + var ids []string if len(*args.RatingProfileIDs) != 0 { for _, id := range *args.RatingProfileIDs { if _, hasIt := cache.Get(utils.RATING_PROFILE_PREFIX + id); hasIt { @@ -1146,7 +1146,7 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache } } if args.ActionIDs != nil { - ids = nil + var ids []string if len(*args.ActionIDs) != 0 { for _, id := range *args.ActionIDs { if _, hasIt := cache.Get(utils.ACTION_PREFIX + id); hasIt { @@ -1164,7 +1164,7 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache } } if args.ActionPlanIDs != nil { - ids = nil + var ids []string if len(*args.ActionPlanIDs) != 0 { for _, id := range *args.ActionPlanIDs { if _, hasIt := cache.Get(utils.ACTION_PLAN_PREFIX + id); hasIt { @@ -1182,7 +1182,7 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache } } if args.ActionTriggerIDs != nil { - ids = nil + var ids []string if len(*args.ActionTriggerIDs) != 0 { for _, id := range *args.ActionTriggerIDs { if _, hasIt := cache.Get(utils.ACTION_TRIGGER_PREFIX + id); hasIt { @@ -1200,7 +1200,7 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache } } if args.SharedGroupIDs != nil { - ids = nil + var ids []string if len(*args.SharedGroupIDs) != 0 { for _, id := range *args.SharedGroupIDs { if _, hasIt := cache.Get(utils.SHARED_GROUP_PREFIX + id); hasIt { @@ -1218,7 +1218,7 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache } } if args.LCRids != nil { - ids = nil + var ids []string if len(*args.LCRids) != 0 { for _, id := range *args.LCRids { if _, hasIt := cache.Get(utils.LCR_PREFIX + id); hasIt { @@ -1236,7 +1236,7 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache } } if args.DerivedChargerIDs != nil { - ids = nil + var ids []string if len(*args.DerivedChargerIDs) != 0 { for _, id := range *args.DerivedChargerIDs { if _, hasIt := cache.Get(utils.DERIVEDCHARGERS_PREFIX + id); hasIt { @@ -1254,7 +1254,7 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache } } if args.AliasIDs != nil { - ids = nil + var ids []string if len(*args.AliasIDs) != 0 { for _, id := range *args.AliasIDs { if _, hasIt := cache.Get(utils.ALIASES_PREFIX + id); hasIt { @@ -1272,7 +1272,7 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache } } if args.ReverseAliasIDs != nil { - ids = nil + var ids []string if len(*args.ReverseAliasIDs) != 0 { for _, id := range *args.ReverseAliasIDs { if _, hasIt := cache.Get(utils.REVERSE_ALIASES_PREFIX + id); hasIt { @@ -1290,7 +1290,7 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache } } if args.ResourceLimitIDs != nil { - ids = nil + var ids []string if len(*args.ResourceLimitIDs) != 0 { for _, id := range *args.ResourceLimitIDs { if _, hasIt := cache.Get(utils.ResourceLimitsPrefix + id); hasIt { diff --git a/data/conf/samples/tutmongo/cgrates.json b/data/conf/samples/tutmongo/cgrates.json index a6cc6e53f..49f6f73b6 100644 --- a/data/conf/samples/tutmongo/cgrates.json +++ b/data/conf/samples/tutmongo/cgrates.json @@ -4,6 +4,10 @@ // Used for cgradmin // Starts rater, scheduler +"general": { + "log_level": 7, +}, + "listen": { "rpc_json": ":2012", // RPC JSON listening address "rpc_gob": ":2013", // RPC GOB listening address diff --git a/general_tests/tutorial_it_test.go b/general_tests/tutorial_it_test.go index fc3c3898b..8582593c9 100644 --- a/general_tests/tutorial_it_test.go +++ b/general_tests/tutorial_it_test.go @@ -110,14 +110,22 @@ func TestTutITCacheStats(t *testing.T) { } else if !reflect.DeepEqual(expectedStats, rcvStats) { t.Errorf("Calling ApierV2.GetCacheStats expected: %+v, received: %+v", expectedStats, rcvStats) } - expKeys := utils.ArgsCache{DestinationIDs: &[]string{"DST_1003", "DST_1002", "DST_DE_MOBILE", "DST_1007", "DST_FS"}} + expKeys := utils.ArgsCache{ + DestinationIDs: &[]string{"DST_1003", "DST_1002", "DST_DE_MOBILE", "DST_1007", "DST_FS"}, + RatingPlanIDs: &[]string{"RP_RETAIL1", "RP_GENERIC"}, + } var rcvKeys utils.ArgsCache - if err := tutLocalRpc.Call("ApierV1.GetCacheKeys", utils.ArgsCacheKeys{ArgsCache: utils.ArgsCache{DestinationIDs: &[]string{}}}, &rcvKeys); err != nil { + argsAPI := utils.ArgsCacheKeys{ArgsCache: utils.ArgsCache{ + DestinationIDs: &[]string{}, RatingPlanIDs: &[]string{"RP_RETAIL1", "RP_GENERIC", "NONEXISTENT"}}} + if err := tutLocalRpc.Call("ApierV1.GetCacheKeys", argsAPI, &rcvKeys); err != nil { t.Error("Got error on ApierV2.GetCacheStats: ", err.Error()) } else { if len(*expKeys.DestinationIDs) != len(*rcvKeys.DestinationIDs) { t.Errorf("Expected: %+v, received: %+v", expKeys.DestinationIDs, rcvKeys.DestinationIDs) } + if !reflect.DeepEqual(*expKeys.RatingPlanIDs, *rcvKeys.RatingPlanIDs) { + t.Errorf("Expected: %+v, received: %+v", expKeys.RatingPlanIDs, rcvKeys.RatingPlanIDs) + } } if _, err := engine.StopStartEngine(tutLocalCfgPath, 1500); err != nil { t.Fatal(err)