diff --git a/admins/dispatchers.go b/admins/dispatchers.go
deleted file mode 100644
index f85c922eb..000000000
--- a/admins/dispatchers.go
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package admins
-
-import (
- "fmt"
- "time"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-// GetDispatcherProfile returns a Dispatcher Profile
-func (admS *AdminS) V1GetDispatcherProfile(ctx *context.Context, arg *utils.TenantIDWithAPIOpts, reply *engine.DispatcherProfile) error {
- if missing := utils.MissingStructFields(arg, []string{utils.ID}); len(missing) != 0 { //Params missing
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- tnt := arg.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- dpp, err := admS.dm.GetDispatcherProfile(ctx, tnt, arg.ID, true, true, utils.NonTransactional)
- if err != nil {
- return utils.APIErrorHandler(err)
- }
- *reply = *dpp
- return nil
-}
-
-// GetDispatcherProfileIDs returns list of dispatcherProfile IDs registered for a tenant
-func (admS *AdminS) V1GetDispatcherProfileIDs(ctx *context.Context, args *utils.ArgsItemIDs, dPrfIDs *[]string) (err error) {
- tnt := args.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- prfx := utils.DispatcherProfilePrefix + tnt + utils.ConcatenatedKeySep
- lenPrfx := len(prfx)
- prfx += args.ItemsPrefix
- var keys []string
- if keys, err = admS.dm.DataDB().GetKeysForPrefix(ctx, prfx); err != nil {
- return
- }
- if len(keys) == 0 {
- return utils.ErrNotFound
- }
- retIDs := make([]string, len(keys))
- for i, key := range keys {
- retIDs[i] = key[lenPrfx:]
- }
- var limit, offset, maxItems int
- if limit, offset, maxItems, err = utils.GetPaginateOpts(args.APIOpts); err != nil {
- return
- }
- *dPrfIDs, err = utils.Paginate(retIDs, limit, offset, maxItems)
- return
-}
-
-// GetDispatcherProfiles returns a list of dispatcher profiles registered for a tenant
-func (admS *AdminS) V1GetDispatcherProfiles(ctx *context.Context, args *utils.ArgsItemIDs, dspPrfs *[]*engine.DispatcherProfile) (err error) {
- tnt := args.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- var dspPrfIDs []string
- if err = admS.V1GetDispatcherProfileIDs(ctx, args, &dspPrfIDs); err != nil {
- return
- }
- *dspPrfs = make([]*engine.DispatcherProfile, 0, len(dspPrfIDs))
- for _, dspPrfID := range dspPrfIDs {
- var dspPrf *engine.DispatcherProfile
- dspPrf, err = admS.dm.GetDispatcherProfile(ctx, tnt, dspPrfID, true, true, utils.NonTransactional)
- if err != nil {
- return utils.APIErrorHandler(err)
- }
- *dspPrfs = append(*dspPrfs, dspPrf)
- }
- return
-}
-
-// GetDispatcherProfilesCount returns the total number of DispatcherProfiles registered for a tenant
-// returns ErrNotFound in case of 0 DispatcherProfiles
-func (admS *AdminS) V1GetDispatcherProfilesCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := args.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- prfx := utils.DispatcherProfilePrefix + tnt + utils.ConcatenatedKeySep + args.ItemsPrefix
- var keys []string
- if keys, err = admS.dm.DataDB().GetKeysForPrefix(ctx, prfx); err != nil {
- return err
- }
- if len(keys) == 0 {
- return utils.ErrNotFound
- }
- *reply = len(keys)
- return
-}
-
-type DispatcherWithAPIOpts struct {
- *engine.DispatcherProfile
- APIOpts map[string]any
-}
-
-// SetDispatcherProfile add/update a new Dispatcher Profile
-func (admS *AdminS) V1SetDispatcherProfile(ctx *context.Context, args *DispatcherWithAPIOpts, reply *string) error {
- if missing := utils.MissingStructFields(args.DispatcherProfile, []string{utils.ID}); len(missing) != 0 {
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- if args.Tenant == utils.EmptyString {
- args.Tenant = admS.cfg.GeneralCfg().DefaultTenant
- }
- if err := admS.dm.SetDispatcherProfile(ctx, args.DispatcherProfile, true); err != nil {
- return utils.APIErrorHandler(err)
- }
- //generate a loadID for CacheDispatcherProfiles and store it in database
- if err := admS.dm.SetLoadIDs(ctx, map[string]int64{utils.CacheDispatcherProfiles: time.Now().UnixNano()}); err != nil {
- return utils.APIErrorHandler(err)
- }
- // delay if needed before cache call
- if admS.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", admS.cfg.GeneralCfg().CachingDelay))
- time.Sleep(admS.cfg.GeneralCfg().CachingDelay)
- }
- //handle caching for DispatcherProfile
- if err := admS.CallCache(ctx, utils.IfaceAsString(args.APIOpts[utils.MetaCache]), args.Tenant, utils.CacheDispatcherProfiles,
- args.TenantID(), utils.EmptyString, &args.FilterIDs, args.APIOpts); err != nil {
- return utils.APIErrorHandler(err)
- }
- // delay if needed before cache call
- if admS.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" (DispatchersInstance) Delaying cache call for %v", admS.cfg.GeneralCfg().CachingDelay))
- time.Sleep(admS.cfg.GeneralCfg().CachingDelay)
- }
- //handle caching for DispatchersInstance
- cacheAct := utils.MetaRemove
- if err := admS.CallCache(ctx, utils.FirstNonEmpty(utils.IfaceAsString(args.APIOpts[utils.MetaCache]), cacheAct),
- args.Tenant, utils.CacheDispatchers, args.TenantID(), utils.EmptyString, &args.FilterIDs, args.APIOpts); err != nil {
- return utils.APIErrorHandler(err)
- }
- // delay if needed before cache call
- if admS.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" (DispatcherRoutes) Delaying cache call for %v", admS.cfg.GeneralCfg().CachingDelay))
- time.Sleep(admS.cfg.GeneralCfg().CachingDelay)
- }
- //handle caching for DispatcherRoutes
- if err := admS.CallCache(ctx, utils.FirstNonEmpty(utils.IfaceAsString(args.APIOpts[utils.MetaCache]), cacheAct),
- args.Tenant, utils.CacheDispatcherRoutes, args.TenantID(),
- utils.ConcatenatedKey(utils.CacheDispatcherProfiles, args.Tenant, args.ID),
- &args.FilterIDs, args.APIOpts); err != nil {
- return utils.APIErrorHandler(err)
- }
- *reply = utils.OK
- return nil
-}
-
-// RemoveDispatcherProfile remove a specific Dispatcher Profile
-func (admS *AdminS) V1RemoveDispatcherProfile(ctx *context.Context, arg *utils.TenantIDWithAPIOpts, reply *string) error {
- if missing := utils.MissingStructFields(arg, []string{utils.ID}); len(missing) != 0 { //Params missing
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- tnt := arg.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- if err := admS.dm.RemoveDispatcherProfile(ctx, tnt,
- arg.ID, true); err != nil {
- return utils.APIErrorHandler(err)
- }
- //generate a loadID for CacheDispatcherProfiles and store it in database
- if err := admS.dm.SetLoadIDs(ctx, map[string]int64{utils.CacheDispatcherProfiles: time.Now().UnixNano()}); err != nil {
- return utils.APIErrorHandler(err)
- }
- // delay if needed before cache call
- if admS.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", admS.cfg.GeneralCfg().CachingDelay))
- time.Sleep(admS.cfg.GeneralCfg().CachingDelay)
- }
- //handle caching for DispatcherProfile
- if err := admS.CallCache(ctx, utils.IfaceAsString(arg.APIOpts[utils.MetaCache]), tnt, utils.CacheDispatcherProfiles,
- utils.ConcatenatedKey(tnt, arg.ID), utils.EmptyString, nil, arg.APIOpts); err != nil {
- return utils.APIErrorHandler(err)
- }
- *reply = utils.OK
- return nil
-}
-
-// GetDispatcherHost returns a Dispatcher Host
-func (admS *AdminS) V1GetDispatcherHost(ctx *context.Context, arg *utils.TenantIDWithAPIOpts, reply *engine.DispatcherHost) error {
- if missing := utils.MissingStructFields(arg, []string{utils.ID}); len(missing) != 0 { //Params missing
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- tnt := arg.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- dpp, err := admS.dm.GetDispatcherHost(ctx, tnt, arg.ID, true, false, utils.NonTransactional)
- if err != nil {
- return utils.APIErrorHandler(err)
- }
- *reply = *dpp
- return nil
-}
-
-// GetDispatcherHostIDs returns list of dispatcherHost IDs registered for a tenant
-func (admS *AdminS) V1GetDispatcherHostIDs(ctx *context.Context, args *utils.ArgsItemIDs, dspHostIDs *[]string) (err error) {
- tenant := args.Tenant
- if tenant == utils.EmptyString {
- tenant = admS.cfg.GeneralCfg().DefaultTenant
- }
- prfx := utils.DispatcherHostPrefix + tenant + utils.ConcatenatedKeySep
- lenPrfx := len(prfx)
- prfx += args.ItemsPrefix
- var keys []string
- if keys, err = admS.dm.DataDB().GetKeysForPrefix(ctx, prfx); err != nil {
- return err
- }
- if len(keys) == 0 {
- return utils.ErrNotFound
- }
- retIDs := make([]string, len(keys))
- for i, key := range keys {
- retIDs[i] = key[lenPrfx:]
- }
- var limit, offset, maxItems int
- if limit, offset, maxItems, err = utils.GetPaginateOpts(args.APIOpts); err != nil {
- return
- }
- *dspHostIDs, err = utils.Paginate(retIDs, limit, offset, maxItems)
- return
-}
-
-// GetDispatcherHosts returns a list of dispatcher hosts registered for a tenant
-func (admS *AdminS) V1GetDispatcherHosts(ctx *context.Context, args *utils.ArgsItemIDs, dspHosts *[]*engine.DispatcherHost) (err error) {
- tnt := args.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- var dspHostIDs []string
- if err = admS.V1GetDispatcherHostIDs(ctx, args, &dspHostIDs); err != nil {
- return
- }
- *dspHosts = make([]*engine.DispatcherHost, 0, len(dspHostIDs))
- for _, dspHostID := range dspHostIDs {
- var dspHost *engine.DispatcherHost
- dspHost, err = admS.dm.GetDispatcherHost(ctx, tnt, dspHostID, true, true, utils.NonTransactional)
- if err != nil {
- return utils.APIErrorHandler(err)
- }
- *dspHosts = append(*dspHosts, dspHost)
- }
- return
-}
-
-// GetDispatcherHostsCount returns the total number of DispatcherHosts registered for a tenant
-// returns ErrNotFound in case of 0 DispatcherHosts
-func (admS *AdminS) V1GetDispatcherHostsCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := args.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- prfx := utils.DispatcherHostPrefix + tnt + utils.ConcatenatedKeySep + args.ItemsPrefix
- var keys []string
- if keys, err = admS.dm.DataDB().GetKeysForPrefix(ctx, prfx); err != nil {
- return err
- }
- if len(keys) == 0 {
- return utils.ErrNotFound
- }
- *reply = len(keys)
- return
-}
-
-// SetDispatcherHost add/update a new Dispatcher Host
-func (admS *AdminS) V1SetDispatcherHost(ctx *context.Context, args *engine.DispatcherHostWithAPIOpts, reply *string) error {
- if missing := utils.MissingStructFields(args.DispatcherHost, []string{utils.ID}); len(missing) != 0 {
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- if args.Tenant == utils.EmptyString {
- args.Tenant = admS.cfg.GeneralCfg().DefaultTenant
- }
- if err := admS.dm.SetDispatcherHost(ctx, args.DispatcherHost); err != nil {
- return utils.APIErrorHandler(err)
- }
- //generate a loadID for CacheDispatcherHosts and store it in database
- if err := admS.dm.SetLoadIDs(ctx, map[string]int64{utils.CacheDispatcherHosts: time.Now().UnixNano()}); err != nil {
- return utils.APIErrorHandler(err)
- }
- // delay if needed before cache call
- if admS.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", admS.cfg.GeneralCfg().CachingDelay))
- time.Sleep(admS.cfg.GeneralCfg().CachingDelay)
- }
- //handle caching for DispatcherProfile
- if err := admS.CallCache(ctx, utils.IfaceAsString(args.APIOpts[utils.MetaCache]), args.Tenant, utils.CacheDispatcherHosts,
- args.TenantID(), utils.EmptyString, nil, args.APIOpts); err != nil {
- return utils.APIErrorHandler(err)
- }
- *reply = utils.OK
- return nil
-}
-
-// RemoveDispatcherHost remove a specific Dispatcher Host
-func (admS *AdminS) V1RemoveDispatcherHost(ctx *context.Context, arg *utils.TenantIDWithAPIOpts, reply *string) error {
- if missing := utils.MissingStructFields(arg, []string{utils.ID}); len(missing) != 0 { //Params missing
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- tnt := arg.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- if err := admS.dm.RemoveDispatcherHost(ctx, tnt, arg.ID); err != nil {
- return utils.APIErrorHandler(err)
- }
- //generate a loadID for CacheDispatcherHosts and store it in database
- if err := admS.dm.SetLoadIDs(ctx, map[string]int64{utils.CacheDispatcherHosts: time.Now().UnixNano()}); err != nil {
- return utils.APIErrorHandler(err)
- }
- // delay if needed before cache call
- if admS.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", admS.cfg.GeneralCfg().CachingDelay))
- time.Sleep(admS.cfg.GeneralCfg().CachingDelay)
- }
- //handle caching for DispatcherProfile
- if err := admS.CallCache(ctx, utils.IfaceAsString(arg.APIOpts[utils.MetaCache]), tnt, utils.CacheDispatcherHosts,
- utils.ConcatenatedKey(tnt, arg.ID), utils.EmptyString, nil, arg.APIOpts); err != nil {
- return utils.APIErrorHandler(err)
- }
- *reply = utils.OK
- return nil
-}
diff --git a/admins/filter_indexes.go b/admins/filter_indexes.go
index c70cd0bf8..7a918dbcd 100644
--- a/admins/filter_indexes.go
+++ b/admins/filter_indexes.go
@@ -78,8 +78,6 @@ func (adms *AdminS) V1RemoveFilterIndexes(ctx *context.Context, arg *AttrRemFilt
}
arg.ItemType = utils.CacheRateFilterIndexes
tntCtx = utils.ConcatenatedKey(tnt, arg.Context)
- case utils.MetaDispatchers:
- arg.ItemType = utils.CacheDispatcherFilterIndexes
case utils.MetaAttributes:
arg.ItemType = utils.CacheAttributeFilterIndexes
}
@@ -134,8 +132,6 @@ func (adms *AdminS) V1GetFilterIndexes(ctx *context.Context, arg *AttrGetFilterI
}
arg.ItemType = utils.CacheRateFilterIndexes
tntCtx = utils.ConcatenatedKey(tnt, arg.Context)
- case utils.MetaDispatchers:
- arg.ItemType = utils.CacheDispatcherFilterIndexes
case utils.MetaAttributes:
arg.ItemType = utils.CacheAttributeFilterIndexes
}
@@ -386,21 +382,6 @@ func (adms *AdminS) V1ComputeFilterIndexes(ctx *context.Context, args *utils.Arg
}
args.RateS = indexes.Size() != 0
}
- //DispatcherProfile Indexes
- if args.DispatcherS {
- cacheIDs[utils.CacheDispatcherFilterIndexes] = []string{utils.MetaAny}
- if indexes, err = engine.ComputeIndexes(ctx, adms.dm, tnt, utils.EmptyString, utils.CacheDispatcherFilterIndexes,
- nil, transactionID, func(tnt, id, grp string) (*[]string, error) {
- dsp, e := adms.dm.GetDispatcherProfile(ctx, tnt, id, true, false, utils.NonTransactional)
- if e != nil {
- return nil, e
- }
- return utils.SliceStringPointer(slices.Clone(dsp.FilterIDs)), nil
- }, nil); err != nil && err != utils.ErrDSPProfileNotFound {
- return utils.APIErrorHandler(err)
- }
- args.DispatcherS = indexes.Size() != 0
- }
//Now we move from tmpKey to the right key for each type
//ThresholdProfile Indexes
@@ -463,12 +444,7 @@ func (adms *AdminS) V1ComputeFilterIndexes(ctx *context.Context, args *utils.Arg
}
}
- //DispatcherProfile Indexes
- if args.DispatcherS {
- if err = adms.dm.SetIndexes(ctx, utils.CacheDispatcherFilterIndexes, tnt, nil, true, transactionID); err != nil {
- return
- }
- }
+
//generate a load
//ID for CacheFilterIndexes and store it in database
loadIDs := make(map[string]int64)
@@ -641,20 +617,6 @@ func (adms *AdminS) V1ComputeFilterIndexIDs(ctx *context.Context, args *utils.Ar
if indexes.Size() != 0 {
cacheIDs[utils.CacheRateProfilesFilterIndexes] = indexes.AsSlice()
}
- //DispatcherProfile Indexes
- if indexes, err = engine.ComputeIndexes(ctx, adms.dm, tnt, utils.EmptyString, utils.CacheDispatcherFilterIndexes,
- &args.DispatcherIDs, transactionID, func(tnt, id, grp string) (*[]string, error) {
- dsp, e := adms.dm.GetDispatcherProfile(ctx, tnt, id, true, false, utils.NonTransactional)
- if e != nil {
- return nil, e
- }
- return utils.SliceStringPointer(slices.Clone(dsp.FilterIDs)), nil
- }, nil); err != nil && err != utils.ErrDSPProfileNotFound {
- return utils.APIErrorHandler(err)
- }
- if indexes.Size() != 0 {
- cacheIDs[utils.CacheDispatcherFilterIndexes] = indexes.AsSlice()
- }
//generate a load
//ID for CacheFilterIndexes and store it in database
@@ -772,20 +734,6 @@ func (adms *AdminS) V1GetChargersIndexesHealth(ctx *context.Context, args *engin
return nil
}
-func (adms *AdminS) V1GetDispatchersIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) error {
- rp, err := engine.GetFltrIdxHealth(ctx, adms.dm,
- ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
- ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
- ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, nil),
- utils.CacheDispatcherFilterIndexes,
- )
- if err != nil {
- return err
- }
- *reply = *rp
- return nil
-}
-
func (adms *AdminS) V1GetRateProfilesIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) error {
rp, err := engine.GetFltrIdxHealth(ctx, adms.dm,
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
diff --git a/apis/dispatchers.go b/apis/dispatchers.go
deleted file mode 100644
index 4d19b6232..000000000
--- a/apis/dispatchers.go
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package apis
-
-import (
- "fmt"
- "time"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-// GetDispatcherProfile returns a Dispatcher Profile
-func (admS *AdminSv1) GetDispatcherProfile(ctx *context.Context, arg *utils.TenantIDWithAPIOpts, reply *engine.DispatcherProfile) error {
- if missing := utils.MissingStructFields(arg, []string{utils.ID}); len(missing) != 0 { //Params missing
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- tnt := arg.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- dpp, err := admS.dm.GetDispatcherProfile(ctx, tnt, arg.ID, true, true, utils.NonTransactional)
- if err != nil {
- return utils.APIErrorHandler(err)
- }
- *reply = *dpp
- return nil
-}
-
-// GetDispatcherProfileIDs returns list of dispatcherProfile IDs registered for a tenant
-func (admS *AdminSv1) GetDispatcherProfileIDs(ctx *context.Context, args *utils.ArgsItemIDs, dPrfIDs *[]string) (err error) {
- tnt := args.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- prfx := utils.DispatcherProfilePrefix + tnt + utils.ConcatenatedKeySep
- lenPrfx := len(prfx)
- prfx += args.ItemsPrefix
- var keys []string
- if keys, err = admS.dm.DataDB().GetKeysForPrefix(ctx, prfx); err != nil {
- return
- }
- if len(keys) == 0 {
- return utils.ErrNotFound
- }
- retIDs := make([]string, len(keys))
- for i, key := range keys {
- retIDs[i] = key[lenPrfx:]
- }
- var limit, offset, maxItems int
- if limit, offset, maxItems, err = utils.GetPaginateOpts(args.APIOpts); err != nil {
- return
- }
- *dPrfIDs, err = utils.Paginate(retIDs, limit, offset, maxItems)
- return
-}
-
-// GetDispatcherProfiles returns a list of dispatcher profiles registered for a tenant
-func (admS *AdminSv1) GetDispatcherProfiles(ctx *context.Context, args *utils.ArgsItemIDs, dspPrfs *[]*engine.DispatcherProfile) (err error) {
- tnt := args.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- var dspPrfIDs []string
- if err = admS.GetDispatcherProfileIDs(ctx, args, &dspPrfIDs); err != nil {
- return
- }
- *dspPrfs = make([]*engine.DispatcherProfile, 0, len(dspPrfIDs))
- for _, dspPrfID := range dspPrfIDs {
- var dspPrf *engine.DispatcherProfile
- dspPrf, err = admS.dm.GetDispatcherProfile(ctx, tnt, dspPrfID, true, true, utils.NonTransactional)
- if err != nil {
- return utils.APIErrorHandler(err)
- }
- *dspPrfs = append(*dspPrfs, dspPrf)
- }
- return
-}
-
-// GetDispatcherProfilesCount returns the total number of DispatcherProfiles registered for a tenant
-// returns ErrNotFound in case of 0 DispatcherProfiles
-func (admS *AdminSv1) GetDispatcherProfilesCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := args.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- prfx := utils.DispatcherProfilePrefix + tnt + utils.ConcatenatedKeySep + args.ItemsPrefix
- var keys []string
- if keys, err = admS.dm.DataDB().GetKeysForPrefix(ctx, prfx); err != nil {
- return err
- }
- if len(keys) == 0 {
- return utils.ErrNotFound
- }
- *reply = len(keys)
- return
-}
-
-type DispatcherWithAPIOpts struct {
- *engine.DispatcherProfile
- APIOpts map[string]any
-}
-
-// SetDispatcherProfile add/update a new Dispatcher Profile
-func (admS *AdminSv1) SetDispatcherProfile(ctx *context.Context, args *DispatcherWithAPIOpts, reply *string) error {
- if missing := utils.MissingStructFields(args.DispatcherProfile, []string{utils.ID}); len(missing) != 0 {
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- if args.Tenant == utils.EmptyString {
- args.Tenant = admS.cfg.GeneralCfg().DefaultTenant
- }
- if err := admS.dm.SetDispatcherProfile(ctx, args.DispatcherProfile, true); err != nil {
- return utils.APIErrorHandler(err)
- }
- //generate a loadID for CacheDispatcherProfiles and store it in database
- if err := admS.dm.SetLoadIDs(ctx, map[string]int64{utils.CacheDispatcherProfiles: time.Now().UnixNano()}); err != nil {
- return utils.APIErrorHandler(err)
- }
- // delay if needed before cache call
- if admS.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", admS.cfg.GeneralCfg().CachingDelay))
- time.Sleep(admS.cfg.GeneralCfg().CachingDelay)
- }
- //handle caching for DispatcherProfile
- if err := admS.CallCache(ctx, utils.IfaceAsString(args.APIOpts[utils.MetaCache]), args.Tenant, utils.CacheDispatcherProfiles,
- args.TenantID(), utils.EmptyString, &args.FilterIDs, args.APIOpts); err != nil {
- return utils.APIErrorHandler(err)
- }
- // delay if needed before cache call
- if admS.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" (DispatchersInstance) Delaying cache call for %v", admS.cfg.GeneralCfg().CachingDelay))
- time.Sleep(admS.cfg.GeneralCfg().CachingDelay)
- }
- //handle caching for DispatchersInstance
- cacheAct := utils.MetaRemove
- if err := admS.CallCache(ctx, utils.FirstNonEmpty(utils.IfaceAsString(args.APIOpts[utils.MetaCache]), cacheAct),
- args.Tenant, utils.CacheDispatchers, args.TenantID(), utils.EmptyString, &args.FilterIDs, args.APIOpts); err != nil {
- return utils.APIErrorHandler(err)
- }
- // delay if needed before cache call
- if admS.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" (DispatcherRoutes) Delaying cache call for %v", admS.cfg.GeneralCfg().CachingDelay))
- time.Sleep(admS.cfg.GeneralCfg().CachingDelay)
- }
- //handle caching for DispatcherRoutes
- if err := admS.CallCache(ctx, utils.FirstNonEmpty(utils.IfaceAsString(args.APIOpts[utils.MetaCache]), cacheAct),
- args.Tenant, utils.CacheDispatcherRoutes, args.TenantID(),
- utils.ConcatenatedKey(utils.CacheDispatcherProfiles, args.Tenant, args.ID),
- &args.FilterIDs, args.APIOpts); err != nil {
- return utils.APIErrorHandler(err)
- }
- *reply = utils.OK
- return nil
-}
-
-// RemoveDispatcherProfile remove a specific Dispatcher Profile
-func (admS *AdminSv1) RemoveDispatcherProfile(ctx *context.Context, arg *utils.TenantIDWithAPIOpts, reply *string) error {
- if missing := utils.MissingStructFields(arg, []string{utils.ID}); len(missing) != 0 { //Params missing
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- tnt := arg.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- if err := admS.dm.RemoveDispatcherProfile(ctx, tnt,
- arg.ID, true); err != nil {
- return utils.APIErrorHandler(err)
- }
- //generate a loadID for CacheDispatcherProfiles and store it in database
- if err := admS.dm.SetLoadIDs(ctx, map[string]int64{utils.CacheDispatcherProfiles: time.Now().UnixNano()}); err != nil {
- return utils.APIErrorHandler(err)
- }
- // delay if needed before cache call
- if admS.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", admS.cfg.GeneralCfg().CachingDelay))
- time.Sleep(admS.cfg.GeneralCfg().CachingDelay)
- }
- //handle caching for DispatcherProfile
- if err := admS.CallCache(ctx, utils.IfaceAsString(arg.APIOpts[utils.MetaCache]), tnt, utils.CacheDispatcherProfiles,
- utils.ConcatenatedKey(tnt, arg.ID), utils.EmptyString, nil, arg.APIOpts); err != nil {
- return utils.APIErrorHandler(err)
- }
- *reply = utils.OK
- return nil
-}
-
-// GetDispatcherHost returns a Dispatcher Host
-func (admS *AdminSv1) GetDispatcherHost(ctx *context.Context, arg *utils.TenantIDWithAPIOpts, reply *engine.DispatcherHost) error {
- if missing := utils.MissingStructFields(arg, []string{utils.ID}); len(missing) != 0 { //Params missing
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- tnt := arg.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- dpp, err := admS.dm.GetDispatcherHost(ctx, tnt, arg.ID, true, false, utils.NonTransactional)
- if err != nil {
- return utils.APIErrorHandler(err)
- }
- *reply = *dpp
- return nil
-}
-
-// GetDispatcherHostIDs returns list of dispatcherHost IDs registered for a tenant
-func (admS *AdminSv1) GetDispatcherHostIDs(ctx *context.Context, args *utils.ArgsItemIDs, dspHostIDs *[]string) (err error) {
- tenant := args.Tenant
- if tenant == utils.EmptyString {
- tenant = admS.cfg.GeneralCfg().DefaultTenant
- }
- prfx := utils.DispatcherHostPrefix + tenant + utils.ConcatenatedKeySep
- lenPrfx := len(prfx)
- prfx += args.ItemsPrefix
- var keys []string
- if keys, err = admS.dm.DataDB().GetKeysForPrefix(ctx, prfx); err != nil {
- return err
- }
- if len(keys) == 0 {
- return utils.ErrNotFound
- }
- retIDs := make([]string, len(keys))
- for i, key := range keys {
- retIDs[i] = key[lenPrfx:]
- }
- var limit, offset, maxItems int
- if limit, offset, maxItems, err = utils.GetPaginateOpts(args.APIOpts); err != nil {
- return
- }
- *dspHostIDs, err = utils.Paginate(retIDs, limit, offset, maxItems)
- return
-}
-
-// GetDispatcherHosts returns a list of dispatcher hosts registered for a tenant
-func (admS *AdminSv1) GetDispatcherHosts(ctx *context.Context, args *utils.ArgsItemIDs, dspHosts *[]*engine.DispatcherHost) (err error) {
- tnt := args.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- var dspHostIDs []string
- if err = admS.GetDispatcherHostIDs(ctx, args, &dspHostIDs); err != nil {
- return
- }
- *dspHosts = make([]*engine.DispatcherHost, 0, len(dspHostIDs))
- for _, dspHostID := range dspHostIDs {
- var dspHost *engine.DispatcherHost
- dspHost, err = admS.dm.GetDispatcherHost(ctx, tnt, dspHostID, true, true, utils.NonTransactional)
- if err != nil {
- return utils.APIErrorHandler(err)
- }
- *dspHosts = append(*dspHosts, dspHost)
- }
- return
-}
-
-// GetDispatcherHostsCount returns the total number of DispatcherHosts registered for a tenant
-// returns ErrNotFound in case of 0 DispatcherHosts
-func (admS *AdminSv1) GetDispatcherHostsCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := args.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- prfx := utils.DispatcherHostPrefix + tnt + utils.ConcatenatedKeySep + args.ItemsPrefix
- var keys []string
- if keys, err = admS.dm.DataDB().GetKeysForPrefix(ctx, prfx); err != nil {
- return err
- }
- if len(keys) == 0 {
- return utils.ErrNotFound
- }
- *reply = len(keys)
- return
-}
-
-// SetDispatcherHost add/update a new Dispatcher Host
-func (admS *AdminSv1) SetDispatcherHost(ctx *context.Context, args *engine.DispatcherHostWithAPIOpts, reply *string) error {
- if missing := utils.MissingStructFields(args.DispatcherHost, []string{utils.ID}); len(missing) != 0 {
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- if args.Tenant == utils.EmptyString {
- args.Tenant = admS.cfg.GeneralCfg().DefaultTenant
- }
- if err := admS.dm.SetDispatcherHost(ctx, args.DispatcherHost); err != nil {
- return utils.APIErrorHandler(err)
- }
- //generate a loadID for CacheDispatcherHosts and store it in database
- if err := admS.dm.SetLoadIDs(ctx, map[string]int64{utils.CacheDispatcherHosts: time.Now().UnixNano()}); err != nil {
- return utils.APIErrorHandler(err)
- }
- // delay if needed before cache call
- if admS.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", admS.cfg.GeneralCfg().CachingDelay))
- time.Sleep(admS.cfg.GeneralCfg().CachingDelay)
- }
- //handle caching for DispatcherProfile
- if err := admS.CallCache(ctx, utils.IfaceAsString(args.APIOpts[utils.MetaCache]), args.Tenant, utils.CacheDispatcherHosts,
- args.TenantID(), utils.EmptyString, nil, args.APIOpts); err != nil {
- return utils.APIErrorHandler(err)
- }
- *reply = utils.OK
- return nil
-}
-
-// RemoveDispatcherHost remove a specific Dispatcher Host
-func (admS *AdminSv1) RemoveDispatcherHost(ctx *context.Context, arg *utils.TenantIDWithAPIOpts, reply *string) error {
- if missing := utils.MissingStructFields(arg, []string{utils.ID}); len(missing) != 0 { //Params missing
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- tnt := arg.Tenant
- if tnt == utils.EmptyString {
- tnt = admS.cfg.GeneralCfg().DefaultTenant
- }
- if err := admS.dm.RemoveDispatcherHost(ctx, tnt, arg.ID); err != nil {
- return utils.APIErrorHandler(err)
- }
- //generate a loadID for CacheDispatcherHosts and store it in database
- if err := admS.dm.SetLoadIDs(ctx, map[string]int64{utils.CacheDispatcherHosts: time.Now().UnixNano()}); err != nil {
- return utils.APIErrorHandler(err)
- }
- // delay if needed before cache call
- if admS.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", admS.cfg.GeneralCfg().CachingDelay))
- time.Sleep(admS.cfg.GeneralCfg().CachingDelay)
- }
- //handle caching for DispatcherProfile
- if err := admS.CallCache(ctx, utils.IfaceAsString(arg.APIOpts[utils.MetaCache]), tnt, utils.CacheDispatcherHosts,
- utils.ConcatenatedKey(tnt, arg.ID), utils.EmptyString, nil, arg.APIOpts); err != nil {
- return utils.APIErrorHandler(err)
- }
- *reply = utils.OK
- return nil
-}
-
-/*
-func NewDispatcherSv1(dS *dispatchers.DispatcherService) *DispatcherSv1 {
- return &DispatcherSv1{dS: dS}
-}
-
-type DispatcherSv1 struct {
- dS *dispatchers.DispatcherService
- ping
-}
-
-// // GetProfileForEvent returns the matching dispatcher profile for the provided event
-// func (dSv1 DispatcherSv1) GetProfilesForEvent(ctx *context.Context, ev *utils.CGREvent,
-// dPrfl *engine.DispatcherProfiles) error {
-// return dSv1.dS.V1GetProfilesForEvent(ctx, ev, dPrfl)
-// }
-
-// func (dS *DispatcherSv1) RemoteStatus(args *utils.TenantWithAPIOpts, reply *map[string]any) (err error) {
-// return dS.dS.DispatcherSv1RemoteStatus(args, reply)
-// }
-
-// func (dS *DispatcherSv1) RemotePing(args *utils.CGREvent, reply *string) (err error) {
-// return dS.dS.DispatcherSv1RemotePing(args, reply)
-// }
-
-// func (dS *DispatcherSv1) RemoteSleep(args *utils.DurationArgs, reply *string) (err error) {
-// return dS.dS.DispatcherSv1RemoteSleep(args, reply)
-// }
-*/
diff --git a/apis/dispatchers_test.go b/apis/dispatchers_test.go
deleted file mode 100644
index d7fb842ad..000000000
--- a/apis/dispatchers_test.go
+++ /dev/null
@@ -1,1475 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package apis
-
-import (
- "reflect"
- "sort"
- "testing"
-
- "github.com/cgrates/birpc"
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDispatchersGetDispatcherProfilesOK(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- connMgr := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMgr)
- admS := NewAdminSv1(cfg, dm, connMgr, nil, nil)
- args1 := &DispatcherWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "test_ID1",
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "Host1",
- },
- },
- Weight: 10,
- },
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
-
- var setReply string
- if err := admS.SetDispatcherProfile(context.Background(), args1, &setReply); err != nil {
- t.Error(err)
- } else if setReply != "OK" {
- t.Error("Unexpected reply returned:", setReply)
- }
-
- args2 := &DispatcherWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "test_ID2",
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "Host2",
- },
- },
- Weight: 10,
- },
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
-
- if err := admS.SetDispatcherProfile(context.Background(), args2, &setReply); err != nil {
- t.Error(err)
- } else if setReply != "OK" {
- t.Error("Unexpected reply returned:", setReply)
- }
-
- // this profile will not match
- args3 := &DispatcherWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "test2_ID1",
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "Host3",
- },
- },
- Weight: 10,
- },
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
-
- if err := admS.SetDispatcherProfile(context.Background(), args3, &setReply); err != nil {
- t.Error(err)
- } else if setReply != "OK" {
- t.Error("Unexpected reply returned:", setReply)
- }
-
- argsGet := &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- ItemsPrefix: "test_ID",
- }
- exp := []*engine.DispatcherProfile{
- {
- Tenant: "cgrates.org",
- ID: "test_ID1",
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "Host1",
- },
- },
- Weight: 10,
- },
- {
- Tenant: "cgrates.org",
- ID: "test_ID2",
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "Host2",
- },
- },
- Weight: 10,
- },
- }
-
- var getReply []*engine.DispatcherProfile
- if err := admS.GetDispatcherProfiles(context.Background(), argsGet, &getReply); err != nil {
- t.Error(err)
- } else {
- sort.Slice(getReply, func(i, j int) bool {
- return getReply[i].ID < getReply[j].ID
- })
- if !reflect.DeepEqual(getReply, exp) {
- t.Errorf("expected: <%+v>, \nreceived: <%+v>",
- utils.ToJSON(exp), utils.ToJSON(getReply))
- }
- }
-}
-
-func TestDispatchersSetGetRemDispatcherProfile(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
- arg := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- ID: "dspID",
- },
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
- var result engine.DispatcherProfile
- var reply string
-
- dspPrf := &DispatcherWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "dspID",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "Host1",
- },
- },
- Weight: 10,
- },
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
-
- if err := adms.SetDispatcherProfile(context.Background(), dspPrf, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Errorf("\nexpected: <%+v>, received: <%+v>", utils.OK, reply)
- }
-
- if err := adms.GetDispatcherProfile(context.Background(), arg, &result); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(result, *dspPrf.DispatcherProfile) {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>",
- utils.ToJSON(dspPrf.DispatcherProfile), utils.ToJSON(result))
- }
-
- var dspPrfIDs []string
- expDspPrfIDs := []string{"dspID"}
-
- if err := adms.GetDispatcherProfileIDs(context.Background(), &utils.ArgsItemIDs{},
- &dspPrfIDs); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(dspPrfIDs, expDspPrfIDs) {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", expDspPrfIDs, dspPrfIDs)
- }
-
- var rplyCount int
-
- if err := adms.GetDispatcherProfilesCount(context.Background(), &utils.ArgsItemIDs{},
- &rplyCount); err != nil {
- t.Error(err)
- } else if rplyCount != len(dspPrfIDs) {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", len(dspPrfIDs), rplyCount)
- }
-
- if err := adms.RemoveDispatcherProfile(context.Background(), arg, &reply); err != nil {
- t.Error(err)
- }
-
- engine.Cache.Clear(nil)
- if err := adms.GetDispatcherProfile(context.Background(), arg, &result); err == nil ||
- err != utils.ErrDSPProfileNotFound {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersGetDispatcherProfileCheckErrors(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
- var rcv engine.DispatcherProfile
- experr := "MANDATORY_IE_MISSING: [ID]"
-
- if err := adms.GetDispatcherProfile(context.Background(), &utils.TenantIDWithAPIOpts{}, &rcv); err == nil ||
- err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- adms.dm = nil
- experr = "SERVER_ERROR: NO_DATABASE_CONNECTION"
-
- arg := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- ID: "TestDispatchersGetDispatcherProfileCheckErrors",
- },
- }
-
- if err := adms.GetDispatcherProfile(context.Background(), arg, &rcv); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersSetDispatcherProfileCheckErrors(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- dspPrf := &DispatcherWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{},
- }
-
- var reply string
- experr := "MANDATORY_IE_MISSING: [ID]"
-
- if err := adms.SetDispatcherProfile(context.Background(), dspPrf, &reply); err == nil ||
- err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dspPrf.ID = "TestDispatchersSetDispatcherProfileCheckErrors"
- dspPrf.FilterIDs = []string{"invalid_filter_format"}
- experr = "SERVER_ERROR: broken reference to filter: for item with ID: cgrates.org:TestDispatchersSetDispatcherProfileCheckErrors"
-
- if err := adms.SetDispatcherProfile(context.Background(), dspPrf, &reply); err == nil ||
- err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dspPrf.FilterIDs = []string{}
- adms.connMgr = engine.NewConnManager(cfg)
- adms.connMgr.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches), utils.CacheSv1, make(chan birpc.ClientConnector))
- ctx, cancel := context.WithTimeout(context.Background(), 10)
- experr = "SERVER_ERROR: context deadline exceeded"
- cfg.GeneralCfg().DefaultCaching = utils.MetaRemove
- if err := adms.SetDispatcherProfile(ctx, dspPrf, &reply); err == nil ||
- err.Error() != experr {
- t.Errorf("\nexpected <%+v>,\nreceived <%+v>", experr, err)
- }
- cancel()
-
- dbMock := &engine.DataDBMock{
- GetDispatcherProfileDrvF: func(*context.Context, string, string) (*engine.DispatcherProfile, error) {
- dspPrf := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "TEST",
- }
- return dspPrf, nil
- },
- SetDispatcherProfileDrvF: func(*context.Context, *engine.DispatcherProfile) error {
- return nil
- },
- RemoveDispatcherProfileDrvF: func(*context.Context, string, string) error {
- return nil
- },
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return nil, nil
- },
- }
-
- adms.dm = engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- experr = "SERVER_ERROR: NOT_IMPLEMENTED"
-
- if err := adms.SetDispatcherProfile(context.Background(), dspPrf, &reply); err == nil ||
- err.Error() != experr {
- t.Errorf("\nexpected <%+v>, \nreceived <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersRemoveDispatcherProfileCheckErrors(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- dspPrf := &DispatcherWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- ID: "TestDispatchersRemoveDispatcherProfileCheckErrors",
- Tenant: "cgrates.org",
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "HOST",
- },
- },
- Weight: 10,
- },
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
- var reply string
-
- if err := adms.SetDispatcherProfile(context.Background(), dspPrf, &reply); err != nil {
- t.Error(err)
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), 10)
- adms.cfg.GeneralCfg().DefaultCaching = "not_a_caching_type"
- adms.connMgr = engine.NewConnManager(cfg)
- adms.connMgr.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches), utils.CacheSv1, make(chan birpc.ClientConnector))
- experr := "SERVER_ERROR: context deadline exceeded"
-
- if err := adms.RemoveDispatcherProfile(ctx, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- ID: "TestDispatchersRemoveDispatcherProfileCheckErrors",
- },
- }, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
- cancel()
-
- adms.cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- var rcv engine.DispatcherProfile
-
- arg := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- ID: "TestDispatchersRemoveDispatcherProfileCheckErrors",
- },
- }
-
- if err := adms.GetDispatcherProfile(context.Background(), arg, &rcv); err == nil || err != utils.ErrDSPProfileNotFound {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", utils.ErrDSPProfileNotFound, err)
- }
-
- experr = "MANDATORY_IE_MISSING: [ID]"
-
- if err := adms.RemoveDispatcherProfile(context.Background(),
- &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{}}, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- adms.dm = nil
- experr = "SERVER_ERROR: NO_DATABASE_CONNECTION"
-
- if err := adms.RemoveDispatcherProfile(context.Background(), &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- ID: "TestDispatchersRemoveDispatcherProfileCheckErrors",
- }, APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- }}, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dbMock := &engine.DataDBMock{
- GetDispatcherProfileDrvF: func(*context.Context, string, string) (*engine.DispatcherProfile, error) {
- dspPrf := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "TEST",
- }
- return dspPrf, nil
- },
- SetDispatcherProfileDrvF: func(*context.Context, *engine.DispatcherProfile) error {
- return nil
- },
- RemoveDispatcherProfileDrvF: func(*context.Context, string, string) error {
- return nil
- },
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return nil, nil
- },
- SetIndexesDrvF: func(ctx *context.Context, idxItmType, tntCtx string, indexes map[string]utils.StringSet, commit bool, transactionID string) (err error) {
- return nil
- },
- GetIndexesDrvF: func(ctx *context.Context, idxItmType, tntCtx, idxKey, transactionID string) (indexes map[string]utils.StringSet, err error) {
- return map[string]utils.StringSet{}, nil
- },
- RemoveDispatcherHostDrvF: func(ctx *context.Context, tnt, id string) error {
- return nil
- },
- }
-
- engine.Cache.Clear(nil)
- adms.dm = engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- experr = "SERVER_ERROR: NOT_IMPLEMENTED"
-
- if err := adms.RemoveDispatcherProfile(context.Background(),
- &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- ID: "TestDispatchersRemoveDispatcherProfileCheckErrors",
- }, APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- }}, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersGetDispatcherProfileIDsErrMock(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- GetDispatcherProfileDrvF: func(*context.Context, string, string) (*engine.DispatcherProfile, error) {
- dspPrf := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "TEST",
- }
- return dspPrf, nil
- },
- SetDispatcherProfileDrvF: func(*context.Context, *engine.DispatcherProfile) error {
- return nil
- },
- RemoveDispatcherProfileDrvF: func(*context.Context, string, string) error {
- return nil
- },
- }
-
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply []string
- experr := "NOT_IMPLEMENTED"
-
- if err := adms.GetDispatcherProfileIDs(context.Background(),
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- }, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersGetDispatcherProfileIDsErrKeys(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return []string{}, nil
- },
- }
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply []string
-
- if err := adms.GetDispatcherProfileIDs(context.Background(),
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- }, &reply); err == nil || err != utils.ErrNotFound {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersGetDispatcherProfilesCountErrMock(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- GetDispatcherProfileDrvF: func(*context.Context, string, string) (*engine.DispatcherProfile, error) {
- dspPrf := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "TEST",
- }
- return dspPrf, nil
- },
- SetDispatcherProfileDrvF: func(*context.Context, *engine.DispatcherProfile) error {
- return nil
- },
- RemoveDispatcherProfileDrvF: func(*context.Context, string, string) error {
- return nil
- },
- }
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply int
-
- if err := adms.GetDispatcherProfilesCount(context.Background(),
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- }, &reply); err == nil || err != utils.ErrNotImplemented {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", utils.ErrNotImplemented, err)
- }
-}
-
-func TestDispatchersGetDispatcherProfilesCountErrKeys(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return []string{}, nil
- },
- }
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply int
-
- if err := adms.GetDispatcherProfilesCount(context.Background(),
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- }, &reply); err == nil || err != utils.ErrNotFound {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
- }
-}
-
-func TestDispatchersGetDispatcherProfileIDsGetOptsErr(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- GetDispatcherProfileDrvF: func(*context.Context, string, string) (*engine.DispatcherProfile, error) {
- dspPrf := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "TEST",
- }
- return dspPrf, nil
- },
- SetDispatcherProfileDrvF: func(*context.Context, *engine.DispatcherProfile) error {
- return nil
- },
- RemoveDispatcherProfileDrvF: func(*context.Context, string, string) error {
- return nil
- },
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return []string{"dpp_cgrates.org:key1", "dpp_cgrates.org:key2", "dpp_cgrates.org:key3"}, nil
- },
- }
-
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply []string
- experr := "cannot convert field: true to int"
-
- if err := adms.GetDispatcherProfileIDs(context.Background(),
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.PageLimitOpt: true,
- },
- }, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersGetDispatcherProfileIDsPaginateErr(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- GetDispatcherProfileDrvF: func(*context.Context, string, string) (*engine.DispatcherProfile, error) {
- dspPrf := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "TEST",
- }
- return dspPrf, nil
- },
- SetDispatcherProfileDrvF: func(*context.Context, *engine.DispatcherProfile) error {
- return nil
- },
- RemoveDispatcherProfileDrvF: func(*context.Context, string, string) error {
- return nil
- },
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return []string{"dpp_cgrates.org:key1", "dpp_cgrates.org:key2", "dpp_cgrates.org:key3"}, nil
- },
- }
-
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply []string
- experr := `SERVER_ERROR: maximum number of items exceeded`
-
- if err := adms.GetDispatcherProfileIDs(context.Background(),
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.PageLimitOpt: 2,
- utils.PageOffsetOpt: 4,
- utils.PageMaxItemsOpt: 5,
- },
- }, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersGetDispatcherHostsOK(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- connMgr := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMgr)
- admS := NewAdminSv1(cfg, dm, connMgr, nil, nil)
- args1 := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "test_ID1",
- Reconnects: -1,
- },
- },
- APIOpts: nil,
- }
-
- var setReply string
- if err := admS.SetDispatcherHost(context.Background(), args1, &setReply); err != nil {
- t.Error(err)
- } else if setReply != "OK" {
- t.Error("Unexpected reply returned:", setReply)
- }
-
- args2 := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "test_ID2",
- Reconnects: -1,
- },
- },
- APIOpts: nil,
- }
-
- if err := admS.SetDispatcherHost(context.Background(), args2, &setReply); err != nil {
- t.Error(err)
- } else if setReply != "OK" {
- t.Error("Unexpected reply returned:", setReply)
- }
-
- // this Host will not match
- args3 := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "test2_ID1",
- Reconnects: -1,
- },
- },
- APIOpts: nil,
- }
-
- if err := admS.SetDispatcherHost(context.Background(), args3, &setReply); err != nil {
- t.Error(err)
- } else if setReply != "OK" {
- t.Error("Unexpected reply returned:", setReply)
- }
-
- argsGet := &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- ItemsPrefix: "test_ID",
- }
- exp := []*engine.DispatcherHost{
- {
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "test_ID1",
- Reconnects: -1,
- },
- },
- {
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "test_ID2",
- Reconnects: -1,
- },
- },
- }
-
- var getReply []*engine.DispatcherHost
- if err := admS.GetDispatcherHosts(context.Background(), argsGet, &getReply); err != nil {
- t.Error(err)
- } else {
- sort.Slice(getReply, func(i, j int) bool {
- return getReply[i].ID < getReply[j].ID
- })
- if !reflect.DeepEqual(getReply, exp) {
- t.Errorf("expected: <%+v>, \nreceived: <%+v>",
- utils.ToJSON(exp), utils.ToJSON(getReply))
- }
- }
-}
-
-func TestDispatchersSetGetRemDispatcherHost(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
- arg := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- ID: "dspHost1",
- },
- }
- var result engine.DispatcherHost
- var reply string
-
- dspHost := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "dspHost1",
- Reconnects: -1,
- },
- },
- APIOpts: nil,
- }
-
- if err := adms.SetDispatcherHost(context.Background(), dspHost, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Errorf("\nexpected: <%+v>, received: <%+v>", utils.OK, reply)
- }
-
- if err := adms.GetDispatcherHost(context.Background(), arg, &result); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(result, *dspHost.DispatcherHost) {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>",
- utils.ToJSON(dspHost.DispatcherHost), utils.ToJSON(result))
- }
-
- var dspHostIDs []string
- expDspHostIDs := []string{"dspHost1"}
-
- if err := adms.GetDispatcherHostIDs(context.Background(), &utils.ArgsItemIDs{},
- &dspHostIDs); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(dspHostIDs, expDspHostIDs) {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", expDspHostIDs, dspHostIDs)
- }
-
- var rplyCount int
-
- if err := adms.GetDispatcherHostsCount(context.Background(), &utils.ArgsItemIDs{},
- &rplyCount); err != nil {
- t.Error(err)
- } else if rplyCount != len(dspHostIDs) {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", len(dspHostIDs), rplyCount)
- }
-
- if err := adms.RemoveDispatcherHost(context.Background(), arg, &reply); err != nil {
- t.Error(err)
- }
-
- engine.Cache.Clear(nil)
- if err := adms.GetDispatcherHost(context.Background(), arg, &result); err == nil ||
- err != utils.ErrDSPHostNotFound {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", utils.ErrDSPHostNotFound, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersGetDispatcherHostCheckErrors(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
- var rcv engine.DispatcherHost
- experr := "MANDATORY_IE_MISSING: [ID]"
-
- if err := adms.GetDispatcherHost(context.Background(), &utils.TenantIDWithAPIOpts{}, &rcv); err == nil ||
- err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- adms.dm = nil
- experr = "SERVER_ERROR: NO_DATABASE_CONNECTION"
-
- arg := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- ID: "TestDispatchersGetDispatcherHostCheckErrors",
- },
- }
-
- if err := adms.GetDispatcherHost(context.Background(), arg, &rcv); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersSetDispatcherHostCheckErrors(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- dspHost := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- RemoteHost: &config.RemoteHost{},
- },
- }
-
- var reply string
- experr := "MANDATORY_IE_MISSING: [ID]"
-
- if err := adms.SetDispatcherHost(context.Background(), dspHost, &reply); err == nil ||
- err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dspHost.ID = "TestDispatchersSetDispatcherHostCheckErrors"
- adms.connMgr = engine.NewConnManager(cfg)
- adms.connMgr.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches), utils.CacheSv1, make(chan birpc.ClientConnector))
- ctx, cancel := context.WithTimeout(context.Background(), 10)
- experr = "SERVER_ERROR: context deadline exceeded"
- cfg.GeneralCfg().DefaultCaching = utils.MetaRemove
- if err := adms.SetDispatcherHost(ctx, dspHost, &reply); err == nil ||
- err.Error() != experr {
- t.Errorf("\nexpected <%+v>,\nreceived <%+v>", experr, err)
- }
- cancel()
-
- dbMock := &engine.DataDBMock{
- GetDispatcherHostDrvF: func(*context.Context, string, string) (*engine.DispatcherHost, error) {
- dspHost := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "TEST",
- },
- }
- return dspHost, nil
- },
- SetDispatcherHostDrvF: func(*context.Context, *engine.DispatcherHost) error {
- return nil
- },
- RemoveDispatcherHostDrvF: func(*context.Context, string, string) error {
- return nil
- },
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return nil, nil
- },
- }
-
- adms.dm = engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- experr = "SERVER_ERROR: NOT_IMPLEMENTED"
-
- if err := adms.SetDispatcherHost(context.Background(), dspHost, &reply); err == nil ||
- err.Error() != experr {
- t.Errorf("\nexpected <%+v>, \nreceived <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersRemoveDispatcherHostCheckErrors(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- dspHost := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- RemoteHost: &config.RemoteHost{
- ID: "TestDispatchersRemoveDispatcherHostCheckErrors",
- },
- Tenant: "cgrates.org",
- },
- }
- var reply string
-
- if err := adms.SetDispatcherHost(context.Background(), dspHost, &reply); err != nil {
- t.Error(err)
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), 10)
- adms.cfg.GeneralCfg().DefaultCaching = "not_a_caching_type"
- adms.connMgr = engine.NewConnManager(cfg)
- adms.connMgr.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches), utils.CacheSv1, make(chan birpc.ClientConnector))
- experr := "SERVER_ERROR: context deadline exceeded"
-
- if err := adms.RemoveDispatcherHost(ctx, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- ID: "TestDispatchersRemoveDispatcherHostCheckErrors",
- },
- }, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
- cancel()
-
- adms.cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- var rcv engine.DispatcherHost
-
- arg := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- ID: "TestDispatchersRemoveDispatcherHostCheckErrors",
- },
- }
-
- if err := adms.GetDispatcherHost(context.Background(), arg, &rcv); err == nil || err != utils.ErrDSPHostNotFound {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", utils.ErrDSPHostNotFound, err)
- }
-
- experr = "MANDATORY_IE_MISSING: [ID]"
-
- if err := adms.RemoveDispatcherHost(context.Background(),
- &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{}}, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- adms.dm = nil
- experr = "SERVER_ERROR: NO_DATABASE_CONNECTION"
-
- if err := adms.RemoveDispatcherHost(context.Background(), &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- ID: "TestDispatchersRemoveDispatcherHostCheckErrors",
- }}, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dbMock := &engine.DataDBMock{
- GetDispatcherHostDrvF: func(*context.Context, string, string) (*engine.DispatcherHost, error) {
- dspHost := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "TEST",
- },
- }
- return dspHost, nil
- },
- SetDispatcherHostDrvF: func(*context.Context, *engine.DispatcherHost) error {
- return nil
- },
- RemoveDispatcherHostDrvF: func(*context.Context, string, string) error {
- return nil
- },
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return nil, nil
- },
- SetIndexesDrvF: func(ctx *context.Context, idxItmType, tntCtx string, indexes map[string]utils.StringSet, commit bool, transactionID string) (err error) {
- return nil
- },
- GetIndexesDrvF: func(ctx *context.Context, idxItmType, tntCtx, idxKey, transactionID string) (indexes map[string]utils.StringSet, err error) {
- return map[string]utils.StringSet{}, nil
- },
- }
-
- engine.Cache.Clear(nil)
- adms.dm = engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- experr = "SERVER_ERROR: NOT_IMPLEMENTED"
-
- if err := adms.RemoveDispatcherHost(context.Background(),
- &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- ID: "TestDispatchersRemoveDispatcherHostCheckErrors",
- }}, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersGetDispatcherHostIDsErrMock(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- GetDispatcherHostDrvF: func(*context.Context, string, string) (*engine.DispatcherHost, error) {
- thPrf := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "TEST",
- },
- }
- return thPrf, nil
- },
- SetDispatcherHostDrvF: func(*context.Context, *engine.DispatcherHost) error {
- return nil
- },
- RemoveDispatcherHostDrvF: func(*context.Context, string, string) error {
- return nil
- },
- }
-
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply []string
- experr := "NOT_IMPLEMENTED"
-
- if err := adms.GetDispatcherHostIDs(context.Background(),
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- }, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersGetDispatcherHostIDsErrKeys(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return []string{}, nil
- },
- }
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply []string
-
- if err := adms.GetDispatcherHostIDs(context.Background(),
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- }, &reply); err == nil || err != utils.ErrNotFound {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersGetDispatcherHostIDsGetOptsErr(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- GetDispatcherHostDrvF: func(*context.Context, string, string) (*engine.DispatcherHost, error) {
- dspHost := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "TEST",
- },
- }
- return dspHost, nil
- },
- SetDispatcherHostDrvF: func(*context.Context, *engine.DispatcherHost) error {
- return nil
- },
- RemoveDispatcherHostDrvF: func(*context.Context, string, string) error {
- return nil
- },
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return []string{"dpp_cgrates.org:key1", "dpp_cgrates.org:key2", "dpp_cgrates.org:key3"}, nil
- },
- }
-
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply []string
- experr := "cannot convert field: true to int"
-
- if err := adms.GetDispatcherHostIDs(context.Background(),
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.PageLimitOpt: true,
- },
- }, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersGetDispatcherHostIDsPaginateErr(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- GetDispatcherHostDrvF: func(*context.Context, string, string) (*engine.DispatcherHost, error) {
- dspHost := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "TEST",
- },
- }
- return dspHost, nil
- },
- SetDispatcherHostDrvF: func(*context.Context, *engine.DispatcherHost) error {
- return nil
- },
- RemoveDispatcherHostDrvF: func(*context.Context, string, string) error {
- return nil
- },
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return []string{"dpp_cgrates.org:key1", "dpp_cgrates.org:key2", "dpp_cgrates.org:key3"}, nil
- },
- }
-
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply []string
- experr := `SERVER_ERROR: maximum number of items exceeded`
-
- if err := adms.GetDispatcherHostIDs(context.Background(),
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.PageLimitOpt: 2,
- utils.PageOffsetOpt: 4,
- utils.PageMaxItemsOpt: 5,
- },
- }, &reply); err == nil || err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersGetDispatcherHostsCountErrMock(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- GetDispatcherHostDrvF: func(*context.Context, string, string) (*engine.DispatcherHost, error) {
- thPrf := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "TEST",
- },
- }
- return thPrf, nil
- },
- SetDispatcherHostDrvF: func(*context.Context, *engine.DispatcherHost) error {
- return nil
- },
- RemoveDispatcherHostDrvF: func(*context.Context, string, string) error {
- return nil
- },
- }
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply int
-
- if err := adms.GetDispatcherHostsCount(context.Background(),
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- }, &reply); err == nil || err != utils.ErrNotImplemented {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", utils.ErrNotImplemented, err)
- }
-}
-
-func TestDispatchersGetDispatcherHostsCountErrKeys(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return []string{}, nil
- },
- }
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply int
-
- if err := adms.GetDispatcherHostsCount(context.Background(),
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- }, &reply); err == nil || err != utils.ErrNotFound {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
- }
-}
-
-func TestDispatchersGetDispatcherProfilesGetIDsErr(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- connMgr := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMgr)
- admS := NewAdminSv1(cfg, dm, connMgr, nil, nil)
- args := &DispatcherWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "test_ID1",
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "Host1",
- },
- },
- Weight: 10,
- },
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
-
- var setReply string
- if err := admS.SetDispatcherProfile(context.Background(), args, &setReply); err != nil {
- t.Error(err)
- } else if setReply != "OK" {
- t.Error("Unexpected reply returned:", setReply)
- }
-
- argsGet := &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- ItemsPrefix: "test_ID",
- APIOpts: map[string]any{
- utils.PageLimitOpt: 2,
- utils.PageOffsetOpt: 4,
- utils.PageMaxItemsOpt: 5,
- },
- }
-
- experr := `SERVER_ERROR: maximum number of items exceeded`
- var getReply []*engine.DispatcherProfile
- if err := admS.GetDispatcherProfiles(context.Background(), argsGet, &getReply); err == nil || err.Error() != experr {
- t.Errorf("expected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-}
-
-func TestDispatchersGetDispatcherProfilesGetProfileErr(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- SetDispatcherProfileDrvF: func(*context.Context, *engine.DispatcherProfile) error {
- return nil
- },
- RemoveDispatcherProfileDrvF: func(*context.Context, string, string) error {
- return nil
- },
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return []string{"dpp_cgrates.org:TEST"}, nil
- },
- }
-
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply []*engine.DispatcherProfile
- experr := "SERVER_ERROR: NOT_IMPLEMENTED"
-
- if err := adms.GetDispatcherProfiles(context.Background(),
- &utils.ArgsItemIDs{
- ItemsPrefix: "TEST",
- }, &reply); err == nil || err.Error() != experr {
- t.Errorf("expected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersGetDispatcherHostsGetIDsErr(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- connMgr := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMgr)
- admS := NewAdminSv1(cfg, dm, connMgr, nil, nil)
- args := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "test_ID1",
- Reconnects: -1,
- },
- },
- APIOpts: nil,
- }
-
- var setReply string
- if err := admS.SetDispatcherHost(context.Background(), args, &setReply); err != nil {
- t.Error(err)
- } else if setReply != "OK" {
- t.Error("Unexpected reply returned:", setReply)
- }
-
- argsGet := &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- ItemsPrefix: "test_ID",
- APIOpts: map[string]any{
- utils.PageLimitOpt: 2,
- utils.PageOffsetOpt: 4,
- utils.PageMaxItemsOpt: 5,
- },
- }
-
- experr := `SERVER_ERROR: maximum number of items exceeded`
- var getReply []*engine.DispatcherHost
- if err := admS.GetDispatcherHosts(context.Background(), argsGet, &getReply); err == nil || err.Error() != experr {
- t.Errorf("expected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-}
-
-func TestDispatchersGetDispatcherHostsGetHostErr(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- dbMock := &engine.DataDBMock{
- SetDispatcherHostDrvF: func(*context.Context, *engine.DispatcherHost) error {
- return nil
- },
- RemoveDispatcherHostDrvF: func(*context.Context, string, string) error {
- return nil
- },
- GetKeysForPrefixF: func(c *context.Context, s string) ([]string, error) {
- return []string{"dph_cgrates.org:TEST"}, nil
- },
- }
-
- dm := engine.NewDataManager(dbMock, cfg.CacheCfg(), nil)
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- }
-
- var reply []*engine.DispatcherHost
- experr := "SERVER_ERROR: NOT_IMPLEMENTED"
-
- if err := adms.GetDispatcherHosts(context.Background(),
- &utils.ArgsItemIDs{
- ItemsPrefix: "TEST",
- }, &reply); err == nil || err.Error() != experr {
- t.Errorf("expected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
- dm.DataDB().Flush(utils.EmptyString)
-}
-
-func TestDispatchersSetDispatcherHostErr(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultCaching = utils.MetaNone
- adms := &AdminSv1{
- cfg: cfg,
- }
-
- dspHost := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- RemoteHost: &config.RemoteHost{
- ID: "TEST",
- },
- },
- }
-
- var reply string
- experr := "SERVER_ERROR: NO_DATABASE_CONNECTION"
-
- if err := adms.SetDispatcherHost(context.Background(), dspHost, &reply); err == nil ||
- err.Error() != experr {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", experr, err)
- }
-
-}
diff --git a/apis/filter_indexes.go b/apis/filter_indexes.go
index 3800c8901..82b2ab0f2 100644
--- a/apis/filter_indexes.go
+++ b/apis/filter_indexes.go
@@ -78,8 +78,6 @@ func (adms *AdminSv1) RemoveFilterIndexes(ctx *context.Context, arg *AttrRemFilt
}
arg.ItemType = utils.CacheRateFilterIndexes
tntCtx = utils.ConcatenatedKey(tnt, arg.Context)
- case utils.MetaDispatchers:
- arg.ItemType = utils.CacheDispatcherFilterIndexes
case utils.MetaAttributes:
arg.ItemType = utils.CacheAttributeFilterIndexes
}
@@ -134,8 +132,6 @@ func (adms *AdminSv1) GetFilterIndexes(ctx *context.Context, arg *AttrGetFilterI
}
arg.ItemType = utils.CacheRateFilterIndexes
tntCtx = utils.ConcatenatedKey(tnt, arg.Context)
- case utils.MetaDispatchers:
- arg.ItemType = utils.CacheDispatcherFilterIndexes
case utils.MetaAttributes:
arg.ItemType = utils.CacheAttributeFilterIndexes
}
@@ -386,21 +382,6 @@ func (adms *AdminSv1) ComputeFilterIndexes(ctx *context.Context, args *utils.Arg
}
args.RateS = indexes.Size() != 0
}
- //DispatcherProfile Indexes
- if args.DispatcherS {
- cacheIDs[utils.CacheDispatcherFilterIndexes] = []string{utils.MetaAny}
- if indexes, err = engine.ComputeIndexes(ctx, adms.dm, tnt, utils.EmptyString, utils.CacheDispatcherFilterIndexes,
- nil, transactionID, func(tnt, id, grp string) (*[]string, error) {
- dsp, e := adms.dm.GetDispatcherProfile(ctx, tnt, id, true, false, utils.NonTransactional)
- if e != nil {
- return nil, e
- }
- return utils.SliceStringPointer(slices.Clone(dsp.FilterIDs)), nil
- }, nil); err != nil && err != utils.ErrDSPProfileNotFound {
- return utils.APIErrorHandler(err)
- }
- args.DispatcherS = indexes.Size() != 0
- }
//Now we move from tmpKey to the right key for each type
//ThresholdProfile Indexes
@@ -463,12 +444,6 @@ func (adms *AdminSv1) ComputeFilterIndexes(ctx *context.Context, args *utils.Arg
}
}
- //DispatcherProfile Indexes
- if args.DispatcherS {
- if err = adms.dm.SetIndexes(ctx, utils.CacheDispatcherFilterIndexes, tnt, nil, true, transactionID); err != nil {
- return
- }
- }
//generate a load
//ID for CacheFilterIndexes and store it in database
loadIDs := make(map[string]int64)
@@ -641,20 +616,6 @@ func (adms *AdminSv1) ComputeFilterIndexIDs(ctx *context.Context, args *utils.Ar
if indexes.Size() != 0 {
cacheIDs[utils.CacheRateProfilesFilterIndexes] = indexes.AsSlice()
}
- //DispatcherProfile Indexes
- if indexes, err = engine.ComputeIndexes(ctx, adms.dm, tnt, utils.EmptyString, utils.CacheDispatcherFilterIndexes,
- &args.DispatcherIDs, transactionID, func(tnt, id, grp string) (*[]string, error) {
- dsp, e := adms.dm.GetDispatcherProfile(ctx, tnt, id, true, false, utils.NonTransactional)
- if e != nil {
- return nil, e
- }
- return utils.SliceStringPointer(slices.Clone(dsp.FilterIDs)), nil
- }, nil); err != nil && err != utils.ErrDSPProfileNotFound {
- return utils.APIErrorHandler(err)
- }
- if indexes.Size() != 0 {
- cacheIDs[utils.CacheDispatcherFilterIndexes] = indexes.AsSlice()
- }
//generate a load
//ID for CacheFilterIndexes and store it in database
@@ -772,20 +733,6 @@ func (adms *AdminSv1) GetChargersIndexesHealth(ctx *context.Context, args *engin
return nil
}
-func (adms *AdminSv1) GetDispatchersIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) error {
- rp, err := engine.GetFltrIdxHealth(ctx, adms.dm,
- ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
- ltcache.NewCache(args.IndexCacheLimit, args.IndexCacheTTL, args.IndexCacheStaticTTL, nil),
- ltcache.NewCache(args.ObjectCacheLimit, args.ObjectCacheTTL, args.ObjectCacheStaticTTL, nil),
- utils.CacheDispatcherFilterIndexes,
- )
- if err != nil {
- return err
- }
- *reply = *rp
- return nil
-}
-
func (adms *AdminSv1) GetRateProfilesIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) error {
rp, err := engine.GetFltrIdxHealth(ctx, adms.dm,
ltcache.NewCache(args.FilterCacheLimit, args.FilterCacheTTL, args.FilterCacheStaticTTL, nil),
diff --git a/apis/filter_indexes_test.go b/apis/filter_indexes_test.go
index b06412410..7a6d50e07 100644
--- a/apis/filter_indexes_test.go
+++ b/apis/filter_indexes_test.go
@@ -212,25 +212,6 @@ func TestRemoveFilterIndexes(t *testing.T) {
t.Errorf("Expected %v\n but received %v", utils.CacheRateFilterIndexes, args.ItemType)
}
- //Dispatchers
- args = &AttrRemFilterIndexes{
- Tenant: "cgrates.org",
- Context: "cgrates",
- ItemType: utils.MetaDispatchers,
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
- if err := adms.RemoveFilterIndexes(context.Background(), args, &reply); err != nil {
- t.Error(err)
- }
- if reply != utils.OK {
- t.Error("Expected OK")
- }
- if args.ItemType != utils.CacheDispatcherFilterIndexes {
- t.Errorf("Expected %v\n but received %v", utils.DispatcherFilterIndexes, args.ItemType)
- }
-
//Attributes
args = &AttrRemFilterIndexes{
Tenant: "cgrates.org",
@@ -413,15 +394,6 @@ func TestComputeFilterIndexes(t *testing.T) {
t.Error(err)
}
- //DispatcherProfile
- args = &utils.ArgsComputeFilterIndexes{
- Tenant: "cgrates.org",
- DispatcherS: true,
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
-
if err := adms.ComputeFilterIndexes(context.Background(), args, &reply); err != nil {
t.Error(err)
}
@@ -559,18 +531,6 @@ func TestComputeFilterIndexIDs(t *testing.T) {
t.Error(err)
}
- //DispatcherProfile
- args = &utils.ArgsComputeFilterIndexIDs{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- DispatcherIDs: []string{""},
- }
-
- if err := adms.ComputeFilterIndexIDs(context.Background(), args, &reply); err != nil {
- t.Error(err)
- }
}
func TestGetFilterIndexes(t *testing.T) {
@@ -714,16 +674,6 @@ func TestGetFilterIndexes(t *testing.T) {
t.Errorf("Expected %v\n but received %v", utils.ErrNotFound, err)
}
- //Dispatchers
- args = &AttrGetFilterIndexes{
- Tenant: "cgrates.org",
- Context: "cgrates",
- ItemType: utils.MetaDispatchers,
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
-
if err := adms.GetFilterIndexes(context.Background(), args, &reply); err != utils.ErrNotFound {
t.Errorf("Expected %v\n but received %v", utils.ErrNotFound, err)
}
@@ -932,33 +882,6 @@ func TestGetChargersIndexHealth(t *testing.T) {
}
}
-func TestGetDispatchersIndexesHealth(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- connMgr := engine.NewConnManager(cfg)
- cfg.AdminSCfg().CachesConns = []string{"*internal"}
- adms := &AdminSv1{
- cfg: cfg,
- dm: dm,
- connMgr: connMgr,
- ping: struct{}{},
- }
-
- var reply engine.FilterIHReply
-
- args := &engine.IndexHealthArgs{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
-
- if err := adms.GetDispatchersIndexesHealth(context.Background(), args, &reply); err != nil {
- t.Error(err)
- }
-}
-
func TestGetRateProfilesIndexesHealth(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
diff --git a/apis/libadmin_test.go b/apis/libadmin_test.go
index bacae5319..125456595 100644
--- a/apis/libadmin_test.go
+++ b/apis/libadmin_test.go
@@ -55,19 +55,10 @@ func TestCallCacheForFilter(t *testing.T) {
if err := dm.SetThresholdProfile(context.TODO(), th, true); err != nil {
t.Fatal(err)
}
- dsp := &engine.DispatcherProfile{
- Tenant: tnt,
- ID: "Dsp1",
- FilterIDs: []string{flt.ID},
- }
- if err := dm.SetDispatcherProfile(context.TODO(), dsp, true); err != nil {
- t.Fatal(err)
- }
exp := map[string][]string{
- utils.CacheFilters: {"cgrates.org:FLTR1"},
- utils.CacheDispatcherFilterIndexes: {"cgrates.org:*string:*req.Account:1001"},
- utils.CacheThresholdFilterIndexes: {"cgrates.org:*string:*req.Account:1001"},
+ utils.CacheFilters: {"cgrates.org:FLTR1"},
+ utils.CacheThresholdFilterIndexes: {"cgrates.org:*string:*req.Account:1001"},
}
rpl, err := composeCacheArgsForFilter(dm, context.TODO(), flt, tnt, flt.TenantID(), map[string][]string{utils.CacheFilters: {"cgrates.org:FLTR1"}})
if err != nil {
@@ -91,9 +82,8 @@ func TestCallCacheForFilter(t *testing.T) {
t.Fatal(err)
}
exp = map[string][]string{
- utils.CacheFilters: {"cgrates.org:FLTR1"},
- utils.CacheDispatcherFilterIndexes: {"cgrates.org:*string:*req.Account:1001", "cgrates.org:*string:*req.Account:1002"},
- utils.CacheThresholdFilterIndexes: {"cgrates.org:*string:*req.Account:1001", "cgrates.org:*string:*req.Account:1002"},
+ utils.CacheFilters: {"cgrates.org:FLTR1"},
+ utils.CacheThresholdFilterIndexes: {"cgrates.org:*string:*req.Account:1001", "cgrates.org:*string:*req.Account:1002"},
}
rpl, err = composeCacheArgsForFilter(dm, context.TODO(), flt, tnt, flt.TenantID(), rpl)
if err != nil {
diff --git a/apis/loaders_it_test.go b/apis/loaders_it_test.go
index b22be8f7c..45d86357a 100644
--- a/apis/loaders_it_test.go
+++ b/apis/loaders_it_test.go
@@ -60,8 +60,6 @@ var (
testLoadersGetActionProfiles,
testLoadersGetAttributeProfiles,
testLoadersGetChargerProfiles,
- testLoadersGetDispatcherProfiles,
- testLoadersGetDispatcherHosts,
testLoadersGetFilters,
testLoadersGetRateProfiles,
testLoadersGetResourceProfiles,
@@ -74,8 +72,6 @@ var (
testLoadersGetActionProfileAfterRemove,
testLoadersGetAttributeProfileAfterRemove,
testLoadersGetChargerProfileAfterRemove,
- testLoadersGetDispatcherProfileAfterRemove,
- testLoadersGetDispatcherHostAfterRemove,
testLoadersGetFilterAfterRemove,
testLoadersGetRateProfileAfterRemove,
testLoadersGetResourceProfileAfterRemove,
@@ -237,30 +233,6 @@ cgrates.org,Charger2,*string:~*req.Account:1002,;15,;false,,
t.Fatal(err)
}
- // Create and populate DispatcherProfiles.csv
- if err := writeFile(utils.DispatcherProfilesCsv, `
-#Tenant,ID,FilterIDs,Weight,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters
-cgrates.org,D1,,,,,,,,,
-cgrates.org,D1,*string:~*req.Account:1001,20,*first,,,,,,
-cgrates.org,D1,,,,,C1,fltr1,10,true,*ratio:1;param1:value1
-cgrates.org,D1,,,,,,,,,
-cgrates.org,D1,,,,,C1,fltr2;fltr4,,false,param2:value2
-cgrates.org,D2,,,*first,,C3,fltr2,20,true,
-cgrates.org,D2,*string:~*req.Account:1002,20,,,C2,fltr3,10,,param3:value3
-`); err != nil {
- t.Fatal(err)
- }
-
- // Create and populate DispatcherHosts.csv
- if err := writeFile(utils.DispatcherHostsCsv, `
-#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12]
-cgrates.org,ALL,,,,,5m,,,,,,
-cgrates.org,ALL,127.0.0.1:6012,,1,3,5m,1m,2m,true,,,
-cgrates.org,ALL,,*json,1,3,5m,1m,2m,false,,,
-`); err != nil {
- t.Fatal(err)
- }
-
// Create and populate Filters.csv
if err := writeFile(utils.FiltersCsv, `
#Tenant[0],ID[1],Type[2],Element[3],Values[4]
@@ -760,100 +732,6 @@ func testLoadersGetChargerProfiles(t *testing.T) {
}
}
-func testLoadersGetDispatcherProfiles(t *testing.T) {
- expDspPrfs := []*engine.DispatcherProfile{
- {
- Tenant: "cgrates.org",
- ID: "D1",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{},
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C1",
- FilterIDs: []string{"fltr1", "fltr2", "fltr4"},
- Weight: 10,
- Params: map[string]any{
- utils.MetaRatio: "1",
- "param1": "value1",
- "param2": "value2",
- },
- Blocker: true,
- },
- },
- },
- {
- Tenant: "cgrates.org",
- ID: "D2",
- FilterIDs: []string{"*string:~*req.Account:1002"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{},
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- {
- ID: "C2",
- FilterIDs: []string{"fltr3"},
- Weight: 10,
- Params: map[string]any{
- "param3": "value3",
- },
- Blocker: false,
- },
- },
- },
- }
- var dspPrfs []*engine.DispatcherProfile
- if err := ldrRPC.Call(context.Background(), utils.AdminSv1GetDispatcherProfiles,
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- }, &dspPrfs); err != nil {
- t.Error(err)
- } else {
- sort.Slice(dspPrfs, func(i, j int) bool {
- return dspPrfs[i].ID < dspPrfs[j].ID
- })
- if !reflect.DeepEqual(dspPrfs, expDspPrfs) {
- t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(expDspPrfs), utils.ToJSON(dspPrfs))
- }
- }
-}
-
-func testLoadersGetDispatcherHosts(t *testing.T) {
- expDspHosts := []*engine.DispatcherHost{
- {
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "ALL",
- Address: "127.0.0.1:6012",
- Transport: utils.MetaJSON,
- ConnectAttempts: 1,
- Reconnects: 3,
- MaxReconnectInterval: 5 * time.Minute,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- TLS: true,
- },
- },
- }
- var dspHosts []*engine.DispatcherHost
- if err := ldrRPC.Call(context.Background(), utils.AdminSv1GetDispatcherHosts,
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- }, &dspHosts); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(dspHosts, expDspHosts) {
- t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ToJSON(expDspHosts), utils.ToJSON(dspHosts))
- }
-}
-
func testLoadersGetFilters(t *testing.T) {
expFltrs := []*engine.Filter{
{
@@ -1469,44 +1347,6 @@ func testLoadersGetChargerProfileAfterRemove(t *testing.T) {
}
}
-func testLoadersGetDispatcherProfileAfterRemove(t *testing.T) {
- var dspPrfIDs []string
- if err := ldrRPC.Call(context.Background(), utils.AdminSv1GetDispatcherProfileIDs,
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- }, &dspPrfIDs); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
- }
-
- var rplyDspPrf engine.ChargerProfile
- if err := ldrRPC.Call(context.Background(), utils.AdminSv1GetDispatcherProfile,
- utils.TenantID{
- Tenant: "cgrates.org",
- ID: "DSP1",
- }, &rplyDspPrf); err == nil || err.Error() != utils.ErrDSPProfileNotFound.Error() {
- t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrDSPProfileNotFound, err)
- }
-}
-
-func testLoadersGetDispatcherHostAfterRemove(t *testing.T) {
- var dspHostIDs []string
- if err := ldrRPC.Call(context.Background(), utils.AdminSv1GetDispatcherHostIDs,
- &utils.ArgsItemIDs{
- Tenant: "cgrates.org",
- }, &dspHostIDs); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err)
- }
-
- var rplyDspHost engine.DispatcherHost
- if err := ldrRPC.Call(context.Background(), utils.AdminSv1GetDispatcherHost,
- utils.TenantID{
- Tenant: "cgrates.org",
- ID: "DSPHOST1",
- }, &rplyDspHost); err == nil || err.Error() != utils.ErrDSPHostNotFound.Error() {
- t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrDSPHostNotFound, err)
- }
-}
-
func testLoadersGetFilterAfterRemove(t *testing.T) {
var fltrIDs []string
if err := ldrRPC.Call(context.Background(), utils.AdminSv1GetFilterIDs,
diff --git a/apis/replicator.go b/apis/replicator.go
index 165f33566..3323becd5 100644
--- a/apis/replicator.go
+++ b/apis/replicator.go
@@ -189,28 +189,6 @@ func (rplSv1 *ReplicatorSv1) GetChargerProfile(ctx *context.Context, tntID *util
return nil
}
-// GetDispatcherProfile is the remote method coresponding to the dataDb driver method
-func (rplSv1 *ReplicatorSv1) GetDispatcherProfile(ctx *context.Context, tntID *utils.TenantIDWithAPIOpts, reply *engine.DispatcherProfile) error {
- engine.UpdateReplicationFilters(utils.DispatcherProfilePrefix, tntID.TenantID.TenantID(), utils.IfaceAsString(tntID.APIOpts[utils.RemoteHostOpt]))
- rcv, err := rplSv1.dm.DataDB().GetDispatcherProfileDrv(ctx, tntID.Tenant, tntID.ID)
- if err != nil {
- return err
- }
- *reply = *rcv
- return nil
-}
-
-// GetDispatcherHost is the remote method coresponding to the dataDb driver method
-func (rplSv1 *ReplicatorSv1) GetDispatcherHost(ctx *context.Context, tntID *utils.TenantIDWithAPIOpts, reply *engine.DispatcherHost) error {
- engine.UpdateReplicationFilters(utils.DispatcherHostPrefix, tntID.TenantID.TenantID(), utils.IfaceAsString(tntID.APIOpts[utils.RemoteHostOpt]))
- rcv, err := rplSv1.dm.DataDB().GetDispatcherHostDrv(ctx, tntID.Tenant, tntID.ID)
- if err != nil {
- return err
- }
- *reply = *rcv
- return nil
-}
-
// GetItemLoadIDs is the remote method coresponding to the dataDb driver method
func (rplSv1 *ReplicatorSv1) GetItemLoadIDs(ctx *context.Context, itemID *utils.StringWithAPIOpts, reply *map[string]int64) error {
engine.UpdateReplicationFilters(utils.LoadIDPrefix, itemID.Arg, utils.IfaceAsString(itemID.APIOpts[utils.RemoteHostOpt]))
@@ -459,42 +437,6 @@ func (rplSv1 *ReplicatorSv1) SetChargerProfile(ctx *context.Context, cp *engine.
return
}
-// SetDispatcherProfile is the replication method coresponding to the dataDb driver method
-func (rplSv1 *ReplicatorSv1) SetDispatcherProfile(ctx *context.Context, dpp *engine.DispatcherProfileWithAPIOpts, reply *string) (err error) {
- if err = rplSv1.dm.DataDB().SetDispatcherProfileDrv(ctx, dpp.DispatcherProfile); err != nil {
- return
- }
- // delay if needed before cache call
- if rplSv1.v1.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.cfg.GeneralCfg().CachingDelay))
- time.Sleep(rplSv1.v1.cfg.GeneralCfg().CachingDelay)
- }
- if err = rplSv1.v1.CallCache(ctx, utils.IfaceAsString(dpp.APIOpts[utils.MetaCache]),
- dpp.Tenant, utils.CacheDispatcherProfiles, dpp.TenantID(), utils.EmptyString, &dpp.FilterIDs, dpp.APIOpts); err != nil {
- return
- }
- *reply = utils.OK
- return
-}
-
-// SetDispatcherHost is the replication method coresponding to the dataDb driver method
-func (rplSv1 *ReplicatorSv1) SetDispatcherHost(ctx *context.Context, dpp *engine.DispatcherHostWithAPIOpts, reply *string) (err error) {
- if err = rplSv1.dm.DataDB().SetDispatcherHostDrv(ctx, dpp.DispatcherHost); err != nil {
- return
- }
- // delay if needed before cache call
- if rplSv1.v1.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.cfg.GeneralCfg().CachingDelay))
- time.Sleep(rplSv1.v1.cfg.GeneralCfg().CachingDelay)
- }
- if err = rplSv1.v1.CallCache(ctx, utils.IfaceAsString(dpp.APIOpts[utils.MetaCache]),
- dpp.Tenant, utils.CacheDispatcherHosts, dpp.TenantID(), utils.EmptyString, nil, dpp.APIOpts); err != nil {
- return
- }
- *reply = utils.OK
- return
-}
-
// SetLoadIDs is the replication method coresponding to the dataDb driver method
func (rplSv1 *ReplicatorSv1) SetLoadIDs(ctx *context.Context, args *utils.LoadIDsWithAPIOpts, reply *string) (err error) {
if err = rplSv1.dm.DataDB().SetLoadIDsDrv(ctx, args.LoadIDs); err != nil {
@@ -755,42 +697,6 @@ func (rplSv1 *ReplicatorSv1) RemoveChargerProfile(ctx *context.Context, args *ut
return
}
-// RemoveDispatcherProfile is the replication method coresponding to the dataDb driver method
-func (rplSv1 *ReplicatorSv1) RemoveDispatcherProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- if err = rplSv1.dm.DataDB().RemoveDispatcherProfileDrv(ctx, args.Tenant, args.ID); err != nil {
- return
- }
- // delay if needed before cache call
- if rplSv1.v1.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.cfg.GeneralCfg().CachingDelay))
- time.Sleep(rplSv1.v1.cfg.GeneralCfg().CachingDelay)
- }
- if err = rplSv1.v1.CallCache(ctx, utils.IfaceAsString(args.APIOpts[utils.MetaCache]),
- args.Tenant, utils.CacheDispatcherProfiles, args.TenantID.TenantID(), utils.EmptyString, nil, args.APIOpts); err != nil {
- return
- }
- *reply = utils.OK
- return
-}
-
-// RemoveDispatcherHost is the replication method coresponding to the dataDb driver method
-func (rplSv1 *ReplicatorSv1) RemoveDispatcherHost(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- if err = rplSv1.dm.DataDB().RemoveDispatcherHostDrv(ctx, args.Tenant, args.ID); err != nil {
- return
- }
- // delay if needed before cache call
- if rplSv1.v1.cfg.GeneralCfg().CachingDelay != 0 {
- utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.cfg.GeneralCfg().CachingDelay))
- time.Sleep(rplSv1.v1.cfg.GeneralCfg().CachingDelay)
- }
- if err = rplSv1.v1.CallCache(ctx, utils.IfaceAsString(args.APIOpts[utils.MetaCache]),
- args.Tenant, utils.CacheDispatcherHosts, args.TenantID.TenantID(), utils.EmptyString, nil, args.APIOpts); err != nil {
- return
- }
- *reply = utils.OK
- return
-}
-
// RemoveIndexes is the replication method coresponding to the dataDb driver method
func (rplSv1 *ReplicatorSv1) RemoveIndexes(ctx *context.Context, args *utils.GetIndexesArg, reply *string) (err error) {
if err = rplSv1.dm.DataDB().RemoveIndexesDrv(ctx, args.IdxItmType, args.TntCtx, args.IdxKey); err != nil {
diff --git a/apis/replicator_test.go b/apis/replicator_test.go
index 1215de345..37b38d791 100644
--- a/apis/replicator_test.go
+++ b/apis/replicator_test.go
@@ -846,163 +846,6 @@ func TestReplicatorGetChargerProfileError(t *testing.T) {
}
}
-func TestReplicatorGetDispatcherProfile(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- v1 := &AdminSv1{
- cfg: cfg,
- dm: dm,
- connMgr: engine.NewConnManager(cfg),
- ping: struct{}{},
- }
-
- var reply engine.DispatcherProfile
- rp := NewReplicatorSv1(dm, v1)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: "false",
- },
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203"},
- Blocker: false,
- },
- },
- }
- rp.dm.SetDispatcherProfile(context.Background(), dsp, false)
- tntID := &utils.TenantIDWithAPIOpts{
- TenantID: utils.NewTenantID("cgrates.org:Dsp1"),
- }
-
- if err := rp.GetDispatcherProfile(context.Background(), tntID, &reply); err != nil {
- t.Error(err)
- }
- if !reflect.DeepEqual(dsp, &reply) {
- t.Errorf("Expected %v\n but received %v", dsp, reply)
- }
-}
-func TestReplicatorGetDispatcherProfileError(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- v1 := &AdminSv1{
- cfg: cfg,
- dm: dm,
- connMgr: engine.NewConnManager(cfg),
- ping: struct{}{},
- }
-
- var reply engine.DispatcherProfile
- rp := NewReplicatorSv1(dm, v1)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp5",
- FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: "false",
- },
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203"},
- Blocker: false,
- },
- },
- }
- rp.dm.SetDispatcherProfile(context.Background(), dsp, false)
- tntID := &utils.TenantIDWithAPIOpts{
- TenantID: utils.NewTenantID("cgrates.org:Dsp1"),
- }
-
- if err := rp.GetDispatcherProfile(context.Background(), tntID, &reply); err == nil || err != utils.ErrDSPProfileNotFound {
- t.Errorf("Expected %v\n but received %v", utils.ErrDSPProfileNotFound, err)
- }
-}
-
-func TestReplicatorGetDispatcherHost(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- v1 := &AdminSv1{
- cfg: cfg,
- dm: dm,
- connMgr: engine.NewConnManager(cfg),
- ping: struct{}{},
- }
-
- var reply engine.DispatcherHost
- rp := NewReplicatorSv1(dm, v1)
- dsph := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "DSH1",
- Address: "*internal",
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- }
- rp.dm.SetDispatcherHost(context.Background(), dsph)
- tntID := &utils.TenantIDWithAPIOpts{
- TenantID: utils.NewTenantID("cgrates.org:DSH1"),
- }
-
- if err := rp.GetDispatcherHost(context.Background(), tntID, &reply); err != nil {
- t.Error(err)
- }
- if !reflect.DeepEqual(dsph, &reply) {
- t.Errorf("Expected %v\n but received %v", dsph, reply)
- }
-}
-
-func TestReplicatorGetDispatcherHostError(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- v1 := &AdminSv1{
- cfg: cfg,
- dm: dm,
- connMgr: engine.NewConnManager(cfg),
- ping: struct{}{},
- }
-
- var reply engine.DispatcherHost
- rp := NewReplicatorSv1(dm, v1)
- dsph := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "DSH22",
- Address: "*internal",
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- }
- rp.dm.SetDispatcherHost(context.Background(), dsph)
- tntID := &utils.TenantIDWithAPIOpts{
- TenantID: utils.NewTenantID("cgrates.org:DSH1"),
- }
-
- if err := rp.GetDispatcherHost(context.Background(), tntID, &reply); err == nil || err != utils.ErrDSPHostNotFound {
- t.Errorf("Expected %v\n but received %v", utils.ErrDSPHostNotFound, err)
- }
-}
-
func TestReplicatorGetItemLoadIDs(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
@@ -1970,174 +1813,6 @@ func TestReplicatorChargerProfileErr1(t *testing.T) {
}
}
-func TestReplicatorSetDispatcherProfile(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- v1 := &AdminSv1{
- cfg: cfg,
- dm: dm,
- connMgr: engine.NewConnManager(cfg),
- ping: struct{}{},
- }
- cfg.AdminSCfg().CachesConns = []string{"*internal"}
- var reply string
- rp := NewReplicatorSv1(dm, v1)
- dspPrf := &engine.DispatcherProfileWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: "false",
- },
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203"},
- Blocker: false,
- },
- },
- },
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
- if err := rp.SetDispatcherProfile(context.Background(), dspPrf, &reply); err != nil {
- t.Error(err)
- }
- rcv, err := rp.dm.GetDispatcherProfile(context.Background(), "cgrates.org", "Dsp1", false, false, utils.GenUUID())
- if err != nil {
- t.Error(err)
- }
- if !reflect.DeepEqual(rcv, dspPrf.DispatcherProfile) {
- t.Errorf("Expected %v\n but received %v", dspPrf.DispatcherProfile, rcv)
- }
-}
-
-func TestReplicatorSetDispatcherProfileErr1(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- v1 := &AdminSv1{
- cfg: cfg,
- dm: dm,
- connMgr: engine.NewConnManager(cfg),
- ping: struct{}{},
- }
- cfg.AdminSCfg().CachesConns = []string{"*internal"}
- var reply string
- rp := NewReplicatorSv1(dm, v1)
- dspPrf := &engine.DispatcherProfileWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: "false",
- },
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203"},
- Blocker: false,
- },
- },
- },
- APIOpts: map[string]any{
- utils.MetaCache: utils.OK,
- },
- }
- errExpect := "nil rpc in argument method: in: out"
- if err := rp.SetDispatcherProfile(context.Background(), dspPrf, &reply); !strings.Contains(err.Error(), errExpect) {
- t.Errorf("Expected error to include %v", errExpect)
- }
-}
-
-func TestReplicatorSetDispatcherHost(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- v1 := &AdminSv1{
- cfg: cfg,
- dm: dm,
- connMgr: engine.NewConnManager(cfg),
- ping: struct{}{},
- }
- cfg.AdminSCfg().CachesConns = []string{"*internal"}
- var reply string
- rp := NewReplicatorSv1(dm, v1)
- dspH := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "DSH1",
- Address: "*internal",
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- },
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
- if err := rp.SetDispatcherHost(context.Background(), dspH, &reply); err != nil {
- t.Error(err)
- }
- rcv, err := rp.dm.GetDispatcherHost(context.Background(), "cgrates.org", "DSH1", false, false, utils.GenUUID())
- if err != nil {
- t.Error(err)
- }
- if !reflect.DeepEqual(rcv, dspH.DispatcherHost) {
- t.Errorf("Expected %v\n but received %v", dspH.DispatcherHost, rcv)
- }
-}
-
-func TestReplicatorSetDispatcherHostErr1(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- v1 := &AdminSv1{
- cfg: cfg,
- dm: dm,
- connMgr: engine.NewConnManager(cfg),
- ping: struct{}{},
- }
- cfg.AdminSCfg().CachesConns = []string{"*internal"}
- var reply string
- rp := NewReplicatorSv1(dm, v1)
- dspH := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "DSH1",
- Address: "*internal",
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- },
- APIOpts: map[string]any{
- utils.MetaCache: utils.OK,
- },
- }
- errExpect := "nil rpc in argument method: in: out"
- if err := rp.SetDispatcherHost(context.Background(), dspH, &reply); !strings.Contains(err.Error(), errExpect) {
- t.Errorf("Expected error to include %v", errExpect)
- }
-}
-
func TestReplicatorRemoveThreshold(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
@@ -3092,186 +2767,6 @@ func TestReplicatorRemoveChargerProfileErr(t *testing.T) {
}
}
-func TestReplicatorRemoveDispatcherProfile(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- v1 := &AdminSv1{
- cfg: cfg,
- dm: dm,
- connMgr: engine.NewConnManager(cfg),
- ping: struct{}{},
- }
- cfg.AdminSCfg().CachesConns = []string{"*internal"}
- var reply string
- rp := NewReplicatorSv1(dm, v1)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: "false",
- },
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203"},
- Blocker: false,
- },
- },
- }
- if err := rp.dm.SetDispatcherProfile(context.Background(), dsp, false); err != nil {
- t.Error(err)
- }
- args := &utils.TenantIDWithAPIOpts{
- TenantID: utils.NewTenantID("cgrates.org:Dsp1"),
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
- err := rp.RemoveDispatcherProfile(context.Background(), args, &reply)
- if err != nil {
- t.Error(err)
- }
- if reply != utils.OK {
- t.Errorf("Expected %v\n but received %v", utils.OK, reply)
- }
-}
-
-func TestReplicatorRemoveDispatcherProfileErr(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- v1 := &AdminSv1{
- cfg: cfg,
- dm: dm,
- connMgr: engine.NewConnManager(cfg),
- ping: struct{}{},
- }
- cfg.AdminSCfg().CachesConns = []string{"*internal"}
- var reply string
- rp := NewReplicatorSv1(dm, v1)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: "false",
- },
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203"},
- Blocker: false,
- },
- },
- }
- if err := rp.dm.SetDispatcherProfile(context.Background(), dsp, false); err != nil {
- t.Error(err)
- }
- args := &utils.TenantIDWithAPIOpts{
- TenantID: utils.NewTenantID("cgrates.org:Dsp1"),
- APIOpts: map[string]any{
- utils.MetaCache: utils.OK,
- },
- }
-
- errExpect := "nil rpc in argument method: in: out"
- if err := rp.RemoveDispatcherProfile(context.Background(), args, &reply); !strings.Contains(err.Error(), errExpect) {
- t.Errorf("Expected error to include %v", errExpect)
- }
-}
-
-func TestReplicatorRemoveDispatcherHost(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- v1 := &AdminSv1{
- cfg: cfg,
- dm: dm,
- connMgr: engine.NewConnManager(cfg),
- ping: struct{}{},
- }
- cfg.AdminSCfg().CachesConns = []string{"*internal"}
- var reply string
- rp := NewReplicatorSv1(dm, v1)
- dspH := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "DSH1",
- Address: "*internal",
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- }
- if err := rp.dm.SetDispatcherHost(context.Background(), dspH); err != nil {
- t.Error(err)
- }
- args := &utils.TenantIDWithAPIOpts{
- TenantID: utils.NewTenantID("cgrates.org:DSH1"),
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaNone,
- },
- }
- err := rp.RemoveDispatcherHost(context.Background(), args, &reply)
- if err != nil {
- t.Error(err)
- }
- if reply != utils.OK {
- t.Errorf("Expected %v\n but received %v", utils.OK, reply)
- }
-}
-
-func TestReplicatorRemoveDispatcherHostErr(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- v1 := &AdminSv1{
- cfg: cfg,
- dm: dm,
- connMgr: engine.NewConnManager(cfg),
- ping: struct{}{},
- }
- cfg.AdminSCfg().CachesConns = []string{"*internal"}
- var reply string
- rp := NewReplicatorSv1(dm, v1)
- dspH := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "DSH1",
- Address: "*internal",
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- }
- if err := rp.dm.SetDispatcherHost(context.Background(), dspH); err != nil {
- t.Error(err)
- }
- args := &utils.TenantIDWithAPIOpts{
- TenantID: utils.NewTenantID("cgrates.org:DSH1"),
- APIOpts: map[string]any{
- utils.MetaCache: utils.OK,
- },
- }
-
- errExpect := "nil rpc in argument method: in: out"
- if err := rp.RemoveDispatcherHost(context.Background(), args, &reply); !strings.Contains(err.Error(), errExpect) {
- t.Errorf("Expected error to include %v", errExpect)
- }
-}
-
func TestReplicatorGetRateProfile(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
diff --git a/apis/tpes_it_test.go b/apis/tpes_it_test.go
index 78b188f4f..a471d1a8c 100644
--- a/apis/tpes_it_test.go
+++ b/apis/tpes_it_test.go
@@ -61,8 +61,6 @@ var (
testTPeSetStatQueueProfile,
testTPeSetActions,
testTPeSetThresholds,
- testTPeSetDispatcherProfiles,
- testSeTPeSetDispatcherHosts,
testTPeSExportTariffPlanHalfTariffPlan,
testTPeSExportTariffPlanAllTariffPlan,
// export again after we will flush the database
@@ -978,122 +976,22 @@ func testTPeSetThresholds(t *testing.T) {
}
}
-func testTPeSetDispatcherProfiles(t *testing.T) {
- dspPrf := &DispatcherWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: "false",
- },
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203"},
- Blocker: false,
- },
- },
- },
- }
-
- var result string
- if err := tpeSRPC.Call(context.Background(), utils.AdminSv1SetDispatcherProfile, dspPrf, &result); err != nil {
- t.Fatal(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-
- dspPrf2 := &DispatcherWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp2",
- FilterIDs: []string{"*string:~*opts.EventType:LoadDispatcher"},
- Strategy: utils.MetaWeight,
- Weight: 10,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "Conn2",
- FilterIDs: []string{"*suffix:~*opts.*answerTime:45T"},
- Params: map[string]any{utils.MetaRatio: 1},
- Blocker: false,
- },
- },
- },
- }
-
- if err := tpeSRPC.Call(context.Background(), utils.AdminSv1SetDispatcherProfile, dspPrf2, &result); err != nil {
- t.Fatal(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-}
-
-func testSeTPeSetDispatcherHosts(t *testing.T) {
- dspPrf := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "DSH1",
- Address: "*internal",
- ConnectAttempts: 1,
- Reconnects: 3,
- MaxReconnectInterval: 5 * time.Minute,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- },
- }
- var result string
- if err := tpeSRPC.Call(context.Background(), utils.AdminSv1SetDispatcherHost, dspPrf, &result); err != nil {
- t.Fatal(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-
- dspPrf2 := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "DSH2",
- Address: "127.0.0.1:6012",
- Transport: utils.MetaJSON,
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- },
- }
- if err := tpeSRPC.Call(context.Background(), utils.AdminSv1SetDispatcherHost, dspPrf2, &result); err != nil {
- t.Fatal(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-}
-
func testTPeSExportTariffPlanHalfTariffPlan(t *testing.T) {
var replyBts []byte
// we will get only the wantes tariff plans in the csv format
if err := tpeSRPC.Call(context.Background(), utils.TPeSv1ExportTariffPlan, &tpes.ArgsExportTP{
Tenant: "cgrates.org",
ExportItems: map[string][]string{
- utils.MetaAttributes: {"TEST_ATTRIBUTES_IT_TEST"},
- utils.MetaResources: {"ResGroup1"},
- utils.MetaFilters: {"fltr_for_prf"},
- utils.MetaRates: {"MultipleRates"},
- utils.MetaChargers: {"Chargers1"},
- utils.MetaRoutes: {"ROUTE_2003"},
- utils.MetaAccounts: {"Account_balances"},
- utils.MetaStats: {"SQ_basic"},
- utils.MetaActions: {"Execute_thd"},
- utils.MetaThresholds: {"TH_Stats1"},
- utils.MetaDispatchers: {"Dsp1"},
- utils.MetaDispatcherHosts: {"DSH1"},
+ utils.MetaAttributes: {"TEST_ATTRIBUTES_IT_TEST"},
+ utils.MetaResources: {"ResGroup1"},
+ utils.MetaFilters: {"fltr_for_prf"},
+ utils.MetaRates: {"MultipleRates"},
+ utils.MetaChargers: {"Chargers1"},
+ utils.MetaRoutes: {"ROUTE_2003"},
+ utils.MetaAccounts: {"Account_balances"},
+ utils.MetaStats: {"SQ_basic"},
+ utils.MetaActions: {"Execute_thd"},
+ utils.MetaThresholds: {"TH_Stats1"},
},
}, &replyBts); err != nil {
t.Error(err)
@@ -1179,14 +1077,6 @@ func testTPeSExportTariffPlanHalfTariffPlan(t *testing.T) {
{"cgrates.org", "TH_Stats1", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z|2014-07-14T14:36:00Z", "", "0", "0", "", "false", "", "false"},
{"cgrates.org", "TH_Stats1", "*string:~*req.Destination:1011", "", "0", "0", "", "false", "", "false"},
},
- utils.DispatcherProfilesCsv: {
- {"#Tenant", "ID", "FilterIDs", "Weight", "Strategy", "StrategyParameters", "ConnID", "ConnFilterIDs", "ConnWeight", "ConnBlocker", "ConnParameters"},
- {"cgrates.org", "Dsp1", "*string:~*req.Account:1001;*ai:~*req.AnswerTime:2014-07-14T14:25:00Z", "20", "*first", "false", "C1", "", "10", "false", "192.168.54.203"},
- },
- utils.DispatcherHostsCsv: {
- {"#Tenant", "ID", "Address", "Transport", "ConnectAttempts", "Reconnects", "MaxReconnectInterval", "ConnectTimeout", "ReplyTimeout", "Tls", "ClientKey", "ClientCertificate", "CaCertificate"},
- {"cgrates.org", "DSH1", "*internal", "", "1", "3", "5m0s", "1m0s", "2m0s", "false", "", "", ""},
- },
}
// we do this copy of the value one xpected because there are some values in a slice that are hard to concatenate as sorted
expected[utils.RatesCsv] = csvRply[utils.RatesCsv]
@@ -1203,18 +1093,16 @@ func testTPeSExportTariffPlanAllTariffPlan(t *testing.T) {
if err := tpeSRPC.Call(context.Background(), utils.TPeSv1ExportTariffPlan, &tpes.ArgsExportTP{
Tenant: "cgrates.org",
ExportItems: map[string][]string{
- utils.MetaAttributes: {"TEST_ATTRIBUTES_IT_TEST", "TEST_ATTRIBUTES_IT_TEST_SECOND"},
- utils.MetaResources: {"ResGroup1", "ResGroup2"},
- utils.MetaFilters: {"fltr_for_prf", "fltr_changed2"},
- utils.MetaRates: {"MultipleRates", "TEST_RATE_IT_TEST"},
- utils.MetaChargers: {"Chargers1", "DifferentCharger"},
- utils.MetaRoutes: {"ROUTE_2003", "ROUTE_ACNT_1001"},
- utils.MetaAccounts: {"Account_balances", "Account_simple"},
- utils.MetaStats: {"SQ_basic", "SQ_2"},
- utils.MetaActions: {"Execute_thd", "SET_BAL"},
- utils.MetaThresholds: {"TH_Stats1", "THD_2"},
- utils.MetaDispatchers: {"Dsp1", "Dsp2"},
- utils.MetaDispatcherHosts: {"DSH1", "DSH2"},
+ utils.MetaAttributes: {"TEST_ATTRIBUTES_IT_TEST", "TEST_ATTRIBUTES_IT_TEST_SECOND"},
+ utils.MetaResources: {"ResGroup1", "ResGroup2"},
+ utils.MetaFilters: {"fltr_for_prf", "fltr_changed2"},
+ utils.MetaRates: {"MultipleRates", "TEST_RATE_IT_TEST"},
+ utils.MetaChargers: {"Chargers1", "DifferentCharger"},
+ utils.MetaRoutes: {"ROUTE_2003", "ROUTE_ACNT_1001"},
+ utils.MetaAccounts: {"Account_balances", "Account_simple"},
+ utils.MetaStats: {"SQ_basic", "SQ_2"},
+ utils.MetaActions: {"Execute_thd", "SET_BAL"},
+ utils.MetaThresholds: {"TH_Stats1", "THD_2"},
},
}, &replyBts); err != nil {
t.Error(err)
@@ -1319,16 +1207,6 @@ func testTPeSExportTariffPlanAllTariffPlan(t *testing.T) {
{"cgrates.org", "TH_Stats1", "*string:~*req.Destination:1011", "", "0", "0", "", "false", "", "false"},
{"cgrates.org", "THD_2", "*string:~*req.Account:1001", ";20", "7", "0", "", "false", "actPrfID", "true"},
},
- utils.DispatcherProfilesCsv: {
- {"#Tenant", "ID", "FilterIDs", "Weight", "Strategy", "StrategyParameters", "ConnID", "ConnFilterIDs", "ConnWeight", "ConnBlocker", "ConnParameters"},
- {"cgrates.org", "Dsp1", "*string:~*req.Account:1001;*ai:~*req.AnswerTime:2014-07-14T14:25:00Z", "20", "*first", "false", "C1", "", "10", "false", "192.168.54.203"},
- {"cgrates.org", "Dsp2", "*string:~*opts.EventType:LoadDispatcher", "10", "*weight", "", "Conn2", "*suffix:~*opts.*answerTime:45T", "0", "false", "*ratio:1"},
- },
- utils.DispatcherHostsCsv: {
- {"#Tenant", "ID", "Address", "Transport", "ConnectAttempts", "Reconnects", "MaxReconnectInterval", "ConnectTimeout", "ReplyTimeout", "Tls", "ClientKey", "ClientCertificate", "CaCertificate"},
- {"cgrates.org", "DSH1", "*internal", "", "1", "3", "5m0s", "1m0s", "2m0s", "false", "", "", ""},
- {"cgrates.org", "DSH2", "127.0.0.1:6012", "*json", "1", "3", "0s", "1m0s", "2m0s", "false", "", "", ""},
- },
}
expected[utils.RatesCsv] = csvRply[utils.RatesCsv]
expected[utils.AccountsCsv] = csvRply[utils.AccountsCsv]
diff --git a/cmd/cgr-console/cgr-console_it_test.go b/cmd/cgr-console/cgr-console_it_test.go
index 1e195bab9..0d6ae192b 100644
--- a/cmd/cgr-console/cgr-console_it_test.go
+++ b/cmd/cgr-console/cgr-console_it_test.go
@@ -771,30 +771,6 @@ func testConsoleItCacheStats(t *testing.T) {
"Items": 0.,
"Groups": 0.,
},
- "*dispatcher_filter_indexes": map[string]any{
- "Items": 0.,
- "Groups": 0.,
- },
- "*dispatcher_hosts": map[string]any{
- "Items": 0.,
- "Groups": 0.,
- },
- "*dispatcher_loads": map[string]any{
- "Items": 0.,
- "Groups": 0.,
- },
- "*dispatcher_profiles": map[string]any{
- "Items": 0.,
- "Groups": 0.,
- },
- "*dispatcher_routes": map[string]any{
- "Items": 0.,
- "Groups": 0.,
- },
- "*dispatchers": map[string]any{
- "Items": 0.,
- "Groups": 0.,
- },
"*event_charges": map[string]any{
"Items": 0.,
"Groups": 0.,
@@ -907,14 +883,6 @@ func testConsoleItCacheStats(t *testing.T) {
"Items": 0.,
"Groups": 0.,
},
- "*tp_dispatcher_hosts": map[string]any{
- "Items": 0.,
- "Groups": 0.,
- },
- "*tp_dispatcher_profiles": map[string]any{
- "Items": 0.,
- "Groups": 0.,
- },
"*tp_filters": map[string]any{
"Items": 0.,
"Groups": 0.,
diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go
index dda7ff30b..55a42fee3 100644
--- a/cmd/cgr-engine/cgr-engine.go
+++ b/cmd/cgr-engine/cgr-engine.go
@@ -142,7 +142,6 @@ func runCGREngine(fs []string) (err error) {
coreS,
services.NewCacheService(cfg),
services.NewFilterService(cfg),
- services.NewDispatcherService(cfg),
services.NewLoaderService(cfg),
services.NewExportFailoverService(cfg),
services.NewAdminSv1Service(cfg),
@@ -272,20 +271,11 @@ func cgrInitServiceManagerV1(cfg *config.CGRConfig, srvMngr *servmanager.Service
cl := srvDeps[utils.CommonListenerS].(*services.CommonListenerService).CLS()
cms := srvDeps[utils.ConnManager].(*services.ConnManagerService)
srv, _ := birpc.NewService(apis.NewServiceManagerV1(srvMngr), utils.EmptyString, false)
- if !cfg.DispatcherSCfg().Enabled {
- cl.RpcRegister(srv)
- }
+ cl.RpcRegister(srv)
cms.AddInternalConn(utils.ServiceManager, srv)
}
func cgrStartRPC(cfg *config.CGRConfig, registry *servmanager.ServiceRegistry, shutdown *utils.SyncedChan) {
- if cfg.DispatcherSCfg().Enabled { // wait only for dispatcher as cache is allways registered before this
- if utils.StructChanTimeout(
- registry.Lookup(utils.DispatcherS).StateChan(utils.StateServiceUP),
- cfg.GeneralCfg().ConnectTimeout) {
- return
- }
- }
cl := registry.Lookup(utils.CommonListenerS).(*services.CommonListenerService).CLS()
cl.StartServer(cfg, shutdown)
}
diff --git a/config/apis.go b/config/apis.go
index 1c7789632..6b129fa28 100644
--- a/config/apis.go
+++ b/config/apis.go
@@ -536,12 +536,6 @@ func storeDiffSection(ctx *context.Context, section string, db ConfigDB, v1, v2
return
}
return db.SetSection(ctx, section, diffSureTaxJsonCfg(jsn, v1.SureTaxCfg(), v2.SureTaxCfg(), v2.GeneralCfg().RSRSep))
- case DispatcherSJSON:
- jsn := new(DispatcherSJsonCfg)
- if err = db.GetSection(ctx, section, jsn); err != nil {
- return
- }
- return db.SetSection(ctx, section, diffDispatcherSJsonCfg(jsn, v1.DispatcherSCfg(), v2.DispatcherSCfg()))
case RegistrarCJSON:
jsn := new(RegistrarCJsonCfgs)
if err = db.GetSection(ctx, section, jsn); err != nil {
diff --git a/config/apis_test.go b/config/apis_test.go
index febfce673..ae599767e 100644
--- a/config/apis_test.go
+++ b/config/apis_test.go
@@ -711,20 +711,6 @@ func TestStoreDiffSectionSureTax(t *testing.T) {
}
}
-func TestStoreDiffSectionDispatcherS(t *testing.T) {
- section := DispatcherSJSON
-
- cgrCfgV1 := NewDefaultCGRConfig()
- cgrCfgV1.dispatcherSCfg = &DispatcherSCfg{}
-
- cgrCfgV2 := NewDefaultCGRConfig()
- cgrCfgV2.dispatcherSCfg = &DispatcherSCfg{}
-
- if err := storeDiffSection(context.Background(), section, new(mockDb), cgrCfgV1, cgrCfgV2); err != utils.ErrNotImplemented || err == nil {
- t.Error(err)
- }
-}
-
func TestStoreDiffSectionRegistrarC(t *testing.T) {
section := RegistrarCJSON
diff --git a/config/cachecfg_test.go b/config/cachecfg_test.go
index 20c98ec1c..59478918a 100644
--- a/config/cachecfg_test.go
+++ b/config/cachecfg_test.go
@@ -50,40 +50,6 @@ func TestAsTransCacheConfig(t *testing.T) {
}
}
-func TestCacheCfgloadFromJsonCfg(t *testing.T) {
- jsonCfg := &CacheJsonCfg{
- Partitions: map[string]*CacheParamJsonCfg{
- utils.MetaDispatchers: {
- Limit: utils.IntPointer(10),
- Ttl: utils.StringPointer("2"),
- Static_ttl: utils.BoolPointer(true),
- Precache: utils.BoolPointer(true),
- Replicate: utils.BoolPointer(true),
- },
- },
- Replication_conns: &[]string{"conn1", "conn2"},
- }
- expected := &CacheCfg{
- Partitions: map[string]*CacheParamCfg{
- utils.MetaDispatchers: {Limit: 10, TTL: 2, StaticTTL: true, Precache: true, Replicate: true},
- },
- ReplicationConns: []string{"conn1", "conn2"},
- }
- jsnCfg := NewDefaultCGRConfig()
- if err := jsnCfg.cacheCfg.loadFromJSONCfg(nil); err != nil {
- t.Error(err)
- } else if err := jsnCfg.cacheCfg.loadFromJSONCfg(jsonCfg); err != nil {
- t.Error(err)
- } else {
- if !reflect.DeepEqual(expected.Partitions[utils.MetaDispatchers], jsnCfg.cacheCfg.Partitions[utils.MetaDispatchers]) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected.Partitions[utils.MetaDispatchers]),
- utils.ToJSON(jsnCfg.cacheCfg.Partitions[utils.MetaDispatchers]))
- } else if !reflect.DeepEqual(jsnCfg.cacheCfg.ReplicationConns, expected.ReplicationConns) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected.ReplicationConns), utils.ToJSON(jsnCfg.cacheCfg.ReplicationConns))
- }
- }
-}
-
func TestReplicationConnsLoadFromJsonCfg(t *testing.T) {
jsonCfg := &CacheJsonCfg{
Replication_conns: &[]string{utils.MetaInternal},
@@ -121,7 +87,7 @@ func TestCacheParamCfgloadFromJsonCfg1(t *testing.T) {
func TestCacheParamCfgloadFromJsonCfg2(t *testing.T) {
jsonCfg := &CacheJsonCfg{
Partitions: map[string]*CacheParamJsonCfg{
- utils.MetaDispatchers: {
+ utils.MetaAttributes: {
Ttl: utils.StringPointer("1ss"),
},
},
@@ -133,46 +99,15 @@ func TestCacheParamCfgloadFromJsonCfg2(t *testing.T) {
}
}
-func TestCachesCfgAsMapInterface1(t *testing.T) {
- cfgJSONStr := `{
- "caches":{
- "partitions": {
- "*dispatchers": {"limit": -1, "ttl": "", "static_ttl": false, "precache": true, "remote":false, "replicate": true},
- },
- },
- }`
- eMap := map[string]any{
- utils.PartitionsCfg: map[string]any{
- utils.MetaDispatchers: map[string]any{"limit": -1, "static_ttl": false, "precache": true, "remote": false, "replicate": true},
- },
- utils.ReplicationConnsCfg: []string{},
- }
- if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
- t.Error(err)
- } else {
- newMap := cgrCfg.cacheCfg.AsMapInterface("").(map[string]any)
- if !reflect.DeepEqual(newMap[utils.PartitionsCfg].(map[string]any)[utils.MetaDispatchers],
- eMap[utils.PartitionsCfg].(map[string]any)[utils.MetaDispatchers]) {
- t.Errorf("Expected %+v, received %+v", eMap[utils.PartitionsCfg].(map[string]any)[utils.MetaDispatchers],
- newMap[utils.PartitionsCfg].(map[string]any)[utils.MetaDispatchers])
- }
- }
-}
-
func TestCacheCfgClone(t *testing.T) {
cs := &CacheCfg{
- Partitions: map[string]*CacheParamCfg{
- utils.MetaDispatchers: {Limit: 10, TTL: 2, StaticTTL: true, Precache: true, Replicate: true},
- },
+ Partitions: map[string]*CacheParamCfg{},
ReplicationConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaSessionS)},
}
rcv := cs.Clone()
if !reflect.DeepEqual(cs, rcv) {
t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(cs), utils.ToJSON(rcv))
}
- if rcv.Partitions[utils.MetaDispatchers].Limit = 0; cs.Partitions[utils.MetaDispatchers].Limit != 10 {
- t.Errorf("Expected clone to not modify the cloned")
- }
if rcv.ReplicationConns[0] = ""; cs.ReplicationConns[0] != utils.ConcatenatedKey(utils.MetaInternal, utils.MetaSessionS) {
t.Errorf("Expected clone to not modify the cloned")
}
diff --git a/config/config.go b/config/config.go
index 3259a51fb..7355156bd 100644
--- a/config/config.go
+++ b/config/config.go
@@ -222,12 +222,8 @@ func newCGRConfig(config []byte) (cfg *CGRConfig, err error) {
}},
tpeSCfg: new(TpeSCfg),
sureTaxCfg: new(SureTaxCfg),
- dispatcherSCfg: &DispatcherSCfg{Opts: &DispatchersOpts{
- Dispatchers: []*DynamicBoolOpt{},
- }},
registrarCCfg: &RegistrarCCfgs{
- RPC: &RegistrarCCfg{Hosts: make(map[string][]*RemoteHost)},
- Dispatchers: &RegistrarCCfg{Hosts: make(map[string][]*RemoteHost)},
+ RPC: &RegistrarCCfg{Hosts: make(map[string][]*RemoteHost)},
},
loaderCgrCfg: new(LoaderCgrCfg),
migratorCgrCfg: &MigratorCgrCfg{
@@ -363,7 +359,6 @@ type CGRConfig struct {
trendSCfg *TrendSCfg // TrendS config
rankingSCfg *RankingSCfg // RankingS config
sureTaxCfg *SureTaxCfg // SureTax config
- dispatcherSCfg *DispatcherSCfg // DispatcherS config
registrarCCfg *RegistrarCCfgs // RegistrarC config
loaderCgrCfg *LoaderCgrCfg // LoaderCgr config
migratorCgrCfg *MigratorCgrCfg // MigratorCgr config
@@ -390,7 +385,7 @@ type CGRConfig struct {
var posibleLoaderTypes = utils.NewStringSet([]string{utils.MetaAttributes,
utils.MetaResources, utils.MetaFilters, utils.MetaStats, utils.MetaTrends,
utils.MetaRoutes, utils.MetaThresholds, utils.MetaChargers, utils.MetaRankings,
- utils.MetaDispatchers, utils.MetaDispatcherHosts, utils.MetaRateProfiles,
+ utils.MetaRateProfiles,
utils.MetaAccounts, utils.MetaActionProfiles})
var possibleReaderTypes = utils.NewStringSet([]string{utils.MetaFileCSV,
@@ -579,17 +574,10 @@ func (cfg *CGRConfig) LoaderCgrCfg() *LoaderCgrCfg {
return cfg.loaderCgrCfg
}
-// DispatcherSCfg returns the config for DispatcherS
-func (cfg *CGRConfig) DispatcherSCfg() *DispatcherSCfg {
- cfg.lks[DispatcherSJSON].Lock()
- defer cfg.lks[DispatcherSJSON].Unlock()
- return cfg.dispatcherSCfg
-}
-
// RegistrarCCfg returns the config for RegistrarC
func (cfg *CGRConfig) RegistrarCCfg() *RegistrarCCfgs {
- cfg.lks[DispatcherSJSON].Lock()
- defer cfg.lks[DispatcherSJSON].Unlock()
+ cfg.lks[RegistrarCJSON].Lock()
+ defer cfg.lks[RegistrarCJSON].Unlock()
return cfg.registrarCCfg
}
@@ -997,7 +985,7 @@ func (cfg *CGRConfig) reloadSections(sections ...string) {
subsystemsThatNeedDataDB := utils.NewStringSet([]string{DataDBJSON,
CDRsJSON, SessionSJSON, AttributeSJSON,
ChargerSJSON, ResourceSJSON, StatSJSON, ThresholdSJSON,
- RouteSJSON, LoaderSJSON, DispatcherSJSON, RateSJSON, AdminSJSON, AccountSJSON,
+ RouteSJSON, LoaderSJSON, RateSJSON, AdminSJSON, AccountSJSON,
ActionSJSON})
subsystemsThatNeedStorDB := utils.NewStringSet([]string{StorDBJSON, CDRsJSON})
needsDataDB := false
@@ -1067,7 +1055,6 @@ func (cfg *CGRConfig) Clone() (cln *CGRConfig) {
rankingSCfg: cfg.rankingSCfg.Clone(),
routeSCfg: cfg.routeSCfg.Clone(),
sureTaxCfg: cfg.sureTaxCfg.Clone(),
- dispatcherSCfg: cfg.dispatcherSCfg.Clone(),
registrarCCfg: cfg.registrarCCfg.Clone(),
loaderCgrCfg: cfg.loaderCgrCfg.Clone(),
migratorCgrCfg: cfg.migratorCgrCfg.Clone(),
diff --git a/config/config_defaults.go b/config/config_defaults.go
index d33d8db6d..ac759e6c2 100644
--- a/config/config_defaults.go
+++ b/config/config_defaults.go
@@ -132,8 +132,6 @@ const CGRATES_CFG_JSON = `
"*route_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate":false},
"*attribute_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate":false},
"*charger_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate":false},
- "*dispatcher_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate":false},
- "*dispatcher_hosts": {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate":false},
"*rate_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate":false},
"*action_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate":false},
"*load_ids": {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate":false},
@@ -148,7 +146,6 @@ const CGRATES_CFG_JSON = `
"*route_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false},
"*attribute_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false},
"*charger_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false},
- "*dispatcher_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false},
"*rate_profile_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false},
"*rate_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false},
"*action_profile_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false},
@@ -270,8 +267,6 @@ const CGRATES_CFG_JSON = `
"*route_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "remote":false, "replicate": false}, // control route profile caching
"*attribute_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "remote":false, "replicate": false}, // control attribute profile caching
"*charger_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "remote":false, "replicate": false}, // control charger profile caching
- "*dispatcher_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "remote":false, "replicate": false}, // control dispatcher profile caching
- "*dispatcher_hosts": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "remote":false, "replicate": false}, // control dispatcher hosts caching
"*rate_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "remote":false, "replicate": false}, // control rate profile caching
"*action_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "remote":false, "replicate": false}, // control action profile caching
"*accounts": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "remote":false, "replicate": false}, // control account profile caching
@@ -283,15 +278,11 @@ const CGRATES_CFG_JSON = `
"*ranking_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "remote":false, "replicate": false}, // control ranking profile caching
"*rankings": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "remote":false, "replicate": false}, // control rankings caching
"*charger_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false}, // control charger filter indexes caching
- "*dispatcher_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false}, // control dispatcher filter indexes caching
"*rate_profile_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false}, // control rate profile filter indexes caching
"*rate_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false}, // control rate filter indexes caching
"*action_profile_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false}, // control action profile filter indexes caching
"*account_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false}, // control coount profile filter indexes caching
"*reverse_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false}, // control reverse filter indexes caching used only for set and remove filters
- "*dispatcher_routes": {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false}, // control dispatcher routes caching
- "*dispatcher_loads": {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false}, // control dispatcher load( in case of *ratio ConnParams is present)
- "*dispatchers": {"limit": -1, "ttl": "", "static_ttl": false, "remote":false, "replicate": false}, // control dispatcher interface
"*diameter_messages": {"limit": -1, "ttl": "3h", "static_ttl": false, "remote":false, "replicate": false}, // diameter messages caching
"*rpc_responses": {"limit": 0, "ttl": "2s", "static_ttl": false, "remote":false, "replicate": false}, // RPC responses caching
"*closed_sessions": {"limit": -1, "ttl": "10s", "static_ttl": false, "remote":false, "replicate": false}, // closed sessions cached for CDRs
@@ -1312,8 +1303,6 @@ const CGRATES_CFG_JSON = `
"*thresholds":{"limit": -1, "ttl": "5s", "static_ttl": false},
"*routes":{"limit": -1, "ttl": "5s", "static_ttl": false},
"*chargers":{"limit": -1, "ttl": "5s", "static_ttl": false},
- "*dispatchers":{"limit": -1, "ttl": "5s", "static_ttl": false},
- "*dispatcher_hosts":{"limit": -1, "ttl": "5s", "static_ttl": false},
"*rate_profiles":{"limit": -1, "ttl": "5s", "static_ttl": false},
"*action_profiles":{"limit": -1, "ttl": "5s", "static_ttl": false},
"*accounts":{"limit": -1, "ttl": "5s", "static_ttl": false},
@@ -1467,42 +1456,6 @@ const CGRATES_CFG_JSON = `
{"tag": "AttributeIDs", "path": "AttributeIDs", "type": "*variable", "value": "~*req.6"}
]
},
- {
- "type": "*dispatchers", // data source type
- "file_name": "DispatcherProfiles.csv", // file name in the tp_in_dir
- "fields": [
- {"tag": "Tenant", "path": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
- {"tag": "ID", "path": "ID", "type": "*variable", "value": "~*req.1", "mandatory": true},
- {"tag": "FilterIDs", "path": "FilterIDs", "type": "*variable", "value": "~*req.2"},
- {"tag": "Weight", "path": "Weight", "type": "*variable", "value": "~*req.3"},
- {"tag": "Strategy", "path": "Strategy", "type": "*variable", "value": "~*req.4"},
- {"tag": "StrategyParameters", "path": "StrategyParams", "type": "*variable", "value": "~*req.5"},
- {"tag": "ConnID", "path": "Hosts.ID", "type": "*variable", "value": "~*req.6","new_branch":true},
- {"tag": "ConnFilterIDs", "path": "Hosts.FilterIDs", "type": "*variable", "value": "~*req.7"},
- {"tag": "ConnWeight", "path": "Hosts.Weight", "type": "*variable", "value": "~*req.8"},
- {"tag": "ConnBlocker", "path": "Hosts.Blocker", "type": "*variable", "value": "~*req.9"},
- {"tag": "ConnParameters", "path": "Hosts.Params", "type": "*variable", "value": "~*req.10"}
- ]
- },
- {
- "type": "*dispatcher_hosts", // data source type
- "file_name": "DispatcherHosts.csv", // file name in the tp_in_dir
- "fields": [
- {"tag": "Tenant", "path": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
- {"tag": "ID", "path": "ID", "type": "*variable", "value": "~*req.1", "mandatory": true},
- {"tag": "Address", "path": "Address", "type": "*variable", "value": "~*req.2"},
- {"tag": "Transport", "path": "Transport", "type": "*variable", "value": "~*req.3"},
- {"tag": "ConnectAttempts", "path": "ConnectAttempts", "type": "*variable", "value":"~*req.4"},
- {"tag": "Reconnects", "path": "Reconnects", "type": "*variable", "value":"~*req.5"},
- {"tag": "MaxReconnectInterval", "path": "MaxReconnectInterval", "type": "*variable", "value":"~*req.6"},
- {"tag": "ConnectTimeout", "path": "ConnectTimeout", "type": "*variable", "value":"~*req.7"},
- {"tag": "ReplyTimeout", "path": "ReplyTimeout", "type": "*variable", "value":"~*req.8"},
- {"tag": "TLS", "path": "TLS", "type": "*variable", "value": "~*req.9"},
- {"tag": "ClientKey", "path": "ClientKey", "type": "*variable", "value":"~*req.10"},
- {"tag": "ClientCertificate", "path": "ClientCertificate", "type": "*variable", "value":"~*req.11"},
- {"tag": "CaCertificate", "path": "CaCertificate", "type": "*variable", "value":"~*req.12"}
- ]
- },
{
"type": "*rate_profiles", // data source type
"file_name": "Rates.csv", // file name in the tp_in_dir
@@ -1649,40 +1602,12 @@ const CGRATES_CFG_JSON = `
},
-"dispatchers":{
- "enabled": false, // starts DispatcherS service: .
- "indexed_selects": true, // enable profile matching exclusively on indexes
- //"string_indexed_fields": [], // query indexes based on these fields for faster processing
- "prefix_indexed_fields": [], // query indexes based on these fields for faster processing
- "suffix_indexed_fields": [], // query indexes based on these fields for faster processing
- "exists_indexed_fields": [], // query indexes based on these fields for faster processing
- "notexists_indexed_fields": [], // query indexes based on these fields for faster processing
- "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level)
- "attributes_conns": [], // connections to AttributeS for API authorization, empty to disable auth functionality: <""|*internal|$rpc_conns_id>
- "opts": {
- // "*dispatchers": [
- // {
- // "Tenant": "*any",
- // "FilterIDs": [],
- // "Value": false,
- // },
- // ],
- },
-},
-
-
"registrarc":{
"rpc":{
"enabled": false,
"registrars_conns": [],
"hosts": [],
"refresh_interval": "5m"
- },
- "dispatchers":{
- "enabled": false,
- "registrars_conns": [],
- "hosts": [],
- "refresh_interval": "5m"
}
},
diff --git a/config/config_json.go b/config/config_json.go
index 483de11a3..e2f8f6920 100644
--- a/config/config_json.go
+++ b/config/config_json.go
@@ -54,7 +54,6 @@ const (
RouteSJSON = "routes"
LoaderSJSON = "loaders"
SureTaxJSON = "suretax"
- DispatcherSJSON = "dispatchers"
RegistrarCJSON = "registrarc"
LoaderJSON = "loader"
MigratorJSON = "migrator"
@@ -102,7 +101,6 @@ var (
HTTPAgentJSON: utils.HTTPAgent,
LoaderSJSON: utils.LoaderS,
AnalyzerSJSON: utils.AnalyzerS,
- DispatcherSJSON: utils.DispatcherS,
DataDBJSON: utils.DataDB,
StorDBJSON: utils.StorDB,
EEsJSON: utils.EEs,
@@ -199,7 +197,6 @@ func newSections(cfg *CGRConfig) Sections {
cfg.dnsAgentCfg,
cfg.sipAgentCfg,
cfg.migratorCgrCfg,
- cfg.dispatcherSCfg,
cfg.registrarCCfg,
cfg.analyzerSCfg,
cfg.admS,
diff --git a/config/config_json_test.go b/config/config_json_test.go
index 91d0a9c6f..8ddd07db7 100644
--- a/config/config_json_test.go
+++ b/config/config_json_test.go
@@ -131,9 +131,6 @@ func TestCacheJsonCfg(t *testing.T) {
utils.CacheChargerProfiles: {Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
Precache: utils.BoolPointer(false), Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
- utils.CacheDispatcherProfiles: {Limit: utils.IntPointer(-1),
- Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
- Precache: utils.BoolPointer(false), Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
utils.CacheRateProfiles: {Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
Precache: utils.BoolPointer(false), Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
@@ -143,9 +140,6 @@ func TestCacheJsonCfg(t *testing.T) {
utils.CacheAccounts: {Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
Precache: utils.BoolPointer(false), Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
- utils.CacheDispatcherHosts: {Limit: utils.IntPointer(-1),
- Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
- Precache: utils.BoolPointer(false), Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
utils.CacheResourceFilterIndexes: {Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
@@ -164,9 +158,6 @@ func TestCacheJsonCfg(t *testing.T) {
utils.CacheChargerFilterIndexes: {Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
- utils.CacheDispatcherFilterIndexes: {Limit: utils.IntPointer(-1),
- Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
- Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
utils.CacheRateProfilesFilterIndexes: {Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
@@ -182,15 +173,6 @@ func TestCacheJsonCfg(t *testing.T) {
utils.CacheReverseFilterIndexes: {Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
- utils.CacheDispatcherRoutes: {Limit: utils.IntPointer(-1),
- Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
- Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
- utils.CacheDispatcherLoads: {Limit: utils.IntPointer(-1),
- Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
- Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
- utils.CacheDispatchers: {Limit: utils.IntPointer(-1),
- Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
- Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
utils.CacheDiameterMessages: {Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer("3h"), Static_ttl: utils.BoolPointer(false),
Remote: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)},
@@ -394,13 +376,6 @@ func TestDfDataDbJsonCfg(t *testing.T) {
Replicate: utils.BoolPointer(false),
Remote: utils.BoolPointer(false),
},
- utils.MetaDispatcherHosts: {
- Ttl: utils.StringPointer(utils.EmptyString),
- Static_ttl: utils.BoolPointer(false),
- Limit: utils.IntPointer(-1),
- Replicate: utils.BoolPointer(false),
- Remote: utils.BoolPointer(false),
- },
utils.MetaRateProfiles: {
Ttl: utils.StringPointer(utils.EmptyString),
Static_ttl: utils.BoolPointer(false),
@@ -422,13 +397,6 @@ func TestDfDataDbJsonCfg(t *testing.T) {
Replicate: utils.BoolPointer(false),
Remote: utils.BoolPointer(false),
},
- utils.MetaDispatcherProfiles: {
- Ttl: utils.StringPointer(utils.EmptyString),
- Static_ttl: utils.BoolPointer(false),
- Limit: utils.IntPointer(-1),
- Replicate: utils.BoolPointer(false),
- Remote: utils.BoolPointer(false),
- },
utils.MetaLoadIDs: {
Ttl: utils.StringPointer(utils.EmptyString),
Static_ttl: utils.BoolPointer(false),
@@ -478,13 +446,6 @@ func TestDfDataDbJsonCfg(t *testing.T) {
Replicate: utils.BoolPointer(false),
Remote: utils.BoolPointer(false),
},
- utils.CacheDispatcherFilterIndexes: {
- Ttl: utils.StringPointer(utils.EmptyString),
- Static_ttl: utils.BoolPointer(false),
- Limit: utils.IntPointer(-1),
- Replicate: utils.BoolPointer(false),
- Remote: utils.BoolPointer(false),
- },
utils.CacheRateProfilesFilterIndexes: {
Ttl: utils.StringPointer(utils.EmptyString),
Static_ttl: utils.BoolPointer(false),
@@ -1486,128 +1447,6 @@ func TestDfLoaderJsonCfg(t *testing.T) {
Value: utils.StringPointer("~*req.6")},
},
},
- {
- Type: utils.StringPointer(utils.MetaDispatchers),
- File_name: utils.StringPointer(utils.DispatcherProfilesCsv),
- Fields: &[]*FcTemplateJsonCfg{
- {Tag: utils.StringPointer(utils.Tenant),
- Path: utils.StringPointer(utils.Tenant),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.0"),
- Mandatory: utils.BoolPointer(true)},
- {Tag: utils.StringPointer(utils.ID),
- Path: utils.StringPointer(utils.ID),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.1"),
- Mandatory: utils.BoolPointer(true)},
- {Tag: utils.StringPointer("FilterIDs"),
- Path: utils.StringPointer("FilterIDs"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.2")},
- {Tag: utils.StringPointer("Weight"),
- Path: utils.StringPointer("Weight"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.3")},
- {Tag: utils.StringPointer("Strategy"),
- Path: utils.StringPointer("Strategy"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.4")},
- {Tag: utils.StringPointer("StrategyParameters"),
- Path: utils.StringPointer("StrategyParams"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.5")},
- {Tag: utils.StringPointer("ConnID"),
- Path: utils.StringPointer("Hosts.ID"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.6"),
- New_branch: utils.BoolPointer(true)},
- {Tag: utils.StringPointer("ConnFilterIDs"),
- Path: utils.StringPointer("Hosts.FilterIDs"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.7")},
- {Tag: utils.StringPointer("ConnWeight"),
- Path: utils.StringPointer("Hosts.Weight"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.8")},
- {Tag: utils.StringPointer("ConnBlocker"),
- Path: utils.StringPointer("Hosts.Blocker"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.9")},
- {Tag: utils.StringPointer("ConnParameters"),
- Path: utils.StringPointer("Hosts.Params"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.10")},
- },
- },
- {
- Type: utils.StringPointer(utils.MetaDispatcherHosts),
- File_name: utils.StringPointer(utils.DispatcherHostsCsv),
- Fields: &[]*FcTemplateJsonCfg{
- {Tag: utils.StringPointer(utils.Tenant),
- Path: utils.StringPointer(utils.Tenant),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.0"),
- Mandatory: utils.BoolPointer(true)},
- {Tag: utils.StringPointer(utils.ID),
- Path: utils.StringPointer(utils.ID),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.1"),
- Mandatory: utils.BoolPointer(true)},
- {Tag: utils.StringPointer("Address"),
- Path: utils.StringPointer("Address"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.2")},
- {Tag: utils.StringPointer("Transport"),
- Path: utils.StringPointer("Transport"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.3")},
- {Tag: utils.StringPointer("ConnectAttempts"),
- Path: utils.StringPointer("ConnectAttempts"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.4"),
- },
- {Tag: utils.StringPointer("Reconnects"),
- Path: utils.StringPointer("Reconnects"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.5"),
- },
- {Tag: utils.StringPointer("MaxReconnectInterval"),
- Path: utils.StringPointer("MaxReconnectInterval"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.6"),
- },
- {Tag: utils.StringPointer("ConnectTimeout"),
- Path: utils.StringPointer("ConnectTimeout"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.7"),
- },
- {Tag: utils.StringPointer("ReplyTimeout"),
- Path: utils.StringPointer("ReplyTimeout"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.8"),
- },
- {Tag: utils.StringPointer("TLS"),
- Path: utils.StringPointer("TLS"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.9"),
- },
- {Tag: utils.StringPointer("ClientKey"),
- Path: utils.StringPointer("ClientKey"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.10"),
- },
- {Tag: utils.StringPointer("ClientCertificate"),
- Path: utils.StringPointer("ClientCertificate"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.11"),
- },
- {Tag: utils.StringPointer("CaCertificate"),
- Path: utils.StringPointer("CaCertificate"),
- Type: utils.StringPointer(utils.MetaVariable),
- Value: utils.StringPointer("~*req.12"),
- },
- },
- },
{
Type: utils.StringPointer(utils.MetaRateProfiles),
File_name: utils.StringPointer(utils.RatesCsv),
@@ -1845,20 +1684,18 @@ func TestDfLoaderJsonCfg(t *testing.T) {
},
},
Cache: map[string]*CacheParamJsonCfg{
- utils.MetaFilters: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
- utils.MetaAttributes: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
- utils.MetaResources: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
- utils.MetaStats: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
- utils.MetaThresholds: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
- utils.MetaRoutes: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
- utils.MetaChargers: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
- utils.MetaDispatchers: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
- utils.MetaDispatcherHosts: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
- utils.MetaRateProfiles: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
- utils.MetaActionProfiles: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
- utils.MetaAccounts: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
- utils.MetaTrends: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
- utils.MetaRankings: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
+ utils.MetaFilters: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
+ utils.MetaAttributes: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
+ utils.MetaResources: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
+ utils.MetaStats: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
+ utils.MetaThresholds: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
+ utils.MetaRoutes: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
+ utils.MetaChargers: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
+ utils.MetaRateProfiles: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
+ utils.MetaActionProfiles: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
+ utils.MetaAccounts: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
+ utils.MetaTrends: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
+ utils.MetaRankings: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer("5s"), Static_ttl: utils.BoolPointer(false)},
},
},
}
@@ -1956,31 +1793,6 @@ func TestDfHttpJsonCfg(t *testing.T) {
}
}
-func TestDfDispatcherSJsonCfg(t *testing.T) {
- eCfg := &DispatcherSJsonCfg{
- Enabled: utils.BoolPointer(false),
- Indexed_selects: utils.BoolPointer(true),
- String_indexed_fields: nil,
- Prefix_indexed_fields: &[]string{},
- Suffix_indexed_fields: &[]string{},
- Exists_indexed_fields: &[]string{},
- Notexists_indexed_fields: &[]string{},
- Attributes_conns: &[]string{},
- Nested_fields: utils.BoolPointer(false),
- Opts: &DispatchersOptsJson{},
- }
- dfCgrJSONCfg, err := NewCgrJsonCfgFromBytes([]byte(CGRATES_CFG_JSON))
- if err != nil {
- t.Error(err)
- }
- cfg := new(DispatcherSJsonCfg)
- if err := dfCgrJSONCfg.GetSection(context.Background(), DispatcherSJSON, cfg); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eCfg, cfg) {
- t.Errorf("expecting: %+v, received: %+v", utils.ToJSON(eCfg), utils.ToJSON(cfg))
- }
-}
-
func TestDfLoaderCfg(t *testing.T) {
cred := json.RawMessage(`".gapi/credentials.json"`)
tok := json.RawMessage(`".gapi/token.json"`)
diff --git a/config/config_test.go b/config/config_test.go
index 68b025de9..c671f0fb8 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -447,9 +447,7 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) {
utils.CacheRouteProfiles: {Limit: -1},
utils.CacheAttributeProfiles: {Limit: -1},
utils.CacheChargerProfiles: {Limit: -1},
- utils.CacheDispatcherProfiles: {Limit: -1},
utils.CacheRateProfiles: {Limit: -1},
- utils.CacheDispatcherHosts: {Limit: -1},
utils.CacheActionProfiles: {Limit: -1},
utils.CacheAccounts: {Limit: -1},
utils.CacheResourceFilterIndexes: {Limit: -1},
@@ -458,7 +456,6 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) {
utils.CacheRouteFilterIndexes: {Limit: -1},
utils.CacheAttributeFilterIndexes: {Limit: -1},
utils.CacheChargerFilterIndexes: {Limit: -1},
- utils.CacheDispatcherFilterIndexes: {Limit: -1},
utils.CacheRateProfilesFilterIndexes: {Limit: -1},
utils.CacheRankingProfiles: {Limit: -1},
utils.CacheRankings: {Limit: -1},
@@ -466,9 +463,6 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) {
utils.CacheActionProfilesFilterIndexes: {Limit: -1},
utils.CacheAccountsFilterIndexes: {Limit: -1},
utils.CacheReverseFilterIndexes: {Limit: -1},
- utils.CacheDispatcherRoutes: {Limit: -1},
- utils.CacheDispatcherLoads: {Limit: -1},
- utils.CacheDispatchers: {Limit: -1},
utils.CacheDiameterMessages: {Limit: -1,
TTL: 3 * time.Hour},
utils.CacheRPCResponses: {Limit: 0,
@@ -1238,38 +1232,6 @@ func TestLoadSureTaxCfgError(t *testing.T) {
}
}
-func TestLoadDispatcherSCfgError(t *testing.T) {
- cfgJSONStr := `{
- "dispatchers":{
- "attributes_conns": "*internal",
- },
-}`
- expected := "json: cannot unmarshal string into Go struct field DispatcherSJsonCfg.Attributes_conns of type []string"
- cgrConfig := NewDefaultCGRConfig()
- if cgrCfgJSON, err := NewCgrJsonCfgFromBytes([]byte(cfgJSONStr)); err != nil {
- t.Error(err)
- } else if err := cgrConfig.dispatcherSCfg.Load(context.Background(), cgrCfgJSON, cgrCfg); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-}
-
-func TestLoadDispatcherHCfgError(t *testing.T) {
- cfgJSONStr := `{
- "registrarc":{
- "dispatchers":{
- "refresh_interval": 5,
- },
- },
-}`
- expected := "json: cannot unmarshal number into Go struct field RegistrarCJsonCfg.Dispatchers.Refresh_interval of type string"
- cgrConfig := NewDefaultCGRConfig()
- if cgrCfgJSON, err := NewCgrJsonCfgFromBytes([]byte(cfgJSONStr)); err != nil {
- t.Error(err)
- } else if err := cgrConfig.registrarCCfg.Load(context.Background(), cgrCfgJSON, cgrCfg); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-}
-
func TestLoadLoaderCgrCfgError(t *testing.T) {
cfgJSONStr := `{
"loader": {
@@ -1919,20 +1881,18 @@ func TestLoaderConfig(t *testing.T) {
WithIndex: true,
},
Cache: map[string]*CacheParamCfg{
- utils.MetaFilters: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaAttributes: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaResources: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaStats: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaThresholds: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaRoutes: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaChargers: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaDispatchers: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaDispatcherHosts: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaRateProfiles: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaActionProfiles: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaAccounts: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaRankings: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaTrends: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaFilters: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaAttributes: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaResources: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaStats: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaThresholds: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaRoutes: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaChargers: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaRateProfiles: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaActionProfiles: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaAccounts: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaRankings: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaTrends: {Limit: -1, TTL: 5 * time.Second},
},
},
}
@@ -1944,27 +1904,6 @@ func TestLoaderConfig(t *testing.T) {
}
}
-func TestDispatcherSConfig(t *testing.T) {
- expected := &DispatcherSCfg{
- Enabled: false,
- IndexedSelects: true,
- PrefixIndexedFields: &[]string{},
- SuffixIndexedFields: &[]string{},
- ExistsIndexedFields: &[]string{},
- NotExistsIndexedFields: &[]string{},
- AttributeSConns: []string{},
- NestedFields: false,
- Opts: &DispatchersOpts{
- []*DynamicBoolOpt{},
- },
- }
- cgrConfig := NewDefaultCGRConfig()
- newConfig := cgrConfig.DispatcherSCfg()
- if !reflect.DeepEqual(expected, newConfig) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(newConfig))
- }
-}
-
func TestAnalyzerConfig(t *testing.T) {
expected := &AnalyzerSCfg{
Enabled: false,
@@ -2294,20 +2233,18 @@ func TestCgrLoaderCfgITDefaults(t *testing.T) {
WithIndex: true,
},
Cache: map[string]*CacheParamCfg{
- utils.MetaFilters: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaAttributes: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaResources: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaStats: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaThresholds: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaRoutes: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaChargers: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaDispatchers: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaDispatcherHosts: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaRateProfiles: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaActionProfiles: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaAccounts: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaTrends: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaRankings: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaFilters: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaAttributes: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaResources: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaStats: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaThresholds: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaRoutes: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaChargers: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaRateProfiles: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaActionProfiles: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaAccounts: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaTrends: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaRankings: {Limit: -1, TTL: 5 * time.Second},
},
Data: []*LoaderDataType{
{
@@ -2860,172 +2797,6 @@ func TestCgrLoaderCfgITDefaults(t *testing.T) {
Layout: time.RFC3339},
},
},
- {
- Type: utils.MetaDispatchers,
- Filename: utils.DispatcherProfilesCsv,
- Fields: []*FCTemplate{
- {Tag: "Tenant",
- Path: "Tenant",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.0", utils.InfieldSep),
- Mandatory: true,
- Layout: time.RFC3339},
- {Tag: "ID",
- Path: "ID",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.1", utils.InfieldSep),
- Mandatory: true,
- Layout: time.RFC3339},
- {Tag: "FilterIDs",
- Path: "FilterIDs",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.2", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "Weight",
- Path: "Weight",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.3", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "Strategy",
- Path: "Strategy",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.4", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "StrategyParameters",
- Path: "StrategyParams",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.5", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "ConnID",
- Path: "Hosts.ID",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.6", utils.InfieldSep),
- Layout: time.RFC3339,
- NewBranch: true,
- },
- {Tag: "ConnFilterIDs",
- Path: "Hosts.FilterIDs",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.7", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "ConnWeight",
- Path: "Hosts.Weight",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.8", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "ConnBlocker",
- Path: "Hosts.Blocker",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.9", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "ConnParameters",
- Path: "Hosts.Params",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.10", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- },
- },
- {
- Type: utils.MetaDispatcherHosts,
- Filename: utils.DispatcherHostsCsv,
- Fields: []*FCTemplate{
- {Tag: "Tenant",
- Path: "Tenant",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.0", utils.InfieldSep),
- Mandatory: true,
- Layout: time.RFC3339},
- {Tag: "ID",
- Path: "ID",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.1", utils.InfieldSep),
- Mandatory: true,
- Layout: time.RFC3339},
- {Tag: "Address",
- Path: "Address",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.2", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "Transport",
- Path: "Transport",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.3", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "ConnectAttempts",
- Path: "ConnectAttempts",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.4", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "Reconnects",
- Path: "Reconnects",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.5", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "MaxReconnectInterval",
- Path: "MaxReconnectInterval",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.6", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "ConnectTimeout",
- Path: "ConnectTimeout",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.7", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "ReplyTimeout",
- Path: "ReplyTimeout",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.8", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "TLS",
- Path: "TLS",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.9", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "ClientKey",
- Path: "ClientKey",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.10", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "ClientCertificate",
- Path: "ClientCertificate",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.11", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "CaCertificate",
- Path: "CaCertificate",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.12", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- },
- },
{
Type: utils.MetaRateProfiles,
Filename: utils.RatesCsv,
@@ -3337,25 +3108,6 @@ func TestCgrLoaderCfgITDefaults(t *testing.T) {
}
}
-func TestCgrCfgJSONDefaultDispatcherSCfg(t *testing.T) {
- eDspSCfg := &DispatcherSCfg{
- Enabled: false,
- IndexedSelects: true,
- StringIndexedFields: nil,
- PrefixIndexedFields: &[]string{},
- SuffixIndexedFields: &[]string{},
- ExistsIndexedFields: &[]string{},
- NotExistsIndexedFields: &[]string{},
- AttributeSConns: []string{},
- Opts: &DispatchersOpts{
- []*DynamicBoolOpt{},
- },
- }
- if !reflect.DeepEqual(cgrCfg.dispatcherSCfg, eDspSCfg) {
- t.Errorf("received: %+v, expecting: %+v", cgrCfg.dispatcherSCfg, eDspSCfg)
- }
-}
-
func TestCgrLoaderCfgDefault(t *testing.T) {
eLdrCfg := &LoaderCgrCfg{
TpID: "",
@@ -3589,20 +3341,18 @@ func TestCgrCfgV1GetConfigSectionLoader(t *testing.T) {
utils.MetaStopOnError: false,
},
utils.CacheCfg: map[string]any{
- utils.MetaFilters: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaAttributes: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaResources: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaStats: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaThresholds: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaRoutes: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaChargers: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaDispatchers: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaDispatcherHosts: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaRateProfiles: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaActionProfiles: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaAccounts: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaTrends: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaRankings: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaFilters: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaAttributes: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaResources: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaStats: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaThresholds: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaRoutes: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaChargers: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaRateProfiles: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaActionProfiles: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaAccounts: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaTrends: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaRankings: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
},
},
},
@@ -4404,55 +4154,6 @@ func TestV1GetConfigSuretax(t *testing.T) {
}
}
-func TestV1GetConfigDispatcherS(t *testing.T) {
- var reply map[string]any
- expected := map[string]any{
- DispatcherSJSON: map[string]any{
- utils.EnabledCfg: false,
- utils.IndexedSelectsCfg: true,
- utils.PrefixIndexedFieldsCfg: []string{},
- utils.SuffixIndexedFieldsCfg: []string{},
- utils.ExistsIndexedFieldsCfg: []string{},
- utils.NotExistsIndexedFieldsCfg: []string{},
- utils.NestedFieldsCfg: false,
- utils.AttributeSConnsCfg: []string{},
- utils.OptsCfg: map[string]any{
- utils.MetaDispatcherSCfg: []*DynamicBoolOpt{},
- },
- },
- }
- cfgCgr := NewDefaultCGRConfig()
- if err := cfgCgr.V1GetConfig(context.Background(), &SectionWithAPIOpts{Sections: []string{DispatcherSJSON}}, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(reply, expected) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(reply))
- }
-}
-
-func TestV1GetConfigDispatcherH(t *testing.T) {
- var reply map[string]any
- expected := map[string]any{
- RegistrarCJSON: map[string]any{
- utils.DispatcherCfg: map[string]any{
- utils.RegistrarsConnsCfg: []string{},
- utils.HostsCfg: []map[string]any{},
- utils.RefreshIntervalCfg: "5m0s",
- },
- utils.RPCCfg: map[string]any{
- utils.RegistrarsConnsCfg: []string{},
- utils.HostsCfg: []map[string]any{},
- utils.RefreshIntervalCfg: "5m0s",
- },
- },
- }
- cfgCgr := NewDefaultCGRConfig()
- if err := cfgCgr.V1GetConfig(context.Background(), &SectionWithAPIOpts{Sections: []string{RegistrarCJSON}}, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(reply, expected) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(reply))
- }
-}
-
func TestV1GetConfigSectionLoader(t *testing.T) {
var reply map[string]any
expected := map[string]any{
@@ -4928,7 +4629,7 @@ func TestV1GetConfigAsJSONGeneral(t *testing.T) {
func TestV1GetConfigAsJSONDataDB(t *testing.T) {
var reply string
- expected := `{"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*account_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*actions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*stat_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoConnScheme":"mongodb","mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisConnectAttempts":20,"redisConnectTimeout":"0s","redisMaxConns":10,"redisPoolPipelineLimit":0,"redisPoolPipelineWindow":"150µs","redisReadTimeout":"0s","redisSentinel":"","redisTLS":false,"redisWriteTimeout":"0s"},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false}}`
+ expected := `{"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*account_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*actions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*stat_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoConnScheme":"mongodb","mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisConnectAttempts":20,"redisConnectTimeout":"0s","redisMaxConns":10,"redisPoolPipelineLimit":0,"redisPoolPipelineWindow":"150µs","redisReadTimeout":"0s","redisSentinel":"","redisTLS":false,"redisWriteTimeout":"0s"},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false}}`
cfgCgr := NewDefaultCGRConfig()
if err := cfgCgr.V1GetConfigAsJSON(context.Background(), &SectionWithAPIOpts{Sections: []string{DataDBJSON}}, &reply); err != nil {
t.Error(err)
@@ -4950,7 +4651,7 @@ func TestV1GetConfigAsJSONTls(t *testing.T) {
func TestV1GetConfigAsJSONTCache(t *testing.T) {
var reply string
- expected := `{"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_loads":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatchers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*event_charges":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*sentrypeer":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":true,"ttl":"24h0m0s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"remote_conns":[],"replication_conns":[]}}`
+ expected := `{"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*event_charges":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*sentrypeer":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":true,"ttl":"24h0m0s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"remote_conns":[],"replication_conns":[]}}`
cfgCgr := NewDefaultCGRConfig()
if err := cfgCgr.V1GetConfigAsJSON(context.Background(), &SectionWithAPIOpts{Sections: []string{CacheJSON}}, &reply); err != nil {
t.Error(err)
@@ -5170,31 +4871,9 @@ func TestV1GetConfigAsJSONSureTax(t *testing.T) {
}
}
-func TestV1GetConfigAsJSONDispatcherS(t *testing.T) {
- var reply string
- expected := `{"dispatchers":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*dispatchers":[]},"prefix_indexed_fields":[],"suffix_indexed_fields":[]}}`
- cgrCfg := NewDefaultCGRConfig()
- if err := cgrCfg.V1GetConfigAsJSON(context.Background(), &SectionWithAPIOpts{Sections: []string{DispatcherSJSON}}, &reply); err != nil {
- t.Error(err)
- } else if expected != reply {
- t.Errorf("Expected %+v,\n received %+v", expected, reply)
- }
-}
-
-func TestV1GetConfigAsJSONDispatcherH(t *testing.T) {
- var reply string
- expected := `{"registrarc":{"dispatchers":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]},"rpc":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]}}}`
- cgrCfg := NewDefaultCGRConfig()
- if err := cgrCfg.V1GetConfigAsJSON(context.Background(), &SectionWithAPIOpts{Sections: []string{RegistrarCJSON}}, &reply); err != nil {
- t.Error(err)
- } else if expected != reply {
- t.Errorf("Expected %+v,\n received %+v", expected, reply)
- }
-}
-
func TestV1GetConfigAsJSONLoaders(t *testing.T) {
var reply string
- expected := `{"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatcher_hosts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatchers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Attributes.Blockers","tag":"AttributeBlockers","type":"*variable","value":"~*req.6"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.7"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.8"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.9"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.5"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.10"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.11"},{"path":"Metrics.Blockers","tag":"MetricBlockers","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatID","tag":"StatID","type":"*variable","value":"~*req.3"},{"path":"Metrics","tag":"Metrics","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"CorrelationType","tag":"CorrelationType","type":"*variable","value":"~*req.8"},{"path":"Tolerance","tag":"Tolerance","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Trends.csv","flags":null,"type":"*trends"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatIDs","tag":"StatIDs","type":"*variable","value":"~*req.3"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.7"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.8"}],"file_name":"Rankings.csv","flags":null,"type":"*rankings"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.7"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.12"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.13"},{"path":"Routes.Blockers","tag":"RouteBlockers","type":"*variable","value":"~*req.14"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.5"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.4"},{"path":"StrategyParams","tag":"StrategyParameters","type":"*variable","value":"~*req.5"},{"new_branch":true,"path":"Hosts.ID","tag":"ConnID","type":"*variable","value":"~*req.6"},{"path":"Hosts.FilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.7"},{"path":"Hosts.Weight","tag":"ConnWeight","type":"*variable","value":"~*req.8"},{"path":"Hosts.Blocker","tag":"ConnBlocker","type":"*variable","value":"~*req.9"},{"path":"Hosts.Params","tag":"ConnParameters","type":"*variable","value":"~*req.10"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"ConnectAttempts","tag":"ConnectAttempts","type":"*variable","value":"~*req.4"},{"path":"Reconnects","tag":"Reconnects","type":"*variable","value":"~*req.5"},{"path":"MaxReconnectInterval","tag":"MaxReconnectInterval","type":"*variable","value":"~*req.6"},{"path":"ConnectTimeout","tag":"ConnectTimeout","type":"*variable","value":"~*req.7"},{"path":"ReplyTimeout","tag":"ReplyTimeout","type":"*variable","value":"~*req.8"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.9"},{"path":"ClientKey","tag":"ClientKey","type":"*variable","value":"~*req.10"},{"path":"ClientCertificate","tag":"ClientCertificate","type":"*variable","value":"~*req.11"},{"path":"CaCertificate","tag":"CaCertificate","type":"*variable","value":"~*req.12"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.5"},{"path":"Targets[\u003c~*req.6\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.8:"],"new_branch":true,"path":"Actions[\u003c~*req.8\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.5"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Blockers","tag":"BalanceBlockers","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.16"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.17"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}]}`
+ expected := `{"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Attributes.Blockers","tag":"AttributeBlockers","type":"*variable","value":"~*req.6"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.7"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.8"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.9"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.5"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.10"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.11"},{"path":"Metrics.Blockers","tag":"MetricBlockers","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatID","tag":"StatID","type":"*variable","value":"~*req.3"},{"path":"Metrics","tag":"Metrics","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"CorrelationType","tag":"CorrelationType","type":"*variable","value":"~*req.8"},{"path":"Tolerance","tag":"Tolerance","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Trends.csv","flags":null,"type":"*trends"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatIDs","tag":"StatIDs","type":"*variable","value":"~*req.3"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.7"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.8"}],"file_name":"Rankings.csv","flags":null,"type":"*rankings"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.7"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.12"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.13"},{"path":"Routes.Blockers","tag":"RouteBlockers","type":"*variable","value":"~*req.14"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.5"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.5"},{"path":"Targets[\u003c~*req.6\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.8:"],"new_branch":true,"path":"Actions[\u003c~*req.8\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.5"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Blockers","tag":"BalanceBlockers","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.16"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.17"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}]}`
cgrCfg := NewDefaultCGRConfig()
if err := cgrCfg.V1GetConfigAsJSON(context.Background(), &SectionWithAPIOpts{Sections: []string{LoaderSJSON}}, &reply); err != nil {
t.Error(err)
@@ -5411,7 +5090,7 @@ func TestV1GetConfigAsJSONAllConfig(t *testing.T) {
}
}`
var reply string
- expected := `{"accounts":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"max_iterations":1000,"max_usage":"259200000000000","nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[],"*usage":[]},"prefix_indexed_fields":[],"rates_conns":[],"suffix_indexed_fields":[],"thresholds_conns":[]},"actions":{"accounts_conns":[],"cdrs_conns":[],"dynaprepaid_actionprofile":[],"ees_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*posterAttempts":[],"*profileIDs":[],"*profileIgnoreFilters":[]},"prefix_indexed_fields":[],"stats_conns":[],"suffix_indexed_fields":[],"tenants":[],"thresholds_conns":[]},"admins":{"actions_conns":[],"attributes_conns":[],"caches_conns":["*internal"],"ees_conns":[],"enabled":false},"analyzers":{"cleanup_interval":"1h0m0s","db_path":"/var/spool/cgrates/analyzers","ees_conns":[],"enabled":false,"index_type":"*scorch","opts":{"*exporterIDs":[]},"ttl":"24h0m0s"},"apiban":{"enabled":false,"keys":[]},"asterisk_agent":{"asterisk_conns":[{"address":"127.0.0.1:8088","alias":"","connect_attempts":3,"max_reconnect_interval":"0s","password":"CGRateS.org","reconnects":5,"user":"cgrates"}],"create_cdr":false,"enabled":false,"sessions_conns":["*birpc_internal"]},"attributes":{"accounts_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*processRuns":[],"*profileIDs":[],"*profileIgnoreFilters":[],"*profileRuns":[]},"prefix_indexed_fields":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_loads":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatchers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*event_charges":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*sentrypeer":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":true,"ttl":"24h0m0s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"remote_conns":[],"replication_conns":[]},"cdrs":{"accounts_conns":[],"actions_conns":[],"attributes_conns":[],"chargers_conns":[],"ees_conns":[],"enabled":false,"extra_fields":[],"online_cdr_exports":null,"opts":{"*accounts":[],"*attributes":[],"*chargers":[],"*ees":[],"*rates":[],"*refund":[],"*rerate":[],"*stats":[],"*store":[],"*thresholds":[]},"rates_conns":[],"session_cost_retries":5,"stats_conns":[],"thresholds_conns":[]},"chargers":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"config_db":{"db_host":"","db_name":"","db_password":"","db_port":0,"db_type":"*internal","db_user":"","opts":{"mongoConnScheme":"mongodb","mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisConnectAttempts":20,"redisConnectTimeout":"0s","redisMaxConns":10,"redisReadTimeout":"0s","redisSentinel":"","redisTLS":false,"redisWriteTimeout":"0s"}},"configs":{"enabled":false,"root_dir":"/var/spool/cgrates/configs","url":"/configs/"},"cores":{"caps":0,"caps_stats_interval":"0","caps_strategy":"*busy","ees_conns":[],"shutdown_timeout":"1s"},"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*account_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*actions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*stat_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoConnScheme":"mongodb","mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisConnectAttempts":20,"redisConnectTimeout":"0s","redisMaxConns":10,"redisPoolPipelineLimit":0,"redisPoolPipelineWindow":"150µs","redisReadTimeout":"0s","redisSentinel":"","redisTLS":false,"redisWriteTimeout":"0s"},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false},"diameter_agent":{"asr_template":"","dictionaries_path":"/usr/share/cgrates/diameter/dict/","enabled":false,"forced_disconnect":"*none","listen":"127.0.0.1:3868","listen_net":"tcp","origin_host":"CGR-DA","origin_realm":"cgrates.org","product_name":"CGRateS","rar_template":"","request_processors":[],"sessions_conns":["*birpc_internal"],"synced_conn_requests":false,"vendor_id":0},"dispatchers":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*dispatchers":[]},"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"dns_agent":{"enabled":false,"listeners":[{"address":"127.0.0.1:53","network":"udp"}],"request_processors":[],"sessions_conns":["*internal"],"timezone":""},"ees":{"attributes_conns":[],"cache":{"*fileCSV":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"enabled":false,"exporters":[{"attempts":1,"attribute_context":"","attribute_ids":[],"blocker":false,"concurrent_requests":0,"efs_conns":["*internal"],"export_path":"/var/spool/cgrates/ees","failed_posts_dir":"/var/spool/cgrates/failed_posts","fields":[],"filters":[],"flags":[],"id":"*default","opts":{},"synchronous":false,"timezone":"","type":"*none"}]},"efs":{"enabled":false,"failed_posts_dir":"/var/spool/cgrates/failed_posts","failed_posts_ttl":"5s","poster_attempts":3},"ers":{"enabled":false,"partial_cache_ttl":"1s","readers":[{"cache_dump_fields":[],"concurrent_requests":1024,"fields":[{"mandatory":true,"path":"*cgreq.ToR","tag":"ToR","type":"*variable","value":"~*req.2"},{"mandatory":true,"path":"*cgreq.OriginID","tag":"OriginID","type":"*variable","value":"~*req.3"},{"mandatory":true,"path":"*cgreq.RequestType","tag":"RequestType","type":"*variable","value":"~*req.4"},{"mandatory":true,"path":"*cgreq.Tenant","tag":"Tenant","type":"*variable","value":"~*req.6"},{"mandatory":true,"path":"*cgreq.Category","tag":"Category","type":"*variable","value":"~*req.7"},{"mandatory":true,"path":"*cgreq.Account","tag":"Account","type":"*variable","value":"~*req.8"},{"mandatory":true,"path":"*cgreq.Subject","tag":"Subject","type":"*variable","value":"~*req.9"},{"mandatory":true,"path":"*cgreq.Destination","tag":"Destination","type":"*variable","value":"~*req.10"},{"mandatory":true,"path":"*cgreq.SetupTime","tag":"SetupTime","type":"*variable","value":"~*req.11"},{"mandatory":true,"path":"*cgreq.AnswerTime","tag":"AnswerTime","type":"*variable","value":"~*req.12"},{"mandatory":true,"path":"*cgreq.Usage","tag":"Usage","type":"*variable","value":"~*req.13"}],"filters":[],"flags":[],"id":"*default","max_reconnect_interval":"5m0s","opts":{"csvFieldSeparator":",","csvHeaderDefineChar":":","csvRowLength":0,"natsSubject":"cgrates_cdrs","partialCacheAction":"*none","partialOrderField":"~*req.AnswerTime"},"partial_commit_fields":[],"processed_path":"/var/spool/cgrates/ers/out","reconnects":-1,"run_delay":"0","source_path":"/var/spool/cgrates/ers/in","tenant":"","timezone":"","type":"*none"}],"sessions_conns":["*internal"]},"filters":{"accounts_conns":[],"rankings_conns":[],"resources_conns":[],"stats_conns":[],"trends_conns":[]},"freeswitch_agent":{"active_session_delimiter":",","create_cdr":false,"empty_balance_ann_file":"","empty_balance_context":"","enabled":false,"event_socket_conns":[{"address":"127.0.0.1:8021","alias":"127.0.0.1:8021","max_reconnect_interval":"0s","password":"ClueCon","reconnects":5,"reply_timeout":"1m0s"}],"extra_fields":[],"low_balance_ann_file":"","max_wait_connection":"2s","sessions_conns":["*birpc_internal"],"subscribe_park":true},"general":{"caching_delay":"0","connect_attempts":5,"connect_timeout":"1s","dbdata_encoding":"*msgpack","decimal_max_scale":0,"decimal_min_scale":0,"decimal_precision":0,"decimal_rounding_mode":"*toNearestEven","default_caching":"*reload","default_category":"call","default_request_type":"*rated","default_tenant":"cgrates.org","default_timezone":"Local","digest_equal":":","digest_separator":",","locking_timeout":"0","max_parallel_conns":100,"max_reconnect_interval":"0","node_id":"ENGINE1","opts":{"*exporterIDs":[]},"reconnects":-1,"reply_timeout":"2s","rounding_decimals":5,"rsr_separator":";","tpexport_dir":"/var/spool/cgrates/tpe"},"http":{"auth_users":{},"client_opts":{"dialFallbackDelay":"300ms","dialKeepAlive":"30s","dialTimeout":"30s","disableCompression":false,"disableKeepAlives":false,"expectContinueTimeout":"0s","forceAttemptHttp2":true,"idleConnTimeout":"1m30s","maxConnsPerHost":0,"maxIdleConns":100,"maxIdleConnsPerHost":2,"responseHeaderTimeout":"0s","skipTLSVerification":false,"tlsHandshakeTimeout":"10s"},"freeswitch_cdrs_url":"/freeswitch_json","http_cdrs":"/cdr_http","json_rpc_url":"/jsonrpc","pprof_path":"/debug/pprof/","prometheus_url":"/prometheus","registrars_url":"/registrar","use_basic_auth":false,"ws_url":"/ws"},"http_agent":[],"janus_agent":{"enabled":false,"janus_conns":[{"address":"127.0.0.1:8088","admin_address":"localhost:7188","admin_password":"","type":"*ws"}],"request_processors":[],"sessions_conns":["*internal"],"url":"/janus"},"kamailio_agent":{"create_cdr":false,"enabled":false,"evapi_conns":[{"address":"127.0.0.1:8448","alias":"","max_reconnect_interval":"0s","reconnects":5}],"sessions_conns":["*birpc_internal"],"timezone":""},"listen":{"http":"127.0.0.1:2080","http_tls":"127.0.0.1:2280","rpc_gob":"127.0.0.1:2013","rpc_gob_tls":"127.0.0.1:2023","rpc_json":"127.0.0.1:2012","rpc_json_tls":"127.0.0.1:2022"},"loader":{"actions_conns":["*localhost"],"caches_conns":["*localhost"],"data_path":"./","disable_reverse":false,"field_separator":",","gapi_credentials":".gapi/credentials.json","gapi_token":".gapi/token.json","tpid":""},"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatcher_hosts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatchers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Attributes.Blockers","tag":"AttributeBlockers","type":"*variable","value":"~*req.6"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.7"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.8"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.9"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.5"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.10"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.11"},{"path":"Metrics.Blockers","tag":"MetricBlockers","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatID","tag":"StatID","type":"*variable","value":"~*req.3"},{"path":"Metrics","tag":"Metrics","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"CorrelationType","tag":"CorrelationType","type":"*variable","value":"~*req.8"},{"path":"Tolerance","tag":"Tolerance","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Trends.csv","flags":null,"type":"*trends"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatIDs","tag":"StatIDs","type":"*variable","value":"~*req.3"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.7"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.8"}],"file_name":"Rankings.csv","flags":null,"type":"*rankings"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.7"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.12"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.13"},{"path":"Routes.Blockers","tag":"RouteBlockers","type":"*variable","value":"~*req.14"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.5"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.4"},{"path":"StrategyParams","tag":"StrategyParameters","type":"*variable","value":"~*req.5"},{"new_branch":true,"path":"Hosts.ID","tag":"ConnID","type":"*variable","value":"~*req.6"},{"path":"Hosts.FilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.7"},{"path":"Hosts.Weight","tag":"ConnWeight","type":"*variable","value":"~*req.8"},{"path":"Hosts.Blocker","tag":"ConnBlocker","type":"*variable","value":"~*req.9"},{"path":"Hosts.Params","tag":"ConnParameters","type":"*variable","value":"~*req.10"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"ConnectAttempts","tag":"ConnectAttempts","type":"*variable","value":"~*req.4"},{"path":"Reconnects","tag":"Reconnects","type":"*variable","value":"~*req.5"},{"path":"MaxReconnectInterval","tag":"MaxReconnectInterval","type":"*variable","value":"~*req.6"},{"path":"ConnectTimeout","tag":"ConnectTimeout","type":"*variable","value":"~*req.7"},{"path":"ReplyTimeout","tag":"ReplyTimeout","type":"*variable","value":"~*req.8"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.9"},{"path":"ClientKey","tag":"ClientKey","type":"*variable","value":"~*req.10"},{"path":"ClientCertificate","tag":"ClientCertificate","type":"*variable","value":"~*req.11"},{"path":"CaCertificate","tag":"CaCertificate","type":"*variable","value":"~*req.12"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.5"},{"path":"Targets[\u003c~*req.6\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.8:"],"new_branch":true,"path":"Actions[\u003c~*req.8\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.5"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Blockers","tag":"BalanceBlockers","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.16"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.17"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}],"logger":{"efs_conns":["*internal"],"level":6,"opts":{"failed_posts_dir":"/var/spool/cgrates/failed_posts","kafka_attempts":1,"kafka_conn":"","kafka_topic":""},"type":"*syslog"},"migrator":{"out_datadb_encoding":"msgpack","out_datadb_host":"127.0.0.1","out_datadb_name":"10","out_datadb_opts":{"mongoConnScheme":"mongodb","mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisConnectAttempts":20,"redisConnectTimeout":"0s","redisMaxConns":10,"redisPoolPipelineLimit":0,"redisPoolPipelineWindow":"150µs","redisReadTimeout":"0s","redisSentinel":"","redisTLS":false,"redisWriteTimeout":"0s"},"out_datadb_password":"","out_datadb_port":"6379","out_datadb_type":"*redis","out_datadb_user":"cgrates","users_filters":null},"radius_agent":{"client_dictionaries":{"*default":"/usr/share/cgrates/radius/dict/"},"client_secrets":{"*default":"CGRateS.org"},"enabled":false,"listen_acct":"127.0.0.1:1813","listen_auth":"127.0.0.1:1812","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"]},"rankings":{"ees_conns":[],"ees_exporter_ids":null,"enabled":false,"scheduled_ids":{},"stats_conns":[],"store_interval":"","thresholds_conns":[]},"rates":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*intervalStart":[],"*profileIDs":[],"*profileIgnoreFilters":[],"*startTime":[],"*usage":[]},"prefix_indexed_fields":[],"rate_exists_indexed_fields":[],"rate_indexed_selects":true,"rate_nested_fields":false,"rate_notexists_indexed_fields":[],"rate_prefix_indexed_fields":[],"rate_suffix_indexed_fields":[],"suffix_indexed_fields":[],"verbosity":1000},"registrarc":{"dispatchers":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]},"rpc":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]}},"resources":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*units":[],"*usageID":[],"*usageTTL":[]},"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[],"thresholds_conns":[]},"routes":{"accounts_conns":[],"attributes_conns":[],"default_ratio":1,"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*context":[],"*ignoreErrors":[],"*limit":[],"*maxCost":[],"*maxItems":[],"*offset":[],"*profileCount":[],"*usage":[]},"prefix_indexed_fields":[],"rates_conns":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"rpc_conns":{"*bijson_localhost":{"conns":[{"address":"127.0.0.1:2014","transport":"*birpc_json"}],"poolSize":0,"strategy":"*first"},"*birpc_internal":{"conns":[{"address":"*birpc_internal","transport":""}],"poolSize":0,"strategy":"*first"},"*internal":{"conns":[{"address":"*internal","transport":""}],"poolSize":0,"strategy":"*first"},"*localhost":{"conns":[{"address":"127.0.0.1:2012","transport":"*json"}],"poolSize":0,"strategy":"*first"}},"sentrypeer":{"audience":"https://sentrypeer.com/api","client_id":"","client_secret":"","grant_type":"client_credentials","ips_url":"https://sentrypeer.com/api/ip-addresses","numbers_url":"https://sentrypeer.com/api/phone-numbers","token_url":"https://authz.sentrypeer.com/oauth/token"},"sessions":{"accounts_conns":[],"actions_conns":[],"alterable_fields":[],"attributes_conns":[],"cdrs_conns":[],"channel_sync_interval":"0","chargers_conns":[],"client_protocol":1,"default_usage":{"*any":"3h0m0s","*data":"1048576","*sms":"1","*voice":"3h0m0s"},"enabled":false,"listen_bigob":"","listen_bijson":"127.0.0.1:2014","min_dur_low_balance":"0","opts":{"*accounts":[],"*attributes":[],"*attributesDerivedReply":[],"*blockerError":[],"*cdrs":[],"*cdrsDerivedReply":[],"*chargeable":[],"*chargers":[],"*debitInterval":[],"*forceUsage":[],"*initiate":[],"*maxUsage":[],"*message":[],"*resources":[],"*resourcesAllocate":[],"*resourcesAuthorize":[],"*resourcesDerivedReply":[],"*resourcesRelease":[],"*routes":[],"*routesDerivedReply":[],"*stats":[],"*statsDerivedReply":[],"*terminate":[],"*thresholds":[],"*thresholdsDerivedReply":[],"*ttl":[],"*ttlLastUsage":[],"*ttlLastUsed":[],"*ttlMaxDelay":[],"*ttlUsage":[],"*update":[]},"rates_conns":[],"replication_conns":[],"resources_conns":[],"routes_conns":[],"session_indexes":[],"stats_conns":[],"stir":{"allowed_attest":["*any"],"default_attest":"A","payload_maxduration":"-1","privatekey_path":"","publickey_path":""},"store_session_costs":false,"terminate_attempts":5,"thresholds_conns":[]},"sip_agent":{"enabled":false,"listen":"127.0.0.1:5060","listen_net":"udp","request_processors":[],"retransmission_timer":"1s","sessions_conns":["*internal"],"timezone":""},"stats":{"ees_conns":[],"ees_exporter_ids":null,"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[],"*prometheusStatIDs":[],"*roundingDecimals":[]},"prefix_indexed_fields":[],"store_interval":"","store_uncompressed_limit":0,"suffix_indexed_fields":[],"thresholds_conns":[]},"stor_db":{"db_host":"127.0.0.1","db_name":"cgrates","db_password":"CGRateS.org","db_port":3306,"db_type":"**mysql","db_user":"cgrates","items":{"*cdrs":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoConnScheme":"mongodb","mongoQueryTimeout":"10s","mysqlDSNParams":{},"mysqlLocation":"Local","pgSSLMode":"disable","sqlConnMaxLifetime":"0s","sqlMaxIdleConns":10,"sqlMaxOpenConns":100},"prefix_indexed_fields":[],"remote_conns":null,"replication_conns":null,"string_indexed_fields":[]},"suretax":{"bill_to_number":"","business_unit":"","client_number":"","client_tracking":"~*opts.*originID","customer_number":"~*req.Subject","include_local_cost":false,"orig_number":"~*req.Subject","p2pplus4":"","p2pzipcode":"","plus4":"","regulatory_code":"03","response_group":"03","response_type":"D4","return_file_code":"0","sales_type_code":"R","tax_exemption_code_list":"","tax_included":"0","tax_situs_rule":"04","term_number":"~*req.Destination","timezone":"UTC","trans_type_code":"010101","unit_type":"00","units":"1","url":"","validation_key":"","zipcode":""},"templates":{"*asr":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"}],"*cca":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"path":"*rep.Result-Code","tag":"ResultCode","type":"*constant","value":"2001"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"},{"mandatory":true,"path":"*rep.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"mandatory":true,"path":"*rep.CC-Request-Type","tag":"CCRequestType","type":"*variable","value":"~*req.CC-Request-Type"},{"mandatory":true,"path":"*rep.CC-Request-Number","tag":"CCRequestNumber","type":"*variable","value":"~*req.CC-Request-Number"}],"*cdrLog":[{"mandatory":true,"path":"*cdr.ToR","tag":"ToR","type":"*variable","value":"~*req.BalanceType"},{"mandatory":true,"path":"*cdr.OriginHost","tag":"OriginHost","type":"*constant","value":"127.0.0.1"},{"mandatory":true,"path":"*cdr.RequestType","tag":"RequestType","type":"*constant","value":"*none"},{"mandatory":true,"path":"*cdr.Tenant","tag":"Tenant","type":"*variable","value":"~*req.Tenant"},{"mandatory":true,"path":"*cdr.Account","tag":"Account","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Subject","tag":"Subject","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Cost","tag":"Cost","type":"*variable","value":"~*req.Cost"},{"mandatory":true,"path":"*cdr.Source","tag":"Source","type":"*constant","value":"*cdrLog"},{"mandatory":true,"path":"*cdr.Usage","tag":"Usage","type":"*constant","value":"1"},{"mandatory":true,"path":"*cdr.RunID","tag":"RunID","type":"*variable","value":"~*req.ActionType"},{"mandatory":true,"path":"*cdr.SetupTime","tag":"SetupTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.AnswerTime","tag":"AnswerTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.PreRated","tag":"PreRated","type":"*constant","value":"true"}],"*err":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"}],"*errSip":[{"mandatory":true,"path":"*rep.Request","tag":"Request","type":"*constant","value":"SIP/2.0 500 Internal Server Error"}],"*rar":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"path":"*diamreq.Re-Auth-Request-Type","tag":"ReAuthRequestType","type":"*constant","value":"0"}]},"thresholds":{"actions_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[]},"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[]},"tls":{"ca_certificate":"","client_certificate":"","client_key":"","server_certificate":"","server_key":"","server_name":"","server_policy":4},"tpes":{"enabled":false},"trends":{"ees_conns":[],"ees_exporter_ids":null,"enabled":false,"scheduled_ids":{},"stats_conns":[],"store_interval":"","store_uncompressed_limit":0,"thresholds_conns":[]}}`
+ expected := `{"accounts":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"max_iterations":1000,"max_usage":"259200000000000","nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[],"*usage":[]},"prefix_indexed_fields":[],"rates_conns":[],"suffix_indexed_fields":[],"thresholds_conns":[]},"actions":{"accounts_conns":[],"cdrs_conns":[],"dynaprepaid_actionprofile":[],"ees_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*posterAttempts":[],"*profileIDs":[],"*profileIgnoreFilters":[]},"prefix_indexed_fields":[],"stats_conns":[],"suffix_indexed_fields":[],"tenants":[],"thresholds_conns":[]},"admins":{"actions_conns":[],"attributes_conns":[],"caches_conns":["*internal"],"ees_conns":[],"enabled":false},"analyzers":{"cleanup_interval":"1h0m0s","db_path":"/var/spool/cgrates/analyzers","ees_conns":[],"enabled":false,"index_type":"*scorch","opts":{"*exporterIDs":[]},"ttl":"24h0m0s"},"apiban":{"enabled":false,"keys":[]},"asterisk_agent":{"asterisk_conns":[{"address":"127.0.0.1:8088","alias":"","connect_attempts":3,"max_reconnect_interval":"0s","password":"CGRateS.org","reconnects":5,"user":"cgrates"}],"create_cdr":false,"enabled":false,"sessions_conns":["*birpc_internal"]},"attributes":{"accounts_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*processRuns":[],"*profileIDs":[],"*profileIgnoreFilters":[],"*profileRuns":[]},"prefix_indexed_fields":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*event_charges":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*sentrypeer":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":true,"ttl":"24h0m0s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"remote_conns":[],"replication_conns":[]},"cdrs":{"accounts_conns":[],"actions_conns":[],"attributes_conns":[],"chargers_conns":[],"ees_conns":[],"enabled":false,"extra_fields":[],"online_cdr_exports":null,"opts":{"*accounts":[],"*attributes":[],"*chargers":[],"*ees":[],"*rates":[],"*refund":[],"*rerate":[],"*stats":[],"*store":[],"*thresholds":[]},"rates_conns":[],"session_cost_retries":5,"stats_conns":[],"thresholds_conns":[]},"chargers":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"config_db":{"db_host":"","db_name":"","db_password":"","db_port":0,"db_type":"*internal","db_user":"","opts":{"mongoConnScheme":"mongodb","mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisConnectAttempts":20,"redisConnectTimeout":"0s","redisMaxConns":10,"redisReadTimeout":"0s","redisSentinel":"","redisTLS":false,"redisWriteTimeout":"0s"}},"configs":{"enabled":false,"root_dir":"/var/spool/cgrates/configs","url":"/configs/"},"cores":{"caps":0,"caps_stats_interval":"0","caps_strategy":"*busy","ees_conns":[],"shutdown_timeout":"1s"},"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*account_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*actions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*stat_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoConnScheme":"mongodb","mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisConnectAttempts":20,"redisConnectTimeout":"0s","redisMaxConns":10,"redisPoolPipelineLimit":0,"redisPoolPipelineWindow":"150µs","redisReadTimeout":"0s","redisSentinel":"","redisTLS":false,"redisWriteTimeout":"0s"},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false},"diameter_agent":{"asr_template":"","dictionaries_path":"/usr/share/cgrates/diameter/dict/","enabled":false,"forced_disconnect":"*none","listen":"127.0.0.1:3868","listen_net":"tcp","origin_host":"CGR-DA","origin_realm":"cgrates.org","product_name":"CGRateS","rar_template":"","request_processors":[],"sessions_conns":["*birpc_internal"],"synced_conn_requests":false,"vendor_id":0},"dns_agent":{"enabled":false,"listeners":[{"address":"127.0.0.1:53","network":"udp"}],"request_processors":[],"sessions_conns":["*internal"],"timezone":""},"ees":{"attributes_conns":[],"cache":{"*fileCSV":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"enabled":false,"exporters":[{"attempts":1,"attribute_context":"","attribute_ids":[],"blocker":false,"concurrent_requests":0,"efs_conns":["*internal"],"export_path":"/var/spool/cgrates/ees","failed_posts_dir":"/var/spool/cgrates/failed_posts","fields":[],"filters":[],"flags":[],"id":"*default","opts":{},"synchronous":false,"timezone":"","type":"*none"}]},"efs":{"enabled":false,"failed_posts_dir":"/var/spool/cgrates/failed_posts","failed_posts_ttl":"5s","poster_attempts":3},"ers":{"enabled":false,"partial_cache_ttl":"1s","readers":[{"cache_dump_fields":[],"concurrent_requests":1024,"fields":[{"mandatory":true,"path":"*cgreq.ToR","tag":"ToR","type":"*variable","value":"~*req.2"},{"mandatory":true,"path":"*cgreq.OriginID","tag":"OriginID","type":"*variable","value":"~*req.3"},{"mandatory":true,"path":"*cgreq.RequestType","tag":"RequestType","type":"*variable","value":"~*req.4"},{"mandatory":true,"path":"*cgreq.Tenant","tag":"Tenant","type":"*variable","value":"~*req.6"},{"mandatory":true,"path":"*cgreq.Category","tag":"Category","type":"*variable","value":"~*req.7"},{"mandatory":true,"path":"*cgreq.Account","tag":"Account","type":"*variable","value":"~*req.8"},{"mandatory":true,"path":"*cgreq.Subject","tag":"Subject","type":"*variable","value":"~*req.9"},{"mandatory":true,"path":"*cgreq.Destination","tag":"Destination","type":"*variable","value":"~*req.10"},{"mandatory":true,"path":"*cgreq.SetupTime","tag":"SetupTime","type":"*variable","value":"~*req.11"},{"mandatory":true,"path":"*cgreq.AnswerTime","tag":"AnswerTime","type":"*variable","value":"~*req.12"},{"mandatory":true,"path":"*cgreq.Usage","tag":"Usage","type":"*variable","value":"~*req.13"}],"filters":[],"flags":[],"id":"*default","max_reconnect_interval":"5m0s","opts":{"csvFieldSeparator":",","csvHeaderDefineChar":":","csvRowLength":0,"natsSubject":"cgrates_cdrs","partialCacheAction":"*none","partialOrderField":"~*req.AnswerTime"},"partial_commit_fields":[],"processed_path":"/var/spool/cgrates/ers/out","reconnects":-1,"run_delay":"0","source_path":"/var/spool/cgrates/ers/in","tenant":"","timezone":"","type":"*none"}],"sessions_conns":["*internal"]},"filters":{"accounts_conns":[],"rankings_conns":[],"resources_conns":[],"stats_conns":[],"trends_conns":[]},"freeswitch_agent":{"active_session_delimiter":",","create_cdr":false,"empty_balance_ann_file":"","empty_balance_context":"","enabled":false,"event_socket_conns":[{"address":"127.0.0.1:8021","alias":"127.0.0.1:8021","max_reconnect_interval":"0s","password":"ClueCon","reconnects":5,"reply_timeout":"1m0s"}],"extra_fields":[],"low_balance_ann_file":"","max_wait_connection":"2s","sessions_conns":["*birpc_internal"],"subscribe_park":true},"general":{"caching_delay":"0","connect_attempts":5,"connect_timeout":"1s","dbdata_encoding":"*msgpack","decimal_max_scale":0,"decimal_min_scale":0,"decimal_precision":0,"decimal_rounding_mode":"*toNearestEven","default_caching":"*reload","default_category":"call","default_request_type":"*rated","default_tenant":"cgrates.org","default_timezone":"Local","digest_equal":":","digest_separator":",","locking_timeout":"0","max_parallel_conns":100,"max_reconnect_interval":"0","node_id":"ENGINE1","opts":{"*exporterIDs":[]},"reconnects":-1,"reply_timeout":"2s","rounding_decimals":5,"rsr_separator":";","tpexport_dir":"/var/spool/cgrates/tpe"},"http":{"auth_users":{},"client_opts":{"dialFallbackDelay":"300ms","dialKeepAlive":"30s","dialTimeout":"30s","disableCompression":false,"disableKeepAlives":false,"expectContinueTimeout":"0s","forceAttemptHttp2":true,"idleConnTimeout":"1m30s","maxConnsPerHost":0,"maxIdleConns":100,"maxIdleConnsPerHost":2,"responseHeaderTimeout":"0s","skipTLSVerification":false,"tlsHandshakeTimeout":"10s"},"freeswitch_cdrs_url":"/freeswitch_json","http_cdrs":"/cdr_http","json_rpc_url":"/jsonrpc","pprof_path":"/debug/pprof/","prometheus_url":"/prometheus","registrars_url":"/registrar","use_basic_auth":false,"ws_url":"/ws"},"http_agent":[],"janus_agent":{"enabled":false,"janus_conns":[{"address":"127.0.0.1:8088","admin_address":"localhost:7188","admin_password":"","type":"*ws"}],"request_processors":[],"sessions_conns":["*internal"],"url":"/janus"},"kamailio_agent":{"create_cdr":false,"enabled":false,"evapi_conns":[{"address":"127.0.0.1:8448","alias":"","max_reconnect_interval":"0s","reconnects":5}],"sessions_conns":["*birpc_internal"],"timezone":""},"listen":{"http":"127.0.0.1:2080","http_tls":"127.0.0.1:2280","rpc_gob":"127.0.0.1:2013","rpc_gob_tls":"127.0.0.1:2023","rpc_json":"127.0.0.1:2012","rpc_json_tls":"127.0.0.1:2022"},"loader":{"actions_conns":["*localhost"],"caches_conns":["*localhost"],"data_path":"./","disable_reverse":false,"field_separator":",","gapi_credentials":".gapi/credentials.json","gapi_token":".gapi/token.json","tpid":""},"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Attributes.Blockers","tag":"AttributeBlockers","type":"*variable","value":"~*req.6"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.7"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.8"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.9"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.5"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.10"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.11"},{"path":"Metrics.Blockers","tag":"MetricBlockers","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatID","tag":"StatID","type":"*variable","value":"~*req.3"},{"path":"Metrics","tag":"Metrics","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"CorrelationType","tag":"CorrelationType","type":"*variable","value":"~*req.8"},{"path":"Tolerance","tag":"Tolerance","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Trends.csv","flags":null,"type":"*trends"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatIDs","tag":"StatIDs","type":"*variable","value":"~*req.3"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.7"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.8"}],"file_name":"Rankings.csv","flags":null,"type":"*rankings"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.7"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.12"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.13"},{"path":"Routes.Blockers","tag":"RouteBlockers","type":"*variable","value":"~*req.14"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.5"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.5"},{"path":"Targets[\u003c~*req.6\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.8:"],"new_branch":true,"path":"Actions[\u003c~*req.8\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.5"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Blockers","tag":"BalanceBlockers","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.16"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.17"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}],"logger":{"efs_conns":["*internal"],"level":6,"opts":{"failed_posts_dir":"/var/spool/cgrates/failed_posts","kafka_attempts":1,"kafka_conn":"","kafka_topic":""},"type":"*syslog"},"migrator":{"out_datadb_encoding":"msgpack","out_datadb_host":"127.0.0.1","out_datadb_name":"10","out_datadb_opts":{"mongoConnScheme":"mongodb","mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisConnectAttempts":20,"redisConnectTimeout":"0s","redisMaxConns":10,"redisPoolPipelineLimit":0,"redisPoolPipelineWindow":"150µs","redisReadTimeout":"0s","redisSentinel":"","redisTLS":false,"redisWriteTimeout":"0s"},"out_datadb_password":"","out_datadb_port":"6379","out_datadb_type":"*redis","out_datadb_user":"cgrates","users_filters":null},"radius_agent":{"client_dictionaries":{"*default":"/usr/share/cgrates/radius/dict/"},"client_secrets":{"*default":"CGRateS.org"},"enabled":false,"listen_acct":"127.0.0.1:1813","listen_auth":"127.0.0.1:1812","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"]},"rankings":{"ees_conns":[],"ees_exporter_ids":null,"enabled":false,"scheduled_ids":{},"stats_conns":[],"store_interval":"","thresholds_conns":[]},"rates":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*intervalStart":[],"*profileIDs":[],"*profileIgnoreFilters":[],"*startTime":[],"*usage":[]},"prefix_indexed_fields":[],"rate_exists_indexed_fields":[],"rate_indexed_selects":true,"rate_nested_fields":false,"rate_notexists_indexed_fields":[],"rate_prefix_indexed_fields":[],"rate_suffix_indexed_fields":[],"suffix_indexed_fields":[],"verbosity":1000},"registrarc":{"rpc":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]}},"resources":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*units":[],"*usageID":[],"*usageTTL":[]},"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[],"thresholds_conns":[]},"routes":{"accounts_conns":[],"attributes_conns":[],"default_ratio":1,"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*context":[],"*ignoreErrors":[],"*limit":[],"*maxCost":[],"*maxItems":[],"*offset":[],"*profileCount":[],"*usage":[]},"prefix_indexed_fields":[],"rates_conns":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"rpc_conns":{"*bijson_localhost":{"conns":[{"address":"127.0.0.1:2014","transport":"*birpc_json"}],"poolSize":0,"strategy":"*first"},"*birpc_internal":{"conns":[{"address":"*birpc_internal","transport":""}],"poolSize":0,"strategy":"*first"},"*internal":{"conns":[{"address":"*internal","transport":""}],"poolSize":0,"strategy":"*first"},"*localhost":{"conns":[{"address":"127.0.0.1:2012","transport":"*json"}],"poolSize":0,"strategy":"*first"}},"sentrypeer":{"audience":"https://sentrypeer.com/api","client_id":"","client_secret":"","grant_type":"client_credentials","ips_url":"https://sentrypeer.com/api/ip-addresses","numbers_url":"https://sentrypeer.com/api/phone-numbers","token_url":"https://authz.sentrypeer.com/oauth/token"},"sessions":{"accounts_conns":[],"actions_conns":[],"alterable_fields":[],"attributes_conns":[],"cdrs_conns":[],"channel_sync_interval":"0","chargers_conns":[],"client_protocol":1,"default_usage":{"*any":"3h0m0s","*data":"1048576","*sms":"1","*voice":"3h0m0s"},"enabled":false,"listen_bigob":"","listen_bijson":"127.0.0.1:2014","min_dur_low_balance":"0","opts":{"*accounts":[],"*attributes":[],"*attributesDerivedReply":[],"*blockerError":[],"*cdrs":[],"*cdrsDerivedReply":[],"*chargeable":[],"*chargers":[],"*debitInterval":[],"*forceUsage":[],"*initiate":[],"*maxUsage":[],"*message":[],"*resources":[],"*resourcesAllocate":[],"*resourcesAuthorize":[],"*resourcesDerivedReply":[],"*resourcesRelease":[],"*routes":[],"*routesDerivedReply":[],"*stats":[],"*statsDerivedReply":[],"*terminate":[],"*thresholds":[],"*thresholdsDerivedReply":[],"*ttl":[],"*ttlLastUsage":[],"*ttlLastUsed":[],"*ttlMaxDelay":[],"*ttlUsage":[],"*update":[]},"rates_conns":[],"replication_conns":[],"resources_conns":[],"routes_conns":[],"session_indexes":[],"stats_conns":[],"stir":{"allowed_attest":["*any"],"default_attest":"A","payload_maxduration":"-1","privatekey_path":"","publickey_path":""},"store_session_costs":false,"terminate_attempts":5,"thresholds_conns":[]},"sip_agent":{"enabled":false,"listen":"127.0.0.1:5060","listen_net":"udp","request_processors":[],"retransmission_timer":"1s","sessions_conns":["*internal"],"timezone":""},"stats":{"ees_conns":[],"ees_exporter_ids":null,"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[],"*prometheusStatIDs":[],"*roundingDecimals":[]},"prefix_indexed_fields":[],"store_interval":"","store_uncompressed_limit":0,"suffix_indexed_fields":[],"thresholds_conns":[]},"stor_db":{"db_host":"127.0.0.1","db_name":"cgrates","db_password":"CGRateS.org","db_port":3306,"db_type":"**mysql","db_user":"cgrates","items":{"*cdrs":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoConnScheme":"mongodb","mongoQueryTimeout":"10s","mysqlDSNParams":{},"mysqlLocation":"Local","pgSSLMode":"disable","sqlConnMaxLifetime":"0s","sqlMaxIdleConns":10,"sqlMaxOpenConns":100},"prefix_indexed_fields":[],"remote_conns":null,"replication_conns":null,"string_indexed_fields":[]},"suretax":{"bill_to_number":"","business_unit":"","client_number":"","client_tracking":"~*opts.*originID","customer_number":"~*req.Subject","include_local_cost":false,"orig_number":"~*req.Subject","p2pplus4":"","p2pzipcode":"","plus4":"","regulatory_code":"03","response_group":"03","response_type":"D4","return_file_code":"0","sales_type_code":"R","tax_exemption_code_list":"","tax_included":"0","tax_situs_rule":"04","term_number":"~*req.Destination","timezone":"UTC","trans_type_code":"010101","unit_type":"00","units":"1","url":"","validation_key":"","zipcode":""},"templates":{"*asr":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"}],"*cca":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"path":"*rep.Result-Code","tag":"ResultCode","type":"*constant","value":"2001"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"},{"mandatory":true,"path":"*rep.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"mandatory":true,"path":"*rep.CC-Request-Type","tag":"CCRequestType","type":"*variable","value":"~*req.CC-Request-Type"},{"mandatory":true,"path":"*rep.CC-Request-Number","tag":"CCRequestNumber","type":"*variable","value":"~*req.CC-Request-Number"}],"*cdrLog":[{"mandatory":true,"path":"*cdr.ToR","tag":"ToR","type":"*variable","value":"~*req.BalanceType"},{"mandatory":true,"path":"*cdr.OriginHost","tag":"OriginHost","type":"*constant","value":"127.0.0.1"},{"mandatory":true,"path":"*cdr.RequestType","tag":"RequestType","type":"*constant","value":"*none"},{"mandatory":true,"path":"*cdr.Tenant","tag":"Tenant","type":"*variable","value":"~*req.Tenant"},{"mandatory":true,"path":"*cdr.Account","tag":"Account","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Subject","tag":"Subject","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Cost","tag":"Cost","type":"*variable","value":"~*req.Cost"},{"mandatory":true,"path":"*cdr.Source","tag":"Source","type":"*constant","value":"*cdrLog"},{"mandatory":true,"path":"*cdr.Usage","tag":"Usage","type":"*constant","value":"1"},{"mandatory":true,"path":"*cdr.RunID","tag":"RunID","type":"*variable","value":"~*req.ActionType"},{"mandatory":true,"path":"*cdr.SetupTime","tag":"SetupTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.AnswerTime","tag":"AnswerTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.PreRated","tag":"PreRated","type":"*constant","value":"true"}],"*err":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"}],"*errSip":[{"mandatory":true,"path":"*rep.Request","tag":"Request","type":"*constant","value":"SIP/2.0 500 Internal Server Error"}],"*rar":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"path":"*diamreq.Re-Auth-Request-Type","tag":"ReAuthRequestType","type":"*constant","value":"0"}]},"thresholds":{"actions_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[]},"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[]},"tls":{"ca_certificate":"","client_certificate":"","client_key":"","server_certificate":"","server_key":"","server_name":"","server_policy":4},"tpes":{"enabled":false},"trends":{"ees_conns":[],"ees_exporter_ids":null,"enabled":false,"scheduled_ids":{},"stats_conns":[],"store_interval":"","store_uncompressed_limit":0,"thresholds_conns":[]}}`
cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSON)
if err != nil {
@@ -5733,9 +5412,6 @@ func TestCGRConfigClone(t *testing.T) {
if !reflect.DeepEqual(cfg.sureTaxCfg, rcv.sureTaxCfg) {
t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(cfg.sureTaxCfg), utils.ToJSON(rcv.sureTaxCfg))
}
- if !reflect.DeepEqual(cfg.dispatcherSCfg, rcv.dispatcherSCfg) {
- t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(cfg.dispatcherSCfg), utils.ToJSON(rcv.dispatcherSCfg))
- }
if !reflect.DeepEqual(cfg.registrarCCfg, rcv.registrarCCfg) {
t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(cfg.registrarCCfg), utils.ToJSON(rcv.registrarCCfg))
}
diff --git a/config/configsanity.go b/config/configsanity.go
index 9cd8f2c5d..4a7c5aa21 100644
--- a/config/configsanity.go
+++ b/config/configsanity.go
@@ -957,17 +957,6 @@ func (cfg *CGRConfig) checkConfigSanity() error {
return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.AdminS, connID)
}
}
- // Dispatcher sanity check
- if cfg.dispatcherSCfg.Enabled {
- for _, connID := range cfg.dispatcherSCfg.AttributeSConns {
- if strings.HasPrefix(connID, utils.MetaDispatchers) && !cfg.attributeSCfg.Enabled {
- return fmt.Errorf("<%s> not enabled but requested by <%s> component", utils.AttributeS, utils.DispatcherS)
- }
- if _, has := cfg.rpcConns[connID]; !has && !strings.HasPrefix(connID, utils.MetaDispatchers) {
- return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.DispatcherS, connID)
- }
- }
- }
// Cache check
for _, connID := range cfg.cacheCfg.RemoteConns {
conn, has := cfg.rpcConns[connID]
@@ -1026,37 +1015,6 @@ func (cfg *CGRConfig) checkConfigSanity() error {
}
}
- if len(cfg.registrarCCfg.Dispatchers.RegistrarSConns) != 0 {
- if len(cfg.registrarCCfg.Dispatchers.Hosts) == 0 {
- return fmt.Errorf("<%s> missing dispatcher host IDs", utils.RegistrarC)
- }
- if cfg.registrarCCfg.Dispatchers.RefreshInterval <= 0 {
- return fmt.Errorf("<%s> the register imterval needs to be bigger than 0", utils.RegistrarC)
- }
- for tnt, hosts := range cfg.registrarCCfg.Dispatchers.Hosts {
- for _, host := range hosts {
- if !slices.Contains([]string{utils.MetaGOB, rpcclient.HTTPjson, utils.MetaJSON, rpcclient.BiRPCJSON, rpcclient.BiRPCGOB}, host.Transport) {
- return fmt.Errorf("<%s> unsupported transport <%s> for host <%s>", utils.RegistrarC, host.Transport, utils.ConcatenatedKey(tnt, host.ID))
- }
- }
- }
- for _, connID := range cfg.registrarCCfg.Dispatchers.RegistrarSConns {
- if connID == utils.MetaInternal {
- return fmt.Errorf("<%s> internal connection IDs are not supported", utils.RegistrarC)
- }
- connCfg, has := cfg.rpcConns[connID]
- if !has {
- return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.RegistrarC, connID)
- }
- if len(connCfg.Conns) != 1 {
- return fmt.Errorf("<%s> connection with id: <%s> needs to have only one host", utils.RegistrarC, connID)
- }
- if connCfg.Conns[0].Transport != rpcclient.HTTPjson {
- return fmt.Errorf("<%s> connection with id: <%s> unsupported transport <%s>", utils.RegistrarC, connID, connCfg.Conns[0].Transport)
- }
- }
- }
-
if len(cfg.registrarCCfg.RPC.RegistrarSConns) != 0 {
if len(cfg.registrarCCfg.RPC.Hosts) == 0 {
return fmt.Errorf("<%s> missing RPC host IDs", utils.RegistrarC)
diff --git a/config/configsanity_test.go b/config/configsanity_test.go
index c74b7f6fa..14bc626df 100644
--- a/config/configsanity_test.go
+++ b/config/configsanity_test.go
@@ -1412,7 +1412,6 @@ func TestConfigSanityRegistrarCRPC(t *testing.T) {
"hosts": {},
},
},
- Dispatchers: &RegistrarCCfg{},
}
expected := " the register imterval needs to be bigger than 0"
@@ -1468,77 +1467,6 @@ func TestConfigSanityRegistrarCRPC(t *testing.T) {
t.Errorf("Expecting: %+q received: %+q", expected, err)
}
}
-func TestConfigSanityRegistrarCDispatcher(t *testing.T) {
- cfg := NewDefaultCGRConfig()
-
- cfg.registrarCCfg = &RegistrarCCfgs{
- Dispatchers: &RegistrarCCfg{
- RegistrarSConns: []string{utils.MetaLocalHost},
- Hosts: map[string][]*RemoteHost{
- "hosts": {},
- },
- },
- RPC: &RegistrarCCfg{},
- }
-
- cfg.registrarCCfg.Dispatchers.Hosts = nil
- expected := " missing dispatcher host IDs"
- if err := cfg.CheckConfigSanity(); err == nil || err.Error() != expected {
- t.Errorf("Expecting: %+q received: %+q", expected, err)
- }
-
- cfg.registrarCCfg.Dispatchers.Hosts = map[string][]*RemoteHost{
- "hosts": {},
- }
-
- expected = " the register imterval needs to be bigger than 0"
- if err := cfg.CheckConfigSanity(); err == nil || err.Error() != expected {
- t.Errorf("Expecting: %+q received: %+q", expected, err)
- }
-
- cfg.registrarCCfg.Dispatchers.Hosts = nil
- cfg.registrarCCfg.Dispatchers.RefreshInterval = 2
- cfg.registrarCCfg.Dispatchers.Hosts = map[string][]*RemoteHost{
- "hosts": {
- {
- ID: "randomID",
- },
- },
- }
- expected = " unsupported transport <> for host "
- if err := cfg.CheckConfigSanity(); err == nil || err.Error() != expected {
- t.Errorf("Expecting: %+q received: %+q", expected, err)
- }
-
- cfg.registrarCCfg.Dispatchers.Hosts["hosts"][0].Transport = utils.MetaJSON
-
- cfg.registrarCCfg.Dispatchers.RegistrarSConns = []string{utils.MetaInternal}
- expected = " internal connection IDs are not supported"
- if err := cfg.CheckConfigSanity(); err == nil || err.Error() != expected {
- t.Errorf("Expecting: %+q received: %+q", expected, err)
- }
-
- cfg.registrarCCfg.Dispatchers.RegistrarSConns = []string{utils.MetaLocalHost}
- expected = " connection with id: <*localhost> unsupported transport <*json>"
- if err := cfg.CheckConfigSanity(); err == nil || err.Error() != expected {
- t.Errorf("Expecting: %+q received: %+q", expected, err)
- }
-
- cfg.registrarCCfg.Dispatchers.RegistrarSConns = []string{"*conn1"}
- expected = " connection with id: <*conn1> not defined"
- if err := cfg.CheckConfigSanity(); err == nil || err.Error() != expected {
- t.Errorf("Expecting: %+q received: %+q", expected, err)
- }
-
- cfg.rpcConns = RPCConns{
- utils.MetaLocalHost: {},
- "*conn1": {},
- }
- expected = " connection with id: <*conn1> needs to have only one host"
- if err := cfg.CheckConfigSanity(); err == nil || err.Error() != expected {
- t.Errorf("Expecting: %+q received: %+q", expected, err)
- }
-}
func TestConfigSanityAnalyzer(t *testing.T) {
cfg := NewDefaultCGRConfig()
@@ -1696,22 +1624,6 @@ func TestConfigSanityAPIer(t *testing.T) {
}
}
-func TestConfigSanityDispatcher(t *testing.T) {
- cfg := NewDefaultCGRConfig()
- cfg.dispatcherSCfg = &DispatcherSCfg{
- Enabled: true,
- AttributeSConns: []string{utils.MetaDispatchers},
- }
- if err := cfg.checkConfigSanity(); err == nil || err.Error() != " not enabled but requested by component" {
- t.Error(err)
- }
- cfg.dispatcherSCfg.AttributeSConns = []string{"test"}
- expected := " connection with id: not defined"
- if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected {
- t.Errorf("Expecting: %+q received: %+q", expected, err)
- }
-}
-
func TestConfigSanityCacheS(t *testing.T) {
cfg := NewDefaultCGRConfig()
diff --git a/config/datadbcfg_test.go b/config/datadbcfg_test.go
index 8e007e733..d2468e187 100644
--- a/config/datadbcfg_test.go
+++ b/config/datadbcfg_test.go
@@ -421,8 +421,7 @@ func TestDataDbCfgloadFromJsonCfgItems(t *testing.T) {
"redisSentinel":"sentinel", // redisSentinel is the name of sentinel
},
"remote_conns":["Conn1"],
- "items":{
- "*dispatcher_hosts":{"remote":true, "replicate":true},
+ "items":{
"*load_ids":{"remote":true, "replicate":true},
}
@@ -441,11 +440,6 @@ func TestDataDbCfgloadFromJsonCfgItems(t *testing.T) {
},
RmtConns: []string{"Conn1"},
Items: map[string]*ItemOpts{
- utils.MetaDispatcherHosts: {
- Limit: -1,
- Remote: true,
- Replicate: true,
- },
utils.MetaLoadIDs: {
Limit: -1,
Remote: true,
diff --git a/config/dispatcherscfg.go b/config/dispatcherscfg.go
deleted file mode 100644
index c4900610e..000000000
--- a/config/dispatcherscfg.go
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package config
-
-import (
- "slices"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/utils"
-)
-
-const (
- DispatchersDispatchersDftOpt = true
-)
-
-type DispatchersOpts struct {
- Dispatchers []*DynamicBoolOpt
-}
-
-// DispatcherSCfg is the configuration of dispatcher service
-type DispatcherSCfg struct {
- Enabled bool
- IndexedSelects bool
- StringIndexedFields *[]string
- PrefixIndexedFields *[]string
- SuffixIndexedFields *[]string
- ExistsIndexedFields *[]string
- NotExistsIndexedFields *[]string
- NestedFields bool
- AttributeSConns []string
- Opts *DispatchersOpts
-}
-
-// loadDispatcherSCfg loads the DispatcherS section of the configuration
-func (dps *DispatcherSCfg) Load(ctx *context.Context, jsnCfg ConfigDB, _ *CGRConfig) (err error) {
- jsnDispatcherSCfg := new(DispatcherSJsonCfg)
- if err = jsnCfg.GetSection(ctx, DispatcherSJSON, jsnDispatcherSCfg); err != nil {
- return
- }
- return dps.loadFromJSONCfg(jsnDispatcherSCfg)
-}
-
-func (dspOpts *DispatchersOpts) loadFromJSONCfg(jsnCfg *DispatchersOptsJson) {
- if jsnCfg == nil {
- return
- }
- if jsnCfg.Dispatchers != nil {
- dspOpts.Dispatchers = append(dspOpts.Dispatchers, jsnCfg.Dispatchers...)
- }
-}
-
-func (dps *DispatcherSCfg) loadFromJSONCfg(jsnCfg *DispatcherSJsonCfg) (err error) {
- if jsnCfg == nil {
- return
- }
- if jsnCfg.Enabled != nil {
- dps.Enabled = *jsnCfg.Enabled
- }
- if jsnCfg.Indexed_selects != nil {
- dps.IndexedSelects = *jsnCfg.Indexed_selects
- }
- if jsnCfg.String_indexed_fields != nil {
- dps.StringIndexedFields = utils.SliceStringPointer(slices.Clone(*jsnCfg.String_indexed_fields))
- }
- if jsnCfg.Prefix_indexed_fields != nil {
- dps.PrefixIndexedFields = utils.SliceStringPointer(slices.Clone(*jsnCfg.Prefix_indexed_fields))
- }
- if jsnCfg.Suffix_indexed_fields != nil {
- dps.SuffixIndexedFields = utils.SliceStringPointer(slices.Clone(*jsnCfg.Suffix_indexed_fields))
- }
- if jsnCfg.Exists_indexed_fields != nil {
- dps.ExistsIndexedFields = utils.SliceStringPointer(slices.Clone(*jsnCfg.Exists_indexed_fields))
- }
- if jsnCfg.Notexists_indexed_fields != nil {
- dps.NotExistsIndexedFields = utils.SliceStringPointer(slices.Clone(*jsnCfg.Notexists_indexed_fields))
- }
- if jsnCfg.Attributes_conns != nil {
- dps.AttributeSConns = updateInternalConnsWithPrfx(*jsnCfg.Attributes_conns, utils.MetaAttributes, utils.MetaDispatchers)
- }
- if jsnCfg.Nested_fields != nil {
- dps.NestedFields = *jsnCfg.Nested_fields
- }
- if jsnCfg.Opts != nil {
- dps.Opts.loadFromJSONCfg(jsnCfg.Opts)
- }
- return
-}
-
-// AsMapInterface returns the config as a map[string]any
-func (dps DispatcherSCfg) AsMapInterface(string) any {
- opts := map[string]any{
- utils.MetaDispatcherSCfg: dps.Opts.Dispatchers,
- }
- mp := map[string]any{
- utils.EnabledCfg: dps.Enabled,
- utils.IndexedSelectsCfg: dps.IndexedSelects,
- utils.NestedFieldsCfg: dps.NestedFields,
- utils.OptsCfg: opts,
- }
- if dps.StringIndexedFields != nil {
- mp[utils.StringIndexedFieldsCfg] = slices.Clone(*dps.StringIndexedFields)
- }
- if dps.PrefixIndexedFields != nil {
- mp[utils.PrefixIndexedFieldsCfg] = slices.Clone(*dps.PrefixIndexedFields)
- }
- if dps.SuffixIndexedFields != nil {
- mp[utils.SuffixIndexedFieldsCfg] = slices.Clone(*dps.SuffixIndexedFields)
- }
- if dps.AttributeSConns != nil {
- mp[utils.AttributeSConnsCfg] = getInternalJSONConnsWithPrfx(dps.AttributeSConns, utils.MetaDispatchers)
- }
- if dps.ExistsIndexedFields != nil {
- mp[utils.ExistsIndexedFieldsCfg] = slices.Clone(*dps.ExistsIndexedFields)
- }
- if dps.NotExistsIndexedFields != nil {
- mp[utils.NotExistsIndexedFieldsCfg] = slices.Clone(*dps.NotExistsIndexedFields)
- }
- return mp
-}
-
-func (DispatcherSCfg) SName() string { return DispatcherSJSON }
-func (dps DispatcherSCfg) CloneSection() Section { return dps.Clone() }
-
-func (dspOpts *DispatchersOpts) Clone() *DispatchersOpts {
- var dpS []*DynamicBoolOpt
- if dspOpts.Dispatchers != nil {
- dpS = CloneDynamicBoolOpt(dspOpts.Dispatchers)
- }
- return &DispatchersOpts{
- Dispatchers: dpS,
- }
-}
-
-// Clone returns a deep copy of DispatcherSCfg
-func (dps DispatcherSCfg) Clone() (cln *DispatcherSCfg) {
- cln = &DispatcherSCfg{
- Enabled: dps.Enabled,
- IndexedSelects: dps.IndexedSelects,
- NestedFields: dps.NestedFields,
- Opts: dps.Opts.Clone(),
- }
-
- if dps.AttributeSConns != nil {
- cln.AttributeSConns = slices.Clone(dps.AttributeSConns)
- }
- if dps.StringIndexedFields != nil {
- cln.StringIndexedFields = utils.SliceStringPointer(slices.Clone(*dps.StringIndexedFields))
- }
- if dps.PrefixIndexedFields != nil {
- cln.PrefixIndexedFields = utils.SliceStringPointer(slices.Clone(*dps.PrefixIndexedFields))
- }
- if dps.SuffixIndexedFields != nil {
- cln.SuffixIndexedFields = utils.SliceStringPointer(slices.Clone(*dps.SuffixIndexedFields))
- }
- if dps.ExistsIndexedFields != nil {
- cln.ExistsIndexedFields = utils.SliceStringPointer(slices.Clone(*dps.ExistsIndexedFields))
- }
- if dps.NotExistsIndexedFields != nil {
- cln.NotExistsIndexedFields = utils.SliceStringPointer(slices.Clone(*dps.NotExistsIndexedFields))
- }
- return
-}
-
-type DispatchersOptsJson struct {
- Dispatchers []*DynamicBoolOpt `json:"*dispatchers"`
-}
-
-type DispatcherSJsonCfg struct {
- Enabled *bool
- Indexed_selects *bool
- String_indexed_fields *[]string
- Prefix_indexed_fields *[]string
- Suffix_indexed_fields *[]string
- Exists_indexed_fields *[]string
- Notexists_indexed_fields *[]string
- Nested_fields *bool // applies when indexed fields is not defined
- Attributes_conns *[]string
- Opts *DispatchersOptsJson
-}
-
-func diffDispatchersOptsJsonCfg(d *DispatchersOptsJson, v1, v2 *DispatchersOpts) *DispatchersOptsJson {
- if d == nil {
- d = new(DispatchersOptsJson)
- }
- if !DynamicBoolOptEqual(v1.Dispatchers, v2.Dispatchers) {
- d.Dispatchers = v2.Dispatchers
- }
- return d
-}
-
-func diffDispatcherSJsonCfg(d *DispatcherSJsonCfg, v1, v2 *DispatcherSCfg) *DispatcherSJsonCfg {
- if d == nil {
- d = new(DispatcherSJsonCfg)
- }
- if v1.Enabled != v2.Enabled {
- d.Enabled = utils.BoolPointer(v2.Enabled)
- }
- if v1.IndexedSelects != v2.IndexedSelects {
- d.Indexed_selects = utils.BoolPointer(v2.IndexedSelects)
- }
- d.String_indexed_fields = diffIndexSlice(d.String_indexed_fields, v1.StringIndexedFields, v2.StringIndexedFields)
- d.Prefix_indexed_fields = diffIndexSlice(d.Prefix_indexed_fields, v1.PrefixIndexedFields, v2.PrefixIndexedFields)
- d.Suffix_indexed_fields = diffIndexSlice(d.Suffix_indexed_fields, v1.SuffixIndexedFields, v2.SuffixIndexedFields)
- d.Exists_indexed_fields = diffIndexSlice(d.Exists_indexed_fields, v1.ExistsIndexedFields, v2.ExistsIndexedFields)
- d.Notexists_indexed_fields = diffIndexSlice(d.Notexists_indexed_fields, v1.NotExistsIndexedFields, v2.NotExistsIndexedFields)
- if v1.NestedFields != v2.NestedFields {
- d.Nested_fields = utils.BoolPointer(v2.NestedFields)
- }
- if !slices.Equal(v1.AttributeSConns, v2.AttributeSConns) {
- d.Attributes_conns = utils.SliceStringPointer(getInternalJSONConns(v2.AttributeSConns))
- }
- d.Opts = diffDispatchersOptsJsonCfg(d.Opts, v1.Opts, v2.Opts)
- return d
-}
diff --git a/config/dispatcherscfg_test.go b/config/dispatcherscfg_test.go
deleted file mode 100644
index d78c71935..000000000
--- a/config/dispatcherscfg_test.go
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package config
-
-import (
- "reflect"
- "testing"
-
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDispatcherSCfgloadFromJsonCfg(t *testing.T) {
- jsonCfg := &DispatcherSJsonCfg{
- Enabled: utils.BoolPointer(true),
- Indexed_selects: utils.BoolPointer(true),
- String_indexed_fields: &[]string{"*req.prefix", "*req.indexed"},
- Prefix_indexed_fields: &[]string{"*req.prefix", "*req.indexed", "*req.fields"},
- Suffix_indexed_fields: &[]string{"*req.prefix", "*req.indexed", "*req.fields"},
- Exists_indexed_fields: &[]string{"*req.prefix", "*req.indexed", "*req.fields"},
- Notexists_indexed_fields: &[]string{"*req.prefix", "*req.indexed", "*req.fields"},
- Attributes_conns: &[]string{utils.MetaInternal, "*conn1"},
- Nested_fields: utils.BoolPointer(true),
- }
- expected := &DispatcherSCfg{
- Enabled: true,
- IndexedSelects: true,
- StringIndexedFields: &[]string{"*req.prefix", "*req.indexed"},
- PrefixIndexedFields: &[]string{"*req.prefix", "*req.indexed", "*req.fields"},
- SuffixIndexedFields: &[]string{"*req.prefix", "*req.indexed", "*req.fields"},
- ExistsIndexedFields: &[]string{"*req.prefix", "*req.indexed", "*req.fields"},
- NotExistsIndexedFields: &[]string{"*req.prefix", "*req.indexed", "*req.fields"},
- AttributeSConns: []string{utils.ConcatenatedKey(utils.MetaDispatchers, utils.MetaAttributes), "*conn1"},
- NestedFields: true,
- Opts: &DispatchersOpts{
- []*DynamicBoolOpt{},
- },
- }
- jsnCfg := NewDefaultCGRConfig()
- if err := jsnCfg.dispatcherSCfg.loadFromJSONCfg(jsonCfg); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, jsnCfg.dispatcherSCfg) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(jsnCfg.dispatcherSCfg))
- }
- jsonCfg = nil
- if err := jsnCfg.dispatcherSCfg.loadFromJSONCfg(jsonCfg); err != nil {
- t.Error(err)
- }
-}
-
-func TestDispatcherSCfgAsMapInterface(t *testing.T) {
- cfgJSONStr := `{
- "dispatchers":{
- "enabled": false,
- "indexed_selects":true,
- "prefix_indexed_fields": [],
- "suffix_indexed_fields": [],
- "exists_indexed_fields": [],
- "notexists_indexed_fields": [],
- "nested_fields": false,
- "attributes_conns": [],
- },
-
-}`
- eMap := map[string]any{
- utils.EnabledCfg: false,
- utils.IndexedSelectsCfg: true,
- utils.PrefixIndexedFieldsCfg: []string{},
- utils.SuffixIndexedFieldsCfg: []string{},
- utils.ExistsIndexedFieldsCfg: []string{},
- utils.NotExistsIndexedFieldsCfg: []string{},
- utils.NestedFieldsCfg: false,
- utils.AttributeSConnsCfg: []string{},
- utils.OptsCfg: map[string]any{
- utils.MetaDispatcherSCfg: []*DynamicBoolOpt{},
- },
- }
- if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
- t.Error(err)
- } else if rcv := cgrCfg.dispatcherSCfg.AsMapInterface(""); !reflect.DeepEqual(eMap, rcv) {
- t.Errorf("Expected %+v, received %+v", eMap, rcv)
- }
-}
-
-func TestDispatcherSCfgAsMapInterface1(t *testing.T) {
- cfgJSONStr := `{
- "dispatchers":{
- "enabled": false,
- "indexed_selects":true,
- "string_indexed_fields": ["*req.prefix"],
- "prefix_indexed_fields": ["*req.prefix","*req.indexed","*req.fields"],
- "suffix_indexed_fields": ["*req.prefix"],
- "exists_indexed_fields": ["*req.prefix","*req.indexed","*req.fields"],
- "notexists_indexed_fields": ["*req.prefix"],
- "nested_fields": false,
- "attributes_conns": ["*internal", "*conn1"],
- },
-
-}`
- eMap := map[string]any{
- utils.EnabledCfg: false,
- utils.IndexedSelectsCfg: true,
- utils.StringIndexedFieldsCfg: []string{"*req.prefix"},
- utils.PrefixIndexedFieldsCfg: []string{"*req.prefix", "*req.indexed", "*req.fields"},
- utils.SuffixIndexedFieldsCfg: []string{"*req.prefix"},
- utils.ExistsIndexedFieldsCfg: []string{"*req.prefix", "*req.indexed", "*req.fields"},
- utils.NotExistsIndexedFieldsCfg: []string{"*req.prefix"},
- utils.NestedFieldsCfg: false,
- utils.AttributeSConnsCfg: []string{"*internal", "*conn1"},
- utils.OptsCfg: map[string]any{
- utils.MetaDispatcherSCfg: []*DynamicBoolOpt{},
- },
- }
- if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
- t.Error(err)
- } else if rcv := cgrCfg.dispatcherSCfg.AsMapInterface(""); !reflect.DeepEqual(eMap, rcv) {
- t.Errorf("Expected %+v, received %+v", eMap, rcv)
- }
-}
-
-func TestDispatcherSCfgAsMapInterface2(t *testing.T) {
- cfgJSONStr := `{
- "dispatchers":{},
-}`
- eMap := map[string]any{
- utils.EnabledCfg: false,
- utils.IndexedSelectsCfg: true,
- utils.PrefixIndexedFieldsCfg: []string{},
- utils.SuffixIndexedFieldsCfg: []string{},
- utils.ExistsIndexedFieldsCfg: []string{},
- utils.NotExistsIndexedFieldsCfg: []string{},
- utils.NestedFieldsCfg: false,
- utils.AttributeSConnsCfg: []string{},
- utils.OptsCfg: map[string]any{
- utils.MetaDispatcherSCfg: []*DynamicBoolOpt{},
- },
- }
- if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
- t.Error(err)
- } else if rcv := cgrCfg.dispatcherSCfg.AsMapInterface(""); !reflect.DeepEqual(eMap, rcv) {
- t.Errorf("Expected %+v, received %+v", eMap, rcv)
- }
-}
-func TestDispatcherSCfgClone(t *testing.T) {
- ban := &DispatcherSCfg{
- Enabled: true,
- IndexedSelects: true,
- StringIndexedFields: &[]string{"*req.prefix", "*req.indexed"},
- PrefixIndexedFields: &[]string{"*req.prefix", "*req.indexed", "*req.fields"},
- SuffixIndexedFields: &[]string{"*req.prefix", "*req.indexed", "*req.fields"},
- ExistsIndexedFields: &[]string{"*req.prefix", "*req.indexed", "*req.fields"},
- NotExistsIndexedFields: &[]string{"*req.prefix", "*req.indexed", "*req.fields"},
- AttributeSConns: []string{utils.ConcatenatedKey(utils.MetaDispatchers, utils.MetaAttributes), "*conn1"},
- NestedFields: true,
- Opts: &DispatchersOpts{},
- }
- rcv := ban.Clone()
- if !reflect.DeepEqual(ban, rcv) {
- t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(ban), utils.ToJSON(rcv))
- }
- if rcv.AttributeSConns[1] = ""; ban.AttributeSConns[1] != "*conn1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
-
- if (*rcv.StringIndexedFields)[0] = ""; (*ban.StringIndexedFields)[0] != "*req.prefix" {
- t.Errorf("Expected clone to not modify the cloned")
- }
-
- if (*rcv.PrefixIndexedFields)[0] = ""; (*ban.PrefixIndexedFields)[0] != "*req.prefix" {
- t.Errorf("Expected clone to not modify the cloned")
- }
- if (*rcv.SuffixIndexedFields)[0] = ""; (*ban.SuffixIndexedFields)[0] != "*req.prefix" {
- t.Errorf("Expected clone to not modify the cloned")
- }
-}
-
-func TestDispatcherSJsonCfg(t *testing.T) {
- var d *DispatcherSJsonCfg
-
- v1 := &DispatcherSCfg{
- Enabled: false,
- IndexedSelects: false,
- StringIndexedFields: &[]string{"*req.Field1"},
- PrefixIndexedFields: nil,
- SuffixIndexedFields: nil,
- NestedFields: true,
- AttributeSConns: []string{"*localhost"},
- Opts: &DispatchersOpts{},
- }
-
- v2 := &DispatcherSCfg{
- Enabled: true,
- IndexedSelects: true,
- StringIndexedFields: &[]string{"*req.Field2"},
- PrefixIndexedFields: &[]string{},
- SuffixIndexedFields: &[]string{},
- NestedFields: false,
- AttributeSConns: []string{"*birpc"},
- Opts: &DispatchersOpts{},
- }
-
- expected := &DispatcherSJsonCfg{
- Enabled: utils.BoolPointer(true),
- Indexed_selects: utils.BoolPointer(true),
- String_indexed_fields: &[]string{"*req.Field2"},
- Prefix_indexed_fields: &[]string{},
- Suffix_indexed_fields: &[]string{},
- Nested_fields: utils.BoolPointer(false),
- Attributes_conns: &[]string{"*birpc"},
- Opts: &DispatchersOptsJson{},
- }
-
- rcv := diffDispatcherSJsonCfg(d, v1, v2)
- if !reflect.DeepEqual(rcv, expected) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
-
- v2_2 := v1
- expected2 := &DispatcherSJsonCfg{
- Opts: &DispatchersOptsJson{},
- }
-
- rcv = diffDispatcherSJsonCfg(d, v1, v2_2)
- if !reflect.DeepEqual(rcv, expected2) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected2), utils.ToJSON(rcv))
- }
-}
-
-func TestDispatcherSCfgCloneTest(t *testing.T) {
- dspCfg := &DispatcherSCfg{
- Enabled: false,
- IndexedSelects: false,
- StringIndexedFields: &[]string{"*req.Field1"},
- PrefixIndexedFields: nil,
- SuffixIndexedFields: nil,
- NestedFields: true,
- AttributeSConns: []string{"*localhost"},
- Opts: &DispatchersOpts{},
- }
-
- exp := &DispatcherSCfg{
- Enabled: false,
- IndexedSelects: false,
- StringIndexedFields: &[]string{"*req.Field1"},
- PrefixIndexedFields: nil,
- SuffixIndexedFields: nil,
- NestedFields: true,
- AttributeSConns: []string{"*localhost"},
- Opts: &DispatchersOpts{},
- }
-
- rcv := dspCfg.CloneSection()
- if !reflect.DeepEqual(rcv, exp) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(rcv))
- }
-}
-
-func TestDispatchersOptsLoadFromJSONCfgNil(t *testing.T) {
- var jsnCfg *DispatchersOptsJson
- dspOpts := &DispatchersOpts{
- Dispatchers: []*DynamicBoolOpt{
- {
- Tenant: "Filler val",
- },
- },
- }
- dspOptsClone := dspOpts.Clone()
- dspOpts.loadFromJSONCfg(jsnCfg)
- if !reflect.DeepEqual(dspOptsClone, dspOpts) {
- t.Errorf("Expected DispatcherSCfg to not change. Was <%+v>\n,now is <%+v>", dspOptsClone, dspOpts)
- }
-}
-
-func TestDiffDispatchersOptsJsonCfg(t *testing.T) {
- var d *DispatchersOptsJson
-
- v1 := &DispatchersOpts{
- Dispatchers: []*DynamicBoolOpt{
- {
- Tenant: "1",
- },
- },
- }
-
- v2 := &DispatchersOpts{
- Dispatchers: []*DynamicBoolOpt{
- {
- Tenant: "2",
- },
- },
- }
-
- expected := &DispatchersOptsJson{
- Dispatchers: []*DynamicBoolOpt{
- {
- Tenant: "2",
- },
- },
- }
-
- rcv := diffDispatchersOptsJsonCfg(d, v1, v2)
- if !reflect.DeepEqual(rcv, expected) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
-
- v2_2 := v1
- expected2 := &DispatchersOptsJson{}
-
- rcv = diffDispatchersOptsJsonCfg(d, v1, v2_2)
- if !reflect.DeepEqual(rcv, expected2) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected2), utils.ToJSON(rcv))
- }
-}
diff --git a/config/loaderscfg_test.go b/config/loaderscfg_test.go
index 0decf34f5..a847007ae 100644
--- a/config/loaderscfg_test.go
+++ b/config/loaderscfg_test.go
@@ -69,20 +69,18 @@ func TestLoaderSCfgloadFromJsonCfgCase1(t *testing.T) {
WithIndex: true,
},
Cache: map[string]*CacheParamCfg{
- utils.MetaFilters: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaAttributes: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaResources: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaStats: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaThresholds: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaRoutes: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaChargers: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaDispatchers: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaDispatcherHosts: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaRateProfiles: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaActionProfiles: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaAccounts: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaTrends: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaRankings: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaFilters: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaAttributes: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaResources: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaStats: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaThresholds: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaRoutes: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaChargers: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaRateProfiles: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaActionProfiles: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaAccounts: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaTrends: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaRankings: {Limit: -1, TTL: 5 * time.Second},
},
Data: []*LoaderDataType{
{
@@ -583,174 +581,6 @@ func TestLoaderSCfgloadFromJsonCfgCase1(t *testing.T) {
Layout: time.RFC3339},
},
},
- {
- Type: utils.MetaDispatchers,
- Flags: flags,
- Filename: utils.DispatcherProfilesCsv,
- Fields: []*FCTemplate{
- {Tag: "Tenant",
- Path: "Tenant",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.0", utils.InfieldSep),
- Mandatory: true,
- Layout: time.RFC3339},
- {Tag: "ID",
- Path: "ID",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.1", utils.InfieldSep),
- Mandatory: true,
- Layout: time.RFC3339},
- {Tag: "FilterIDs",
- Path: "FilterIDs",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.2", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "Weight",
- Path: "Weight",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.3", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "Strategy",
- Path: "Strategy",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.4", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "StrategyParameters",
- Path: "StrategyParams",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.5", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "ConnID",
- Path: "Hosts.ID",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.6", utils.InfieldSep),
- Layout: time.RFC3339,
- NewBranch: true,
- },
- {Tag: "ConnFilterIDs",
- Path: "Hosts.FilterIDs",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.7", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "ConnWeight",
- Path: "Hosts.Weight",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.8", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "ConnBlocker",
- Path: "Hosts.Blocker",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.9", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "ConnParameters",
- Path: "Hosts.Params",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.10", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- },
- },
- {
- Type: utils.MetaDispatcherHosts,
- Flags: flags,
- Filename: utils.DispatcherHostsCsv,
- Fields: []*FCTemplate{
- {Tag: "Tenant",
- Path: "Tenant",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.0", utils.InfieldSep),
- Mandatory: true,
- Layout: time.RFC3339},
- {Tag: "ID",
- Path: "ID",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.1", utils.InfieldSep),
- Mandatory: true,
- Layout: time.RFC3339},
- {Tag: "Address",
- Path: "Address",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.2", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {Tag: "Transport",
- Path: "Transport",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.3", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "ConnectAttempts",
- Path: "ConnectAttempts",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.4", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "Reconnects",
- Path: "Reconnects",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.5", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "MaxReconnectInterval",
- Path: "MaxReconnectInterval",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.6", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "ConnectTimeout",
- Path: "ConnectTimeout",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.7", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "ReplyTimeout",
- Path: "ReplyTimeout",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.8", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "TLS",
- Path: "TLS",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.9", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "ClientKey",
- Path: "ClientKey",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.10", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "ClientCertificate",
- Path: "ClientCertificate",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.11", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- {
- Tag: "CaCertificate",
- Path: "CaCertificate",
- Type: utils.MetaVariable,
- Value: NewRSRParsersMustCompile("~*req.12", utils.InfieldSep),
- Layout: time.RFC3339,
- },
- },
- },
{
Type: utils.MetaRateProfiles,
Flags: flags,
@@ -1862,169 +1692,6 @@ func TestLoaderCfgAsMapInterfaceCase1(t *testing.T) {
},
},
},
- {
- utils.TypeCfg: "*dispatchers",
- utils.FilenameCfg: "DispatcherProfiles.csv",
- utils.FlagsCfg: flags,
- utils.FieldsCfg: []map[string]any{
- {
- utils.TagCfg: "Tenant",
- utils.PathCfg: "Tenant",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.0",
- utils.MandatoryCfg: true,
- },
- {
- utils.TagCfg: "ID",
- utils.PathCfg: "ID",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.1",
- utils.MandatoryCfg: true,
- },
- {
- utils.TagCfg: "FilterIDs",
- utils.PathCfg: "FilterIDs",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.2",
- },
- {
- utils.TagCfg: "Weight",
- utils.PathCfg: "Weight",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.3",
- },
- {
- utils.TagCfg: "Strategy",
- utils.PathCfg: "Strategy",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.4",
- },
- {
- utils.TagCfg: "StrategyParameters",
- utils.PathCfg: "StrategyParams",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.5",
- },
- {
- utils.NewBranchCfg: true,
- utils.TagCfg: "ConnID",
- utils.PathCfg: "Hosts.ID",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.6",
- },
- {
- utils.TagCfg: "ConnFilterIDs",
- utils.PathCfg: "Hosts.FilterIDs",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.7",
- },
- {
- utils.TagCfg: "ConnWeight",
- utils.PathCfg: "Hosts.Weight",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.8",
- },
- {
- utils.TagCfg: "ConnBlocker",
- utils.PathCfg: "Hosts.Blocker",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.9",
- },
- {
- utils.TagCfg: "ConnParameters",
- utils.PathCfg: "Hosts.Params",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.10",
- },
- },
- },
- {
- utils.TypeCfg: "*dispatcher_hosts",
- utils.FilenameCfg: "DispatcherHosts.csv",
- utils.FlagsCfg: flags,
- utils.FieldsCfg: []map[string]any{
- {
- utils.TagCfg: "Tenant",
- utils.PathCfg: "Tenant",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.0",
- utils.MandatoryCfg: true,
- },
- {
- utils.TagCfg: "ID",
- utils.PathCfg: "ID",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.1",
- utils.MandatoryCfg: true,
- },
- {
- utils.TagCfg: "Address",
- utils.PathCfg: "Address",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.2",
- },
- {
- utils.TagCfg: "Transport",
- utils.PathCfg: "Transport",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.3",
- },
- {
- utils.TagCfg: "ConnectAttempts",
- utils.PathCfg: "ConnectAttempts",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.4",
- },
- {
- utils.TagCfg: "Reconnects",
- utils.PathCfg: "Reconnects",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.5",
- },
- {
- utils.TagCfg: "MaxReconnectInterval",
- utils.PathCfg: "MaxReconnectInterval",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.6",
- },
- {
- utils.TagCfg: "ConnectTimeout",
- utils.PathCfg: "ConnectTimeout",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.7",
- },
- {
- utils.TagCfg: "ReplyTimeout",
- utils.PathCfg: "ReplyTimeout",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.8",
- },
- {
- utils.TagCfg: "TLS",
- utils.PathCfg: "TLS",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.9",
- },
- {
- utils.TagCfg: "ClientKey",
- utils.PathCfg: "ClientKey",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.10",
- },
- {
- utils.TagCfg: "ClientCertificate",
- utils.PathCfg: "ClientCertificate",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.11",
- },
- {
- utils.TagCfg: "CaCertificate",
- utils.PathCfg: "CaCertificate",
- utils.TypeCfg: "*variable",
- utils.ValueCfg: "~*req.12",
- },
- },
- },
{
utils.TypeCfg: "*rate_profiles",
utils.FilenameCfg: "Rates.csv",
@@ -2357,20 +2024,18 @@ func TestLoaderCfgAsMapInterfaceCase1(t *testing.T) {
},
},
utils.CacheCfg: map[string]any{
- utils.MetaFilters: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaAttributes: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaResources: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaStats: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaThresholds: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaRoutes: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaChargers: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaDispatchers: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaDispatcherHosts: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaRateProfiles: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaActionProfiles: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaAccounts: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaRankings: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
- utils.MetaTrends: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaFilters: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaAttributes: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaResources: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaStats: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaThresholds: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaRoutes: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaChargers: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaRateProfiles: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaActionProfiles: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaAccounts: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaRankings: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
+ utils.MetaTrends: map[string]any{utils.LimitCfg: -1, utils.TTLCfg: "5s", utils.PrecacheCfg: false, utils.RemoteCfg: false, utils.ReplicateCfg: false, utils.StaticTTLCfg: false},
},
},
}
@@ -2481,18 +2146,16 @@ func TestLoaderSCfgsClone(t *testing.T) {
},
Opts: &LoaderSOptsCfg{},
Cache: map[string]*CacheParamCfg{
- utils.MetaFilters: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaAttributes: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaResources: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaStats: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaThresholds: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaRoutes: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaChargers: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaDispatchers: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaDispatcherHosts: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaRateProfiles: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaActionProfiles: {Limit: -1, TTL: 5 * time.Second},
- utils.MetaAccounts: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaFilters: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaAttributes: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaResources: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaStats: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaThresholds: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaRoutes: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaChargers: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaRateProfiles: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaActionProfiles: {Limit: -1, TTL: 5 * time.Second},
+ utils.MetaAccounts: {Limit: -1, TTL: 5 * time.Second},
},
}}
rcv := ban.Clone()
diff --git a/config/registrarccfg.go b/config/registrarccfg.go
index e48f762e6..8806d72fc 100644
--- a/config/registrarccfg.go
+++ b/config/registrarccfg.go
@@ -26,10 +26,9 @@ import (
"github.com/cgrates/cgrates/utils"
)
-// RegistrarCCfgs is the configuration of registrarc rpc and dispatcher
+// RegistrarCCfgs is the configuration of registrarc rpc
type RegistrarCCfgs struct {
- RPC *RegistrarCCfg
- Dispatchers *RegistrarCCfg
+ RPC *RegistrarCCfg
}
// loadRegistrarCCfg loads the RegistrarC section of the configuration
@@ -45,17 +44,13 @@ func (dps *RegistrarCCfgs) loadFromJSONCfg(jsnCfg *RegistrarCJsonCfgs) (err erro
if jsnCfg == nil {
return nil
}
- if err = dps.RPC.loadFromJSONCfg(jsnCfg.RPC); err != nil {
- return
- }
- return dps.Dispatchers.loadFromJSONCfg(jsnCfg.Dispatchers)
+ return dps.RPC.loadFromJSONCfg(jsnCfg.RPC)
}
// AsMapInterface returns the config as a map[string]any
func (dps RegistrarCCfgs) AsMapInterface(string) any {
return map[string]any{
- utils.RPCCfg: dps.RPC.AsMapInterface(),
- utils.DispatcherCfg: dps.Dispatchers.AsMapInterface(),
+ utils.RPCCfg: dps.RPC.AsMapInterface(),
}
}
@@ -65,8 +60,7 @@ func (dps RegistrarCCfgs) CloneSection() Section { return dps.Clone() }
// Clone returns a deep copy of DispatcherHCfg
func (dps RegistrarCCfgs) Clone() (cln *RegistrarCCfgs) {
return &RegistrarCCfgs{
- RPC: dps.RPC.Clone(),
- Dispatchers: dps.Dispatchers.Clone(),
+ RPC: dps.RPC.Clone(),
}
}
@@ -198,8 +192,7 @@ func diffRegistrarCJsonCfg(d *RegistrarCJsonCfg, v1, v2 *RegistrarCCfg) *Registr
}
type RegistrarCJsonCfgs struct {
- RPC *RegistrarCJsonCfg
- Dispatchers *RegistrarCJsonCfg
+ RPC *RegistrarCJsonCfg
}
func diffRegistrarCJsonCfgs(d *RegistrarCJsonCfgs, v1, v2 *RegistrarCCfgs) *RegistrarCJsonCfgs {
@@ -207,6 +200,5 @@ func diffRegistrarCJsonCfgs(d *RegistrarCJsonCfgs, v1, v2 *RegistrarCCfgs) *Regi
d = new(RegistrarCJsonCfgs)
}
d.RPC = diffRegistrarCJsonCfg(d.RPC, v1.RPC, v2.RPC)
- d.Dispatchers = diffRegistrarCJsonCfg(d.Dispatchers, v1.Dispatchers, v2.Dispatchers)
return d
}
diff --git a/config/registrarccfg_test.go b/config/registrarccfg_test.go
index 76681f9e1..08ef3d60c 100644
--- a/config/registrarccfg_test.go
+++ b/config/registrarccfg_test.go
@@ -65,44 +65,6 @@ func TestDispatcherHCfgloadFromJsonCfg(t *testing.T) {
},
Refresh_interval: utils.StringPointer("5"),
},
- Dispatchers: &RegistrarCJsonCfg{
- Registrars_conns: &[]string{"*conn1", "*conn2"},
- Hosts: []*RemoteHostJsonWithTenant{
- {
-
- Tenant: utils.StringPointer(utils.MetaDefault),
- RemoteHostJson: &RemoteHostJson{
- Id: utils.StringPointer("Host1"),
- Transport: utils.StringPointer(utils.MetaJSON),
- },
- },
- {
- Tenant: utils.StringPointer(utils.MetaDefault),
- RemoteHostJson: &RemoteHostJson{
- Id: utils.StringPointer("Host2"),
- Transport: utils.StringPointer(utils.MetaGOB),
- },
- },
- {
-
- Tenant: utils.StringPointer("cgrates.net"),
- RemoteHostJson: &RemoteHostJson{
- Id: utils.StringPointer("Host1"),
- Transport: utils.StringPointer(utils.MetaJSON),
- Tls: utils.BoolPointer(true),
- },
- },
- {
- Tenant: utils.StringPointer("cgrates.net"),
- RemoteHostJson: &RemoteHostJson{
- Id: utils.StringPointer("Host2"),
- Transport: utils.StringPointer(utils.MetaGOB),
- Tls: utils.BoolPointer(true),
- },
- },
- },
- Refresh_interval: utils.StringPointer("5"),
- },
}
expected := &RegistrarCCfgs{
RPC: &RegistrarCCfg{
@@ -133,34 +95,6 @@ func TestDispatcherHCfgloadFromJsonCfg(t *testing.T) {
},
RefreshInterval: 5,
},
- Dispatchers: &RegistrarCCfg{
- RegistrarSConns: []string{"*conn1", "*conn2"},
- Hosts: map[string][]*RemoteHost{
- utils.MetaDefault: {
- {
- ID: "Host1",
- Transport: utils.MetaJSON,
- },
- {
- ID: "Host2",
- Transport: utils.MetaGOB,
- },
- },
- "cgrates.net": {
- {
- ID: "Host1",
- Transport: utils.MetaJSON,
- TLS: true,
- },
- {
- ID: "Host2",
- Transport: utils.MetaGOB,
- TLS: true,
- },
- },
- },
- RefreshInterval: 5,
- },
}
jsnCfg := NewDefaultCGRConfig()
if err := jsnCfg.registrarCCfg.loadFromJSONCfg(jsonCfg); err != nil {
@@ -186,176 +120,6 @@ func TestDispatcherHCfgloadFromJsonCfg(t *testing.T) {
}
}
-func TestDispatcherHCfgAsMapInterface(t *testing.T) {
- cfgJSONStr := `{
- "registrarc":{
- "rpc":{
- "registrars_conns": ["*conn1","*conn2"],
- "hosts": [
- { "Tenant":"*default",
- "ID": "Host1",
- "transport": "*json",
- "tls": false
- },
- {
- "Tenant":"*default",
- "ID": "Host2",
- "transport": "*gob",
- "tls": false
- },
- ],
- "refresh_interval": "0",
- },
- "dispatchers":{
- "registrars_conns": ["*conn1","*conn2"],
- "hosts": [
- { "Tenant":"*default",
- "ID": "Host1",
- "transport": "*json",
- "tls": false
- },
- {
- "Tenant":"*default",
- "ID": "Host2",
- "transport": "*gob",
- "tls": false
- },
- ],
- "refresh_interval": "0",
- },
- },
-}`
- eMap := map[string]any{
- utils.RPCCfg: map[string]any{
- utils.RegistrarsConnsCfg: []string{"*conn1", "*conn2"},
- utils.HostsCfg: []map[string]any{
- {
- utils.Tenant: utils.MetaDefault,
- utils.IDCfg: "Host1",
- utils.TransportCfg: "*json",
- },
- {
- utils.Tenant: utils.MetaDefault,
- utils.IDCfg: "Host2",
- utils.TransportCfg: "*gob",
- },
- },
- utils.RefreshIntervalCfg: "0",
- },
- utils.DispatcherCfg: map[string]any{
- utils.RegistrarsConnsCfg: []string{"*conn1", "*conn2"},
- utils.HostsCfg: []map[string]any{
- {
- utils.Tenant: utils.MetaDefault,
- utils.IDCfg: "Host1",
- utils.TransportCfg: "*json",
- },
- {
- utils.Tenant: utils.MetaDefault,
- utils.IDCfg: "Host2",
- utils.TransportCfg: "*gob",
- },
- },
- utils.RefreshIntervalCfg: "0",
- },
- }
- if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
- t.Error(err)
- } else if rcv := cgrCfg.registrarCCfg.AsMapInterface(""); !reflect.DeepEqual(eMap, rcv) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(eMap), utils.ToJSON(rcv))
- }
-}
-
-func TestDispatcherCfgParseWithNanoSec(t *testing.T) {
- jsonCfg := &RegistrarCJsonCfgs{
- RPC: &RegistrarCJsonCfg{
- Refresh_interval: utils.StringPointer("1ss"),
- },
- }
- expErrMessage := "time: unknown unit \"ss\" in duration \"1ss\""
- jsnCfg := NewDefaultCGRConfig()
- if err := jsnCfg.registrarCCfg.loadFromJSONCfg(jsonCfg); err == nil || err.Error() != expErrMessage {
- t.Errorf("Expected %+v \n, recevied %+v", expErrMessage, err)
- }
-}
-
-func TestDispatcherCfgParseWithNanoSec2(t *testing.T) {
- jsonCfg := &RegistrarCJsonCfgs{
- Dispatchers: &RegistrarCJsonCfg{
- Refresh_interval: utils.StringPointer("1ss"),
- },
- }
- expErrMessage := "time: unknown unit \"ss\" in duration \"1ss\""
- jsnCfg := NewDefaultCGRConfig()
- if err := jsnCfg.registrarCCfg.loadFromJSONCfg(jsonCfg); err == nil || err.Error() != expErrMessage {
- t.Errorf("Expected %+v \n, recevied %+v", expErrMessage, err)
- }
-}
-
-func TestDispatcherHCfgAsMapInterface2(t *testing.T) {
- cfgJSONStr := `{
- "registrarc": {},
-}`
- eMap := map[string]any{
- utils.DispatcherCfg: map[string]any{
- utils.RegistrarsConnsCfg: []string{},
- utils.HostsCfg: []map[string]any{},
- utils.RefreshIntervalCfg: "5m0s",
- },
- utils.RPCCfg: map[string]any{
- utils.RegistrarsConnsCfg: []string{},
- utils.HostsCfg: []map[string]any{},
- utils.RefreshIntervalCfg: "5m0s",
- },
- }
- if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
- t.Error(err)
- } else if rcv := cgrCfg.registrarCCfg.AsMapInterface(""); !reflect.DeepEqual(eMap, rcv) {
- t.Errorf("Expected %+v, received %+v", eMap, rcv)
- }
-}
-
-func TestDispatcherHCfgClone(t *testing.T) {
- ban := &RegistrarCCfg{
- RegistrarSConns: []string{"*conn1", "*conn2"},
- Hosts: map[string][]*RemoteHost{
- utils.MetaDefault: {
- {
- ID: "Host1",
- Transport: utils.MetaJSON,
- },
- {
- ID: "Host2",
- Transport: utils.MetaGOB,
- },
- },
- "cgrates.net": {
- {
- ID: "Host1",
- Transport: utils.MetaJSON,
- TLS: true,
- },
- {
- ID: "Host2",
- Transport: utils.MetaGOB,
- TLS: true,
- },
- },
- },
- RefreshInterval: 5,
- }
- rcv := ban.Clone()
- if !reflect.DeepEqual(ban, rcv) {
- t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(ban), utils.ToJSON(rcv))
- }
- if rcv.RegistrarSConns[0] = ""; ban.RegistrarSConns[0] != "*conn1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
- if rcv.Hosts[utils.MetaDefault][0].ID = ""; ban.Hosts[utils.MetaDefault][0].ID != "Host1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
-}
-
func TestDiffRegistrarCJsonCfg(t *testing.T) {
var d *RegistrarCJsonCfg
@@ -429,211 +193,3 @@ func TestDiffRegistrarCJsonCfg(t *testing.T) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
}
-
-func TestDiffRegistrarCJsonCfgs(t *testing.T) {
- var d *RegistrarCJsonCfgs
-
- v1 := &RegistrarCCfgs{
- RPC: &RegistrarCCfg{
- RegistrarSConns: []string{"*localhost"},
- Hosts: map[string][]*RemoteHost{
- "HOST_1": {
- {
- ID: "host1_ID",
- Address: "127.0.0.1:8080",
- Transport: "tcp",
- TLS: false,
- },
- },
- },
- RefreshInterval: 2 * time.Second,
- },
- Dispatchers: &RegistrarCCfg{
- RegistrarSConns: []string{"*localhost"},
- Hosts: map[string][]*RemoteHost{
- "HOST_1": {
- {
- ID: "host1_ID",
- Address: "127.0.0.1:8080",
- Transport: "tcp",
- TLS: false,
- },
- },
- },
- RefreshInterval: 2 * time.Second,
- },
- }
-
- v2 := &RegistrarCCfgs{
- RPC: &RegistrarCCfg{
- RegistrarSConns: []string{"*birpc"},
- Hosts: map[string][]*RemoteHost{
- "HOST_1": {
- {
- ID: "host2_ID",
- Address: "0.0.0.0:8080",
- Transport: "udp",
- TLS: true,
- },
- },
- },
- RefreshInterval: 4 * time.Second,
- },
- Dispatchers: &RegistrarCCfg{
- RegistrarSConns: []string{"*birpc"},
- Hosts: map[string][]*RemoteHost{
- "HOST_1": {
- {
- ID: "host2_ID",
- Address: "0.0.0.0:8080",
- Transport: "udp",
- TLS: true,
- },
- },
- },
- RefreshInterval: 4 * time.Second,
- },
- }
-
- expected := &RegistrarCJsonCfgs{
- RPC: &RegistrarCJsonCfg{
- Registrars_conns: &[]string{"*birpc"},
- Hosts: []*RemoteHostJsonWithTenant{
- {
- Tenant: utils.StringPointer("HOST_1"),
- RemoteHostJson: &RemoteHostJson{
- Id: utils.StringPointer("host2_ID"),
- Address: utils.StringPointer("0.0.0.0:8080"),
- Transport: utils.StringPointer("udp"),
- Tls: utils.BoolPointer(true),
- },
- },
- },
- Refresh_interval: utils.StringPointer("4s"),
- },
- Dispatchers: &RegistrarCJsonCfg{
- Registrars_conns: &[]string{"*birpc"},
- Hosts: []*RemoteHostJsonWithTenant{
- {
- Tenant: utils.StringPointer("HOST_1"),
- RemoteHostJson: &RemoteHostJson{
- Id: utils.StringPointer("host2_ID"),
- Address: utils.StringPointer("0.0.0.0:8080"),
- Transport: utils.StringPointer("udp"),
- Tls: utils.BoolPointer(true),
- },
- },
- },
- Refresh_interval: utils.StringPointer("4s"),
- },
- }
-
- rcv := diffRegistrarCJsonCfgs(d, v1, v2)
- if !reflect.DeepEqual(rcv, expected) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
-
- d = new(RegistrarCJsonCfgs)
- v1 = v2
- expected = &RegistrarCJsonCfgs{
- RPC: &RegistrarCJsonCfg{
- Hosts: []*RemoteHostJsonWithTenant{
- {
- Tenant: utils.StringPointer("HOST_1"),
- RemoteHostJson: &RemoteHostJson{
- Id: utils.StringPointer("host2_ID"),
- Address: utils.StringPointer("0.0.0.0:8080"),
- Transport: utils.StringPointer("udp"),
- Tls: utils.BoolPointer(true),
- },
- },
- },
- },
- Dispatchers: &RegistrarCJsonCfg{
- Hosts: []*RemoteHostJsonWithTenant{
- {
- Tenant: utils.StringPointer("HOST_1"),
- RemoteHostJson: &RemoteHostJson{
- Id: utils.StringPointer("host2_ID"),
- Address: utils.StringPointer("0.0.0.0:8080"),
- Transport: utils.StringPointer("udp"),
- Tls: utils.BoolPointer(true),
- },
- },
- },
- },
- }
- rcv = diffRegistrarCJsonCfgs(d, v1, v2)
- if !reflect.DeepEqual(rcv, expected) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
-}
-
-func TestRegristrarcCloneSection(t *testing.T) {
- rgstCfg := &RegistrarCCfgs{
- RPC: &RegistrarCCfg{
- RegistrarSConns: []string{"*localhost"},
- Hosts: map[string][]*RemoteHost{
- "HOST_1": {
- {
- ID: "host1_ID",
- Address: "127.0.0.1:8080",
- Transport: "tcp",
- TLS: false,
- },
- },
- },
- RefreshInterval: 2 * time.Second,
- },
- Dispatchers: &RegistrarCCfg{
- RegistrarSConns: []string{"*localhost"},
- Hosts: map[string][]*RemoteHost{
- "HOST_1": {
- {
- ID: "host1_ID",
- Address: "127.0.0.1:8080",
- Transport: "tcp",
- TLS: false,
- },
- },
- },
- RefreshInterval: 2 * time.Second,
- },
- }
-
- exp := &RegistrarCCfgs{
- RPC: &RegistrarCCfg{
- RegistrarSConns: []string{"*localhost"},
- Hosts: map[string][]*RemoteHost{
- "HOST_1": {
- {
- ID: "host1_ID",
- Address: "127.0.0.1:8080",
- Transport: "tcp",
- TLS: false,
- },
- },
- },
- RefreshInterval: 2 * time.Second,
- },
- Dispatchers: &RegistrarCCfg{
- RegistrarSConns: []string{"*localhost"},
- Hosts: map[string][]*RemoteHost{
- "HOST_1": {
- {
- ID: "host1_ID",
- Address: "127.0.0.1:8080",
- Transport: "tcp",
- TLS: false,
- },
- },
- },
- RefreshInterval: 2 * time.Second,
- },
- }
-
- rcv := rgstCfg.CloneSection()
- if !reflect.DeepEqual(rcv, exp) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(rcv))
- }
-}
diff --git a/console/dispatcher_host.go b/console/dispatcher_host.go
deleted file mode 100644
index 67dc0c4de..000000000
--- a/console/dispatcher_host.go
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package console
-
-import (
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func init() {
- c := &CmdGetDispatcherHost{
- name: "dispatcher_host",
- rpcMethod: utils.AdminSv1GetDispatcherHost,
- rpcParams: &utils.TenantIDWithAPIOpts{},
- }
- commands[c.Name()] = c
- c.CommandExecuter = &CommandExecuter{c}
-}
-
-// Commander implementation
-type CmdGetDispatcherHost struct {
- name string
- rpcMethod string
- rpcParams *utils.TenantIDWithAPIOpts
- *CommandExecuter
-}
-
-func (self *CmdGetDispatcherHost) Name() string {
- return self.name
-}
-
-func (self *CmdGetDispatcherHost) RpcMethod() string {
- return self.rpcMethod
-}
-
-func (self *CmdGetDispatcherHost) RpcParams(reset bool) any {
- if reset || self.rpcParams == nil {
- self.rpcParams = new(utils.TenantIDWithAPIOpts)
- }
- return self.rpcParams
-}
-
-func (self *CmdGetDispatcherHost) PostprocessRpcParams() error {
- return nil
-}
-
-func (self *CmdGetDispatcherHost) RpcResult() any {
- var s engine.DispatcherHost
- return &s
-}
diff --git a/console/dispatcher_host_ids.go b/console/dispatcher_host_ids.go
deleted file mode 100644
index a81d993e8..000000000
--- a/console/dispatcher_host_ids.go
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package console
-
-import (
- "github.com/cgrates/cgrates/utils"
-)
-
-func init() {
- c := &CmdGetDispatcherHostIDs{
- name: "dispatcher_host_ids",
- rpcMethod: utils.AdminSv1GetDispatcherHostIDs,
- rpcParams: &utils.ArgsItemIDs{},
- }
- commands[c.Name()] = c
- c.CommandExecuter = &CommandExecuter{c}
-}
-
-// Commander implementation
-type CmdGetDispatcherHostIDs struct {
- name string
- rpcMethod string
- rpcParams *utils.ArgsItemIDs
- *CommandExecuter
-}
-
-func (self *CmdGetDispatcherHostIDs) Name() string {
- return self.name
-}
-
-func (self *CmdGetDispatcherHostIDs) RpcMethod() string {
- return self.rpcMethod
-}
-
-func (self *CmdGetDispatcherHostIDs) RpcParams(reset bool) any {
- if reset || self.rpcParams == nil {
- self.rpcParams = new(utils.ArgsItemIDs)
- }
- return self.rpcParams
-}
-
-func (self *CmdGetDispatcherHostIDs) PostprocessRpcParams() error {
- return nil
-}
-
-func (self *CmdGetDispatcherHostIDs) RpcResult() any {
- var s []string
- return &s
-}
diff --git a/console/dispatcher_host_remove.go b/console/dispatcher_host_remove.go
deleted file mode 100644
index 7cc5c738d..000000000
--- a/console/dispatcher_host_remove.go
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package console
-
-import (
- "github.com/cgrates/cgrates/utils"
-)
-
-func init() {
- c := &CmdRemoveDispatcherHost{
- name: "dispatcher_host_remove",
- rpcMethod: utils.AdminSv1RemoveDispatcherHost,
- rpcParams: &utils.TenantIDWithAPIOpts{},
- }
- commands[c.Name()] = c
- c.CommandExecuter = &CommandExecuter{c}
-}
-
-// Commander implementation
-type CmdRemoveDispatcherHost struct {
- name string
- rpcMethod string
- rpcParams *utils.TenantIDWithAPIOpts
- *CommandExecuter
-}
-
-func (self *CmdRemoveDispatcherHost) Name() string {
- return self.name
-}
-
-func (self *CmdRemoveDispatcherHost) RpcMethod() string {
- return self.rpcMethod
-}
-
-func (self *CmdRemoveDispatcherHost) RpcParams(reset bool) any {
- if reset || self.rpcParams == nil {
- self.rpcParams = &utils.TenantIDWithAPIOpts{APIOpts: make(map[string]any)}
- }
- return self.rpcParams
-}
-
-func (self *CmdRemoveDispatcherHost) PostprocessRpcParams() error {
- return nil
-}
-
-func (self *CmdRemoveDispatcherHost) RpcResult() any {
- var s string
- return &s
-}
diff --git a/console/dispatcher_host_set.go b/console/dispatcher_host_set.go
deleted file mode 100644
index d5198f726..000000000
--- a/console/dispatcher_host_set.go
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package console
-
-import (
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func init() {
- c := &CmdSetDispatcherHost{
- name: "dispatcher_host_set",
- rpcMethod: utils.AdminSv1SetDispatcherHost,
- rpcParams: &engine.DispatcherHostWithAPIOpts{},
- }
- commands[c.Name()] = c
- c.CommandExecuter = &CommandExecuter{c}
-}
-
-// Commander implementation
-type CmdSetDispatcherHost struct {
- name string
- rpcMethod string
- rpcParams *engine.DispatcherHostWithAPIOpts
- *CommandExecuter
-}
-
-func (self *CmdSetDispatcherHost) Name() string {
- return self.name
-}
-
-func (self *CmdSetDispatcherHost) RpcMethod() string {
- return self.rpcMethod
-}
-
-func (self *CmdSetDispatcherHost) RpcParams(reset bool) any {
- if reset || self.rpcParams == nil {
- self.rpcParams = &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: new(engine.DispatcherHost),
- APIOpts: make(map[string]any),
- }
- }
- return self.rpcParams
-}
-
-func (self *CmdSetDispatcherHost) PostprocessRpcParams() error {
- return nil
-}
-
-func (self *CmdSetDispatcherHost) RpcResult() any {
- var s string
- return &s
-}
diff --git a/console/dispatcher_hosts.go b/console/dispatcher_hosts.go
deleted file mode 100644
index 08ee802c9..000000000
--- a/console/dispatcher_hosts.go
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package console
-
-import (
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func init() {
- c := &CmdGetDispatcherHosts{
- name: "dispatcher_hosts",
- rpcMethod: utils.AdminSv1GetDispatcherHosts,
- rpcParams: &utils.ArgsItemIDs{},
- }
- commands[c.Name()] = c
- c.CommandExecuter = &CommandExecuter{c}
-}
-
-// Commander implementation
-type CmdGetDispatcherHosts struct {
- name string
- rpcMethod string
- rpcParams *utils.ArgsItemIDs
- *CommandExecuter
-}
-
-func (self *CmdGetDispatcherHosts) Name() string {
- return self.name
-}
-
-func (self *CmdGetDispatcherHosts) RpcMethod() string {
- return self.rpcMethod
-}
-
-func (self *CmdGetDispatcherHosts) RpcParams(reset bool) any {
- if reset || self.rpcParams == nil {
- self.rpcParams = new(utils.ArgsItemIDs)
- }
- return self.rpcParams
-}
-
-func (self *CmdGetDispatcherHosts) PostprocessRpcParams() error {
- return nil
-}
-
-func (self *CmdGetDispatcherHosts) RpcResult() any {
- var s []*engine.DispatcherHost
- return &s
-}
diff --git a/console/dispatcher_profile.go b/console/dispatcher_profile.go
deleted file mode 100644
index afc3d720f..000000000
--- a/console/dispatcher_profile.go
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package console
-
-import (
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func init() {
- c := &CmdGetDispatcherProfile{
- name: "dispatcher_profile",
- rpcMethod: utils.AdminSv1GetDispatcherProfile,
- rpcParams: &utils.TenantIDWithAPIOpts{},
- }
- commands[c.Name()] = c
- c.CommandExecuter = &CommandExecuter{c}
-}
-
-// Commander implementation
-type CmdGetDispatcherProfile struct {
- name string
- rpcMethod string
- rpcParams *utils.TenantIDWithAPIOpts
- *CommandExecuter
-}
-
-func (self *CmdGetDispatcherProfile) Name() string {
- return self.name
-}
-
-func (self *CmdGetDispatcherProfile) RpcMethod() string {
- return self.rpcMethod
-}
-
-func (self *CmdGetDispatcherProfile) RpcParams(reset bool) any {
- if reset || self.rpcParams == nil {
- self.rpcParams = new(utils.TenantIDWithAPIOpts)
- }
- return self.rpcParams
-}
-
-func (self *CmdGetDispatcherProfile) PostprocessRpcParams() error {
- return nil
-}
-
-func (self *CmdGetDispatcherProfile) RpcResult() any {
- var s engine.DispatcherProfile
- return &s
-}
diff --git a/console/dispatcher_profile_ids.go b/console/dispatcher_profile_ids.go
deleted file mode 100644
index 3b0b34a2d..000000000
--- a/console/dispatcher_profile_ids.go
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package console
-
-import (
- "github.com/cgrates/cgrates/utils"
-)
-
-func init() {
- c := &CmdGetDispatcherProfileIDs{
- name: "dispatcher_profile_ids",
- rpcMethod: utils.AdminSv1GetDispatcherProfileIDs,
- rpcParams: &utils.ArgsItemIDs{},
- }
- commands[c.Name()] = c
- c.CommandExecuter = &CommandExecuter{c}
-}
-
-// Commander implementation
-type CmdGetDispatcherProfileIDs struct {
- name string
- rpcMethod string
- rpcParams *utils.ArgsItemIDs
- *CommandExecuter
-}
-
-func (self *CmdGetDispatcherProfileIDs) Name() string {
- return self.name
-}
-
-func (self *CmdGetDispatcherProfileIDs) RpcMethod() string {
- return self.rpcMethod
-}
-
-func (self *CmdGetDispatcherProfileIDs) RpcParams(reset bool) any {
- if reset || self.rpcParams == nil {
- self.rpcParams = new(utils.ArgsItemIDs)
- }
- return self.rpcParams
-}
-
-func (self *CmdGetDispatcherProfileIDs) PostprocessRpcParams() error {
- return nil
-}
-
-func (self *CmdGetDispatcherProfileIDs) RpcResult() any {
- var s []string
- return &s
-}
diff --git a/console/dispatcher_profile_remove.go b/console/dispatcher_profile_remove.go
deleted file mode 100644
index 1e5cd5a27..000000000
--- a/console/dispatcher_profile_remove.go
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package console
-
-import (
- "github.com/cgrates/cgrates/utils"
-)
-
-func init() {
- c := &CmdRemoveDispatcherProfile{
- name: "dispatcher_profile_remove",
- rpcMethod: utils.AdminSv1RemoveDispatcherProfile,
- rpcParams: &utils.TenantIDWithAPIOpts{},
- }
- commands[c.Name()] = c
- c.CommandExecuter = &CommandExecuter{c}
-}
-
-// Commander implementation
-type CmdRemoveDispatcherProfile struct {
- name string
- rpcMethod string
- rpcParams *utils.TenantIDWithAPIOpts
- *CommandExecuter
-}
-
-func (self *CmdRemoveDispatcherProfile) Name() string {
- return self.name
-}
-
-func (self *CmdRemoveDispatcherProfile) RpcMethod() string {
- return self.rpcMethod
-}
-
-func (self *CmdRemoveDispatcherProfile) RpcParams(reset bool) any {
- if reset || self.rpcParams == nil {
- self.rpcParams = &utils.TenantIDWithAPIOpts{APIOpts: make(map[string]any)}
- }
- return self.rpcParams
-}
-
-func (self *CmdRemoveDispatcherProfile) PostprocessRpcParams() error {
- return nil
-}
-
-func (self *CmdRemoveDispatcherProfile) RpcResult() any {
- var s string
- return &s
-}
diff --git a/console/dispatcher_profile_set.go b/console/dispatcher_profile_set.go
deleted file mode 100644
index 2a25d0eae..000000000
--- a/console/dispatcher_profile_set.go
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package console
-
-import (
- "github.com/cgrates/cgrates/apis"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func init() {
- c := &CmdSetDispatcherProfile{
- name: "dispatcher_profile_set",
- rpcMethod: utils.AdminSv1SetDispatcherProfile,
- rpcParams: &apis.DispatcherWithAPIOpts{},
- }
- commands[c.Name()] = c
- c.CommandExecuter = &CommandExecuter{c}
-}
-
-// Commander implementation
-type CmdSetDispatcherProfile struct {
- name string
- rpcMethod string
- rpcParams *apis.DispatcherWithAPIOpts
- *CommandExecuter
-}
-
-func (self *CmdSetDispatcherProfile) Name() string {
- return self.name
-}
-
-func (self *CmdSetDispatcherProfile) RpcMethod() string {
- return self.rpcMethod
-}
-
-func (self *CmdSetDispatcherProfile) RpcParams(reset bool) any {
- if reset || self.rpcParams == nil {
- self.rpcParams = &apis.DispatcherWithAPIOpts{
- DispatcherProfile: new(engine.DispatcherProfile),
- APIOpts: make(map[string]any),
- }
- }
- return self.rpcParams
-}
-
-func (self *CmdSetDispatcherProfile) PostprocessRpcParams() error {
- return nil
-}
-
-func (self *CmdSetDispatcherProfile) RpcResult() any {
- var s string
- return &s
-}
diff --git a/console/dispatcher_profiles.go b/console/dispatcher_profiles.go
deleted file mode 100644
index 8ae2ef065..000000000
--- a/console/dispatcher_profiles.go
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package console
-
-import (
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func init() {
- c := &CmdGetDispatcherProfiles{
- name: "dispatcher_profiles",
- rpcMethod: utils.AdminSv1GetDispatcherProfiles,
- rpcParams: &utils.ArgsItemIDs{},
- }
- commands[c.Name()] = c
- c.CommandExecuter = &CommandExecuter{c}
-}
-
-// Commander implementation
-type CmdGetDispatcherProfiles struct {
- name string
- rpcMethod string
- rpcParams *utils.ArgsItemIDs
- *CommandExecuter
-}
-
-func (self *CmdGetDispatcherProfiles) Name() string {
- return self.name
-}
-
-func (self *CmdGetDispatcherProfiles) RpcMethod() string {
- return self.rpcMethod
-}
-
-func (self *CmdGetDispatcherProfiles) RpcParams(reset bool) any {
- if reset || self.rpcParams == nil {
- self.rpcParams = new(utils.ArgsItemIDs)
- }
- return self.rpcParams
-}
-
-func (self *CmdGetDispatcherProfiles) PostprocessRpcParams() error {
- return nil
-}
-
-func (self *CmdGetDispatcherProfiles) RpcResult() any {
- var s []*engine.DispatcherProfile
- return &s
-}
diff --git a/console/dispatchers_for_event.go b/console/dispatchers_for_event.go
deleted file mode 100644
index 98f7a8027..000000000
--- a/console/dispatchers_for_event.go
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package console
-
-import (
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func init() {
- c := &CmdDispatcherProfile{
- name: "dispatchers_for_event",
- rpcMethod: utils.DispatcherSv1GetProfilesForEvent,
- }
- commands[c.Name()] = c
- c.CommandExecuter = &CommandExecuter{c}
-}
-
-// Commander implementation
-type CmdDispatcherProfile struct {
- name string
- rpcMethod string
- rpcParams *utils.CGREvent
- *CommandExecuter
-}
-
-func (self *CmdDispatcherProfile) Name() string {
- return self.name
-}
-
-func (self *CmdDispatcherProfile) RpcMethod() string {
- return self.rpcMethod
-}
-
-func (self *CmdDispatcherProfile) RpcParams(reset bool) any {
- if reset || self.rpcParams == nil {
- self.rpcParams = new(utils.CGREvent)
- }
- return self.rpcParams
-}
-
-func (self *CmdDispatcherProfile) PostprocessRpcParams() error {
- return nil
-}
-
-func (self *CmdDispatcherProfile) RpcResult() any {
- var s engine.DispatcherProfiles
- return &s
-}
diff --git a/console/ping.go b/console/ping.go
index 620d0bacc..156afe017 100644
--- a/console/ping.go
+++ b/console/ping.go
@@ -67,8 +67,6 @@ func (self *CmdApierPing) RpcMethod() string {
return utils.SessionSv1Ping
case utils.LoaderSLow:
return utils.LoaderSv1Ping
- case utils.DispatcherSLow:
- return utils.DispatcherSv1Ping
case utils.AnalyzerSLow:
return utils.AnalyzerSv1Ping
case utils.ReplicatorLow:
diff --git a/data/conf/samples/apis_loaders_internal/cgrates.json b/data/conf/samples/apis_loaders_internal/cgrates.json
index 24899eaa1..33fc39f55 100644
--- a/data/conf/samples/apis_loaders_internal/cgrates.json
+++ b/data/conf/samples/apis_loaders_internal/cgrates.json
@@ -70,18 +70,6 @@
"file_name": "Chargers.csv",
"fields": [{"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}],
},
- {
- "type": "*dispatchers",
- "file_name": "DispatcherProfiles.csv",
- "fields": [{"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}],
- },
- {
- "type": "*dispatcher_hosts",
- "file_name": "DispatcherHosts.csv",
- "fields": [
- {"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"},
- ],
- },
{
"type": "*rate_profiles",
"file_name": "Rates.csv",
diff --git a/data/conf/samples/apis_loaders_mongo/cgrates.json b/data/conf/samples/apis_loaders_mongo/cgrates.json
index 714c14811..9ab7a4d6d 100644
--- a/data/conf/samples/apis_loaders_mongo/cgrates.json
+++ b/data/conf/samples/apis_loaders_mongo/cgrates.json
@@ -65,18 +65,6 @@
"file_name": "Chargers.csv",
"fields": [{"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}],
},
- {
- "type": "*dispatchers",
- "file_name": "DispatcherProfiles.csv",
- "fields": [{"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}],
- },
- {
- "type": "*dispatcher_hosts",
- "file_name": "DispatcherHosts.csv",
- "fields": [
- {"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"},
- ],
- },
{
"type": "*rate_profiles",
"file_name": "Rates.csv",
diff --git a/data/conf/samples/apis_loaders_mysql/cgrates.json b/data/conf/samples/apis_loaders_mysql/cgrates.json
index 2092158f0..1e51559bf 100644
--- a/data/conf/samples/apis_loaders_mysql/cgrates.json
+++ b/data/conf/samples/apis_loaders_mysql/cgrates.json
@@ -62,18 +62,6 @@
"file_name": "Chargers.csv",
"fields": [{"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}],
},
- {
- "type": "*dispatchers",
- "file_name": "DispatcherProfiles.csv",
- "fields": [{"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}],
- },
- {
- "type": "*dispatcher_hosts",
- "file_name": "DispatcherHosts.csv",
- "fields": [
- {"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"},
- ],
- },
{
"type": "*rate_profiles",
"file_name": "Rates.csv",
diff --git a/data/conf/samples/cache_replicate/dispatcher_engine/cgrates.json b/data/conf/samples/cache_replicate/dispatcher_engine/cgrates.json
index f6eefd14a..a9dedb3d3 100644
--- a/data/conf/samples/cache_replicate/dispatcher_engine/cgrates.json
+++ b/data/conf/samples/cache_replicate/dispatcher_engine/cgrates.json
@@ -22,8 +22,6 @@
"caches":{
"partitions": {
- "*dispatcher_routes": {"limit": -1, "ttl": "1h", "replicate": true},
- "*dispatcher_loads": {"limit": -1, "replicate": true}
},
"replication_conns": ["cacheReplication"],
"remote_conns": ["cacheReplication"],
@@ -36,12 +34,7 @@
},
},
-
-"dispatchers":{
- "enabled": true,
-},
-
-
+
"admins": {
"enabled": true,
diff --git a/data/conf/samples/cache_replicate/dispatcher_engine2/cgrates.json b/data/conf/samples/cache_replicate/dispatcher_engine2/cgrates.json
index a1e9cae18..c84729af0 100644
--- a/data/conf/samples/cache_replicate/dispatcher_engine2/cgrates.json
+++ b/data/conf/samples/cache_replicate/dispatcher_engine2/cgrates.json
@@ -28,15 +28,10 @@
"caches":{
"partitions": {
- "*dispatcher_routes": {"limit": -1, "ttl": "1h"}
},
},
-"dispatchers":{
- "enabled": true,
-},
-
-
+
"admins": {
"enabled": true,
},
diff --git a/data/conf/samples/cache_rpl_active_active/dispatcher_engine/cgrates.json b/data/conf/samples/cache_rpl_active_active/dispatcher_engine/cgrates.json
index 7e24d2ec0..33b079782 100644
--- a/data/conf/samples/cache_rpl_active_active/dispatcher_engine/cgrates.json
+++ b/data/conf/samples/cache_rpl_active_active/dispatcher_engine/cgrates.json
@@ -21,8 +21,6 @@
"caches":{
"partitions": {
- "*dispatcher_routes": {"limit": -1, "ttl": "1h", "replicate": true},
- "*dispatcher_loads": {"limit": -1, "replicate": true}
},
"replication_conns": ["cacheReplication"],
},
@@ -34,9 +32,7 @@
},
},
-"dispatchers":{
- "enabled": true,
-},
+
"admins": {
diff --git a/data/conf/samples/cache_rpl_active_active/dispatcher_engine2/cgrates.json b/data/conf/samples/cache_rpl_active_active/dispatcher_engine2/cgrates.json
index 585d44c15..710cd3ebb 100644
--- a/data/conf/samples/cache_rpl_active_active/dispatcher_engine2/cgrates.json
+++ b/data/conf/samples/cache_rpl_active_active/dispatcher_engine2/cgrates.json
@@ -28,8 +28,6 @@
"caches":{
"partitions": {
- "*dispatcher_routes": {"limit": -1, "ttl": "1h", "replicate": true},
- "*dispatcher_loads": {"limit": -1, "replicate": true}
},
"replication_conns": ["cacheReplication"],
},
diff --git a/data/conf/samples/dataconverter_internal/cgrates.json b/data/conf/samples/dataconverter_internal/cgrates.json
index cc089cba2..13726ed32 100644
--- a/data/conf/samples/dataconverter_internal/cgrates.json
+++ b/data/conf/samples/dataconverter_internal/cgrates.json
@@ -62,18 +62,6 @@
"file_name": "Chargers.csv",
"fields": [{"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}]
},
- {
- "type": "*dispatchers",
- "file_name": "DispatcherProfiles.csv",
- "fields": [{"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}]
- },
- {
- "type": "*dispatcher_hosts",
- "file_name": "DispatcherHosts.csv",
- "fields": [
- {"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}
- ]
- },
{
"type": "*rate_profiles",
"file_name": "Rates.csv",
diff --git a/data/conf/samples/dataconverter_mongo/cgrates.json b/data/conf/samples/dataconverter_mongo/cgrates.json
index c99175440..17f16b45a 100644
--- a/data/conf/samples/dataconverter_mongo/cgrates.json
+++ b/data/conf/samples/dataconverter_mongo/cgrates.json
@@ -67,18 +67,6 @@
"file_name": "Chargers.csv",
"fields": [{"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}]
},
- {
- "type": "*dispatchers",
- "file_name": "DispatcherProfiles.csv",
- "fields": [{"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}]
- },
- {
- "type": "*dispatcher_hosts",
- "file_name": "DispatcherHosts.csv",
- "fields": [
- {"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}
- ]
- },
{
"type": "*rate_profiles",
"file_name": "Rates.csv",
diff --git a/data/conf/samples/dataconverter_mysql/cgrates.json b/data/conf/samples/dataconverter_mysql/cgrates.json
index 84f8e45c0..795efde84 100644
--- a/data/conf/samples/dataconverter_mysql/cgrates.json
+++ b/data/conf/samples/dataconverter_mysql/cgrates.json
@@ -64,18 +64,6 @@
"file_name": "Chargers.csv",
"fields": [{"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}]
},
- {
- "type": "*dispatchers",
- "file_name": "DispatcherProfiles.csv",
- "fields": [{"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}]
- },
- {
- "type": "*dispatcher_hosts",
- "file_name": "DispatcherHosts.csv",
- "fields": [
- {"tag": "BaseTmpl","type": "*template", "value": "baseTmpl"}
- ]
- },
{
"type": "*rate_profiles",
"file_name": "Rates.csv",
diff --git a/data/conf/samples/dispatcher_opts/cgrates.json b/data/conf/samples/dispatcher_opts/cgrates.json
index 81e3927f1..a838a2d8a 100644
--- a/data/conf/samples/dispatcher_opts/cgrates.json
+++ b/data/conf/samples/dispatcher_opts/cgrates.json
@@ -27,25 +27,9 @@
"attributes": {
"enabled": true
},
-
-"dispatchers":{
- "enabled": true,
- "opts": {
- "*dispatchers": [
- {
- "Tenant": "cgrates.org",
- "FilterIDs": ["*string:~*opts.*subsys:*dispatchers"],
- "Value": false
- }
- ]
- }
-},
-
+
"caches":{
- "partitions": {
- "*dispatcher_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "remote":true, "replicate": false},
- "*dispatcher_routes": {"limit": -1, "ttl": "", "static_ttl": false, "remote":true, "replicate": false},
- "*dispatchers": {"limit": -1, "ttl": "", "static_ttl": false, "remote":true, "replicate": false}
+ "partitions": {
},
"remote_conns": ["gob_cache"]
},
diff --git a/data/conf/samples/dispatcher_opts_admin/cgrates.json b/data/conf/samples/dispatcher_opts_admin/cgrates.json
deleted file mode 100644
index c9ac6b933..000000000
--- a/data/conf/samples/dispatcher_opts_admin/cgrates.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
-
-"general": {
- "node_id": "HOST2",
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":4012",
- "rpc_gob": ":4013",
- "http": ":4080"
-},
-
-"data_db": {
- "db_type": "redis",
- "db_port": 6379,
- "db_name": "10"
-},
-
-"stor_db": {
- "db_password": "CGRateS.org"
-},
-
-"dispatchers":{
- "enabled": true,
- "opts": {
- "*dispatchers": [
- {
- "Tenant": "cgrates.org",
- "FilterIDs": ["*string:~*opts.*subsys:*dispatchers"],
- "Value": false
- }
- ]
- }
-},
-
-"caches":{
- "partitions": {
- "*dispatcher_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "remote":true, "replicate": false},
- "*dispatcher_routes": {"limit": -1, "ttl": "", "static_ttl": false, "remote":true, "replicate": false},
- "*dispatchers": {"limit": -1, "ttl": "", "static_ttl": false, "remote":true, "replicate": false}
- },
- "remote_conns": ["gob_cache"]
-},
-
-"admins": {
- "enabled": true,
- "caches_conns":["broadcast_cache"]
-},
-
-"rpc_conns": {
- "broadcast_cache": {
- "strategy": "*broadcast",
- "conns": [
- {"address": "127.0.0.1:2012", "transport":"*json"},
- {"address": "127.0.0.1:4012", "transport":"*json"}
- ]
- },
- "gob_cache": {
- "strategy": "*first",
- "conns": [
- {"address": "127.0.0.1:4013", "transport":"*gob"}
- ]
- }
-}
-
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/all/cgrates.json b/data/conf/samples/dispatchers/all/cgrates.json
deleted file mode 100644
index 3425e1b03..000000000
--- a/data/conf/samples/dispatchers/all/cgrates.json
+++ /dev/null
@@ -1,99 +0,0 @@
-{
-
-"general": {
- "node_id": "ALL",
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":6012",
- "rpc_gob": ":6013",
- "http": ":6080"
-},
-
-"data_db": {
- "db_type": "redis",
- "db_port": 6379,
- "db_name": "11"
-},
-
-"stor_db": {
- "db_password": "CGRateS.org"
-},
-
-"rpc_conns": {
- "conn1": {
- "strategy": "*first",
- "conns": [{"address": "127.0.0.1:6012", "transport":"*json"}]
- },
- "rplConn": {
- "strategy": "*broadcast_sync",
- "conns": [{"address": "127.0.0.1:7012", "transport":"*json"}]
- }
-},
-
-"attributes": {
- "enabled": true
-},
-
-"chargers": {
- "enabled": true,
- "attributes_conns": ["*internal"]
-},
-
-"thresholds": {
- "enabled": true
-},
-
-"routes": {
- "enabled": true,
- "rates_conns": ["*internal"],
- "accounts_conns": ["*internal"]
-},
-
-"stats": {
- "enabled": true
-},
-
-"resources": {
- "enabled": true
-},
-
-"rates": {
- "enabled": true
-},
-
-"actions": {
- "enabled": true
-},
-
-"accounts": {
- "enabled": true
-},
-
-"cdrs": {
- "enabled": true,
- "chargers_conns":["*internal"],
- "rates_conns": ["*internal"]
-},
-
-"sessions": {
- "enabled": true,
- "listen_bijson": ":6014",
- "routes_conns": ["*internal"],
- "resources_conns": ["*internal"],
- "attributes_conns": ["*internal"],
- "rates_conns": ["*internal"],
- "chargers_conns": ["*internal"],
- "cdrs_conns": ["*internal"]
-},
-
-"admins": {
- "enabled": true,
- "caches_conns":["conn1"]
-}
-
-}
diff --git a/data/conf/samples/dispatchers/all2/cgrates.json b/data/conf/samples/dispatchers/all2/cgrates.json
deleted file mode 100644
index 7f804cb22..000000000
--- a/data/conf/samples/dispatchers/all2/cgrates.json
+++ /dev/null
@@ -1,95 +0,0 @@
-{
-
-"general": {
- "node_id": "ALL2",
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":7012",
- "rpc_gob": ":7013",
- "http": ":7080"
-},
-
-"data_db": {
- "db_type": "redis",
- "db_port": 6379,
- "db_name": "12"
-},
-
-"stor_db": {
- "db_type":"*internal"
-},
-
-"rpc_conns": {
- "conn1": {
- "strategy": "*first",
- "conns": [{"address": "127.0.0.1:7012", "transport":"*json"}]
- }
-},
-
-"attributes": {
- "enabled": true
-},
-
-"chargers": {
- "enabled": true,
- "attributes_conns": ["*internal"]
-},
-
-"thresholds": {
- "enabled": true
-},
-
-"routes": {
- "enabled": true,
- "rates_conns": ["*internal"],
- "accounts_conns": ["*internal"]
-},
-
-"stats": {
- "enabled": true
-},
-
-"resources": {
- "enabled": true
-},
-
-"rates": {
- "enabled": true
-},
-
-"actions": {
- "enabled": true
-},
-
-"accounts": {
- "enabled": true
-},
-
-"cdrs": {
- "enabled": true,
- "chargers_conns":["*internal"],
- "rates_conns": ["*internal"]
-},
-
-"sessions": {
- "enabled": true,
- "listen_bijson": ":7014",
- "routes_conns": ["*internal"],
- "resources_conns": ["*internal"],
- "attributes_conns": ["*internal"],
- "rates_conns": ["*internal"],
- "cdrs_conns": ["*internal"],
- "chargers_conns": ["*internal"]
-},
-
-"admins": {
- "enabled": true,
- "caches_conns":["conn1"]
-}
-
-}
diff --git a/data/conf/samples/dispatchers/all2_mongo/cgrates.json b/data/conf/samples/dispatchers/all2_mongo/cgrates.json
deleted file mode 100644
index fd878c9578..000000000
--- a/data/conf/samples/dispatchers/all2_mongo/cgrates.json
+++ /dev/null
@@ -1,98 +0,0 @@
-{
-
-"general": {
- "node_id": "ALL2",
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":7012",
- "rpc_gob": ":7013",
- "http": ":7080"
-},
-
-"data_db": {
- "db_type": "mongo",
- "db_name": "12",
- "db_port": 27017
-},
-
-"stor_db": {
- "db_type": "mongo",
- "db_name": "cgrates",
- "db_port": 27017,
- "db_password": ""
-},
-
-"rpc_conns": {
- "conn1": {
- "strategy": "*first",
- "conns": [{"address": "127.0.0.1:7012", "transport":"*json"}]
- }
-},
-
-"attributes": {
- "enabled": true
-},
-
-"chargers": {
- "enabled": true,
- "attributes_conns": ["*internal"]
-},
-
-"thresholds": {
- "enabled": true
-},
-
-"routes": {
- "enabled": true,
- "rates_conns": ["*internal"],
- "accounts_conns": ["*internal"]
-},
-
-"stats": {
- "enabled": true
-},
-
-"resources": {
- "enabled": true
-},
-
-"rates": {
- "enabled": true
-},
-
-"actions": {
- "enabled": true
-},
-
-"accounts": {
- "enabled": true
-},
-
-"cdrs": {
- "enabled": true,
- "chargers_conns":["*internal"],
- "rates_conns": ["*internal"]
-},
-
-"sessions": {
- "enabled": true,
- "listen_bijson": ":7014",
- "routes_conns": ["*internal"],
- "resources_conns": ["*internal"],
- "attributes_conns": ["*internal"],
- "rates_conns": ["*internal"],
- "cdrs_conns": ["*internal"],
- "chargers_conns": ["*internal"]
-},
-
-"admins": {
- "enabled": true,
- "caches_conns":["conn1"]
-}
-
-}
diff --git a/data/conf/samples/dispatchers/all2_mysql/cgrates.json b/data/conf/samples/dispatchers/all2_mysql/cgrates.json
deleted file mode 100644
index b6d02788b..000000000
--- a/data/conf/samples/dispatchers/all2_mysql/cgrates.json
+++ /dev/null
@@ -1,95 +0,0 @@
-{
-
-"general": {
- "node_id": "ALL2",
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":7012",
- "rpc_gob": ":7013",
- "http": ":7080"
-},
-
-"data_db": {
- "db_type": "redis",
- "db_port": 6379,
- "db_name": "12"
-},
-
-"stor_db": {
- "db_type":"*internal"
-},
-
-"rpc_conns": {
- "conn1": {
- "strategy": "*first",
- "conns": [{"address": "127.0.0.1:7012", "transport":"*json"}]
- }
-},
-
-"attributes": {
- "enabled": true
-},
-
-"chargers": {
- "enabled": true,
- "attributes_conns": ["*internal"]
-},
-
-"thresholds": {
- "enabled": true
-},
-
-"routes": {
- "enabled": true,
- "rates_conns": ["*internal"],
- "accounts_conns": ["*internal"]
-},
-
-"stats": {
- "enabled": true
-},
-
-"resources": {
- "enabled": true
-},
-
-"rates": {
- "enabled": true
-},
-
-"actions": {
- "enabled": true
-},
-
-"accounts": {
- "enabled": true
-},
-
-"cdrs": {
- "enabled": true,
- "chargers_conns":["*internal"],
- "rates_conns": ["*internal"]
-},
-
-"sessions": {
- "enabled": true,
- "listen_bijson": ":7014",
- "routes_conns": ["*internal"],
- "resources_conns": ["*internal"],
- "attributes_conns": ["*internal"],
- "rates_conns": ["*internal"],
- "cdrs_conns": ["*internal"],
- "chargers_conns": ["*internal"]
-},
-
-"admins": {
- "enabled": true,
- "caches_conns":["conn1"]
-}
-
-}
diff --git a/data/conf/samples/dispatchers/all_mongo/cgrates.json b/data/conf/samples/dispatchers/all_mongo/cgrates.json
deleted file mode 100644
index 899476ef7..000000000
--- a/data/conf/samples/dispatchers/all_mongo/cgrates.json
+++ /dev/null
@@ -1,102 +0,0 @@
-{
-
-"general": {
- "node_id": "ALL",
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":6012",
- "rpc_gob": ":6013",
- "http": ":6080"
-},
-
-"data_db": {
- "db_type": "mongo",
- "db_name": "11",
- "db_port": 27017
-},
-
-"stor_db": {
- "db_type": "mongo",
- "db_name": "cgrates",
- "db_port": 27017,
- "db_password": ""
-},
-
-"rpc_conns": {
- "conn1": {
- "strategy": "*first",
- "conns": [{"address": "127.0.0.1:6012", "transport":"*json"}]
- },
- "rplConn": {
- "strategy": "*broadcast_sync",
- "conns": [{"address": "127.0.0.1:7012", "transport":"*json"}]
- }
-},
-
-"attributes": {
- "enabled": true
-},
-
-"chargers": {
- "enabled": true,
- "attributes_conns": ["*internal"]
-},
-
-"thresholds": {
- "enabled": true
-},
-
-"routes": {
- "enabled": true,
- "rates_conns": ["*internal"],
- "accounts_conns": ["*internal"]
-},
-
-"stats": {
- "enabled": true
-},
-
-"resources": {
- "enabled": true
-},
-
-"rates": {
- "enabled": true
-},
-
-"actions": {
- "enabled": true
-},
-
-"accounts": {
- "enabled": true
-},
-
-"cdrs": {
- "enabled": true,
- "chargers_conns":["*internal"],
- "rates_conns": ["*internal"]
-},
-
-"sessions": {
- "enabled": true,
- "listen_bijson": ":6014",
- "routes_conns": ["*internal"],
- "resources_conns": ["*internal"],
- "attributes_conns": ["*internal"],
- "rates_conns": ["*internal"],
- "chargers_conns": ["*internal"],
- "cdrs_conns": ["*internal"]
-},
-
-"admins": {
- "enabled": true,
- "caches_conns":["conn1"]
-}
-
-}
diff --git a/data/conf/samples/dispatchers/all_mysql/cgrates.json b/data/conf/samples/dispatchers/all_mysql/cgrates.json
deleted file mode 100644
index d46c8ca6e..000000000
--- a/data/conf/samples/dispatchers/all_mysql/cgrates.json
+++ /dev/null
@@ -1,100 +0,0 @@
-{
-
-"general": {
- "node_id": "ALL",
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":6012",
- "rpc_gob": ":6013",
- "http": ":6080"
-},
-
-"data_db": {
- "db_type": "redis",
- "db_port": 6379,
- "db_name": "11"
-},
-
-"stor_db": {
- "db_password": "CGRateS.org"
-},
-
-"rpc_conns": {
- "conn1": {
- "strategy": "*first",
- "conns": [{"address": "127.0.0.1:6012", "transport":"*json"}]
- },
- "rplConn": {
- "strategy": "*broadcast_sync",
- "conns": [{"address": "127.0.0.1:7012", "transport":"*json"}]
- }
-},
-
-"attributes": {
- "enabled": true
-},
-
-"chargers": {
- "enabled": true,
- "attributes_conns": ["*internal"]
-},
-
-"thresholds": {
- "enabled": true
-},
-
-"routes": {
- "enabled": true,
- "rates_conns": ["*internal"],
- "accounts_conns": ["*internal"]
-},
-
-"stats": {
- "enabled": true
-},
-
-"resources": {
- "enabled": true
-},
-
-"rates": {
- "enabled": true
-},
-
-
-"actions": {
- "enabled": true
-},
-
-"accounts": {
- "enabled": true
-},
-
-"cdrs": {
- "enabled": true,
- "chargers_conns":["*internal"],
- "rates_conns": ["*internal"]
-},
-
-"sessions": {
- "enabled": true,
- "listen_bijson": ":6014",
- "routes_conns": ["*internal"],
- "resources_conns": ["*internal"],
- "attributes_conns": ["*internal"],
- "rates_conns": ["*internal"],
- "chargers_conns": ["*internal"],
- "cdrs_conns": ["*internal"]
-},
-
-"admins": {
- "enabled": true,
- "caches_conns":["conn1"]
-}
-
-}
diff --git a/data/conf/samples/dispatchers/diamagent/cgrates.json b/data/conf/samples/dispatchers/diamagent/cgrates.json
deleted file mode 100644
index 623bd47e4..000000000
--- a/data/conf/samples/dispatchers/diamagent/cgrates.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
-// CGRateS Configuration file
-//
-// Used for cgradmin
-// Starts rater, scheduler
-
-"general": {
- "node_id": "DispatcherS1",
- "reconnects": 1
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":2012", // RPC JSON listening address
- "rpc_gob": ":2013", // RPC GOB listening address
- "http": ":2080" // HTTP listening address
-},
-
-"data_db": { // database used to store runtime data (eg: accounts, cdr stats)
- "db_type": "mongo", // stor database type to use:
- "db_port": 27017, // the port to reach the datadb
- "db_name": "datadb",
- "db_password": ""
-},
-
-
-
-"attributes": {
- "enabled": true
-},
-
-"dispatchers":{
- "enabled": true,
- "attributes_conns": ["*internal"]
-},
-
-
-"diameter_agent": {
- "enabled": true,
- "sessions_conns": ["*localhost"],
- "asr_template": "*asr"
-},
-
-
-"admins": {
- "enabled": true,
-}
-}
diff --git a/data/conf/samples/dispatchers/diamagent/data.json b/data/conf/samples/dispatchers/diamagent/data.json
deleted file mode 100644
index 409b66cda..000000000
--- a/data/conf/samples/dispatchers/diamagent/data.json
+++ /dev/null
@@ -1,128 +0,0 @@
-
-{
-
-"diameter_agent": {
- "request_processors": [
-
- {
- "id": "data_init",
- "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1", "*prefix:~*req.Service-Context-Id:gprs"],
- "flags": ["*initiate", "*accounts"],
- "request_fields":[
- {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"},
- {"tag": "APIkey", "path": "*opts.*apiKey", "type": "*constant", "value": "ses12345"},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
- "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", "mandatory": true},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
- {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "2048"},
- ],
- "reply_fields": [
- {"tag": "CCATemplate", "type": "*template", "value": "*cca"},
- {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"],
- "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true},
- ],
- },
-
- {
- "id": "data_update_grp1",
- "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2",
- "*string:~*req.Multiple-Services-Credit-Control.Rating-Group:1", "*prefix:~*req.Service-Context-Id:gprs"],
- "flags": ["*update", "*accounts","*continue"],
- "request_fields":[
- {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"},
- {"tag": "APIkey", "path": "*opts.*apiKey", "type": "*constant", "value": "ses12345"},
- {"tag": "InitialOriginID", "path": "*cgreq.InitialOriginID", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed", "value": "_grp1"},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
- {"tag": "Category", "path": "*cgreq.Category", "type": "*contant", "value": "generic"},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
- "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
- {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "2048"},
- {"tag": "LastUsed", "path": "*cgreq.LastUsed", "type": "*sum",
- "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(1)]"},
- ],
- "reply_fields": [
- {"tag": "CCATemplate", "type": "*template", "value": "*cca"},
- {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"],
- "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true},
- ],
- },
-
- {
- "id": "data_update_grp2",
- "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2",
- "*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2", "*prefix:~*req.Service-Context-Id:gprs"],
- "flags": ["*update", "*accounts"],
- "request_fields":[
- {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"},
- {"tag": "APIkey", "path": "*opts.*apiKey", "type": "*constant", "value": "ses12345"},
- {"tag": "InitialOriginID", "path": "*cgreq.InitialOriginID", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*constant", "value": "_grp2"},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
- "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
- {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "2048"},
- {"tag": "LastUsed", "path": "*cgreq.LastUsed", "type": "*sum",
- "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(2)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(2)]"},
- ],
- "reply_fields": [
- {"tag": "CCATemplate", "type": "*template", "value": "*cca"},
- {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"],
- "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true},
- ],
- },
-
- {
- "id": "data_terminate",
- "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:3",
- "*prefix:~*req.Service-Context-Id:gprs"],
- "flags": ["*terminate", "*accounts"],
- "request_fields":[
- {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"},
- {"tag": "APIkey", "path": "*opts.*apiKey", "type": "*constant", "value": "ses12345"},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "OriginIDPrefix", "path": "*cgreq.OriginIDPrefix", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
- "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
- {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "LastUsed", "path": "*cgreq.LastUsed", "type": "*handler", "handler_id": "*sum",
- "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets"},
- ],
- },
- ]
-}
-
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/diamagent/dryrun.json b/data/conf/samples/dispatchers/diamagent/dryrun.json
deleted file mode 100644
index 850f350d3..000000000
--- a/data/conf/samples/dispatchers/diamagent/dryrun.json
+++ /dev/null
@@ -1,75 +0,0 @@
-{
-
-"diameter_agent": {
- "request_processors": [
- {
- "id": "dryrun1",
- "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.Service-Context-Id:TestDiamItDryRun"],
- "flags": ["*dryRun","*continue"],
- "request_fields":[
- {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*sms"},
- {"tag": "APIKey", "path": "*opts.*apiKey", "type": "*constant", "value": "ses12345"},
- {"tag": "Val1", "path": "*cgreq.Val1", "type": "*constant", "value": "1"},
- {"tag": "Val2", "path": "*cgreq.Val2", "type": "*constant", "value": "2"},
- {"tag": "Val3", "path": "*cgreq.Val3", "type": "*constant", "value": "3"},
- {"tag": "OptionalField", "path":"*cgreq.OptionalField", "type":"*variable",
- "value":"~*req.Inexistent", "mandatory":false},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "RequestType", "path": "*cgreq.RequestType",
- "type": "*constant", "value": "*prepaid"},
- {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "UsedUnits1", "path": "*cgreq.UsedUnits1", "type": "*variable", "mandatory": true,
- "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"},
- {"tag": "UsedUnits2", "path": "*cgreq.UsedUnits2", "type": "*variable", "mandatory": true,
- "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"},
-
- ],
- "reply_fields":[
- {"tag": "CCATemplate", "type": "*template", "value": "*cca"},
- {"tag": "ResultCode", "path": "*rep.Result-Code", "type": "*constant", "value": "2002"},
- {"tag": "RatingGroup", "path": "*rep.Multiple-Services-Credit-Control.Rating-Group",
- "type": "*constant", "value": "1"},
- {"tag": "CCTotalOctets1", "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets",
- "type": "*variable", "value": "~*cgreq.UsedUnits1"},
- {"tag": "GrantedUsage", "path": "*rep.Granted-Service-Unit.CC-Time", "type": "*sum",
- "value": "~*cgreq.Val1;~*cgreq.Val2;~*cgreq.Val3"},
- ],
- },
- {
- "id": "dryrun2",
- "filters": ["*notempty:~*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[0]:"], // make sure the CC-Total-Octets was populated in the previous processor
- "flags": ["*dryRun"],
- "request_fields":[
- {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*sms"},
- {"tag": "APIKey", "path": "*opts.*apiKey", "type": "*constant", "value": "ses12345"},
- {"tag": "Val1", "path": "*cgreq.Val1", "type": "*constant", "value": "1"},
- {"tag": "Val2", "path": "*cgreq.Val2", "type": "*constant", "value": "2"},
- {"tag": "Val3", "path": "*cgreq.Val3", "type": "*constant", "value": "3"},
- {"tag": "OptionalField", "path":"*cgreq.OptionalField", "type":"*variable",
- "value":"~*req.Inexistent", "mandatory":false},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "RequestType", "path": "*cgreq.RequestType",
- "type": "*constant", "value": "*prepaid"},
- {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "UsedUnits1", "path": "*cgreq.UsedUnits1", "type": "*variable", "mandatory": true,
- "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"},
- {"tag": "UsedUnits2", "path": "*cgreq.UsedUnits2", "type": "*variable", "mandatory": true,
- "value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"},
-
- ],
- "reply_fields":[
- {"tag": "RatingGroup", "path": "*rep.Multiple-Services-Credit-Control.Rating-Group",
- "type": "*group", "value": "2","new_branch": true},
- {"tag": "CCTotalOctets2", "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets",
- "type": "*group", "value": "~*cgreq.UsedUnits2"},
- ],
- },
-
- ],
-},
-
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/diamagent/message.json b/data/conf/samples/dispatchers/diamagent/message.json
deleted file mode 100644
index 5ae720a37..000000000
--- a/data/conf/samples/dispatchers/diamagent/message.json
+++ /dev/null
@@ -1,38 +0,0 @@
-{
-
-"diameter_agent": {
- "request_processors": [
-
- {
- "id": "message",
- "filters": ["*string:~*vars.*cmd:CCR", "*prefix:~*req.Service-Context-Id:message",
- "*string:~*req.CC-Request-Type:4"],
- "flags": ["*message", "*accounts", "*cdrs","*attributes"],
- "request_fields":[
- {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*sms"},
- {"tag": "APIKey", "path": "*opts.*apiKey", "type": "*constant", "value": "ses12345"},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "sms"},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
- "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", "mandatory": true,
- "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data"},
- {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable",
- "value": "~*req.Requested-Service-Unit.CC-Time", "mandatory": true},
- ],
- "reply_fields":[
- {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"],
- "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true},
- ],
- },
-
- ],
-},
-
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/diamagent/mms.json b/data/conf/samples/dispatchers/diamagent/mms.json
deleted file mode 100644
index eebc25d93..000000000
--- a/data/conf/samples/dispatchers/diamagent/mms.json
+++ /dev/null
@@ -1,96 +0,0 @@
-{
-
- "diameter_agent": {
- "request_processors": [
-
- {
- "id": "mms",
- "filters": [
- "*string:~*vars.*cmd:CCR",
- "*prefix:~*req.Service-Context-Id:mms",
- "*string:~*req.CC-Request-Type:4"
- ],
- "flags": ["*message", "*accounts", "*cdrs","*attributes"],
- "request_fields":[
- {
- "tag": "ToR",
- "path": "*cgreq.ToR",
- "type": "*constant",
- "value": "*mms"
- },
- { "tag": "APIKey",
- "path": "*opts.*apiKey",
- "type": "*constant",
- "value": "ses12345"
- },
- {
- "tag": "OriginID",
- "path": "*cgreq.OriginID",
- "type": "*variable",
- "value": "~*req.Session-Id",
- "mandatory": true
- },
- {
- "tag": "Category",
- "path": "*cgreq.Category",
- "type": "*constant",
- "value": "mms"
- },
- {
- "tag": "RequestType",
- "path": "*cgreq.RequestType",
- "type": "*constant",
- "value": "*prepaid"
- },
- {
- "tag": "Account",
- "path": "*cgreq.Account",
- "type": "*variable",
- "mandatory": true,
- "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
- },
- {
- "tag": "Destination",
- "path": "*cgreq.Destination",
- "type": "*variable",
- "mandatory": true,
- "value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data"
- },
- {
- "tag": "SetupTime",
- "path": "*cgreq.SetupTime",
- "type": "*variable",
- "value": "~*req.Event-Timestamp",
- "mandatory": true
- },
- {
- "tag": "AnswerTime",
- "path": "*cgreq.AnswerTime",
- "type": "*variable",
- "value": "~*req.Event-Timestamp",
- "mandatory": true
- },
- {
- "tag": "Usage",
- "path": "*cgreq.Usage",
- "type": "*variable",
- "value": "~*req.Requested-Service-Unit.CC-Time",
- "mandatory": true
- },
- ],
- "reply_fields":[
- {
- "tag": "ResultCode",
- "filters": ["*notempty:~*cgrep.Error:"],
- "path": "*rep.Result-Code",
- "type": "*constant",
- "value": "5030",
- "blocker": true
- },
- ],
- },
-
- ],
- },
-
- }
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/diamagent/simpa.json b/data/conf/samples/dispatchers/diamagent/simpa.json
deleted file mode 100644
index b6c624a2e..000000000
--- a/data/conf/samples/dispatchers/diamagent/simpa.json
+++ /dev/null
@@ -1,29 +0,0 @@
-
-{
-
-"diameter_agent": {
- "request_processors": [
- {
- "id": "simpa_event",
- "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:4",
- "*prefix:~*req.Service-Context-Id:simpa"],
- "flags": ["*message", "*accounts", "*log"],
- "request_fields":[
- {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*generic"},
- {"tag": "APIKey", "path": "*opts.*apiKey", "type": "*constant", "value": "ses12345"},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
- "value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "Usage", "path": "*cgreq.Usage", "type": "*valueExponent", "mandatory": true,
- "value": "~*req.Requested-Service-Unit.CC-Money.Unit-Value.Value-Digits;~*req.Requested-Service-Unit.CC-Money.Unit-Value.Exponent"},
- ],
- },
- ],
-},
-
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/diamagent/tests.json b/data/conf/samples/dispatchers/diamagent/tests.json
deleted file mode 100644
index 49c3fbbe7..000000000
--- a/data/conf/samples/dispatchers/diamagent/tests.json
+++ /dev/null
@@ -1,47 +0,0 @@
-
-{
-
-"diameter_agent": {
- "request_processors": [
- {
- "id": "TestSessionDisconnect",
- "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1",
- "*prefix:~*req.Service-Context-Id:testSessionDisconnect"],
- "flags": ["*initiate", "*accounts","*attributes"],
- "request_fields":[
- {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"},
- {"tag": "APIKey", "path": "*opts.*apiKey", "type": "*constant", "value": "ses12345"},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*variable",
- "value": "~*req.Origin-Host", "mandatory": true},
- {"tag": "RequestType", "path": "*cgreq.RequestType",
- "type": "*constant", "value": "*prepaid"},
- {"tag": "Category", "path": "*cgreq.Category",
- "type": "*constant", "value": "call"},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
- "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true},
- {"tag": "Subject", "path": "*cgreq.Subject", "type": "*variable",
- "value": "~*req.Service-Information.IN-Information.Calling-Party-Address", "mandatory": true},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable",
- "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable",
- "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true},
- {"tag": "DebitInterval", "path": "*opts.*ssDebitInterval",
- "type": "*constant", "value": "1s"},
- ],
- "reply_fields":[
- {"tag": "CCATemplate", "type": "*template", "value": "*cca"},
- {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"],
- "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true},
- {"tag": "GrantedUnits", "path": "*rep.Granted-Service-Unit.CC-Time",
- "filters": ["*gte:~*cgrep.MaxUsage:0s"],
- "type": "*variable", "value": "~*cgrep.MaxUsage{*duration_seconds&*round:0}", "mandatory": true},
- ],
- },
- ],
-},
-
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/diamagent/voice.json b/data/conf/samples/dispatchers/diamagent/voice.json
deleted file mode 100644
index 4018fbc7b..000000000
--- a/data/conf/samples/dispatchers/diamagent/voice.json
+++ /dev/null
@@ -1,236 +0,0 @@
-
-{
-
-"diameter_agent": {
- "request_processors": [
- {
- "id": "VoiceInitForceDuration",
- "filters": [
- "*string:~*vars.*cmd:CCR",
- "*string:~*req.CC-Request-Type:1",
- "*prefix:~*req.Service-Context-Id:forceDurationVoice"
- ],
- "flags": ["*initiate", "*fd", "*accounts", "*attributes"],
- "request_fields":[
- {
- "tag": "ToR",
- "path": "*cgreq.ToR",
- "type": "*constant",
- "value": "*voice"
- },
- {
- "tag": "OriginID",
- "path": "*cgreq.OriginID",
- "type": "*variable",
- "value": "~*req.Session-Id",
- "mandatory": true
- },
- {
- "tag": "OriginHost",
- "path": "*cgreq.OriginHost",
- "type": "*variable",
- "value": "~*vars.RemoteHost",
- "mandatory": true
- },
- {
- "tag": "RequestType",
- "path": "*cgreq.RequestType",
- "type": "*constant",
- "value": "*attributes"
- },
- {
- "tag": "Category",
- "path": "*cgreq.Category",
- "type": "*constant",
- "value": "call"
- },
- {
- "tag": "Account",
- "path": "*cgreq.Account",
- "type": "*constant",
- "value": "*attributes"
- },
- {
- "tag": "Destination",
- "path": "*cgreq.Destination",
- "type": "*variable",
- "value": "~*req.Service-Information.IN-Information.Real-Called-Number",
- "mandatory": true
- },
- {
- "tag": "AnswerTime",
- "path": "*cgreq.AnswerTime",
- "type": "*variable",
- "value": "~*req.Event-Timestamp",
- "mandatory": true
- },
- {
- "tag": "Usage",
- "path": "*cgreq.Usage",
- "type": "*variable",
- "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/",
- "mandatory": true
- },
- {
- "tag": "SubscriberID",
- "path": "*cgreq.SubscriberId",
- "type": "*variable",
- "value": "~*req.Subscription-Id.Subscription-Id-Data",
- "mandatory": true
- },
- ],
- "reply_fields":[
- {
- "tag": "ResultCode",
- "filters": ["*notempty:~*cgrep.Error:"],
- "path": "*rep.Result-Code",
- "type": "*constant",
- "value": "5030",
- "blocker": true
- },
- {
- "tag": "ResultCode",
- "path": "*rep.Result-Code",
- "type": "*constant",
- "value": "2001"
- },
- {
- "tag": "GrantedUnits",
- "path": "*rep.Granted-Service-Unit.CC-Time",
- "type": "*variable",
- "value": "~*cgrep.MaxUsage{*duration_seconds}",
- "mandatory": true
- },
- ],
- },
- {
- "id": "VoiceInit",
- "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1",
- "*prefix:~*req.Service-Context-Id:voice"],
- "flags": ["*initiate", "*accounts", "*attributes","*continue"],
- "request_fields":[
- {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"},
- {"tag": "APIKey", "path": "*opts.*apiKey", "type": "*constant", "value": "ses12345"},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*variable",
- "value": "~*vars.RemoteHost", "mandatory": true},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*attributes"},
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*constant", "value": "*attributes"},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable",
- "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable",
- "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true},
- {"tag": "SubscriberID", "path": "*cgreq.SubscriberId", "type": "*variable",
- "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true},
- ],
- "reply_fields":[
- {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"],
- "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true},
- {"tag": "ResultCode", "path": "*rep.Result-Code", "type": "*constant", "value": "2001"},
- {"tag": "GrantedUnits", "path": "*rep.Granted-Service-Unit.CC-Time", "type": "*variable",
- "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
- ],
- },
- {
- "id": "VoiceTerminateEmulate",
- "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1",
- "*prefix:~*req.Service-Context-Id:voice","*eq:~*cgrep.MaxUsage:0"],
- "flags": ["*terminate", "*accounts", "*attributes"],
- "request_fields":[
- {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"},
- {"tag": "APIKey", "path": "*opts.*apiKey", "type": "*constant", "value": "ses12345"},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*variable",
- "value": "~*vars.RemoteHost", "mandatory": true},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*attributes"},
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*constant", "value": "*attributes"},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable",
- "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable",
- "value": "0s", "mandatory": true},
- {"tag": "SubscriberID", "path": "*cgreq.SubscriberId", "type": "*variable",
- "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true}
- ],
- "reply_fields":[
- {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"],
- "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true},
- {"tag": "ResultCode", "path": "*rep.Result-Code", "type": "*constant", "value": "2001"},
- ],
- },
- {
- "id": "VoiceUpdate",
- "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2",
- "*prefix:~*req.Service-Context-Id:voice"],
- "flags": ["*update", "*accounts", "*attributes"],
- "request_fields":[
- {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"},
- {"tag": "APIKey", "path": "*opts.*apiKey", "type": "*constant", "value": "ses12345"},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*variable",
- "value": "~*vars.RemoteHost", "mandatory": true},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*attributes"},
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*constant", "value": "*attributes"},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable",
- "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "Usage", "path": "*cgreq.Usage", "type": "*variable",
- "value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true},
- {"tag": "LastUsed", "path": "*cgreq.LastUsed", "type": "*variable",
- "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true},
- {"tag": "SubscriberID", "path": "*cgreq.SubscriberId", "type": "*variable",
- "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true},
- ],
- "reply_fields":[
- {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"],
- "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true},
- {"tag": "ResultCode", "path": "*rep.Result-Code", "type": "*constant", "value": "2001"},
- {"tag": "GrantedUnits", "path": "*rep.Granted-Service-Unit.CC-Time", "type": "*variable",
- "value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
- ],
- },
- {
- "id": "VoiceTerminate",
- "filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:3",
- "*prefix:~*req.Service-Context-Id:voice"],
- "flags": ["*terminate", "*accounts", "*attributes", "*cdrs"],
- "request_fields":[
- {"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*voice"},
- {"tag": "APIKey", "path": "*opts.*apiKey", "type": "*constant", "value": "ses12345"},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*variable",
- "value": "~*req.Session-Id", "mandatory": true},
- {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*variable",
- "value": "~*vars.RemoteHost", "mandatory": true},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*attributes"},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*constant", "value": "*attributes"},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable",
- "value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "Usage", "path": "*cgreq.Usage", "type": "*ccUsage", "mandatory": true,
- "value": "~*req.CC-Request-Number;~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/;5m"},
- {"tag": "LastUsed", "path": "*cgreq.LastUsed", "type": "*variable",
- "value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true},
- {"tag": "SubscriberID", "path": "*cgreq.SubscriberId", "type": "*variable",
- "value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true},
- ],
- "reply_fields":[
- {"tag": "ResultCode", "filters": ["*notempty:~*cgrep.Error:"],
- "path": "*rep.Result-Code", "type": "*constant", "value": "5030", "blocker": true},
- {"tag": "ResultCode", "path": "*rep.Result-Code", "type": "*constant", "value": "2001"},
- ],
- },
- ],
-},
-
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/dispatchers_internal/cgrates.json b/data/conf/samples/dispatchers/dispatchers_internal/cgrates.json
deleted file mode 100644
index d14262ad0..000000000
--- a/data/conf/samples/dispatchers/dispatchers_internal/cgrates.json
+++ /dev/null
@@ -1,64 +0,0 @@
-{
-
-"general": {
- "node_id": "DispatcherS1",
- "reconnects": 1,
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":2012",
- "rpc_gob": ":2013",
- "http": ":2080",
-},
-
-
-"data_db": {
- "db_type": "*internal",
-},
-
-"caches":{
- "partitions": {
- "*dispatcher_routes": {"limit": -1, "ttl": "2s"}
- },
-},
-
-"attributes": {
- "enabled": true
-},
-
-"rates": {
- "enabled": true,
-},
-
-
-"chargers": {
- "enabled": true,
-},
-
-
-"sessions": {
- "enabled": true,
- "attributes_conns": ["*localhost"],
- "rates_conns": ["*localhost"],
- "resources_conns": ["*localhost"],
- "chargers_conns": ["*localhost"],
- "listen_bijson": ":3014",
-},
-
-
-"dispatchers":{
- "enabled": true,
- "attributes_conns": ["*internal"],
-},
-
-
-"admins": {
- "enabled": true,
-},
-
-
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/dispatchers_internal_gob/cgrates.json b/data/conf/samples/dispatchers/dispatchers_internal_gob/cgrates.json
deleted file mode 100644
index 2247a6a5f..000000000
--- a/data/conf/samples/dispatchers/dispatchers_internal_gob/cgrates.json
+++ /dev/null
@@ -1,75 +0,0 @@
-{
-
- // Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
- // Copyright (C) ITsysCOM GmbH
- //
- // This file contains the default configuration hardcoded into CGRateS.
- // This is what you get when you load CGRateS with an empty configuration file.
-
- "general": {
- "node_id": "DispatcherS1",
- "reconnects": 1,
- },
-
- "logger": {
- "level": 7
- },
-
-
- "listen": {
- "rpc_json": ":2012",
- "rpc_gob": ":2013",
- "http": ":2080",
- },
-
-
- "data_db": {
- "db_type": "*internal",
- },
-
- "caches":{
- "partitions": {
- "*dispatcher_routes": {"limit": -1, "ttl": "2s"}
- },
- },
-
- "attributes": {
- "enabled": true
- },
-
- "rates": {
- "enabled": true,
- },
-
-
- "chargers": {
- "enabled": true,
- },
-
- "rpc_conns": {
- "conn1": {
- "strategy": "*first",
- "conns": [{"address": "127.0.0.1:2013", "transport":"*gob"}],
- },
- },
-
- "sessions": {
- "enabled": true,
- "attributes_conns": ["conn1"],
- "rates_conns": ["conn1"],
- "resources_conns": ["conn1"],
- "chargers_conns": ["conn1"],
- "listen_bijson": ":3014",
- },
-
-
- "dispatchers":{
- "enabled": true,
- "attributes_conns": ["*internal"],
- },
-
-
- "admins": {
- "enabled": true,
- },
- }
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/dispatchers_mongo/cgrates.json b/data/conf/samples/dispatchers/dispatchers_mongo/cgrates.json
deleted file mode 100644
index bbd8cd417..000000000
--- a/data/conf/samples/dispatchers/dispatchers_mongo/cgrates.json
+++ /dev/null
@@ -1,71 +0,0 @@
-{
-
-// Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-// Copyright (C) ITsysCOM GmbH
-//
-// This file contains the default configuration hardcoded into CGRateS.
-// This is what you get when you load CGRateS with an empty configuration file.
-
-"general": {
- "node_id": "DispatcherS1",
- "reconnects": 1,
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":2012",
- "rpc_gob": ":2013",
- "http": ":2080",
-},
-
-"data_db": {
- "db_type": "mongo",
- "db_name": "10",
- "db_port": 27017,
-},
-
-
-
-
-"caches":{
- "partitions": {
- "*dispatcher_routes": {"limit": -1, "ttl": "2s"}
- },
-},
-
-"rates": {
- "enabled": true,
-},
-
-"attributes": {
- "enabled": true
-},
-
-
-"chargers": {
- "enabled": true,
-},
-
-"sessions": {
- "enabled": true,
- "attributes_conns": ["*localhost"],
- "rates_conns": ["*localhost"],
- "resources_conns": ["*localhost"],
- "chargers_conns": ["*localhost"],
- "listen_bijson": ":3014",
-},
-
-
-"dispatchers":{
- "enabled": true,
- "attributes_conns": ["*internal"],
-},
-
-
-"admins": {
- "enabled": true,
-},
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/dispatchers_mongo_gob/cgrates.json b/data/conf/samples/dispatchers/dispatchers_mongo_gob/cgrates.json
deleted file mode 100644
index deda48181..000000000
--- a/data/conf/samples/dispatchers/dispatchers_mongo_gob/cgrates.json
+++ /dev/null
@@ -1,79 +0,0 @@
-{
-
-// Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-// Copyright (C) ITsysCOM GmbH
-//
-// This file contains the default configuration hardcoded into CGRateS.
-// This is what you get when you load CGRateS with an empty configuration file.
-
-"general": {
- "node_id": "DispatcherS1",
- "reconnects": 1,
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":2012",
- "rpc_gob": ":2013",
- "http": ":2080",
-},
-
-"data_db": {
- "db_type": "mongo",
- "db_name": "10",
- "db_port": 27017,
-},
-
-
-
-
-"caches":{
- "partitions": {
- "*dispatcher_routes": {"limit": -1, "ttl": "2s"}
- },
-},
-
-"rates": {
- "enabled": true,
-},
-
-
-"attributes": {
- "enabled": true
-},
-
-
-"chargers": {
- "enabled": true,
-},
-
-"rpc_conns": {
- "conn1": {
- "strategy": "*first",
- "conns": [{"address": "127.0.0.1:2013", "transport":"*gob"}],
- },
-},
-
-"sessions": {
- "enabled": true,
- "attributes_conns": ["conn1"],
- "rates_conns": ["conn1"],
- "resources_conns": ["conn1"],
- "chargers_conns": ["conn1"],
- "listen_bijson": ":3014",
-},
-
-
-"dispatchers":{
- "enabled": true,
- "attributes_conns": ["*internal"],
-},
-
-
-"admins": {
- "enabled": true,
-},
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/dispatchers_mysql/cgrates.json b/data/conf/samples/dispatchers/dispatchers_mysql/cgrates.json
deleted file mode 100644
index 40d7b45a9..000000000
--- a/data/conf/samples/dispatchers/dispatchers_mysql/cgrates.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
-
-"general": {
- "node_id": "DispatcherS1",
- "reconnects": 1
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":2012",
- "rpc_gob": ":2013",
- "http": ":2080"
-},
-
-"stor_db": {
- "db_type":"*internal"
-},
-
-"caches":{
- "partitions": {
- "*dispatcher_routes": {"limit": -1, "ttl": "2s"}
- }
-},
-
-"attributes": {
- "enabled": true
-},
-
-"chargers": {
- "enabled": true
-},
-
-"sessions": {
- "enabled": true,
- "attributes_conns": ["*localhost"],
- "rates_conns": ["*localhost"],
- "resources_conns": ["*localhost"],
- "chargers_conns": ["*localhost"],
- "listen_bijson": ":3014"
-},
-
-"dispatchers":{
- "enabled": true,
- "attributes_conns": ["*internal"]
-},
-
-"admins": {
- "enabled": true
-}
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/dispatchers_mysql_gob/cgrates.json b/data/conf/samples/dispatchers/dispatchers_mysql_gob/cgrates.json
deleted file mode 100644
index 168461e88..000000000
--- a/data/conf/samples/dispatchers/dispatchers_mysql_gob/cgrates.json
+++ /dev/null
@@ -1,75 +0,0 @@
-{
-
- // Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
- // Copyright (C) ITsysCOM GmbH
- //
- // This file contains the default configuration hardcoded into CGRateS.
- // This is what you get when you load CGRateS with an empty configuration file.
-
- "general": {
- "node_id": "DispatcherS1",
- "reconnects": 1,
- },
-
- "logger": {
- "level": 7
- },
-
- "listen": {
- "rpc_json": ":2012",
- "rpc_gob": ":2013",
- "http": ":2080",
- },
-
-
- "data_db": { // database used to store runtime data (eg: accounts, cdr stats)
- "db_type": "redis", // data_db type:
- "db_port": 6379, // data_db port to reach the database
- "db_name": "10", // data_db database name to connect to
-
- },
-
-
-
- "caches":{
- "partitions": {
- "*dispatcher_routes": {"limit": -1, "ttl": "2s"}
- },
- },
-
- "attributes": {
- "enabled": true
- },
-
-
- "chargers": {
- "enabled": true,
- },
-
- "rpc_conns": {
- "conn1": {
- "strategy": "*first",
- "conns": [{"address": "127.0.0.1:2013", "transport":"*gob"}],
- },
- },
-
- "sessions": {
- "enabled": true,
- "attributes_conns": ["conn1"],
- "rates_conns": ["conn1"],
- "resources_conns": ["conn1"],
- "chargers_conns": ["conn1"],
- "listen_bijson": ":3014",
- },
-
-
- "dispatchers":{
- "enabled": true,
- "attributes_conns": ["*internal"],
- },
-
-
- "admins": {
- "enabled": true,
- },
- }
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/dispatchers_no_attributes/cgrates.json b/data/conf/samples/dispatchers/dispatchers_no_attributes/cgrates.json
deleted file mode 100644
index f483b3d4e..000000000
--- a/data/conf/samples/dispatchers/dispatchers_no_attributes/cgrates.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
-
-"general": {
- "node_id": "DispatcherS1",
- "reconnects": 1
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":2012",
- "rpc_gob": ":2013",
- "http": ":2080"
-},
-
-"stor_db": {
- "db_type":"*internal"
-},
-
-"caches":{
- "partitions": {
- "*dispatcher_routes": {"limit": -1, "ttl": "2s"}
- }
-},
-
-"sessions": {
- "enabled": true,
- "listen_bijson": ":3014"
-},
-
-"dispatchers":{
- "enabled": true
-},
-
-"admins": {
- "enabled": true
-}
-
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/radagent/accounting.json b/data/conf/samples/dispatchers/radagent/accounting.json
deleted file mode 100644
index dd120a3bf..000000000
--- a/data/conf/samples/dispatchers/radagent/accounting.json
+++ /dev/null
@@ -1,64 +0,0 @@
-{
-
-"radius_agent": {
- "request_processors": [
- {
- "id": "KamailioAccountingStart",
- "filters": ["*string:~*req.Acct-Status-Type:Start"],
- "flags": ["*initiate", "*attributes", "*resources", "*accounts"],
- "request_fields":[
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant",
- "value": "*prepaid", "mandatory": true},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed",
- "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag;-;~*req.Sip-To-Tag", "mandatory": true},
- {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*composed",
- "value": "~*req.NAS-IP-Address", "mandatory": true},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*composed",
- "value": "~*req.User-Name", "mandatory": true},
- {"tag": "Subject", "path": "*cgreq.Subject", "type": "*composed",
- "value": "~*req.User-Name", "mandatory": true},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*composed",
- "value": "~*req.Called-Station-Id", "mandatory": true},
- {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*composed",
- "value": "~*req.Ascend-User-Acct-Time", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*composed",
- "value": "~*req.Ascend-User-Acct-Time", "mandatory": true},
- {"tag": "RemoteAddr" , "path": "*cgreq.RemoteAddr", "type": "*variable",
- "value": "~*vars.RemoteHost:s/(.*):\\d+/${1}/"},
- ],
- "reply_fields":[],
- },
- {
- "id": "KamailioAccountingStop",
- "filters": ["*string:~*req.Acct-Status-Type:Stop"],
- "flags": ["*terminate", "*resources", "*accounts", "*cdrs"],
- "request_fields":[
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant",
- "value": "*prepaid", "mandatory": true},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed",
- "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag;-;~*req.Sip-To-Tag", "mandatory": true},
- {"tag": "OriginHost", "path": "*cgreq.OriginHost", "type": "*composed",
- "value": "~*req.NAS-IP-Address", "mandatory": true},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*composed",
- "value": "~*req.User-Name", "mandatory": true},
- {"tag": "Subject", "path": "*cgreq.Subject", "type": "*composed",
- "value": "~*req.User-Name", "mandatory": true},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*composed",
- "value": "~*req.Called-Station-Id", "mandatory": true},
- {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*composed",
- "value": "~*req.Ascend-User-Acct-Time", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*composed",
- "value": "~*req.Ascend-User-Acct-Time", "mandatory": true},
- {"tag": "Usage", "path": "*cgreq.Usage", "type": "*usageDifference",
- "value": "~*req.Event-Timestamp;~*req.Ascend-User-Acct-Time", "mandatory": true},
- {"tag": "RemoteAddr" , "path": "*cgreq.RemoteAddr", "type": "*variable",
- "value": "~*vars.RemoteHost:s/(.*):\\d+/${1}/"},
- ],
- "reply_fields":[],
- },
- ],
- },
-
-},
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/radagent/authchallenge.json b/data/conf/samples/dispatchers/radagent/authchallenge.json
deleted file mode 100644
index f6d006747..000000000
--- a/data/conf/samples/dispatchers/radagent/authchallenge.json
+++ /dev/null
@@ -1,62 +0,0 @@
-{
- "radius_agent": {
- "request_processors": [
- {
- "id": "Challenge",
- "filters": ["*string:~*vars.*radReqType:*radAuth", "*string:~*req.Sip-From-Tag:12345678",
- "*empty:~*req.User-Password:"],
- "flags": ["*none", "*log"],
- "reply_fields":[
- {"tag": "Code", "path": "*rep.*radReplyCode",
- "type": "*constant", "value": "AccessChallenge"},
- {"tag": "ReplyMessage", "path": "*rep.Reply-Message",
- "type": "*constant", "value": "Missing User-Password"}
- ],
- },
- {
- "id": "CGRAuth",
- "filters": ["*string:~*vars.*radReqType:*radAuth", "*string:~*req.Sip-From-Tag:12345678"],
- "flags": ["*authorize", "*attributes", "*accounts", "*continue"],
- "request_fields":[
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant",
- "value": "*prepaid", "mandatory": true},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed",
- "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag", "mandatory": true},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*composed",
- "value": "~*req.User-Name", "mandatory": true},
- {"tag": "Subject", "path": "*cgreq.Subject", "type": "*composed",
- "value": "~*req.User-Name", "mandatory": true},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*composed",
- "value": "~*req.Called-Station-Id", "mandatory": true},
- {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*composed",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*composed",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "PasswordFromAttributes", "path": "*cgreq.PasswordFromAttributes", "type": "*constant",
- "value": "*attributes"}
- ],
- "reply_fields":[
- {"tag": "MaxUsage", "path": "*rep.SIP-AVP", "type": "*composed",
- "value": "session_max_time#;~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
- ],
- },
- {
- "id": "RadiusAuthProcessorChallenge",
- "filters": ["*string:~*vars.*radReqType:*radAuth","*string:~*req.Sip-From-Tag:12345678"],
- "flags": ["*radauth", "*pap", "*log"],
- "request_fields":[
- {"tag": "UserPassword", "path": "*vars.UserPassword", "type": "*variable",
- "value": "~*cgrep.Attributes.PasswordFromAttributes"},
- ],
- "reply_fields":[
- {"tag":"RemoveAddedFields", "filters": ["*notempty:~*cgrep.Error:"], "type": "*removeall", "path": "*rep"},
- {"tag": "Code", "path": "*rep.*radReplyCode", "filters": ["*notempty:~*cgrep.Error:"],
- "type": "*constant", "value": "AccessReject"},
- {"tag": "ReplyMessage", "path": "*rep.Reply-Message", "filters": ["*notempty:~*cgrep.Error:"],
- "type": "*variable", "value": "~*cgrep.Error"}
- ]
- },
- ],
- }
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/radagent/authchap.json b/data/conf/samples/dispatchers/radagent/authchap.json
deleted file mode 100644
index 39193305d..000000000
--- a/data/conf/samples/dispatchers/radagent/authchap.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
-
- "radius_agent": {
- "request_processors": [
- {
- "id": "CGRCHAPAuth",
- "filters": ["*string:~*vars.*radReqType:*radAuth", "*string:~*req.Sip-From-Tag:51585362"],
- "flags": ["*authorize", "*attributes", "*accounts", "*continue"],
- "request_fields":[
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant",
- "value": "*prepaid", "mandatory": true},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed",
- "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag", "mandatory": true},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*composed",
- "value": "~*req.User-Name", "mandatory": true},
- {"tag": "Subject", "path": "*cgreq.Subject", "type": "*composed",
- "value": "~*req.User-Name", "mandatory": true},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*composed",
- "value": "~*req.Called-Station-Id", "mandatory": true},
- {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*composed",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*composed",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "PasswordFromAttributes", "path": "*cgreq.PasswordFromAttributes", "type": "*constant",
- "value": "*attributes"}
- ],
- "reply_fields":[
- {"tag": "MaxUsage", "path": "*rep.SIP-AVP", "type": "*composed",
- "value": "session_max_time#;~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
- ],
- },
- {
- "id": "RadiusCHAPAuthProcessor",
- "filters": ["*string:~*vars.*radReqType:*radAuth", "*string:~*req.Sip-From-Tag:51585362"],
- "flags": ["*radauth", "*chap", "*log"],
- "request_fields":[
- {"tag": "UserPassword", "path": "*vars.UserPassword", "type": "*variable",
- "value": "~*cgrep.Attributes.PasswordFromAttributes"},
- ],
- "reply_fields":[
- {"tag":"RemoveAddedFields", "filters": ["*notempty:~*cgrep.Error:"], "type": "*removeall", "path": "*rep"},
- {"tag": "Code", "path": "*rep.*radReplyCode", "filters": ["*notempty:~*cgrep.Error:"],
- "type": "*constant", "value": "AccessReject"},
- {"tag": "ReplyMessage", "path": "*rep.Reply-Message", "filters": ["*notempty:~*cgrep.Error:"],
- "type": "*variable", "value": "~*cgrep.Error"}
- ]
- },
- ],
- }
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/radagent/authmschapv2.json b/data/conf/samples/dispatchers/radagent/authmschapv2.json
deleted file mode 100644
index 23ee13dc8..000000000
--- a/data/conf/samples/dispatchers/radagent/authmschapv2.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
- "radius_agent": {
- "request_processors": [
- {
- "id": "CGRMSCHAPV2PAuth",
- "filters": ["*string:~*vars.*radReqType:*radAuth", "*string:~*req.Sip-From-Tag:51585363"],
- "flags": ["*authorize", "*attributes", "*accounts", "*continue"],
- "request_fields":[
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant",
- "value": "*prepaid", "mandatory": true},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed",
- "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag", "mandatory": true},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*composed",
- "value": "~*req.User-Name", "mandatory": true},
- {"tag": "Subject", "path": "*cgreq.Subject", "type": "*composed",
- "value": "~*req.User-Name", "mandatory": true},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*composed",
- "value": "~*req.Called-Station-Id", "mandatory": true},
- {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*composed",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*composed",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "PasswordFromAttributes", "path": "*cgreq.PasswordFromAttributes", "type": "*constant",
- "value": "*attributes"}
- ],
- "reply_fields":[
- {"tag": "MaxUsage", "path": "*rep.SIP-AVP", "type": "*composed",
- "value": "session_max_time#;~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
- ],
- },
- {
- "id": "RadiusAuthProcessor",
- "filters": ["*string:~*vars.*radReqType:*radAuth", "*string:~*req.Sip-From-Tag:51585363"],
- "flags": ["*radauth", "*mschapv2", "*log"],
- "request_fields":[
- {"tag": "UserPassword", "path": "*vars.UserPassword", "type": "*variable",
- "value": "~*cgrep.Attributes.PasswordFromAttributes"},
- ],
- "reply_fields":[
- {"tag":"RemoveAddedFields", "filters": ["*notempty:~*cgrep.Error:"], "type": "*removeall", "path": "*rep"},
- {"tag": "Code", "path": "*rep.*radReplyCode", "filters": ["*notempty:~*cgrep.Error:"],
- "type": "*constant", "value": "AccessReject"},
- {"tag": "ReplyMessage", "path": "*rep.Reply-Message", "filters": ["*notempty:~*cgrep.Error:"],
- "type": "*variable", "value": "~*cgrep.Error"}
- ]
- },
-
- ],
- }
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/radagent/authpapauth.json b/data/conf/samples/dispatchers/radagent/authpapauth.json
deleted file mode 100644
index 5910e8614..000000000
--- a/data/conf/samples/dispatchers/radagent/authpapauth.json
+++ /dev/null
@@ -1,51 +0,0 @@
-{
-
- "radius_agent": {
- "request_processors": [
- {
- "id": "CGRPAPAuth",
- "filters": ["*string:~*vars.*radReqType:*radAuth", "*string:~*req.Sip-From-Tag:51585361"],
- "flags": ["*authorize", "*attributes", "*accounts", "*continue"],
- "request_fields":[
- {"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "call"},
- {"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant",
- "value": "*prepaid", "mandatory": true},
- {"tag": "OriginID", "path": "*cgreq.OriginID", "type": "*composed",
- "value": "~*req.Acct-Session-Id;-;~*req.Sip-From-Tag", "mandatory": true},
- {"tag": "Account", "path": "*cgreq.Account", "type": "*composed",
- "value": "~*req.User-Name", "mandatory": true},
- {"tag": "Subject", "path": "*cgreq.Subject", "type": "*composed",
- "value": "~*req.User-Name", "mandatory": true},
- {"tag": "Destination", "path": "*cgreq.Destination", "type": "*composed",
- "value": "~*req.Called-Station-Id", "mandatory": true},
- {"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*composed",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*composed",
- "value": "~*req.Event-Timestamp", "mandatory": true},
- {"tag": "PasswordFromAttributes", "path": "*cgreq.PasswordFromAttributes", "type": "*constant",
- "value": "*attributes"}
- ],
- "reply_fields":[
- {"tag": "MaxUsage", "path": "*rep.SIP-AVP", "type": "*composed",
- "value": "session_max_time#;~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
- ],
- },
- {
- "id": "RadiusPAPAuthProcessor",
- "filters": ["*string:~*vars.*radReqType:*radAuth", "*string:~*req.Sip-From-Tag:51585361"],
- "flags": ["*radauth", "*pap", "*log"],
- "request_fields":[
- {"tag": "UserPassword", "path": "*vars.UserPassword", "type": "*variable",
- "value": "~*cgrep.Attributes.PasswordFromAttributes"},
- ],
- "reply_fields":[
- {"tag":"RemoveAddedFields", "filters": ["*notempty:~*cgrep.Error:"], "type": "*removeall", "path": "*rep"},
- {"tag": "Code", "path": "*rep.*radReplyCode", "filters": ["*notempty:~*cgrep.Error:"],
- "type": "*constant", "value": "AccessReject"},
- {"tag": "ReplyMessage", "path": "*rep.Reply-Message", "filters": ["*notempty:~*cgrep.Error:"],
- "type": "*variable", "value": "~*cgrep.Error"}
- ]
- },
- ],
- }
-}
\ No newline at end of file
diff --git a/data/conf/samples/dispatchers/radagent/cgrates.json b/data/conf/samples/dispatchers/radagent/cgrates.json
deleted file mode 100644
index 32a5f57bf..000000000
--- a/data/conf/samples/dispatchers/radagent/cgrates.json
+++ /dev/null
@@ -1,60 +0,0 @@
-{
-// CGRateS Configuration file
-//
-
-"general": {
- "node_id": "DispatcherS1",
- "reconnects": 1,
-},
-
-"logger": {
- "level": 7
-},
-
-"listen": {
- "rpc_json": ":2012", // RPC JSON listening address
- "rpc_gob": ":2013", // RPC GOB listening address
- "http": ":2080", // HTTP listening address
-},
-
-"data_db": { // database used to store runtime data (eg: accounts, cdr stats)
- "db_type": "mongo", // stor database type to use:
- "db_port": 27017, // the port to reach the datadb
- "db_name": "datadb",
- "db_password": "",
-},
-
-
-
-"attributes": {
- "enabled": true
-},
-
-"schedulers": {
- "enabled": true,
-},
-
-"rals": {
- "enabled": true,
-},
-
-"dispatchers":{
- "enabled": true,
-},
-
-"sessions": {
- "enabled": true,
- "debit_interval": "10s",
-},
-
-
-"radius_agent": {
- "enabled": true,
- "sessions_conns": ["*localhost"],
-},
-
-"admins": {
- "enabled": true,
- "scheduler_conns": ["*internal"],
-},
-}
diff --git a/data/conf/samples/export_it_test_mongo/cgrates.json b/data/conf/samples/export_it_test_mongo/cgrates.json
index 20049503b..ebd1d9bb5 100644
--- a/data/conf/samples/export_it_test_mongo/cgrates.json
+++ b/data/conf/samples/export_it_test_mongo/cgrates.json
@@ -164,8 +164,6 @@
"*thresholds":{"limit": -1, "ttl": "5s", "static_ttl": false},
"*routes":{"limit": -1, "ttl": "5s", "static_ttl": false},
"*chargers":{"limit": -1, "ttl": "5s", "static_ttl": false},
- "*dispatchers":{"limit": -1, "ttl": "5s", "static_ttl": false},
- "*dispatcher_hosts":{"limit": -1, "ttl": "5s", "static_ttl": false},
"*rate_profiles":{"limit": -1, "ttl": "5s", "static_ttl": false},
"*action_profiles":{"limit": -1, "ttl": "5s", "static_ttl": false},
"*accounts":{"limit": -1, "ttl": "5s", "static_ttl": false},
@@ -284,41 +282,6 @@
{"tag": "AttributeIDs", "path": "AttributeIDs", "type": "*variable", "value": "~*req.6"},
],
},
- {
- "type": "*dispatchers", // data source type
- "file_name": "DispatcherProfiles.csv", // file name in the tp_in_dir
- "fields": [
- {"tag": "Tenant", "path": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
- {"tag": "ID", "path": "ID", "type": "*variable", "value": "~*req.1", "mandatory": true},
- {"tag": "FilterIDs", "path": "FilterIDs", "type": "*variable", "value": "~*req.2"},
- {"tag": "Weight", "path": "Weight", "type": "*variable", "value": "~*req.3"},
- {"tag": "Strategy", "path": "Strategy", "type": "*variable", "value": "~*req.4"},
- {"tag": "StrategyParameters", "path": "StrategyParams", "type": "*variable", "value": "~*req.5"},
- {"tag": "ConnID", "path": "Hosts.ID", "type": "*variable", "value": "~*req.6","new_branch":true},
- {"tag": "ConnFilterIDs", "path": "Hosts.FilterIDs", "type": "*variable", "value": "~*req.7"},
- {"tag": "ConnWeight", "path": "Hosts.Weight", "type": "*variable", "value": "~*req.8"},
- {"tag": "ConnBlocker", "path": "Hosts.Blocker", "type": "*variable", "value": "~*req.9"},
- {"tag": "ConnParameters", "path": "Hosts.Params", "type": "*variable", "value": "~*req.10"},
- ],
- },
- {
- "type": "*dispatcher_hosts", // data source type
- "file_name": "DispatcherHosts.csv", // file name in the tp_in_dir
- "fields": [
- {"tag": "Tenant", "path": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
- {"tag": "ID", "path": "ID", "type": "*variable", "value": "~*req.1", "mandatory": true},
- {"tag": "Address", "path": "Address", "type": "*variable", "value": "~*req.2"},
- {"tag": "Transport", "path": "Transport", "type": "*variable", "value": "~*req.3"},
- {"tag": "ConnectAttempts", "path": "ConnectAttempts", "type": "*variable", "value":"~*req.4"},
- {"tag": "Reconnects", "path": "Reconnects", "type": "*variable", "value":"~*req.5"},
- {"tag": "ConnectTimeout", "path": "ConnectTimeout", "type": "*variable", "value":"~*req.6"},
- {"tag": "ReplyTimeout", "path": "ReplyTimeout", "type": "*variable", "value":"~*req.7"},
- {"tag": "TLS", "path": "TLS", "type": "*variable", "value": "~*req.8"},
- {"tag": "ClientKey", "path": "ClientKey", "type": "*variable", "value":"~*req.9"},
- {"tag": "ClientCertificate", "path": "ClientCertificate", "type": "*variable", "value":"~*req.10"},
- {"tag": "CaCertificate", "path": "CaCertificate", "type": "*variable", "value":"~*req.11"},
- ],
- },
{
"type": "*rate_profiles", // data source type
"file_name": "Rates.csv", // file name in the tp_in_dir
diff --git a/data/conf/samples/filtered_replication/engine1_mongo/cgrates.json b/data/conf/samples/filtered_replication/engine1_mongo/cgrates.json
index a61f5a071..1ad9cbda1 100644
--- a/data/conf/samples/filtered_replication/engine1_mongo/cgrates.json
+++ b/data/conf/samples/filtered_replication/engine1_mongo/cgrates.json
@@ -38,8 +38,6 @@
"*route_profiles":{"remote":true,"replicate":false},
"*attribute_profiles":{"remote":true,"replicate":false},
"*charger_profiles": {"remote":true,"replicate":false},
- "*dispatcher_profiles":{"remote":true,"replicate":false},
- "*dispatcher_hosts":{"remote":true,"replicate":false},
"*rate_profiles":{"remote":true,"replicate":false},
"*load_ids":{"remote":true,"replicate":false},
"*indexes":{"remote":true, "replicate":false},
diff --git a/data/conf/samples/filtered_replication/engine1_redis/cgrates.json b/data/conf/samples/filtered_replication/engine1_redis/cgrates.json
index 02fa6f4e1..ca5aa822d 100644
--- a/data/conf/samples/filtered_replication/engine1_redis/cgrates.json
+++ b/data/conf/samples/filtered_replication/engine1_redis/cgrates.json
@@ -39,8 +39,6 @@
"*route_profiles":{"remote":true,"replicate":false},
"*attribute_profiles":{"remote":true,"replicate":false},
"*charger_profiles": {"remote":true,"replicate":false},
- "*dispatcher_profiles":{"remote":true,"replicate":false},
- "*dispatcher_hosts":{"remote":true,"replicate":false},
"*rate_profiles":{"remote":true,"replicate":false},
"*load_ids":{"remote":true,"replicate":false},
"*indexes":{"remote":true, "replicate":false},
diff --git a/data/conf/samples/filtered_replication/engine2_mongo/cgrates.json b/data/conf/samples/filtered_replication/engine2_mongo/cgrates.json
index 86c1eb317..067ccf81c 100644
--- a/data/conf/samples/filtered_replication/engine2_mongo/cgrates.json
+++ b/data/conf/samples/filtered_replication/engine2_mongo/cgrates.json
@@ -39,9 +39,6 @@
"*route_profiles":{"remote":true,"replicate":false},
"*attribute_profiles":{"remote":true,"replicate":false},
"*charger_profiles": {"remote":true,"replicate":false},
- "*dispatcher_profiles":{"remote":true,"replicate":false},
- "*dispatcher_hosts":{"remote":true,"replicate":false},
- "*rate_profiles":{"remote":true,"replicate":false},
"*load_ids":{"remote":true,"replicate":false},
"*indexes":{"remote":true, "replicate":false},
"*action_profiles":{"remote":true,"replicate":false},
diff --git a/data/conf/samples/filtered_replication/engine2_redis/cgrates.json b/data/conf/samples/filtered_replication/engine2_redis/cgrates.json
index 45729b1c0..9f34e8765 100644
--- a/data/conf/samples/filtered_replication/engine2_redis/cgrates.json
+++ b/data/conf/samples/filtered_replication/engine2_redis/cgrates.json
@@ -39,8 +39,6 @@
"*route_profiles":{"remote":true,"replicate":false},
"*attribute_profiles":{"remote":true,"replicate":false},
"*charger_profiles": {"remote":true,"replicate":false},
- "*dispatcher_profiles":{"remote":true,"replicate":false},
- "*dispatcher_hosts":{"remote":true,"replicate":false},
"*rate_profiles":{"remote":true,"replicate":false},
"*load_ids":{"remote":true,"replicate":false},
"*indexes":{"remote":true, "replicate":false},
diff --git a/data/conf/samples/filtered_replication/internal/cgrates.json b/data/conf/samples/filtered_replication/internal/cgrates.json
index 81eaf5758..0813d3972 100644
--- a/data/conf/samples/filtered_replication/internal/cgrates.json
+++ b/data/conf/samples/filtered_replication/internal/cgrates.json
@@ -40,8 +40,6 @@
"*route_profiles":{"remote":false,"replicate":true},
"*attribute_profiles":{"remote":false,"replicate":true},
"*charger_profiles": {"remote":false,"replicate":true},
- "*dispatcher_profiles":{"remote":false,"replicate":true},
- "*dispatcher_hosts":{"remote":false,"replicate":true},
"*indexes" :{"remote":false,"replicate":true},
"*rate_profiles":{"remote":false,"replicate":true},
"*load_ids":{"remote":false,"replicate":true},
diff --git a/data/conf/samples/gocs/au_site/cgrates.json b/data/conf/samples/gocs/au_site/cgrates.json
index 6ff32956d..f6fdac2bb 100644
--- a/data/conf/samples/gocs/au_site/cgrates.json
+++ b/data/conf/samples/gocs/au_site/cgrates.json
@@ -40,8 +40,6 @@
"*route_profiles":{"remote":true},
"*attribute_profiles":{"remote":true},
"*charger_profiles": {"remote":true},
- "*dispatcher_profiles":{"remote":true},
- "*dispatcher_hosts":{"remote":true},
"*load_ids":{"remote":true},
"*indexes":{"remote":true}
}
diff --git a/data/conf/samples/gocs/dsp_site/cgrates.json b/data/conf/samples/gocs/dsp_site/cgrates.json
index 188a60ca8..002f4517e 100644
--- a/data/conf/samples/gocs/dsp_site/cgrates.json
+++ b/data/conf/samples/gocs/dsp_site/cgrates.json
@@ -28,7 +28,6 @@
"caches":{
"partitions": {
- "*dispatcher_routes": {"limit": -1, "ttl": "2s"}
},
},
diff --git a/data/conf/samples/gocs/us_site/cgrates.json b/data/conf/samples/gocs/us_site/cgrates.json
index 05a5affd1..97251f24e 100644
--- a/data/conf/samples/gocs/us_site/cgrates.json
+++ b/data/conf/samples/gocs/us_site/cgrates.json
@@ -45,8 +45,6 @@
"*route_profiles":{"replicate":false},
"*attribute_profiles":{"replicate":false},
"*charger_profiles": {"replicate":false},
- "*dispatcher_profiles":{"replicate":false},
- "*dispatcher_hosts":{"replicate":false},
"*load_ids":{"replicate":false},
"*indexes":{"replicate":false}
}
diff --git a/data/conf/samples/loaders_indexes_internal_db/cgrates.json b/data/conf/samples/loaders_indexes_internal_db/cgrates.json
index acb27fe21..4edcbb377 100644
--- a/data/conf/samples/loaders_indexes_internal_db/cgrates.json
+++ b/data/conf/samples/loaders_indexes_internal_db/cgrates.json
@@ -46,8 +46,6 @@
"*route_profiles": {"remote":true, "replicate":true},
"*attribute_profiles": {"remote":true, "replicate":true},
"*charger_profiles": {"remote":true, "replicate":true},
- "*dispatcher_profiles": {"remote":true, "replicate":true},
- "*dispatcher_hosts": {"remote":true, "replicate":true},
"*load_ids": {"remote":true, "replicate":true},
"*versions": {"remote":true, "replicate":true},
"*rate_profiles": {"remote":true, "replicate":true},
@@ -59,7 +57,6 @@
"*route_filter_indexes" : {"replicate":true},
"*attribute_filter_indexes" : {"replicate":true},
"*charger_filter_indexes" : {"replicate":true},
- "*dispatcher_filter_indexes" : {"replicate":true},
"*reverse_filter_indexes" : {"replicate":true},
"*rate_profile_filter_indexes" : {"replicate": true},
"*rate_filter_indexes" : {"replicate": true},
diff --git a/data/conf/samples/precache/tutmongo/cgrates.json b/data/conf/samples/precache/tutmongo/cgrates.json
index 483a47478..ddfc44f4c 100644
--- a/data/conf/samples/precache/tutmongo/cgrates.json
+++ b/data/conf/samples/precache/tutmongo/cgrates.json
@@ -47,9 +47,6 @@
"*route_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"*attribute_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"*charger_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
- "*dispatcher_profiles" : {"limit": 10000, "ttl":"0s", "precache": true},
- "*dispatcher_hosts" : {"limit": 10000, "ttl":"0s", "precache": true},
- "*dispatcher_routes" : {"limit": 10000, "ttl":"0s", "precache": false},
},
},
diff --git a/data/conf/samples/precache/tutmongo_apiban/cgrates.json b/data/conf/samples/precache/tutmongo_apiban/cgrates.json
index 4d364acca..6c130674b 100644
--- a/data/conf/samples/precache/tutmongo_apiban/cgrates.json
+++ b/data/conf/samples/precache/tutmongo_apiban/cgrates.json
@@ -47,9 +47,6 @@
"*route_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"*attribute_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"*charger_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
- "*dispatcher_profiles" : {"limit": 10000, "ttl":"0s", "precache": true},
- "*dispatcher_hosts" : {"limit": 10000, "ttl":"0s", "precache": true},
- "*dispatcher_routes" : {"limit": 10000, "ttl":"0s", "precache": false},
"*apiban" : {"limit": 254, "ttl":"0s", "precache": true}
},
},
diff --git a/data/conf/samples/precache/tutmysql/cgrates.json b/data/conf/samples/precache/tutmysql/cgrates.json
index 7dd4d9ca3..b64fa1cab 100644
--- a/data/conf/samples/precache/tutmysql/cgrates.json
+++ b/data/conf/samples/precache/tutmysql/cgrates.json
@@ -41,9 +41,6 @@
"*route_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"*attribute_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"*charger_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
- "*dispatcher_profiles" : {"limit": 10000, "ttl":"0s", "precache": true},
- "*dispatcher_hosts" : {"limit": 10000, "ttl":"0s", "precache": true},
- "*dispatcher_routes" : {"limit": 10000, "ttl":"0s", "precache": false},
},
},
diff --git a/data/conf/samples/precache/tutmysql_apiban/cgrates.json b/data/conf/samples/precache/tutmysql_apiban/cgrates.json
index e941bf930..01fb62263 100644
--- a/data/conf/samples/precache/tutmysql_apiban/cgrates.json
+++ b/data/conf/samples/precache/tutmysql_apiban/cgrates.json
@@ -41,9 +41,6 @@
"*route_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"*attribute_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
"*charger_filter_indexes" : {"limit": 10000, "ttl":"0s", "precache": true},
- "*dispatcher_profiles" : {"limit": 10000, "ttl":"0s", "precache": true},
- "*dispatcher_hosts" : {"limit": 10000, "ttl":"0s", "precache": true},
- "*dispatcher_routes" : {"limit": 10000, "ttl":"0s", "precache": false},
"*apiban" : {"limit": 254, "ttl":"0s", "precache": true}
},
},
diff --git a/data/conf/samples/tpe_internal/cgrates.json b/data/conf/samples/tpe_internal/cgrates.json
index 6ca75e115..236ceaa16 100644
--- a/data/conf/samples/tpe_internal/cgrates.json
+++ b/data/conf/samples/tpe_internal/cgrates.json
@@ -39,8 +39,6 @@
"*route_profiles": {"limit": 0, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control route profile caching
"*attribute_profiles": {"limit": 0, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control attribute profile caching
"*charger_profiles": {"limit": 0, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control charger profile caching
- "*dispatcher_profiles": {"limit": 0, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control dispatcher profile caching
- "*dispatcher_hosts": {"limit": 0, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control dispatcher hosts caching
"*rate_profiles": {"limit": 0, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control rate profile caching
"*action_profiles": {"limit": 0, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control action profile caching
"*accounts": {"limit": 0, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control account profile caching
diff --git a/data/scripts/generate_dispatchers/generator.go b/data/scripts/generate_dispatchers/generator.go
deleted file mode 100644
index b5f6a7a44..000000000
--- a/data/scripts/generate_dispatchers/generator.go
+++ /dev/null
@@ -1,451 +0,0 @@
-//go: build ignore
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-package main
-
-import (
- "fmt"
- "go/ast"
- "go/printer"
- "go/token"
- "io"
- "log"
- "os"
- "path"
- "reflect"
- "sort"
- "strconv"
- "unicode"
-
- "github.com/cgrates/cgrates/accounts"
- "github.com/cgrates/cgrates/actions"
- "github.com/cgrates/cgrates/analyzers"
- "github.com/cgrates/cgrates/apis"
- "github.com/cgrates/cgrates/cdrs"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/cores"
- "github.com/cgrates/cgrates/ees"
- "github.com/cgrates/cgrates/efs"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/ers"
- "github.com/cgrates/cgrates/guardian"
- "github.com/cgrates/cgrates/loaders"
- "github.com/cgrates/cgrates/rates"
- "github.com/cgrates/cgrates/sessions"
- "github.com/cgrates/cgrates/tpes"
- "github.com/cgrates/cgrates/utils"
-)
-
-func main() {
- type genFile struct {
- path string
- subsystem string // the name of the constant
- obj any
- customName string
- }
- fmt.Println("Generating dispatcher files ...")
- for _, file := range []genFile{
- {"accounts.go", "MetaAccounts", new(accounts.AccountS), utils.EmptyString},
- {"actions.go", "MetaActions", new(actions.ActionS), utils.EmptyString},
- {"attributes.go", "MetaAttributes", new(engine.AttributeS), utils.EmptyString},
- {"caches.go", "MetaCaches", engine.Cache, utils.EmptyString},
- {"cdrs.go", "MetaCDRs", new(cdrs.CDRServer), utils.CDRs},
- {"chargers.go", "MetaChargers", new(engine.ChargerS), utils.EmptyString},
- {"config.go", "MetaConfig", new(config.CGRConfig), utils.ConfigS},
- {"rates.go", "RateS", new(rates.RateS), utils.EmptyString},
- {"replicator.go", "MetaReplicator", new(apis.ReplicatorSv1), utils.EmptyString},
- {"resources.go", "MetaResources", new(engine.ResourceS), utils.EmptyString},
- {"routes.go", "MetaRoutes", new(engine.RouteS), utils.EmptyString},
- {"sessions.go", "MetaSessionS", new(sessions.SessionS), utils.SessionS},
- {"rankings.go", "MetaRankings", new(engine.RankingS), utils.RankingS},
- {"trends.go", "MetaTrends", new(engine.TrendS), utils.TrendS},
- {"stats.go", "MetaStats", new(engine.StatS), utils.EmptyString},
- {"thresholds.go", "MetaThresholds", new(engine.ThresholdS), utils.EmptyString},
- {"loaders.go", "MetaLoaders", new(loaders.LoaderS), utils.EmptyString},
- {"ees.go", "MetaEEs", new(ees.EeS), utils.EmptyString},
- {"analyzers.go", "MetaAnalyzer", new(analyzers.AnalyzerS), utils.EmptyString},
- {"admins.go", "MetaAdminS", new(apis.AdminSv1), utils.EmptyString},
- {"cores.go", "MetaCore", new(cores.CoreS), utils.EmptyString},
- {"guardian.go", "MetaGuardian", guardian.Guardian, utils.GuardianS},
- {"efs.go", "MetaEFs", new(efs.EfS), utils.EmptyString},
- {"ers.go", "MetaERs", new(ers.ERService), utils.ErS},
- {"tpes.go", "MetaTpes", new(tpes.TPeS), utils.EmptyString},
- // {"servicemanager.go", "MetaServiceManager", new(servmanager.ServiceManager), utils.EmptyString},
- } {
- if err := createFile(file.path, file.subsystem, file.customName, file.obj); err != nil {
- log.Fatal(err)
- }
- }
-
-}
-
-func createFile(filePath, subsystem, customName string, obj any) (err error) {
- var f io.WriteCloser
- if f, err = os.Create(filePath); err != nil {
- return
- }
- defer f.Close()
- return writeFile(f, subsystem, customName, obj)
-}
-
-func writeFile(w io.Writer, subsystem, customName string, obj any) (err error) {
- if _, err = w.Write([]byte(`/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-`)); err != nil {
- return
- }
- srv, _ := engine.NewServiceWithName(obj, customName, len(customName) != 0)
- fs := token.NewFileSet()
- f := generateService(subsystem, srv)
- ast.SortImports(fs, f)
- return printer.Fprint(w, fs, f)
-}
-
-func generateService(subsystem string, srvs engine.IntService) *ast.File {
- imports := utils.NewStringSet([]string{
- "github.com/cgrates/cgrates/utils",
- "github.com/cgrates/birpc/context",
- })
- decl := make([]ast.Decl, 0)
- for k, srv := range srvs {
- if unicode.IsLetter(rune(k[len(k)-1])) {
- continue
- }
- methods := make([]string, 0, len(srv.Methods))
- for n := range srv.Methods {
- methods = append(methods, n)
- }
- sort.Strings(methods)
- for _, n := range methods {
- m := srv.Methods[n]
- decl = append(decl, generateFunc(srv.Name+n, subsystem, m.ArgType, m.ReplyType))
- imports.AddSlice(getImports(m.ArgType))
- imports.AddSlice(getImports(m.ReplyType))
- }
- }
- imports.Remove("")
- imps := make([]ast.Spec, imports.Size())
- for i, k := range imports.AsOrderedSlice() {
- imps[i] = &ast.ImportSpec{Path: &ast.BasicLit{
- // Kind: token.STRING,
- Value: strconv.Quote(k),
- }}
- }
- decl = append([]ast.Decl{&ast.GenDecl{
- Tok: token.IMPORT,
- Specs: imps,
- }}, decl...)
- return &ast.File{
- Name: ast.NewIdent("dispatchers"),
- Decls: decl,
- }
-}
-
-func generateFunc(service, subsystem string, arg, reply reflect.Type) *ast.FuncDecl {
- defer func() {
- val := recover()
- if val != nil {
- log.Println(service)
- panic(val)
- }
- }()
- return &ast.FuncDecl{
- Recv: &ast.FieldList{
- List: []*ast.Field{{
- Names: []*ast.Ident{ast.NewIdent("dS")},
- Type: &ast.StarExpr{X: ast.NewIdent("DispatcherService")},
- }},
- },
- Name: ast.NewIdent(service),
- Type: &ast.FuncType{
- Params: &ast.FieldList{List: []*ast.Field{
- {
- Names: []*ast.Ident{ast.NewIdent("ctx")},
- Type: &ast.StarExpr{X: &ast.SelectorExpr{
- X: ast.NewIdent("context"),
- Sel: ast.NewIdent("Context"),
- }},
- },
- {
- Names: []*ast.Ident{ast.NewIdent("args")},
- Type: getArgType(arg),
- },
- {
- Names: []*ast.Ident{ast.NewIdent("reply")},
- Type: getArgType(reply),
- },
- }},
- Results: &ast.FieldList{List: []*ast.Field{{
- Names: []*ast.Ident{ast.NewIdent("err")},
- Type: ast.NewIdent("error"),
- }}},
- },
- Body: &ast.BlockStmt{List: generateFuncBody(arg, service, subsystem)},
- }
-}
-
-type fldPath struct {
- Name string
- IsPointer bool
-}
-
-func generatePath(arg reflect.Type, field string, kind reflect.Kind) (p []fldPath) {
- if arg.Kind() == reflect.Ptr {
- arg = arg.Elem()
- }
- if arg.Kind() != reflect.Struct {
- return
- }
- fld, has := arg.FieldByName(field)
- if !has {
- nf := arg.NumField()
- for i := 0; i < nf; i++ {
- fld := arg.Field(i)
- if fld.Type.Kind() != reflect.Struct ||
- fld.Type.Kind() != reflect.Ptr {
- continue
- }
- if p = generatePath(fld.Type, field, kind); p != nil {
- return append([]fldPath{{fld.Name, fld.Type.Kind() == reflect.Ptr}}, p...)
- }
- }
- return
- }
- p = make([]fldPath, len(fld.Index))
- cur := arg
- for i, idx := range fld.Index {
- f := cur.Field(idx)
- p[i] = fldPath{f.Name, f.Type.Kind() == reflect.Ptr}
- cur = f.Type
- if cur.Kind() == reflect.Ptr {
- cur = cur.Elem()
- }
- }
- if cur.Kind() != kind {
- return nil
- }
- return
-}
-
-func newCond(conds []*ast.BinaryExpr) *ast.BinaryExpr {
- if len(conds) == 1 {
- return conds[0]
- }
- return &ast.BinaryExpr{
- X: conds[0],
- Op: token.LAND,
- Y: newCond(conds[1:]),
- }
-}
-func generateCond(arg reflect.Type, obj, dftVal ast.Expr, field string, kind reflect.Kind) (p []ast.Stmt) {
- p = make([]ast.Stmt, 0, 2)
- p = append(p, &ast.AssignStmt{
- Lhs: []ast.Expr{obj},
- Tok: token.DEFINE,
- Rhs: []ast.Expr{dftVal},
- })
- paths := generatePath(arg, field, kind)
- if len(paths) == 0 {
- return
- }
- paths = append([]fldPath{{"args", arg.Kind() == reflect.Ptr}}, paths...)
- conds := make([]*ast.BinaryExpr, 0, len(paths)+1)
- curPath := ""
- nilI := ast.NewIdent("nil")
- for i, p := range paths {
- if i != 0 {
- curPath += "."
- }
- curPath += p.Name
- if !p.IsPointer {
- continue
- }
- conds = append(conds, &ast.BinaryExpr{
- X: ast.NewIdent(curPath),
- Op: token.NEQ,
- Y: nilI,
- })
- }
- if kind == reflect.String {
- conds = append(conds, &ast.BinaryExpr{
- X: ast.NewIdent("len(" + curPath + ")"),
- Op: token.NEQ,
- Y: ast.NewIdent("0"),
- })
- }
- if len(conds) == 0 {
- return []ast.Stmt{
- &ast.AssignStmt{
- Lhs: []ast.Expr{obj},
- Tok: token.DEFINE,
- Rhs: []ast.Expr{ast.NewIdent(curPath)},
- },
- }
- }
- p = append(p, &ast.IfStmt{
- Cond: newCond(conds),
- Body: &ast.BlockStmt{List: []ast.Stmt{
- &ast.AssignStmt{
- Lhs: []ast.Expr{obj},
- Tok: token.ASSIGN,
- Rhs: []ast.Expr{ast.NewIdent(curPath)},
- },
- }},
- })
- return
-}
-
-func generateFuncBody(arg reflect.Type, funcName, subsystem string) (p []ast.Stmt) {
- tnt := ast.NewIdent("tnt")
- p = append(p, generateCond(arg, tnt, ast.NewIdent("dS.cfg.GeneralCfg().DefaultTenant"), utils.Tenant, reflect.String)...)
- ev := ast.NewIdent("ev")
- p = append(p, generateCond(arg, ev, ast.NewIdent("make(map[string]any)"), utils.Event, reflect.Map)...)
- opts := ast.NewIdent("opts")
- p = append(p, generateCond(arg, opts, ast.NewIdent("make(map[string]any)"), "APIOpts", reflect.Map)...)
-
- p = append(p, &ast.ReturnStmt{Results: []ast.Expr{&ast.CallExpr{
- Fun: &ast.SelectorExpr{
- X: ast.NewIdent("dS"),
- Sel: ast.NewIdent("Dispatch"),
- },
- Args: []ast.Expr{
- ast.NewIdent("ctx"),
- &ast.UnaryExpr{
- Op: token.AND,
- X: &ast.CompositeLit{
- Type: ast.NewIdent("utils.CGREvent"),
- Elts: []ast.Expr{
- &ast.KeyValueExpr{
- Key: ast.NewIdent(utils.Tenant),
- Value: tnt,
- },
- &ast.KeyValueExpr{
- Key: ast.NewIdent(utils.Event),
- Value: ev,
- },
- &ast.KeyValueExpr{
- Key: ast.NewIdent("APIOpts"),
- Value: opts,
- },
- },
- },
- },
- &ast.SelectorExpr{
- X: ast.NewIdent("utils"),
- Sel: ast.NewIdent(subsystem),
- },
- &ast.SelectorExpr{
- X: ast.NewIdent("utils"),
- Sel: ast.NewIdent(funcName),
- },
- ast.NewIdent("args"),
- ast.NewIdent("reply"),
- },
- }},
- })
- return
-
-}
-
-func getArgType(args reflect.Type) ast.Expr {
- if name := args.Name(); len(name) != 0 {
- pkgpath := args.PkgPath()
- if len(pkgpath) == 0 {
- return ast.NewIdent(name)
- }
- return &ast.SelectorExpr{
- X: ast.NewIdent(path.Base(pkgpath)),
- Sel: ast.NewIdent(name),
- }
- }
- switch args.Kind() {
- default:
- panic("unsuported argument")
- case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
- reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
- reflect.Uintptr, reflect.Float32, reflect.Float64, reflect.Complex64,
- reflect.Complex128, reflect.String:
- return ast.NewIdent(args.Name())
- case reflect.Interface:
- name := args.Name()
- if len(name) == 0 {
- name = "any"
- }
- return ast.NewIdent(name)
- case reflect.Ptr:
- return &ast.StarExpr{
- X: getArgType(args.Elem()),
- }
- case reflect.Struct:
- pkgpath := args.PkgPath()
- if len(pkgpath) == 0 {
- return ast.NewIdent(args.Name())
- }
- return &ast.SelectorExpr{
- X: ast.NewIdent(path.Base(pkgpath)),
- Sel: ast.NewIdent(args.Name()),
- }
- case reflect.Array, reflect.Slice:
- return &ast.ArrayType{
- Elt: getArgType(args.Elem()),
- }
- case reflect.Map:
- return &ast.MapType{
- Key: getArgType(args.Key()),
- Value: getArgType(args.Elem()),
- }
- }
-}
-
-func getImports(args reflect.Type) []string {
- switch args.Kind() {
- default:
- panic("unsuported argument")
- case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
- reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
- reflect.Uintptr, reflect.Float32, reflect.Float64, reflect.Complex64,
- reflect.Complex128, reflect.String, reflect.Interface:
- return nil
- case reflect.Ptr, reflect.Array, reflect.Slice:
- return append(getImports(args.Elem()), args.PkgPath())
- case reflect.Struct:
- return []string{args.PkgPath()}
- case reflect.Map:
- args.PkgPath()
- key := append(getImports(args.Key()), args.PkgPath())
- return append(key, getImports(args.Elem())...)
- }
-}
diff --git a/data/scripts/generate_dispatchers/generator_test.go b/data/scripts/generate_dispatchers/generator_test.go
deleted file mode 100644
index ab370d03f..000000000
--- a/data/scripts/generate_dispatchers/generator_test.go
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package main
-
-/*
-func TestGenerate(t *testing.T) {
- t.Errorf("%#v", writeFile(os.Stdout, "MetaAttributes", utils.EmptyString, new(engine.AttributeS)))
-}
-func TestGeneratePath(t *testing.T) {
- path := generatePath(reflect.TypeOf(new(utils.TenantIDWithAPIOpts)), "Tenant", reflect.String)
- t.Error(path)
-}
-*/
diff --git a/data/tariffplans/cache_replications/dispatcher_engine/DispatcherHosts.csv b/data/tariffplans/cache_replications/dispatcher_engine/DispatcherHosts.csv
deleted file mode 100644
index c2bfc8d2f..000000000
--- a/data/tariffplans/cache_replications/dispatcher_engine/DispatcherHosts.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12]
-cgrates.org,Engine1,127.0.0.1:6012,*json,1,3,,"1m","2m",false,,,
\ No newline at end of file
diff --git a/data/tariffplans/cache_replications/dispatcher_engine/DispatcherProfiles.csv b/data/tariffplans/cache_replications/dispatcher_engine/DispatcherProfiles.csv
deleted file mode 100644
index a9371f41b..000000000
--- a/data/tariffplans/cache_replications/dispatcher_engine/DispatcherProfiles.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tenant,ID,FilterIDs,Weight,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters
-cgrates.org,Engine1,,10,*weight,,Engine1,,20,false,
-cgrates.org,Engine2,*string:~*req.EventName:TestLoad;*string:~*vars.*subsys:*chargers,20,*weight,,Engine1,,20,false,*ratio:1
\ No newline at end of file
diff --git a/data/tariffplans/cache_replications/dispatcher_engine2/DispatcherHosts.csv b/data/tariffplans/cache_replications/dispatcher_engine2/DispatcherHosts.csv
deleted file mode 100644
index a237ab4b6..000000000
--- a/data/tariffplans/cache_replications/dispatcher_engine2/DispatcherHosts.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12]
-cgrates.org,Self,*internal,,1,3,,"1m","2m",false,,,
-cgrates.org,Engine1,127.0.0.1:6012,*json,1,3,,"1m","2m",false,,,
diff --git a/data/tariffplans/cache_replications/dispatcher_engine2/DispatcherProfiles.csv b/data/tariffplans/cache_replications/dispatcher_engine2/DispatcherProfiles.csv
deleted file mode 100644
index f718a612f..000000000
--- a/data/tariffplans/cache_replications/dispatcher_engine2/DispatcherProfiles.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-#Tenant,ID,FilterIDs,Weight,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters
-cgrates.org,InternalDispatcher,*string:~*vars.*subsys:*caches|*core,30,*weight,,Self,,20,false,
-cgrates.org,ExternalDispatcher,*string:~*vars.*subsys:*attributes,10,*weight,,Engine1,,20,false,
-cgrates.org,Engine2,*string:~*vars.*subsys:*chargers,10,*weight,,Engine1,,20,false,*ratio:1
\ No newline at end of file
diff --git a/data/tariffplans/cache_rpl_active_active/dispatcher_engine/DispatcherHosts.csv b/data/tariffplans/cache_rpl_active_active/dispatcher_engine/DispatcherHosts.csv
deleted file mode 100644
index a237ab4b6..000000000
--- a/data/tariffplans/cache_rpl_active_active/dispatcher_engine/DispatcherHosts.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12]
-cgrates.org,Self,*internal,,1,3,,"1m","2m",false,,,
-cgrates.org,Engine1,127.0.0.1:6012,*json,1,3,,"1m","2m",false,,,
diff --git a/data/tariffplans/cache_rpl_active_active/dispatcher_engine/DispatcherProfiles.csv b/data/tariffplans/cache_rpl_active_active/dispatcher_engine/DispatcherProfiles.csv
deleted file mode 100644
index b826c668a..000000000
--- a/data/tariffplans/cache_rpl_active_active/dispatcher_engine/DispatcherProfiles.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-#Tenant,ID,FilterIDs,Weight,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters
-cgrates.org,InternalDispatcher,*caches;*core,,30,*weight,,Self,,20,false,
-cgrates.org,Engine1,,10,*weight,,Engine1,,20,false,
-cgrates.org,Engine2,*string:~*req.EventName:TestLoad;*string:~*vars.*subsys:*chargers,20,*weight,,Engine1,,20,false,*ratio:1
\ No newline at end of file
diff --git a/data/tariffplans/cache_rpl_active_active/dispatcher_engine2/DispatcherHosts.csv b/data/tariffplans/cache_rpl_active_active/dispatcher_engine2/DispatcherHosts.csv
deleted file mode 100644
index 368049bd3..000000000
--- a/data/tariffplans/cache_rpl_active_active/dispatcher_engine2/DispatcherHosts.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12]
-cgrates.org,Self,*internal,,1,3,,"1m","2m",false,,,
-cgrates.org,Engine1,127.0.0.1:6012,*json,1,3,,"1m","2m",false,,,
\ No newline at end of file
diff --git a/data/tariffplans/cache_rpl_active_active/dispatcher_engine2/DispatcherProfiles.csv b/data/tariffplans/cache_rpl_active_active/dispatcher_engine2/DispatcherProfiles.csv
deleted file mode 100644
index f718a612f..000000000
--- a/data/tariffplans/cache_rpl_active_active/dispatcher_engine2/DispatcherProfiles.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-#Tenant,ID,FilterIDs,Weight,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters
-cgrates.org,InternalDispatcher,*string:~*vars.*subsys:*caches|*core,30,*weight,,Self,,20,false,
-cgrates.org,ExternalDispatcher,*string:~*vars.*subsys:*attributes,10,*weight,,Engine1,,20,false,
-cgrates.org,Engine2,*string:~*vars.*subsys:*chargers,10,*weight,,Engine1,,20,false,*ratio:1
\ No newline at end of file
diff --git a/data/tariffplans/dispatchers/Attributes.csv b/data/tariffplans/dispatchers/Attributes.csv
deleted file mode 100644
index d3dbdbd18..000000000
--- a/data/tariffplans/dispatchers/Attributes.csv
+++ /dev/null
@@ -1,27 +0,0 @@
-#Tenant,ID,FilterIDs,Weights,Blockers,AttributeFilterIDs,AttributeBlockers,Path,Type,Value
-cgrates.org,ATTR_1001_SIMPLEAUTH,*string:~*req.Account:1001,;20,;false,,,*req.Password,*constant,CGRateS.org
-cgrates.org,ATTR_1001_SIMPLEAUTH,,;20,;false,,,*req.EventName,*constant,*remove
-cgrates.org,ATTR_1003_SIMPLEAUTH,*string:~*req.Account:1003,;20,;false,,,*req.Password,*constant,CGRateS.com
-cgrates.org,ATTR_API_ATTR_FAKE_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:12345,;20,;false,,,*req.APIMethods,*constant,
-cgrates.org,ATTR_API_ATTR_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:attr12345,;20,;false,,,*req.APIMethods,*constant,AttributeSv1.Ping&AttributeSv1.GetAttributeForEvent&AttributeSv1.ProcessEvent
-cgrates.org,ATTR_API_CHRG_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:chrg12345,;20,;false,,,*req.APIMethods,*constant,ChargerSv1.Ping&ChargerSv1.GetChargersForEvent&ChargerSv1.ProcessEvent
-cgrates.org,ATTR_API_THR_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:thr12345,;20,;false,,,*req.APIMethods,*constant,ThresholdSv1.Ping&ThresholdSv1.GetThresholdsForEvent&ThresholdSv1.ProcessEvent&ThresholdSv1.GetThreshold&ThresholdSv1.GetThresholdIDs
-cgrates.org,ATTR_API_SUP_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:sup12345,;20,;false,,,*req.APIMethods,*constant,RouteSv1.Ping&RouteSv1.GetRoutes&RouteSv1.GetRouteProfilesForEvent
-cgrates.org,ATTR_API_STAT_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:stat12345,;20,;false,,,*req.APIMethods,*constant,StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics
-cgrates.org,ATTR_API_RES_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:res12345,;20,;false,,,*req.APIMethods,*constant,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources&ResourceSv1.GetResource
-cgrates.org,ATTR_API_SES_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:ses12345,;20,;false,,,*req.APIMethods,*constant,SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessMessage&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession&SessionSv1.ProcessEvent&SessionSv1.GetCost&SessionSv1.STIRAuthenticate&SessionSv1.STIRIdentity
-cgrates.org,ATTR_API_RSP_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:rsp12345,;20,;false,,,*req.APIMethods,*constant,CoreSv1.Status&CoreSv1.Ping&Responder.Shutdown&Responder.Ping
-cgrates.org,ATTR_API_CHC_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:chc12345,;20,;false,,,*req.APIMethods,*constant,CacheSv1.Ping&CacheSv1.GetCacheStats&CacheSv1.LoadCache&CacheSv1.PrecacheStatus&CacheSv1.GetItemIDs&CacheSv1.HasItem&CacheSv1.GetItemExpiryTime&CacheSv1.ReloadCache&CacheSv1.RemoveItem&CacheSv1.RemoveItems&CacheSv1.Clear
-cgrates.org,ATTR_API_GRD_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:grd12345,;20,;false,,,*req.APIMethods,*constant,GuardianSv1.Ping&GuardianSv1.RemoteLock&GuardianSv1.RemoteUnlock
-cgrates.org,ATTR_API_CDRS_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:cdrs12345,;20,;false,,,*req.APIMethods,*constant,CDRsV1.Ping&CDRsV1.ProcessEvent&CDRsV1.GetCDRs&CDRsV1.GetCDRsCount&CDRsV1.ProcessCDR&CDRsV1.ProcessExternalCDR
-cgrates.org,ATTR_API_DSP_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:dsp12345,;20,;false,,,*req.APIMethods,*constant,DispatcherSv1.Ping&DispatcherSv1.GetProfilesForEvent
-cgrates.org,ATTR_API_PSE_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:pse12345,;20,;false,,,*req.APIMethods,*constant,SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessMessage&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession&AttributeSv1.ProcessEvent&Responder.Debit&ResourceSv1.AllocateResources&ChargerSv1.ProcessEvent&Responder.MaxDebit&SessionSv1.ProcessEvent&ResourceSv1.ReleaseResources
-cgrates.org,ATTR_API_CFG_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:cfg12345,;20,;false,,,*req.APIMethods,*constant,ConfigSv1.GetConfig&ConfigSv1.ReloadConfig
-cgrates.org,ATTR_API_APIER_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:apier12345,;20,;false,,,*req.APIMethods,*constant,APIerSv1.GetAttributeProfile&APIerSv1.SetAttributeProfile
-cgrates.org,ATTR_API_RALS_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:rals12345,;20,;false,,,*req.APIMethods,*constant,RALsV1.Ping&RALsV1.GetRatingPlansCost
-cgrates.org,ATTR_API_REPLICATOR_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:repl12345,;20,;false,,,*req.APIMethods,*constant,ReplicatorSv1.Ping&ReplicatorSv1.GetAccount&ReplicatorSv1.SetAccount&ReplicatorSv1.RemoveAccount&ReplicatorSv1.GetRouteProfile&ReplicatorSv1.SetRouteProfile&ReplicatorSv1.RemoveRouteProfile&ReplicatorSv1.GetAttributeProfile&ReplicatorSv1.SetAttributeProfile&ReplicatorSv1.RemoveAttributeProfile&ReplicatorSv1.SetChargerProfile&ReplicatorSv1.GetChargerProfile&ReplicatorSv1.RemoveChargerProfile&ReplicatorSv1.GetDispatcherProfile&ReplicatorSv1.SetDispatcherProfile&ReplicatorSv1.RemoveDispatcherProfile&ReplicatorSv1.GetDispatcherHost&ReplicatorSv1.SetDispatcherHost&ReplicatorSv1.RemoveDispatcherHost&ReplicatorSv1.GetFilter&ReplicatorSv1.SetFilter&ReplicatorSv1.RemoveFilter&ReplicatorSv1.GetThreshold&ReplicatorSv1.SetThreshold&ReplicatorSv1.RemoveThreshold&ReplicatorSv1.GetStatQueue&ReplicatorSv1.SetStatQueue&ReplicatorSv1.RemoveStatQueue&ReplicatorSv1.GetResource&ReplicatorSv1.SetResource&ReplicatorSv1.RemoveResource&ReplicatorSv1.GetResourceProfile&ReplicatorSv1.SetResourceProfile&ReplicatorSv1.RemoveResourceProfile&ReplicatorSv1.GetStatQueueProfile&ReplicatorSv1.SetStatQueueProfile&ReplicatorSv1.RemoveStatQueueProfile&ReplicatorSv1.GetThresholdProfile&ReplicatorSv1.SetThresholdProfile&ReplicatorSv1.RemoveThresholdProfile&ReplicatorSv1.GetTiming&ReplicatorSv1.SetTiming&ReplicatorSv1.RemoveTiming&ReplicatorSv1.GetActionTriggers&ReplicatorSv1.SetActionTriggers&ReplicatorSv1.RemoveActionTriggers&ReplicatorSv1.SetSharedGroup&ReplicatorSv1.GetSharedGroup&ReplicatorSv1.RemoveSharedGroup&ReplicatorSv1.SetActions&ReplicatorSv1.GetActions&ReplicatorSv1.RemoveActions&ReplicatorSv1.SetActionPlan&ReplicatorSv1.GetActionPlan&ReplicatorSv1.RemoveActionPlan&ReplicatorSv1.SetAccountActionPlans&ReplicatorSv1.GetAccountActionPlans&ReplicatorSv1.RemAccountActionPlans&ReplicatorSv1.SetRatingPlan&ReplicatorSv1.GetRatingPlan&ReplicatorSv1.RemoveRatingPlan&ReplicatorSv1.SetRatingProfile&ReplicatorSv1.GetRatingProfile&ReplicatorSv1.RemoveRatingProfile&ReplicatorSv1.SetDestination&ReplicatorSv1.GetDestination&ReplicatorSv1.RemoveDestination&ReplicatorSv1.SetLoadIDs&ReplicatorSv1.GetItemLoadIDs&ReplicatorSv1.SetRateProfile&ReplicatorSv1.GetRateProfile&ReplicatorSv1.RemoveRateProfile&ReplicatorSv1.SetAccount&ReplicatorSv1.GetAccount&ReplicatorSv1.RemoveAccount&ReplicatorSv1.SetActionProfile&ReplicatorSv1.GetActionProfile&ReplicatorSv1.RemoveActionProfile
-cgrates.org,ATTR_API_CDRSV2,*string:~*opts.*context:*auth;*string:~*req.ApiKey:cdrsv212345,;20,;false,,,*req.APIMethods,*constant,CDRsV2.ProcessEvent&CDRsV2.StoreSessionCost
-cgrates.org,ATTR_API_RATES_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:rPrf12345,;20,;false,,,*req.APIMethods,*constant,RateSv1.Ping&RateSv1.CostForEvent
-cgrates.org,ATTR_API_CORE_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:core12345,;20,;false,,,*req.APIMethods,*constant,CoreSv1.Status&CoreSv1.Ping&CoreSv1.Sleep
-cgrates.org,ATTR_API_ACTIONS_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:actPrf12345,;20,;false,,,*req.APIMethods,*constant,ActionSv1.Ping
-cgrates.org,ATTR_API_ACCOUNTS_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:accPrf12345,;20,;false,,,*req.APIMethods,*constant,AccountSv1.Ping
diff --git a/data/tariffplans/dispatchers/DispatcherHosts.csv b/data/tariffplans/dispatchers/DispatcherHosts.csv
deleted file mode 100644
index f61624ed2..000000000
--- a/data/tariffplans/dispatchers/DispatcherHosts.csv
+++ /dev/null
@@ -1,5 +0,0 @@
-#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12]
-cgrates.org,SELF,*internal,,1,3,,"1m","2m",false,,,
-cgrates.org,ALL,127.0.0.1:6012,*json,1,3,,"1m","2m",false,,,
-cgrates.org,ALL2,127.0.0.1:7012,*json,1,3,,"1m","2m",false,,,
-cgrates.org,NonexistingHost,127.0.0.1:10012,*json,1,3,,"1m","2m",false,,,
\ No newline at end of file
diff --git a/data/tariffplans/dispatchers/DispatcherProfiles.csv b/data/tariffplans/dispatchers/DispatcherProfiles.csv
deleted file mode 100644
index bce092f78..000000000
--- a/data/tariffplans/dispatchers/DispatcherProfiles.csv
+++ /dev/null
@@ -1,17 +0,0 @@
-#Tenant,ID,FilterIDs,Weight,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters
-cgrates.org,PING1,,10,*weight,,ALL,,20,false,
-cgrates.org,PING1,,,,,ALL2,,10,,
-cgrates.org,PING2,*string:~*req.EventName:NonexistingHost,20,*weight,,NonexistingHost,,20,false,
-cgrates.org,PING2,,,,,ALL2,,10,,
-cgrates.org,EVENT1,*string:~*req.EventName:Event1,30,*weight,,ALL2,,20,false,
-cgrates.org,EVENT1,,,,,ALL,,10,,
-cgrates.org,EVENT2,*string:~*req.EventName:RoundRobin,20,*round_robin,,ALL2,,20,false,
-cgrates.org,EVENT2,,,,,ALL,,10,,
-cgrates.org,EVENT3,*string:~*req.EventName:Random,20,*random,,ALL2,,20,false,
-cgrates.org,EVENT3,,,,,ALL,,10,,
-cgrates.org,EVENT4,*string:~*req.EventName:Broadcast,20,*broadcast_sync,,ALL2,,20,false,
-cgrates.org,EVENT4,,,,,ALL,,10,,
-cgrates.org,EVENT5,*string:~*req.EventName:Internal,20,*weight,,SELF,,20,false,
-cgrates.org,EVENT6,*string:~*opts.*method:DispatcherSv1.GetProfilesForEvent,20,*weight,,SELF,,20,false,
-cgrates.org,EVENT7,*string:~*opts.EventType:LoadDispatcher,20,*weight,*default_ratio:1,ALL,,20,false,
-cgrates.org,EVENT7,,20,,,ALL2,,20,,*ratio:1
diff --git a/data/tariffplans/dispatchers_gob/Attributes.csv b/data/tariffplans/dispatchers_gob/Attributes.csv
deleted file mode 100644
index 1f8c66399..000000000
--- a/data/tariffplans/dispatchers_gob/Attributes.csv
+++ /dev/null
@@ -1,27 +0,0 @@
-#Tenant,ID,FilterIDs,Weights,Blockers,AttributeFilterIDs,AttributeBlockers,Path,Type,Value
-cgrates.org,ATTR_1001_SIMPLEAUTH,*string:~*req.Account:1001,;20,;false,,,*req.Password,*constant,CGRateS.org
-cgrates.org,ATTR_1001_SIMPLEAUTH,,;20,;false,,,*req.EventName,*constant,*remove
-cgrates.org,ATTR_1003_SIMPLEAUTH,*string:~*req.Account:1003,;20,;false,,,*req.Password,*constant,CGRateS.com
-cgrates.org,ATTR_API_ATTR_FAKE_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:12345,;20,;false,,,*req.APIMethods,*constant,
-cgrates.org,ATTR_API_ATTR_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:attr12345,;20,;false,,,*req.APIMethods,*constant,AttributeSv1.Ping&AttributeSv1.GetAttributeForEvent&AttributeSv1.ProcessEvent
-cgrates.org,ATTR_API_CHRG_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:chrg12345,;20,;false,,,*req.APIMethods,*constant,ChargerSv1.Ping&ChargerSv1.GetChargersForEvent&ChargerSv1.ProcessEvent
-cgrates.org,ATTR_API_THR_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:thr12345,;20,;false,,,*req.APIMethods,*constant,ThresholdSv1.Ping&ThresholdSv1.GetThresholdsForEvent&ThresholdSv1.ProcessEvent&ThresholdSv1.GetThreshold&ThresholdSv1.GetThresholdIDs
-cgrates.org,ATTR_API_SUP_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:sup12345,;20,;false,,,*req.APIMethods,*constant,RouteSv1.Ping&RouteSv1.GetRoutes&RouteSv1.GetRouteProfilesForEvent
-cgrates.org,ATTR_API_STAT_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:stat12345,;20,;false,,,*req.APIMethods,*constant,StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics
-cgrates.org,ATTR_API_RES_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:res12345,;20,;false,,,*req.APIMethods,*constant,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources&ResourceSv1.GetResource
-cgrates.org,ATTR_API_SES_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:ses12345,;20,;false,,,*req.APIMethods,*constant,SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessMessage&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession&SessionSv1.ProcessEvent&SessionSv1.GetCost&SessionSv1.STIRAuthenticate&SessionSv1.STIRIdentity
-cgrates.org,ATTR_API_RSP_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:rsp12345,;20,;false,,,*req.APIMethods,*constant,CoreSv1.Status&CoreSv1.Ping&Responder.Shutdown&Responder.Ping
-cgrates.org,ATTR_API_CHC_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:chc12345,;20,;false,,,*req.APIMethods,*constant,CacheSv1.Ping&CacheSv1.GetCacheStats&CacheSv1.LoadCache&CacheSv1.PrecacheStatus&CacheSv1.GetItemIDs&CacheSv1.HasItem&CacheSv1.GetItemExpiryTime&CacheSv1.ReloadCache&CacheSv1.RemoveItem&CacheSv1.RemoveItems&CacheSv1.Clear
-cgrates.org,ATTR_API_GRD_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:grd12345,;20,;false,,,*req.APIMethods,*constant,GuardianSv1.Ping&GuardianSv1.RemoteLock&GuardianSv1.RemoteUnlock
-cgrates.org,ATTR_API_CDRS_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:cdrs12345,;20,;false,,,*req.APIMethods,*constant,CDRsV1.Ping&CDRsV1.ProcessEvent&CDRsV1.GetCDRs&CDRsV1.GetCDRsCount&CDRsV1.ProcessCDR&CDRsV1.ProcessExternalCDR
-cgrates.org,ATTR_API_DSP_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:dsp12345,;20,;false,,,*req.APIMethods,*constant,DispatcherSv1.Ping&DispatcherSv1.GetProfilesForEvent
-cgrates.org,ATTR_API_PSE_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:pse12345,;20,;false,,,*req.APIMethods,*constant,SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessMessage&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession&AttributeSv1.ProcessEvent&Responder.Debit&ResourceSv1.AllocateResources&ChargerSv1.ProcessEvent&Responder.MaxDebit&SessionSv1.ProcessEvent&ResourceSv1.ReleaseResources
-cgrates.org,ATTR_API_CFG_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:cfg12345,;20,;false,,,*req.APIMethods,*constant,ConfigSv1.GetConfig&ConfigSv1.ReloadConfig
-cgrates.org,ATTR_API_APIER_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:apier12345,;20,;false,,,*req.APIMethods,*constant,APIerSv1.GetAttributeProfile&APIerSv1.SetAttributeProfile
-cgrates.org,ATTR_API_RALS_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:rals12345,;20,;false,,,*req.APIMethods,*constant,RALsV1.Ping&RALsV1.GetRatingPlansCost
-cgrates.org,ATTR_API_REPLICATOR_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:repl12345,;20,;false,,,*req.APIMethods,*constant,ReplicatorSv1.Ping&ReplicatorSv1.GetAccount&ReplicatorSv1.SetAccount&ReplicatorSv1.RemoveAccount&ReplicatorSv1.GetRouteProfile&ReplicatorSv1.SetRouteProfile&ReplicatorSv1.RemoveRouteProfile&ReplicatorSv1.GetAttributeProfile&ReplicatorSv1.SetAttributeProfile&ReplicatorSv1.RemoveAttributeProfile&ReplicatorSv1.SetChargerProfile&ReplicatorSv1.GetChargerProfile&ReplicatorSv1.RemoveChargerProfile&ReplicatorSv1.GetDispatcherProfile&ReplicatorSv1.SetDispatcherProfile&ReplicatorSv1.RemoveDispatcherProfile&ReplicatorSv1.GetDispatcherHost&ReplicatorSv1.SetDispatcherHost&ReplicatorSv1.RemoveDispatcherHost&ReplicatorSv1.GetFilter&ReplicatorSv1.SetFilter&ReplicatorSv1.RemoveFilter&ReplicatorSv1.GetThreshold&ReplicatorSv1.SetThreshold&ReplicatorSv1.RemoveThreshold&ReplicatorSv1.GetStatQueue&ReplicatorSv1.SetStatQueue&ReplicatorSv1.RemoveStatQueue&ReplicatorSv1.GetResource&ReplicatorSv1.SetResource&ReplicatorSv1.RemoveResource&ReplicatorSv1.GetResourceProfile&ReplicatorSv1.SetResourceProfile&ReplicatorSv1.RemoveResourceProfile&ReplicatorSv1.GetStatQueueProfile&ReplicatorSv1.SetStatQueueProfile&ReplicatorSv1.RemoveStatQueueProfile&ReplicatorSv1.GetThresholdProfile&ReplicatorSv1.SetThresholdProfile&ReplicatorSv1.RemoveThresholdProfile&ReplicatorSv1.GetTiming&ReplicatorSv1.SetTiming&ReplicatorSv1.RemoveTiming&ReplicatorSv1.GetActionTriggers&ReplicatorSv1.SetActionTriggers&ReplicatorSv1.RemoveActionTriggers&ReplicatorSv1.SetSharedGroup&ReplicatorSv1.GetSharedGroup&ReplicatorSv1.RemoveSharedGroup&ReplicatorSv1.SetActions&ReplicatorSv1.GetActions&ReplicatorSv1.RemoveActions&ReplicatorSv1.SetActionPlan&ReplicatorSv1.GetActionPlan&ReplicatorSv1.RemoveActionPlan&ReplicatorSv1.SetAccountActionPlans&ReplicatorSv1.GetAccountActionPlans&ReplicatorSv1.RemAccountActionPlans&ReplicatorSv1.SetRatingPlan&ReplicatorSv1.GetRatingPlan&ReplicatorSv1.RemoveRatingPlan&ReplicatorSv1.SetRatingProfile&ReplicatorSv1.GetRatingProfile&ReplicatorSv1.RemoveRatingProfile&ReplicatorSv1.SetLoadIDs&ReplicatorSv1.GetItemLoadIDs&ReplicatorSv1.SetRateProfile&ReplicatorSv1.GetRateProfile&ReplicatorSv1.RemoveRateProfile
-cgrates.org,ATTR_API_CDRSV2,*string:~*opts.*context:*auth;*string:~*req.ApiKey:cdrsv212345,;20,;false,,,*req.APIMethods,*constant,CDRsV2.ProcessEvent&CDRsV2.StoreSessionCost
-cgrates.org,ATTR_API_RATES_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:rPrf12345,;20,;false,,,*req.APIMethods,*constant,RateSv1.Ping
-cgrates.org,ATTR_API_CORE_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:core12345,;20,;false,,,*req.APIMethods,*constant,CoreSv1.Status&CoreSv1.Ping&CoreSv1.Sleep
-cgrates.org,ATTR_API_ACTIONS_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:actPrf12345,;20,;false,,,*req.APIMethods,*constant,ActionSv1.Ping
-cgrates.org,ATTR_API_ACCOUNTS_AUTH,*string:~*opts.*context:*auth;*string:~*req.ApiKey:accPrf12345,;20,;false,,,*req.APIMethods,*constant,AccountSv1.Ping
diff --git a/data/tariffplans/dispatchers_gob/DispatcherHosts.csv b/data/tariffplans/dispatchers_gob/DispatcherHosts.csv
deleted file mode 100644
index fc24a9a96..000000000
--- a/data/tariffplans/dispatchers_gob/DispatcherHosts.csv
+++ /dev/null
@@ -1,5 +0,0 @@
-#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12]
-cgrates.org,SELF,*internal,,1,3,,"1m","2m",false,,,
-cgrates.org,ALL,127.0.0.1:6013,*gob,1,3,,"1m","2m",false,,,
-cgrates.org,ALL2,127.0.0.1:7013,*gob,1,3,,"1m","2m",false,,,
-cgrates.org,NonexistingHost,127.0.0.1:10012,*json,1,3,,"1m","2m",false,,,
\ No newline at end of file
diff --git a/data/tariffplans/dispatchers_gob/DispatcherProfiles.csv b/data/tariffplans/dispatchers_gob/DispatcherProfiles.csv
deleted file mode 100644
index bce092f78..000000000
--- a/data/tariffplans/dispatchers_gob/DispatcherProfiles.csv
+++ /dev/null
@@ -1,17 +0,0 @@
-#Tenant,ID,FilterIDs,Weight,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters
-cgrates.org,PING1,,10,*weight,,ALL,,20,false,
-cgrates.org,PING1,,,,,ALL2,,10,,
-cgrates.org,PING2,*string:~*req.EventName:NonexistingHost,20,*weight,,NonexistingHost,,20,false,
-cgrates.org,PING2,,,,,ALL2,,10,,
-cgrates.org,EVENT1,*string:~*req.EventName:Event1,30,*weight,,ALL2,,20,false,
-cgrates.org,EVENT1,,,,,ALL,,10,,
-cgrates.org,EVENT2,*string:~*req.EventName:RoundRobin,20,*round_robin,,ALL2,,20,false,
-cgrates.org,EVENT2,,,,,ALL,,10,,
-cgrates.org,EVENT3,*string:~*req.EventName:Random,20,*random,,ALL2,,20,false,
-cgrates.org,EVENT3,,,,,ALL,,10,,
-cgrates.org,EVENT4,*string:~*req.EventName:Broadcast,20,*broadcast_sync,,ALL2,,20,false,
-cgrates.org,EVENT4,,,,,ALL,,10,,
-cgrates.org,EVENT5,*string:~*req.EventName:Internal,20,*weight,,SELF,,20,false,
-cgrates.org,EVENT6,*string:~*opts.*method:DispatcherSv1.GetProfilesForEvent,20,*weight,,SELF,,20,false,
-cgrates.org,EVENT7,*string:~*opts.EventType:LoadDispatcher,20,*weight,*default_ratio:1,ALL,,20,false,
-cgrates.org,EVENT7,,20,,,ALL2,,20,,*ratio:1
diff --git a/data/tariffplans/gocs/dsp_site/DispatcherHosts.csv b/data/tariffplans/gocs/dsp_site/DispatcherHosts.csv
deleted file mode 100644
index 75a0e0bc2..000000000
--- a/data/tariffplans/gocs/dsp_site/DispatcherHosts.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12]
-cgrates.org,AU_SITE,127.0.0.1:3012,*json,1,3,,"1m","2m",false,,,
-cgrates.org,US_SITE,127.0.0.1:4012,*json,1,3,,"1m","2m",false,,,
-cgrates.org,SELF,*internal,,1,3,,"1m","2m",false,,,
\ No newline at end of file
diff --git a/data/tariffplans/gocs/dsp_site/DispatcherProfiles.csv b/data/tariffplans/gocs/dsp_site/DispatcherProfiles.csv
deleted file mode 100644
index 6cd210160..000000000
--- a/data/tariffplans/gocs/dsp_site/DispatcherProfiles.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-#Tenant,ID,FilterIDs,Weight,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters
-cgrates.org,BROADCAST,*string:~*vars.*subsys:*sessions,30,*broadcast_sync,,AU_SITE,,20,false,
-cgrates.org,BROADCAST,,,,,US_SITE,,20,,
-cgrates.org,SELF,,10,*weight,,SELF,,20,false,
\ No newline at end of file
diff --git a/data/tariffplans/loadRateTest/DispatcherHosts.csv b/data/tariffplans/loadRateTest/DispatcherHosts.csv
deleted file mode 100644
index e69de29bb..000000000
diff --git a/data/tariffplans/loadRateTest/DispatcherProfiles.csv b/data/tariffplans/loadRateTest/DispatcherProfiles.csv
deleted file mode 100644
index e69de29bb..000000000
diff --git a/data/tariffplans/precache/DispatcherHosts.csv b/data/tariffplans/precache/DispatcherHosts.csv
deleted file mode 100644
index 15275cb62..000000000
--- a/data/tariffplans/precache/DispatcherHosts.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-#Tenant[0],ID[1],Address[2],Transport[3],ConnectAttempts[4],Reconnects[5],MaxReconnectInterval[6],ConnectTimeout[7],ReplyTimeout[8],Tls[9],ClientKey[10],ClientCertificate[11],CaCertificate[12]
-cgrates.org,SELF,*internal,,1,3,,"1m","2m",false,,,
\ No newline at end of file
diff --git a/data/tariffplans/precache/DispatcherProfiles.csv b/data/tariffplans/precache/DispatcherProfiles.csv
deleted file mode 100644
index 2197c5345..000000000
--- a/data/tariffplans/precache/DispatcherProfiles.csv
+++ /dev/null
@@ -1,12 +0,0 @@
-#Tenant,ID,FilterIDs,Weight,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters
-cgrates.org,PING1,,10,*weight,,ALL,,20,false,
-cgrates.org,PING1,,,,,ALL2,,10,,
-cgrates.org,EVENT1,*string:~*req.EventName:Event1,30,*weight,,ALL2,,20,false,
-cgrates.org,EVENT1,,,,,ALL,,10,,
-cgrates.org,EVENT2,*string:~*req.EventName:RoundRobin,20,*round_robin,,ALL2,,20,false,
-cgrates.org,EVENT2,,,,,ALL,,10,,
-cgrates.org,EVENT3,*string:~*req.EventName:Random,20,*random,,ALL2,,20,false,
-cgrates.org,EVENT3,,,,,ALL,,10,,
-cgrates.org,EVENT4,*string:~*req.EventName:Broadcast,20,*broadcast_sync,,ALL2,,20,false,
-cgrates.org,EVENT4,,,,,ALL,,10,,
-cgrates.org,EVENT5,*string:~*req.EventName:Internal,20,*weight,,SELF,,20,false,
diff --git a/data/tariffplans/testit/DispatcherHosts.csv b/data/tariffplans/testit/DispatcherHosts.csv
deleted file mode 100644
index e69de29bb..000000000
diff --git a/data/tariffplans/testit/DispatcherProfiles.csv b/data/tariffplans/testit/DispatcherProfiles.csv
deleted file mode 100644
index e69de29bb..000000000
diff --git a/data/tariffplans/testtp/DispatcherHosts.csv b/data/tariffplans/testtp/DispatcherHosts.csv
deleted file mode 100644
index e69de29bb..000000000
diff --git a/data/tariffplans/testtp/DispatcherProfiles.csv b/data/tariffplans/testtp/DispatcherProfiles.csv
deleted file mode 100644
index e69de29bb..000000000
diff --git a/data/tariffplans/tutorial/DispatcherHosts.csv b/data/tariffplans/tutorial/DispatcherHosts.csv
deleted file mode 100644
index e69de29bb..000000000
diff --git a/dispatchers/accounts.go b/dispatchers/accounts.go
deleted file mode 100644
index 072a34cb4..000000000
--- a/dispatchers/accounts.go
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) AccountSv1AccountsForEvent(ctx *context.Context, args *utils.CGREvent, reply *[]*utils.Account) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAccounts, utils.AccountSv1AccountsForEvent, args, reply)
-}
-func (dS *DispatcherService) AccountSv1ActionRemoveBalance(ctx *context.Context, args *utils.ArgsActRemoveBalances, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAccounts, utils.AccountSv1ActionRemoveBalance, args, reply)
-}
-func (dS *DispatcherService) AccountSv1ActionSetBalance(ctx *context.Context, args *utils.ArgsActSetBalance, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAccounts, utils.AccountSv1ActionSetBalance, args, reply)
-}
-func (dS *DispatcherService) AccountSv1DebitAbstracts(ctx *context.Context, args *utils.CGREvent, reply *utils.EventCharges) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAccounts, utils.AccountSv1DebitAbstracts, args, reply)
-}
-func (dS *DispatcherService) AccountSv1DebitConcretes(ctx *context.Context, args *utils.CGREvent, reply *utils.EventCharges) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAccounts, utils.AccountSv1DebitConcretes, args, reply)
-}
-func (dS *DispatcherService) AccountSv1GetAccount(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *utils.Account) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAccounts, utils.AccountSv1GetAccount, args, reply)
-}
-func (dS *DispatcherService) AccountSv1MaxAbstracts(ctx *context.Context, args *utils.CGREvent, reply *utils.EventCharges) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAccounts, utils.AccountSv1MaxAbstracts, args, reply)
-}
-func (dS *DispatcherService) AccountSv1MaxConcretes(ctx *context.Context, args *utils.CGREvent, reply *utils.EventCharges) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAccounts, utils.AccountSv1MaxConcretes, args, reply)
-}
-func (dS *DispatcherService) AccountSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAccounts, utils.AccountSv1Ping, args, reply)
-}
-func (dS *DispatcherService) AccountSv1RefundCharges(ctx *context.Context, args *utils.APIEventCharges, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAccounts, utils.AccountSv1RefundCharges, args, reply)
-}
diff --git a/dispatchers/accounts_it_test.go b/dispatchers/accounts_it_test.go
deleted file mode 100644
index 0c83b39dc..000000000
--- a/dispatchers/accounts_it_test.go
+++ /dev/null
@@ -1,79 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/utils"
-)
-
-var sTestsDspAccPrf = []func(t *testing.T){
- testDspAccPrfPing,
-}
-
-// Test start here
-func TestDspAccountSIT(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- }
- testDsp(t, sTestsDspAccPrf, "TestDspAccionSIT", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
-}
-
-func testDspAccPrfPing(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.AccountSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.AccountSv1Ping, &utils.CGREvent{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "accPrf12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
diff --git a/dispatchers/accounts_test.go b/dispatchers/accounts_test.go
deleted file mode 100644
index 8fa594fd0..000000000
--- a/dispatchers/accounts_test.go
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDspAccountSv1PingNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.AccountSv1Ping(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspAccountSv1PingNilArgs(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.AccountSv1Ping(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspAccountSv1PingErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.AccountSv1Ping(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspAAccountsForEventNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *[]*utils.Account
- result := dspSrv.AccountSv1AccountsForEvent(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspAccountsForEventErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *[]*utils.Account
- result := dspSrv.AccountSv1AccountsForEvent(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspMaxAbstractsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *utils.EventCharges
- result := dspSrv.AccountSv1MaxAbstracts(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspMaxAbstractsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *utils.EventCharges
- result := dspSrv.AccountSv1MaxAbstracts(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspDebitAbstractsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *utils.EventCharges
- result := dspSrv.AccountSv1DebitAbstracts(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspDebitAbstractsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *utils.EventCharges
- result := dspSrv.AccountSv1DebitAbstracts(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspMaxConcretesNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *utils.EventCharges
- result := dspSrv.AccountSv1MaxConcretes(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspMaxConcretesErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *utils.EventCharges
- result := dspSrv.AccountSv1MaxConcretes(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspDebitConcretesNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *utils.EventCharges
- result := dspSrv.AccountSv1DebitConcretes(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspDebitConcretesErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *utils.EventCharges
- result := dspSrv.AccountSv1DebitConcretes(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspAccountSv1ActionSetBalanceNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.ArgsActSetBalance{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.AccountSv1ActionSetBalance(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspAccountSv1ActionSetBalanceErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.ArgsActSetBalance{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.AccountSv1ActionSetBalance(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspAAccountSv1ActionRemoveBalanceNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.ArgsActRemoveBalances{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.AccountSv1ActionRemoveBalance(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspAccountSv1ActionRemoveBalanceErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.ArgsActRemoveBalances{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.AccountSv1ActionRemoveBalance(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/dispatchers/actions.go b/dispatchers/actions.go
deleted file mode 100644
index e3170b2b7..000000000
--- a/dispatchers/actions.go
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) ActionSv1ExecuteActions(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaActions, utils.ActionSv1ExecuteActions, args, reply)
-}
-func (dS *DispatcherService) ActionSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaActions, utils.ActionSv1Ping, args, reply)
-}
-func (dS *DispatcherService) ActionSv1ScheduleActions(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaActions, utils.ActionSv1ScheduleActions, args, reply)
-}
diff --git a/dispatchers/actions_it_test.go b/dispatchers/actions_it_test.go
deleted file mode 100644
index e2a15c91d..000000000
--- a/dispatchers/actions_it_test.go
+++ /dev/null
@@ -1,79 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/utils"
-)
-
-var sTestsDspActPrf = []func(t *testing.T){
- testDspActPrfPing,
-}
-
-// Test start here
-func TestDspActionSIT(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- }
- testDsp(t, sTestsDspActPrf, "TestDspActionSIT", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
-}
-
-func testDspActPrfPing(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.ActionSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ActionSv1Ping, &utils.CGREvent{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "actPrf12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
diff --git a/dispatchers/actions_test.go b/dispatchers/actions_test.go
deleted file mode 100644
index a7857192e..000000000
--- a/dispatchers/actions_test.go
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDspActionSv1PingNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ActionSv1Ping(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspActionSv1PingNilArgs(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ActionSv1Ping(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspActionSv1PingErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ActionSv1Ping(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspActionSv1ScheduleActionsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ActionSv1ScheduleActions(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspActionSv1ScheduleActionsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ActionSv1ScheduleActions(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspActionSv1ScheduleActionsNilArgs(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *string
- result := dspSrv.ActionSv1ScheduleActions(context.Background(), nil, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspActionSv1ExecuteActionsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ActionSv1ExecuteActions(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspActionSv1ExecuteActionsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ActionSv1ExecuteActions(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspActionSv1ExecuteActionsNilArgs(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *string
- result := dspSrv.ActionSv1ExecuteActions(context.Background(), nil, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/dispatchers/admins.go b/dispatchers/admins.go
deleted file mode 100644
index 22b6618c1..000000000
--- a/dispatchers/admins.go
+++ /dev/null
@@ -1,1330 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/apis"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) AdminSv1ComputeFilterIndexIDs(ctx *context.Context, args *utils.ArgsComputeFilterIndexIDs, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1ComputeFilterIndexIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1ComputeFilterIndexes(ctx *context.Context, args *utils.ArgsComputeFilterIndexes, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1ComputeFilterIndexes, args, reply)
-}
-func (dS *DispatcherService) AdminSv1FiltersMatch(ctx *context.Context, args *engine.ArgsFiltersMatch, reply *bool) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.CGREvent != nil && len(args.CGREvent.Tenant) != 0) {
- tnt = args.CGREvent.Tenant
- }
- ev := make(map[string]any)
- if args != nil && args.CGREvent != nil {
- ev = args.CGREvent.Event
- }
- opts := make(map[string]any)
- if args != nil && args.CGREvent != nil {
- opts = args.CGREvent.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1FiltersMatch, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetAccount(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *utils.Account) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetAccount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetAccountIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetAccountIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetAccounts(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*utils.Account) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetAccounts, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetAccountsCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetAccountsCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetAccountsIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetAccountsIndexesHealth, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetActionProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.ActionProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetActionProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetActionProfileIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetActionProfileIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetActionProfiles(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*engine.ActionProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetActionProfiles, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetActionProfilesCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetActionProfilesCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetActionsIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetActionsIndexesHealth, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetAttributeProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.APIAttributeProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetAttributeProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetAttributeProfileIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetAttributeProfileIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetAttributeProfiles(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*engine.APIAttributeProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetAttributeProfiles, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetAttributeProfilesCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetAttributeProfilesCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetAttributesIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetAttributesIndexesHealth, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetCDRs(ctx *context.Context, args *utils.CDRFilters, reply *[]*utils.CDR) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetCDRs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetChargerProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.ChargerProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetChargerProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetChargerProfileIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetChargerProfileIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetChargerProfiles(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*engine.ChargerProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetChargerProfiles, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetChargerProfilesCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetChargerProfilesCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetChargersIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetChargersIndexesHealth, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetDispatcherHost(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.DispatcherHost) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetDispatcherHost, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetDispatcherHostIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetDispatcherHostIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetDispatcherHosts(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*engine.DispatcherHost) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetDispatcherHosts, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetDispatcherHostsCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetDispatcherHostsCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetDispatcherProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.DispatcherProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetDispatcherProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetDispatcherProfileIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetDispatcherProfileIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetDispatcherProfiles(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*engine.DispatcherProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetDispatcherProfiles, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetDispatcherProfilesCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetDispatcherProfilesCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetDispatchersIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetDispatchersIndexesHealth, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetFilter(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.Filter) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetFilter, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetFilterIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetFilterIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetFilterIndexes(ctx *context.Context, args *apis.AttrGetFilterIndexes, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetFilterIndexes, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetFilters(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*engine.Filter) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetFilters, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetFiltersCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetFiltersCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRankingProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.RankingProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRankingProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRankingProfileIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRankingProfileIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRankingProfiles(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*engine.RankingProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRankingProfiles, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRankingProfilesCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRankingProfilesCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRateProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *utils.RateProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRateProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRateProfileIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRateProfileIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRateProfileRateIDs(ctx *context.Context, args *utils.ArgsSubItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRateProfileRateIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRateProfileRates(ctx *context.Context, args *utils.ArgsSubItemIDs, reply *[]*utils.Rate) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRateProfileRates, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRateProfileRatesCount(ctx *context.Context, args *utils.ArgsSubItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRateProfileRatesCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRateProfiles(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*utils.RateProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRateProfiles, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRateProfilesCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRateProfilesCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRateProfilesIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRateProfilesIndexesHealth, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRateRatesIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRateRatesIndexesHealth, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetResourceProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.ResourceProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetResourceProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetResourceProfileIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetResourceProfileIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetResourceProfiles(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*engine.ResourceProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetResourceProfiles, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetResourceProfilesCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetResourceProfilesCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetResourcesIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetResourcesIndexesHealth, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetReverseFilterHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *map[string]*engine.ReverseFilterIHReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetReverseFilterHealth, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRouteProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.RouteProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRouteProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRouteProfileIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRouteProfileIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRouteProfiles(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*engine.RouteProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRouteProfiles, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRouteProfilesCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRouteProfilesCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetRoutesIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetRoutesIndexesHealth, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetStatQueueProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.StatQueueProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetStatQueueProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetStatQueueProfileIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetStatQueueProfileIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetStatQueueProfiles(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*engine.StatQueueProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetStatQueueProfiles, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetStatQueueProfilesCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetStatQueueProfilesCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetStatsIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetStatsIndexesHealth, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetThresholdProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.ThresholdProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetThresholdProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetThresholdProfileIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetThresholdProfileIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetThresholdProfiles(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*engine.ThresholdProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetThresholdProfiles, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetThresholdProfilesCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetThresholdProfilesCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetThresholdsIndexesHealth(ctx *context.Context, args *engine.IndexHealthArgs, reply *engine.FilterIHReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetThresholdsIndexesHealth, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetTrendProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.TrendProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetTrendProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetTrendProfileIDs(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetTrendProfileIDs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetTrendProfiles(ctx *context.Context, args *utils.ArgsItemIDs, reply *[]*engine.TrendProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetTrendProfiles, args, reply)
-}
-func (dS *DispatcherService) AdminSv1GetTrendProfilesCount(ctx *context.Context, args *utils.ArgsItemIDs, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1GetTrendProfilesCount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1Ping, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveAccount(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveAccount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveActionProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveActionProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveAttributeProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveAttributeProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveCDRs(ctx *context.Context, args *utils.CDRFilters, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveCDRs, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveChargerProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveChargerProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveDispatcherHost(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveDispatcherHost, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveDispatcherProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveDispatcherProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveFilter(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveFilter, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveFilterIndexes(ctx *context.Context, args *apis.AttrRemFilterIndexes, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveFilterIndexes, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveRankingProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveRankingProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveRateProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveRateProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveRateProfileRates(ctx *context.Context, args *utils.RemoveRPrfRates, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveRateProfileRates, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveResourceProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveResourceProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveRouteProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveRouteProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveStatQueueProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveStatQueueProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveThresholdProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveThresholdProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1RemoveTrendProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1RemoveTrendProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetAccount(ctx *context.Context, args *utils.AccountWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.Account != nil && len(args.Account.Tenant) != 0) {
- tnt = args.Account.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetAccount, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetActionProfile(ctx *context.Context, args *engine.ActionProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.ActionProfile != nil && len(args.ActionProfile.Tenant) != 0) {
- tnt = args.ActionProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetActionProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetAttributeProfile(ctx *context.Context, args *engine.APIAttributeProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.APIAttributeProfile != nil && len(args.APIAttributeProfile.Tenant) != 0) {
- tnt = args.APIAttributeProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetAttributeProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetChargerProfile(ctx *context.Context, args *apis.ChargerWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.ChargerProfile != nil && len(args.ChargerProfile.Tenant) != 0) {
- tnt = args.ChargerProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetChargerProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetDispatcherHost(ctx *context.Context, args *engine.DispatcherHostWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.DispatcherHost != nil && len(args.DispatcherHost.Tenant) != 0) {
- tnt = args.DispatcherHost.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetDispatcherHost, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetDispatcherProfile(ctx *context.Context, args *apis.DispatcherWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.DispatcherProfile != nil && len(args.DispatcherProfile.Tenant) != 0) {
- tnt = args.DispatcherProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetDispatcherProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetFilter(ctx *context.Context, args *engine.FilterWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.Filter != nil && len(args.Filter.Tenant) != 0) {
- tnt = args.Filter.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetFilter, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetRankingProfile(ctx *context.Context, args *engine.RankingProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.RankingProfile != nil && len(args.RankingProfile.Tenant) != 0) {
- tnt = args.RankingProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetRankingProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetRateProfile(ctx *context.Context, args *utils.APIRateProfile, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.RateProfile != nil && len(args.RateProfile.Tenant) != 0) {
- tnt = args.RateProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetRateProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetResourceProfile(ctx *context.Context, args *engine.ResourceProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.ResourceProfile != nil && len(args.ResourceProfile.Tenant) != 0) {
- tnt = args.ResourceProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetResourceProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetRouteProfile(ctx *context.Context, args *engine.RouteProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.RouteProfile != nil && len(args.RouteProfile.Tenant) != 0) {
- tnt = args.RouteProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetRouteProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetStatQueueProfile(ctx *context.Context, args *engine.StatQueueProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.StatQueueProfile != nil && len(args.StatQueueProfile.Tenant) != 0) {
- tnt = args.StatQueueProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetStatQueueProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetThresholdProfile(ctx *context.Context, args *engine.ThresholdProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.ThresholdProfile != nil && len(args.ThresholdProfile.Tenant) != 0) {
- tnt = args.ThresholdProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetThresholdProfile, args, reply)
-}
-func (dS *DispatcherService) AdminSv1SetTrendProfile(ctx *context.Context, args *engine.TrendProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TrendProfile != nil && len(args.TrendProfile.Tenant) != 0) {
- tnt = args.TrendProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAdminS, utils.AdminSv1SetTrendProfile, args, reply)
-}
diff --git a/dispatchers/analyzers.go b/dispatchers/analyzers.go
deleted file mode 100644
index 56065de39..000000000
--- a/dispatchers/analyzers.go
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/analyzers"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) AnalyzerSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAnalyzerS, utils.AnalyzerSv1Ping, args, reply)
-}
-func (dS *DispatcherService) AnalyzerSv1StringQuery(ctx *context.Context, args *analyzers.QueryArgs, reply *[]map[string]any) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- ev := make(map[string]any)
- opts := make(map[string]any)
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAnalyzerS, utils.AnalyzerSv1StringQuery, args, reply)
-}
diff --git a/dispatchers/attributes.go b/dispatchers/attributes.go
deleted file mode 100644
index 8da99b8c9..000000000
--- a/dispatchers/attributes.go
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) AttributeSv1GetAttributeForEvent(ctx *context.Context, args *utils.CGREvent, reply *engine.APIAttributeProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAttributes, utils.AttributeSv1GetAttributeForEvent, args, reply)
-}
-func (dS *DispatcherService) AttributeSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAttributes, utils.AttributeSv1Ping, args, reply)
-}
-func (dS *DispatcherService) AttributeSv1ProcessEvent(ctx *context.Context, args *utils.CGREvent, reply *engine.AttrSProcessEventReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaAttributes, utils.AttributeSv1ProcessEvent, args, reply)
-}
diff --git a/dispatchers/attributes_it_test.go b/dispatchers/attributes_it_test.go
deleted file mode 100644
index 40d7fceba..000000000
--- a/dispatchers/attributes_it_test.go
+++ /dev/null
@@ -1,673 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "reflect"
- "sort"
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var sTestsDspAttr = []func(t *testing.T){
- testDspAttrPingFailover,
- testDspAttrPingFailover2,
- testDspAttrPingFailoverNotFoundHost,
- testDspAttrGetAttrFailover,
- testDspAttrGetAttrRoundRobin,
-
- testDspAttrPing,
- testDspAttrTestMissingArgDispatcher,
- testDspAttrTestMissingApiKey,
- testDspAttrTestUnknownApiKey,
- testDspAttrTestAuthKey,
- testDspAttrTestAuthKey2,
- testDspAttrTestAuthKey3,
-
- testDspAttrGetAttrInternal,
-}
-
-// Test start here
-func TestDspAttributeS(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- }
- testDsp(t, sTestsDspAttr, "TestDspAttributeS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
-}
-
-func TestDspAttributeSNoConn(t *testing.T) {
- if *utils.DBType != utils.MetaMySQL {
- t.SkipNow()
- }
- testDsp(t, []func(t *testing.T){
- testDspAttrPingFailover,
- testDspAttrPing,
- testDspAttrPingNoArgDispatcher,
- }, "TestDspAttributeS", "all_mysql", "all2_mysql", "dispatchers_no_attributes", "tutorial", "oldtutorial", "dispatchers")
-}
-
-func testDspAttrPingFailover(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- reply = ""
- if err := allEngine2.RPC.Call(context.Background(), utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- reply = ""
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "attr12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine.stopEngine(t)
- reply = ""
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine2.stopEngine(t)
- reply = ""
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, &ev, &reply); err == nil {
- t.Errorf("Expected error but received %v and reply %v\n", err, reply)
- }
- allEngine.startEngine(t)
- allEngine2.startEngine(t)
- reply = ""
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
-
-func testDspAttrPingFailoverNotFoundHost(t *testing.T) {
- var reply string
- if err := allEngine2.RPC.Call(context.Background(), utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- Event: map[string]any{
- "EventName": "NonexistingHost",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "attr12345",
- utils.OptsDispatchersProfilesCount: 1,
- },
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine2.stopEngine(t) // stop the engine and we expect to get error
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, &ev, &reply); err == nil {
- t.Errorf("Expected error but received %v and reply %v\n", err, reply)
- }
- allEngine2.startEngine(t)
- reply = ""
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
-
-func testDspAttrPingFailover2(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- reply = ""
- if err := allEngine2.RPC.Call(context.Background(), utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- reply = ""
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "attr12345",
- },
- }
- allEngine.stopEngine(t) // stop the engine and the call should go to the second engine
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine2.stopEngine(t)
- reply = ""
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, &ev, &reply); err == nil {
- t.Errorf("Expected error but received %v and reply %v\n", err, reply)
- }
- allEngine.startEngine(t)
- allEngine2.startEngine(t)
- reply = ""
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
-
-func testDspAttrGetAttrFailover(t *testing.T) {
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAttributeSGetAttributeForEvent",
- Event: map[string]any{
- utils.AccountField: "1002",
- utils.EventName: "Event1",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "attr12345",
- utils.OptsContext: "simpleauth",
- },
- }
- eAttrPrf := &engine.APIAttributeProfile{
- Tenant: ev.Tenant,
- ID: "ATTR_1002_SIMPLEAUTH",
- FilterIDs: []string{"*string:~*req.Account:1002", "*string:~*opts.*context:simpleauth"},
- Attributes: []*engine.ExternalAttribute{{
- FilterIDs: []string{},
- Path: utils.MetaReq + utils.NestingSep + "Password",
- Type: utils.MetaConstant,
- Value: "CGRateS.org",
- }},
- Blockers: utils.DynamicBlockers{
- {
- Blocker: false,
- },
- },
- Weights: utils.DynamicWeights{
- {
- Weight: 20,
- },
- },
- }
- if *utils.Encoding == utils.MetaGOB {
- eAttrPrf.Attributes[0].FilterIDs = nil // empty slice are nil in gob
- }
-
- eRply := &engine.AttrSProcessEventReply{
- AlteredFields: []*engine.FieldsAltered{
- {
- MatchedProfileID: "cgrates.org:ATTR_1002_SIMPLEAUTH",
- Fields: []string{"*req.Password"},
- },
- },
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAttributeSGetAttributeForEvent",
- Event: map[string]any{
- utils.AccountField: "1002",
- utils.EventName: "Event1",
- "Password": "CGRateS.org",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "attr12345",
- utils.OptsContext: "simpleauth",
- utils.MetaNodeID: "DispatcherS1",
- utils.MetaSubsys: "*dispatchers",
- },
- },
- }
-
- var attrReply engine.APIAttributeProfile
- var rplyEv engine.AttrSProcessEventReply
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
- ev, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1ProcessEvent,
- ev, &rplyEv); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- } else if reflect.DeepEqual(*eRply, &rplyEv) {
- t.Errorf("Expecting: %s, received: %s",
- utils.ToJSON(*eRply), utils.ToJSON(rplyEv))
- }
-
- allEngine2.stopEngine(t)
-
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
- ev, &attrReply); err != nil {
- t.Error(err)
- }
- sort.Strings(eAttrPrf.FilterIDs)
- sort.Strings(attrReply.FilterIDs)
- if !reflect.DeepEqual(*eAttrPrf, attrReply) {
- t.Errorf("Expecting: %s, received: %s", utils.ToJSON(*eAttrPrf), utils.ToJSON(attrReply))
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1ProcessEvent,
- ev, &rplyEv); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eRply, &rplyEv) {
- t.Errorf("Expecting: %s, received: %s",
- utils.ToJSON(eRply), utils.ToJSON(rplyEv))
- }
-
- allEngine2.startEngine(t)
-}
-
-func testDspAttrPing(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- if dispEngine.RPC == nil {
- t.Fatal(dispEngine.RPC)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, &utils.CGREvent{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "attr12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
-
-func testDspAttrTestMissingArgDispatcher(t *testing.T) {
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAttributeSGetAttributeForEvent",
- Event: map[string]any{
- utils.AccountField: "1001",
- },
- APIOpts: map[string]any{
- utils.OptsContext: "simpleauth",
- },
- }
- var attrReply *engine.AttributeProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
- ev, &attrReply); err == nil || err.Error() != utils.NewErrMandatoryIeMissing(utils.APIKey).Error() {
- t.Errorf("Error:%v rply=%s", err, utils.ToJSON(attrReply))
- }
-}
-
-func testDspAttrTestMissingApiKey(t *testing.T) {
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAttributeSGetAttributeForEvent",
- Event: map[string]any{
- utils.AccountField: "1001",
- },
- APIOpts: map[string]any{
- utils.OptsContext: "simpleauth",
- },
- }
- var attrReply *engine.AttributeProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
- ev, &attrReply); err == nil || err.Error() != utils.NewErrMandatoryIeMissing(utils.APIKey).Error() {
- t.Errorf("Error:%v rply=%s", err, utils.ToJSON(attrReply))
- }
-}
-
-func testDspAttrTestUnknownApiKey(t *testing.T) {
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAttributeSGetAttributeForEvent",
- Event: map[string]any{
- utils.AccountField: "1001",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "1234",
- },
- }
- var attrReply *engine.AttributeProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
- ev, &attrReply); err == nil || err.Error() != utils.ErrUnknownApiKey.Error() {
- t.Error(err)
- }
-}
-
-func testDspAttrTestAuthKey(t *testing.T) {
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAttributeSGetAttributeForEvent",
- Event: map[string]any{
- utils.AccountField: "1001",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "12345",
- utils.OptsContext: "simpleauth",
- },
- }
- var attrReply *engine.AttributeProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
- ev, &attrReply); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
- t.Error(err)
- }
-}
-
-func testDspAttrTestAuthKey2(t *testing.T) {
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAttributeSGetAttributeForEvent",
- Event: map[string]any{
- utils.AccountField: "1001",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "attr12345",
- utils.OptsContext: "simpleauth",
- },
- }
- eAttrPrf := &engine.APIAttributeProfile{
- Tenant: ev.Tenant,
- ID: "ATTR_1001_SIMPLEAUTH",
- FilterIDs: []string{"*string:~*req.Account:1001", "*string:~*opts.*context:simpleauth"},
- Attributes: []*engine.ExternalAttribute{{
- FilterIDs: []string{},
- Path: utils.MetaReq + utils.NestingSep + "Password",
- Type: utils.MetaConstant,
- Value: "CGRateS.org",
- }},
- Blockers: utils.DynamicBlockers{
- {
- Blocker: false,
- },
- },
- Weights: utils.DynamicWeights{
- {
- Weight: 20,
- },
- },
- }
- if *utils.Encoding == utils.MetaGOB {
- eAttrPrf.Attributes[0].FilterIDs = nil // empty slice are nil in gob
- }
- var attrReply engine.APIAttributeProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
- ev, &attrReply); err != nil {
- t.Error(err)
- }
- sort.Strings(eAttrPrf.FilterIDs)
- sort.Strings(attrReply.FilterIDs)
- if !reflect.DeepEqual(*eAttrPrf, attrReply) {
- t.Errorf("Expecting: %s, received: %s", utils.ToJSON(*eAttrPrf), utils.ToJSON(attrReply))
- }
-
- eRply := &engine.AttrSProcessEventReply{
- AlteredFields: []*engine.FieldsAltered{
- {
- MatchedProfileID: "cgrates.org:ATTR_1001_SIMPLEAUTH",
- Fields: []string{"*req.Password"},
- },
- },
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAttributeSGetAttributeForEvent",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "attr12345",
- utils.OptsContext: "simpleauth",
- utils.MetaNodeID: "DispatcherS1",
- utils.MetaSubsys: "*dispatchers",
- },
- },
- }
-
- var rplyEv engine.AttrSProcessEventReply
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1ProcessEvent,
- ev, &rplyEv); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eRply, &rplyEv) {
- t.Errorf("Expecting: %s, received: %s",
- utils.ToJSON(eRply), utils.ToJSON(rplyEv))
- }
-}
-
-func testDspAttrTestAuthKey3(t *testing.T) {
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAttributeSGetAttributeForEvent",
- Event: map[string]any{
- utils.AccountField: "1001",
- utils.EventName: "Event1",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "attr12345",
- utils.OptsContext: "simpleauth",
- },
- }
- var attrReply *engine.AttributeProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
- ev, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-}
-
-func testDspAttrGetAttrRoundRobin(t *testing.T) {
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAttributeSGetAttributeForEvent",
- Event: map[string]any{
- utils.AccountField: "1002",
- utils.EventName: "RoundRobin",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "attr12345",
- utils.OptsContext: "simpleauth",
- },
- }
- eAttrPrf := &engine.APIAttributeProfile{
- Tenant: ev.Tenant,
- ID: "ATTR_1002_SIMPLEAUTH",
- FilterIDs: []string{"*string:~*req.Account:1002", "*string:~*opts.*context:simpleauth"},
- Attributes: []*engine.ExternalAttribute{{
- FilterIDs: []string{},
- Path: utils.MetaReq + utils.NestingSep + "Password",
- Type: utils.MetaConstant,
- Value: "CGRateS.org",
- }},
- Blockers: utils.DynamicBlockers{
- {
- Blocker: false,
- },
- },
- Weights: utils.DynamicWeights{
- {
- Weight: 20,
- },
- },
- }
- if *utils.Encoding == utils.MetaGOB {
- eAttrPrf.Attributes[0].FilterIDs = nil // empty slice are nil in gob
- }
-
- eRply := &engine.AttrSProcessEventReply{
- AlteredFields: []*engine.FieldsAltered{
- {
- MatchedProfileID: "cgrates.org:ATTR_1002_SIMPLEAUTH",
- Fields: []string{"*req.Password"},
- },
- },
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAttributeSGetAttributeForEvent",
- Event: map[string]any{
- utils.AccountField: "1002",
- utils.EventName: "RoundRobin",
- "Password": "CGRateS.org",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "attr12345",
- utils.OptsContext: "simpleauth",
- utils.MetaNodeID: "DispatcherS1",
- utils.MetaSubsys: "*dispatchers",
- },
- },
- }
-
- var attrReply engine.APIAttributeProfile
- var rplyEv engine.AttrSProcessEventReply
- // To ALL2
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
- ev, &attrReply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-
- // To ALL
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1GetAttributeForEvent,
- ev, &attrReply); err != nil {
- t.Error(err)
- }
-
- sort.Strings(eAttrPrf.FilterIDs)
- sort.Strings(attrReply.FilterIDs)
- if !reflect.DeepEqual(*eAttrPrf, attrReply) {
- t.Errorf("Expecting: %s, received: %s", utils.ToJSON(*eAttrPrf), utils.ToJSON(attrReply))
- }
-
- // To ALL2
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1ProcessEvent,
- ev, &rplyEv); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- } else if reflect.DeepEqual(eRply, &rplyEv) {
- t.Errorf("Expecting: %s, received: %s",
- utils.ToJSON(eRply), utils.ToJSON(rplyEv))
- }
-
- // To ALL
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1ProcessEvent,
- ev, &rplyEv); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eRply, &rplyEv) {
- t.Errorf("Expecting: %s, received: %s",
- utils.ToJSON(eRply), utils.ToJSON(rplyEv))
- }
-}
-
-func testDspAttrGetAttrInternal(t *testing.T) {
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAttributeSGetAttributeForEvent",
- Event: map[string]any{
- utils.EventName: "Internal",
- utils.AccountField: "1003",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "attr12345",
- utils.OptsContext: "simpleauth",
- },
- }
-
- eRply := &engine.AttrSProcessEventReply{
- AlteredFields: []*engine.FieldsAltered{
- {
- MatchedProfileID: "cgrates.org:ATTR_1003_SIMPLEAUTH",
- Fields: []string{"*req.Password"},
- },
- },
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAttributeSGetAttributeForEvent",
- Event: map[string]any{
- utils.AccountField: "1003",
- utils.EventName: "Internal",
- "Password": "CGRateS.com",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "attr12345",
- utils.OptsContext: "simpleauth",
- utils.MetaNodeID: "DispatcherS1",
- utils.MetaSubsys: "*dispatchers",
- },
- },
- }
-
- var rplyEv engine.AttrSProcessEventReply
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1ProcessEvent,
- ev, &rplyEv); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eRply, &rplyEv) {
- t.Errorf("Expecting: %s, received: %s",
- utils.ToJSON(eRply), utils.ToJSON(rplyEv))
- }
-}
-
-func testDspAttrPingNoArgDispatcher(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- if dispEngine.RPC == nil {
- t.Fatal(dispEngine.RPC)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.AttributeSv1Ping, &utils.CGREvent{Tenant: "cgrates.org"}, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
diff --git a/dispatchers/attributes_test.go b/dispatchers/attributes_test.go
deleted file mode 100644
index 7e28c29b2..000000000
--- a/dispatchers/attributes_test.go
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDspAttributeSv1PingError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrEvent := &utils.CGREvent{}
- var reply *string
- err := dspSrv.AttributeSv1Ping(context.Background(), cgrEvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDspAttributeSv1PingErrorTenant(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrEvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- err := dspSrv.AttributeSv1Ping(context.Background(), cgrEvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDspAttributeSv1PingErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- err := dspSrv.AttributeSv1Ping(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDspAttributeSv1PingErrorAttributeSConns(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrEvent := &utils.CGREvent{
- Tenant: "tenant",
- ID: "ID",
- }
- var reply *string
- err := dspSrv.AttributeSv1Ping(context.Background(), cgrEvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDspAttributeSv1GetAttributeForEventError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- ev := &utils.CGREvent{}
-
- var reply *engine.APIAttributeProfile
- err := dspSrv.AttributeSv1GetAttributeForEvent(context.Background(), ev, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDspAttributeSv1GetAttributeForEventErrorTenant(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- ev := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *engine.APIAttributeProfile
- err := dspSrv.AttributeSv1GetAttributeForEvent(context.Background(), ev, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDspAttributeSv1GetAttributeForEventErrorAttributeS(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- ev := &utils.CGREvent{
- Tenant: "tenant",
- }
-
- var reply *engine.APIAttributeProfile
- err := dspSrv.AttributeSv1GetAttributeForEvent(context.Background(), ev, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDspAttributeSv1ProcessEventError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- ev := &utils.CGREvent{
- Tenant: "tenant",
- }
-
- var reply *engine.AttrSProcessEventReply
- err := dspSrv.AttributeSv1ProcessEvent(context.Background(), ev, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDspAttributeSv1ProcessEventErrorAttributeSConns(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- ev := &utils.CGREvent{
- Tenant: "tenant",
- }
-
- var reply *engine.AttrSProcessEventReply
- err := dspSrv.AttributeSv1ProcessEvent(context.Background(), ev, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
diff --git a/dispatchers/caches.go b/dispatchers/caches.go
deleted file mode 100644
index 8775f29ee..000000000
--- a/dispatchers/caches.go
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/utils"
- "github.com/cgrates/ltcache"
- "time"
-)
-
-func (dS *DispatcherService) CacheSv1Clear(ctx *context.Context, args *utils.AttrCacheIDsWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1Clear, args, reply)
-}
-func (dS *DispatcherService) CacheSv1GetCacheStats(ctx *context.Context, args *utils.AttrCacheIDsWithAPIOpts, reply *map[string]*ltcache.CacheStats) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1GetCacheStats, args, reply)
-}
-func (dS *DispatcherService) CacheSv1GetGroupItemIDs(ctx *context.Context, args *utils.ArgsGetGroupWithAPIOpts, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1GetGroupItemIDs, args, reply)
-}
-func (dS *DispatcherService) CacheSv1GetItem(ctx *context.Context, args *utils.ArgsGetCacheItemWithAPIOpts, reply *any) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1GetItem, args, reply)
-}
-func (dS *DispatcherService) CacheSv1GetItemExpiryTime(ctx *context.Context, args *utils.ArgsGetCacheItemWithAPIOpts, reply *time.Time) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1GetItemExpiryTime, args, reply)
-}
-func (dS *DispatcherService) CacheSv1GetItemIDs(ctx *context.Context, args *utils.ArgsGetCacheItemIDsWithAPIOpts, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1GetItemIDs, args, reply)
-}
-func (dS *DispatcherService) CacheSv1GetItemWithRemote(ctx *context.Context, args *utils.ArgsGetCacheItemWithAPIOpts, reply *any) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1GetItemWithRemote, args, reply)
-}
-func (dS *DispatcherService) CacheSv1HasGroup(ctx *context.Context, args *utils.ArgsGetGroupWithAPIOpts, reply *bool) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1HasGroup, args, reply)
-}
-func (dS *DispatcherService) CacheSv1HasItem(ctx *context.Context, args *utils.ArgsGetCacheItemWithAPIOpts, reply *bool) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1HasItem, args, reply)
-}
-func (dS *DispatcherService) CacheSv1LoadCache(ctx *context.Context, args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1LoadCache, args, reply)
-}
-func (dS *DispatcherService) CacheSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1Ping, args, reply)
-}
-func (dS *DispatcherService) CacheSv1PrecacheStatus(ctx *context.Context, args *utils.AttrCacheIDsWithAPIOpts, reply *map[string]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1PrecacheStatus, args, reply)
-}
-func (dS *DispatcherService) CacheSv1ReloadCache(ctx *context.Context, args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1ReloadCache, args, reply)
-}
-func (dS *DispatcherService) CacheSv1RemoveGroup(ctx *context.Context, args *utils.ArgsGetGroupWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1RemoveGroup, args, reply)
-}
-func (dS *DispatcherService) CacheSv1RemoveItem(ctx *context.Context, args *utils.ArgsGetCacheItemWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1RemoveItem, args, reply)
-}
-func (dS *DispatcherService) CacheSv1RemoveItems(ctx *context.Context, args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1RemoveItems, args, reply)
-}
-func (dS *DispatcherService) CacheSv1ReplicateRemove(ctx *context.Context, args *utils.ArgCacheReplicateRemove, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1ReplicateRemove, args, reply)
-}
-func (dS *DispatcherService) CacheSv1ReplicateSet(ctx *context.Context, args *utils.ArgCacheReplicateSet, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1ReplicateSet, args, reply)
-}
diff --git a/dispatchers/caches_it_test.go b/dispatchers/caches_it_test.go
deleted file mode 100644
index e62adcd36..000000000
--- a/dispatchers/caches_it_test.go
+++ /dev/null
@@ -1,360 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "reflect"
- "sort"
- "testing"
- "time"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
- "github.com/cgrates/ltcache"
-)
-
-var sTestsDspChc = []func(t *testing.T){
- testDspChcPing,
- testDspChcLoadAfterFolder,
- testDspChcPrecacheStatus,
- testDspChcGetItemIDs,
- testDspChcHasItem,
- testDspChcGetItemExpiryTime,
- testDspChcReloadCache,
- testDspChcRemoveItem,
- testDspChcClear,
-}
-
-// Test start here
-func TestDspCacheSv1(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- }
- testDsp(t, sTestsDspChc, "TestDspCacheSv1", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
-}
-
-func testDspChcPing(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.CacheSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- if dispEngine.RPC == nil {
- t.Fatal(dispEngine.RPC)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1Ping, &utils.CGREvent{
-
- Tenant: "cgrates.org",
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chc12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
-
-func testDspChcLoadAfterFolder(t *testing.T) {
- var rcvStats map[string]*ltcache.CacheStats
- expStats := engine.GetDefaultEmptyCacheStats()
- args := utils.AttrCacheIDsWithAPIOpts{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chc12345",
- },
- Tenant: "cgrates.org",
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1GetCacheStats, args, &rcvStats); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expStats, rcvStats) {
- t.Errorf("Expecting: %+v, \n received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats))
- }
- reply := ""
- // Simple test that command is executed without errors
- argsR := utils.NewAttrReloadCacheWithOpts()
- argsR.APIOpts = map[string]any{
- utils.OptsAPIKey: "chc12345",
- }
- argsR.Tenant = "cgrates.org"
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1LoadCache, argsR, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Error(reply)
- }
- expStats[utils.CacheAttributeProfiles].Items = 11
- expStats[utils.CacheChargerProfiles].Items = 2
- expStats[utils.CacheFilters].Items = 7
- expStats[utils.CacheResourceProfiles].Items = 1
- expStats[utils.CacheResources].Items = 1
- expStats[utils.CacheStatQueueProfiles].Items = 2
- expStats[utils.CacheStatQueues].Items = 2
- expStats[utils.CacheRouteProfiles].Items = 3
- expStats[utils.CacheThresholdProfiles].Items = 2
- expStats[utils.CacheThresholds].Items = 2
- expStats[utils.CacheLoadIDs].Items = 32
- expStats[utils.CacheThresholdFilterIndexes].Items = 2
- expStats[utils.CacheThresholdFilterIndexes].Groups = 1
- expStats[utils.CacheRankingProfiles].Items = 0
- expStats[utils.CacheRankingProfiles].Groups = 0
- expStats[utils.CacheRankings].Items = 0
- expStats[utils.CacheRankings].Groups = 0
- expStats[utils.CacheStatFilterIndexes].Items = 7
- expStats[utils.CacheStatFilterIndexes].Groups = 1
- expStats[utils.CacheRouteFilterIndexes].Items = 3
- expStats[utils.CacheRouteFilterIndexes].Groups = 1
- expStats[utils.CacheResourceFilterIndexes].Items = 3
- expStats[utils.CacheResourceFilterIndexes].Groups = 1
- expStats[utils.CacheChargerFilterIndexes].Items = 1
- expStats[utils.CacheChargerFilterIndexes].Groups = 1
- expStats[utils.CacheAttributeFilterIndexes].Items = 10
- expStats[utils.CacheAttributeFilterIndexes].Groups = 2
- expStats[utils.CacheReverseFilterIndexes].Items = 8
- expStats[utils.CacheReverseFilterIndexes].Groups = 6
- expStats[utils.CacheRateProfiles].Items = 2
- expStats[utils.CacheRateProfilesFilterIndexes].Items = 1
- expStats[utils.CacheRateProfilesFilterIndexes].Groups = 1
- expStats[utils.CacheRateFilterIndexes].Items = 2
- expStats[utils.CacheRateFilterIndexes].Groups = 2
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1GetCacheStats, &args, &rcvStats); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expStats, rcvStats) {
- t.Errorf("Expecting: %+v, \n received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats))
- }
-}
-
-func testDspChcPrecacheStatus(t *testing.T) {
- var reply map[string]string
- expected := map[string]string{
- utils.CacheResourceProfiles: utils.MetaReady,
- utils.CacheResources: utils.MetaReady,
- utils.CacheStatQueueProfiles: utils.MetaReady,
- utils.CacheStatQueues: utils.MetaReady,
- utils.CacheThresholdProfiles: utils.MetaReady,
- utils.CacheThresholds: utils.MetaReady,
- utils.CacheTrendProfiles: utils.MetaReady,
- utils.CacheTrends: utils.MetaReady,
- utils.CacheRankingProfiles: utils.MetaReady,
- utils.CacheRankings: utils.MetaReady,
- utils.CacheFilters: utils.MetaReady,
- utils.CacheRouteProfiles: utils.MetaReady,
- utils.CacheAttributeProfiles: utils.MetaReady,
- utils.CacheChargerProfiles: utils.MetaReady,
- utils.CacheDispatcherProfiles: utils.MetaReady,
- utils.CacheDispatcherHosts: utils.MetaReady,
- utils.CacheDiameterMessages: utils.MetaReady,
- utils.CacheAttributeFilterIndexes: utils.MetaReady,
- utils.CacheResourceFilterIndexes: utils.MetaReady,
- utils.MetaSentryPeer: utils.MetaReady,
- utils.CacheStatFilterIndexes: utils.MetaReady,
- utils.CacheThresholdFilterIndexes: utils.MetaReady,
- utils.CacheRouteFilterIndexes: utils.MetaReady,
- utils.CacheChargerFilterIndexes: utils.MetaReady,
- utils.CacheDispatcherFilterIndexes: utils.MetaReady,
- utils.CacheRateProfilesFilterIndexes: utils.MetaReady,
- utils.CacheRateFilterIndexes: utils.MetaReady,
- utils.CacheRateProfiles: utils.MetaReady,
- utils.CacheLoadIDs: utils.MetaReady,
- utils.CacheCDRIDs: utils.MetaReady,
- utils.CacheClosedSessions: utils.MetaReady,
- utils.CacheDispatcherRoutes: utils.MetaReady,
- utils.CacheEventResources: utils.MetaReady,
- utils.CacheRPCConnections: utils.MetaReady,
- utils.CacheRPCResponses: utils.MetaReady,
- utils.CacheUCH: utils.MetaReady,
- utils.CacheSTIR: utils.MetaReady,
- utils.CacheDispatcherLoads: utils.MetaReady,
- utils.CacheDispatchers: utils.MetaReady,
- utils.CacheEventCharges: utils.MetaReady,
- utils.CacheReverseFilterIndexes: utils.MetaReady,
- utils.CacheCapsEvents: utils.MetaReady,
- utils.CacheActionProfiles: utils.MetaReady,
- utils.CacheActionProfilesFilterIndexes: utils.MetaReady,
- utils.CacheAccountsFilterIndexes: utils.MetaReady,
- utils.CacheAccounts: utils.MetaReady,
- utils.MetaAPIBan: utils.MetaReady,
- utils.CacheReplicationHosts: utils.MetaReady,
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1PrecacheStatus, utils.AttrCacheIDsWithAPIOpts{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chc12345",
- },
- Tenant: "cgrates.org",
- }, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, reply) {
- t.Errorf("Expected: %v , \n received:%v", utils.ToJSON(expected), utils.ToJSON(reply))
- }
-}
-
-func testDspChcGetItemIDs(t *testing.T) {
- var rcvKeys []string
- expKeys := []string{"cgrates.org:DEFAULT", "cgrates.org:Raw"}
- argsAPI := utils.ArgsGetCacheItemIDsWithAPIOpts{
- ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
- CacheID: utils.CacheChargerProfiles,
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chc12345",
- },
- Tenant: "cgrates.org",
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
- t.Fatalf("Got error on APIerSv1.GetCacheStats: %s ", err.Error())
- }
- sort.Strings(rcvKeys)
- if !reflect.DeepEqual(expKeys, rcvKeys) {
- t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
- }
-}
-
-func testDspChcHasItem(t *testing.T) {
- var reply bool
- expected := true
- argsAPI := utils.ArgsGetCacheItemWithAPIOpts{
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheChargerProfiles,
- ItemID: "cgrates.org:DEFAULT",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chc12345",
- },
- Tenant: "cgrates.org",
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1HasItem, argsAPI, &reply); err != nil {
- t.Error(err)
- } else if !reply {
- t.Errorf("Expected: %v , received:%v", expected, reply)
- }
-}
-
-func testDspChcGetItemExpiryTime(t *testing.T) {
- var reply time.Time
- var expected time.Time
- argsAPI := utils.ArgsGetCacheItemWithAPIOpts{
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheChargerProfiles,
- ItemID: "cgrates.org:DEFAULT",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chc12345",
- },
- Tenant: "cgrates.org",
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1GetItemExpiryTime, argsAPI, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, reply) {
- t.Errorf("Expected: %v , received:%v", expected, reply)
- }
-}
-
-func testDspChcReloadCache(t *testing.T) {
- reply := ""
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chc12345",
- },
- Tenant: "cgrates.org",
- }, &reply); err != nil {
- t.Error("Got error on CacheSv1.ReloadCache: ", err.Error())
- } else if reply != utils.OK {
- t.Error("Calling CacheSv1.ReloadCache got reply: ", reply)
- }
-}
-
-func testDspChcRemoveItem(t *testing.T) {
- var reply bool
- argsAPI := utils.ArgsGetCacheItemWithAPIOpts{
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheChargerProfiles,
- ItemID: "cgrates.org:DEFAULT",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chc12345",
- },
- Tenant: "cgrates.org",
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1HasItem, argsAPI, &reply); err != nil {
- t.Error(err)
- } else if !reply {
- t.Errorf("Expected: %v , received:%v", true, reply)
- }
- var remReply string
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1RemoveItem, argsAPI, &remReply); err != nil {
- t.Error(err)
- } else if remReply != utils.OK {
- t.Errorf("Expected: %v , received:%v", utils.OK, remReply)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1HasItem, argsAPI, &reply); err != nil {
- t.Error(err)
- } else if reply {
- t.Errorf("Expected: %v , received:%v", false, reply)
- }
-}
-
-func testDspChcClear(t *testing.T) {
- reply := ""
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1Clear, utils.AttrCacheIDsWithAPIOpts{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chc12345",
- },
- Tenant: "cgrates.org",
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Error("Calling CacheSv1.ReloadCache got reply: ", reply)
- }
- var rcvStats map[string]*ltcache.CacheStats
- expStats := engine.GetDefaultEmptyCacheStats()
- if err := dispEngine.RPC.Call(context.Background(), utils.CacheSv1GetCacheStats, utils.AttrCacheIDsWithAPIOpts{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chc12345",
- },
- Tenant: "cgrates.org",
- }, &rcvStats); err != nil {
- t.Error("Got error on CacheSv1.GetCacheStats: ", err.Error())
- } else if !reflect.DeepEqual(expStats, rcvStats) {
- t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats))
- }
-}
diff --git a/dispatchers/caches_test.go b/dispatchers/caches_test.go
deleted file mode 100644
index d7cd8dd65..000000000
--- a/dispatchers/caches_test.go
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
- "time"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/utils"
- "github.com/cgrates/ltcache"
-)
-
-func TestDspCacheSv1PingError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- ID: "",
- Event: nil,
- APIOpts: nil,
- }
- var reply *string
- result := dspSrv.CacheSv1Ping(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1PingErrorArgs(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.CacheSv1Ping(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1PingErrorAttributeSConns(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- ID: "",
- Event: nil,
- APIOpts: nil,
- }
- var reply *string
- result := dspSrv.CacheSv1Ping(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1GetItemIDsError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.ArgsGetCacheItemIDsWithAPIOpts{}
- var reply *[]string
- result := dspSrv.CacheSv1GetItemIDs(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1GetItemIDsErrorArgsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.ArgsGetCacheItemIDsWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *[]string
- result := dspSrv.CacheSv1GetItemIDs(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1HasItemError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{}
- var reply *bool
- result := dspSrv.CacheSv1HasItem(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1HasItemErrorArgsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *bool
- result := dspSrv.CacheSv1HasItem(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1GetItemExpiryTimeCacheSv1GetItemExpiryTimeError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{}
- var reply *time.Time
- result := dspSrv.CacheSv1GetItemExpiryTime(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1GetItemExpiryTimeCacheSv1GetItemExpiryTimeErrorArgsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *time.Time
- result := dspSrv.CacheSv1GetItemExpiryTime(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1RemoveItemError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{}
- var reply *string
- result := dspSrv.CacheSv1RemoveItem(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1RemoveItemArgsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.CacheSv1RemoveItem(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1RemoveItemsError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.AttrReloadCacheWithAPIOpts{}
- var reply *string
- result := dspSrv.CacheSv1RemoveItems(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1RemoveItemsArgsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.AttrReloadCacheWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.CacheSv1RemoveItems(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1ClearError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.AttrCacheIDsWithAPIOpts{}
- var reply *string
- result := dspSrv.CacheSv1Clear(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1ClearArgsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.AttrCacheIDsWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.CacheSv1Clear(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1GetCacheStatsError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.AttrCacheIDsWithAPIOpts{}
- var reply *map[string]*ltcache.CacheStats
- result := dspSrv.CacheSv1GetCacheStats(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1GetCacheStatsArgsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.AttrCacheIDsWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *map[string]*ltcache.CacheStats
- result := dspSrv.CacheSv1GetCacheStats(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1PrecacheStatusError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.AttrCacheIDsWithAPIOpts{}
- var reply *map[string]string
- result := dspSrv.CacheSv1PrecacheStatus(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1PrecacheStatusArgsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.AttrCacheIDsWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *map[string]string
- result := dspSrv.CacheSv1PrecacheStatus(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1HasGroupError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.ArgsGetGroupWithAPIOpts{}
- var reply *bool
- result := dspSrv.CacheSv1HasGroup(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1HasGroupArgsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.ArgsGetGroupWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *bool
- result := dspSrv.CacheSv1HasGroup(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1GetGroupItemIDsError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.ArgsGetGroupWithAPIOpts{}
- var reply *[]string
- result := dspSrv.CacheSv1GetGroupItemIDs(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1GetGroupItemIDsArgsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.ArgsGetGroupWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *[]string
- result := dspSrv.CacheSv1GetGroupItemIDs(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1RemoveGroupError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.ArgsGetGroupWithAPIOpts{}
- var reply *string
- result := dspSrv.CacheSv1RemoveGroup(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1RemoveGroupArgsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.ArgsGetGroupWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.CacheSv1RemoveGroup(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1ReloadCacheError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.AttrReloadCacheWithAPIOpts{}
- var reply *string
- result := dspSrv.CacheSv1ReloadCache(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1ReloadCacheNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.AttrReloadCacheWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.CacheSv1ReloadCache(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1LoadCacheError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.AttrReloadCacheWithAPIOpts{}
- var reply *string
- result := dspSrv.CacheSv1LoadCache(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1LoadCacheNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.AttrReloadCacheWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.CacheSv1LoadCache(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1ReplicateRemoveError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.ArgCacheReplicateRemove{}
- var reply *string
- result := dspSrv.CacheSv1ReplicateRemove(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1ReplicateRemoveNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.ArgCacheReplicateRemove{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.CacheSv1ReplicateRemove(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1ReplicateSetError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.ArgCacheReplicateSet{}
- var reply *string
- result := dspSrv.CacheSv1ReplicateSet(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCacheSv1ReplicateSetNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.ArgCacheReplicateSet{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.CacheSv1ReplicateSet(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/dispatchers/cdrs.go b/dispatchers/cdrs.go
deleted file mode 100644
index 5336a38dc..000000000
--- a/dispatchers/cdrs.go
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) CDRsV1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCDRs, utils.CDRsV1Ping, args, reply)
-}
-func (dS *DispatcherService) CDRsV1ProcessEvent(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCDRs, utils.CDRsV1ProcessEvent, args, reply)
-}
-func (dS *DispatcherService) CDRsV1ProcessEventWithGet(ctx *context.Context, args *utils.CGREvent, reply *[]*utils.EventsWithOpts) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCDRs, utils.CDRsV1ProcessEventWithGet, args, reply)
-}
-func (dS *DispatcherService) CDRsV1ProcessStoredEvents(ctx *context.Context, args *utils.CDRFilters, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCDRs, utils.CDRsV1ProcessStoredEvents, args, reply)
-}
diff --git a/dispatchers/cdrs_test.go b/dispatchers/cdrs_test.go
deleted file mode 100644
index d8186f261..000000000
--- a/dispatchers/cdrs_test.go
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDspCDRsV1PingError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{}
- var reply *string
- result := dspSrv.CDRsV1Ping(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCDRsV1PingNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.CDRsV1Ping(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCDRsV1PingNilError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *string
- result := dspSrv.CDRsV1Ping(context.Background(), nil, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCDRsV1ProcessEventError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- ev := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.CDRsV1ProcessEvent(context.Background(), ev, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCDRsV1ProcessEventNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- ev := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.CDRsV1ProcessEvent(context.Background(), ev, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-/*
-func TestDspCDRsV2ProcessEventError(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- ev := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *[]*utils.EventWithFlags
- result := dspSrv.CDRsV2ProcessEvent(context.Background(), ev, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCDRsV2ProcessEventNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- ev := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *[]*utils.EventWithFlags
- result := dspSrv.CDRsV2ProcessEvent(context.Background(), ev, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspCDRsV2ProcessEventErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- ev := &utils.CGREvent{}
- var reply *[]*utils.EventWithFlags
- result := dspSrv.CDRsV2ProcessEvent(context.Background(), ev, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-*/
diff --git a/dispatchers/chargers.go b/dispatchers/chargers.go
deleted file mode 100644
index 7585de563..000000000
--- a/dispatchers/chargers.go
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) ChargerSv1GetChargersForEvent(ctx *context.Context, args *utils.CGREvent, reply *engine.ChargerProfiles) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaChargers, utils.ChargerSv1GetChargersForEvent, args, reply)
-}
-func (dS *DispatcherService) ChargerSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaChargers, utils.ChargerSv1Ping, args, reply)
-}
-func (dS *DispatcherService) ChargerSv1ProcessEvent(ctx *context.Context, args *utils.CGREvent, reply *[]*engine.ChrgSProcessEventReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaChargers, utils.ChargerSv1ProcessEvent, args, reply)
-}
diff --git a/dispatchers/chargers_it_test.go b/dispatchers/chargers_it_test.go
deleted file mode 100644
index 6c2030b18..000000000
--- a/dispatchers/chargers_it_test.go
+++ /dev/null
@@ -1,333 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "reflect"
- "sort"
- "strings"
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var sTestsDspCpp = []func(t *testing.T){
- testDspCppPingFailover,
- testDspCppGetChtgFailover,
- testDspCppGetChtgRoundRobin,
-
- testDspCppPing,
- testDspCppTestAuthKey,
- testDspCppTestAuthKey2,
-}
-
-// Test start here
-func TestDspChargerST(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- }
- testDsp(t, sTestsDspCpp, "TestDspChargerS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
-}
-
-func testDspCppPingFailover(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.ChargerSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- ev := utils.CGREvent{
- Tenant: "cgrates.org",
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chrg12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ChargerSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.ChargerSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine2.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.ChargerSv1Ping, &ev, &reply); err == nil {
- t.Errorf("Expected error but received %v and reply %v\n", err, reply)
- }
- allEngine.startEngine(t)
- allEngine2.startEngine(t)
-}
-
-func testDspCppGetChtgFailover(t *testing.T) {
- args := utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "event1",
- Event: map[string]any{
- utils.EventName: "Event1",
- utils.AccountField: "1001",
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chrg12345",
- },
- }
- eChargers := &engine.ChargerProfiles{
- &engine.ChargerProfile{
- Tenant: "cgrates.org",
- ID: "DEFAULT",
- FilterIDs: []string{},
- RunID: utils.MetaDefault,
- AttributeIDs: []string{"*none"},
- Weights: utils.DynamicWeights{
- {
- Weight: 0,
- },
- },
- },
- }
- if *utils.Encoding == utils.MetaGOB {
- (*eChargers)[0].FilterIDs = nil // empty slice are nil in gob
- }
- var reply *engine.ChargerProfiles
- if err := dispEngine.RPC.Call(context.Background(), utils.ChargerSv1GetChargersForEvent,
- args, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eChargers, reply) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eChargers), utils.ToJSON(reply))
- }
-
- allEngine2.stopEngine(t)
- *eChargers = append(*eChargers,
- &engine.ChargerProfile{
- Tenant: "cgrates.org",
- ID: "Raw",
- FilterIDs: []string{},
- RunID: utils.MetaRaw,
- AttributeIDs: []string{"*constant:*req.RequestType:*none"},
- Weights: utils.DynamicWeights{
- {
- Weight: 0,
- },
- },
- },
- )
- if *utils.Encoding == utils.MetaGOB {
- (*eChargers)[1].FilterIDs = nil // empty slice are nil in gob
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ChargerSv1GetChargersForEvent,
- args, &reply); err != nil {
- t.Fatal(err)
- }
- sort.Slice(*reply, func(i, j int) bool {
- return strings.Compare((*reply)[i].ID, (*reply)[j].ID) < 0
- })
- if !reflect.DeepEqual(eChargers, reply) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eChargers), utils.ToJSON(reply))
- }
-
- allEngine2.startEngine(t)
-}
-
-func testDspCppPing(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.ChargerSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ChargerSv1Ping, &utils.CGREvent{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chrg12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
-
-func testDspCppTestAuthKey(t *testing.T) {
- args := utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "event1",
- Event: map[string]any{
- utils.AccountField: "1001",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "12345",
- },
- }
- var reply *engine.ChargerProfiles
- if err := dispEngine.RPC.Call(context.Background(), utils.ChargerSv1GetChargersForEvent,
- args, &reply); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
- t.Error(err)
- }
-}
-
-func testDspCppTestAuthKey2(t *testing.T) {
- args := utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "event1",
- Event: map[string]any{
- utils.AccountField: "1001",
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chrg12345",
- },
- }
- eChargers := &engine.ChargerProfiles{
- &engine.ChargerProfile{
- Tenant: "cgrates.org",
- ID: "DEFAULT",
- FilterIDs: []string{},
- RunID: utils.MetaDefault,
- AttributeIDs: []string{"*none"},
- Weights: utils.DynamicWeights{
- {
- Weight: 0,
- },
- },
- },
- &engine.ChargerProfile{
- Tenant: "cgrates.org",
- ID: "Raw",
- FilterIDs: []string{},
- RunID: utils.MetaRaw,
- AttributeIDs: []string{"*constant:*req.RequestType:*none"},
- Weights: utils.DynamicWeights{
- {
- Weight: 0,
- },
- },
- },
- }
- if *utils.Encoding == utils.MetaGOB {
- (*eChargers)[0].FilterIDs = nil // empty slice are nil in gob
- (*eChargers)[1].FilterIDs = nil // empty slice are nil in gob
- }
- var reply *engine.ChargerProfiles
- if err := dispEngine.RPC.Call(context.Background(), utils.ChargerSv1GetChargersForEvent,
- args, &reply); err != nil {
- t.Fatal(err)
- }
- sort.Slice(*reply, func(i, j int) bool {
- return strings.Compare((*reply)[i].ID, (*reply)[j].ID) < 0
- })
- if !reflect.DeepEqual(eChargers, reply) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eChargers), utils.ToJSON(reply))
- }
-}
-
-func testDspCppGetChtgRoundRobin(t *testing.T) {
- args := utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "event1",
- Event: map[string]any{
- utils.EventName: "RoundRobin",
- utils.AccountField: "1001",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "chrg12345",
- },
- }
- eChargers := &engine.ChargerProfiles{
- &engine.ChargerProfile{
- Tenant: "cgrates.org",
- ID: "DEFAULT",
- FilterIDs: []string{},
- RunID: utils.MetaDefault,
- AttributeIDs: []string{"*none"},
- Weights: utils.DynamicWeights{
- {
- Weight: 0,
- },
- },
- },
- }
- if *utils.Encoding == utils.MetaGOB {
- (*eChargers)[0].FilterIDs = nil // empty slice are nil in gob
- }
- var reply *engine.ChargerProfiles
- // To ALL2
- if err := dispEngine.RPC.Call(context.Background(), utils.ChargerSv1GetChargersForEvent,
- args, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eChargers, reply) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eChargers), utils.ToJSON(reply))
- }
- // To ALL
- *eChargers = append(*eChargers,
- &engine.ChargerProfile{
- Tenant: "cgrates.org",
- ID: "Raw",
- FilterIDs: []string{},
- RunID: utils.MetaRaw,
- AttributeIDs: []string{"*constant:*req.RequestType:*none"},
- Weights: utils.DynamicWeights{
- {
- Weight: 0,
- },
- },
- },
- )
- if *utils.Encoding == utils.MetaGOB {
- (*eChargers)[1].FilterIDs = nil // empty slice are nil in gob
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ChargerSv1GetChargersForEvent,
- args, &reply); err != nil {
- t.Fatal(err)
- }
- sort.Slice(*reply, func(i, j int) bool {
- return strings.Compare((*reply)[i].ID, (*reply)[j].ID) < 0
- })
- if !reflect.DeepEqual(eChargers, reply) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eChargers), utils.ToJSON(reply))
- }
-
-}
diff --git a/dispatchers/chargers_test.go b/dispatchers/chargers_test.go
deleted file mode 100644
index a554adadc..000000000
--- a/dispatchers/chargers_test.go
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDspChargerSv1PingNilStruct(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ChargerSv1Ping(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspChargerSv1PingNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ChargerSv1Ping(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspChargerSv1PingErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{}
- var reply *string
- result := dspSrv.ChargerSv1Ping(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspChargerSv1GetChargersForEventNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *engine.ChargerProfiles
- result := dspSrv.ChargerSv1GetChargersForEvent(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspChargerSv1GetChargersForEventErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{}
- var reply *engine.ChargerProfiles
- result := dspSrv.ChargerSv1GetChargersForEvent(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspChargerSv1ProcessEventNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *[]*engine.ChrgSProcessEventReply
- result := dspSrv.ChargerSv1ProcessEvent(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspChargerSv1ProcessEventErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{}
- var reply *[]*engine.ChrgSProcessEventReply
- result := dspSrv.ChargerSv1ProcessEvent(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/dispatchers/config.go b/dispatchers/config.go
deleted file mode 100644
index 33835f9d2..000000000
--- a/dispatchers/config.go
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) ConfigSv1GetConfig(ctx *context.Context, args *config.SectionWithAPIOpts, reply *map[string]any) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaConfig, utils.ConfigSv1GetConfig, args, reply)
-}
-func (dS *DispatcherService) ConfigSv1GetConfigAsJSON(ctx *context.Context, args *config.SectionWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaConfig, utils.ConfigSv1GetConfigAsJSON, args, reply)
-}
-func (dS *DispatcherService) ConfigSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaConfig, utils.ConfigSv1Ping, args, reply)
-}
-func (dS *DispatcherService) ConfigSv1ReloadConfig(ctx *context.Context, args *config.ReloadArgs, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaConfig, utils.ConfigSv1ReloadConfig, args, reply)
-}
-func (dS *DispatcherService) ConfigSv1SetConfig(ctx *context.Context, args *config.SetConfigArgs, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaConfig, utils.ConfigSv1SetConfig, args, reply)
-}
-func (dS *DispatcherService) ConfigSv1SetConfigFromJSON(ctx *context.Context, args *config.SetConfigFromJSONArgs, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaConfig, utils.ConfigSv1SetConfigFromJSON, args, reply)
-}
-func (dS *DispatcherService) ConfigSv1StoreCfgInDB(ctx *context.Context, args *config.SectionWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaConfig, utils.ConfigSv1StoreCfgInDB, args, reply)
-}
diff --git a/dispatchers/config_it_test.go b/dispatchers/config_it_test.go
deleted file mode 100644
index 4aa9e45ff..000000000
--- a/dispatchers/config_it_test.go
+++ /dev/null
@@ -1,88 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "reflect"
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/utils"
-)
-
-var sTestsDspConfig = []func(t *testing.T){
- testDspConfigSv1GetJSONSection,
-}
-
-// Test start here
-func TestDspConfigIT(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- }
- testDsp(t, sTestsDspConfig, "TestDspConfigIT", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
-}
-
-func testDspConfigSv1GetJSONSection(t *testing.T) {
- expected := map[string]any{
- "http": ":6080",
- "http_tls": "127.0.0.1:2280",
- "rpc_gob": ":6013",
- "rpc_gob_tls": "127.0.0.1:2023",
- "rpc_json": ":6012",
- "rpc_json_tls": "127.0.0.1:2022",
- }
- expected = map[string]any{
- "listen": expected,
- }
- var reply map[string]any
- if err := dispEngine.RPC.Call(context.Background(), utils.ConfigSv1GetConfig, &config.SectionWithAPIOpts{
- Tenant: "cgrates.org",
- Sections: []string{"listen"},
- APIOpts: map[string]any{
- utils.OptsAPIKey: "cfg12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, reply) {
- t.Errorf("Expected: %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(reply))
- }
-}
diff --git a/dispatchers/config_test.go b/dispatchers/config_test.go
deleted file mode 100644
index ccb8b424e..000000000
--- a/dispatchers/config_test.go
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
-)
-
-func TestDspConfigSv1GetConfigNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &config.SectionWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *map[string]any
- result := dspSrv.ConfigSv1GetConfig(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspConfigSv1GetConfigErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &config.SectionWithAPIOpts{}
- var reply *map[string]any
- result := dspSrv.ConfigSv1GetConfig(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspConfigSv1ReloadConfigNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &config.ReloadArgs{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ConfigSv1ReloadConfig(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspConfigSv1ReloadConfigErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &config.ReloadArgs{}
- var reply *string
- result := dspSrv.ConfigSv1ReloadConfig(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspConfigSv1SetConfigNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &config.SetConfigArgs{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ConfigSv1SetConfig(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspConfigSv1SetConfigErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &config.SetConfigArgs{}
- var reply *string
- result := dspSrv.ConfigSv1SetConfig(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspConfigSv1SetConfigFromJSONNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &config.SetConfigFromJSONArgs{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ConfigSv1SetConfigFromJSON(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspConfigSv1SetConfigFromJSONErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &config.SetConfigFromJSONArgs{}
- var reply *string
- result := dspSrv.ConfigSv1SetConfigFromJSON(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspConfigSv1GetConfigAsJSONNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &config.SectionWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ConfigSv1GetConfigAsJSON(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspConfigSv1GetConfigAsJSONErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &config.SectionWithAPIOpts{}
- var reply *string
- result := dspSrv.ConfigSv1GetConfigAsJSON(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/dispatchers/cores.go b/dispatchers/cores.go
deleted file mode 100644
index 8d9b039be..000000000
--- a/dispatchers/cores.go
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/cores"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) CoreSv1Panic(ctx *context.Context, args *utils.PanicMessageArgs, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCore, utils.CoreSv1Panic, args, reply)
-}
-func (dS *DispatcherService) CoreSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCore, utils.CoreSv1Ping, args, reply)
-}
-func (dS *DispatcherService) CoreSv1Shutdown(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCore, utils.CoreSv1Shutdown, args, reply)
-}
-func (dS *DispatcherService) CoreSv1Sleep(ctx *context.Context, args *utils.DurationArgs, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCore, utils.CoreSv1Sleep, args, reply)
-}
-func (dS *DispatcherService) CoreSv1StartCPUProfiling(ctx *context.Context, args *utils.DirectoryArgs, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCore, utils.CoreSv1StartCPUProfiling, args, reply)
-}
-func (dS *DispatcherService) CoreSv1StartMemoryProfiling(ctx *context.Context, args cores.MemoryProfilingParams, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := args.APIOpts
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCore, utils.CoreSv1StartMemoryProfiling, args, reply)
-}
-func (dS *DispatcherService) CoreSv1Status(ctx *context.Context, args *cores.V1StatusParams, reply *map[string]any) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCore, utils.CoreSv1Status, args, reply)
-}
-func (dS *DispatcherService) CoreSv1StopCPUProfiling(ctx *context.Context, args *utils.TenantWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCore, utils.CoreSv1StopCPUProfiling, args, reply)
-}
-func (dS *DispatcherService) CoreSv1StopMemoryProfiling(ctx *context.Context, args utils.TenantWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := args.APIOpts
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCore, utils.CoreSv1StopMemoryProfiling, args, reply)
-}
diff --git a/dispatchers/dispatchers.go b/dispatchers/dispatchers.go
deleted file mode 100644
index 9dd82abf2..000000000
--- a/dispatchers/dispatchers.go
+++ /dev/null
@@ -1,355 +0,0 @@
-//go:generate go run ../data/scripts/generate_dispatchers/generator.go
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "fmt"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/guardian"
- "github.com/cgrates/cgrates/utils"
- "github.com/cgrates/rpcclient"
-)
-
-// NewDispatcherService constructs a DispatcherService
-func NewDispatcherService(dm *engine.DataManager,
- cfg *config.CGRConfig, fltrS *engine.FilterS,
- connMgr *engine.ConnManager) *DispatcherService {
- return &DispatcherService{
- dm: dm,
- cfg: cfg,
- fltrS: fltrS,
- connMgr: connMgr,
- }
-}
-
-// DispatcherService is the service handling dispatching towards internal components
-// designed to handle automatic partitioning and failover
-type DispatcherService struct {
- dm *engine.DataManager
- cfg *config.CGRConfig
- fltrS *engine.FilterS
- connMgr *engine.ConnManager
-}
-
-func (dS *DispatcherService) authorizeEvent(ctx *context.Context, ev *utils.CGREvent,
- reply *engine.AttrSProcessEventReply) (err error) {
- if err = dS.connMgr.Call(ctx, dS.cfg.DispatcherSCfg().AttributeSConns,
- utils.AttributeSv1ProcessEvent, ev, reply); err != nil {
- if err.Error() == utils.ErrNotFound.Error() {
- err = utils.ErrUnknownApiKey
- }
- return
- }
- return
-}
-
-func (dS *DispatcherService) authorize(ctx *context.Context, method, tenant string, apiKey string) (err error) {
- if apiKey == "" {
- return utils.NewErrMandatoryIeMissing(utils.APIKey)
- }
- ev := &utils.CGREvent{
- Tenant: tenant,
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- utils.APIKey: apiKey,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaDispatchers,
- utils.OptsContext: utils.MetaAuth,
- },
- }
- var rplyEv engine.AttrSProcessEventReply
- if err = dS.authorizeEvent(ctx, ev, &rplyEv); err != nil {
- return
- }
- var apiMethods string
- if apiMethods, err = rplyEv.CGREvent.FieldAsString(utils.APIMethods); err != nil {
- return
- }
- if !ParseStringSet(apiMethods).Has(method) {
- return utils.ErrUnauthorizedApi
- }
- return
-}
-
-// dispatcherForEvent returns a dispatcher instance configured for specific event
-// or utils.ErrNotFound if none present
-func (dS *DispatcherService) dispatcherProfilesForEvent(ctx *context.Context, tnt string, ev *utils.CGREvent,
- evNm utils.MapStorage) (dPrlfs engine.DispatcherProfiles, err error) {
- // make sure dispatching is allowed
- var shouldDispatch bool
- if shouldDispatch, err = engine.GetBoolOpts(ctx, tnt, evNm, dS.fltrS, dS.cfg.DispatcherSCfg().Opts.Dispatchers,
- config.DispatchersDispatchersDftOpt, utils.MetaDispatchers); err != nil {
- return
- } else if !shouldDispatch {
- return engine.DispatcherProfiles{
- &engine.DispatcherProfile{Tenant: utils.MetaInternal, ID: utils.MetaInternal}}, nil
- }
- // find out the matching profiles
- var prflIDs utils.StringSet
- if prflIDs, err = engine.MatchingItemIDsForEvent(ctx, evNm,
- dS.cfg.DispatcherSCfg().StringIndexedFields,
- dS.cfg.DispatcherSCfg().PrefixIndexedFields,
- dS.cfg.DispatcherSCfg().SuffixIndexedFields,
- dS.cfg.DispatcherSCfg().ExistsIndexedFields,
- dS.cfg.DispatcherSCfg().NotExistsIndexedFields,
- dS.dm, utils.CacheDispatcherFilterIndexes, tnt,
- dS.cfg.DispatcherSCfg().IndexedSelects,
- dS.cfg.DispatcherSCfg().NestedFields,
- ); err != nil {
- return
- }
- for prflID := range prflIDs {
- prfl, err := dS.dm.GetDispatcherProfile(ctx, tnt, prflID, true, true, utils.NonTransactional)
- if err != nil {
- if err != utils.ErrDSPProfileNotFound {
- return nil, err
- }
- continue
- }
-
- if pass, err := dS.fltrS.Pass(ctx, tnt, prfl.FilterIDs,
- evNm); err != nil {
- return nil, err
- } else if !pass {
- continue
- }
- dPrlfs = append(dPrlfs, prfl)
- }
- if len(dPrlfs) == 0 {
- err = utils.ErrDSPProfileNotFound
- return
- }
- prfCount := len(dPrlfs) // if the option is not present return for all profiles
- if prfCountOpt, err := ev.OptAsInt64(utils.OptsDispatchersProfilesCount); err != nil {
- if err != utils.ErrNotFound { // is an conversion error
- return nil, err
- }
- } else if prfCount > int(prfCountOpt) { // it has the option and is smaller that the current number of profiles
- prfCount = int(prfCountOpt)
- }
- dPrlfs.Sort()
- dPrlfs = dPrlfs[:prfCount]
- return
-}
-
-// Dispatch is the method forwarding the request towards the right connection
-func (dS *DispatcherService) Dispatch(ctx *context.Context, ev *utils.CGREvent, subsys string,
- serviceMethod string, args, reply any) (err error) {
- tnt := ev.Tenant
- if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
- if err = dS.authorize(ctx, serviceMethod, tnt, utils.IfaceAsString(ev.APIOpts[utils.OptsAPIKey])); err != nil {
- return
- }
- }
- evNm := utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- utils.MetaMethod: serviceMethod,
- },
- }
- dspLoopAPIOpts := map[string]any{
- utils.MetaSubsys: utils.MetaDispatchers,
- utils.MetaNodeID: dS.cfg.GeneralCfg().NodeID,
- }
- // avoid further processing if the request is internal
- var shouldDispatch bool
- if shouldDispatch, err = engine.GetBoolOpts(ctx, tnt, evNm, dS.fltrS, dS.cfg.DispatcherSCfg().Opts.Dispatchers,
- true, utils.MetaDispatchers); err != nil {
- return utils.NewErrDispatcherS(err)
- } else if !shouldDispatch {
- return callDH(ctx,
- newInternalHost(tnt), utils.EmptyString, nil,
- dS.cfg, dS.connMgr.GetDispInternalChan(),
- serviceMethod, args, reply)
- }
-
- // in case of routeID, route based on previously discovered profile
- var dR *DispatcherRoute
- var dPrfls engine.DispatcherProfiles
- routeID := utils.IfaceAsString(ev.APIOpts[utils.OptsRouteID])
- if routeID != utils.EmptyString { // overwrite routeID with RouteID:Subsystem for subsystem correct routing
- routeID = utils.ConcatenatedKey(routeID, subsys)
- guardID := utils.ConcatenatedKey(utils.DispatcherSv1, utils.OptsRouteID, routeID)
- refID := guardian.Guardian.GuardIDs("",
- dS.cfg.GeneralCfg().LockingTimeout, guardID) // lock the routeID so we can make sure we have time to execute only once before caching
- defer guardian.Guardian.UnguardIDs(refID)
- // use previously discovered route
- argsCache := &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: ev.Tenant,
- APIOpts: dspLoopAPIOpts,
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatcherRoutes,
- ItemID: routeID,
- }}
- var itmRemote any
- if itmRemote, err = engine.Cache.GetWithRemote(ctx, argsCache); err == nil && itmRemote != nil {
- var canCast bool
- if dR, canCast = itmRemote.(*DispatcherRoute); !canCast {
- err = utils.ErrCastFailed
- } else {
- var d Dispatcher
- if d, err = getDispatcherWithCache(ctx,
- &engine.DispatcherProfile{Tenant: dR.Tenant, ID: dR.ProfileID},
- dS.dm); err == nil {
- for k, v := range dspLoopAPIOpts {
- ev.APIOpts[k] = v // dispatcher loop protection opts
- }
- if err = d.Dispatch(dS.dm, dS.fltrS, dS.cfg,
- ctx, dS.connMgr.GetDispInternalChan(), evNm, tnt, utils.EmptyString, dR,
- serviceMethod, args, reply); !rpcclient.ShouldFailover(err) {
- return // dispatch success or specific error coming from upstream
- }
- }
- }
- }
- if err != nil {
- // did not dispatch properly, fail-back to standard dispatching
- utils.Logger.Warning(fmt.Sprintf("<%s> error <%s> using cached routing for dR %+v, continuing with normal dispatching",
- utils.DispatcherS, err.Error(), dR))
- }
- }
- if dPrfls, err = dS.dispatcherProfilesForEvent(ctx, tnt, ev, evNm); err != nil {
- return utils.NewErrDispatcherS(err)
- } else if len(dPrfls) == 0 { // no profiles matched
- return utils.ErrDSPProfileNotFound
- } else if isInternalDispatcherProfile(dPrfls[0]) { // dispatcherS was disabled
- return callDH(ctx,
- newInternalHost(tnt), utils.EmptyString, nil,
- dS.cfg, dS.connMgr.GetDispInternalChan(),
- serviceMethod, args, reply)
- }
- if ev.APIOpts == nil {
- ev.APIOpts = make(map[string]any)
- }
- ev.APIOpts[utils.MetaSubsys] = utils.MetaDispatchers // inject into args
- ev.APIOpts[utils.MetaNodeID] = dS.cfg.GeneralCfg().NodeID
- for _, dPrfl := range dPrfls {
- // get or build the Dispatcher for the config
- var d Dispatcher
- if d, err = getDispatcherWithCache(ctx, dPrfl, dS.dm); err == nil {
- if err = d.Dispatch(dS.dm, dS.fltrS, dS.cfg,
- ctx, dS.connMgr.GetDispInternalChan(), evNm, tnt, routeID,
- &DispatcherRoute{
- Tenant: dPrfl.Tenant,
- ProfileID: dPrfl.ID,
- },
- serviceMethod, args, reply); !rpcclient.ShouldFailover(err) {
- return
- }
- }
- utils.Logger.Warning(fmt.Sprintf("<%s> error <%s> dispatching with the profile: <%+v>",
- utils.DispatcherS, err.Error(), dPrfl))
- }
- return // return the last error
-}
-
-func (dS *DispatcherService) V1GetProfilesForEvent(ctx *context.Context, ev *utils.CGREvent,
- dPfl *engine.DispatcherProfiles) (err error) {
- tnt := ev.Tenant
- if tnt == utils.EmptyString {
- tnt = dS.cfg.GeneralCfg().DefaultTenant
- }
- retDPfl, errDpfl := dS.dispatcherProfilesForEvent(ctx, tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: ev.APIOpts[utils.MetaSubsys],
- utils.MetaMethod: ev.APIOpts[utils.MetaMethod],
- },
- })
- if errDpfl != nil {
- return utils.NewErrDispatcherS(errDpfl)
- }
- *dPfl = retDPfl
- return
-}
-
-func (dS *DispatcherService) ping(ctx *context.Context, subsys, method string, args *utils.CGREvent,
- reply *string) (err error) {
- if args == nil {
- args = new(utils.CGREvent)
- }
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args.Tenant != utils.EmptyString {
- tnt = args.Tenant
- }
- if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
- if err = dS.authorize(ctx, method, tnt,
- utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey])); err != nil {
- return
- }
- }
- return dS.Dispatch(ctx, args, subsys, method, args, reply)
-}
-
-func (dS *DispatcherService) DispatcherSv1RemoteStatus(ctx *context.Context, args *utils.TenantWithAPIOpts,
- reply *map[string]any) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args.Tenant != utils.EmptyString {
- tnt = args.Tenant
- }
- if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
- if err = dS.authorize(ctx, utils.CoreSv1Status, tnt,
- utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey])); err != nil {
- return
- }
- }
- return dS.Dispatch(ctx, &utils.CGREvent{
- Tenant: tnt,
- APIOpts: args.APIOpts,
- }, utils.MetaCore, utils.CoreSv1Status, args, reply)
-}
-
-func (dS *DispatcherService) DispatcherSv1RemoteSleep(ctx *context.Context, args *utils.DurationArgs, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args.Tenant != utils.EmptyString {
- tnt = args.Tenant
- }
- if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
- if err = dS.authorize(ctx, utils.CoreSv1Sleep, tnt,
- utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey])); err != nil {
- return
- }
- }
- return dS.Dispatch(ctx, &utils.CGREvent{
- Tenant: tnt,
- APIOpts: args.APIOpts,
- }, utils.MetaCore, utils.CoreSv1Sleep, args, reply)
-}
-
-func (dS *DispatcherService) DispatcherSv1RemotePing(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && args.Tenant != utils.EmptyString {
- tnt = args.Tenant
- }
- if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
- if err = dS.authorize(ctx, utils.CoreSv1Ping, tnt,
- utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey])); err != nil {
- return
- }
- }
- return dS.Dispatch(ctx, args, utils.MetaCore, utils.CoreSv1Ping, args, reply)
-}
diff --git a/dispatchers/dispatchers_it_test.go b/dispatchers/dispatchers_it_test.go
deleted file mode 100644
index db1eb5f0d..000000000
--- a/dispatchers/dispatchers_it_test.go
+++ /dev/null
@@ -1,189 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-// for the moment we dispable Apier through dispatcher
-// until we figured out a better sollution in case of gob server
-/*
-import (
- "reflect"
- "testing"
- "time"
-
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var sTestsDspApier = []func(t *testing.T){
- testDspApierSetAttributes,
- testDspApierGetAttributes,
- testDspApierUnkownAPiKey,
-}
-
-//Test start here
-func TestDspApierITMySQL(t *testing.T) {
- testDsp(t, sTestsDspApier, "TestDspApier", "all", "all2", "dispatchers_mysql", "tutorial", "oldtutorial", "dispatchers")
-}
-
-func TestDspApierITMongo(t *testing.T) {
- testDsp(t, sTestsDspApier, "TestDspApier", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers")
-}
-
-//because we import dispatchers in APIerSv1 we will send information as map[string]any
-func testDspApierSetAttributes(t *testing.T) {
- ev := &map[string]any{
- utils.Tenant: "cgrates.org",
- "ID": "ATTR_Dispatcher",
- "Contexts": []string{utils.MetaSessionS},
- "FilterIDs": []string{"*string:~Account:1234"},
- "ActivationInterval": &utils.ActivationInterval{
- ActivationTimes: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
- ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
- },
- "Attributes": []*engine.Attribute{
- {
- Path: utils.MetaReq + utils.NestingSep + utils.Subject,
- Value: config.RSRParsers{
- &config.RSRParser{
- Rules: "roam",
- },
- },
- },
- },
- "Weight": 10,
- utils.APIKey: utils.StringPointer("apier12345"),
- }
- var result string
- if err := dispEngine.RPC.Call(utils.APIerSv1SetAttributeProfile, ev, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-
-}
-
-func testDspApierGetAttributes(t *testing.T) {
- var reply *engine.AttributeProfile
- alsPrf := &engine.AttributeProfile{
- Tenant: "cgrates.org",
- ID: "ATTR_Dispatcher",
- Contexts: []string{utils.MetaSessionS},
- FilterIDs: []string{"*string:~*req.Account:1234"},
- ActivationInterval: &utils.ActivationInterval{
- ActivationTimes: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
- ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
- },
- Attributes: []*engine.Attribute{
- {
- Path: utils.MetaReq + utils.NestingSep + utils.Subject,
- Value: config.RSRParsers{
- &config.RSRParser{
- Rules: "roam",
- },
- },
- },
- },
- Weight: 10,
- }
- alsPrf.Compile()
- if err := dispEngine.RPC.Call(utils.APIerSv1GetAttributeProfile,
- utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_Dispatcher"},
- ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("apier12345")},
- }, &reply); err != nil {
- t.Fatal(err)
- }
- reply.Compile()
- if !reflect.DeepEqual(alsPrf, reply) {
- t.Errorf("Expecting : %+v, received: %+v", alsPrf, reply)
- }
-
-}
-
-func testDspApierUnkownAPiKey(t *testing.T) {
- var reply *engine.AttributeProfile
- if err := dispEngine.RPC.Call(utils.APIerSv1GetAttributeProfile,
- utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_Dispatcher"},
- ArgDispatcher: &utils.ArgDispatcher{APIKey: utils.StringPointer("RandomApiKey")},
- }, &reply); err == nil || err.Error() != utils.ErrUnknownApiKey.Error() {
- t.Fatal(err)
- }
-}
-func TestDispatcherServiceDispatcherProfileForEventGetDispatchertWithoutAuthentification(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = false
- rpcCl := map[string]chan rpcclient.ClientConnector{}
- connMng := engine.NewConnManager(cfg, rpcCl)
- dm := engine.NewDataManager(&engine.DataDBMock{
- GetKeysForPrefixF: func(string) ([]string, error) {
- return []string{"dpp_cgrates.org:123"}, nil
- },
- }, nil, connMng)
- dsp := &engine.DispatcherProfile{
- ID: "321",
- Subsystems: []string{utils.MetaAccounts},
- FilterIDs: []string{"filter"},
- ActivationInterval: &utils.ActivationInterval{},
- Strategy: "",
- StrategyParams: nil,
- Weight: 0,
- Hosts: nil,
- }
- err := dm.SetDispatcherProfile(dsp, false)
- if err == nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.ErrNotImplemented, err)
- }
- fltr := &engine.Filter{
- ID: "filter",
- Rules: nil,
- ActivationInterval: &utils.ActivationInterval{
- ActivationTime: time.Date(1999, 2, 3, 4, 5, 6, 700000000, time.UTC),
- ExpiryTime: time.Date(2000, 2, 3, 4, 5, 6, 700000000, time.UTC),
- },
- }
- err = dm.SetFilter(fltr, false)
- if err == nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.ErrNotImplemented, err)
- }
- fltrs := engine.NewFilterS(cfg, connMng, dm)
- dss := NewDispatcherService(dm, cfg, fltrs, connMng)
- ev := &utils.CGREvent{
- ID: "321",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- }
- tnt := ev.Tenant
- _, err = dss.dispatcherProfilesForEvent(tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- }, utils.MetaAccounts)
- expected := utils.ErrNotImplemented
- if err == nil || err != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-*/
diff --git a/dispatchers/dispatchers_test.go b/dispatchers/dispatchers_test.go
deleted file mode 100644
index 2bb85f88e..000000000
--- a/dispatchers/dispatchers_test.go
+++ /dev/null
@@ -1,1420 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "reflect"
- "testing"
-
- "github.com/cgrates/birpc"
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
-
- "github.com/cgrates/cgrates/utils"
- "github.com/cgrates/rpcclient"
-)
-
-func TestDispatcherServiceDispatcherProfileForEventGetDispatcherProfileNF(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = false
- connMng := engine.NewConnManager(cfg)
- dm := engine.NewDataManager(&engine.DataDBMock{
- GetKeysForPrefixF: func(*context.Context, string) ([]string, error) {
- return []string{"dpp_cgrates.org:123"}, nil
- },
- }, nil, connMng)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "321",
- FilterIDs: []string{"filter", "*string:~*vars.*subsys:" + utils.MetaAccounts},
- Strategy: "",
- StrategyParams: nil,
- Weight: 0,
- Hosts: nil,
- }
- err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
- if err == nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.ErrNotImplemented, err)
- }
- fltr := &engine.Filter{
- Tenant: "cgrates.org",
- ID: "filter",
- Rules: nil,
- }
- err = dm.SetFilter(context.Background(), fltr, false)
- if err == nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.ErrNotImplemented, err)
- }
- fltrs := engine.NewFilterS(cfg, connMng, dm)
- dss := NewDispatcherService(dm, cfg, fltrs, connMng)
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "321",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaAccounts,
- },
- }
- tnt := ev.Tenant
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- _, err = dss.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- })
- expected := utils.ErrNotImplemented
- if err == nil || err != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDispatcherServiceDispatcherProfileForEventMIIDENotFound(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = false
- connMng := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMng)
- dss := NewDispatcherService(dm, cfg, engine.NewFilterS(cfg, connMng, dm), connMng)
- ev := &utils.CGREvent{}
- tnt := ""
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- _, err := dss.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- })
- if err == nil || err != utils.ErrNotFound {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.ErrNotFound, err)
- }
-}
-
-func (dS *DispatcherService) DispatcherServicePing(ev *utils.CGREvent, reply *string) error {
- *reply = utils.Pong
- return nil
-}
-
-func TestDispatcherauthorizeEvent(t *testing.T) {
- dm := &engine.DataManager{}
- cfg := config.NewDefaultCGRConfig()
- fltr := &engine.FilterS{}
- connMgr := &engine.ConnManager{}
- dsp := NewDispatcherService(dm, cfg, fltr, connMgr)
- ev := &utils.CGREvent{}
- reply := &engine.AttrSProcessEventReply{}
- err := dsp.authorizeEvent(context.Background(), ev, reply)
- expected := "MANDATORY_IE_MISSING: [connIDs]"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDispatcherAuthorizeEventErr(t *testing.T) {
- dm := &engine.DataManager{}
- cfg := config.NewDefaultCGRConfig()
- fltr := &engine.FilterS{}
- connMgr := &engine.ConnManager{}
- dsp := NewDispatcherService(dm, cfg, fltr, connMgr)
- ev := &utils.CGREvent{}
- reply := &engine.AttrSProcessEventReply{}
- err := dsp.authorizeEvent(context.Background(), ev, reply)
- expected := "MANDATORY_IE_MISSING: [connIDs]"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDispatcherV1GetProfileForEventErr(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultTenant = utils.EmptyString
- dsp := NewDispatcherService(nil, cfg, nil, nil)
- ev := &utils.CGREvent{}
- dPfl := &engine.DispatcherProfiles{}
- err := dsp.V1GetProfilesForEvent(context.Background(), ev, dPfl)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDispatcherV1GetProfileForEvent(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultTenant = utils.EmptyString
- dsp := NewDispatcherService(nil, cfg, nil, nil)
- ev := &utils.CGREvent{}
- dPfl := &engine.DispatcherProfiles{}
- err := dsp.V1GetProfilesForEvent(context.Background(), ev, dPfl)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDispatcherDispatch(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.GeneralCfg().DefaultTenant = utils.EmptyString
- dsp := NewDispatcherService(nil, cfg, nil, nil)
- ev := &utils.CGREvent{}
- err := dsp.Dispatch(context.TODO(), ev, "", "", "", "")
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDispatcherAuthorizeError(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().AttributeSConns = []string{"connID"}
- cfg.RPCConns()["connID"] = &config.RPCConn{
- Strategy: rpcclient.PoolFirst,
- PoolSize: 0,
- Conns: []*config.RemoteHost{
- {
- ID: "",
- Address: "error",
- Transport: "",
- TLS: false,
- },
- },
- }
- connMng := engine.NewConnManager(cfg)
- dsp := NewDispatcherService(nil, cfg, nil, connMng)
- err := dsp.authorize(context.Background(), "", "cgrates.org", utils.APIMethods)
- expected := "dial tcp: address error: missing port in address"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDispatcherAuthorizeError2(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().AttributeSConns = []string{utils.APIMethods}
- cfg.RPCConns()[utils.APIMethods] = &config.RPCConn{
- Strategy: rpcclient.PoolFirst,
- PoolSize: 0,
- Conns: []*config.RemoteHost{
- {
- ID: "",
- Address: "error",
- Transport: "",
- TLS: false,
- },
- },
- }
- connMng := engine.NewConnManager(cfg)
- dsp := NewDispatcherService(nil, cfg, nil, connMng)
- err := dsp.authorize(context.Background(), "", "cgrates.org", utils.APIMethods)
- expected := "dial tcp: address error: missing port in address"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDispatcherServiceAuthorizeEvenError1(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- dm := engine.NewDataManager(nil, nil, nil)
- connMgr := engine.NewConnManager(cfg)
- newCache := engine.NewCacheS(cfg, dm, connMgr, nil)
- engine.Cache = newCache
- fltr := &engine.FilterS{}
- dsp := NewDispatcherService(dm, cfg, fltr, connMgr)
- cfg.DispatcherSCfg().AttributeSConns = []string{"connID"}
- ev := &utils.CGREvent{}
- reply := &engine.AttrSProcessEventReply{}
- engine.Cache.SetWithoutReplicate(utils.CacheRPCConnections, "connID",
- nil, nil, true, utils.NonTransactional)
- err := dsp.authorizeEvent(context.Background(), ev, reply)
- expected := "UNKNOWN_API_KEY"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
- engine.Cache = cacheInit
-}
-
-func TestDispatcherServiceAuthorizeEventError2(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- dm := engine.NewDataManager(nil, nil, nil)
- connMgr := engine.NewConnManager(cfg)
- newCache := engine.NewCacheS(cfg, dm, connMgr, nil)
- engine.Cache = newCache
- fltr := &engine.FilterS{}
- dsp := NewDispatcherService(dm, cfg, fltr, connMgr)
- cfg.DispatcherSCfg().AttributeSConns = []string{"connID"}
- ev := &utils.CGREvent{}
- reply := &engine.AttrSProcessEventReply{}
- dh := &engine.DispatcherHost{
- Tenant: "testTenant",
- RemoteHost: &config.RemoteHost{
- ID: "testID",
- Address: "",
- Transport: "",
- TLS: false,
- },
- }
- value := &lazyDH{dh: dh, cfg: cfg, iPRCCh: nil}
- engine.Cache.SetWithoutReplicate(utils.CacheRPCConnections, "connID",
- value, nil, true, utils.NonTransactional)
-
- expected := "dial tcp: missing address"
- if err := dsp.authorizeEvent(context.Background(), ev, reply); err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
- engine.Cache = cacheInit
-}
-
-type mockTypeCon2 struct{}
-
-func (*mockTypeCon2) Call(ctx *context.Context, serviceMethod string, args, reply any) error {
- return nil
-}
-
-func TestDispatcherServiceAuthorizeEventError3(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().AttributeSConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes)}
- dm := engine.NewDataManager(nil, nil, nil)
- chanRPC := make(chan birpc.ClientConnector, 1)
- chanRPC <- new(mockTypeCon2)
- connMgr := engine.NewConnManager(cfg)
- connMgr.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes), utils.AttributeSv1, chanRPC)
-
- dsp := NewDispatcherService(dm, cfg, nil, connMgr)
- ev := &utils.CGREvent{
- Tenant: "testTenant",
- ID: "testID",
- Event: map[string]any{},
- APIOpts: nil,
- }
- dh := &engine.DispatcherHost{
- Tenant: "testTenant",
- RemoteHost: &config.RemoteHost{
- ID: "testID",
- Address: rpcclient.InternalRPC,
- Transport: utils.MetaInternal,
- TLS: false,
- },
- }
- value := &lazyDH{dh: dh, cfg: cfg, iPRCCh: chanRPC}
-
- newCache := engine.NewCacheS(cfg, dm, connMgr, nil)
- engine.Cache = newCache
- engine.Cache.SetWithoutReplicate(utils.CacheRPCConnections, "testID",
- value, nil, true, utils.NonTransactional)
- rply := &engine.AttrSProcessEventReply{}
- if err := dsp.authorizeEvent(context.Background(), ev, rply); err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- engine.Cache = cacheInit
-}
-
-type mockTypeCon3 struct{}
-
-func (*mockTypeCon3) Call(ctx *context.Context, serviceMethod string, args, reply any) error {
- eVreply := &engine.AttrSProcessEventReply{
- CGREvent: &utils.CGREvent{
- Tenant: "testTenant",
- ID: "testID",
- Event: map[string]any{
- utils.APIMethods: "yes",
- },
- APIOpts: nil,
- },
- }
- *reply.(*engine.AttrSProcessEventReply) = *eVreply
- return nil
-}
-
-func TestDispatcherServiceAuthorizeError(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().AttributeSConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes)}
- dm := engine.NewDataManager(nil, nil, nil)
- chanRPC := make(chan birpc.ClientConnector, 1)
- chanRPC <- new(mockTypeCon3)
- connMgr := engine.NewConnManager(cfg)
- connMgr.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes), utils.AttributeSv1, chanRPC)
-
- dsp := NewDispatcherService(dm, cfg, nil, connMgr)
- dh := &engine.DispatcherHost{
- Tenant: "testTenant",
- RemoteHost: &config.RemoteHost{
- ID: "testID",
- Address: rpcclient.InternalRPC,
- Transport: utils.MetaInternal,
- TLS: false,
- },
- }
- value := &lazyDH{dh: dh, cfg: cfg, iPRCCh: chanRPC}
- newCache := engine.NewCacheS(cfg, dm, connMgr, nil)
- engine.Cache = newCache
- engine.Cache.SetWithoutReplicate(utils.CacheRPCConnections, "testID",
- value, nil, true, utils.NonTransactional)
- expected := "UNAUTHORIZED_API"
- if err := dsp.authorize(context.Background(), utils.APIMethods, "testTenant", "apikey"); err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
- engine.Cache = cacheInit
-}
-
-type mockTypeCon4 struct{}
-
-func (*mockTypeCon4) Call(ctx *context.Context, serviceMethod string, args, reply any) error {
- eVreply := &engine.AttrSProcessEventReply{
- CGREvent: &utils.CGREvent{
- Tenant: "testTenant",
- ID: "testID",
- Event: map[string]any{},
- APIOpts: nil,
- },
- }
- *reply.(*engine.AttrSProcessEventReply) = *eVreply
- return nil
-}
-
-func TestDispatcherServiceAuthorizeError2(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().AttributeSConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes)}
- dm := engine.NewDataManager(nil, nil, nil)
- chanRPC := make(chan birpc.ClientConnector, 1)
- chanRPC <- new(mockTypeCon4)
- connMgr := engine.NewConnManager(cfg)
- connMgr.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes), utils.AttributeSv1, chanRPC)
-
- dsp := NewDispatcherService(dm, cfg, nil, connMgr)
- dh := &engine.DispatcherHost{
- Tenant: "testTenant",
- RemoteHost: &config.RemoteHost{
- ID: "testID",
- Address: rpcclient.InternalRPC,
- Transport: utils.MetaInternal,
- TLS: false,
- },
- }
- value := &lazyDH{dh: dh, cfg: cfg, iPRCCh: chanRPC}
-
- newCache := engine.NewCacheS(cfg, dm, connMgr, nil)
- engine.Cache = newCache
- engine.Cache.SetWithoutReplicate(utils.CacheRPCConnections, "testID",
- value, nil, true, utils.NonTransactional)
- expected := "NOT_FOUND"
- if err := dsp.authorize(context.Background(), utils.APIMethods, "testTenant", "apikey"); err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
- engine.Cache = cacheInit
-}
-
-type mockTypeCon5 struct{}
-
-func (*mockTypeCon5) Call(ctx *context.Context, serviceMethod string, args, reply any) error {
- eVreply := &engine.AttrSProcessEventReply{
- CGREvent: &utils.CGREvent{
- Tenant: "testTenant",
- ID: "testID",
- Event: map[string]any{
- utils.APIMethods: "testMethod",
- },
- APIOpts: nil,
- },
- }
- *reply.(*engine.AttrSProcessEventReply) = *eVreply
- return nil
-}
-
-func TestDispatcherServiceAuthorizeError3(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().AttributeSConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes)}
- dm := engine.NewDataManager(nil, nil, nil)
- chanRPC := make(chan birpc.ClientConnector, 1)
- chanRPC <- new(mockTypeCon5)
- connMgr := engine.NewConnManager(cfg)
- connMgr.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes), utils.AttributeSv1, chanRPC)
-
- dsp := NewDispatcherService(dm, cfg, nil, connMgr)
- dh := &engine.DispatcherHost{
- Tenant: "testTenant",
- RemoteHost: &config.RemoteHost{
- ID: "testID",
- Address: rpcclient.InternalRPC,
- Transport: utils.MetaInternal,
- TLS: false,
- },
- }
- value := &lazyDH{dh: dh, cfg: cfg, iPRCCh: chanRPC}
-
- newCache := engine.NewCacheS(cfg, dm, connMgr, nil)
- engine.Cache = newCache
- engine.Cache.SetWithoutReplicate(utils.CacheRPCConnections, "testID",
- value, nil, true, utils.NonTransactional)
- if err := dsp.authorize(context.Background(), "testMethod", "testTenant", "apikey"); err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- engine.Cache = cacheInit
-}
-
-func TestDispatcherServiceDispatcherProfileForEventErrNil(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = false
- connMng := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMng)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "123",
- FilterIDs: []string{"*string:~*vars.*subsys:" + utils.MetaAccounts},
- Strategy: "",
- StrategyParams: nil,
- Weight: 0,
- Hosts: nil,
- }
- err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- dss := NewDispatcherService(dm, cfg, engine.NewFilterS(cfg, connMng, dm), connMng)
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "123",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaAccounts,
- },
- }
- tnt := ev.Tenant
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- _, err = dss.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- })
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
-}
-
-func TestDispatcherV1GetProfileForEventReturn(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = false
- connMng := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMng)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "123",
- FilterIDs: []string{"*string:~*vars.*subsys:" + utils.MetaAccounts},
- Strategy: "",
- StrategyParams: nil,
- Weight: 0,
- Hosts: nil,
- }
- err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- dss := NewDispatcherService(dm, cfg, engine.NewFilterS(cfg, connMng, dm), connMng)
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "123",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaAccounts,
- },
- }
- tnt := ev.Tenant
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- _, err = dss.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- })
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- dPfl := &engine.DispatcherProfiles{}
- err = dss.V1GetProfilesForEvent(context.Background(), ev, dPfl)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDispatcherServiceDispatcherProfileForEventErrNotFound(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = false
- connMng := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMng)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "123",
- FilterIDs: []string{"*string:~*vars.*subsys:" + utils.MetaAccounts},
- Strategy: "",
- StrategyParams: nil,
- Weight: 0,
- Hosts: nil,
- }
- err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- dss := NewDispatcherService(dm, cfg, engine.NewFilterS(cfg, connMng, dm), connMng)
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "123",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaAny,
- },
- }
- tnt := ev.Tenant
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- _, err = dss.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- })
- if err == nil || err != utils.ErrDSPProfileNotFound {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.ErrDSPProfileNotFound, err)
- }
-}
-
-func TestDispatcherServiceDispatcherProfileForEventErrNotFound2(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = false
- connMng := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMng)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "123",
- FilterIDs: []string{"*string:~*vars.*subsys:" + utils.MetaAccounts},
- Strategy: "",
- StrategyParams: nil,
- Weight: 0,
- Hosts: nil,
- }
- err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- dss := NewDispatcherService(dm, cfg, engine.NewFilterS(cfg, connMng, dm), connMng)
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "123",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaAccounts,
- },
- }
- tnt := ""
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- _, err = dss.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- })
- if err == nil || err != utils.ErrDSPProfileNotFound {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.ErrDSPProfileNotFound, err)
- }
-}
-
-func TestDispatcherServiceDispatcherProfileForEventErrNotFoundFilter(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = false
- connMng := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMng)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "123",
- FilterIDs: []string{"filter", "*string:~*vars.*subsys:" + utils.MetaAccounts},
- Strategy: "",
- StrategyParams: nil,
- Weight: 0,
- Hosts: nil,
- }
- err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- fltrs := engine.NewFilterS(cfg, connMng, dm)
- dss := NewDispatcherService(dm, cfg, fltrs, connMng)
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "123",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaAccounts,
- },
- }
- tnt := ev.Tenant
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- _, err = dss.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- })
- if err == nil || err.Error() != "NOT_FOUND:filter" {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", "NOT_FOUND:filter", err)
- }
-}
-
-func TestDispatcherServiceDispatchDspErr(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = false
- connMng := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMng)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "123",
- FilterIDs: []string{"*string:~*vars.*subsys:" + utils.MetaAccounts},
- Strategy: "",
- StrategyParams: nil,
- Weight: 0,
- Hosts: nil,
- }
- err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- dss := NewDispatcherService(dm, cfg, engine.NewFilterS(cfg, connMng, dm), connMng)
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "123",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaAccounts,
- },
- }
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- err = dss.Dispatch(context.TODO(), ev, subsys, "", "", "")
- expected := "unsupported dispatch strategy: <>"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDispatcherServiceDispatchDspErrHostNotFound(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = false
- connMng := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMng)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "123",
- FilterIDs: []string{"*string:~*vars.*subsys:" + utils.MetaAccounts},
- StrategyParams: make(map[string]any),
- Strategy: utils.MetaWeight,
- Weight: 0,
- Hosts: nil,
- }
- value, errDsp := newDispatcher(dsp)
- if errDsp != nil {
- t.Fatal(errDsp)
- }
- ctx := &context.Context{}
- engine.Cache.Set(ctx, utils.CacheDispatchers, dsp.TenantID(), value, nil, true, utils.EmptyString)
-
- err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- dss := NewDispatcherService(dm, cfg, engine.NewFilterS(cfg, connMng, dm), connMng)
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "123",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaAccounts,
- },
- }
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- err = dss.Dispatch(context.TODO(), ev, subsys, "", "", "")
- expected := "DSP_HOST_NOT_FOUND"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDispatcherServiceDispatcherProfileForEventFoundFilter(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = false
- connMng := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMng)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "123",
- FilterIDs: []string{"*string:~*req.RunID:1", "*string:~*vars.*subsys:" + utils.MetaAccounts},
- Strategy: "",
- StrategyParams: nil,
- Weight: 0,
- Hosts: nil,
- }
- err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- fltrs := engine.NewFilterS(cfg, connMng, dm)
- dss := NewDispatcherService(dm, cfg, fltrs, connMng)
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "123",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaAccounts,
- },
- }
- tnt := ev.Tenant
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- _, err = dss.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- })
- if err == nil || err.Error() != "DSP_PROFILE_NOT_FOUND" {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", "DSP_PROFILE_NOT_FOUND:filter", err)
- }
-}
-
-func TestDispatcherServiceDispatcherProfileForEventNotNotFound(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = true
- connMng := engine.NewConnManager(cfg)
- var cnt int
-
- dm := engine.NewDataManager(&engine.DataDBMock{
- GetIndexesDrvF: func(ctx *context.Context, idxItmType, tntCtx, idxKey, transactionID string) (indexes map[string]utils.StringSet, err error) {
- if cnt == 0 {
- cnt++
- return map[string]utils.StringSet{
- idxKey: {"cgrates.org:dsp1": {}},
- }, nil
- }
- return nil, utils.ErrNotImplemented
- },
- }, nil, connMng)
- fltrs := engine.NewFilterS(cfg, connMng, dm)
- dss := NewDispatcherService(dm, cfg, fltrs, connMng)
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "123",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaAccounts,
- },
- }
- tnt := ev.Tenant
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- _, err := dss.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- })
- expected := utils.ErrNotImplemented
- if err == nil || err != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestDispatcherServiceDispatcherProfileForEventGetDispatcherError(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = false
- connMng := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMng)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "123",
- FilterIDs: []string{"*string:~*req.RunID:1", "*string:~*vars.*subsys:" + utils.MetaAccounts},
- Strategy: "",
- StrategyParams: nil,
- Weight: 0,
- Hosts: nil,
- }
- err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- fltrs := engine.NewFilterS(cfg, connMng, dm)
- dss := NewDispatcherService(dm, cfg, fltrs, connMng)
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "123",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaAccounts,
- },
- }
- tnt := ev.Tenant
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- _, err = dss.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- })
- if err == nil || err.Error() != "DSP_PROFILE_NOT_FOUND" {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", "DSP_PROFILE_NOT_FOUND:filter", err)
- }
-}
-
-func TestDispatcherServiceDispatchDspErrHostNotFound2(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- cfg.DispatcherSCfg().IndexedSelects = false
- connMng := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMng)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "123",
- FilterIDs: []string{"*string:~*vars.*subsys:" + utils.MetaAccounts},
- StrategyParams: make(map[string]any),
- Strategy: utils.MetaWeight,
- Weight: 0,
- Hosts: nil,
- }
- newCache := engine.NewCacheS(cfg, dm, connMng, nil)
- value, errDsp := newDispatcher(dsp)
- if errDsp != nil {
- t.Fatal(errDsp)
- }
- ctx := &context.Context{}
- engine.Cache = newCache
- engine.Cache.Set(ctx, utils.CacheDispatchers, dsp.TenantID(), value, nil, true, utils.EmptyString)
-
- err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- dss := NewDispatcherService(dm, cfg, engine.NewFilterS(cfg, connMng, dm), connMng)
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "123",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaAccounts,
- },
- }
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- err = dss.Dispatch(context.TODO(), ev, subsys, "", "", "")
- expected := "DSP_HOST_NOT_FOUND"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
- engine.Cache = cacheInit
-}
-
-type mockTypeConSetCache struct{}
-
-func (*mockTypeConSetCache) Call(ctx *context.Context, serviceMethod string, args, reply any) error {
- return utils.ErrNotImplemented
-}
-
-func TestDispatcherServiceDispatchDspErrHostNotFound3(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- cfg.CacheCfg().ReplicationConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator)}
- cfg.CacheCfg().Partitions[utils.CacheDispatchers] = &config.CacheParamCfg{
- Replicate: true,
- }
- cfg.DispatcherSCfg().IndexedSelects = false
- chanRPC := make(chan birpc.ClientConnector, 1)
- chanRPC <- new(mockTypeConSetCache)
- connMgr := engine.NewConnManager(cfg)
- connMgr.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator), utils.ReplicatorSv1, chanRPC)
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, nil, connMgr)
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "123",
- FilterIDs: []string{"*string:~*vars.*subsys:" + utils.MetaAccounts},
- StrategyParams: make(map[string]any),
- Strategy: utils.MetaWeight,
- Weight: 0,
- Hosts: nil,
- }
- newCache := engine.NewCacheS(cfg, dm, connMgr, nil)
- engine.Cache = newCache
-
- err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- dss := NewDispatcherService(dm, cfg, engine.NewFilterS(cfg, connMgr, dm), connMgr)
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "123",
- Event: map[string]any{
- utils.AccountField: "1001",
- "Password": "CGRateS.org",
- "RunID": utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaAccounts,
- },
- }
- subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
- err = dss.Dispatch(context.TODO(), ev, subsys, "", "", "")
- expected := "NOT_IMPLEMENTED"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
- engine.Cache = cacheInit
-}
-
-func TestDispatchersdispatcherProfileForEventAnySSfalseFirstNotFound(t *testing.T) {
- tmp := engine.Cache
- defer func() {
- engine.Cache = tmp
- }()
-
- cfg := config.NewDefaultCGRConfig()
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(dataDB, cfg.CacheCfg(), nil)
- connMgr := engine.NewConnManager(cfg)
- engine.Cache = engine.NewCacheS(cfg, dm, connMgr, nil)
-
- dS := &DispatcherService{
- cfg: cfg,
- dm: dm,
- fltrS: engine.NewFilterS(cfg, nil, dm),
- }
-
- dsp1 := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- FilterIDs: []string{"*string:~*req.Account:1002", "*string:~*vars.*subsys:" + utils.MetaSessionS},
- ID: "DSP_1",
- Strategy: "*weight",
- Weight: 10,
- }
- err := dS.dm.SetDispatcherProfile(context.TODO(), dsp1, true)
- if err != nil {
- t.Error(err)
- }
-
- dsp2 := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- ID: "DSP_2",
- Strategy: "*weight",
- Weight: 20,
- }
- err = dS.dm.SetDispatcherProfile(context.TODO(), dsp2, true)
- if err != nil {
- t.Error(err)
- }
-
- tnt := "cgrates.org"
- ev := &utils.CGREvent{
- Tenant: tnt,
- Event: map[string]any{
- utils.AccountField: "1001",
- },
- APIOpts: map[string]any{
- utils.OptsDispatchersProfilesCount: 1,
- },
- }
- subsys := utils.MetaSessionS
-
- if rcv, err := dS.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- }); err != nil {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, err)
- } else if len(rcv) != 1 {
- t.Errorf("Unexpected number of profiles:%v", len(rcv))
- } else if !reflect.DeepEqual(rcv[0], dsp2) {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", dsp2, rcv)
- }
-}
-
-func TestDispatchersdispatcherProfileForEventAnySSfalseFound(t *testing.T) {
- tmp := engine.Cache
- defer func() {
- engine.Cache = tmp
- }()
-
- cfg := config.NewDefaultCGRConfig()
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- connMgr := engine.NewConnManager(cfg)
- dm := engine.NewDataManager(dataDB, cfg.CacheCfg(), nil)
- engine.Cache = engine.NewCacheS(cfg, dm, connMgr, nil)
-
- dS := &DispatcherService{
- cfg: cfg,
- dm: dm,
- fltrS: engine.NewFilterS(cfg, nil, dm),
- }
-
- dsp1 := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- FilterIDs: []string{"*string:~*req.Account:1001", "*string:~*vars.*subsys:" + utils.MetaSessionS},
- ID: "DSP_1",
- Strategy: "*weight",
- Weight: 20,
- }
- err := dS.dm.SetDispatcherProfile(context.TODO(), dsp1, true)
- if err != nil {
- t.Error(err)
- }
-
- dsp2 := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- ID: "DSP_2",
- Strategy: "*weight",
- Weight: 10,
- }
- err = dS.dm.SetDispatcherProfile(context.TODO(), dsp2, true)
- if err != nil {
- t.Error(err)
- }
-
- tnt := "cgrates.org"
- ev := &utils.CGREvent{
- Tenant: tnt,
- Event: map[string]any{
- utils.AccountField: "1001",
- },
- APIOpts: map[string]any{
- utils.OptsDispatchersProfilesCount: 1,
- },
- }
- subsys := utils.MetaSessionS
-
- if rcv, err := dS.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- }); err != nil {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, err)
- } else if len(rcv) != 1 {
- t.Errorf("Unexpected number of profiles:%v", len(rcv))
- } else if !reflect.DeepEqual(rcv[0], dsp1) {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", dsp1, rcv)
- }
-}
-
-func TestDispatchersdispatcherProfileForEventAnySSfalseNotFound(t *testing.T) {
- tmp := engine.Cache
- defer func() {
- engine.Cache = tmp
- }()
-
- cfg := config.NewDefaultCGRConfig()
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- connMgr := engine.NewConnManager(cfg)
- dm := engine.NewDataManager(dataDB, cfg.CacheCfg(), nil)
- engine.Cache = engine.NewCacheS(cfg, dm, connMgr, nil)
-
- dS := &DispatcherService{
- cfg: cfg,
- dm: dm,
- fltrS: engine.NewFilterS(cfg, nil, dm),
- }
-
- dsp1 := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- FilterIDs: []string{"*string:~*req.Account:1002", "*string:~*vars.*subsys:" + utils.MetaSessionS},
- ID: "DSP_1",
- Strategy: "*weight",
- Weight: 20,
- }
- err := dS.dm.SetDispatcherProfile(context.TODO(), dsp1, true)
- if err != nil {
- t.Error(err)
- }
-
- dsp2 := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- FilterIDs: []string{"*string:~*req.Account:1002"},
- ID: "DSP_2",
- Strategy: "*weight",
- Weight: 10,
- }
- err = dS.dm.SetDispatcherProfile(context.TODO(), dsp2, true)
- if err != nil {
- t.Error(err)
- }
-
- tnt := "cgrates.org"
- ev := &utils.CGREvent{
- Tenant: tnt,
- Event: map[string]any{
- utils.AccountField: "1001",
- },
- APIOpts: map[string]any{
- utils.OptsDispatchersProfilesCount: 1,
- },
- }
- subsys := utils.MetaSessionS
-
- if rcv, err := dS.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- }); err == nil || err != utils.ErrDSPProfileNotFound {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", utils.ErrDSPProfileNotFound, err)
- } else if rcv != nil {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, rcv)
- }
-}
-
-func TestDispatchersdispatcherProfileForEventAnySStrueNotFound(t *testing.T) {
- tmp := engine.Cache
- defer func() {
- engine.Cache = tmp
- }()
-
- cfg := config.NewDefaultCGRConfig()
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- connMgr := engine.NewConnManager(cfg)
- dm := engine.NewDataManager(dataDB, cfg.CacheCfg(), nil)
- engine.Cache = engine.NewCacheS(cfg, dm, connMgr, nil)
-
- dS := &DispatcherService{
- cfg: cfg,
- dm: dm,
- fltrS: engine.NewFilterS(cfg, nil, dm),
- }
-
- dsp1 := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- FilterIDs: []string{"*string:~*req.Account:1002", "*string:~*vars.*subsys:" + utils.MetaSessionS},
- ID: "DSP_1",
- Strategy: "*weight",
- Weight: 20,
- }
- err := dS.dm.SetDispatcherProfile(context.TODO(), dsp1, true)
- if err != nil {
- t.Error(err)
- }
-
- dsp2 := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- FilterIDs: []string{"*string:~*req.Account:1002"},
- ID: "DSP_2",
- Strategy: "*weight",
- Weight: 10,
- }
- err = dS.dm.SetDispatcherProfile(context.TODO(), dsp2, true)
- if err != nil {
- t.Error(err)
- }
-
- tnt := "cgrates.org"
- ev := &utils.CGREvent{
- Tenant: tnt,
- Event: map[string]any{
- utils.AccountField: "1001",
- },
- APIOpts: map[string]any{
- utils.OptsDispatchersProfilesCount: 1,
- },
- }
- subsys := utils.MetaSessionS
-
- if rcv, err := dS.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- }); err == nil || err != utils.ErrDSPProfileNotFound {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", utils.ErrDSPProfileNotFound, err)
- } else if rcv != nil {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, rcv)
- }
-}
-
-func TestDispatchersdispatcherProfileForEventAnySStrueBothFound(t *testing.T) {
- tmp := engine.Cache
- defer func() {
- engine.Cache = tmp
- }()
-
- cfg := config.NewDefaultCGRConfig()
- dataDB := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- connMgr := engine.NewConnManager(cfg)
- dm := engine.NewDataManager(dataDB, cfg.CacheCfg(), nil)
- engine.Cache = engine.NewCacheS(cfg, dm, connMgr, nil)
-
- dS := &DispatcherService{
- cfg: cfg,
- dm: dm,
- fltrS: engine.NewFilterS(cfg, nil, dm),
- }
-
- dsp1 := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- FilterIDs: []string{"*string:~*req.Account:1001", "*string:~*vars.*subsys:" + utils.MetaSessionS},
- ID: "DSP_1",
- Strategy: "*weight",
- Weight: 10,
- }
- err := dS.dm.SetDispatcherProfile(context.TODO(), dsp1, true)
- if err != nil {
- t.Error(err)
- }
-
- dsp2 := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- ID: "DSP_2",
- Strategy: "*weight",
- Weight: 20,
- }
- err = dS.dm.SetDispatcherProfile(context.TODO(), dsp2, true)
- if err != nil {
- t.Error(err)
- }
-
- tnt := "cgrates.org"
- ev := &utils.CGREvent{
- Tenant: tnt,
- Event: map[string]any{
- utils.AccountField: "1001",
- },
- APIOpts: map[string]any{
- utils.OptsDispatchersProfilesCount: 1,
- },
- }
- subsys := utils.MetaSessionS
-
- if rcv, err := dS.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- }); err != nil {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, err)
- } else if len(rcv) != 1 {
- t.Errorf("Unexpected number of profiles:%v", len(rcv))
- } else if !reflect.DeepEqual(rcv[0], dsp2) {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", dsp2, rcv)
- }
-
- dsp1.Weight = 30
- err = dS.dm.SetDispatcherProfile(context.TODO(), dsp1, true)
- if err != nil {
- t.Error(err)
- }
-
- if rcv, err := dS.dispatcherProfilesForEvent(context.Background(), tnt, ev, utils.MapStorage{
- utils.MetaReq: ev.Event,
- utils.MetaOpts: ev.APIOpts,
- utils.MetaVars: utils.MapStorage{
- utils.MetaSubsys: subsys,
- },
- }); err != nil {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", nil, err)
- } else if len(rcv) != 1 {
- t.Errorf("Unexpected number of profiles:%v", len(rcv))
- } else if !reflect.DeepEqual(rcv[0], dsp1) {
- t.Errorf("\nexpected: <%+v>, \nreceived: <%+v>", dsp1, rcv)
- }
-}
diff --git a/dispatchers/ees.go b/dispatchers/ees.go
deleted file mode 100644
index 48278cc53..000000000
--- a/dispatchers/ees.go
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/ees"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) EeSv1ArchiveEventsInReply(ctx *context.Context, args *ees.ArchiveEventsArgs, reply *[]uint8) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaEEs, utils.EeSv1ArchiveEventsInReply, args, reply)
-}
-func (dS *DispatcherService) EeSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaEEs, utils.EeSv1Ping, args, reply)
-}
-func (dS *DispatcherService) EeSv1ProcessEvent(ctx *context.Context, args *utils.CGREventWithEeIDs, reply *map[string]map[string]any) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.CGREvent != nil && len(args.CGREvent.Tenant) != 0) {
- tnt = args.CGREvent.Tenant
- }
- ev := make(map[string]any)
- if args != nil && args.CGREvent != nil {
- ev = args.CGREvent.Event
- }
- opts := make(map[string]any)
- if args != nil && args.CGREvent != nil {
- opts = args.CGREvent.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaEEs, utils.EeSv1ProcessEvent, args, reply)
-}
diff --git a/dispatchers/efs.go b/dispatchers/efs.go
deleted file mode 100644
index a1c4cbb35..000000000
--- a/dispatchers/efs.go
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/efs"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) EfSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaEFs, utils.EfSv1Ping, args, reply)
-}
-func (dS *DispatcherService) EfSv1ProcessEvent(ctx *context.Context, args *utils.ArgsFailedPosts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaEFs, utils.EfSv1ProcessEvent, args, reply)
-}
-func (dS *DispatcherService) EfSv1ReplayEvents(ctx *context.Context, args efs.ReplayEventsParams, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaEFs, utils.EfSv1ReplayEvents, args, reply)
-}
diff --git a/dispatchers/ers.go b/dispatchers/ers.go
deleted file mode 100644
index 996479918..000000000
--- a/dispatchers/ers.go
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/ers"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) ErSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaERs, utils.ErSv1Ping, args, reply)
-}
-func (dS *DispatcherService) ErSv1RunReader(ctx *context.Context, args ers.V1RunReaderParams, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := args.APIOpts
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaERs, utils.ErSv1RunReader, args, reply)
-}
diff --git a/dispatchers/guardian.go b/dispatchers/guardian.go
deleted file mode 100644
index 241dab615..000000000
--- a/dispatchers/guardian.go
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/guardian"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) GuardianSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaGuardian, utils.GuardianSv1Ping, args, reply)
-}
-func (dS *DispatcherService) GuardianSv1RemoteLock(ctx *context.Context, args *guardian.AttrRemoteLockWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaGuardian, utils.GuardianSv1RemoteLock, args, reply)
-}
-func (dS *DispatcherService) GuardianSv1RemoteUnlock(ctx *context.Context, args *guardian.AttrRemoteUnlockWithAPIOpts, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaGuardian, utils.GuardianSv1RemoteUnlock, args, reply)
-}
diff --git a/dispatchers/guardian_it_test.go b/dispatchers/guardian_it_test.go
deleted file mode 100644
index 923280f2a..000000000
--- a/dispatchers/guardian_it_test.go
+++ /dev/null
@@ -1,116 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "reflect"
- "testing"
- "time"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/guardian"
- "github.com/cgrates/cgrates/utils"
-)
-
-var sTestsDspGrd = []func(t *testing.T){
- testDspGrdPing,
- testDspGrdLock,
-}
-
-// Test start here
-func TestDspGuardianST(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- }
- testDsp(t, sTestsDspGrd, "TestDspGuardianS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
-}
-
-func testDspGrdPing(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.GuardianSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.GuardianSv1Ping, &utils.CGREvent{
- Tenant: "cgrates.org",
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "grd12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
-
-func testDspGrdLock(t *testing.T) {
- // lock
- args := utils.AttrRemoteLock{
- ReferenceID: "",
- LockIDs: []string{"lock1"},
- Timeout: 500 * time.Millisecond,
- }
- var reply string
- if err := dispEngine.RPC.Call(context.Background(), utils.GuardianSv1RemoteLock, &guardian.AttrRemoteLockWithAPIOpts{
- AttrRemoteLock: args,
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "grd12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- }
-
- var unlockReply []string
- if err := dispEngine.RPC.Call(context.Background(), utils.GuardianSv1RemoteUnlock, &guardian.AttrRemoteUnlockWithAPIOpts{
- RefID: reply,
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "grd12345",
- },
- }, &unlockReply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(args.LockIDs, unlockReply) {
- t.Errorf("Expected: %s , received: %s", utils.ToJSON(args.LockIDs), utils.ToJSON(unlockReply))
- }
-}
diff --git a/dispatchers/guardian_test.go b/dispatchers/guardian_test.go
deleted file mode 100644
index 058466bde..000000000
--- a/dispatchers/guardian_test.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/guardian"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDspRateSv1CostForEventCase(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.GuardianSv1Ping(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspGuardianSv1PingNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.GuardianSv1Ping(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspGuardianSv1PingErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.GuardianSv1Ping(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspGuardianSv1RemoteLockCase(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &guardian.AttrRemoteLockWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.GuardianSv1RemoteLock(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspGuardianSv1RemoteLockErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &guardian.AttrRemoteLockWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.GuardianSv1RemoteLock(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspGuardianSv1RemoteUnlockCase(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &guardian.AttrRemoteUnlockWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *[]string
- result := dspSrv.GuardianSv1RemoteUnlock(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspGuardianSv1RemoteUnlockErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &guardian.AttrRemoteUnlockWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *[]string
- result := dspSrv.GuardianSv1RemoteUnlock(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/dispatchers/lib_test.go b/dispatchers/lib_test.go
deleted file mode 100644
index d45dc4b73..000000000
--- a/dispatchers/lib_test.go
+++ /dev/null
@@ -1,150 +0,0 @@
-//go:build integration || flaky
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "os/exec"
- "path"
- "strconv"
- "testing"
- "time"
-
- "github.com/cgrates/birpc"
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var (
- dispEngine *testDispatcher
- allEngine *testDispatcher
- allEngine2 *testDispatcher
-)
-
-type testDispatcher struct {
- CfgPath string
- Cfg *config.CGRConfig
- RPC *birpc.Client
- cmd *exec.Cmd
-}
-
-func newTestEngine(t *testing.T, cfgPath string, initDataDB, initStorDB bool) (d *testDispatcher) {
- d = new(testDispatcher)
- d.CfgPath = cfgPath
- var err error
- d.Cfg, err = config.NewCGRConfigFromPath(context.Background(), d.CfgPath)
- if err != nil {
- t.Fatalf("Error at config init :%v\n", err)
- }
- d.Cfg.DataFolderPath = *utils.DataDir // Share DataFolderPath through config towards StoreDb for Flush()
-
- if initDataDB {
- d.initDataDb(t)
- }
- if initStorDB {
- d.resetStorDb(t)
- }
- d.startEngine(t)
- return d
-}
-
-func (d *testDispatcher) startEngine(t *testing.T) {
- var err error
- // if !strings.Contains(d.CfgPath, "dispatchers_mysql") {
- if d.cmd, err = engine.StartEngine(d.CfgPath, *utils.WaitRater); err != nil {
- t.Fatalf("Error at engine start:%v\n", err)
- }
- // }
- d.RPC = engine.NewRPCClient(t, d.Cfg.ListenCfg(), *utils.Encoding)
-}
-
-func (d *testDispatcher) stopEngine(t *testing.T) {
- pid := strconv.Itoa(d.cmd.Process.Pid)
- if err := exec.Command("kill", "-9", pid).Run(); err != nil {
- t.Fatalf("Error at stop engine:%v\n", err)
- }
- time.Sleep(200 * time.Millisecond)
- // // if err := d.cmd.Process.Kill(); err != nil {
- // // t.Fatalf("Error at stop engine:%v\n", err)
- // }
-}
-
-func (d *testDispatcher) initDataDb(t *testing.T) {
- if err := engine.InitDataDB(d.Cfg); err != nil {
- t.Fatalf("Error at DataDB init:%v\n", err)
- }
-}
-
-// Wipe out the cdr database
-func (d *testDispatcher) resetStorDb(t *testing.T) {
- if err := engine.InitStorDB(d.Cfg); err != nil {
- t.Fatalf("Error at StorDB init:%v\n", err)
- }
-}
-
-// func (d *testDispatcher) loadData(t *testing.T, path string) {
-// var reply string
-// attrs := &utils.AttrLoadTpFromFolder{FolderPath: path}
-// if err := d.RPC.Call(utils.APIerSv1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
-// t.Errorf("<%s>Error at loading data from folder :%v", d.CfgPath, err)
-// }
-// }
-
-func (d *testDispatcher) loadData2(t *testing.T, path string) {
- wchan := make(chan struct{}, 1)
- go func() {
- loaderPath, err := exec.LookPath("cgr-loader")
- if err != nil {
- t.Error(err)
- }
- loader := exec.Command(loaderPath, "-config_path", d.CfgPath, "-path", path)
-
- if err := loader.Start(); err != nil {
- t.Error(err)
- }
- loader.Wait()
- wchan <- struct{}{}
- }()
- select {
- case <-wchan:
- case <-time.After(5 * time.Second):
- t.Errorf("cgr-loader failed: ")
- }
-}
-
-func testDsp(t *testing.T, tests []func(t *testing.T), testName, all, all2, disp, allTF, all2TF, attrTF string) {
- // engine.KillEngine(0)
- allEngine = newTestEngine(t, path.Join(*utils.DataDir, "conf", "samples", "dispatchers", all), true, true)
- allEngine2 = newTestEngine(t, path.Join(*utils.DataDir, "conf", "samples", "dispatchers", all2), true, true)
- dispEngine = newTestEngine(t, path.Join(*utils.DataDir, "conf", "samples", "dispatchers", disp), true, true)
- dispEngine.loadData2(t, path.Join(*utils.DataDir, "tariffplans", attrTF))
- allEngine.loadData2(t, path.Join(*utils.DataDir, "tariffplans", allTF))
- allEngine2.loadData2(t, path.Join(*utils.DataDir, "tariffplans", all2TF))
- time.Sleep(200 * time.Millisecond)
- for _, stest := range tests {
- t.Run(testName, stest)
- }
- dispEngine.stopEngine(t)
- allEngine.stopEngine(t)
- allEngine2.stopEngine(t)
- engine.KillEngine(0)
-}
diff --git a/dispatchers/libdispatcher.go b/dispatchers/libdispatcher.go
deleted file mode 100644
index cdf0b05d3..000000000
--- a/dispatchers/libdispatcher.go
+++ /dev/null
@@ -1,520 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "encoding/gob"
- "fmt"
- "math/rand"
- "sort"
- "sync"
- "time"
-
- "github.com/cgrates/birpc"
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
- "github.com/cgrates/rpcclient"
-)
-
-var (
- internalDispatcher = &engine.DispatcherProfile{Tenant: utils.MetaInternal, ID: utils.MetaInternal}
-)
-
-func init() {
- gob.Register(new(LoadMetrics))
- gob.Register(new(DispatcherRoute))
- //gob.RegisterName("dispatchers.DispatcherRoute", DispatcherRoute{})
-}
-
-// isInternalDispatcherProfile compares the profile to the internal one
-func isInternalDispatcherProfile(d *engine.DispatcherProfile) bool {
- return d.Tenant == internalDispatcher.Tenant && d.ID == internalDispatcher.ID
-}
-
-// DispatcherRoute is bounded to a routeID
-type DispatcherRoute struct {
- Tenant, ProfileID, HostID string
-}
-
-// getDispatcherWithCache
-func getDispatcherWithCache(ctx *context.Context, dPrfl *engine.DispatcherProfile, dm *engine.DataManager) (d Dispatcher, err error) {
- tntID := dPrfl.TenantID()
- if x, ok := engine.Cache.Get(utils.CacheDispatchers,
- tntID); ok && x != nil {
- d = x.(Dispatcher)
- return
- }
- if dPrfl.Hosts == nil { // dispatcher profile was not retrieved but built artificially above, try retrieving
- if dPrfl, err = dm.GetDispatcherProfile(ctx, dPrfl.Tenant, dPrfl.ID,
- true, true, utils.NonTransactional); err != nil {
- return
- }
- }
- if d, err = newDispatcher(dPrfl); err != nil {
- return
- } else if err = engine.Cache.Set(ctx, utils.CacheDispatchers, tntID, d, // cache the built Dispatcher
- nil, true, utils.EmptyString); err != nil {
- return
- }
- return
-}
-
-// Dispatcher is responsible for routing requests to pool of connections
-// there will be different implementations based on strategy
-type Dispatcher interface {
- // Dispatch is used to send the method over the connections given
- Dispatch(dm *engine.DataManager, flts *engine.FilterS, cfg *config.CGRConfig,
- ctx *context.Context, iPRCCh chan birpc.ClientConnector,
- ev utils.DataProvider, tnt, routeID string, dR *DispatcherRoute,
- serviceMethod string, args any, reply any) (err error)
-}
-
-// newDispatcher constructs instances of Dispatcher
-func newDispatcher(pfl *engine.DispatcherProfile) (d Dispatcher, err error) {
- hosts := pfl.Hosts.Clone()
- hosts.Sort() // make sure the connections are sorted
- switch pfl.Strategy {
- case utils.MetaWeight:
- return newSingleDispatcher(hosts, pfl.StrategyParams, pfl.TenantID(), new(noSort))
- case utils.MetaRandom:
- return newSingleDispatcher(hosts, pfl.StrategyParams, pfl.TenantID(), new(randomSort))
- case utils.MetaRoundRobin:
- return newSingleDispatcher(hosts, pfl.StrategyParams, pfl.TenantID(), new(roundRobinSort))
- case rpcclient.PoolBroadcast,
- rpcclient.PoolBroadcastSync,
- rpcclient.PoolBroadcastAsync:
- return &broadcastDispatcher{
- strategy: pfl.Strategy,
- hosts: hosts,
- }, nil
- default:
- err = fmt.Errorf("unsupported dispatch strategy: <%s>", pfl.Strategy)
- }
- return
-}
-
-// getDispatcherHosts returns a list of host IDs matching the event with filters
-func getDispatcherHosts(fltrs *engine.FilterS, ev utils.DataProvider,
- ctx *context.Context, tnt string, hosts engine.DispatcherHostProfiles) (hostIDs engine.DispatcherHostIDs, err error) {
- hostIDs = make(engine.DispatcherHostIDs, 0, len(hosts))
- for _, host := range hosts {
- var pass bool
- if pass, err = fltrs.Pass(ctx, tnt, host.FilterIDs, ev); err != nil {
- return
- }
- if pass {
- hostIDs = append(hostIDs, host.ID)
- if host.Blocker {
- break
- }
- }
- }
- return
-}
-
-// hostSorted is the sorting interface used by singleDispatcher
-type hostSorter interface {
- Sort(fltrs *engine.FilterS, ev utils.DataProvider,
- ctx *context.Context, tnt string, hosts engine.DispatcherHostProfiles) (hostIDs engine.DispatcherHostIDs, err error)
-}
-
-// noSort will just return the matching hosts for the event.
-type noSort struct{}
-
-func (noSort) Sort(fltrs *engine.FilterS, ev utils.DataProvider,
- ctx *context.Context, tnt string, hosts engine.DispatcherHostProfiles) (hostIDs engine.DispatcherHostIDs, err error) {
- return getDispatcherHosts(fltrs, ev, ctx, tnt, hosts)
-}
-
-// randomSort will randomize the matching hosts for the event
-type randomSort struct{}
-
-func (randomSort) Sort(fltrs *engine.FilterS, ev utils.DataProvider,
- ctx *context.Context, tnt string, hosts engine.DispatcherHostProfiles) (hostIDs engine.DispatcherHostIDs, err error) {
- rand.Shuffle(len(hosts), func(i, j int) {
- hosts[i], hosts[j] = hosts[j], hosts[i]
- })
- return getDispatcherHosts(fltrs, ev, ctx, tnt, hosts)
-}
-
-// roundRoinSort will sort the matching hosts for the event in a round-robin fashion via nextIDx
-// which will be increased on each Sort iteration
-type roundRobinSort struct{ nextIDx int }
-
-func (rs *roundRobinSort) Sort(fltrs *engine.FilterS, ev utils.DataProvider,
- ctx *context.Context, tnt string, hosts engine.DispatcherHostProfiles) (hostIDs engine.DispatcherHostIDs, err error) {
- dh := make(engine.DispatcherHostProfiles, len(hosts))
- idx := rs.nextIDx
- for i := 0; i < len(dh); i++ {
- if idx > len(dh)-1 {
- idx = 0
- }
- dh[i] = hosts[idx]
- idx++
- }
- rs.nextIDx++
- if rs.nextIDx >= len(hosts) {
- rs.nextIDx = 0
- }
- return getDispatcherHosts(fltrs, ev, ctx, tnt, dh)
-}
-
-// newSingleDispatcher is the constructor for singleDispatcher struct.
-func newSingleDispatcher(hosts engine.DispatcherHostProfiles, params map[string]any,
- tntID string, sorter hostSorter) (_ Dispatcher, err error) {
- if dflt, has := params[utils.MetaDefaultRatio]; has {
- var ratio int64
- if ratio, err = utils.IfaceAsTInt64(dflt); err != nil {
- return
- }
- return &loadDispatcher{
- tntID: tntID,
- defaultRatio: ratio,
- sorter: sorter,
- hosts: hosts,
- }, nil
- }
- for _, host := range hosts {
- if _, has := host.Params[utils.MetaRatio]; has {
- return &loadDispatcher{
- tntID: tntID,
- defaultRatio: 1,
- sorter: sorter,
- hosts: hosts,
- }, nil
- }
- }
- return &singleResultDispatcher{
- sorter: sorter,
- hosts: hosts,
- }, nil
-}
-
-// singleResultDispatcher routes the event to a single host
-// implements Dispatcher interface
-type singleResultDispatcher struct {
- sorter hostSorter
- hosts engine.DispatcherHostProfiles
-}
-
-func (sd *singleResultDispatcher) Dispatch(dm *engine.DataManager, flts *engine.FilterS, cfg *config.CGRConfig,
- ctx *context.Context, iPRCCh chan birpc.ClientConnector,
- ev utils.DataProvider, tnt, routeID string, dR *DispatcherRoute,
- serviceMethod string, args any, reply any) (err error) {
- if dR != nil && dR.HostID != utils.EmptyString { // route to previously discovered route
- return callDHwithID(ctx, tnt, dR.HostID, routeID, dR, dm,
- cfg, iPRCCh, serviceMethod, args, reply)
- }
- var hostIDs []string
- if hostIDs, err = sd.sorter.Sort(flts, ev, ctx, tnt, sd.hosts); err != nil {
- return
- } else if len(hostIDs) == 0 { // in case we do not match any host
- return utils.ErrDSPHostNotFound
- }
- for _, hostID := range hostIDs {
- var dRh *DispatcherRoute
- if routeID != utils.EmptyString {
- dRh = &DispatcherRoute{
- Tenant: dR.Tenant,
- ProfileID: dR.ProfileID,
- HostID: hostID,
- }
- }
- if err = callDHwithID(ctx, tnt, hostID, routeID, dRh, dm,
- cfg, iPRCCh, serviceMethod, args, reply); err != utils.ErrDSPHostNotFound &&
- !rpcclient.ShouldFailover(err) { // successful dispatch with normal errors
- return
- }
- if err != nil {
- // not found or network errors will continue with standard dispatching
- utils.Logger.Warning(fmt.Sprintf("<%s> error <%s> dispatching to host with identity <%s>",
- utils.DispatcherS, err.Error(), hostID))
- }
- }
- return
-}
-
-// broadcastDispatcher routes the event to multiple hosts in a pool
-// implements the Dispatcher interface
-type broadcastDispatcher struct {
- strategy string
- hosts engine.DispatcherHostProfiles
-}
-
-func (b *broadcastDispatcher) Dispatch(dm *engine.DataManager, flts *engine.FilterS, cfg *config.CGRConfig,
- ctx *context.Context, iPRCCh chan birpc.ClientConnector,
- ev utils.DataProvider, tnt, routeID string, dR *DispatcherRoute,
- serviceMethod string, args any, reply any) (err error) {
- var hostIDs []string
- if hostIDs, err = getDispatcherHosts(flts, ev, ctx, tnt, b.hosts); err != nil {
- return
- }
- var hasHosts bool
- pool := rpcclient.NewRPCPool(b.strategy, config.CgrConfig().GeneralCfg().ReplyTimeout)
- for _, hostID := range hostIDs {
- var dH *engine.DispatcherHost
- if dH, err = dm.GetDispatcherHost(ctx, tnt, hostID, true, true, utils.NonTransactional); err != nil {
- if err == utils.ErrDSPHostNotFound {
- utils.Logger.Warning(fmt.Sprintf("<%s> could not find host with ID %q",
- utils.DispatcherS, hostID))
- err = nil
- continue
- }
- return utils.NewErrDispatcherS(err)
- }
- hasHosts = true
- var dRh *DispatcherRoute
- if routeID != utils.EmptyString {
- dRh = &DispatcherRoute{
- Tenant: dR.Tenant,
- ProfileID: dR.ProfileID,
- HostID: hostID,
- }
- }
- pool.AddClient(&lazyDH{
- dh: dH,
- cfg: cfg,
- iPRCCh: iPRCCh,
- routeID: routeID,
- dR: dRh,
- })
- }
- if !hasHosts { // in case we do not match any host
- return utils.ErrDSPHostNotFound
- }
- return pool.Call(ctx, serviceMethod, args, reply)
-}
-
-type loadDispatcher struct {
- tntID string
- defaultRatio int64
- sorter hostSorter
- hosts engine.DispatcherHostProfiles
-}
-
-func (ld *loadDispatcher) Dispatch(dm *engine.DataManager, flts *engine.FilterS, cfg *config.CGRConfig,
- ctx *context.Context, iPRCCh chan birpc.ClientConnector,
- ev utils.DataProvider, tnt, routeID string, dR *DispatcherRoute,
- serviceMethod string, args any, reply any) (err error) {
-
- var lM *LoadMetrics
- if x, ok := engine.Cache.Get(utils.CacheDispatcherLoads, ld.tntID); ok && x != nil {
- var canCast bool
- if lM, canCast = x.(*LoadMetrics); !canCast {
- return fmt.Errorf("cannot cast %+v to *LoadMetrics", x)
- }
- } else if lM, err = newLoadMetrics(ld.hosts, ld.defaultRatio); err != nil {
- return
- }
- if dR != nil { // route to previously discovered route
- lM.incrementLoad(ctx, dR.HostID, ld.tntID)
- err = callDHwithID(ctx, tnt, dR.HostID, routeID, dR, dm,
- cfg, iPRCCh, serviceMethod, args, reply)
- lM.decrementLoad(ctx, dR.HostID, ld.tntID) // call ended
- if err != utils.ErrDSPHostNotFound && !rpcclient.ShouldFailover(err) { // successful dispatch with normal errors
- return
- }
- // not found or network errors will continue with standard dispatching
- utils.Logger.Warning(fmt.Sprintf("<%s> error <%s> dispatching to host with id <%q>",
- utils.DispatcherS, err.Error(), dR.HostID))
- }
- var hostIDs []string
- if hostIDs, err = ld.sorter.Sort(flts, ev, ctx, tnt, lM.getHosts(ld.hosts)); err != nil {
- return
- } else if len(hostIDs) == 0 { // in case we do not match any host
- return utils.ErrDSPHostNotFound
- }
- for _, hostID := range hostIDs {
- var dRh *DispatcherRoute
- if routeID != utils.EmptyString {
- dRh = &DispatcherRoute{
- Tenant: dR.Tenant,
- ProfileID: dR.ProfileID,
- HostID: hostID,
- }
- }
- lM.incrementLoad(ctx, hostID, ld.tntID)
- err = callDHwithID(ctx, tnt, hostID, routeID, dRh, dm,
- cfg, iPRCCh, serviceMethod, args, reply)
- lM.decrementLoad(ctx, hostID, ld.tntID) // call ended
- if err != utils.ErrDSPHostNotFound && !rpcclient.ShouldFailover(err) { // successful dispatch with normal errors
- return
- }
- if err != nil {
- // not found or network errors will continue with standard dispatching
- utils.Logger.Warning(fmt.Sprintf("<%s> error <%s> dispatching to host with id <%q>",
- utils.DispatcherS, err.Error(), hostID))
- }
- }
- return
-}
-
-func newLoadMetrics(hosts engine.DispatcherHostProfiles, dfltRatio int64) (*LoadMetrics, error) {
- lM := &LoadMetrics{
- HostsLoad: make(map[string]int64),
- HostsRatio: make(map[string]int64),
- }
- for _, host := range hosts {
- if strRatio, has := host.Params[utils.MetaRatio]; !has {
- lM.HostsRatio[host.ID] = dfltRatio
- } else if ratio, err := utils.IfaceAsTInt64(strRatio); err != nil {
- return nil, err
- } else {
- lM.HostsRatio[host.ID] = ratio
- }
- }
- return lM, nil
-}
-
-// LoadMetrics the structure to save the metrix for load strategy
-type LoadMetrics struct {
- mutex sync.RWMutex
- HostsLoad map[string]int64
- HostsRatio map[string]int64
-}
-
-// used to sort the host IDs based on costs
-type hostCosts struct {
- hosts engine.DispatcherHostProfiles
- load []int64
-}
-
-func (hc *hostCosts) Len() int { return len(hc.hosts) }
-func (hc *hostCosts) Less(i, j int) bool { return hc.load[i] < hc.load[j] }
-func (hc *hostCosts) Swap(i, j int) {
- hc.load[i], hc.load[j] = hc.load[j], hc.load[i]
- hc.hosts[i], hc.hosts[j] = hc.hosts[j], hc.hosts[i]
-}
-
-func (lM *LoadMetrics) getHosts(hosts engine.DispatcherHostProfiles) engine.DispatcherHostProfiles {
- hlp := &hostCosts{
- hosts: make(engine.DispatcherHostProfiles, 0, len(hosts)),
- load: make([]int64, 0, len(hosts)),
- }
- lM.mutex.RLock()
-
- for _, host := range hosts {
- switch {
- case lM.HostsRatio[host.ID] < 0:
- hlp.load = append(hlp.load, 0)
- case lM.HostsRatio[host.ID] == 0:
- continue
- default:
- hlp.load = append(hlp.load, lM.HostsLoad[host.ID]/lM.HostsRatio[host.ID])
- }
- hlp.hosts = append(hlp.hosts, host)
- }
- lM.mutex.RUnlock()
- sort.Stable(hlp)
- return hlp.hosts
-}
-
-func (lM *LoadMetrics) incrementLoad(ctx *context.Context, hostID, tntID string) {
- lM.mutex.Lock()
- lM.HostsLoad[hostID]++
- engine.Cache.ReplicateSet(ctx, utils.CacheDispatcherLoads, tntID, lM)
- lM.mutex.Unlock()
-}
-
-func (lM *LoadMetrics) decrementLoad(ctx *context.Context, hostID, tntID string) {
- lM.mutex.Lock()
- lM.HostsLoad[hostID]--
- engine.Cache.ReplicateSet(ctx, utils.CacheDispatcherLoads, tntID, lM)
- lM.mutex.Unlock()
-}
-
-// callDHwithID is a wrapper on callDH using ID of the host which the other cannot do due to lazyDH
-// if routeID provided, will also cache once the call is successful
-func callDHwithID(ctx *context.Context, tnt, hostID, routeID string, dR *DispatcherRoute,
- dm *engine.DataManager, cfg *config.CGRConfig, iPRCCh chan birpc.ClientConnector,
- serviceMethod string, args, reply any) (err error) {
- var dH *engine.DispatcherHost
- if dH, err = dm.GetDispatcherHost(ctx, tnt, hostID, true, true, utils.NonTransactional); err != nil {
- return
- }
- if err = callDH(ctx, dH, routeID, dR, cfg, iPRCCh, serviceMethod, args, reply); err != nil {
- return
- }
- return
-}
-
-func callDH(ctx *context.Context,
- dh *engine.DispatcherHost, routeID string, dR *DispatcherRoute,
- cfg *config.CGRConfig, iPRCCh chan birpc.ClientConnector,
- method string, args, reply any) (err error) {
- if routeID != utils.EmptyString { // cache the discovered route before dispatching
- argsCache := &utils.ArgCacheReplicateSet{
- Tenant: dh.Tenant,
- APIOpts: map[string]any{
- utils.MetaSubsys: utils.MetaDispatchers,
- utils.MetaNodeID: cfg.GeneralCfg().NodeID,
- },
- CacheID: utils.CacheDispatcherRoutes,
- ItemID: routeID,
- Value: dR,
- GroupIDs: []string{utils.ConcatenatedKey(utils.CacheDispatcherProfiles, dR.Tenant, dR.ProfileID)},
- }
- if err = engine.Cache.SetWithReplicate(ctx, argsCache); err != nil {
- if !rpcclient.ShouldFailover(err) {
- return
- }
- // did not dispatch properly, fail-back to standard dispatching
- utils.Logger.Warning(fmt.Sprintf("<%s> ignoring cache network error <%s> setting route dR %+v",
- utils.DispatcherS, err.Error(), dR))
- }
- }
- var conn birpc.ClientConnector
- if conn, err = dh.GetConn(ctx, cfg, iPRCCh); err != nil {
- return
- }
- if err = conn.Call(ctx, method, args, reply); err != nil {
- return
- }
- return
-}
-
-// lazyDH is created for the broadcast strategy so we can make sure host exists during setup phase
-type lazyDH struct {
- dh *engine.DispatcherHost
- cfg *config.CGRConfig
- iPRCCh chan birpc.ClientConnector
- routeID string
- dR *DispatcherRoute
-}
-
-func (l *lazyDH) Call(ctx *context.Context, method string, args, reply any) (err error) {
- return callDH(ctx, l.dh, l.routeID, l.dR, l.cfg, l.iPRCCh, method, args, reply)
-}
-
-// newInternalHost returns an internal host as needed for internal dispatching
-func newInternalHost(tnt string) *engine.DispatcherHost {
- return &engine.DispatcherHost{
- Tenant: tnt,
- RemoteHost: &config.RemoteHost{
- ID: utils.MetaInternal,
- Address: utils.MetaInternal,
- ConnectAttempts: 1,
- Reconnects: 1,
- ConnectTimeout: time.Second,
- ReplyTimeout: time.Second,
- },
- }
-}
diff --git a/dispatchers/libdispatcher_test.go b/dispatchers/libdispatcher_test.go
deleted file mode 100644
index d0e406285..000000000
--- a/dispatchers/libdispatcher_test.go
+++ /dev/null
@@ -1,939 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "net/rpc"
- "reflect"
- "testing"
-
- "github.com/cgrates/birpc"
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
- "github.com/cgrates/rpcclient"
-)
-
-func TestLibDispatcherLoadMetricsGetHosts(t *testing.T) {
- dhp := engine.DispatcherHostProfiles{
- {ID: "DSP_1", Params: map[string]any{utils.MetaRatio: 1}},
- {ID: "DSP_2", Params: map[string]any{utils.MetaRatio: 1}},
- {ID: "DSP_3", Params: map[string]any{utils.MetaRatio: 1}},
- {ID: "DSP_4", Params: map[string]any{utils.MetaRatio: 1}},
- {ID: "DSP_5", Params: map[string]any{utils.MetaRatio: 1}},
- }
- lm, err := newLoadMetrics(dhp, 1)
- if err != nil {
- t.Fatal(err)
- }
- hostsIDs := engine.DispatcherHostIDs(dhp.HostIDs())
- // to prevent randomness we increment all loads exept the first one
- for _, hst := range hostsIDs[1:] {
- lm.incrementLoad(context.Background(), hst, utils.EmptyString)
- }
- // check only the first host because the rest may be in a random order
- // because they share the same cost
- if rply := lm.getHosts(dhp.Clone()); rply[0].ID != "DSP_1" {
- t.Errorf("Expected: %q ,received: %q", "DSP_1", rply[0].ID)
- }
- lm.incrementLoad(context.Background(), hostsIDs[0], utils.EmptyString)
- lm.decrementLoad(context.Background(), hostsIDs[1], utils.EmptyString)
- if rply := lm.getHosts(dhp.Clone()); rply[0].ID != "DSP_2" {
- t.Errorf("Expected: %q ,received: %q", "DSP_2", rply[0].ID)
- }
- for _, hst := range hostsIDs {
- lm.incrementLoad(context.Background(), hst, utils.EmptyString)
- }
- if rply := lm.getHosts(dhp.Clone()); rply[0].ID != "DSP_2" {
- t.Errorf("Expected: %q ,received: %q", "DSP_2", rply[0].ID)
- }
-}
-
-func TestLibDispatcherNewSingleDispatcher(t *testing.T) {
- dhp := engine.DispatcherHostProfiles{
- {ID: "DSP_1"},
- {ID: "DSP_2"},
- {ID: "DSP_3"},
- {ID: "DSP_4"},
- {ID: "DSP_5"},
- }
- var exp Dispatcher = &singleResultDispatcher{hosts: dhp}
- if rply, err := newSingleDispatcher(dhp, map[string]any{}, utils.EmptyString, nil); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(exp, rply) {
- t.Errorf("Expected: singleResultDispatcher structure,received: %s", utils.ToJSON(rply))
- }
-
- dhp = engine.DispatcherHostProfiles{
- {ID: "DSP_1"},
- {ID: "DSP_2"},
- {ID: "DSP_3"},
- {ID: "DSP_4"},
- {ID: "DSP_5", Params: map[string]any{utils.MetaRatio: 1}},
- }
- exp = &loadDispatcher{
- hosts: dhp,
- tntID: "cgrates.org",
- defaultRatio: 1,
- }
- if rply, err := newSingleDispatcher(dhp, map[string]any{}, "cgrates.org", nil); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(exp, rply) {
- t.Errorf("Expected: loadDispatcher structure,received: %s", utils.ToJSON(rply))
- }
-
- dhp = engine.DispatcherHostProfiles{
- {ID: "DSP_1"},
- {ID: "DSP_2"},
- {ID: "DSP_3"},
- {ID: "DSP_4"},
- }
- exp = &loadDispatcher{
- hosts: dhp,
- tntID: "cgrates.org",
- defaultRatio: 2,
- }
- if rply, err := newSingleDispatcher(dhp, map[string]any{utils.MetaDefaultRatio: 2}, "cgrates.org", nil); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(exp, rply) {
- t.Errorf("Expected: loadDispatcher structure,received: %s", utils.ToJSON(rply))
- }
-
- exp = &loadDispatcher{
- hosts: dhp,
- tntID: "cgrates.org",
- defaultRatio: 0,
- }
- if rply, err := newSingleDispatcher(dhp, map[string]any{utils.MetaDefaultRatio: 0}, "cgrates.org", nil); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(exp, rply) {
- t.Errorf("Expected: loadDispatcher structure,received: %s", utils.ToJSON(rply))
- }
-
- if _, err := newSingleDispatcher(dhp, map[string]any{utils.MetaDefaultRatio: "A"}, "cgrates.org", nil); err == nil {
- t.Fatalf("Expected error received: %v", err)
- }
-}
-
-func TestLibDispatcherNewLoadMetrics(t *testing.T) {
- dhp := engine.DispatcherHostProfiles{
- {ID: "DSP_1", Params: map[string]any{utils.MetaRatio: 1}},
- {ID: "DSP_2", Params: map[string]any{utils.MetaRatio: 0}},
- {ID: "DSP_3"},
- }
- exp := &LoadMetrics{
- HostsLoad: map[string]int64{},
- HostsRatio: map[string]int64{
- "DSP_1": 1,
- "DSP_2": 0,
- "DSP_3": 2,
- },
- }
- if lm, err := newLoadMetrics(dhp, 2); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(exp, lm) {
- t.Errorf("Expected: %s ,received: %s", utils.ToJSON(exp), utils.ToJSON(lm))
- }
- dhp = engine.DispatcherHostProfiles{
- {ID: "DSP_1", Params: map[string]any{utils.MetaRatio: "A"}},
- }
- if _, err := newLoadMetrics(dhp, 2); err == nil {
- t.Errorf("Expected error received: %v", err)
- }
-}
-
-func TestLibDispatcherLoadMetricsGetHosts2(t *testing.T) {
- dhp := engine.DispatcherHostProfiles{
- {ID: "DSP_1", Params: map[string]any{utils.MetaRatio: 2}},
- {ID: "DSP_2", Params: map[string]any{utils.MetaRatio: 3}},
- {ID: "DSP_3", Params: map[string]any{utils.MetaRatio: 1}},
- {ID: "DSP_4", Params: map[string]any{utils.MetaRatio: 5}},
- {ID: "DSP_5", Params: map[string]any{utils.MetaRatio: 1}},
- {ID: "DSP_6", Params: map[string]any{utils.MetaRatio: 0}},
- }
- lm, err := newLoadMetrics(dhp, 1)
- if err != nil {
- t.Fatal(err)
- }
- hostsIDs := engine.DispatcherHostIDs(dhp.HostIDs())
- exp := []string(hostsIDs.Clone())[:5]
- if rply := lm.getHosts(dhp.Clone()); !reflect.DeepEqual(exp, rply.HostIDs()) {
- t.Errorf("Expected: %+v ,received: %+v", exp, rply)
- }
- for i := 0; i < 100; i++ {
- for _, dh := range dhp {
- for j := int64(0); j < lm.HostsRatio[dh.ID]; j++ {
- if rply := lm.getHosts(dhp.Clone()); !reflect.DeepEqual(exp, rply.HostIDs()) {
- t.Errorf("Expected for id<%s>: %+v ,received: %+v", dh.ID, exp, rply)
- }
- lm.incrementLoad(context.Background(), dh.ID, utils.EmptyString)
- }
- exp = append(exp[1:], exp[0])
- }
- exp = []string{"DSP_1", "DSP_2", "DSP_3", "DSP_4", "DSP_5"}
- if rply := lm.getHosts(dhp.Clone()); !reflect.DeepEqual(exp, rply.HostIDs()) {
- t.Errorf("Expected: %+v ,received: %+v", exp, rply)
- }
- lm.decrementLoad(context.Background(), "DSP_4", utils.EmptyString)
- lm.decrementLoad(context.Background(), "DSP_4", utils.EmptyString)
- lm.decrementLoad(context.Background(), "DSP_2", utils.EmptyString)
- exp = []string{"DSP_2", "DSP_4", "DSP_1", "DSP_3", "DSP_5"}
- if rply := lm.getHosts(dhp.Clone()); !reflect.DeepEqual(exp, rply.HostIDs()) {
- t.Errorf("Expected: %+v ,received: %+v", exp, rply)
- }
- lm.incrementLoad(context.Background(), "DSP_2", utils.EmptyString)
-
- exp = []string{"DSP_4", "DSP_1", "DSP_2", "DSP_3", "DSP_5"}
- if rply := lm.getHosts(dhp.Clone()); !reflect.DeepEqual(exp, rply.HostIDs()) {
- t.Errorf("Expected: %+v ,received: %+v", exp, rply)
- }
- lm.incrementLoad(context.Background(), "DSP_4", utils.EmptyString)
-
- if rply := lm.getHosts(dhp.Clone()); !reflect.DeepEqual(exp, rply.HostIDs()) {
- t.Errorf("Expected: %+v ,received: %+v", exp, rply)
- }
- lm.incrementLoad(context.Background(), "DSP_4", utils.EmptyString)
- exp = []string{"DSP_1", "DSP_2", "DSP_3", "DSP_4", "DSP_5"}
- if rply := lm.getHosts(dhp.Clone()); !reflect.DeepEqual(exp, rply.HostIDs()) {
- t.Errorf("Expected: %+v ,received: %+v", exp, rply)
- }
- }
-
- dhp = engine.DispatcherHostProfiles{
- {ID: "DSP_1", Params: map[string]any{utils.MetaRatio: -1}},
- {ID: "DSP_2", Params: map[string]any{utils.MetaRatio: 3}},
- {ID: "DSP_3", Params: map[string]any{utils.MetaRatio: 1}},
- {ID: "DSP_4", Params: map[string]any{utils.MetaRatio: 5}},
- {ID: "DSP_5", Params: map[string]any{utils.MetaRatio: 1}},
- {ID: "DSP_6", Params: map[string]any{utils.MetaRatio: 0}},
- }
- lm, err = newLoadMetrics(dhp, 1)
- if err != nil {
- t.Fatal(err)
- }
- hostsIDs = engine.DispatcherHostIDs(dhp.HostIDs())
- exp = []string(hostsIDs.Clone())[:5]
- if rply := lm.getHosts(dhp.Clone()); !reflect.DeepEqual(exp, rply.HostIDs()) {
- t.Errorf("Expected: %+v ,received: %+v", exp, rply)
- }
- for i := 0; i < 100; i++ {
- if rply := lm.getHosts(dhp.Clone()); !reflect.DeepEqual(exp, rply.HostIDs()) {
- t.Errorf("Expected: %+v ,received: %+v", exp, rply)
- }
- lm.incrementLoad(context.Background(), exp[0], utils.EmptyString)
- }
-}
-
-func TestLibDispatcherNewDispatcherMetaWeight(t *testing.T) {
- pfl := &engine.DispatcherProfile{
- Hosts: engine.DispatcherHostProfiles{},
- Strategy: utils.MetaWeight,
- }
- result, err := newDispatcher(pfl)
- if err != nil {
- t.Errorf("\nExpected , \nReceived <%+v>", err)
- }
- expected := &singleResultDispatcher{
- hosts: engine.DispatcherHostProfiles{},
- sorter: new(noSort),
- }
- if !reflect.DeepEqual(result.(*singleResultDispatcher).hosts, expected.hosts) {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected.hosts, result.(*singleResultDispatcher).hosts)
- }
- if !reflect.DeepEqual(result.(*singleResultDispatcher).sorter, expected.sorter) {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", result.(*singleResultDispatcher).sorter, expected.sorter)
- }
-}
-
-func TestLibDispatcherNewDispatcherMetaWeightErr(t *testing.T) {
- pfl := &engine.DispatcherProfile{
- Hosts: engine.DispatcherHostProfiles{},
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: false,
- },
- Strategy: utils.MetaWeight,
- }
- _, err := newDispatcher(pfl)
- expected := "cannot convert field: false to int"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-
-}
-
-func TestLibDispatcherNewDispatcherMetaRandom(t *testing.T) {
- pfl := &engine.DispatcherProfile{
- Hosts: engine.DispatcherHostProfiles{},
- Strategy: utils.MetaRandom,
- }
- result, err := newDispatcher(pfl)
- if err != nil {
- t.Errorf("\nExpected , \nReceived <%+v>", err)
- }
- expected := &singleResultDispatcher{
- hosts: engine.DispatcherHostProfiles{},
- sorter: new(randomSort),
- }
- if !reflect.DeepEqual(result.(*singleResultDispatcher).sorter, expected.sorter) {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected.sorter, result.(*singleResultDispatcher).sorter)
- }
- if !reflect.DeepEqual(result.(*singleResultDispatcher).hosts, expected.hosts) {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected.hosts, result.(*singleResultDispatcher).hosts)
- }
-}
-
-func TestLibDispatcherNewDispatcherMetaRandomErr(t *testing.T) {
- pfl := &engine.DispatcherProfile{
- Hosts: engine.DispatcherHostProfiles{},
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: false,
- },
- Strategy: utils.MetaRandom,
- }
- _, err := newDispatcher(pfl)
- expected := "cannot convert field: false to int"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-
-}
-
-func TestLibDispatcherNewDispatcherMetaRoundRobin(t *testing.T) {
- pfl := &engine.DispatcherProfile{
- Hosts: engine.DispatcherHostProfiles{},
- Strategy: utils.MetaRoundRobin,
- }
- result, err := newDispatcher(pfl)
- if err != nil {
- t.Errorf("\nExpected , \nReceived <%+v>", err)
- }
- expected := &singleResultDispatcher{
- hosts: engine.DispatcherHostProfiles{},
- sorter: new(roundRobinSort),
- }
- if !reflect.DeepEqual(result.(*singleResultDispatcher).sorter, expected.sorter) {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected.sorter, result.(*singleResultDispatcher).sorter)
- }
- if !reflect.DeepEqual(result.(*singleResultDispatcher).hosts, expected.hosts) {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected.hosts, result.(*singleResultDispatcher).hosts)
- }
-}
-
-func TestLibDispatcherNewDispatcherMetaRoundRobinErr(t *testing.T) {
- pfl := &engine.DispatcherProfile{
- Hosts: engine.DispatcherHostProfiles{},
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: false,
- },
- Strategy: utils.MetaRoundRobin,
- }
- _, err := newDispatcher(pfl)
- expected := "cannot convert field: false to int"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-
-}
-
-func TestLibDispatcherNewDispatcherPoolBroadcast(t *testing.T) {
- pfl := &engine.DispatcherProfile{
- Hosts: engine.DispatcherHostProfiles{},
- Strategy: rpcclient.PoolBroadcast,
- }
- result, err := newDispatcher(pfl)
- if err != nil {
- t.Errorf("\nExpected , \nReceived <%+v>", err)
- }
- expected := &broadcastDispatcher{
- hosts: engine.DispatcherHostProfiles{},
- strategy: pfl.Strategy,
- }
- if !reflect.DeepEqual(result.(*broadcastDispatcher).strategy, expected.strategy) {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected.strategy, result.(*broadcastDispatcher).strategy)
- }
- if !reflect.DeepEqual(result.(*broadcastDispatcher).hosts, expected.hosts) {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected.hosts, result.(*broadcastDispatcher).hosts)
- }
-}
-
-func TestLibDispatcherNewDispatcherError(t *testing.T) {
- pfl := &engine.DispatcherProfile{
- Hosts: engine.DispatcherHostProfiles{},
- Strategy: "badStrategy",
- }
- expected := "unsupported dispatch strategy: "
- _, err := newDispatcher(pfl)
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-
-}
-
-func TestLibDispatcherSingleResultDispatcherDispatch(t *testing.T) {
- wgDsp := &singleResultDispatcher{sorter: new(noSort)}
- dM := engine.NewDataManager(engine.NewInternalDB(nil, nil, config.CgrConfig().DataDbCfg().Items), config.CgrConfig().CacheCfg(), nil)
- err := wgDsp.Dispatch(dM, nil, config.CgrConfig(), context.Background(), nil, nil, "", "", &DispatcherRoute{}, "", "", "")
- expected := "DSP_HOST_NOT_FOUND"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestLibDispatcherSingleResultDispatcherDispatchRouteID(t *testing.T) {
- wgDsp := &singleResultDispatcher{sorter: new(roundRobinSort)}
- dM := engine.NewDataManager(engine.NewInternalDB(nil, nil, config.CgrConfig().DataDbCfg().Items), config.CgrConfig().CacheCfg(), nil)
- err := wgDsp.Dispatch(dM, nil, config.CgrConfig(), context.Background(), nil, nil, "", "routeID", &DispatcherRoute{}, "", "", "")
- expected := "DSP_HOST_NOT_FOUND"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestLibDispatcherBroadcastDispatcherDispatch(t *testing.T) {
- wgDsp := &broadcastDispatcher{hosts: engine.DispatcherHostProfiles{{ID: "testID"}}}
- dM := engine.NewDataManager(engine.NewInternalDB(nil, nil, config.CgrConfig().DataDbCfg().Items), config.CgrConfig().CacheCfg(), nil)
- err := wgDsp.Dispatch(dM, nil, config.CgrConfig(), context.Background(), nil, nil, "", "", &DispatcherRoute{}, "", "", "")
- expected := "DSP_HOST_NOT_FOUND"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestLibDispatcherBroadcastDispatcherDispatchRouteID(t *testing.T) {
- wgDsp := &broadcastDispatcher{hosts: engine.DispatcherHostProfiles{{ID: "testID"}}}
- dM := engine.NewDataManager(engine.NewInternalDB(nil, nil, config.CgrConfig().DataDbCfg().Items), config.CgrConfig().CacheCfg(), nil)
- err := wgDsp.Dispatch(dM, nil, config.CgrConfig(), context.Background(), nil, nil, "", "routeID", &DispatcherRoute{}, "", "", "")
- expected := "DSP_HOST_NOT_FOUND"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestLibDispatcherLoadDispatcherDispatch(t *testing.T) {
- wgDsp := &loadDispatcher{sorter: new(randomSort)}
- dM := engine.NewDataManager(engine.NewInternalDB(nil, nil, config.CgrConfig().DataDbCfg().Items), config.CgrConfig().CacheCfg(), nil)
- err := wgDsp.Dispatch(dM, nil, config.CgrConfig(), context.Background(), nil, nil, "", "", &DispatcherRoute{}, "", "", "")
- expected := "DSP_HOST_NOT_FOUND"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestLibDispatcherLoadDispatcherDispatchHostsID(t *testing.T) {
- wgDsp := &loadDispatcher{
- hosts: engine.DispatcherHostProfiles{
- {ID: "hostID1"},
- {ID: "hostID2"},
- },
- sorter: new(noSort),
- }
- dM := engine.NewDataManager(engine.NewInternalDB(nil, nil, config.CgrConfig().DataDbCfg().Items), config.CgrConfig().CacheCfg(), nil)
- err := wgDsp.Dispatch(dM, nil, config.CgrConfig(), context.Background(), nil, nil, "", "routeID", &DispatcherRoute{}, "", "", "")
- expected := "DSP_HOST_NOT_FOUND"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestLibDispatcherLoadStrategyDispatchCaseCallError(t *testing.T) {
- wgDsp := &loadDispatcher{
- hosts: engine.DispatcherHostProfiles{
- {
- ID: "hostID",
- },
- },
- defaultRatio: 1,
- sorter: new(noSort),
- }
- err := wgDsp.Dispatch(nil, nil, config.CgrConfig(), context.Background(), nil, nil, "", "", &DispatcherRoute{}, "", "", "")
- expected := "NO_DATABASE_CONNECTION"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestLibDispatcherLoadStrategyDispatchCaseHostsCastError(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- newCache := engine.NewCacheS(cfg, nil, nil, nil)
- engine.Cache = newCache
- engine.Cache.SetWithoutReplicate(utils.CacheDispatcherLoads, "testID",
- false, nil, true, utils.NonTransactional)
- wgDsp := &loadDispatcher{
- tntID: "testID",
- hosts: engine.DispatcherHostProfiles{
- {
- ID: "testID",
- // FilterIDs: []string{"filterID"},
- Weight: 4,
- Params: map[string]any{
- utils.MetaRatio: 1,
- },
- Blocker: false,
- },
- },
- defaultRatio: 1,
- sorter: new(noSort),
- }
- err := wgDsp.Dispatch(nil, nil, config.CgrConfig(), context.Background(), nil, nil, "", "", &DispatcherRoute{}, "", "", "")
- expected := "cannot cast false to *LoadMetrics"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
- engine.Cache = cacheInit
-}
-
-func TestLibDispatcherLoadStrategyDispatchCaseHostsCastError2(t *testing.T) {
- wgDsp := &loadDispatcher{
- tntID: "testID",
- hosts: engine.DispatcherHostProfiles{
- {
- ID: "testID",
- // FilterIDs: []string{"filterID"},
- Weight: 4,
- Params: map[string]any{
- utils.MetaRatio: false,
- },
- Blocker: false,
- },
- },
- defaultRatio: 1,
- sorter: new(noSort),
- }
- err := wgDsp.Dispatch(nil, nil, config.CgrConfig(), context.Background(), nil, nil, "", "", &DispatcherRoute{}, "", "", "")
- expected := "cannot convert field: false to int"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
-}
-
-func TestLibDispatcherSingleResultDispatcherCastError(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- dm := engine.NewDataManager(nil, nil, nil)
- newCache := engine.NewCacheS(cfg, dm, nil, nil)
- engine.Cache = newCache
- value := &engine.DispatcherHost{
- Tenant: "testTenant",
- RemoteHost: &config.RemoteHost{
- ID: "testID",
- Address: "",
- Transport: "",
- TLS: false,
- },
- }
- engine.Cache.SetWithoutReplicate(utils.CacheDispatcherRoutes, "testID:*attributes",
- value, nil, true, utils.NonTransactional)
- wgDsp := &singleResultDispatcher{sorter: new(noSort), hosts: engine.DispatcherHostProfiles{{ID: "testID"}}}
- err := wgDsp.Dispatch(nil, nil, config.CgrConfig(), context.Background(), nil, nil, "", "testID", &DispatcherRoute{}, "", "", "")
- expected := "NO_DATABASE_CONNECTION"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
- engine.Cache = cacheInit
-}
-
-type mockTypeCon struct{}
-
-func (*mockTypeCon) Call(ctx *context.Context, method string, args any, reply any) error {
- return utils.ErrNotFound
-}
-
-func TestLibDispatcherBroadcastDispatcherDispatchError1(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- dm := engine.NewDataManager(nil, nil, nil)
- newCache := engine.NewCacheS(cfg, dm, nil, nil)
- engine.Cache = newCache
- value := &engine.DispatcherHost{
- Tenant: "testTenant",
- RemoteHost: &config.RemoteHost{
- ID: "testID",
- Address: "",
- Transport: "",
- TLS: false,
- },
- }
- engine.Cache.SetWithoutReplicate(utils.CacheDispatcherRoutes, "testID:*attributes",
- value, nil, true, utils.NonTransactional)
- wgDsp := &broadcastDispatcher{hosts: engine.DispatcherHostProfiles{{ID: "testID"}}}
- err := wgDsp.Dispatch(nil, nil, cfg, context.Background(), nil, nil, "testTenant", "testID", &DispatcherRoute{}, "", "", "")
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
- engine.Cache = cacheInit
-}
-
-func TestLibDispatcherBroadcastDispatcherDispatchError2(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- dm := engine.NewDataManager(nil, nil, nil)
- newCache := engine.NewCacheS(cfg, dm, nil, nil)
- engine.Cache = newCache
-
- engine.Cache.SetWithoutReplicate(utils.CacheDispatcherHosts, "testTenant:testID",
- nil, nil, true, utils.NonTransactional)
- wgDsp := &broadcastDispatcher{hosts: engine.DispatcherHostProfiles{{ID: "testID"}}}
- err := wgDsp.Dispatch(nil, nil, cfg, context.Background(), nil, nil, "testTenant", "testID", &DispatcherRoute{}, "", "", "")
- expected := "DSP_HOST_NOT_FOUND"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
- engine.Cache = cacheInit
-}
-
-func TestLibDispatcherBroadcastDispatcherDispatchError3(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- dm := engine.NewDataManager(nil, nil, nil)
- newCache := engine.NewCacheS(cfg, dm, nil, nil)
- engine.Cache = newCache
- value := &engine.DispatcherHost{
- Tenant: "testTenant",
- RemoteHost: &config.RemoteHost{
- ID: "testID",
- Address: "",
- Transport: "",
- TLS: false,
- },
- }
- engine.Cache.SetWithoutReplicate(utils.CacheDispatcherHosts, "testTenant:testID",
- value, nil, true, utils.NonTransactional)
- wgDsp := &broadcastDispatcher{hosts: engine.DispatcherHostProfiles{{ID: "testID"}}}
- err := wgDsp.Dispatch(nil, nil, cfg, context.Background(), nil, nil, "testTenant", "testID", &DispatcherRoute{}, "", "", "")
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- engine.Cache = cacheInit
-}
-
-func TestLibDispatcherLoadDispatcherCacheError4(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- cfg.CacheCfg().ReplicationConns = []string{"con"}
- cfg.CacheCfg().RemoteConns = []string{"con1"}
- cfg.CacheCfg().Partitions[utils.CacheDispatcherRoutes].Replicate = true
- cfg.CacheCfg().Partitions[utils.CacheDispatcherRoutes].Remote = true
- cfg.RPCConns()["con"] = &config.RPCConn{
- Strategy: "",
- PoolSize: 0,
- Conns: []*config.RemoteHost{
- {
- ID: "testID",
- Address: "",
- Transport: "",
- TLS: false,
- },
- },
- }
- cfg.RPCConns()["con1"] = &config.RPCConn{
- Strategy: "*first",
- PoolSize: 0,
- Conns: []*config.RemoteHost{
- {
- ID: "conn_internal",
- Address: "*internal",
- Transport: "",
- TLS: false,
- },
- },
- }
- connMng := engine.NewConnManager(cfg)
- dataDB := engine.NewInternalDB(nil, nil, nil)
- dm := engine.NewDataManager(dataDB, nil, connMng)
-
- newCache := engine.NewCacheS(cfg, dm, connMng, nil)
- engine.Cache = newCache
- value := &engine.DispatcherHost{
- Tenant: "testTenant",
- RemoteHost: &config.RemoteHost{
- ID: "testID",
- Address: rpcclient.InternalRPC,
- Transport: utils.MetaInternal,
- TLS: false,
- },
- }
-
- engine.Cache.SetWithoutReplicate(utils.CacheDispatcherHosts, "testTENANT:testID",
- value, nil, true, utils.NonTransactional)
- wgDsp := &loadDispatcher{
- tntID: "testTENANT",
- hosts: engine.DispatcherHostProfiles{
- {
- ID: "testID",
- // FilterIDs: []string{"filterID1", "filterID2"},
- Weight: 3,
- Params: map[string]any{
- utils.MetaRatio: 1,
- },
- Blocker: true,
- },
- {
- ID: "testID2",
- // FilterIDs: []string{"filterID1", "filterID2"},
- Weight: 3,
- Params: map[string]any{
- utils.MetaRatio: 2,
- },
- Blocker: true,
- },
- },
- defaultRatio: 0,
- sorter: new(noSort),
- }
- err := wgDsp.Dispatch(dm, nil, cfg, context.Background(), nil, nil, "testTENANT", "testID", &DispatcherRoute{}, utils.AttributeSv1Ping, &utils.CGREvent{}, &wgDsp)
- expected := "INTERNALLY_DISCONNECTED"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
- engine.Cache = cacheInit
-}
-
-type mockTypeConDispatch struct{}
-
-func (*mockTypeConDispatch) Call(ctx *context.Context, serviceMethod string, args, reply any) error {
- return rpc.ErrShutdown
-}
-
-func TestLibDispatcherLoadDispatcherCacheError5(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
-
- dm := engine.NewDataManager(nil, nil, nil)
- newCache := engine.NewCacheS(cfg, dm, nil, nil)
- engine.Cache = newCache
- value := &engine.DispatcherHost{
- Tenant: "testTenant",
- RemoteHost: &config.RemoteHost{
- ID: "testID",
- Address: rpcclient.InternalRPC,
- Transport: utils.MetaInternal,
- TLS: false,
- },
- }
-
- chanRPC := make(chan birpc.ClientConnector, 1)
- chanRPC <- new(mockTypeConDispatch)
- engine.Cache.SetWithoutReplicate(utils.CacheDispatcherHosts, "testTenant:testID",
- value, nil, true, utils.NonTransactional)
- wgDsp := &loadDispatcher{
- tntID: "testTenant",
- hosts: engine.DispatcherHostProfiles{
- {
- ID: "testID",
- Weight: 3,
- Params: map[string]any{
- utils.MetaRatio: 1,
- },
- Blocker: true,
- },
- },
- defaultRatio: 0,
- sorter: new(noSort),
- }
- err := wgDsp.Dispatch(nil, nil, cfg, context.Background(), chanRPC, nil, "testTenant", "testID", &DispatcherRoute{}, utils.AttributeSv1Ping, &utils.CGREvent{}, &wgDsp)
- if err == nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", "connection is shut down", err)
- }
- engine.Cache = cacheInit
-}
-func TestLibDispatcherSingleResultDispatcherCase1(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- dm := engine.NewDataManager(nil, nil, nil)
- newCache := engine.NewCacheS(cfg, dm, nil, nil)
- engine.Cache = newCache
- value := &engine.DispatcherHost{
- Tenant: "testTenant",
- RemoteHost: &config.RemoteHost{
- ID: "testID",
- Address: rpcclient.InternalRPC,
- Transport: utils.MetaInternal,
- TLS: false,
- },
- }
- chanRPC := make(chan birpc.ClientConnector, 1)
- chanRPC <- new(mockTypeConDispatch)
- engine.Cache.SetWithoutReplicate(utils.CacheDispatcherHosts, "testTenant:testID",
- value, nil, true, utils.NonTransactional)
- wgDsp := &singleResultDispatcher{sorter: new(noSort), hosts: engine.DispatcherHostProfiles{{ID: "testID"}}}
- err := wgDsp.Dispatch(dm, nil, cfg, context.Background(), chanRPC, nil, "testTenant", "", &DispatcherRoute{}, utils.AttributeSv1Ping, &utils.CGREvent{}, &wgDsp)
- if err == nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", "connection is shut down", err)
- }
- engine.Cache = cacheInit
-}
-
-type mockTypeConDispatch2 struct{}
-
-func (*mockTypeConDispatch2) Call(ctx *context.Context, serviceMethod string, args, reply any) error {
- return nil
-}
-
-func TestLibDispatcherSingleResultDispatcherCase2(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- dm := engine.NewDataManager(nil, nil, nil)
- newCache := engine.NewCacheS(cfg, dm, nil, nil)
- engine.Cache = newCache
- value := &engine.DispatcherHost{
- Tenant: "testTenant",
- RemoteHost: &config.RemoteHost{
- ID: "testID",
- Address: rpcclient.InternalRPC,
- Transport: utils.MetaInternal,
- TLS: false,
- },
- }
- chanRPC := make(chan birpc.ClientConnector, 1)
- chanRPC <- new(mockTypeConDispatch2)
- engine.Cache.SetWithoutReplicate(utils.CacheDispatcherHosts, "testTenant:testID",
- value, nil, true, utils.NonTransactional)
- wgDsp := &singleResultDispatcher{sorter: new(noSort), hosts: engine.DispatcherHostProfiles{{ID: "testID"}}}
- err := wgDsp.Dispatch(dm, nil, cfg, context.Background(), chanRPC, nil, "testTenant", "routeID", &DispatcherRoute{}, utils.AttributeSv1Ping, &utils.CGREvent{}, &wgDsp)
- if err != nil {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
- }
- engine.Cache = cacheInit
-}
-
-func TestLibDispatcherSingleResultDispatcherCase3(t *testing.T) {
- cacheInit := engine.Cache
- cfg := config.NewDefaultCGRConfig()
- cfg.CacheCfg().ReplicationConns = []string{"con"}
- cfg.CacheCfg().Partitions[utils.CacheDispatcherRoutes].Replicate = true
- cfg.RPCConns()["con"] = &config.RPCConn{
- Strategy: "",
- PoolSize: 0,
- Conns: []*config.RemoteHost{
- {
- ID: "testID",
- Address: "",
- Transport: "",
- TLS: false,
- },
- },
- }
- connMng := engine.NewConnManager(cfg)
- dm := engine.NewDataManager(nil, nil, connMng)
- newCache := engine.NewCacheS(cfg, dm, connMng, nil)
- engine.Cache = newCache
- value := &engine.DispatcherHost{
- Tenant: "testTenant",
- RemoteHost: &config.RemoteHost{
- ID: "testID",
- Address: "",
- Transport: utils.MetaInternal,
- TLS: false,
- },
- }
- chanRPC := make(chan birpc.ClientConnector, 1)
- chanRPC <- new(mockTypeConDispatch2)
- engine.Cache.SetWithoutReplicate(utils.CacheDispatcherHosts, "testTenant:testID",
- value, nil, true, utils.NonTransactional)
- wgDsp := &singleResultDispatcher{sorter: new(noSort), hosts: engine.DispatcherHostProfiles{{ID: "testID"}}}
- err := wgDsp.Dispatch(dm, nil, cfg, context.Background(), chanRPC, nil, "testTenant", "routeID", &DispatcherRoute{}, utils.AttributeSv1Ping, &utils.CGREvent{}, &wgDsp)
- expected := "INTERNALLY_DISCONNECTED"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
- }
- engine.Cache = cacheInit
-}
-
-func TestLibDispatcherDispatchFilterError(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- flts := engine.NewFilterS(cfg, nil, nil)
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- var dsp Dispatcher = &singleResultDispatcher{
- sorter: new(noSort),
- hosts: engine.DispatcherHostProfiles{{
- ID: "testID",
- FilterIDs: []string{"*wrongType"},
- }},
- }
- expErrMsg := "inline parse error for string: <*wrongType>"
- if err := dsp.Dispatch(dm, flts, cfg, context.Background(), nil, nil, "", "", &DispatcherRoute{}, "", "", ""); err == nil || err.Error() != expErrMsg {
- t.Errorf("Expected error: %s received: %v", expErrMsg, err)
- }
- dsp = &loadDispatcher{
- sorter: new(noSort),
- hosts: engine.DispatcherHostProfiles{{
- ID: "testID2",
- FilterIDs: []string{"*wrongType"},
- }},
- defaultRatio: 1,
- }
- if err := dsp.Dispatch(dm, flts, cfg, context.Background(), nil, nil, "", "", &DispatcherRoute{}, "", "", ""); err == nil || err.Error() != expErrMsg {
- t.Errorf("Expected error: %s received: %v", expErrMsg, err)
- }
- dsp = &broadcastDispatcher{
- hosts: engine.DispatcherHostProfiles{{
- ID: "testID",
- FilterIDs: []string{"*wrongType"},
- }},
- }
- if err := dsp.Dispatch(dm, flts, cfg, context.Background(), nil, nil, "", "", &DispatcherRoute{}, "", "", ""); err == nil || err.Error() != expErrMsg {
- t.Errorf("Expected error: %s received: %v", expErrMsg, err)
- }
-}
-
-func TestLibDispatcherRandomSort(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- flts := engine.NewFilterS(cfg, nil, nil)
- sorter := new(randomSort)
- hosts := engine.DispatcherHostProfiles{
- {ID: "testID1"},
- {ID: "testID2"},
- }
-
- expHostIDs1 := engine.DispatcherHostIDs{"testID1", "testID2"}
- expHostIDs2 := engine.DispatcherHostIDs{"testID2", "testID1"}
- if hostIDs, err := sorter.Sort(flts, nil, context.Background(), "", hosts); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expHostIDs1, hostIDs) &&
- !reflect.DeepEqual(expHostIDs2, hostIDs) {
- t.Errorf("Expected: %q or %q, received: %q", expHostIDs1, expHostIDs2, hostIDs)
- }
-}
-
-func TestLibDispatcherRoundRobinSort(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- flts := engine.NewFilterS(cfg, nil, nil)
- sorter := new(roundRobinSort)
- hosts := engine.DispatcherHostProfiles{
- {ID: "testID1"},
- {ID: "testID2"},
- }
-
- expHostIDs1 := engine.DispatcherHostIDs{"testID1", "testID2"}
- if hostIDs, err := sorter.Sort(flts, nil, context.Background(), "", hosts); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expHostIDs1, hostIDs) {
- t.Errorf("Expected: %q, received: %q", expHostIDs1, hostIDs)
- }
- expHostIDs2 := engine.DispatcherHostIDs{"testID2", "testID1"}
- if hostIDs, err := sorter.Sort(flts, nil, context.Background(), "", hosts); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expHostIDs2, hostIDs) {
- t.Errorf("Expected: %q, received: %q", expHostIDs2, hostIDs)
- }
-}
diff --git a/dispatchers/loaders.go b/dispatchers/loaders.go
deleted file mode 100644
index a5699c751..000000000
--- a/dispatchers/loaders.go
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/loaders"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) LoaderSv1ImportZip(ctx *context.Context, args *loaders.ArgsProcessZip, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaLoaders, utils.LoaderSv1ImportZip, args, reply)
-}
-func (dS *DispatcherService) LoaderSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaLoaders, utils.LoaderSv1Ping, args, reply)
-}
-func (dS *DispatcherService) LoaderSv1Run(ctx *context.Context, args *loaders.ArgsProcessFolder, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaLoaders, utils.LoaderSv1Run, args, reply)
-}
diff --git a/dispatchers/rankings.go b/dispatchers/rankings.go
deleted file mode 100644
index 317d05c7a..000000000
--- a/dispatchers/rankings.go
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) RankingSv1GetRanking(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.Ranking) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaRankings, utils.RankingSv1GetRanking, args, reply)
-}
-func (dS *DispatcherService) RankingSv1GetRankingSummary(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.RankingSummary) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaRankings, utils.RankingSv1GetRankingSummary, args, reply)
-}
-func (dS *DispatcherService) RankingSv1GetSchedule(ctx *context.Context, args *utils.ArgScheduledRankings, reply *[]utils.ScheduledRanking) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantIDWithAPIOpts.TenantID != nil && len(args.TenantIDWithAPIOpts.TenantID.Tenant) != 0) {
- tnt = args.TenantIDWithAPIOpts.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.TenantIDWithAPIOpts.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaRankings, utils.RankingSv1GetSchedule, args, reply)
-}
-func (dS *DispatcherService) RankingSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaRankings, utils.RankingSv1Ping, args, reply)
-}
-func (dS *DispatcherService) RankingSv1ScheduleQueries(ctx *context.Context, args *utils.ArgScheduleRankingQueries, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantIDWithAPIOpts.TenantID != nil && len(args.TenantIDWithAPIOpts.TenantID.Tenant) != 0) {
- tnt = args.TenantIDWithAPIOpts.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.TenantIDWithAPIOpts.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaRankings, utils.RankingSv1ScheduleQueries, args, reply)
-}
diff --git a/dispatchers/rates.go b/dispatchers/rates.go
deleted file mode 100644
index c29560599..000000000
--- a/dispatchers/rates.go
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) RateSv1CostForEvent(ctx *context.Context, args *utils.CGREvent, reply *utils.RateProfileCost) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.RateS, utils.RateSv1CostForEvent, args, reply)
-}
-func (dS *DispatcherService) RateSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.RateS, utils.RateSv1Ping, args, reply)
-}
-func (dS *DispatcherService) RateSv1RateProfileRatesForEvent(ctx *context.Context, args *utils.CGREventWithRateProfile, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.CGREvent != nil && len(args.CGREvent.Tenant) != 0) {
- tnt = args.CGREvent.Tenant
- }
- ev := make(map[string]any)
- if args != nil && args.CGREvent != nil {
- ev = args.CGREvent.Event
- }
- opts := make(map[string]any)
- if args != nil && args.CGREvent != nil {
- opts = args.CGREvent.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.RateS, utils.RateSv1RateProfileRatesForEvent, args, reply)
-}
-func (dS *DispatcherService) RateSv1RateProfilesForEvent(ctx *context.Context, args *utils.CGREvent, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.RateS, utils.RateSv1RateProfilesForEvent, args, reply)
-}
diff --git a/dispatchers/rates_it_test.go b/dispatchers/rates_it_test.go
deleted file mode 100644
index 590bcc4b5..000000000
--- a/dispatchers/rates_it_test.go
+++ /dev/null
@@ -1,243 +0,0 @@
-//go:build flaky
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
- "time"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/utils"
-)
-
-var sTestsDspRPrf = []func(t *testing.T){
- testDspRPrfPing,
- testDspRPrfCostForEvent,
- testDspRPrfCostForEventWithoutFilters,
-}
-
-// Test start here
-func TestDspRateSIT(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- }
- testDsp(t, sTestsDspRPrf, "TestDspRateSIT", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
-}
-
-func testDspRPrfPing(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.RateSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.RateSv1Ping, utils.CGREvent{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "rPrf12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
-
-func testDspRPrfCostForEvent(t *testing.T) {
- rPrf := &utils.APIRateProfile{
- RateProfile: &utils.RateProfile{
- ID: "DefaultRate",
- Tenant: "cgrates.org",
- FilterIDs: []string{"*string:~*req.Subject:1001"},
- Weights: utils.DynamicWeights{
- {
- Weight: 0,
- },
- },
- Rates: map[string]*utils.Rate{
- "RT_WEEK": {
- ID: "RT_WEEK",
- Weights: utils.DynamicWeights{
- {
- Weight: 0,
- },
- },
- ActivationTimes: "* * * * *",
- IntervalRates: []*utils.IntervalRate{
- {
- IntervalStart: utils.NewDecimal(0, 0),
- RecurrentFee: utils.NewDecimal(12, 2),
- Unit: utils.NewDecimal(int64(time.Minute), 0),
- Increment: utils.NewDecimal(int64(time.Minute), 0),
- },
- },
- },
- },
- },
- }
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.AdminSv1SetRateProfile, rPrf, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Errorf("Expected OK, received %+v", reply)
- }
- var rply *utils.RateProfile
- if err := allEngine.RPC.Call(context.Background(), utils.AdminSv1GetRateProfile, &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "DefaultRate",
- }, &rply); err != nil {
- t.Error(err)
- }
-
- exp := &utils.RateProfileCost{
- ID: "DefaultRate",
- Cost: utils.NewDecimal(12, 2),
- CostIntervals: []*utils.RateSIntervalCost{{
- Increments: []*utils.RateSIncrementCost{{
- Usage: utils.NewDecimal(int64(time.Minute), 0),
- RateID: "ec268a8",
- CompressFactor: 1,
- }},
- CompressFactor: 1,
- }},
- Rates: map[string]*utils.IntervalRate{"ec268a8": {
- IntervalStart: utils.NewDecimal(0, 0),
- RecurrentFee: utils.NewDecimalFromFloat64(0.12),
- Unit: utils.NewDecimal(60000000000, 0),
- Increment: utils.NewDecimal(60000000000, 0),
- }},
- }
-
- var rpCost *utils.RateProfileCost
- if err := dispEngine.RPC.Call(context.Background(), utils.RateSv1CostForEvent, &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "DefaultRate",
- Event: map[string]any{
- utils.Subject: "1001",
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "rPrf12345",
- }}, &rpCost); err != nil {
- t.Error(err)
- } else if !rpCost.Equals(exp) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(exp), utils.ToJSON(rpCost))
- }
-}
-
-func testDspRPrfCostForEventWithoutFilters(t *testing.T) {
- rPrf := &utils.APIRateProfile{
- RateProfile: &utils.RateProfile{
- ID: "ID_RP",
- Tenant: "cgrates.org",
- Weights: utils.DynamicWeights{
- {
- Weight: 10,
- },
- },
- Rates: map[string]*utils.Rate{
- "RT_WEEK": {
- ID: "RT_WEEK",
- Weights: utils.DynamicWeights{
- {
- Weight: 0,
- },
- },
- ActivationTimes: "* * * * *",
- IntervalRates: []*utils.IntervalRate{
- {
- IntervalStart: utils.NewDecimal(0, 0),
- RecurrentFee: utils.NewDecimal(25, 2),
- Unit: utils.NewDecimal(int64(time.Minute), 0),
- Increment: utils.NewDecimal(int64(time.Second), 0),
- },
- },
- },
- },
- },
- }
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.AdminSv1SetRateProfile, rPrf, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Errorf("Expected OK, received %+v", reply)
- }
- var rply *utils.RateProfile
- if err := allEngine.RPC.Call(context.Background(), utils.AdminSv1GetRateProfile, &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "ID_RP",
- }, &rply); err != nil {
- t.Error(err)
- }
-
- exp := &utils.RateProfileCost{
- ID: "ID_RP",
- Cost: utils.NewDecimal(25, 2),
- CostIntervals: []*utils.RateSIntervalCost{{
- Increments: []*utils.RateSIncrementCost{{
- Usage: utils.NewDecimal(int64(time.Minute), 0),
- RateID: "ec268a8",
- CompressFactor: 60,
- }},
- CompressFactor: 1,
- }},
- Rates: map[string]*utils.IntervalRate{"ec268a8": {
- IntervalStart: utils.NewDecimal(0, 0),
- RecurrentFee: utils.NewDecimalFromFloat64(0.25),
- Unit: utils.NewDecimal(60000000000, 0),
- Increment: utils.NewDecimal(1000000000, 0),
- }},
- }
-
- var rpCost *utils.RateProfileCost
- if err := dispEngine.RPC.Call(context.Background(), utils.RateSv1CostForEvent, &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "EVENT_RATE",
- Event: map[string]any{
- utils.Subject: "1002",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "rPrf12345",
- }}, &rpCost); err != nil {
- t.Error(err)
- } else if !rpCost.Equals(exp) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(exp), utils.ToJSON(rpCost))
- }
-}
diff --git a/dispatchers/rates_test.go b/dispatchers/rates_test.go
deleted file mode 100644
index 84955dd11..000000000
--- a/dispatchers/rates_test.go
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDspRateSv1PingErrorCase2(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.RateSv1Ping(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspRateSv1PingErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.RateSv1Ping(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspRateSv1CostForEventCaseNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.RateSv1Ping(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspRateSv1CostForEventCase2(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *utils.RateProfileCost
- result := dspSrv.RateSv1CostForEvent(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspRateSv1PingNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *utils.RateProfileCost
- result := dspSrv.RateSv1CostForEvent(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspRateSv1CostForEventErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *utils.RateProfileCost
- result := dspSrv.RateSv1CostForEvent(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/dispatchers/replicator.go b/dispatchers/replicator.go
deleted file mode 100644
index 327f31146..000000000
--- a/dispatchers/replicator.go
+++ /dev/null
@@ -1,711 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) ReplicatorSv1GetAccount(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *utils.Account) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetAccount, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetActionProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.ActionProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetActionProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetAttributeProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.AttributeProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetAttributeProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetChargerProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.ChargerProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetChargerProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetDispatcherHost(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.DispatcherHost) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetDispatcherHost, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetDispatcherProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.DispatcherProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetDispatcherProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetFilter(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.Filter) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetFilter, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetIndexes(ctx *context.Context, args *utils.GetIndexesArg, reply *map[string]utils.StringSet) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetIndexes, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetItemLoadIDs(ctx *context.Context, args *utils.StringWithAPIOpts, reply *map[string]int64) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetItemLoadIDs, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetRateProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *utils.RateProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetRateProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetResource(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.Resource) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetResource, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetResourceProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.ResourceProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetResourceProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetRouteProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.RouteProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetRouteProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetStatQueue(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.StatQueue) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetStatQueue, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetStatQueueProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.StatQueueProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetStatQueueProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetThreshold(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.Threshold) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetThreshold, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetThresholdProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.ThresholdProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetThresholdProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetTrend(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.Trend) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetTrend, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1GetTrendProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.TrendProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1GetTrendProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1Ping, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveAccount(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveAccount, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveActionProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveActionProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveAttributeProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveAttributeProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveChargerProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveChargerProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveDispatcherHost(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveDispatcherHost, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveDispatcherProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveDispatcherProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveFilter(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveFilter, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveIndexes(ctx *context.Context, args *utils.GetIndexesArg, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveIndexes, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveRateProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveRateProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveResource(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveResource, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveResourceProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveResourceProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveRouteProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveRouteProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveStatQueue(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveStatQueue, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveStatQueueProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveStatQueueProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveThreshold(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveThreshold, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveThresholdProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveThresholdProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveTrend(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveTrend, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1RemoveTrendProfile(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1RemoveTrendProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetAccount(ctx *context.Context, args *utils.AccountWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.Account != nil && len(args.Account.Tenant) != 0) {
- tnt = args.Account.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetAccount, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetActionProfile(ctx *context.Context, args *engine.ActionProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.ActionProfile != nil && len(args.ActionProfile.Tenant) != 0) {
- tnt = args.ActionProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetActionProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetAttributeProfile(ctx *context.Context, args *engine.AttributeProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.AttributeProfile != nil && len(args.AttributeProfile.Tenant) != 0) {
- tnt = args.AttributeProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetAttributeProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetChargerProfile(ctx *context.Context, args *engine.ChargerProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.ChargerProfile != nil && len(args.ChargerProfile.Tenant) != 0) {
- tnt = args.ChargerProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetChargerProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetDispatcherHost(ctx *context.Context, args *engine.DispatcherHostWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.DispatcherHost != nil && len(args.DispatcherHost.Tenant) != 0) {
- tnt = args.DispatcherHost.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetDispatcherHost, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetDispatcherProfile(ctx *context.Context, args *engine.DispatcherProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.DispatcherProfile != nil && len(args.DispatcherProfile.Tenant) != 0) {
- tnt = args.DispatcherProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetDispatcherProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetFilter(ctx *context.Context, args *engine.FilterWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.Filter != nil && len(args.Filter.Tenant) != 0) {
- tnt = args.Filter.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetFilter, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetIndexes(ctx *context.Context, args *utils.SetIndexesArg, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetIndexes, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetLoadIDs(ctx *context.Context, args *utils.LoadIDsWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetLoadIDs, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetRateProfile(ctx *context.Context, args *utils.RateProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.RateProfile != nil && len(args.RateProfile.Tenant) != 0) {
- tnt = args.RateProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetRateProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetResource(ctx *context.Context, args *engine.ResourceWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.Resource != nil && len(args.Resource.Tenant) != 0) {
- tnt = args.Resource.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetResource, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetResourceProfile(ctx *context.Context, args *engine.ResourceProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.ResourceProfile != nil && len(args.ResourceProfile.Tenant) != 0) {
- tnt = args.ResourceProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetResourceProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetRouteProfile(ctx *context.Context, args *engine.RouteProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.RouteProfile != nil && len(args.RouteProfile.Tenant) != 0) {
- tnt = args.RouteProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetRouteProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetStatQueue(ctx *context.Context, args *engine.StatQueueWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetStatQueue, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetStatQueueProfile(ctx *context.Context, args *engine.StatQueueProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.StatQueueProfile != nil && len(args.StatQueueProfile.Tenant) != 0) {
- tnt = args.StatQueueProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetStatQueueProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetThreshold(ctx *context.Context, args *engine.ThresholdWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.Threshold != nil && len(args.Threshold.Tenant) != 0) {
- tnt = args.Threshold.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetThreshold, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetThresholdProfile(ctx *context.Context, args *engine.ThresholdProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.ThresholdProfile != nil && len(args.ThresholdProfile.Tenant) != 0) {
- tnt = args.ThresholdProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetThresholdProfile, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetTrend(ctx *context.Context, args *engine.TrendWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.Trend != nil && len(args.Trend.Tenant) != 0) {
- tnt = args.Trend.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetTrend, args, reply)
-}
-func (dS *DispatcherService) ReplicatorSv1SetTrendProfile(ctx *context.Context, args *engine.TrendProfileWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TrendProfile != nil && len(args.TrendProfile.Tenant) != 0) {
- tnt = args.TrendProfile.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaReplicator, utils.ReplicatorSv1SetTrendProfile, args, reply)
-}
diff --git a/dispatchers/replicator_it_test.go b/dispatchers/replicator_it_test.go
deleted file mode 100644
index a05d96d27..000000000
--- a/dispatchers/replicator_it_test.go
+++ /dev/null
@@ -1,1046 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "reflect"
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var sTestsDspRpl = []func(t *testing.T){
- testDspRplPingFailover,
- testDspRplSupplierProfile,
- testDspRplAttributeProfile,
- testDspRplChargerProfile,
- testDspRplDispatcherProfile,
- testDspRplDispatcherHost,
- testDspRplFilter,
- testDspRplThreshold,
- testDspRplThresholdProfile,
- testDspRplStatQueue,
- testDspRplStatQueueProfile,
- testDspRplResource,
- testDspRplResourceProfile,
- testDspRplRateProfile,
- testDspRplAccount,
- testDspRplActionProfile,
-}
-
-// Test start here
-func TestDspReplicator(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- }
- testDsp(t, sTestsDspRpl, "TestDspReplicator", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
-}
-
-func testDspRplPingFailover(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.ReplicatorSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- reply = utils.EmptyString
- if err := allEngine2.RPC.Call(context.Background(), utils.ReplicatorSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- reply = utils.EmptyString
- ev := utils.CGREvent{
- Tenant: "cgrates.org",
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine.stopEngine(t)
- reply = utils.EmptyString
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine2.stopEngine(t)
- reply = utils.EmptyString
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1Ping, &ev, &reply); err == nil {
- t.Errorf("Expected error but received %v and reply %v\n", err, reply)
- }
- allEngine.startEngine(t)
- allEngine2.startEngine(t)
- reply = utils.EmptyString
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
-
-func testDspRplSupplierProfile(t *testing.T) {
- // Set RouteProfile
- var replyStr string
- argSetSupplierProfile := &engine.RouteProfileWithAPIOpts{
- RouteProfile: &engine.RouteProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetRouteProfile, argSetSupplierProfile, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetSupplierProfile: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get RouteProfile
- var reply *engine.RouteProfile
- argRouteProfile := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetRouteProfile, argRouteProfile, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetSupplierProfile: ", err)
- } else if reply.ID != argSetSupplierProfile.ID {
- t.Errorf("Expecting: %+v, received: %+v", argSetSupplierProfile.ID, reply.ID)
- } else if reply.Tenant != argSetSupplierProfile.Tenant {
- t.Errorf("Expecting: %+v, received: %+v", argSetSupplierProfile.Tenant, reply.Tenant)
- }
-
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get RouteProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetRouteProfile, argRouteProfile, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove SupplierProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveRouteProfile, argRouteProfile, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get RouteProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetRouteProfile, argRouteProfile, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-}
-
-func testDspRplAttributeProfile(t *testing.T) {
- // Set AttributeProfile
- var replyStr string
- setAttributeProfile := &engine.AttributeProfileWithAPIOpts{
- AttributeProfile: &engine.AttributeProfile{
- Tenant: "cgrates.org",
- ID: "id",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetAttributeProfile, setAttributeProfile, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetAttributeProfile: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get AttributeProfile
- var reply engine.AttributeProfile
- argAttributeProfile := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "id",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetAttributeProfile, argAttributeProfile, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetAttributeProfile: ", err)
- } else if reply.ID != setAttributeProfile.ID {
- t.Errorf("Expecting: %+v, received: %+v", setAttributeProfile.ID, reply.ID)
- } else if reply.Tenant != setAttributeProfile.Tenant {
- t.Errorf("Expecting: %+v, received: %+v", setAttributeProfile.Tenant, reply.Tenant)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get AttributeProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetAttributeProfile, argAttributeProfile, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove AttributeProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveAttributeProfile, argAttributeProfile, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get AttributeProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetAttributeProfile, argAttributeProfile, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-}
-
-func testDspRplChargerProfile(t *testing.T) {
- // Set ChargerProfile
- var replyStr string
- setChargerProfile := &engine.ChargerProfileWithAPIOpts{
- ChargerProfile: &engine.ChargerProfile{
- ID: "id",
- Tenant: "cgrates.org",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetChargerProfile, setChargerProfile, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetChargerProfile: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get ChargerProfile
- var reply engine.ChargerProfile
- argsChargerProfile := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "id",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetChargerProfile, argsChargerProfile, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetChargerProfile: ", err)
- } else if reply.ID != argsChargerProfile.ID {
- t.Errorf("Expecting: %+v, received: %+v", argsChargerProfile.ID, reply.ID)
- } else if reply.Tenant != argsChargerProfile.Tenant {
- t.Errorf("Expecting: %+v, received: %+v", argsChargerProfile.Tenant, reply.Tenant)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get ChargerProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetChargerProfile, argsChargerProfile, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove ChargerProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveChargerProfile, argsChargerProfile, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get ChargerProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetChargerProfile, argsChargerProfile, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-}
-
-func testDspRplDispatcherProfile(t *testing.T) {
- // Set DispatcherProfile
- var replyStr string
- setDispatcherProfile := &engine.DispatcherProfileWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetDispatcherProfile, setDispatcherProfile, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetDispatcherProfile: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get DispatcherProfile
- var reply engine.DispatcherProfile
- argsDispatcherProfile := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetDispatcherProfile, argsDispatcherProfile, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetDispatcherProfile: ", err)
- } else if reply.ID != argsDispatcherProfile.ID {
- t.Errorf("Expecting: %+v, received: %+v", argsDispatcherProfile.ID, reply.ID)
- } else if reply.Tenant != argsDispatcherProfile.Tenant {
- t.Errorf("Expecting: %+v, received: %+v", argsDispatcherProfile.Tenant, reply.Tenant)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get DispatcherProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetDispatcherProfile, argsDispatcherProfile, &reply); err == nil || err.Error() != utils.ErrDSPProfileNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrDSPProfileNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove DispatcherProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveDispatcherProfile, argsDispatcherProfile, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get DispatcherProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetDispatcherProfile, argsDispatcherProfile, &reply); err == nil || err.Error() != utils.ErrDSPProfileNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrDSPProfileNotFound, err)
- }
-}
-
-func testDspRplDispatcherHost(t *testing.T) {
- // Set DispatcherHost
- var replyStr string
- setDispatcherHost := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "ID",
- },
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetDispatcherHost, setDispatcherHost, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetDispatcherHost: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get DispatcherHost
- var reply engine.DispatcherHost
- argsDispatcherHost := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetDispatcherHost, argsDispatcherHost, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetDispatcherHost: ", err)
- } else if reply.ID != argsDispatcherHost.ID {
- t.Errorf("Expecting: %+v, received: %+v", argsDispatcherHost.ID, reply.ID)
- } else if reply.Tenant != argsDispatcherHost.Tenant {
- t.Errorf("Expecting: %+v, received: %+v", argsDispatcherHost.Tenant, reply.Tenant)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get DispatcherHost
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetDispatcherHost, argsDispatcherHost, &reply); err == nil || err.Error() != utils.ErrDSPHostNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrDSPHostNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove DispatcherHost
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveDispatcherHost, argsDispatcherHost, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get DispatcherHost
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetDispatcherHost, argsDispatcherHost, &reply); err == nil || err.Error() != utils.ErrDSPHostNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrDSPHostNotFound, err)
- }
-}
-
-func testDspRplFilter(t *testing.T) {
- // Set Filter
- var replyStr string
- setFilter := &engine.FilterWithAPIOpts{
- Filter: &engine.Filter{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetFilter, setFilter, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetFilter: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get Filter
- var reply engine.Filter
- argsFilter := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetFilter, argsFilter, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetFilter: ", err)
- } else if reply.ID != argsFilter.ID {
- t.Errorf("Expecting: %+v, received: %+v", argsFilter.ID, reply.ID)
- } else if reply.Tenant != argsFilter.Tenant {
- t.Errorf("Expecting: %+v, received: %+v", argsFilter.Tenant, reply.Tenant)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get Filter
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetFilter, argsFilter, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove Filter
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveFilter, argsFilter, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get Filter
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetFilter, argsFilter, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-}
-
-func testDspRplThreshold(t *testing.T) {
- // Set Threshold
- var replyStr string
- setThreshold := &engine.ThresholdWithAPIOpts{
- Threshold: &engine.Threshold{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetThreshold, setThreshold, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetThreshold: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get Threshold
- var reply engine.Threshold
- argsThreshold := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetThreshold, argsThreshold, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetThreshold: ", err)
- } else if reply.ID != argsThreshold.ID {
- t.Errorf("Expecting: %+v, received: %+v", argsThreshold.ID, reply.ID)
- } else if reply.Tenant != argsThreshold.Tenant {
- t.Errorf("Expecting: %+v, received: %+v", argsThreshold.Tenant, reply.Tenant)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get Threshold
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetThreshold, argsThreshold, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove Threshold
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveThreshold, argsThreshold, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get Threshold
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetThreshold, argsThreshold, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-}
-
-func testDspRplThresholdProfile(t *testing.T) {
- // Set ThresholdProfile
- var replyStr string
- setThresholdProfile := &engine.ThresholdProfileWithAPIOpts{
- ThresholdProfile: &engine.ThresholdProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetThresholdProfile, setThresholdProfile, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetThresholdProfile: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get ThresholdProfile
- var reply engine.ThresholdProfile
- argsThresholdProfile := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetThresholdProfile, argsThresholdProfile, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetThresholdProfile: ", err)
- } else if reply.ID != argsThresholdProfile.ID {
- t.Errorf("Expecting: %+v, received: %+v", argsThresholdProfile.ID, reply.ID)
- } else if reply.Tenant != argsThresholdProfile.Tenant {
- t.Errorf("Expecting: %+v, received: %+v", argsThresholdProfile.Tenant, reply.Tenant)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get ThresholdProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetThresholdProfile, argsThresholdProfile, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove ThresholdProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveThresholdProfile, argsThresholdProfile, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get ThresholdProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetThresholdProfile, argsThresholdProfile, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-}
-
-func testDspRplStatQueue(t *testing.T) {
- // Set StatQueue
- var replyStr string
- setStatQueue := &engine.StatQueueWithAPIOpts{
- StatQueue: &engine.StatQueue{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetStatQueue, setStatQueue, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetStatQueue: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get StatQueue
- var reply engine.StatQueue
- argsStatQueue := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetStatQueue, argsStatQueue, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetStatQueue: ", err)
- } else if reply.ID != argsStatQueue.ID {
- t.Errorf("Expecting: %+v, received: %+v", argsStatQueue.ID, reply.ID)
- } else if reply.Tenant != argsStatQueue.Tenant {
- t.Errorf("Expecting: %+v, received: %+v", argsStatQueue.Tenant, reply.Tenant)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get StatQueue
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetStatQueue, argsStatQueue, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove StatQueue
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveStatQueue, argsStatQueue, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get StatQueue
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetStatQueue, argsStatQueue, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-}
-
-func testDspRplStatQueueProfile(t *testing.T) {
- // Set StatQueueProfile
- var replyStr string
- setStatQueueProfile := &engine.StatQueueProfileWithAPIOpts{
- StatQueueProfile: &engine.StatQueueProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetStatQueueProfile, setStatQueueProfile, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetStatQueueProfile: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get StatQueueProfile
- var reply engine.StatQueueProfile
- argsStatQueueProfile := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetStatQueueProfile, argsStatQueueProfile, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetStatQueueProfile: ", err)
- } else if reply.ID != argsStatQueueProfile.ID {
- t.Errorf("Expecting: %+v, received: %+v", argsStatQueueProfile.ID, reply.ID)
- } else if reply.Tenant != argsStatQueueProfile.Tenant {
- t.Errorf("Expecting: %+v, received: %+v", argsStatQueueProfile.Tenant, reply.Tenant)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get StatQueueProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetStatQueueProfile, argsStatQueueProfile, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove StatQueueProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveStatQueueProfile, argsStatQueueProfile, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get StatQueueProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetStatQueueProfile, argsStatQueueProfile, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-}
-
-func testDspRplResource(t *testing.T) {
- // Set Resource
- var replyStr string
- setResource := &engine.ResourceWithAPIOpts{
- Resource: &engine.Resource{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetResource, setResource, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetResource: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get Resource
- var reply engine.Resource
- argsResource := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetResource, argsResource, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetResource: ", err)
- } else if reply.ID != argsResource.ID {
- t.Errorf("Expecting: %+v, received: %+v", argsResource.ID, reply.ID)
- } else if reply.Tenant != argsResource.Tenant {
- t.Errorf("Expecting: %+v, received: %+v", argsResource.Tenant, reply.Tenant)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get Resource
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetResource, argsResource, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove Resource
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveResource, argsResource, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get Resource
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetResource, argsResource, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-}
-
-func testDspRplResourceProfile(t *testing.T) {
- // Set ResourceProfile
- var replyStr string
- setResourceProfile := &engine.ResourceProfileWithAPIOpts{
- ResourceProfile: &engine.ResourceProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetResourceProfile, setResourceProfile, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetResourceProfile: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get ResourceProfile
- var reply engine.ResourceProfile
- argsResourceProfile := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "ID",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetResourceProfile, argsResourceProfile, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetResourceProfile: ", err)
- } else if reply.ID != argsResourceProfile.ID {
- t.Errorf("Expecting: %+v, received: %+v", argsResourceProfile.ID, reply.ID)
- } else if reply.Tenant != argsResourceProfile.Tenant {
- t.Errorf("Expecting: %+v, received: %+v", argsResourceProfile.Tenant, reply.Tenant)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get ResourceProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetResourceProfile, argsResourceProfile, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove ResourceProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveResourceProfile, argsResourceProfile, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get ResourceProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetResourceProfile, argsResourceProfile, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-}
-
-func testDspRplRateProfile(t *testing.T) {
- // Set RateProfile
- var replyStr string
- rPrf := &utils.RateProfileWithAPIOpts{
- RateProfile: &utils.RateProfile{
- Tenant: "cgrates.org",
- ID: "RP1",
- FilterIDs: []string{"*string:~*req.Subject:1001", "*string:~*req.Subject:1002"},
- Weights: utils.DynamicWeights{
- {
- Weight: 0,
- },
- },
- MaxCostStrategy: "*free",
- Rates: map[string]*utils.Rate{
- "FIRST_GI": {
- ID: "FIRST_GI",
- FilterIDs: []string{"*gi:~*req.Usage:0"},
- Weights: utils.DynamicWeights{
- {
- Weight: 0,
- },
- },
- Blocker: false,
- },
- "SECOND_GI": {
- ID: "SECOND_GI",
- FilterIDs: []string{"*gi:~*req.Usage:1m"},
- Weights: utils.DynamicWeights{
- {
- Weight: 10,
- },
- },
- Blocker: false,
- },
- },
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetRateProfile, rPrf, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetRateProfile: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get RateProfile
- var reply *utils.RateProfile
- args := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "RP1",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetRateProfile, args, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetRateProfile: ", err)
- } else if !reflect.DeepEqual(rPrf.RateProfile, reply) {
- t.Errorf("Expecting: %+v, received: %+v, ", rPrf.RateProfile, reply)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get RateProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetRateProfile, args, &reply); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove RateProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveRateProfile, args, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get RateProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetRateProfile, args, &reply); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-}
-func testDspRplAccount(t *testing.T) {
- // Set Account
- var replyStr string
- rPrf := &utils.AccountWithAPIOpts{
- Account: &utils.Account{
- Tenant: "cgrates.org",
- ID: "RP1",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetAccount, rPrf, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetAccount: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get RateProfile
- var reply *utils.Account
- args := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "RP1",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetAccount, args, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetAccount: ", err)
- } else if !reflect.DeepEqual(rPrf.Account, reply) {
- t.Errorf("Expecting: %+v, received: %+v, ", rPrf.Account, reply)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get RateProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetAccount, args, &reply); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove RateProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveAccount, args, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get RateProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetAccount, args, &reply); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
-}
-
-func testDspRplActionProfile(t *testing.T) {
- // Set RateProfile
- var replyStr string
- rPrf := &engine.ActionProfileWithAPIOpts{
- ActionProfile: &engine.ActionProfile{
- Tenant: "cgrates.org",
- ID: "RP1",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1SetActionProfile, rPrf, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetActionProfile: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get RateProfile
- var reply *engine.ActionProfile
- args := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "RP1",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetActionProfile, args, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetActionProfile: ", err)
- } else if !reflect.DeepEqual(rPrf.ActionProfile, reply) {
- t.Errorf("Expecting: %+v, received: %+v, ", rPrf.ActionProfile, reply)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get RateProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetActionProfile, args, &reply); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove RateProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1RemoveActionProfile, args, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get RateProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.ReplicatorSv1GetActionProfile, args, &reply); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
-}
diff --git a/dispatchers/replicator_test.go b/dispatchers/replicator_test.go
deleted file mode 100644
index ae7378bf2..000000000
--- a/dispatchers/replicator_test.go
+++ /dev/null
@@ -1,2115 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDspReplicatorSv1PingNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *string
- result := dspSrv.ReplicatorSv1Ping(context.Background(), nil, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1PingNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ReplicatorSv1Ping(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1PingErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ReplicatorSv1Ping(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetStatQueueNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.StatQueue
- result := dspSrv.ReplicatorSv1GetStatQueue(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetStatQueueErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.StatQueue
- result := dspSrv.ReplicatorSv1GetStatQueue(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetFilterNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.Filter
- result := dspSrv.ReplicatorSv1GetFilter(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetFilterErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.Filter
- result := dspSrv.ReplicatorSv1GetFilter(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetThresholdNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.Threshold
- result := dspSrv.ReplicatorSv1GetThreshold(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetThresholdErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.Threshold
- result := dspSrv.ReplicatorSv1GetThreshold(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetThresholdProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.ThresholdProfile
- result := dspSrv.ReplicatorSv1GetThresholdProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetThresholdProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.ThresholdProfile
- result := dspSrv.ReplicatorSv1GetThresholdProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetStatQueueProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.StatQueueProfile
- result := dspSrv.ReplicatorSv1GetStatQueueProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetStatQueueProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.StatQueueProfile
- result := dspSrv.ReplicatorSv1GetStatQueueProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetResourceNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.Resource
- result := dspSrv.ReplicatorSv1GetResource(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetResourceErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.Resource
- result := dspSrv.ReplicatorSv1GetResource(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetResourceProfileReplicatorSv1GetResourceProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.ResourceProfile
- result := dspSrv.ReplicatorSv1GetResourceProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetResourceProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.ResourceProfile
- result := dspSrv.ReplicatorSv1GetResourceProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetRouteProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.RouteProfile
- result := dspSrv.ReplicatorSv1GetRouteProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetRouteProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.RouteProfile
- result := dspSrv.ReplicatorSv1GetRouteProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetAttributeProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.AttributeProfile
- result := dspSrv.ReplicatorSv1GetAttributeProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetAttributeProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.AttributeProfile
- result := dspSrv.ReplicatorSv1GetAttributeProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetChargerProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.ChargerProfile
- result := dspSrv.ReplicatorSv1GetChargerProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetChargerProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.ChargerProfile
- result := dspSrv.ReplicatorSv1GetChargerProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetDispatcherProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.DispatcherProfile
- result := dspSrv.ReplicatorSv1GetDispatcherProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetDispatcherProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.DispatcherProfile
- result := dspSrv.ReplicatorSv1GetDispatcherProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetDispatcherHostNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.DispatcherHost
- result := dspSrv.ReplicatorSv1GetDispatcherHost(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetDispatcherHostErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.DispatcherHost
- result := dspSrv.ReplicatorSv1GetDispatcherHost(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetItemLoadIDsNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *map[string]int64
- result := dspSrv.ReplicatorSv1GetItemLoadIDs(context.Background(), nil, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetItemLoadIDsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.StringWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *map[string]int64
- result := dspSrv.ReplicatorSv1GetItemLoadIDs(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetItemLoadIDsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.StringWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *map[string]int64
- result := dspSrv.ReplicatorSv1GetItemLoadIDs(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetThresholdProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &engine.ThresholdProfileWithAPIOpts{
- ThresholdProfile: &engine.ThresholdProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetThresholdProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetThresholdProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &engine.ThresholdProfileWithAPIOpts{
- ThresholdProfile: &engine.ThresholdProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetThresholdProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveFilterNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveFilter(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveFilterErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveFilter(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveFilterNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveFilter(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveThresholdProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveThresholdProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveThresholdProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveThresholdProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveThresholdProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveThresholdProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveStatQueueProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveStatQueueProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveStatQueueProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveStatQueueProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveStatQueueProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveStatQueueProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveResourceNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveResource(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveResourceErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveResource(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveResourceNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveResource(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveResourceProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveResourceProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveResourceProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveResourceProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveResourceProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveResourceProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveRouteProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveRouteProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveRouteProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveRouteProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveRouteProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveRouteProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveAttributeProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveAttributeProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveAttributeProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveAttributeProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveAttributeProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveAttributeProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveChargerProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveChargerProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveChargerProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveChargerProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveChargerProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveChargerProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveDispatcherHostNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveDispatcherHost(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveDispatcherHostErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveDispatcherHost(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveDispatcherHostNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveDispatcherHost(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveDispatcherProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveDispatcherProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveDispatcherProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveDispatcherProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveDispatcherProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveDispatcherProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetIndexesNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.GetIndexesArg{
- Tenant: "tenant",
- }
- var reply *map[string]utils.StringSet
- result := dspSrv.ReplicatorSv1GetIndexes(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetIndexesErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.GetIndexesArg{
- Tenant: "tenant",
- }
- var reply *map[string]utils.StringSet
- result := dspSrv.ReplicatorSv1GetIndexes(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetIndexesNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *map[string]utils.StringSet
- result := dspSrv.ReplicatorSv1GetIndexes(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetIndexesNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.SetIndexesArg{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetIndexes(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetIndexesErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.SetIndexesArg{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetIndexes(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetIndexesNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetIndexes(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveIndexesNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.GetIndexesArg{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveIndexes(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetLoadIDsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.LoadIDsWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetLoadIDs(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetLoadIDsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.LoadIDsWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetLoadIDs(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetLoadIDsNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetLoadIDs(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveAccountNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveAccount(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveAccountErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveAccount(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveAccountNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveAccount(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveStatQueueNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveStatQueue(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveStatQueueErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveStatQueue(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveStatQueueNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveStatQueue(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveIndexesErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.GetIndexesArg{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveIndexes(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveIndexesNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveIndexes(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetThresholdProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetThresholdProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetThresholdNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &engine.ThresholdWithAPIOpts{
- Threshold: &engine.Threshold{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetThreshold(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetThresholdErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &engine.ThresholdWithAPIOpts{
- Threshold: &engine.Threshold{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetThreshold(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetThresholdNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetThreshold(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetAccountNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.AccountWithAPIOpts{
- Account: &utils.Account{},
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetAccount(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetAccountErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.AccountWithAPIOpts{
- Account: &utils.Account{
- ID: "testID",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetAccount(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetAccountNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetAccount(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetStatQueueNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &engine.StatQueueWithAPIOpts{
- StatQueue: &engine.StatQueue{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetStatQueue(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetStatQueueErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &engine.StatQueueWithAPIOpts{
- StatQueue: &engine.StatQueue{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetStatQueue(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetStatQueueNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetStatQueue(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetFilterNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &engine.FilterWithAPIOpts{
- Filter: &engine.Filter{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetFilter(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetFilterErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &engine.FilterWithAPIOpts{
- Filter: &engine.Filter{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetFilter(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetFilterNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetFilter(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetStatQueueProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &engine.StatQueueProfileWithAPIOpts{
- StatQueueProfile: &engine.StatQueueProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetStatQueueProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetStatQueueProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &engine.StatQueueProfileWithAPIOpts{
- StatQueueProfile: &engine.StatQueueProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetStatQueueProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetStatQueueProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetStatQueueProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetResourceNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &engine.ResourceWithAPIOpts{
- Resource: &engine.Resource{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetResource(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetResourceErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &engine.ResourceWithAPIOpts{
- Resource: &engine.Resource{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetResource(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetResourceNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetResource(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetResourceProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &engine.ResourceProfileWithAPIOpts{
- ResourceProfile: &engine.ResourceProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetResourceProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestReplicatorSv1SetResourceProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &engine.ResourceProfileWithAPIOpts{
- ResourceProfile: &engine.ResourceProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetResourceProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetResourceProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetResourceProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetRouteProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &engine.RouteProfileWithAPIOpts{
- RouteProfile: &engine.RouteProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetRouteProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetRouteProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &engine.RouteProfileWithAPIOpts{
- RouteProfile: &engine.RouteProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetRouteProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetRouteProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetRouteProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetAttributeProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &engine.AttributeProfileWithAPIOpts{
- AttributeProfile: &engine.AttributeProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetAttributeProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetAttributeProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &engine.AttributeProfileWithAPIOpts{
- AttributeProfile: &engine.AttributeProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetAttributeProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetAttributeProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetAttributeProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetChargerProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &engine.ChargerProfileWithAPIOpts{
- ChargerProfile: &engine.ChargerProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetChargerProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetChargerProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &engine.ChargerProfileWithAPIOpts{
- ChargerProfile: &engine.ChargerProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetChargerProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetChargerProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetChargerProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetDispatcherProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &engine.DispatcherProfileWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetDispatcherProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetDispatcherProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &engine.DispatcherProfileWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetDispatcherProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetDispatcherProfileNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetDispatcherProfile(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetDispatcherHostNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetDispatcherHost(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestReplicatorSv1SetDispatcherHostErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetDispatcherHost(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetDispatcherHostNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1SetDispatcherHost(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveThresholdNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveThreshold(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestReplicatorSv1RemoveThresholdErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveThreshold(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveThresholdNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveThreshold(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetRateProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *utils.RateProfile
- result := dspSrv.ReplicatorSv1GetRateProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetRateProfileErrorTenant(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *utils.RateProfile
- result := dspSrv.ReplicatorSv1GetRateProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetRateProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{}
- var reply *utils.RateProfile
- result := dspSrv.ReplicatorSv1GetRateProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetActionProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.ActionProfile
- result := dspSrv.ReplicatorSv1GetActionProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetActionProfileErrorTenant(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.ActionProfile
- result := dspSrv.ReplicatorSv1GetActionProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetActionProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.ActionProfile
- result := dspSrv.ReplicatorSv1GetActionProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetActionProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &engine.ActionProfileWithAPIOpts{
- ActionProfile: &engine.ActionProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetActionProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetActionProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &engine.ActionProfileWithAPIOpts{
- ActionProfile: &engine.ActionProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetActionProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetActionProfileErrorNilArgs(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *string
- result := dspSrv.ReplicatorSv1SetActionProfile(context.Background(), nil, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetRateProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.RateProfileWithAPIOpts{
- RateProfile: &utils.RateProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetRateProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetRateProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.RateProfileWithAPIOpts{
- RateProfile: &utils.RateProfile{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1SetRateProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1SetRateProfileErrorNilArgs(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *string
- result := dspSrv.ReplicatorSv1SetRateProfile(context.Background(), nil, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveRateProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveRateProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDsReplicatorSv1RemoveRateProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveRateProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveRateProfileErrorNilArgs(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveRateProfile(context.Background(), nil, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveActionProfileNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveActionProfile(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1RemoveActionProfileErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveActionProfile(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestReplicatorSv1RemoveActionProfileNilArgs(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *string
- result := dspSrv.ReplicatorSv1RemoveActionProfile(context.Background(), nil, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetAccountErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *utils.Account
- result := dspSrv.ReplicatorSv1GetAccount(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspReplicatorSv1GetAccountErrorCase2(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *utils.Account
- result := dspSrv.ReplicatorSv1GetAccount(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/dispatchers/resources.go b/dispatchers/resources.go
deleted file mode 100644
index 7d7fae1f2..000000000
--- a/dispatchers/resources.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) ResourceSv1AllocateResources(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaResources, utils.ResourceSv1AllocateResources, args, reply)
-}
-func (dS *DispatcherService) ResourceSv1AuthorizeResources(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaResources, utils.ResourceSv1AuthorizeResources, args, reply)
-}
-func (dS *DispatcherService) ResourceSv1GetResource(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.Resource) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaResources, utils.ResourceSv1GetResource, args, reply)
-}
-func (dS *DispatcherService) ResourceSv1GetResourceWithConfig(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.ResourceWithConfig) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaResources, utils.ResourceSv1GetResourceWithConfig, args, reply)
-}
-func (dS *DispatcherService) ResourceSv1GetResourcesForEvent(ctx *context.Context, args *utils.CGREvent, reply *engine.Resources) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaResources, utils.ResourceSv1GetResourcesForEvent, args, reply)
-}
-func (dS *DispatcherService) ResourceSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaResources, utils.ResourceSv1Ping, args, reply)
-}
-func (dS *DispatcherService) ResourceSv1ReleaseResources(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaResources, utils.ResourceSv1ReleaseResources, args, reply)
-}
diff --git a/dispatchers/resources_it_test.go b/dispatchers/resources_it_test.go
deleted file mode 100644
index 5be3e02cc..000000000
--- a/dispatchers/resources_it_test.go
+++ /dev/null
@@ -1,303 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "reflect"
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var sTestsDspRes = []func(t *testing.T){
- testDspResPingFailover,
-
- testDspResPing,
- testDspResTestAuthKey,
- testDspResTestAuthKey2,
- testDspResTestAuthKey3,
-}
-
-// Test start here
-func TestDspResourceSIT(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- }
- testDsp(t, sTestsDspRes, "TestDspResourceS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
-}
-
-func testDspResPingFailover(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.ResourceSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- ev := utils.CGREvent{
- Tenant: "cgrates.org",
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "res12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ResourceSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.ResourceSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine2.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.ResourceSv1Ping, &ev, &reply); err == nil {
- t.Errorf("Expected error but received %v and reply %v\n", err, reply)
- }
- allEngine.startEngine(t)
- allEngine2.startEngine(t)
-}
-
-func testDspResPing(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.ResourceSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ResourceSv1Ping, &utils.CGREvent{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "res12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
-
-func testDspResTestAuthKey(t *testing.T) {
- var rs *engine.Resources
- args := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- utils.AccountField: "1001",
- utils.Destination: "1002",
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "12345",
- utils.OptsResourcesUsageID: utils.UUIDSha1Prefix(),
- },
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.ResourceSv1GetResourcesForEvent,
- args, &rs); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
- t.Error(err)
- }
-}
-
-func testDspResTestAuthKey2(t *testing.T) {
- var rs *engine.Resources
- args := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- utils.AccountField: "1001",
- utils.Destination: "1002",
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "res12345",
- utils.OptsResourcesUsageID: utils.UUIDSha1Prefix(),
- },
- }
- eRs := &engine.Resources{
- &engine.Resource{
- Tenant: "cgrates.org",
- ID: "ResGroup1",
- Usages: map[string]*engine.ResourceUsage{},
- },
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.ResourceSv1GetResourcesForEvent,
- args, &rs); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eRs, rs) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eRs), utils.ToJSON(rs))
- }
-}
-
-func testDspResTestAuthKey3(t *testing.T) {
- // first event matching Resource1
- var reply string
- argsRU := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- "Account": "1002",
- "Subject": "1001",
- "Destination": "1002"},
- APIOpts: map[string]any{
- utils.OptsAPIKey: "res12345",
- utils.OptsResourcesUsageID: "651a8db2-4f67-4cf8-b622-169e8a482e51",
- utils.OptsResourcesUnits: 1,
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ResourceSv1AllocateResources,
- argsRU, &reply); err != nil {
- t.Error(err)
- }
- eAllocationMsg := "ResGroup1"
- if reply != eAllocationMsg {
- t.Errorf("Expecting: %+v, received: %+v", eAllocationMsg, reply)
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.ResourceSv1AuthorizeResources, &argsRU, &reply); err != nil {
- t.Error(err)
- } else if reply != eAllocationMsg { // already 3 usages active before allow call, we should have now more than allowed
- t.Errorf("Expecting: %+v, received: %+v", eAllocationMsg, reply)
- }
- argsRU = &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- "Account": "1002",
- "Subject": "1001",
- "Destination": "1002"},
- APIOpts: map[string]any{
- utils.OptsAPIKey: "res12345",
- utils.OptsResourcesUsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
- utils.OptsResourcesUnits: 17,
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ResourceSv1AuthorizeResources,
- &argsRU, &reply); err == nil || err.Error() != utils.ErrResourceUnauthorized.Error() {
- t.Error(err)
- }
-
- // relase the only resource active for Resource1
- argsRU = &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- "Account": "1002",
- "Subject": "1001",
- "Destination": "1002"},
- APIOpts: map[string]any{
- utils.OptsAPIKey: "res12345",
- utils.OptsResourcesUsageID: "651a8db2-4f67-4cf8-b622-169e8a482e51",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ResourceSv1ReleaseResources,
- argsRU, &reply); err != nil {
- t.Error(err)
- }
- // try reserving with full units for Resource1, case which did not work in previous test
- // only match Resource1 since we don't want for storing of the resource2 bellow
- argsRU = &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- "Account": "1002",
- "Subject": "1001",
- "Destination": "1002"},
- APIOpts: map[string]any{
- utils.OptsAPIKey: "res12345",
- utils.OptsResourcesUsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
- utils.OptsResourcesUnits: 6,
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ResourceSv1AuthorizeResources, &argsRU, &reply); err != nil {
- t.Error(err)
- } else if reply != "ResGroup1" {
- t.Error("Unexpected reply returned", reply)
- }
- var rs *engine.Resources
- args := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "Event5",
- Event: map[string]any{
- "Account": "1002",
- "Subject": "1001",
- "Destination": "1002"},
- APIOpts: map[string]any{
- utils.OptsAPIKey: "res12345",
- utils.OptsResourcesUsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ResourceSv1GetResourcesForEvent, args, &rs); err != nil {
- t.Error(err)
- } else if len(*rs) != 1 {
- t.Errorf("Resources: %+v", utils.ToJSON(rs))
- }
- if rs == nil {
- t.Fatal("Expecting rs to not be nil")
- }
- // make sure Resource1 have no more active resources
- for _, r := range *rs {
- if r.ID == "ResGroup1" &&
- (len(r.Usages) != 0 || len(r.TTLIdx) != 0) {
- t.Errorf("Unexpected resource: %+v", utils.ToJSON(r))
- }
- }
- var r *engine.Resource
- argsGetResource := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ResGroup1"},
- APIOpts: map[string]any{
- utils.OptsAPIKey: "res12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ResourceSv1GetResource, argsGetResource, &r); err != nil {
- t.Fatal(err)
- }
- // make sure Resource1 have no more active resources
- if r.ID == "ResGroup1" &&
- (len(r.Usages) != 0 || len(r.TTLIdx) != 0) {
- t.Errorf("Unexpected resource: %+v", utils.ToJSON(r))
- }
-
-}
diff --git a/dispatchers/resources_test.go b/dispatchers/resources_test.go
deleted file mode 100644
index 762b70811..000000000
--- a/dispatchers/resources_test.go
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDspResourceSv1PingNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *string
- result := dspSrv.ResourceSv1Ping(context.Background(), nil, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1PingNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ResourceSv1Ping(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1PingErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ResourceSv1Ping(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1GetResourcesForEventNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *engine.Resources
- result := dspSrv.ResourceSv1GetResourcesForEvent(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1GetResourcesForEventErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *engine.Resources
- result := dspSrv.ResourceSv1GetResourcesForEvent(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1AuthorizeResourcesNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ResourceSv1AuthorizeResources(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1AuthorizeResourcesErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ResourceSv1AuthorizeResources(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1ReleaseResourcesNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ResourceSv1ReleaseResources(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1ReleaseResourcesErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ResourceSv1ReleaseResources(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1GetResourceNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.Resource
- result := dspSrv.ResourceSv1GetResource(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1GetResourceErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.Resource
- result := dspSrv.ResourceSv1GetResource(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1AllocateResourcesNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ResourceSv1AllocateResources(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1AllocateResourcesErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.ResourceSv1AllocateResources(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1GetResourceWithConfigNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.ResourceWithConfig
- result := dspSrv.ResourceSv1GetResourceWithConfig(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspResourceSv1GetResourceWithConfigErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *engine.ResourceWithConfig
- result := dspSrv.ResourceSv1GetResourceWithConfig(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/dispatchers/routes.go b/dispatchers/routes.go
deleted file mode 100644
index 46a33d44f..000000000
--- a/dispatchers/routes.go
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) RouteSv1GetRouteProfilesForEvent(ctx *context.Context, args *utils.CGREvent, reply *[]*engine.RouteProfile) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaRoutes, utils.RouteSv1GetRouteProfilesForEvent, args, reply)
-}
-func (dS *DispatcherService) RouteSv1GetRoutes(ctx *context.Context, args *utils.CGREvent, reply *engine.SortedRoutesList) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaRoutes, utils.RouteSv1GetRoutes, args, reply)
-}
-func (dS *DispatcherService) RouteSv1GetRoutesList(ctx *context.Context, args *utils.CGREvent, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaRoutes, utils.RouteSv1GetRoutesList, args, reply)
-}
-func (dS *DispatcherService) RouteSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaRoutes, utils.RouteSv1Ping, args, reply)
-}
diff --git a/dispatchers/routes_it_test.go b/dispatchers/routes_it_test.go
deleted file mode 100644
index fc7c62292..000000000
--- a/dispatchers/routes_it_test.go
+++ /dev/null
@@ -1,395 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "reflect"
- "sort"
- "testing"
- "time"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var (
- sTestsDspSup = []func(t *testing.T){
- testDspSupPingFailover,
- testDspSupGetSupFailover,
- testDspSupGetSupRoundRobin,
-
- testDspSupPing,
- testDspSupTestAuthKey,
- testDspSupTestAuthKey2,
- testDspSupGetSupplierForEvent,
- }
-)
-
-// Test start here
-func TestDspSupplierS(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- }
- testDsp(t, sTestsDspSup, "TestDspSupplierS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
-}
-
-func testDspSupPing(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.RouteSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.RouteSv1Ping, &utils.CGREvent{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "sup12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
-
-func testDspSupPingFailover(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.RouteSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- ev := utils.CGREvent{
- Tenant: "cgrates.org",
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "sup12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.RouteSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.RouteSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine2.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.RouteSv1Ping, &ev, &reply); err == nil {
- t.Errorf("Expected error but received %v and reply %v\n", err, reply)
- }
- allEngine.startEngine(t)
- allEngine2.startEngine(t)
-}
-
-func testDspSupGetSupFailover(t *testing.T) {
- var rpl engine.SortedRoutesList
- eRpl1 := engine.SortedRoutesList{{
- ProfileID: "ROUTE_WEIGHT_2",
- Sorting: utils.MetaWeight,
- Routes: []*engine.SortedRoute{
- {
- RouteID: "route1",
- RouteParameters: "",
- SortingData: map[string]any{
- utils.Weight: 10.0,
- },
- },
- },
- }}
- eRpl := engine.SortedRoutesList{{
- ProfileID: "ROUTE_ACNT_1002",
- Sorting: utils.MetaLC,
- Routes: []*engine.SortedRoute{
- {
- RouteID: "route1",
- RouteParameters: "",
- SortingData: map[string]any{
- utils.Cost: 0.1,
- utils.RateProfileID: "RP_1002_LOW",
- utils.Weight: 10.0,
- },
- },
- {
- RouteID: "route2",
- RouteParameters: "",
- SortingData: map[string]any{
- utils.Cost: 0.12,
- utils.RateProfileID: "RP_1002",
- utils.Weight: 20.0,
- },
- },
- },
- }}
- args := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- utils.EventName: "Event1",
- utils.AccountField: "1002",
- utils.Subject: "1002",
- utils.Destination: "1001",
- utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC),
- utils.Usage: "1m20s",
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "sup12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.RouteSv1GetRoutes,
- args, &rpl); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eRpl1, rpl) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eRpl1), utils.ToJSON(rpl))
- }
- allEngine2.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.RouteSv1GetRoutes,
- args, &rpl); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eRpl, rpl) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eRpl), utils.ToJSON(rpl))
- }
- allEngine2.startEngine(t)
-}
-
-func testDspSupTestAuthKey(t *testing.T) {
- var rpl engine.SortedRoutesList
- args := &utils.CGREvent{
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- utils.AccountField: "1002",
- utils.Subject: "1002",
- utils.Destination: "1001",
- utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC),
- utils.Usage: "1m20s",
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.RouteSv1GetRoutes,
- args, &rpl); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
- t.Error(err)
- }
-}
-
-func testDspSupTestAuthKey2(t *testing.T) {
- var rpl engine.SortedRoutesList
- eRpl := engine.SortedRoutesList{{
- ProfileID: "ROUTE_ACNT_1002",
- Sorting: utils.MetaLC,
- Routes: []*engine.SortedRoute{
- {
- RouteID: "route1",
- RouteParameters: "",
- SortingData: map[string]any{
- utils.Cost: 0.1,
- utils.RateProfileID: "RP_1002_LOW",
- utils.Weight: 10.0,
- },
- },
- {
- RouteID: "route2",
- RouteParameters: "",
- SortingData: map[string]any{
- utils.Cost: 0.12,
- utils.RateProfileID: "RP_1002",
- utils.Weight: 20.0,
- },
- },
- },
- }}
- args := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- utils.AccountField: "1002",
- utils.Subject: "1002",
- utils.Destination: "1001",
- utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC),
- utils.Usage: "1m20s",
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "sup12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.RouteSv1GetRoutes,
- args, &rpl); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eRpl, rpl) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eRpl), utils.ToJSON(rpl))
- }
-}
-
-func testDspSupGetSupRoundRobin(t *testing.T) {
- var rpl engine.SortedRoutesList
- eRpl1 := engine.SortedRoutesList{{
- ProfileID: "ROUTE_WEIGHT_2",
- Sorting: utils.MetaWeight,
- Routes: []*engine.SortedRoute{
- {
- RouteID: "route1",
- RouteParameters: "",
- SortingData: map[string]any{
- utils.Weight: 10.0,
- },
- },
- },
- }}
- eRpl := engine.SortedRoutesList{{
- ProfileID: "ROUTE_ACNT_1002",
- Sorting: utils.MetaLC,
- Routes: []*engine.SortedRoute{
- {
- RouteID: "route1",
- RouteParameters: "",
- SortingData: map[string]any{
- utils.Cost: 0.1,
- utils.RateProfileID: "RP_1002_LOW",
- utils.Weight: 10.0,
- },
- },
- {
- RouteID: "route2",
- RouteParameters: "",
- SortingData: map[string]any{
- utils.Cost: 0.12,
- utils.RateProfileID: "RP_1002",
- utils.Weight: 20.0,
- },
- },
- },
- }}
- args := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- utils.EventName: "RoundRobin",
- utils.AccountField: "1002",
- utils.Subject: "1002",
- utils.Destination: "1001",
- utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC),
- utils.Usage: "1m20s",
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "sup12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.RouteSv1GetRoutes,
- args, &rpl); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eRpl1, rpl) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eRpl1), utils.ToJSON(rpl))
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.RouteSv1GetRoutes,
- args, &rpl); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eRpl, rpl) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(eRpl), utils.ToJSON(rpl))
- }
-}
-
-func testDspSupGetSupplierForEvent(t *testing.T) {
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testV1SplSGetHighestCostSuppliers",
- Event: map[string]any{
- utils.AccountField: "1002",
- utils.Subject: "1002",
- utils.Destination: "1001",
- utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC),
- utils.Usage: "1m20s",
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "sup12345",
- },
- }
- expected := engine.RouteProfile{
- Tenant: "cgrates.org",
- ID: "ROUTE_ACNT_1002",
- FilterIDs: []string{"FLTR_ACNT_1002"},
- Sorting: utils.MetaLC,
- SortingParameters: []string{},
- Routes: []*engine.Route{
- {
- ID: "route1",
- RateProfileIDs: []string{"RP_1002_LOW"},
- Weights: utils.DynamicWeights{{Weight: 10}},
- Blockers: utils.DynamicBlockers{
- {
- Blocker: false,
- },
- },
- RouteParameters: "",
- },
- {
- ID: "route2",
- RateProfileIDs: []string{"RP_1002"},
- Weights: utils.DynamicWeights{{Weight: 20}},
- RouteParameters: "",
- },
- },
- Weights: utils.DynamicWeights{{Weight: 10}},
- }
- if *utils.Encoding == utils.MetaGOB {
- expected.SortingParameters = nil // empty slices are nil in gob
- }
- var supProf []*engine.RouteProfile
- if err := dispEngine.RPC.Call(context.Background(), utils.RouteSv1GetRouteProfilesForEvent,
- ev, &supProf); err != nil {
- t.Fatal(err)
- }
- sort.Slice(supProf[0].Routes, func(i, j int) bool {
- return supProf[0].Routes[i].Weights[0].Weight < supProf[0].Routes[j].Weights[0].Weight
- })
- if !reflect.DeepEqual(expected, *supProf[0]) {
- t.Errorf("Expected: %s ,received: %s", utils.ToJSON(expected), utils.ToJSON(*supProf[0]))
- }
-}
diff --git a/dispatchers/routes_test.go b/dispatchers/routes_test.go
deleted file mode 100644
index 41474196d..000000000
--- a/dispatchers/routes_test.go
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDspRouteSv1PingNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *string
- result := dspSrv.RouteSv1Ping(context.Background(), nil, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspRouteSv1PingNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.RouteSv1Ping(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspRouteSv1PingErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.RouteSv1Ping(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspRouteSv1GetRoutesNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *engine.SortedRoutesList
- result := dspSrv.RouteSv1GetRoutes(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspRouteSv1GetRoutesErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *engine.SortedRoutesList
- result := dspSrv.RouteSv1GetRoutes(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspRouteSv1GetRoutesListNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *[]string
- result := dspSrv.RouteSv1GetRoutesList(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspRouteSv1GetRoutesListErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *[]string
- result := dspSrv.RouteSv1GetRoutesList(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspRouteSv1GetRouteProfilesForEventNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *[]*engine.RouteProfile
- result := dspSrv.RouteSv1GetRouteProfilesForEvent(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspRouteSv1GetRouteProfilesForEventErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *[]*engine.RouteProfile
- result := dspSrv.RouteSv1GetRouteProfilesForEvent(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/dispatchers/sessions.go b/dispatchers/sessions.go
deleted file mode 100644
index d120521db..000000000
--- a/dispatchers/sessions.go
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/sessions"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) SessionSv1ActivateSessions(ctx *context.Context, args *utils.SessionIDsWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1ActivateSessions, args, reply)
-}
-func (dS *DispatcherService) SessionSv1AuthorizeEvent(ctx *context.Context, args *utils.CGREvent, reply *sessions.V1AuthorizeReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1AuthorizeEvent, args, reply)
-}
-func (dS *DispatcherService) SessionSv1AuthorizeEventWithDigest(ctx *context.Context, args *utils.CGREvent, reply *sessions.V1AuthorizeReplyWithDigest) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1AuthorizeEventWithDigest, args, reply)
-}
-func (dS *DispatcherService) SessionSv1DeactivateSessions(ctx *context.Context, args *utils.SessionIDsWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1DeactivateSessions, args, reply)
-}
-func (dS *DispatcherService) SessionSv1DisconnectPeer(ctx *context.Context, args *utils.DPRArgs, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- ev := make(map[string]any)
- opts := make(map[string]any)
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1DisconnectPeer, args, reply)
-}
-func (dS *DispatcherService) SessionSv1ForceDisconnect(ctx *context.Context, args *utils.SessionFilter, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1ForceDisconnect, args, reply)
-}
-func (dS *DispatcherService) SessionSv1GetActiveSessions(ctx *context.Context, args *utils.SessionFilter, reply *[]*sessions.ExternalSession) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1GetActiveSessions, args, reply)
-}
-func (dS *DispatcherService) SessionSv1GetActiveSessionsCount(ctx *context.Context, args *utils.SessionFilter, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1GetActiveSessionsCount, args, reply)
-}
-func (dS *DispatcherService) SessionSv1GetPassiveSessions(ctx *context.Context, args *utils.SessionFilter, reply *[]*sessions.ExternalSession) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1GetPassiveSessions, args, reply)
-}
-func (dS *DispatcherService) SessionSv1GetPassiveSessionsCount(ctx *context.Context, args *utils.SessionFilter, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1GetPassiveSessionsCount, args, reply)
-}
-func (dS *DispatcherService) SessionSv1InitiateSession(ctx *context.Context, args *utils.CGREvent, reply *sessions.V1InitSessionReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1InitiateSession, args, reply)
-}
-func (dS *DispatcherService) SessionSv1InitiateSessionWithDigest(ctx *context.Context, args *utils.CGREvent, reply *sessions.V1InitReplyWithDigest) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1InitiateSessionWithDigest, args, reply)
-}
-func (dS *DispatcherService) SessionSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1Ping, args, reply)
-}
-func (dS *DispatcherService) SessionSv1ProcessCDR(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1ProcessCDR, args, reply)
-}
-func (dS *DispatcherService) SessionSv1ProcessEvent(ctx *context.Context, args *utils.CGREvent, reply *sessions.V1ProcessEventReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1ProcessEvent, args, reply)
-}
-func (dS *DispatcherService) SessionSv1ProcessMessage(ctx *context.Context, args *utils.CGREvent, reply *sessions.V1ProcessMessageReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1ProcessMessage, args, reply)
-}
-func (dS *DispatcherService) SessionSv1ReAuthorize(ctx *context.Context, args *utils.SessionFilter, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1ReAuthorize, args, reply)
-}
-func (dS *DispatcherService) SessionSv1RegisterInternalBiJSONConn(ctx *context.Context, args string, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- ev := make(map[string]any)
- opts := make(map[string]any)
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1RegisterInternalBiJSONConn, args, reply)
-}
-func (dS *DispatcherService) SessionSv1ReplicateSessions(ctx *context.Context, args sessions.ArgsReplicateSessions, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := args.APIOpts
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1ReplicateSessions, args, reply)
-}
-func (dS *DispatcherService) SessionSv1STIRAuthenticate(ctx *context.Context, args *sessions.V1STIRAuthenticateArgs, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1STIRAuthenticate, args, reply)
-}
-func (dS *DispatcherService) SessionSv1STIRIdentity(ctx *context.Context, args *sessions.V1STIRIdentityArgs, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1STIRIdentity, args, reply)
-}
-func (dS *DispatcherService) SessionSv1SetPassiveSession(ctx *context.Context, args *sessions.Session, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.OriginCGREvent.Tenant) != 0 {
- tnt = args.OriginCGREvent.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1SetPassiveSession, args, reply)
-}
-func (dS *DispatcherService) SessionSv1SyncSessions(ctx *context.Context, args *utils.TenantWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1SyncSessions, args, reply)
-}
-func (dS *DispatcherService) SessionSv1TerminateSession(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1TerminateSession, args, reply)
-}
-func (dS *DispatcherService) SessionSv1UpdateSession(ctx *context.Context, args *utils.CGREvent, reply *sessions.V1UpdateSessionReply) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaSessionS, utils.SessionSv1UpdateSession, args, reply)
-}
diff --git a/dispatchers/sessions_it_test.go b/dispatchers/sessions_it_test.go
deleted file mode 100644
index 77c40fcb6..000000000
--- a/dispatchers/sessions_it_test.go
+++ /dev/null
@@ -1,1054 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
- "time"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/sessions"
- "github.com/cgrates/cgrates/utils"
-)
-
-/*
- var sTestsDspSession = []func(t *testing.T){
- testDspSessionAddBalacne,
-
- testDspSessionPingFailover,
-
- testDspSessionPing,
- testDspSessionTestAuthKey,
- testDspSessionAuthorize,
- testDspSessionInit,
- testDspGetSessions,
- testDspSessionUpdate,
- testDspSessionTerminate,
- testDspSessionProcessCDR,
- testDspSessionProcessEvent,
- testDspSessionProcessEvent2,
-
- testDspSessionProcessEvent3,
-
- testDspSessionGetCost,
- testDspSessionReplicate,
- testDspSessionPassive,
-
- testDspSessionSTIRAuthenticate,
- testDspSessionSTIRIdentity,
- testDspSessionForceDisconect,
- }
-
-//Test start here
-
- func TestDspSessionS(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- config3 += "_gob"
- }
- testDsp(t, sTestsDspSession, "TestDspSessionS", config1, config2, config3, "testit", "tutorial", dispDIR)
- }
-
- func testDspSessionAddBalacne(t *testing.T) {
- initUsage := 40 * time.Minute
- attrSetBalance := utils.AttrSetBalance{
- Tenant: "cgrates.org",
- Account: "1001",
- BalanceType: utils.MetaVoice,
- Value: float64(initUsage),
- Balance: map[string]any{
- utils.ID: "SessionBalance",
- utils.RatingSubject: "*zero5ms",
- },
- }
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.APIerSv2SetBalance, attrSetBalance, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Errorf("Received: %s", reply)
- }
- var acnt *engine.Account
- attrs := &utils.AttrGetAccount{
- Tenant: attrSetBalance.Tenant,
- Account: attrSetBalance.Account,
- }
- eAcntVal := float64(initUsage)
- if err := allEngine.RPC.Call(context.Background(), utils.APIerSv2GetAccount, attrs, &acnt); err != nil {
- t.Error(err)
- } else if acnt.BalanceMap[utils.MetaVoice].GetTotalValue() != eAcntVal {
- t.Errorf("Expecting: %v, received: %v",
- time.Duration(eAcntVal), time.Duration(acnt.BalanceMap[utils.MetaVoice].GetTotalValue()))
- }
- if err := allEngine2.RPC.Call(context.Background(), utils.APIerSv2SetBalance, attrSetBalance, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Errorf("Received: %s", reply)
- }
- if err := allEngine2.RPC.Call(context.Background(), utils.APIerSv2GetAccount, attrs, &acnt); err != nil {
- t.Error(err)
- } else if acnt.BalanceMap[utils.MetaVoice].GetTotalValue() != eAcntVal {
- t.Errorf("Expecting: %v, received: %v",
- time.Duration(eAcntVal), time.Duration(acnt.BalanceMap[utils.MetaVoice].GetTotalValue()))
- }
- }
-
- func testDspSessionPing(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.SessionSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1Ping, &utils.CGREvent{
- Tenant: "cgrates.org",
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- }
-
- func testDspSessionPingFailover(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.SessionSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- ev := &utils.CGREvent{
- Tenant: "cgrates.org",
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine2.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1Ping, &ev, &reply); err == nil {
- t.Errorf("Expected error but received %v and reply %v\n", err, reply)
- }
- allEngine.startEngine(t)
- allEngine2.startEngine(t)
- }
-
- func testDspSessionTestAuthKey(t *testing.T) {
- authUsage := 5 * time.Minute
- args := sessions.V1AuthorizeArgs{
- GetMaxUsage: true,
- AuthorizeResources: true,
- GetRoutes: true,
- GetAttributes: true,
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TestSSv1ItAuth",
- Event: map[string]any{
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.OriginID: "TestSSv1It1",
- utils.RequestType: utils.MetaPrepaid,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
- utils.Usage: authUsage,
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "12345",
- },
- },
- }
- var rply sessions.V1AuthorizeReplyWithDigest
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1AuthorizeEventWithDigest,
- args, &rply); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
- t.Error(err)
- }
- }
-
- func testDspSessionAuthorize(t *testing.T) {
- authUsage := 5 * time.Minute
- argsAuth := &sessions.V1AuthorizeArgs{
- GetMaxUsage: true,
- AuthorizeResources: true,
- GetRoutes: true,
- GetAttributes: true,
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TestSSv1ItAuth",
- Event: map[string]any{
- utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf",
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.OriginID: "TestSSv1It1",
- utils.RequestType: utils.MetaPrepaid,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
- utils.Usage: authUsage,
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- utils.OptsRoutesProfileCount: 1.,
- },
- },
- }
- var rply sessions.V1AuthorizeReplyWithDigest
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1AuthorizeEventWithDigest,
- argsAuth, &rply); err != nil {
- t.Error(err)
- return
- }
- if rply.MaxUsage != authUsage.Seconds() {
- t.Errorf("Unexpected MaxUsage: %v", rply.MaxUsage)
- }
- if *rply.ResourceAllocation == "" {
- t.Errorf("Unexpected ResourceAllocation: %s", *rply.ResourceAllocation)
- }
- eSplrs := "route1,route2"
- tp := strings.Split(*rply.RoutesDigest, ",")
- sort.Strings(tp)
- *rply.RoutesDigest = strings.Join(tp, ",")
- if eSplrs != *rply.RoutesDigest {
- t.Errorf("expecting: %v, received: %v", eSplrs, *rply.RoutesDigest)
- }
- eAttrs := "OfficeGroup:Marketing"
- if eAttrs != *rply.AttributesDigest {
- t.Errorf("expecting: %v, received: %v", eAttrs, *rply.AttributesDigest)
- }
- }
-
- func testDspSessionInit(t *testing.T) {
- initUsage := 5 * time.Minute
- argsInit := &sessions.V1InitSessionArgs{
- InitSession: true,
- AllocateResources: true,
- GetAttributes: true,
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TestSSv1ItInitiateSession",
- Event: map[string]any{
- utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf",
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.OriginID: "TestSSv1It1",
- utils.RequestType: utils.MetaPrepaid,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
- utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC),
- utils.Usage: initUsage,
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- },
- }
- var rply sessions.V1InitReplyWithDigest
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1InitiateSessionWithDigest,
- argsInit, &rply); err != nil {
- t.Fatal(err)
- }
- if rply.MaxUsage != initUsage.Seconds() {
- t.Errorf("Unexpected MaxUsage: %v", rply.MaxUsage)
- }
- if *rply.ResourceAllocation != "RES_ACNT_1001" {
- t.Errorf("Unexpected ResourceAllocation: %s", *rply.ResourceAllocation)
- }
- }
-
- func testDspGetSessions(t *testing.T) {
- filtr := utils.SessionFilter{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- Tenant: "cgrates.org",
- Filters: []string{},
- }
- var reply int
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetActiveSessionsCount,
- &filtr, &reply); err != nil {
- t.Fatal(err)
- } else if reply != 3 {
- t.Errorf("Expected 3 active sessions received %v", reply)
- }
- var rply []*sessions.ExternalSession
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetActiveSessions,
- &filtr, &rply); err != nil {
- t.Fatal(err)
- } else if len(rply) != 3 {
- t.Errorf("Unexpected number of sessions returned %v :%s", len(rply), utils.ToJSON(rply))
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetPassiveSessionsCount,
- &filtr, &reply); err != nil {
- t.Fatal(err)
- } else if reply != 0 {
- t.Errorf("Expected no pasive sessions received %v", reply)
- }
- rply = nil
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetPassiveSessions,
- &filtr, &rply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Fatalf("Expected %v received %v with reply %s", utils.ErrNotFound, err, utils.ToJSON(rply))
- }
- }
-
- func testDspSessionUpdate(t *testing.T) {
- reqUsage := 5 * time.Minute
- argsUpdate := &sessions.V1UpdateSessionArgs{
- GetAttributes: true,
- UpdateSession: true,
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TestSSv1ItUpdateSession",
- Event: map[string]any{
- utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf",
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.OriginID: "TestSSv1It1",
- utils.RequestType: utils.MetaPrepaid,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
- utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC),
- utils.Usage: reqUsage,
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- },
- }
- var rply sessions.V1UpdateSessionReply
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1UpdateSession,
- argsUpdate, &rply); err != nil {
- t.Error(err)
- }
- eAttrs := &engine.AttrSProcessEventReply{
- MatchedProfiles: []string{"cgrates.org:ATTR_ACNT_1001"},
- AlteredFields: []string{"*req.OfficeGroup"},
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TestSSv1ItUpdateSession",
- Event: map[string]any{
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- "OfficeGroup": "Marketing",
- utils.OriginID: "TestSSv1It1",
- utils.RequestType: utils.MetaPrepaid,
- utils.SetupTime: "2018-01-07T17:00:00Z",
- utils.AnswerTime: "2018-01-07T17:00:10Z",
- utils.Usage: float64(reqUsage),
- utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- utils.Subsys: utils.MetaSessionS,
- },
- },
- }
- if *utils.Encoding == utils.MetaGOB { // gob maintains the variable type
- eAttrs.CGREvent.Event[utils.Usage] = reqUsage
- eAttrs.CGREvent.Event[utils.SetupTime] = argsUpdate.CGREvent.Event[utils.SetupTime]
- eAttrs.CGREvent.Event[utils.AnswerTime] = argsUpdate.CGREvent.Event[utils.AnswerTime]
- }
- if !reflect.DeepEqual(eAttrs, rply.Attributes) {
- t.Errorf("expecting: %+v, received: %+v",
- utils.ToJSON(eAttrs), utils.ToJSON(rply.Attributes))
- }
- if rply.MaxUsage == nil || *rply.MaxUsage != reqUsage {
- t.Errorf("Unexpected MaxUsage: %v", utils.ToJSON(rply))
- }
- }
-
- func testDspSessionUpdate2(t *testing.T) {
- reqUsage := 5 * time.Minute
- argsUpdate := &sessions.V1UpdateSessionArgs{
- GetAttributes: true,
- UpdateSession: true,
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TestSSv1ItUpdateSession",
- Event: map[string]any{
- utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf",
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.OriginID: "TestSSv1It1",
- utils.RequestType: utils.MetaPrepaid,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
- utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC),
- utils.Usage: reqUsage,
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- },
- }
- var rply sessions.V1UpdateSessionReply
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1UpdateSession,
- argsUpdate, &rply); err != nil {
- t.Fatal(err)
- }
- eAttrs := &engine.AttrSProcessEventReply{
- MatchedProfiles: []string{"cgrates.org:ATTR_1001_SESSIONAUTH"},
- AlteredFields: []string{"*req.LCRProfile", "*req.Password", "*req.RequestType", "*req.PaypalAccount"},
-
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TestSSv1ItUpdateSession",
- Event: map[string]any{
- utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf",
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- "LCRProfile": "premium_cli",
- "Password": "CGRateS.org",
- "PaypalAccount": "cgrates@paypal.com",
- utils.OriginID: "TestSSv1It1",
- utils.RequestType: utils.MetaPrepaid,
- utils.SetupTime: "2018-01-07T17:00:00Z",
- utils.AnswerTime: "2018-01-07T17:00:10Z",
- utils.Usage: float64(reqUsage),
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- utils.Subsys: utils.MetaSessionS,
- },
- },
- }
- sort.Strings(eAttrs.AlteredFields)
- if *utils.Encoding == utils.MetaGOB { // gob maintains the variable type
- eAttrs.CGREvent.Event[utils.Usage] = reqUsage
- eAttrs.CGREvent.Event[utils.SetupTime] = argsUpdate.CGREvent.Event[utils.SetupTime]
- eAttrs.CGREvent.Event[utils.AnswerTime] = argsUpdate.CGREvent.Event[utils.AnswerTime]
- }
- if rply.Attributes != nil && rply.Attributes.AlteredFields != nil {
- sort.Strings(rply.Attributes.AlteredFields)
- }
- if !reflect.DeepEqual(eAttrs, rply.Attributes) {
- t.Errorf("expecting: %+v, received: %+v",
- utils.ToJSON(eAttrs), utils.ToJSON(rply.Attributes))
- }
- if rply.MaxUsage == nil || *rply.MaxUsage != reqUsage {
- t.Errorf("Unexpected MaxUsage: %v", utils.ToJSON(rply))
- }
- }
-
- func testDspSessionTerminate(t *testing.T) {
- args := &sessions.V1TerminateSessionArgs{
- TerminateSession: true,
- ReleaseResources: true,
-
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TestSSv1ItUpdateSession",
- Event: map[string]any{
- utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf",
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.OriginID: "TestSSv1It1",
- utils.RequestType: utils.MetaPrepaid,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
- utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC),
- utils.Usage: 10 * time.Minute,
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- },
- }
- var rply string
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1TerminateSession,
- args, &rply); err != nil {
- t.Error(err)
- }
- if rply != utils.OK {
- t.Errorf("Unexpected reply: %s", rply)
- }
- }
-
- func testDspSessionProcessCDR(t *testing.T) {
- args := utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TestSSv1ItProcessCDR",
- Event: map[string]any{
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.OriginID: "TestSSv1It1",
- utils.RequestType: utils.MetaPostpaid,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
- utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC),
- utils.Usage: 10 * time.Minute,
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- }
-
- var rply string
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1ProcessCDR,
- args, &rply); err != nil {
- t.Fatal(err)
- }
- if rply != utils.OK {
- t.Errorf("Unexpected reply: %s", rply)
- }
- }
-
- func testDspSessionProcessEvent(t *testing.T) {
- initUsage := 5 * time.Minute
- args := sessions.V1ProcessMessageArgs{
- AllocateResources: true,
- Debit: true,
- GetAttributes: true,
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TestSSv1ItProcessEvent",
- Event: map[string]any{
- utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebac",
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.OriginHost: "disp",
- utils.OriginID: "TestSSv1It2",
- utils.RequestType: utils.MetaPrepaid,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
- utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC),
- utils.Usage: initUsage,
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- },
- }
- var rply sessions.V1ProcessMessageReply
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1ProcessMessage,
- args, &rply); err != nil {
- t.Fatal(err)
- }
- if rply.MaxUsage == nil || *rply.MaxUsage != initUsage {
- t.Errorf("Unexpected MaxUsage: %v", rply.MaxUsage)
- }
- if *rply.ResourceAllocation != "RES_ACNT_1001" {
- t.Errorf("Unexpected ResourceAllocation: %s", *rply.ResourceAllocation)
- }
- eAttrs := &engine.AttrSProcessEventReply{
- MatchedProfiles: []string{"cgrates.org:ATTR_ACNT_1001"},
- AlteredFields: []string{"*req.OfficeGroup"},
-
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TestSSv1ItProcessEvent",
- Event: map[string]any{
- utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebac",
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- "OfficeGroup": "Marketing",
- utils.OriginHost: "disp",
- utils.OriginID: "TestSSv1It2",
- utils.RequestType: utils.MetaPrepaid,
- utils.SetupTime: "2018-01-07T17:00:00Z",
- utils.AnswerTime: "2018-01-07T17:00:10Z",
- utils.Usage: 300000000000.0,
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- utils.Subsys: utils.MetaSessionS,
- },
- },
- }
- if *utils.Encoding == utils.MetaGOB { // gob maintains the variable type
- eAttrs.CGREvent.Event[utils.Usage] = initUsage
- eAttrs.CGREvent.Event[utils.SetupTime] = args.CGREvent.Event[utils.SetupTime]
- eAttrs.CGREvent.Event[utils.AnswerTime] = args.CGREvent.Event[utils.AnswerTime]
- }
- if !reflect.DeepEqual(eAttrs, rply.Attributes) {
- t.Errorf("expecting: %+v, received: %+v",
- utils.ToJSON(eAttrs), utils.ToJSON(rply.Attributes))
- }
- }
-
- func testDspSessionProcessEvent2(t *testing.T) {
- initUsage := 5 * time.Minute
- args := sessions.V1ProcessMessageArgs{
- AllocateResources: true,
- Debit: true,
- GetAttributes: true,
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TestSSv1ItProcessEvent",
- Event: map[string]any{
- utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf",
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.OriginID: "TestSSv1It2",
- utils.RequestType: utils.MetaPrepaid,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
- utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC),
- utils.Usage: initUsage,
- utils.EventName: "Internal",
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "pse12345",
- },
- },
- }
- var rply sessions.V1ProcessMessageReply
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1ProcessMessage,
- args, &rply); err != nil {
- t.Fatal(err)
- }
- if rply.MaxUsage == nil || *rply.MaxUsage != initUsage {
- t.Errorf("Unexpected MaxUsage: %v", rply.MaxUsage)
- }
- if *rply.ResourceAllocation != "RES_ACNT_1001" {
- t.Errorf("Unexpected ResourceAllocation: %s", *rply.ResourceAllocation)
- }
- eAttrs := &engine.AttrSProcessEventReply{
- MatchedProfiles: []string{"cgrates.org:ATTR_1001_SIMPLEAUTH"},
- AlteredFields: []string{"*req.EventName", "*req.Password"},
-
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TestSSv1ItProcessEvent",
- Event: map[string]any{
- utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf",
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- "Password": "CGRateS.org",
- utils.OriginID: "TestSSv1It2",
- utils.RequestType: utils.MetaPrepaid,
- utils.SetupTime: "2018-01-07T17:00:00Z",
- utils.AnswerTime: "2018-01-07T17:00:10Z",
- utils.Usage: 300000000000.0,
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "pse12345",
- utils.Subsys: utils.MetaSessionS,
- },
- },
- }
- if *utils.Encoding == utils.MetaGOB { // gob maintains the variable type
- eAttrs.CGREvent.Event[utils.Usage] = initUsage
- eAttrs.CGREvent.Event[utils.SetupTime] = args.CGREvent.Event[utils.SetupTime]
- eAttrs.CGREvent.Event[utils.AnswerTime] = args.CGREvent.Event[utils.AnswerTime]
- }
- sort.Strings(rply.Attributes.AlteredFields)
- if !reflect.DeepEqual(eAttrs, rply.Attributes) {
- t.Errorf("expecting: %+v, received: %+v",
- utils.ToJSON(eAttrs), utils.ToJSON(rply.Attributes))
- }
- }
-
- func testDspSessionReplicate(t *testing.T) {
- allEngine.initDataDb(t)
-
- var reply string
- // reload cache in order to corectly cahce the indexes
- if err := allEngine.RPC.Call(context.Background(), utils.CacheSv1Clear, &utils.AttrCacheIDsWithAPIOpts{
- CacheIDs: nil,
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Error("Reply: ", reply)
- }
- allEngine.loadData(t, path.Join(*utils.DataDir, "tariffplans", "testit"))
- testDspSessionAddBalacne(t)
- testDspSessionAuthorize(t)
- testDspSessionInit(t)
-
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1ReplicateSessions, &ArgsReplicateSessionsWithAPIOpts{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- Tenant: "cgrates.org",
- ArgsReplicateSessions: sessions.ArgsReplicateSessions{
- CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf",
- Passive: false,
- ConnIDs: []string{"rplConn"},
- },
- }, &reply); err != nil {
- t.Fatal(err)
- } else if reply != utils.OK {
- t.Errorf("Unexpected reply %s", reply)
- }
-
- var repl int
- time.Sleep(10 * time.Millisecond)
- if err := allEngine2.RPC.Call(context.Background(), utils.SessionSv1GetPassiveSessionsCount,
- new(utils.SessionFilter), &repl); err != nil {
- t.Fatal(err)
- } else if repl != 3 {
- t.Errorf("Expected 3 sessions received %v", repl)
- }
- }
-
- func testDspSessionPassive(t *testing.T) {
- allEngine.stopEngine(t)
- testDspSessionUpdate2(t)
- var repl int
- filtr := utils.SessionFilter{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- Tenant: "cgrates.org",
- Filters: []string{},
- }
- time.Sleep(10 * time.Millisecond)
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetPassiveSessionsCount,
- filtr, &repl); err != nil {
- t.Fatal(err)
- } else if repl != 0 {
- t.Errorf("Expected no passive sessions received %v", repl)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetActiveSessionsCount,
- filtr, &repl); err != nil {
- t.Fatal(err)
- } else if repl != 3 {
- t.Errorf("Expected 3 active sessions received %v", repl)
- }
-
- var rply []*sessions.ExternalSession
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetActiveSessions,
- &filtr, &rply); err != nil {
- t.Fatal(err)
- } else if len(rply) != 3 {
- t.Errorf("Unexpected number of sessions returned %v :%s", len(rply), utils.ToJSON(rply))
- }
-
- var reply string
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1SetPassiveSession, sessions.Session{
- CGRID: rply[0].CGRID,
- Tenant: rply[0].Tenant,
- ResourceID: "TestSSv1It1",
- EventStart: engine.NewMapEvent(map[string]any{
- utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf",
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.OriginID: "TestSSv1It1",
- utils.RequestType: utils.MetaPrepaid,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
- utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC),
- utils.Usage: 5 * time.Minute,
- }),
- SRuns: []*sessions.SRun{
- {
- Event: engine.NewMapEvent(map[string]any{
- "RunID": "CustomerCharges",
- utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf",
- utils.Tenant: "cgrates.org",
- utils.Category: "call",
- utils.ToR: utils.MetaVoice,
- utils.OriginID: "TestSSv1It1",
- utils.RequestType: utils.MetaPrepaid,
- utils.AccountField: "1001",
- utils.Destination: "1002",
- utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
- utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC),
- utils.Usage: 5 * time.Minute,
- }),
- CD: &engine.CallDescriptor{},
- EventCost: &engine.EventCost{},
-
- LastUsage: 5 * time.Minute,
- TotalUsage: 10 * time.Minute,
- },
- },
- OptsStart: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- }, &reply); err != nil {
- t.Fatal(err)
- } else if reply != utils.OK {
- t.Errorf("Unexpected reply %s", reply)
- }
- time.Sleep(10 * time.Millisecond)
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetPassiveSessionsCount,
- filtr, &repl); err != nil {
- t.Fatal(err)
- } else if repl != 1 {
- t.Errorf("Expected 1 passive sessions received %v", repl)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetActiveSessionsCount,
- filtr, &repl); err != nil {
- t.Fatal(err)
- } else if repl != 0 {
- t.Errorf("Expected no active sessions received %v", repl)
- }
- }
-
- func testDspSessionForceDisconect(t *testing.T) {
- allEngine.startEngine(t)
- allEngine.initDataDb(t)
-
- allEngine.loadData(t, path.Join(*utils.DataDir, "tariffplans", "testit"))
- testDspSessionAddBalacne(t)
- testDspSessionAuthorize(t)
- testDspSessionInit(t)
- var repl int
- filtr := utils.SessionFilter{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- Tenant: "cgrates.org",
- Filters: []string{},
- }
- time.Sleep(10 * time.Millisecond)
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetPassiveSessionsCount,
- filtr, &repl); err != nil {
- t.Fatal(err)
- } else if repl != 0 {
- t.Errorf("Expected no passive sessions received %v", repl)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetActiveSessionsCount,
- filtr, &repl); err != nil {
- t.Fatal(err)
- } else if repl != 3 {
- t.Errorf("Expected 3 active sessions received %v", repl)
- }
-
- var rply []*sessions.ExternalSession
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetActiveSessions,
- &filtr, &rply); err != nil {
- t.Fatal(err)
- } else if len(rply) != 3 {
- t.Errorf("Unexpected number of sessions returned %v :%s", len(rply), utils.ToJSON(rply))
- }
-
- var reply string
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1ForceDisconnect, &filtr, &reply); err != nil {
- t.Fatal(err)
- } else if reply != utils.OK {
- t.Errorf("Unexpected reply %s", reply)
- }
- time.Sleep(10 * time.Millisecond)
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetPassiveSessionsCount,
- filtr, &repl); err != nil {
- t.Fatal(err)
- } else if repl != 0 {
- t.Errorf("Expected 1 passive sessions received %v", repl)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetActiveSessionsCount,
- filtr, &repl); err != nil {
- t.Fatal(err)
- } else if repl != 0 {
- t.Errorf("Expected no active sessions received %v", repl)
- }
- }
-
- func testDspSessionProcessEvent3(t *testing.T) {
- args := &sessions.V1ProcessEventArgs{
- Flags: []string{"*rals:*terminate", "*resources:*release"},
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testSSv1ItProcessEventTerminateSession",
- Event: map[string]any{
- utils.Tenant: "cgrates.org",
- utils.ToR: utils.MetaVoice,
- utils.OriginID: "TestSSv1It2",
- utils.RequestType: utils.MetaPrepaid,
- utils.AccountField: "1001",
- utils.Subject: "ANY2CNT",
- utils.Destination: "1002",
- utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
- utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC),
- utils.Usage: 10 * time.Minute,
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "pse12345",
- },
- },
- }
- var rply sessions.V1ProcessEventReply
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1ProcessEvent,
- args, &rply); err != nil {
- t.Error(err)
- }
-
- var repl int
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetActiveSessionsCount,
- utils.SessionFilter{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- Tenant: "cgrates.org",
- Filters: []string{},
- }, &repl); err != nil {
- t.Fatal(err)
- } else if repl != 0 {
- t.Errorf("Expected no active sessions received %v", repl)
- }
- }
-
-func testDspSessionGetCost(t *testing.T) {
-
- args := &sessions.V1ProcessEventArgs{
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testSSv1ItGetCost",
- Event: map[string]any{
- utils.Tenant: "cgrates.org",
- utils.ToR: utils.MetaMonetary,
- utils.OriginID: "testSSv1ItProcessEventWithGetCost",
- utils.RequestType: utils.MetaPrepaid,
- utils.Subject: "ANY2CNT",
- utils.Destination: "1002",
- utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC),
- utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC),
- utils.Usage: 10 * time.Minute,
- },
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- },
- }
-
- var rply sessions.V1GetCostReply
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1GetCost,
- args, &rply); err != nil {
- t.Error(err)
- }
-
- if rply.EventCost == nil {
- t.Errorf("Received nil EventCost")
- } else if *rply.EventCost.Cost != 0.198 { // same cost as in CDR
- t.Errorf("Expected: %+v,received: %+v", 0.198, *rply.EventCost.Cost)
- } else if *rply.EventCost.Usage != 10*time.Minute {
- t.Errorf("Expected: %+v,received: %+v", 10*time.Minute, *rply.EventCost.Usage)
- }
-
-}
-
- func testDspSessionSTIRAuthenticate(t *testing.T) {
- var rply string
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1STIRAuthenticate,
- &sessions.V1STIRAuthenticateArgs{
- Attest: []string{"A"},
- PayloadMaxDuration: "-1",
- DestinationTn: "1002",
- Identity: "eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiIsInR5cCI6InBhc3Nwb3J0IiwieDV1IjoiL3Vzci9zaGFyZS9jZ3JhdGVzL3N0aXIvc3Rpcl9wdWJrZXkucGVtIn0.eyJhdHRlc3QiOiJBIiwiZGVzdCI6eyJ0biI6WyIxMDAyIl19LCJpYXQiOjE1ODcwMzg4MDIsIm9yaWciOnsidG4iOiIxMDAxIn0sIm9yaWdpZCI6IjEyMzQ1NiJ9.cMEMlFnfyTu8uxfeU4RoZTamA7ifFT9Ibwrvi1_LKwL2xAU6fZ_CSIxKbtyOpNhM_sV03x7CfA_v0T4sHkifzg;info=;ppt=shaken",
- OriginatorTn: "1001",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- }, &rply); err != nil {
- t.Fatal(err)
- } else if rply != utils.OK {
- t.Errorf("Expected: %s ,received: %s", utils.OK, rply)
- }
- }
-*/
-func testDspSessionSTIRIdentity(t *testing.T) {
- payload := &utils.PASSporTPayload{
- Dest: utils.PASSporTDestinationsIdentity{Tn: []string{"1002"}},
- IAT: 1587019822,
- Orig: utils.PASSporTOriginsIdentity{Tn: "1001"},
- OrigID: "123456",
- }
- args := &sessions.V1STIRIdentityArgs{
- Payload: payload,
- PublicKeyPath: "/usr/share/cgrates/stir/stir_pubkey.pem",
- PrivateKeyPath: "/usr/share/cgrates/stir/stir_privatekey.pem",
- OverwriteIAT: true,
- APIOpts: map[string]any{
- utils.OptsAPIKey: "ses12345",
- },
- }
- var rply string
- if err := dispEngine.RPC.Call(context.Background(), utils.SessionSv1STIRIdentity,
- args, &rply); err != nil {
- t.Error(err)
- }
- if err := sessions.AuthStirShaken(context.Background(), rply, "1001", "", "1002", "", utils.NewStringSet([]string{"A"}), 10*time.Minute); err != nil {
- t.Fatal(err)
- }
-}
diff --git a/dispatchers/sessions_test.go b/dispatchers/sessions_test.go
deleted file mode 100644
index b727344fd..000000000
--- a/dispatchers/sessions_test.go
+++ /dev/null
@@ -1,533 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/sessions"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDspSessionSv1PingNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.SessionSv1Ping(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1PingErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.SessionSv1Ping(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1AuthorizeEventNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *sessions.V1AuthorizeReply
- result := dspSrv.SessionSv1AuthorizeEvent(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1AuthorizeEventErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *sessions.V1AuthorizeReply
- result := dspSrv.SessionSv1AuthorizeEvent(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1AuthorizeEventWithDigestNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *sessions.V1AuthorizeReplyWithDigest
- result := dspSrv.SessionSv1AuthorizeEventWithDigest(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1AuthorizeEventWithDigestErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *sessions.V1AuthorizeReplyWithDigest
- result := dspSrv.SessionSv1AuthorizeEventWithDigest(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1SyncSessionsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.SessionSv1SyncSessions(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1SyncSessionsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.SessionSv1SyncSessions(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1ProcessCDRNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.SessionSv1ProcessCDR(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1ProcessCDRErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.SessionSv1ProcessCDR(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1ProcessMessageNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *sessions.V1ProcessMessageReply
- result := dspSrv.SessionSv1ProcessMessage(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1ProcessMessageErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *sessions.V1ProcessMessageReply
- result := dspSrv.SessionSv1ProcessMessage(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1ProcessEventNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *sessions.V1ProcessEventReply
- result := dspSrv.SessionSv1ProcessEvent(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1ProcessEventErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *sessions.V1ProcessEventReply
- result := dspSrv.SessionSv1ProcessEvent(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1GetActiveSessionsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.SessionFilter{
- Tenant: "tenant",
- }
- var reply *[]*sessions.ExternalSession
- result := dspSrv.SessionSv1GetActiveSessions(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1GetActiveSessionsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.SessionFilter{
- Tenant: "tenant",
- }
- var reply *[]*sessions.ExternalSession
- result := dspSrv.SessionSv1GetActiveSessions(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1GetActiveSessionsCountNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.SessionFilter{
- Tenant: "tenant",
- }
- var reply *int
- result := dspSrv.SessionSv1GetActiveSessionsCount(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1GetActiveSessionsCountErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.SessionFilter{
- Tenant: "tenant",
- }
- var reply *int
- result := dspSrv.SessionSv1GetActiveSessionsCount(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1ForceDisconnectNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.SessionFilter{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.SessionSv1ForceDisconnect(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1ForceDisconnectErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.SessionFilter{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.SessionSv1ForceDisconnect(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1GetPassiveSessionsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.SessionFilter{
- Tenant: "tenant",
- }
- var reply *[]*sessions.ExternalSession
- result := dspSrv.SessionSv1GetPassiveSessions(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1GetPassiveSessionsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.SessionFilter{
- Tenant: "tenant",
- }
- var reply *[]*sessions.ExternalSession
- result := dspSrv.SessionSv1GetPassiveSessions(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1ReplicateSessionsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := sessions.ArgsReplicateSessions{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.SessionSv1ReplicateSessions(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1ReplicateSessionsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := sessions.ArgsReplicateSessions{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.SessionSv1ReplicateSessions(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1GetPassiveSessionsCountNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.SessionFilter{
- Tenant: "tenant",
- }
- var reply *int
- result := dspSrv.SessionSv1GetPassiveSessionsCount(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1GetPassiveSessionsCountErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.SessionFilter{
- Tenant: "tenant",
- }
- var reply *int
- result := dspSrv.SessionSv1GetPassiveSessionsCount(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1STIRAuthenticateNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &sessions.V1STIRAuthenticateArgs{}
- var reply *string
- result := dspSrv.SessionSv1STIRAuthenticate(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1STIRAuthenticateErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &sessions.V1STIRAuthenticateArgs{}
- var reply *string
- result := dspSrv.SessionSv1STIRAuthenticate(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1STIRIdentityNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &sessions.V1STIRIdentityArgs{}
- var reply *string
- result := dspSrv.SessionSv1STIRIdentity(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1STIRIdentityErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &sessions.V1STIRIdentityArgs{}
- var reply *string
- result := dspSrv.SessionSv1STIRIdentity(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1ActivateSessionsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.SessionIDsWithAPIOpts{}
- var reply *string
- result := dspSrv.SessionSv1ActivateSessions(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1ActivateSessionsErrorTenant(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.SessionIDsWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.SessionSv1ActivateSessions(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1ActivateSessionsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.SessionIDsWithAPIOpts{}
- var reply *string
- result := dspSrv.SessionSv1ActivateSessions(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1DeactivateSessionsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.SessionIDsWithAPIOpts{}
- var reply *string
- result := dspSrv.SessionSv1DeactivateSessions(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1DeactivateSessionsErrorTenant(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.SessionIDsWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.SessionSv1DeactivateSessions(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspSessionSv1DeactivateSessionsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.SessionIDsWithAPIOpts{}
- var reply *string
- result := dspSrv.SessionSv1DeactivateSessions(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/dispatchers/stats.go b/dispatchers/stats.go
deleted file mode 100644
index 03b45adb1..000000000
--- a/dispatchers/stats.go
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) StatSv1GetQueueDecimalMetrics(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *map[string]*utils.Decimal) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaStats, utils.StatSv1GetQueueDecimalMetrics, args, reply)
-}
-func (dS *DispatcherService) StatSv1GetQueueFloatMetrics(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *map[string]float64) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaStats, utils.StatSv1GetQueueFloatMetrics, args, reply)
-}
-func (dS *DispatcherService) StatSv1GetQueueIDs(ctx *context.Context, args *utils.TenantWithAPIOpts, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaStats, utils.StatSv1GetQueueIDs, args, reply)
-}
-func (dS *DispatcherService) StatSv1GetQueueStringMetrics(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *map[string]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaStats, utils.StatSv1GetQueueStringMetrics, args, reply)
-}
-func (dS *DispatcherService) StatSv1GetStatQueue(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.StatQueue) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaStats, utils.StatSv1GetStatQueue, args, reply)
-}
-func (dS *DispatcherService) StatSv1GetStatQueuesForEvent(ctx *context.Context, args *utils.CGREvent, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaStats, utils.StatSv1GetStatQueuesForEvent, args, reply)
-}
-func (dS *DispatcherService) StatSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaStats, utils.StatSv1Ping, args, reply)
-}
-func (dS *DispatcherService) StatSv1ProcessEvent(ctx *context.Context, args *utils.CGREvent, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaStats, utils.StatSv1ProcessEvent, args, reply)
-}
-func (dS *DispatcherService) StatSv1ResetStatQueue(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaStats, utils.StatSv1ResetStatQueue, args, reply)
-}
diff --git a/dispatchers/stats_it_test.go b/dispatchers/stats_it_test.go
deleted file mode 100644
index cefa4fe85..000000000
--- a/dispatchers/stats_it_test.go
+++ /dev/null
@@ -1,352 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "reflect"
- "sort"
- "testing"
- "time"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/utils"
-)
-
-var sTestsDspSts = []func(t *testing.T){
- testDspStsPingFailover,
- testDspStsGetStatFailover,
-
- testDspStsPing,
- testDspStsTestAuthKey,
- testDspStsTestAuthKey2,
- testDspStsTestAuthKey3,
-}
-
-// Test start here
-func TestDspStatS(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- }
- testDsp(t, sTestsDspSts, "TestDspStatS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
-}
-
-func testDspStsPingFailover(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.StatSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- ev := utils.CGREvent{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "stat12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine2.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1Ping, &ev, &reply); err == nil {
- t.Errorf("Expected error but received %v and reply %v\n", err, reply)
- }
- allEngine.startEngine(t)
- allEngine2.startEngine(t)
-}
-
-func testDspStsGetStatFailover(t *testing.T) {
- var reply []string
- var metrics map[string]string
- expected := []string{"Stats1"}
- args := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "event1",
- Event: map[string]any{
- utils.EventName: "Event1",
- utils.AccountField: "1001",
- utils.Destination: "1002",
- utils.RunID: utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaStartTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
- utils.MetaUsage: 135 * time.Second,
- utils.MetaCost: 123.0,
- utils.OptsAPIKey: "stat12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1ProcessEvent, args, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(reply, expected) {
- t.Errorf("Expecting: %+v, received: %+v", expected, reply)
- }
-
- args2 := utils.TenantIDWithAPIOpts{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "stat12345",
- },
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "Stats1",
- },
- }
- allEngine.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1GetQueueStringMetrics,
- args2, &metrics); err != nil {
- t.Error(err)
- }
-
- allEngine.startEngine(t)
- allEngine2.stopEngine(t)
-
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1GetQueueStringMetrics,
- args2, &metrics); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expected error NOT_FOUND but received %v and reply %v\n", err, reply)
- }
- allEngine2.startEngine(t)
-}
-
-func testDspStsPing(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.StatSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1Ping, &utils.CGREvent{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "stat12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
-
-func testDspStsTestAuthKey(t *testing.T) {
- var reply []string
- args := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "event1",
- Event: map[string]any{
- utils.AccountField: "1001",
- },
- APIOpts: map[string]any{
- utils.MetaStartTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
- utils.MetaUsage: 135 * time.Second,
- utils.MetaCost: 123.0,
- utils.MetaPDD: 12 * time.Second,
- utils.OptsAPIKey: "12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1ProcessEvent,
- args, &reply); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
- t.Error(err)
- }
-
- args2 := utils.TenantIDWithAPIOpts{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "12345",
- },
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "Stats2",
- },
- }
-
- var metrics map[string]string
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1GetQueueStringMetrics,
- args2, &metrics); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
- t.Error(err)
- }
-}
-
-func testDspStsTestAuthKey2(t *testing.T) {
- var reply []string
- var metrics map[string]string
- expected := []string{"Stats2"}
- args := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "event1",
- Event: map[string]any{
- utils.AccountField: "1001",
- utils.RunID: utils.MetaDefault,
- utils.Destination: "1002",
- },
- APIOpts: map[string]any{
- utils.MetaStartTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
- utils.MetaUsage: 135 * time.Second,
- utils.MetaCost: 123.0,
- utils.OptsAPIKey: "stat12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1ProcessEvent, args, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(reply, expected) {
- t.Errorf("Expecting: %+v, received: %+v", expected, reply)
- }
-
- args2 := utils.TenantIDWithAPIOpts{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "stat12345",
- },
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "Stats2",
- },
- }
- expectedMetrics := map[string]string{
- utils.MetaTCC: "123",
- utils.MetaTCD: "2m15s",
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1GetQueueStringMetrics,
- args2, &metrics); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expectedMetrics, metrics) {
- t.Errorf("expecting: %+v, received reply: %s", expectedMetrics, metrics)
- }
-
- args = &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "event1",
- Event: map[string]any{
- utils.AccountField: "1002",
- utils.Destination: "1001",
- utils.RunID: utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaStartTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
- utils.MetaUsage: 45 * time.Second,
- utils.MetaCost: 10.0,
- utils.OptsAPIKey: "stat12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1ProcessEvent, args, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(reply, expected) {
- t.Errorf("Expecting: %+v, received: %+v", expected, reply)
- }
-
- expectedMetrics = map[string]string{
- utils.MetaTCC: "133",
- utils.MetaTCD: "3m0s",
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1GetQueueStringMetrics,
- args2, &metrics); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expectedMetrics, metrics) {
- t.Errorf("expecting: %+v, received reply: %s", expectedMetrics, metrics)
- }
-}
-
-func testDspStsTestAuthKey3(t *testing.T) {
- var reply []string
- var metrics map[string]float64
-
- args2 := utils.TenantIDWithAPIOpts{
- APIOpts: map[string]any{
- utils.OptsAPIKey: "stat12345",
- },
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "Stats2",
- },
- }
- expectedMetrics := map[string]float64{
- utils.MetaTCC: 133,
- utils.MetaTCD: 180 * 1e9,
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1GetQueueFloatMetrics,
- args2, &metrics); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expectedMetrics, metrics) {
- t.Errorf("expecting: %+v, received reply: %v", expectedMetrics, metrics)
- }
-
- estats := []string{"Stats2", "Stats2_1"}
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1GetQueueIDs,
- &utils.TenantWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "stat12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- }
- sort.Strings(estats)
- sort.Strings(reply)
- if !reflect.DeepEqual(estats, reply) {
- t.Errorf("expecting: %+v, received reply: %v", estats, reply)
- }
-
- estats = []string{"Stats2"}
- if err := dispEngine.RPC.Call(context.Background(), utils.StatSv1GetStatQueuesForEvent,
- &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "GetStats",
- Event: map[string]any{
- utils.AccountField: "1002",
- utils.Destination: "1001",
- utils.RunID: utils.MetaDefault,
- },
- APIOpts: map[string]any{
- utils.MetaStartTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
- utils.MetaUsage: 45 * time.Second,
- utils.MetaCost: 10.0,
- utils.OptsAPIKey: "stat12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(estats, reply) {
- t.Errorf("expecting: %+v, received reply: %v", estats, reply)
- }
-}
diff --git a/dispatchers/stats_test.go b/dispatchers/stats_test.go
deleted file mode 100644
index 3f6796cc5..000000000
--- a/dispatchers/stats_test.go
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDspStatSv1PingNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.StatSv1Ping(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspStatSv1PingNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *string
- result := dspSrv.StatSv1Ping(context.Background(), nil, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspStatSv1PingErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *string
- result := dspSrv.StatSv1Ping(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspStatSv1GetStatQueuesForEventNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *[]string
- result := dspSrv.StatSv1GetStatQueuesForEvent(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspStatSv1GetStatQueuesForEventErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *[]string
- result := dspSrv.StatSv1GetStatQueuesForEvent(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspStatSv1GetQueueStringMetricsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *map[string]string
- result := dspSrv.StatSv1GetQueueStringMetrics(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspStatSv1GetQueueStringMetricsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *map[string]string
- result := dspSrv.StatSv1GetQueueStringMetrics(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspStatSv1ProcessEventNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *[]string
- result := dspSrv.StatSv1ProcessEvent(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspStatSv1ProcessEventErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.CGREvent{
- Tenant: "tenant",
- }
- var reply *[]string
- result := dspSrv.StatSv1ProcessEvent(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspStatSv1GetQueueFloatMetricsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *map[string]float64
- result := dspSrv.StatSv1GetQueueFloatMetrics(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspStatSv1GetQueueFloatMetricsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }
- var reply *map[string]float64
- result := dspSrv.StatSv1GetQueueFloatMetrics(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspStatSv1GetQueueIDsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- CGREvent := &utils.TenantWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *[]string
- result := dspSrv.StatSv1GetQueueIDs(context.Background(), CGREvent, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspStatSv1GetQueueIDsErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- CGREvent := &utils.TenantWithAPIOpts{
- Tenant: "tenant",
- }
- var reply *[]string
- result := dspSrv.StatSv1GetQueueIDs(context.Background(), CGREvent, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/dispatchers/thresholds.go b/dispatchers/thresholds.go
deleted file mode 100644
index 399140824..000000000
--- a/dispatchers/thresholds.go
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) ThresholdSv1GetThreshold(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *engine.Threshold) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaThresholds, utils.ThresholdSv1GetThreshold, args, reply)
-}
-func (dS *DispatcherService) ThresholdSv1GetThresholdIDs(ctx *context.Context, args *utils.TenantWithAPIOpts, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaThresholds, utils.ThresholdSv1GetThresholdIDs, args, reply)
-}
-func (dS *DispatcherService) ThresholdSv1GetThresholdsForEvent(ctx *context.Context, args *utils.CGREvent, reply *engine.Thresholds) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaThresholds, utils.ThresholdSv1GetThresholdsForEvent, args, reply)
-}
-func (dS *DispatcherService) ThresholdSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaThresholds, utils.ThresholdSv1Ping, args, reply)
-}
-func (dS *DispatcherService) ThresholdSv1ProcessEvent(ctx *context.Context, args *utils.CGREvent, reply *[]string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaThresholds, utils.ThresholdSv1ProcessEvent, args, reply)
-}
-func (dS *DispatcherService) ThresholdSv1ResetThreshold(ctx *context.Context, args *utils.TenantIDWithAPIOpts, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantID != nil && len(args.TenantID.Tenant) != 0) {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaThresholds, utils.ThresholdSv1ResetThreshold, args, reply)
-}
diff --git a/dispatchers/thresholds_it_test.go b/dispatchers/thresholds_it_test.go
deleted file mode 100644
index bf62f462c..000000000
--- a/dispatchers/thresholds_it_test.go
+++ /dev/null
@@ -1,254 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "reflect"
- "sort"
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var sTestsDspTh = []func(t *testing.T){
- testDspThPingFailover,
- testDspThProcessEventFailover,
-
- testDspThPing,
- testDspThTestAuthKey,
- testDspThTestAuthKey2,
- testDspThTestAuthKey3,
-}
-
-// Test start here
-func TestDspThresholdS(t *testing.T) {
- var config1, config2, config3 string
- switch *utils.DBType {
- case utils.MetaInternal:
- t.SkipNow()
- case utils.MetaMySQL:
- config1 = "all_mysql"
- config2 = "all2_mysql"
- config3 = "dispatchers_mysql"
- case utils.MetaMongo:
- config1 = "all_mongo"
- config2 = "all2_mongo"
- config3 = "dispatchers_mongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
-
- dispDIR := "dispatchers"
- if *utils.Encoding == utils.MetaGOB {
- dispDIR += "_gob"
- }
- testDsp(t, sTestsDspTh, "TestDspThresholdS", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
-}
-
-func testDspThPingFailover(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.ThresholdSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- ev := utils.CGREvent{
- Tenant: "cgrates.org",
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "thr12345",
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ThresholdSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.ThresholdSv1Ping, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- allEngine2.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.ThresholdSv1Ping, &ev, &reply); err == nil {
- t.Errorf("Expected error but received %v and reply %v\n", err, reply)
- }
- allEngine.startEngine(t)
- allEngine2.startEngine(t)
-}
-
-func testDspThProcessEventFailover(t *testing.T) {
- var ids []string
- eIDs := []string{"THD_ACNT_1001"}
- args := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- utils.EventName: "Event1",
- utils.AccountField: "1001"},
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "thr12345",
- },
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.ThresholdSv1ProcessEvent, args,
- &ids); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expected error NOT_FOUND but received %v and reply %v\n", err, ids)
- }
- allEngine2.stopEngine(t)
- if err := dispEngine.RPC.Call(context.Background(), utils.ThresholdSv1ProcessEvent, args, &ids); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eIDs, ids) {
- t.Errorf("expecting: %+v, received: %+v", eIDs, ids)
- }
- allEngine2.startEngine(t)
-}
-
-func testDspThPing(t *testing.T) {
- var reply string
- if err := allEngine.RPC.Call(context.Background(), utils.ThresholdSv1Ping, new(utils.CGREvent), &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ThresholdSv1Ping, &utils.CGREvent{
- Tenant: "cgrates.org",
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "thr12345",
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.Pong {
- t.Errorf("Received: %s", reply)
- }
-}
-
-func testDspThTestAuthKey(t *testing.T) {
- var ids []string
- args := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- utils.AccountField: "1002"},
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "12345",
- },
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.ThresholdSv1ProcessEvent,
- args, &ids); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
- t.Error(err)
- }
- var th *engine.Thresholds
- if err := dispEngine.RPC.Call(context.Background(), utils.ThresholdSv1GetThresholdsForEvent, args,
- &th); err == nil || err.Error() != utils.ErrUnauthorizedApi.Error() {
- t.Error(err)
- }
-}
-
-func testDspThTestAuthKey2(t *testing.T) {
- var ids []string
- eIDs := []string{"THD_ACNT_1002"}
- args := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: utils.UUIDSha1Prefix(),
- Event: map[string]any{
- utils.AccountField: "1002"},
-
- APIOpts: map[string]any{
- utils.OptsAPIKey: "thr12345",
- },
- }
-
- if err := dispEngine.RPC.Call(context.Background(), utils.ThresholdSv1ProcessEvent, args, &ids); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eIDs, ids) {
- t.Errorf("expecting: %+v, received: %+v", eIDs, ids)
- }
- var th *engine.Thresholds
- eTh := &engine.Thresholds{
- &engine.Threshold{
- Tenant: "cgrates.org",
- ID: "THD_ACNT_1002",
- Hits: 1,
- },
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ThresholdSv1GetThresholdsForEvent, args, &th); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual((*eTh)[0].Tenant, (*th)[0].Tenant) {
- t.Errorf("expecting: %+v, received: %+v", (*eTh)[0].Tenant, (*th)[0].Tenant)
- } else if !reflect.DeepEqual((*eTh)[0].ID, (*th)[0].ID) {
- t.Errorf("expecting: %+v, received: %+v", (*eTh)[0].ID, (*th)[0].ID)
- } else if !reflect.DeepEqual((*eTh)[0].Hits, (*th)[0].Hits) {
- t.Errorf("expecting: %+v, received: %+v", (*eTh)[0].Hits, (*th)[0].Hits)
- }
-}
-
-func testDspThTestAuthKey3(t *testing.T) {
- var th *engine.Threshold
- eTh := &engine.Threshold{
- Tenant: "cgrates.org",
- ID: "THD_ACNT_1002",
- Hits: 1,
- }
- if err := dispEngine.RPC.Call(context.Background(), utils.ThresholdSv1GetThreshold, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "THD_ACNT_1002",
- },
- APIOpts: map[string]any{
- utils.OptsAPIKey: "thr12345",
- },
- }, &th); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual((*eTh).Tenant, (*th).Tenant) {
- t.Errorf("expecting: %+v, received: %+v", (*eTh).Tenant, (*th).Tenant)
- } else if !reflect.DeepEqual((*eTh).ID, (*th).ID) {
- t.Errorf("expecting: %+v, received: %+v", (*eTh).ID, (*th).ID)
- } else if !reflect.DeepEqual((*eTh).Hits, (*th).Hits) {
- t.Errorf("expecting: %+v, received: %+v", (*eTh).Hits, (*th).Hits)
- }
-
- var ids []string
- eIDs := []string{"THD_ACNT_1002"}
-
- if err := dispEngine.RPC.Call(context.Background(), utils.ThresholdSv1GetThresholdIDs, &utils.TenantWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsAPIKey: "thr12345",
- },
- }, &ids); err != nil {
- t.Fatal(err)
- }
- sort.Strings(ids)
- if !reflect.DeepEqual(eIDs, ids) {
- t.Errorf("expecting: %+v, received: %+v", eIDs, ids)
- }
-}
diff --git a/dispatchers/thresholds_test.go b/dispatchers/thresholds_test.go
deleted file mode 100644
index c76d10cdc..000000000
--- a/dispatchers/thresholds_test.go
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDspThresholdSv1PingNilEvent(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ThresholdSv1Ping(context.Background(), nil, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspThresholdSv1PingNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *string
- result := dspSrv.ThresholdSv1Ping(context.Background(), &utils.CGREvent{
- Tenant: "tenant",
- }, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspThresholdSv1PingErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *string
- result := dspSrv.ThresholdSv1Ping(context.Background(), &utils.CGREvent{}, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspThresholdSv1GetThresholdsForEventNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *engine.Thresholds
- result := dspSrv.ThresholdSv1GetThresholdsForEvent(context.Background(), &utils.CGREvent{
- Tenant: "tenant",
- }, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspThresholdSv1GetThresholdsEvnil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *engine.Thresholds
- result := dspSrv.ThresholdSv1GetThresholdsForEvent(context.Background(), &utils.CGREvent{
- Tenant: "tenant",
- }, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspThresholdSv1ProcessEventNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *[]string
- result := dspSrv.ThresholdSv1ProcessEvent(context.Background(), &utils.CGREvent{
- Tenant: "tenant",
- }, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspThresholdSv1ProcessEventnNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *[]string
- result := dspSrv.ThresholdSv1ProcessEvent(context.Background(), &utils.CGREvent{
- Tenant: "tenant",
- }, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspThresholdSv1GetThresholdIDsNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *[]string
- result := dspSrv.ThresholdSv1GetThresholdIDs(context.Background(), &utils.TenantWithAPIOpts{
- Tenant: "tenant",
- }, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspThresholdSv1GetThresholdIDErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *[]string
- result := dspSrv.ThresholdSv1GetThresholdIDs(context.Background(), &utils.TenantWithAPIOpts{
- Tenant: "tenant",
- }, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspThresholdSv1GetThresholdNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- var reply *engine.Threshold
- result := dspSrv.ThresholdSv1GetThreshold(context.Background(), &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }, reply)
- expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDspThresholdSv1GetThresholdErrorNil(t *testing.T) {
- cgrCfg := config.NewDefaultCGRConfig()
- dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
- cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
- var reply *engine.Threshold
- result := dspSrv.ThresholdSv1GetThreshold(context.Background(), &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "tenant",
- },
- }, reply)
- expected := "MANDATORY_IE_MISSING: [ApiKey]"
- if result == nil || result.Error() != expected {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/dispatchers/tpes.go b/dispatchers/tpes.go
deleted file mode 100644
index af282ea58..000000000
--- a/dispatchers/tpes.go
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/tpes"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) TPeSv1ExportTariffPlan(ctx *context.Context, args *tpes.ArgsExportTP, reply *[]uint8) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaTpes, utils.TPeSv1ExportTariffPlan, args, reply)
-}
-func (dS *DispatcherService) TPeSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaTpes, utils.TPeSv1Ping, args, reply)
-}
diff --git a/dispatchers/trends.go b/dispatchers/trends.go
deleted file mode 100644
index 569852bda..000000000
--- a/dispatchers/trends.go
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-// do not modify this code because it's generated
-package dispatchers
-
-import (
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (dS *DispatcherService) TrendSv1GetScheduledTrends(ctx *context.Context, args *utils.ArgScheduledTrends, reply *[]utils.ScheduledTrend) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantIDWithAPIOpts.TenantID != nil && len(args.TenantIDWithAPIOpts.TenantID.Tenant) != 0) {
- tnt = args.TenantIDWithAPIOpts.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.TenantIDWithAPIOpts.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaTrends, utils.TrendSv1GetScheduledTrends, args, reply)
-}
-func (dS *DispatcherService) TrendSv1GetTrend(ctx *context.Context, args *utils.ArgGetTrend, reply *engine.Trend) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.TenantWithAPIOpts.Tenant) != 0 {
- tnt = args.TenantWithAPIOpts.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.TenantWithAPIOpts.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaTrends, utils.TrendSv1GetTrend, args, reply)
-}
-func (dS *DispatcherService) TrendSv1GetTrendSummary(ctx *context.Context, args utils.TenantIDWithAPIOpts, reply *engine.TrendSummary) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args.TenantID != nil && len(args.TenantID.Tenant) != 0 {
- tnt = args.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := args.APIOpts
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaTrends, utils.TrendSv1GetTrendSummary, args, reply)
-}
-func (dS *DispatcherService) TrendSv1Ping(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && len(args.Tenant) != 0 {
- tnt = args.Tenant
- }
- ev := make(map[string]any)
- if args != nil {
- ev = args.Event
- }
- opts := make(map[string]any)
- if args != nil {
- opts = args.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaTrends, utils.TrendSv1Ping, args, reply)
-}
-func (dS *DispatcherService) TrendSv1ScheduleQueries(ctx *context.Context, args *utils.ArgScheduleTrendQueries, reply *int) (err error) {
- tnt := dS.cfg.GeneralCfg().DefaultTenant
- if args != nil && (args.TenantIDWithAPIOpts.TenantID != nil && len(args.TenantIDWithAPIOpts.TenantID.Tenant) != 0) {
- tnt = args.TenantIDWithAPIOpts.TenantID.Tenant
- }
- ev := make(map[string]any)
- opts := make(map[string]any)
- if args != nil {
- opts = args.TenantIDWithAPIOpts.APIOpts
- }
- return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaTrends, utils.TrendSv1ScheduleQueries, args, reply)
-}
diff --git a/dispatchers/utils.go b/dispatchers/utils.go
deleted file mode 100644
index 32512cc63..000000000
--- a/dispatchers/utils.go
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "strings"
-
- "github.com/cgrates/cgrates/utils"
-)
-
-func ParseStringSet(s string) utils.StringSet {
- if s == utils.MetaZero {
- return make(utils.StringSet)
- }
- return utils.NewStringSet(strings.Split(s, utils.ANDSep))
-}
diff --git a/dispatchers/utils_test.go b/dispatchers/utils_test.go
deleted file mode 100644
index ffa66ca69..000000000
--- a/dispatchers/utils_test.go
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package dispatchers
-
-import (
- "reflect"
- "strings"
- "testing"
-
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestDParseStringSetMetaZero(t *testing.T) {
- stringTest := utils.MetaZero
- result := ParseStringSet(stringTest)
- expected := make(utils.StringSet)
- if !reflect.DeepEqual(result, expected) {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
-
-func TestDParseStringSet(t *testing.T) {
- stringTest := "testString"
- result := ParseStringSet(stringTest)
- expected := utils.NewStringSet(strings.Split(stringTest, utils.ANDSep))
- if !reflect.DeepEqual(result, expected) {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
- }
-}
diff --git a/engine/caches.go b/engine/caches.go
index 2b7106078..dbd0660e9 100644
--- a/engine/caches.go
+++ b/engine/caches.go
@@ -62,10 +62,6 @@ func init() {
// Filters
gob.Register(new(Filter))
gob.Register(new(FilterWithAPIOpts))
- // Dispatcher
- gob.Register(new(DispatcherHost))
- gob.Register(new(DispatcherHostProfile))
- gob.Register(new(DispatcherHostWithAPIOpts))
// RateProfiles
gob.Register(new(utils.RateProfile))
gob.Register(new(utils.RateProfileWithAPIOpts))
diff --git a/engine/connmanager.go b/engine/connmanager.go
index da0eaccea..e0566e611 100644
--- a/engine/connmanager.go
+++ b/engine/connmanager.go
@@ -228,74 +228,6 @@ func (cM *ConnManager) AddInternalConn(connName, apiPrefix string,
cM.dynIntCh[apiPrefix] = iConnCh
}
-func (cM *ConnManager) EnableDispatcher(dsp IntService) {
- cM.disp = map[string]chan context.ClientConnector{
- utils.ConcatenatedKey(utils.MetaDispatchers, utils.MetaAttributes): cM.rpcInternal[utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes)],
- }
- cM.dispIntCh = make(RPCClientSet)
- for m, srv := range dsp {
- var key string
- switch {
- case strings.HasPrefix(m, utils.AccountS):
- key = utils.MetaAccounts
- case strings.HasPrefix(m, utils.ActionS):
- key = utils.MetaActions
- case strings.HasPrefix(m, utils.AttributeS):
- key = utils.MetaAttributes
- case strings.HasPrefix(m, utils.CacheS):
- key = utils.MetaCaches
- case strings.HasPrefix(m, utils.ChargerS):
- key = utils.MetaChargers
- case strings.HasPrefix(m, utils.ConfigS):
- key = utils.MetaConfig
- case strings.HasPrefix(m, utils.DispatcherS):
- key = utils.MetaDispatchers
- case strings.HasPrefix(m, utils.GuardianS):
- key = utils.MetaGuardian
- case strings.HasPrefix(m, utils.RateS):
- key = utils.MetaRates
- case strings.HasPrefix(m, utils.ResourceS):
- key = utils.MetaResources
- case strings.HasPrefix(m, utils.RouteS):
- key = utils.MetaRoutes
- case strings.HasPrefix(m, utils.SessionS):
- key = utils.MetaSessionS
- case strings.HasPrefix(m, utils.StatS):
- key = utils.MetaStats
- case strings.HasPrefix(m, utils.ThresholdS):
- key = utils.MetaThresholds
- case strings.HasPrefix(m, utils.CDRs):
- key = utils.MetaCDRs
- case strings.HasPrefix(m, utils.ReplicatorS):
- key = utils.MetaReplicator
- case strings.HasPrefix(m, utils.EeS):
- key = utils.MetaEEs
- case strings.HasPrefix(m, utils.CoreS):
- key = utils.MetaCore
- case strings.HasPrefix(m, utils.AnalyzerS):
- key = utils.MetaAnalyzerS
- case strings.HasPrefix(m, utils.AdminS):
- key = utils.MetaAdminS
- case strings.HasPrefix(m, utils.LoaderS):
- key = utils.MetaLoaders
- case strings.HasPrefix(m, utils.ServiceManager):
- key = utils.MetaServiceManager
- }
- key = utils.ConcatenatedKey(utils.MetaInternal, key)
- ch := make(chan birpc.ClientConnector, 1)
- ch <- srv
- cM.disp[key] = ch
- cM.dispIntCh[m] = ch
- }
- cM.Reload()
-}
-
-func (cM *ConnManager) DisableDispatcher() {
- cM.disp = nil
- cM.dispIntCh = nil
- cM.Reload()
-}
-
func (cM *ConnManager) getInternalConnChan(key string) (c chan birpc.ClientConnector, has bool) {
if cM.disp != nil {
c, has = cM.disp[key]
diff --git a/engine/datadbmock.go b/engine/datadbmock.go
index 1162a67a2..00cb02de5 100644
--- a/engine/datadbmock.go
+++ b/engine/datadbmock.go
@@ -24,65 +24,59 @@ import (
)
type DataDBMock struct {
- RemoveRateProfileDrvF func(ctx *context.Context, str1 string, str2 string, rateIDs *[]string) error
- SetRateProfileDrvF func(*context.Context, *utils.RateProfile, bool) error
- GetRateProfileDrvF func(*context.Context, string, string) (*utils.RateProfile, error)
- GetRateProfileRatesDrvF func(*context.Context, string, string, string, bool) ([]string, []*utils.Rate, error)
- GetKeysForPrefixF func(*context.Context, string) ([]string, error)
- GetIndexesDrvF func(ctx *context.Context, idxItmType, tntCtx, idxKey, transactionID string) (indexes map[string]utils.StringSet, err error)
- SetIndexesDrvF func(ctx *context.Context, idxItmType, tntCtx string, indexes map[string]utils.StringSet, commit bool, transactionID string) (err error)
- GetAttributeProfileDrvF func(ctx *context.Context, str1 string, str2 string) (*AttributeProfile, error)
- SetAttributeProfileDrvF func(ctx *context.Context, attr *AttributeProfile) error
- RemoveAttributeProfileDrvF func(ctx *context.Context, str1 string, str2 string) error
- SetLoadIDsDrvF func(ctx *context.Context, loadIDs map[string]int64) error
- GetFilterDrvF func(ctx *context.Context, str1 string, str2 string) (*Filter, error)
- GetChargerProfileDrvF func(ctx *context.Context, tnt, id string) (*ChargerProfile, error)
- SetChargerProfileDrvF func(ctx *context.Context, chr *ChargerProfile) (err error)
- GetThresholdProfileDrvF func(ctx *context.Context, tenant, id string) (tp *ThresholdProfile, err error)
- SetThresholdProfileDrvF func(ctx *context.Context, tp *ThresholdProfile) (err error)
- RemThresholdProfileDrvF func(ctx *context.Context, tenant, id string) (err error)
- GetThresholdDrvF func(ctx *context.Context, tenant, id string) (*Threshold, error)
- RemoveThresholdDrvF func(ctx *context.Context, tnt, id string) error
- GetResourceProfileDrvF func(ctx *context.Context, tnt, id string) (*ResourceProfile, error)
- SetResourceProfileDrvF func(ctx *context.Context, rp *ResourceProfile) error
- RemoveResourceProfileDrvF func(ctx *context.Context, tnt, id string) error
- RemoveResourceDrvF func(ctx *context.Context, tnt, id string) error
- SetResourceDrvF func(ctx *context.Context, r *Resource) error
- SetTrendProfileDrvF func(ctx *context.Context, tr *TrendProfile) (err error)
- GetTrendProfileDrvF func(ctx *context.Context, tenant string, id string) (sq *TrendProfile, err error)
- RemTrendProfileDrvF func(ctx *context.Context, tenant string, id string) (err error)
- SetRankingProfileDrvF func(ctx *context.Context, sq *RankingProfile) (err error)
- GetRankingProfileDrvF func(ctx *context.Context, tenant string, id string) (sq *RankingProfile, err error)
- RemRankingProfileDrvF func(ctx *context.Context, tenant string, id string) (err error)
- GetStatQueueProfileDrvF func(ctx *context.Context, tenant, id string) (sq *StatQueueProfile, err error)
- SetStatQueueProfileDrvF func(ctx *context.Context, sq *StatQueueProfile) (err error)
- RemStatQueueProfileDrvF func(ctx *context.Context, tenant, id string) (err error)
- RemStatQueueDrvF func(ctx *context.Context, tenant, id string) (err error)
- SetFilterDrvF func(ctx *context.Context, fltr *Filter) error
- GetActionProfileDrvF func(ctx *context.Context, tenant string, ID string) (*ActionProfile, error)
- SetActionProfileDrvF func(ctx *context.Context, ap *ActionProfile) error
- RemoveActionProfileDrvF func(ctx *context.Context, tenant string, ID string) error
- RemoveFilterDrvF func(ctx *context.Context, str1 string, str2 string) error
- SetAccountDrvF func(ctx *context.Context, profile *utils.Account) error
- GetAccountDrvF func(ctx *context.Context, str1 string, str2 string) (*utils.Account, error)
- RemoveAccountDrvF func(ctx *context.Context, str1 string, str2 string) error
- GetRouteProfileDrvF func(ctx *context.Context, tnt, id string) (*RouteProfile, error)
- SetRouteProfileDrvF func(ctx *context.Context, rtPrf *RouteProfile) error
- RemoveRouteProfileDrvF func(ctx *context.Context, tnt, id string) error
- RemoveChargerProfileDrvF func(ctx *context.Context, chr string, rpl string) error
- GetDispatcherProfileDrvF func(*context.Context, string, string) (*DispatcherProfile, error)
- SetDispatcherProfileDrvF func(*context.Context, *DispatcherProfile) error
- RemoveDispatcherProfileDrvF func(*context.Context, string, string) error
- GetDispatcherHostDrvF func(*context.Context, string, string) (*DispatcherHost, error)
- SetDispatcherHostDrvF func(*context.Context, *DispatcherHost) error
- RemoveDispatcherHostDrvF func(*context.Context, string, string) error
- GetItemLoadIDsDrvF func(ctx *context.Context, itemIDPrefix string) (loadIDs map[string]int64, err error)
- SetThresholdDrvF func(*context.Context, *Threshold) error
- SetStatQueueDrvF func(*context.Context, *StoredStatQueue, *StatQueue) error
- HasDataDrvF func(ctx *context.Context, category, subject, tenant string) (bool, error)
- RemoveIndexesDrvF func(ctx *context.Context, idxItmType, tntCtx, idxKey string) error
- GetStatQueueDrvF func(ctx *context.Context, tenant, id string) (sq *StatQueue, err error)
- GetResourceDrvF func(ctx *context.Context, tenant, id string) (*Resource, error)
+ RemoveRateProfileDrvF func(ctx *context.Context, str1 string, str2 string, rateIDs *[]string) error
+ SetRateProfileDrvF func(*context.Context, *utils.RateProfile, bool) error
+ GetRateProfileDrvF func(*context.Context, string, string) (*utils.RateProfile, error)
+ GetRateProfileRatesDrvF func(*context.Context, string, string, string, bool) ([]string, []*utils.Rate, error)
+ GetKeysForPrefixF func(*context.Context, string) ([]string, error)
+ GetIndexesDrvF func(ctx *context.Context, idxItmType, tntCtx, idxKey, transactionID string) (indexes map[string]utils.StringSet, err error)
+ SetIndexesDrvF func(ctx *context.Context, idxItmType, tntCtx string, indexes map[string]utils.StringSet, commit bool, transactionID string) (err error)
+ GetAttributeProfileDrvF func(ctx *context.Context, str1 string, str2 string) (*AttributeProfile, error)
+ SetAttributeProfileDrvF func(ctx *context.Context, attr *AttributeProfile) error
+ RemoveAttributeProfileDrvF func(ctx *context.Context, str1 string, str2 string) error
+ SetLoadIDsDrvF func(ctx *context.Context, loadIDs map[string]int64) error
+ GetFilterDrvF func(ctx *context.Context, str1 string, str2 string) (*Filter, error)
+ GetChargerProfileDrvF func(ctx *context.Context, tnt, id string) (*ChargerProfile, error)
+ SetChargerProfileDrvF func(ctx *context.Context, chr *ChargerProfile) (err error)
+ GetThresholdProfileDrvF func(ctx *context.Context, tenant, id string) (tp *ThresholdProfile, err error)
+ SetThresholdProfileDrvF func(ctx *context.Context, tp *ThresholdProfile) (err error)
+ RemThresholdProfileDrvF func(ctx *context.Context, tenant, id string) (err error)
+ GetThresholdDrvF func(ctx *context.Context, tenant, id string) (*Threshold, error)
+ RemoveThresholdDrvF func(ctx *context.Context, tnt, id string) error
+ GetResourceProfileDrvF func(ctx *context.Context, tnt, id string) (*ResourceProfile, error)
+ SetResourceProfileDrvF func(ctx *context.Context, rp *ResourceProfile) error
+ RemoveResourceProfileDrvF func(ctx *context.Context, tnt, id string) error
+ RemoveResourceDrvF func(ctx *context.Context, tnt, id string) error
+ SetResourceDrvF func(ctx *context.Context, r *Resource) error
+ SetTrendProfileDrvF func(ctx *context.Context, tr *TrendProfile) (err error)
+ GetTrendProfileDrvF func(ctx *context.Context, tenant string, id string) (sq *TrendProfile, err error)
+ RemTrendProfileDrvF func(ctx *context.Context, tenant string, id string) (err error)
+ SetRankingProfileDrvF func(ctx *context.Context, sq *RankingProfile) (err error)
+ GetRankingProfileDrvF func(ctx *context.Context, tenant string, id string) (sq *RankingProfile, err error)
+ RemRankingProfileDrvF func(ctx *context.Context, tenant string, id string) (err error)
+ GetStatQueueProfileDrvF func(ctx *context.Context, tenant, id string) (sq *StatQueueProfile, err error)
+ SetStatQueueProfileDrvF func(ctx *context.Context, sq *StatQueueProfile) (err error)
+ RemStatQueueProfileDrvF func(ctx *context.Context, tenant, id string) (err error)
+ RemStatQueueDrvF func(ctx *context.Context, tenant, id string) (err error)
+ SetFilterDrvF func(ctx *context.Context, fltr *Filter) error
+ GetActionProfileDrvF func(ctx *context.Context, tenant string, ID string) (*ActionProfile, error)
+ SetActionProfileDrvF func(ctx *context.Context, ap *ActionProfile) error
+ RemoveActionProfileDrvF func(ctx *context.Context, tenant string, ID string) error
+ RemoveFilterDrvF func(ctx *context.Context, str1 string, str2 string) error
+ SetAccountDrvF func(ctx *context.Context, profile *utils.Account) error
+ GetAccountDrvF func(ctx *context.Context, str1 string, str2 string) (*utils.Account, error)
+ RemoveAccountDrvF func(ctx *context.Context, str1 string, str2 string) error
+ GetRouteProfileDrvF func(ctx *context.Context, tnt, id string) (*RouteProfile, error)
+ SetRouteProfileDrvF func(ctx *context.Context, rtPrf *RouteProfile) error
+ RemoveRouteProfileDrvF func(ctx *context.Context, tnt, id string) error
+ RemoveChargerProfileDrvF func(ctx *context.Context, chr string, rpl string) error
+ GetItemLoadIDsDrvF func(ctx *context.Context, itemIDPrefix string) (loadIDs map[string]int64, err error)
+ SetThresholdDrvF func(*context.Context, *Threshold) error
+ SetStatQueueDrvF func(*context.Context, *StoredStatQueue, *StatQueue) error
+ HasDataDrvF func(ctx *context.Context, category, subject, tenant string) (bool, error)
+ RemoveIndexesDrvF func(ctx *context.Context, idxItmType, tntCtx, idxKey string) error
+ GetStatQueueDrvF func(ctx *context.Context, tenant, id string) (sq *StatQueue, err error)
+ GetResourceDrvF func(ctx *context.Context, tenant, id string) (*Resource, error)
}
// Storage methods
@@ -411,27 +405,6 @@ func (dbM *DataDBMock) RemoveChargerProfileDrv(ctx *context.Context, chr string,
return utils.ErrNotImplemented
}
-func (dbM *DataDBMock) GetDispatcherProfileDrv(ctx *context.Context, tnt, id string) (*DispatcherProfile, error) {
- if dbM.GetDispatcherProfileDrvF != nil {
- return dbM.GetDispatcherProfileDrvF(ctx, tnt, id)
- }
- return nil, utils.ErrNotImplemented
-}
-
-func (dbM *DataDBMock) SetDispatcherProfileDrv(ctx *context.Context, dP *DispatcherProfile) error {
- if dbM.GetDispatcherProfileDrvF != nil {
- return dbM.SetDispatcherProfileDrvF(ctx, dP)
- }
- return utils.ErrNotImplemented
-}
-
-func (dbM *DataDBMock) RemoveDispatcherProfileDrv(ctx *context.Context, tnt, id string) error {
- if dbM.RemoveDispatcherProfileDrvF != nil {
- return dbM.RemoveDispatcherProfileDrvF(ctx, tnt, id)
- }
- return utils.ErrNotImplemented
-}
-
func (dbM *DataDBMock) GetItemLoadIDsDrv(ctx *context.Context, itemIDPrefix string) (loadIDs map[string]int64, err error) {
if dbM.GetItemLoadIDsDrvF != nil {
return dbM.GetItemLoadIDsDrvF(ctx, itemIDPrefix)
@@ -450,27 +423,6 @@ func (dbM *DataDBMock) RemoveLoadIDsDrv() error {
return utils.ErrNotImplemented
}
-func (dbM *DataDBMock) GetDispatcherHostDrv(ctx *context.Context, tnt, id string) (*DispatcherHost, error) {
- if dbM.GetDispatcherHostDrvF != nil {
- return dbM.GetDispatcherHostDrvF(ctx, tnt, id)
- }
- return nil, utils.ErrNotImplemented
-}
-
-func (dbM *DataDBMock) SetDispatcherHostDrv(ctx *context.Context, dH *DispatcherHost) error {
- if dbM.GetDispatcherHostDrvF != nil {
- return dbM.SetDispatcherHostDrvF(ctx, dH)
- }
- return utils.ErrNotImplemented
-}
-
-func (dbM *DataDBMock) RemoveDispatcherHostDrv(ctx *context.Context, tnt, id string) error {
- if dbM.RemoveDispatcherHostDrvF != nil {
- return dbM.RemoveDispatcherHostDrvF(ctx, tnt, id)
- }
- return utils.ErrNotImplemented
-}
-
func (dbM *DataDBMock) GetRateProfileDrv(ctx *context.Context, tnt string, id string) (*utils.RateProfile, error) {
if dbM.GetRateProfileDrvF != nil {
return dbM.GetRateProfileDrvF(ctx, tnt, id)
diff --git a/engine/datamanager.go b/engine/datamanager.go
index 531f206b6..bbe0b50d1 100644
--- a/engine/datamanager.go
+++ b/engine/datamanager.go
@@ -38,7 +38,6 @@ var (
utils.ThresholdFilterIndexes: {},
utils.RouteFilterIndexes: {},
utils.ChargerFilterIndexes: {},
- utils.DispatcherFilterIndexes: {},
utils.RateProfilesFilterIndexPrfx: {},
utils.ActionProfilesFilterIndexPrfx: {},
utils.RateFilterIndexPrfx: {},
@@ -61,9 +60,6 @@ var (
utils.RouteProfilePrefix: {},
utils.AttributeProfilePrefix: {},
utils.ChargerProfilePrefix: {},
- utils.DispatcherProfilePrefix: {},
- utils.DispatcherHostPrefix: {},
- utils.MetaDispatchers: {}, // not realy a prefix as this is not stored in DB
utils.AccountFilterIndexPrfx: {},
utils.AccountPrefix: {},
utils.RateProfilePrefix: {},
@@ -74,7 +70,6 @@ var (
utils.ThresholdFilterIndexes: {},
utils.RouteFilterIndexes: {},
utils.ChargerFilterIndexes: {},
- utils.DispatcherFilterIndexes: {},
utils.RateProfilesFilterIndexPrfx: {},
utils.ActionProfilesFilterIndexPrfx: {},
utils.RateFilterIndexPrfx: {},
@@ -125,7 +120,7 @@ func (dm *DataManager) CacheDataFromDB(ctx *context.Context, prfx string, ids []
return
}
// *apiban and *dispatchers are not stored in database
- if prfx == utils.MetaAPIBan || prfx == utils.MetaDispatchers || prfx == utils.MetaSentryPeer { // no need for ids in this case
+ if prfx == utils.MetaAPIBan || prfx == utils.MetaSentryPeer { // no need for ids in this case
ids = []string{utils.EmptyString}
} else if len(ids) != 0 && ids[0] == utils.MetaAny {
if mustBeCached {
@@ -203,12 +198,6 @@ func (dm *DataManager) CacheDataFromDB(ctx *context.Context, prfx string, ids []
case utils.ChargerProfilePrefix:
tntID := utils.NewTenantID(dataID)
_, err = dm.GetChargerProfile(ctx, tntID.Tenant, tntID.ID, false, true, utils.NonTransactional)
- case utils.DispatcherProfilePrefix:
- tntID := utils.NewTenantID(dataID)
- _, err = dm.GetDispatcherProfile(ctx, tntID.Tenant, tntID.ID, false, true, utils.NonTransactional)
- case utils.DispatcherHostPrefix:
- tntID := utils.NewTenantID(dataID)
- _, err = dm.GetDispatcherHost(ctx, tntID.Tenant, tntID.ID, false, true, utils.NonTransactional)
case utils.RateProfilePrefix:
tntID := utils.NewTenantID(dataID)
_, err = dm.GetRateProfile(ctx, tntID.Tenant, tntID.ID, false, true, utils.NonTransactional)
@@ -251,12 +240,6 @@ func (dm *DataManager) CacheDataFromDB(ctx *context.Context, prfx string, ids []
return
}
_, err = dm.GetIndexes(ctx, utils.CacheChargerFilterIndexes, tntCtx, idxKey, utils.NonTransactional, false, true)
- case utils.DispatcherFilterIndexes:
- var tntCtx, idxKey string
- if tntCtx, idxKey, err = splitFilterIndex(dataID); err != nil {
- return
- }
- _, err = dm.GetIndexes(ctx, utils.CacheDispatcherFilterIndexes, tntCtx, idxKey, utils.NonTransactional, false, true)
case utils.RateProfilesFilterIndexPrfx:
var tntCtx, idxKey string
if tntCtx, idxKey, err = splitFilterIndex(dataID); err != nil {
@@ -2091,230 +2074,6 @@ func (dm *DataManager) RemoveChargerProfile(ctx *context.Context, tenant, id str
return
}
-func (dm *DataManager) GetDispatcherProfile(ctx *context.Context, tenant, id string, cacheRead, cacheWrite bool,
- transactionID string) (dpp *DispatcherProfile, err error) {
- tntID := utils.ConcatenatedKey(tenant, id)
- if cacheRead {
- if x, ok := Cache.Get(utils.CacheDispatcherProfiles, tntID); ok {
- if x == nil {
- return nil, utils.ErrDSPProfileNotFound
- }
- return x.(*DispatcherProfile), nil
- }
- }
- if dm == nil {
- err = utils.ErrNoDatabaseConn
- return
- }
- dpp, err = dm.dataDB.GetDispatcherProfileDrv(ctx, tenant, id)
- if err != nil {
- if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaDispatcherProfiles]; err == utils.ErrDSPProfileNotFound && itm.Remote {
- if err = dm.connMgr.Call(ctx, config.CgrConfig().DataDbCfg().RmtConns,
- utils.ReplicatorSv1GetDispatcherProfile,
- &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: tenant, ID: id},
- APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, utils.EmptyString,
- utils.FirstNonEmpty(config.CgrConfig().DataDbCfg().RmtConnID,
- config.CgrConfig().GeneralCfg().NodeID)),
- }, &dpp); err == nil {
- err = dm.dataDB.SetDispatcherProfileDrv(ctx, dpp)
- }
- }
- if err != nil {
- err = utils.CastRPCErr(err)
- if err == utils.ErrDSPProfileNotFound && cacheWrite {
- if errCh := Cache.Set(ctx, utils.CacheDispatcherProfiles, tntID, nil, nil,
- cacheCommit(transactionID), transactionID); errCh != nil {
- return nil, errCh
- }
-
- }
- return nil, err
- }
- }
- if cacheWrite {
- if errCh := Cache.Set(ctx, utils.CacheDispatcherProfiles, tntID, dpp, nil,
- cacheCommit(transactionID), transactionID); errCh != nil {
- return nil, errCh
- }
- }
- return
-}
-
-func (dm *DataManager) SetDispatcherProfile(ctx *context.Context, dpp *DispatcherProfile, withIndex bool) (err error) {
- if dm == nil {
- return utils.ErrNoDatabaseConn
- }
- if withIndex {
- if err := dm.checkFilters(ctx, dpp.Tenant, dpp.FilterIDs); err != nil {
- // if we get a broken filter do not set the profile
- return fmt.Errorf("%+s for item with ID: %+v",
- err, dpp.TenantID())
- }
- }
- oldDpp, err := dm.GetDispatcherProfile(ctx, dpp.Tenant, dpp.ID, true, false, utils.NonTransactional)
- if err != nil && err != utils.ErrDSPProfileNotFound {
- return err
- }
- if err = dm.DataDB().SetDispatcherProfileDrv(ctx, dpp); err != nil {
- return err
- }
- if withIndex {
- var oldFiltersIDs *[]string
- if oldDpp != nil {
- oldFiltersIDs = &oldDpp.FilterIDs
- }
- if err = updatedIndexes(ctx, dm, utils.CacheDispatcherFilterIndexes, dpp.Tenant,
- utils.EmptyString, dpp.ID, oldFiltersIDs, dpp.FilterIDs, false); err != nil {
- return
- }
- }
- if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaDispatcherProfiles]; itm.Replicate {
- err = replicate(ctx, dm.connMgr, config.CgrConfig().DataDbCfg().RplConns,
- config.CgrConfig().DataDbCfg().RplFiltered,
- utils.DispatcherProfilePrefix, dpp.TenantID(), // this are used to get the host IDs from cache
- utils.ReplicatorSv1SetDispatcherProfile,
- &DispatcherProfileWithAPIOpts{
- DispatcherProfile: dpp,
- APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID,
- config.CgrConfig().DataDbCfg().RplCache, utils.EmptyString)})
- }
- return
-}
-
-func (dm *DataManager) RemoveDispatcherProfile(ctx *context.Context, tenant, id string, withIndex bool) (err error) {
- if dm == nil {
- return utils.ErrNoDatabaseConn
- }
- oldDpp, err := dm.GetDispatcherProfile(ctx, tenant, id, true, false, utils.NonTransactional)
- if err != nil && err != utils.ErrDSPProfileNotFound {
- return err
- }
- if err = dm.DataDB().RemoveDispatcherProfileDrv(ctx, tenant, id); err != nil {
- return
- }
- if oldDpp == nil {
- return utils.ErrDSPProfileNotFound
- }
- if withIndex {
- if err = removeIndexFiltersItem(ctx, dm, utils.CacheDispatcherFilterIndexes, tenant, id, oldDpp.FilterIDs); err != nil {
- return
- }
- if err = removeItemFromFilterIndex(ctx, dm, utils.CacheDispatcherFilterIndexes,
- tenant, utils.EmptyString, id, oldDpp.FilterIDs); err != nil {
- return
- }
- }
- if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaDispatcherProfiles]; itm.Replicate {
- replicate(ctx, dm.connMgr, config.CgrConfig().DataDbCfg().RplConns,
- config.CgrConfig().DataDbCfg().RplFiltered,
- utils.DispatcherProfilePrefix, utils.ConcatenatedKey(tenant, id), // this are used to get the host IDs from cache
- utils.ReplicatorSv1RemoveDispatcherProfile,
- &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: tenant, ID: id},
- APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID,
- config.CgrConfig().DataDbCfg().RplCache, utils.EmptyString)})
- }
- return
-}
-
-func (dm *DataManager) GetDispatcherHost(ctx *context.Context, tenant, id string, cacheRead, cacheWrite bool,
- transactionID string) (dH *DispatcherHost, err error) {
- tntID := utils.ConcatenatedKey(tenant, id)
- if cacheRead {
- if x, ok := Cache.Get(utils.CacheDispatcherHosts, tntID); ok {
- if x == nil {
- return nil, utils.ErrDSPHostNotFound
- }
- return x.(*DispatcherHost), nil
- }
- }
- if dm == nil {
- err = utils.ErrNoDatabaseConn
- return
- }
- dH, err = dm.dataDB.GetDispatcherHostDrv(ctx, tenant, id)
- if err != nil {
- if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaDispatcherHosts]; err == utils.ErrDSPHostNotFound && itm.Remote {
- if err = dm.connMgr.Call(ctx, config.CgrConfig().DataDbCfg().RmtConns,
- utils.ReplicatorSv1GetDispatcherHost,
- &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: tenant, ID: id},
- APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, utils.EmptyString,
- utils.FirstNonEmpty(config.CgrConfig().DataDbCfg().RmtConnID,
- config.CgrConfig().GeneralCfg().NodeID)),
- }, &dH); err == nil {
- err = dm.dataDB.SetDispatcherHostDrv(ctx, dH)
- }
- }
- if err != nil {
- err = utils.CastRPCErr(err)
- if err == utils.ErrDSPHostNotFound && cacheWrite {
- if errCh := Cache.Set(ctx, utils.CacheDispatcherHosts, tntID, nil, nil,
- cacheCommit(transactionID), transactionID); errCh != nil {
- return nil, errCh
- }
-
- }
- return nil, err
- }
- }
- if cacheWrite {
- if err = Cache.Set(ctx, utils.CacheDispatcherHosts, tntID, dH, nil,
- cacheCommit(transactionID), transactionID); err != nil {
- return nil, err
- }
- }
- return
-}
-
-func (dm *DataManager) SetDispatcherHost(ctx *context.Context, dpp *DispatcherHost) (err error) {
- if dm == nil {
- return utils.ErrNoDatabaseConn
- }
- if err = dm.DataDB().SetDispatcherHostDrv(ctx, dpp); err != nil {
- return
- }
- if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaDispatcherHosts]; itm.Replicate {
- err = replicate(ctx, dm.connMgr, config.CgrConfig().DataDbCfg().RplConns,
- config.CgrConfig().DataDbCfg().RplFiltered,
- utils.DispatcherHostPrefix, dpp.TenantID(), // this are used to get the host IDs from cache
- utils.ReplicatorSv1SetDispatcherHost,
- &DispatcherHostWithAPIOpts{
- DispatcherHost: dpp,
- APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID,
- config.CgrConfig().DataDbCfg().RplCache, utils.EmptyString)})
- }
- return
-}
-
-func (dm *DataManager) RemoveDispatcherHost(ctx *context.Context, tenant, id string) (err error) {
- if dm == nil {
- return utils.ErrNoDatabaseConn
- }
- oldDpp, err := dm.GetDispatcherHost(ctx, tenant, id, true, false, utils.NonTransactional)
- if err != nil && err != utils.ErrDSPHostNotFound {
- return err
- }
- if err = dm.DataDB().RemoveDispatcherHostDrv(ctx, tenant, id); err != nil {
- return
- }
- if oldDpp == nil {
- return utils.ErrNotFound
- }
- if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaDispatcherHosts]; itm.Replicate {
- replicate(ctx, dm.connMgr, config.CgrConfig().DataDbCfg().RplConns,
- config.CgrConfig().DataDbCfg().RplFiltered,
- utils.DispatcherHostPrefix, utils.ConcatenatedKey(tenant, id), // this are used to get the host IDs from cache
- utils.ReplicatorSv1RemoveDispatcherHost,
- &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: tenant, ID: id},
- APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID,
- config.CgrConfig().DataDbCfg().RplCache, utils.EmptyString)})
- }
- return
-}
-
func (dm *DataManager) GetItemLoadIDs(ctx *context.Context, itemIDPrefix string, cacheWrite bool) (loadIDs map[string]int64, err error) {
if dm == nil {
err = utils.ErrNoDatabaseConn
diff --git a/engine/datamanager_test.go b/engine/datamanager_test.go
index c5f98e55c..2191d9ce3 100644
--- a/engine/datamanager_test.go
+++ b/engine/datamanager_test.go
@@ -654,185 +654,6 @@ func TestDataManagerRemoveAccountReplicateTrue(t *testing.T) {
}
-func TestDataManagerRemoveDispatcherHostErrNilDM(t *testing.T) {
-
- var dm *DataManager
- if err := dm.RemoveDispatcherHost(context.Background(), utils.CGRateSorg, "*stirng:~*req.Account:1001"); err != utils.ErrNoDatabaseConn {
- t.Error(err)
- }
-
-}
-
-func TestDataManagerRemoveDispatcherHostErroldDppNil(t *testing.T) {
- tmp := Cache
- defer func() {
- Cache = tmp
- }()
-
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- if err := dm.RemoveDispatcherHost(context.Background(), utils.CGRateSorg, "*stirng:~*req.Account:1001"); err != utils.ErrNotFound {
- t.Error(err)
- }
-
-}
-
-func TestDataManagerRemoveDispatcherHostErrGetDisp(t *testing.T) {
- tmp := Cache
- defer func() {
- Cache = tmp
- }()
-
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dm.dataDB = &DataDBMock{
- GetDispatcherHostDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherHost, error) {
- return nil, utils.ErrNotImplemented
- },
- }
-
- if err := dm.RemoveDispatcherHost(context.Background(), utils.CGRateSorg, "*stirng:~*req.Account:1001"); err != utils.ErrNotImplemented {
- t.Error(err)
- }
-
-}
-
-func TestDataManagerRemoveDispatcherHostErrRemoveDisp(t *testing.T) {
- tmp := Cache
- defer func() {
- Cache = tmp
- }()
-
- Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dm.dataDB = &DataDBMock{
- GetDispatcherHostDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherHost, error) {
- return &DispatcherHost{}, nil
- },
- RemoveDispatcherHostDrvF: func(ctx *context.Context, s1, s2 string) error {
- return utils.ErrNotImplemented
- },
- }
-
- if err := dm.RemoveDispatcherHost(context.Background(), utils.CGRateSorg, "*stirng:~*req.Account:1001"); err != utils.ErrNotImplemented {
- t.Error(err)
- }
-
-}
-
-func TestDataManagerRemoveDispatcherHostReplicateTrue(t *testing.T) {
- tmp := Cache
- cfgtmp := config.CgrConfig()
- defer func() {
- Cache = tmp
- config.SetCgrConfig(cfgtmp)
- }()
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- cfg.DataDbCfg().Items[utils.MetaDispatcherHosts].Replicate = true
- cfg.DataDbCfg().RplConns = []string{}
- config.SetCgrConfig(cfg)
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dm.dataDB = &DataDBMock{
- GetDispatcherHostDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherHost, error) {
- return &DispatcherHost{}, nil
- },
- RemoveDispatcherHostDrvF: func(ctx *context.Context, s1, s2 string) error {
- return nil
- },
- }
-
- // tested replicate
- dm.RemoveDispatcherHost(context.Background(), utils.CGRateSorg, "*stirng:~*req.Account:1001")
-
-}
-
-func TestDataManagerSetDispatcherHostErrNilDM(t *testing.T) {
-
- var dm *DataManager
- if err := dm.SetDispatcherHost(context.Background(), nil); err != utils.ErrNoDatabaseConn {
- t.Error(err)
- }
-
-}
-
-func TestDataManagerSetDispatcherHostErrDataDB(t *testing.T) {
-
- tmp := Cache
- defer func() {
- Cache = tmp
- }()
-
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
- dm.dataDB = &DataDBMock{
- SetDispatcherHostDrvF: func(ctx *context.Context, dh *DispatcherHost) error {
- return utils.ErrNotImplemented
- },
- }
- defer data.Close()
- if err := dm.SetDispatcherHost(context.Background(), nil); err != utils.ErrNotImplemented {
- t.Error(err)
- }
-
-}
-
-func TestDataManagerSetDispatcherHostReplicateTrue(t *testing.T) {
-
- tmp := Cache
- cfgtmp := config.CgrConfig()
- defer func() {
- Cache = tmp
- config.SetCgrConfig(cfgtmp)
- }()
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- cfg.DataDbCfg().Items[utils.MetaDispatcherHosts].Replicate = true
-
- config.SetCgrConfig(cfg)
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
-
- dm := NewDataManager(data, cfg.CacheCfg(), nil)
-
- dpp := &DispatcherHost{
- Tenant: utils.CGRateSorg,
- RemoteHost: &config.RemoteHost{
- ID: "ID",
- Address: "127.0.0.1",
- Transport: utils.MetaJSON,
- ConnectAttempts: 1,
- Reconnects: 1,
- MaxReconnectInterval: time.Minute,
- ConnectTimeout: time.Nanosecond,
- ReplyTimeout: time.Nanosecond,
- TLS: true,
- ClientKey: "key",
- ClientCertificate: "ce",
- CaCertificate: "ca",
- },
- }
- // tested replicate
- dm.SetDispatcherHost(context.Background(), dpp)
-
-}
-
func TestDMRemoveAccountReplicate(t *testing.T) {
tmp := Cache
@@ -2678,107 +2499,6 @@ func TestDMCacheDataFromDBChargerProfilePrefix(t *testing.T) {
}
-func TestDMCacheDataFromDBDispatcherProfilePrefix(t *testing.T) {
- tmp := Cache
- defer func() {
- Cache = tmp
- }()
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dpp := &DispatcherProfile{
-
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- if err := dm.SetDispatcherProfile(context.Background(), dpp, false); err != nil {
- t.Error(err)
- }
-
- if _, ok := Cache.Get(utils.CacheDispatcherProfiles, "cgrates.org:ID"); ok {
- t.Error("expected ok to be false")
- }
-
- if err := dm.CacheDataFromDB(context.Background(), utils.DispatcherProfilePrefix, []string{utils.MetaAny}, false); err != nil {
- t.Error(err)
- }
-
- if rcv, ok := Cache.Get(utils.CacheDispatcherProfiles, "cgrates.org:ID"); !ok {
- t.Error("expected ok to be true")
- } else if !reflect.DeepEqual(rcv, dpp) {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", dpp, rcv)
- }
-
-}
-
-func TestDMCacheDataFromDBDispatcherHostPrefix(t *testing.T) {
- tmp := Cache
- defer func() {
- Cache = tmp
- }()
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dph := &DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "ID",
- Address: "127.0.0.1",
- Transport: utils.MetaJSON,
- ConnectAttempts: 1,
- Reconnects: 1,
- MaxReconnectInterval: 1,
- ConnectTimeout: time.Nanosecond,
- ReplyTimeout: time.Nanosecond,
- TLS: true,
- ClientKey: "key",
- ClientCertificate: "ce",
- CaCertificate: "ca",
- },
- }
-
- if err := dm.SetDispatcherHost(context.Background(), dph); err != nil {
- t.Error(err)
- }
-
- if _, ok := Cache.Get(utils.CacheDispatcherHosts, "cgrates.org:ID"); ok {
- t.Error("expected ok to be false")
- }
-
- if err := dm.CacheDataFromDB(context.Background(), utils.DispatcherHostPrefix, []string{utils.MetaAny}, false); err != nil {
- t.Error(err)
- }
-
- if rcv, ok := Cache.Get(utils.CacheDispatcherHosts, "cgrates.org:ID"); !ok {
- t.Error("expected ok to be true")
- } else if !reflect.DeepEqual(rcv, dph) {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", dph, rcv)
- }
-
-}
-
func TestDMCacheDataFromDBRateProfilePrefix(t *testing.T) {
tmp := Cache
defer func() {
@@ -3093,42 +2813,6 @@ func TestDMCacheDataFromDBChargerFilterIndexes(t *testing.T) {
}
-func TestDMCacheDataFromDBDispatcherFilterIndexes(t *testing.T) {
- tmp := Cache
- defer func() {
- Cache = tmp
- }()
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- indexes := map[string]utils.StringSet{"*string:*req.Account:1002": {"ATTR1": {}, "ATTR2": {}}}
-
- if err := dm.SetIndexes(context.Background(), utils.CacheDispatcherFilterIndexes, "cgrates.org", indexes, true, utils.NonTransactional); err != nil {
- t.Error(err)
- }
-
- if _, ok := Cache.Get(utils.CacheDispatcherFilterIndexes, utils.ConcatenatedKey("cgrates.org", "*string:*req.Account:1002")); ok {
- t.Error("expected ok to be false")
- }
-
- if err := dm.CacheDataFromDB(context.Background(), utils.DispatcherFilterIndexes, []string{utils.MetaAny}, false); err != nil {
- t.Error(err)
- }
-
- exp := utils.StringSet{"ATTR1": {}, "ATTR2": {}}
-
- if rcv, ok := Cache.Get(utils.CacheDispatcherFilterIndexes, utils.ConcatenatedKey("cgrates.org", "*string:*req.Account:1002")); !ok {
- t.Error("expected ok to be true")
- } else if !reflect.DeepEqual(rcv, exp) {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", exp, rcv)
- }
-
-}
-
func TestDMCacheDataFromDBRateProfilesFilterIndexPrfx(t *testing.T) {
tmp := Cache
defer func() {
@@ -3381,24 +3065,6 @@ func TestDMCacheDataFromDBChargerFilterIndexesErr(t *testing.T) {
}
}
-func TestDMCacheDataFromDBDispatcherFilterIndexesErr(t *testing.T) {
- tmp := Cache
- defer func() {
- Cache = tmp
- }()
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- errExp := "WRONG_IDX_KEY_FORMAT"
- if err := dm.CacheDataFromDB(context.Background(), utils.DispatcherFilterIndexes, []string{"tntCtx:*prefix:~*accounts"}, false); errExp != err.Error() {
- t.Errorf("Expected %v\n but received %v", errExp, err)
- }
-}
-
func TestDMCacheDataFromDBRateProfilesFilterIndexPrfxErr(t *testing.T) {
tmp := Cache
defer func() {
@@ -7191,242 +6857,6 @@ func TestDMRemoveChargerProfileReplicate(t *testing.T) {
}
-func TestDMRemoveDispatcherProfileNoDMErr(t *testing.T) {
- var dm *DataManager
- err := dm.RemoveDispatcherProfile(context.Background(), "cgrates.org", "dp_1", false)
- if err != utils.ErrNoDatabaseConn {
- t.Errorf("\nExpected error <%+v>, \nReceived error <%+v>", utils.ErrNoDatabaseConn, err)
- }
-}
-
-func TestDMRemoveDispatcherProfileGetDispatcherProfileErr(t *testing.T) {
-
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- data := &DataDBMock{
- GetDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherProfile, error) {
- return &DispatcherProfile{}, utils.ErrNotImplemented
- },
- }
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dpp := &DispatcherProfile{
-
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- err := dm.RemoveDispatcherProfile(context.Background(), dpp.Tenant, dpp.ID, false)
- if err != utils.ErrNotImplemented {
- t.Errorf("\nExpected error <%+v>, \nReceived error <%+v>", utils.ErrNotImplemented, err)
- }
-
-}
-
-func TestDMRemoveDispatcherProfileRemoveDispatcherProfileDrvErr(t *testing.T) {
-
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- data := &DataDBMock{
- GetDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherProfile, error) {
- return &DispatcherProfile{}, nil
- },
- }
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dpp := &DispatcherProfile{
-
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- err := dm.RemoveDispatcherProfile(context.Background(), dpp.Tenant, dpp.ID, false)
- if err != utils.ErrNotImplemented {
- t.Errorf("\nExpected error <%+v>, \nReceived error <%+v>", utils.ErrNotImplemented, err)
- }
-
-}
-
-func TestDMRemoveDispatcherProfileNilOldDppErr(t *testing.T) {
-
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- var Id string
- var tnt string
- err := dm.RemoveDispatcherProfile(context.Background(), tnt, Id, false)
- if err != utils.ErrDSPProfileNotFound {
- t.Errorf("\nExpected error <%+v>, \nReceived error <%+v>", utils.ErrDSPProfileNotFound, err)
- }
-
-}
-
-func TestDMRemoveDispatcherProfileRmvItemFromFiltrIndexErr(t *testing.T) {
-
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- data := &DataDBMock{
- GetDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherProfile, error) {
- return &DispatcherProfile{}, nil
- },
- RemoveDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) error { return nil },
- }
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dpp := &DispatcherProfile{
-
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- err := dm.RemoveDispatcherProfile(context.Background(), dpp.Tenant, dpp.ID, true)
- if err != utils.ErrNotImplemented {
- t.Errorf("\nExpected error <%+v>, \nReceived error <%+v>", utils.ErrNotImplemented, err)
- }
-
-}
-
-func TestDMRemoveDispatcherProfileRmvIndexFiltersItemErr(t *testing.T) {
-
- Cache.Clear(nil)
-
- dpp := &DispatcherProfile{
-
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- cfg := config.NewDefaultCGRConfig()
- data := &DataDBMock{
- GetDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherProfile, error) { return dpp, nil },
- RemoveDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) error { return nil },
- }
-
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- err := dm.RemoveDispatcherProfile(context.Background(), dpp.Tenant, dpp.ID, true)
- if err != utils.ErrNotImplemented {
- t.Errorf("\nExpected error <%+v>, \nReceived error <%+v>", utils.ErrNotImplemented, err)
- }
-
-}
-
-func TestDMRemoveDispatcherProfileReplicate(t *testing.T) {
-
- cfgtmp := config.CgrConfig()
- defer func() {
- config.SetCgrConfig(cfgtmp)
- }()
- Cache.Clear(nil)
-
- dpp := &DispatcherProfile{
-
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- cfg := config.NewDefaultCGRConfig()
- cfg.DataDbCfg().Items[utils.MetaDispatcherProfiles].Replicate = true
- cfg.DataDbCfg().RplConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator)}
- config.SetCgrConfig(cfg)
-
- cc := make(chan birpc.ClientConnector, 1)
- cc <- &ccMock{
-
- calls: map[string]func(ctx *context.Context, args any, reply any) error{
- utils.ReplicatorSv1RemoveDispatcherProfile: func(ctx *context.Context, args, reply any) error { return utils.ErrNotImplemented },
- },
- }
-
- cM := NewConnManager(cfg)
- cM.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator), utils.ReplicatorSv1, cc)
- data := &DataDBMock{
- GetDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherProfile, error) { return dpp, nil },
- RemoveDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) error { return nil },
- }
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- // tests replicate
- dm.RemoveDispatcherProfile(context.Background(), dpp.Tenant, dpp.ID, false)
-
-}
-
func TestDMRemoveRateProfileNoDMErr(t *testing.T) {
var dm *DataManager
err := dm.RemoveRateProfile(context.Background(), "cgrates.org", "Rp_1", false)
@@ -8320,209 +7750,6 @@ func TestDMSetChargerProfileReplicate(t *testing.T) {
}
-func TestDMSetDispatcherProfileNoDMErr(t *testing.T) {
- var dm *DataManager
- err := dm.SetDispatcherProfile(context.Background(), &DispatcherProfile{}, false)
- if err != utils.ErrNoDatabaseConn {
- t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.ErrNoDatabaseConn, err)
- }
-}
-
-func TestDMSetDispatcherProfileCheckFiltersErr(t *testing.T) {
-
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dpp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DP_1",
- FilterIDs: []string{"*string*req.Account1001"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- expErr := "broken reference to filter: <*string*req.Account1001> for item with ID: cgrates.org:DP_1"
- if err := dm.SetDispatcherProfile(context.Background(), dpp, true); err == nil || err.Error() != expErr {
- t.Errorf("Expected error <%v>, received error <%v>", expErr, err)
- }
-
-}
-
-func TestDMSetDispatcherProfileGetDispatcherProfileErr(t *testing.T) {
-
- cfg := config.NewDefaultCGRConfig()
- data := &DataDBMock{
- GetDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherProfile, error) {
- return &DispatcherProfile{}, utils.ErrNotImplemented
- },
- }
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dpp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DP_1",
- FilterIDs: []string{"*string*req.Account1001"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- if err := dm.SetDispatcherProfile(context.Background(), dpp, false); err != utils.ErrNotImplemented {
- t.Errorf("Expected error <%v>, received error <%v>", utils.ErrNotImplemented, err)
- }
-}
-
-func TestDMSetDispatcherProfileSetDispatcherProfileDrvErr(t *testing.T) {
-
- cfg := config.NewDefaultCGRConfig()
- data := &DataDBMock{
- GetDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherProfile, error) {
- return &DispatcherProfile{}, nil
- },
- SetDispatcherProfileDrvF: func(ctx *context.Context, dp *DispatcherProfile) error { return utils.ErrNotImplemented },
- }
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dpp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DP_1",
- FilterIDs: []string{"*string*req.Account1001"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
- if err := dm.SetDispatcherProfile(context.Background(), dpp, false); err != utils.ErrNotImplemented {
- t.Errorf("Expected error <%v>, received error <%v>", utils.ErrNotImplemented, err)
- }
-}
-
-func TestDMSetDispatcherProfileUpdatedIndexesErr(t *testing.T) {
-
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- data := &DataDBMock{
- GetDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherProfile, error) {
- return &DispatcherProfile{}, nil
- },
- SetDispatcherProfileDrvF: func(ctx *context.Context, dp *DispatcherProfile) error { return nil },
- }
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dpp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DP_1",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- if err := dm.SetDispatcherProfile(context.Background(), dpp, true); err != utils.ErrNotImplemented {
- t.Errorf("Expected error <%v>, received error <%v>", utils.ErrNotImplemented, err)
- }
-}
-
-func TestDMSetDispatcherProfileReplicate(t *testing.T) {
-
- cfgtmp := config.CgrConfig()
- defer func() {
- config.SetCgrConfig(cfgtmp)
- }()
- Cache.Clear(nil)
-
- dpp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DP_1",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- cfg := config.NewDefaultCGRConfig()
- cfg.DataDbCfg().Items[utils.MetaDispatcherProfiles].Replicate = true
- cfg.DataDbCfg().RplConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator)}
- config.SetCgrConfig(cfg)
-
- cc := make(chan birpc.ClientConnector, 1)
- cc <- &ccMock{
-
- calls: map[string]func(ctx *context.Context, args any, reply any) error{
- utils.ReplicatorSv1SetDispatcherProfile: func(ctx *context.Context, args, reply any) error { return utils.ErrNotImplemented },
- },
- }
-
- cM := NewConnManager(cfg)
- cM.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator), utils.ReplicatorSv1, cc)
- data := &DataDBMock{
- GetDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherProfile, error) {
- return dpp, nil
- },
- SetDispatcherProfileDrvF: func(ctx *context.Context, dp *DispatcherProfile) error { return nil },
- }
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- // tests replicate
- if err := dm.SetDispatcherProfile(context.Background(), dpp, false); err != utils.ErrNotImplemented {
- t.Errorf("Expected error <%v>, received error <%v>", utils.ErrNotImplemented, err)
- }
-
-}
-
func TestDMSetActionProfileNoDMErr(t *testing.T) {
var dm *DataManager
err := dm.SetActionProfile(context.Background(), &ActionProfile{}, false)
@@ -9941,497 +9168,6 @@ func TestDMGetChargerProfileCacheWriteErr2(t *testing.T) {
if _, err := dm.GetChargerProfile(context.Background(), utils.CGRateSorg, cpp.ID, false, true, utils.NonTransactional); err != utils.ErrNotImplemented {
t.Errorf("Expected error <%v>, received error <%v>", utils.ErrNotImplemented, err)
}
-
-}
-
-func TestDMGetDispatcherProfileCacheGetErr(t *testing.T) {
-
- defer func() {
- Cache = NewCacheS(config.NewDefaultCGRConfig(), nil, nil, nil)
- }()
-
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- if err := Cache.Set(context.Background(), utils.CacheDispatcherProfiles, utils.ConcatenatedKey(utils.CGRateSorg, "dp1"), nil, []string{}, true, utils.NonTransactional); err != nil {
- t.Error(err)
- }
-
- _, err := dm.GetDispatcherProfile(context.Background(), utils.CGRateSorg, "dp1", true, false, utils.NonTransactional)
- if err != utils.ErrDSPProfileNotFound {
- t.Errorf("Expected error <%v>, received error <%v>", utils.ErrDSPProfileNotFound, err)
- }
-}
-
-func TestDMGetDispatcherProfileCacheGet(t *testing.T) {
-
- defer func() {
- Cache = NewCacheS(config.NewDefaultCGRConfig(), nil, nil, nil)
- }()
-
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dpp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DP_1",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- if err := Cache.Set(context.Background(), utils.CacheDispatcherProfiles, utils.ConcatenatedKey(utils.CGRateSorg, "dp1"), dpp, []string{}, true, utils.NonTransactional); err != nil {
- t.Error(err)
- }
-
- if rcv, err := dm.GetDispatcherProfile(context.Background(), utils.CGRateSorg, "dp1", true, false, utils.NonTransactional); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcv, dpp) {
- t.Errorf("Expected <%v>, received <%v>", dpp, rcv)
- }
-}
-
-func TestDMGetDispatcherProfileNilDMErr(t *testing.T) {
-
- var dm *DataManager
-
- _, err := dm.GetDispatcherProfile(context.Background(), utils.CGRateSorg, "dp1", false, false, utils.NonTransactional)
- if err != utils.ErrNoDatabaseConn {
- t.Errorf("\nExpected error <%+v>, \nReceived error <%+v>", utils.ErrNoDatabaseConn, err)
- }
-
-}
-
-func TestDMGetDispatcherProfileSetDispatcherProfileDrvErr(t *testing.T) {
-
- cfgtmp := config.CgrConfig()
- defer func() {
- config.SetCgrConfig(cfgtmp)
- Cache = NewCacheS(config.NewDefaultCGRConfig(), nil, nil, nil)
- }()
-
- dpp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DP_1",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- cfg := config.NewDefaultCGRConfig()
- cfg.DataDbCfg().Items[utils.MetaDispatcherProfiles].Remote = true
- cfg.DataDbCfg().RmtConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.RemoteConnsCfg)}
- config.SetCgrConfig(cfg)
-
- cc := make(chan birpc.ClientConnector, 1)
- cc <- &ccMock{
-
- calls: map[string]func(ctx *context.Context, args any, reply any) error{
- utils.ReplicatorSv1GetDispatcherProfile: func(ctx *context.Context, args, reply any) error { return nil },
- },
- }
-
- cM := NewConnManager(cfg)
- cM.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.RemoteConnsCfg), utils.ReplicatorSv1, cc)
- data := &DataDBMock{
- GetDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherProfile, error) {
- return dpp, utils.ErrDSPProfileNotFound
- },
- SetDispatcherProfileDrvF: func(ctx *context.Context, dp *DispatcherProfile) error { return utils.ErrNotImplemented },
- }
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- _, err := dm.GetDispatcherProfile(context.Background(), utils.CGRateSorg, dpp.ID, false, false, utils.NonTransactional)
- if err != utils.ErrNotImplemented {
- t.Errorf("Expected error <%v>, received error <%v>", utils.ErrNotImplemented, err)
- }
-}
-
-func TestDMGetDispatcherProfileCacheWriteErr1(t *testing.T) {
-
- dpp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DP_1",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- cfgtmp := config.CgrConfig()
- defer func() {
- Cache = NewCacheS(config.NewDefaultCGRConfig(), nil, nil, nil)
- config.SetCgrConfig(cfgtmp)
- }()
-
- cfg := config.NewDefaultCGRConfig()
- cfg.CacheCfg().ReplicationConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator)}
- cfg.CacheCfg().Partitions[utils.CacheDispatcherProfiles].Replicate = true
- config.SetCgrConfig(cfg)
-
- cc := make(chan birpc.ClientConnector, 1)
- cc <- &ccMock{
-
- calls: map[string]func(ctx *context.Context, args any, reply any) error{
- utils.CacheSv1ReplicateSet: func(ctx *context.Context, args, reply any) error {
-
- return utils.ErrNotImplemented
- },
- },
- }
-
- cM := NewConnManager(cfg)
- cM.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator), utils.CacheSv1, cc)
-
- data := &DataDBMock{
- GetDispatcherProfileDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherProfile, error) {
- return dpp, utils.ErrDSPProfileNotFound
- },
- }
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- Cache = NewCacheS(cfg, dm, cM, nil)
-
- _, err := dm.GetDispatcherProfile(context.Background(), utils.CGRateSorg, dpp.ID, false, true, utils.NonTransactional)
- if err != utils.ErrNotImplemented {
- t.Errorf("Expected error <%v>, received error <%v>", utils.ErrNotImplemented, err)
- }
-}
-
-func TestDMGetDispatcherProfileCacheWriteErr2(t *testing.T) {
-
- cfgtmp := config.CgrConfig()
- defer func() {
- Cache = NewCacheS(config.NewDefaultCGRConfig(), nil, nil, nil)
- config.SetCgrConfig(cfgtmp)
- }()
-
- cfg := config.NewDefaultCGRConfig()
- cfg.CacheCfg().ReplicationConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator)}
- cfg.CacheCfg().Partitions[utils.CacheDispatcherProfiles].Replicate = true
- config.SetCgrConfig(cfg)
-
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
-
- cc := make(chan birpc.ClientConnector, 1)
- cc <- &ccMock{
-
- calls: map[string]func(ctx *context.Context, args any, reply any) error{
- utils.CacheSv1ReplicateSet: func(ctx *context.Context, args, reply any) error { return utils.ErrNotImplemented },
- },
- }
-
- cM := NewConnManager(cfg)
- cM.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator), utils.CacheSv1, cc)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dpp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DP_1",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- },
- }
-
- if err := dm.dataDB.SetDispatcherProfileDrv(context.Background(), dpp); err != nil {
- t.Error(err)
- }
-
- Cache = NewCacheS(cfg, dm, cM, nil)
-
- _, err := dm.GetDispatcherProfile(context.Background(), utils.CGRateSorg, dpp.ID, false, true, utils.NonTransactional)
- if err != utils.ErrNotImplemented {
- t.Errorf("Expected error <%v>, received error <%v>", utils.ErrNotImplemented, err)
- }
-
-}
-
-func TestDMGetDispatcherHostCacheGetErr(t *testing.T) {
-
- defer func() {
- Cache = NewCacheS(config.NewDefaultCGRConfig(), nil, nil, nil)
- }()
-
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- if err := Cache.Set(context.Background(), utils.CacheDispatcherHosts, utils.ConcatenatedKey(utils.CGRateSorg, "dh1"), nil, []string{}, true, utils.NonTransactional); err != nil {
- t.Error(err)
- }
-
- _, err := dm.GetDispatcherHost(context.Background(), utils.CGRateSorg, "dh1", true, false, utils.NonTransactional)
- if err != utils.ErrDSPHostNotFound {
- t.Errorf("Expected error <%v>, received error <%v>", utils.ErrDSPHostNotFound, err)
- }
-}
-
-func TestDMGetDispatcherHostCacheGet(t *testing.T) {
-
- defer func() {
- Cache = NewCacheS(config.NewDefaultCGRConfig(), nil, nil, nil)
- }()
-
- cfg := config.NewDefaultCGRConfig()
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- cM := NewConnManager(cfg)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dH := &DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "ID",
- Address: "127.0.0.1",
- Transport: utils.MetaJSON,
- ConnectAttempts: 1,
- Reconnects: 1,
- MaxReconnectInterval: 1,
- ConnectTimeout: time.Nanosecond,
- ReplyTimeout: time.Nanosecond,
- TLS: true,
- ClientKey: "key",
- ClientCertificate: "ce",
- CaCertificate: "ca",
- },
- }
-
- if err := Cache.Set(context.Background(), utils.CacheDispatcherHosts, utils.ConcatenatedKey(utils.CGRateSorg, "dh1"), dH, []string{}, true, utils.NonTransactional); err != nil {
- t.Error(err)
- }
-
- if rcv, err := dm.GetDispatcherHost(context.Background(), utils.CGRateSorg, "dh1", true, false, utils.NonTransactional); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcv, dH) {
- t.Errorf("Expected <%v>, received <%v>", dH, rcv)
- }
-}
-
-func TestDMGetDispatcherHostNilDMErr(t *testing.T) {
-
- var dm *DataManager
-
- _, err := dm.GetDispatcherHost(context.Background(), utils.CGRateSorg, "dh1", false, false, utils.NonTransactional)
- if err != utils.ErrNoDatabaseConn {
- t.Errorf("\nExpected error <%+v>, \nReceived error <%+v>", utils.ErrNoDatabaseConn, err)
- }
-
-}
-
-func TestDMGetDispatcherHostSetDispatcherHostDrvErr(t *testing.T) {
-
- cfgtmp := config.CgrConfig()
- defer func() {
- config.SetCgrConfig(cfgtmp)
- Cache = NewCacheS(config.NewDefaultCGRConfig(), nil, nil, nil)
- }()
-
- dH := &DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "ID",
- Address: "127.0.0.1",
- Transport: utils.MetaJSON,
- ConnectAttempts: 1,
- Reconnects: 1,
- MaxReconnectInterval: 1,
- ConnectTimeout: time.Nanosecond,
- ReplyTimeout: time.Nanosecond,
- TLS: true,
- ClientKey: "key",
- ClientCertificate: "ce",
- CaCertificate: "ca",
- },
- }
-
- cfg := config.NewDefaultCGRConfig()
- cfg.DataDbCfg().Items[utils.MetaDispatcherHosts].Remote = true
- cfg.DataDbCfg().RmtConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.RemoteConnsCfg)}
- config.SetCgrConfig(cfg)
-
- cc := make(chan birpc.ClientConnector, 1)
- cc <- &ccMock{
-
- calls: map[string]func(ctx *context.Context, args any, reply any) error{
- utils.ReplicatorSv1GetDispatcherHost: func(ctx *context.Context, args, reply any) error { return nil },
- },
- }
-
- cM := NewConnManager(cfg)
- cM.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.RemoteConnsCfg), utils.ReplicatorSv1, cc)
- data := &DataDBMock{
- GetDispatcherHostDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherHost, error) {
- return dH, utils.ErrDSPHostNotFound
- },
- SetDispatcherHostDrvF: func(ctx *context.Context, dh *DispatcherHost) error { return utils.ErrNotImplemented },
- }
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- _, err := dm.GetDispatcherHost(context.Background(), utils.CGRateSorg, dH.ID, false, false, utils.NonTransactional)
- if err != utils.ErrNotImplemented {
- t.Errorf("Expected error <%v>, received error <%v>", utils.ErrNotImplemented, err)
- }
-}
-
-func TestDMGetDispatcherHostCacheWriteErr1(t *testing.T) {
-
- dH := &DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "ID",
- Address: "127.0.0.1",
- Transport: utils.MetaJSON,
- ConnectAttempts: 1,
- Reconnects: 1,
- MaxReconnectInterval: 1,
- ConnectTimeout: time.Nanosecond,
- ReplyTimeout: time.Nanosecond,
- TLS: true,
- ClientKey: "key",
- ClientCertificate: "ce",
- CaCertificate: "ca",
- },
- }
-
- cfgtmp := config.CgrConfig()
- defer func() {
- Cache = NewCacheS(config.NewDefaultCGRConfig(), nil, nil, nil)
- config.SetCgrConfig(cfgtmp)
- }()
-
- cfg := config.NewDefaultCGRConfig()
- cfg.CacheCfg().ReplicationConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator)}
- cfg.CacheCfg().Partitions[utils.CacheDispatcherHosts].Replicate = true
- config.SetCgrConfig(cfg)
-
- cc := make(chan birpc.ClientConnector, 1)
- cc <- &ccMock{
-
- calls: map[string]func(ctx *context.Context, args any, reply any) error{
- utils.CacheSv1ReplicateSet: func(ctx *context.Context, args, reply any) error {
-
- return utils.ErrNotImplemented
- },
- },
- }
-
- cM := NewConnManager(cfg)
- cM.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator), utils.CacheSv1, cc)
-
- data := &DataDBMock{
- GetDispatcherHostDrvF: func(ctx *context.Context, s1, s2 string) (*DispatcherHost, error) {
- return dH, utils.ErrDSPHostNotFound
- },
- }
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- Cache = NewCacheS(cfg, dm, cM, nil)
-
- _, err := dm.GetDispatcherHost(context.Background(), utils.CGRateSorg, dH.ID, false, true, utils.NonTransactional)
- if err != utils.ErrNotImplemented {
- t.Errorf("Expected error <%v>, received error <%v>", utils.ErrNotImplemented, err)
- }
-}
-
-func TestDMGetDispatcherHostCacheWriteErr2(t *testing.T) {
-
- cfgtmp := config.CgrConfig()
- defer func() {
- Cache = NewCacheS(config.NewDefaultCGRConfig(), nil, nil, nil)
- config.SetCgrConfig(cfgtmp)
- }()
-
- cfg := config.NewDefaultCGRConfig()
- cfg.CacheCfg().ReplicationConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator)}
- cfg.CacheCfg().Partitions[utils.MetaDispatcherHosts].Replicate = true
- config.SetCgrConfig(cfg)
-
- data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
-
- cc := make(chan birpc.ClientConnector, 1)
- cc <- &ccMock{
-
- calls: map[string]func(ctx *context.Context, args any, reply any) error{
- utils.CacheSv1ReplicateSet: func(ctx *context.Context, args, reply any) error { return utils.ErrNotImplemented },
- },
- }
-
- cM := NewConnManager(cfg)
- cM.AddInternalConn(utils.ConcatenatedKey(utils.MetaInternal, utils.MetaReplicator), utils.CacheSv1, cc)
- dm := NewDataManager(data, cfg.CacheCfg(), cM)
-
- dH := &DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "ID",
- Address: "127.0.0.1",
- Transport: utils.MetaJSON,
- ConnectAttempts: 1,
- Reconnects: 1,
- MaxReconnectInterval: 1,
- ConnectTimeout: time.Nanosecond,
- ReplyTimeout: time.Nanosecond,
- TLS: true,
- ClientKey: "key",
- ClientCertificate: "ce",
- CaCertificate: "ca",
- },
- }
-
- if err := dm.dataDB.SetDispatcherHostDrv(context.Background(), dH); err != nil {
- t.Error(err)
- }
-
- Cache = NewCacheS(cfg, dm, cM, nil)
-
- _, err := dm.GetDispatcherHost(context.Background(), utils.CGRateSorg, dH.ID, false, true, utils.NonTransactional)
- if err != utils.ErrNotImplemented {
- t.Errorf("Expected error <%v>, received error <%v>", utils.ErrNotImplemented, err)
- }
-
}
func TestDMGetItemLoadIDsNilDM(t *testing.T) {
diff --git a/engine/dispatcherprfl.go b/engine/dispatcherprfl.go
index 38bb0b05c..23da2c5d3 100644
--- a/engine/dispatcherprfl.go
+++ b/engine/dispatcherprfl.go
@@ -23,7 +23,6 @@ import (
"slices"
"sort"
"strconv"
- "strings"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
@@ -99,35 +98,6 @@ func (dHPrfls DispatcherHostProfiles) HostIDs() (hostIDs []string) {
return
}
-// DispatcherProfile is the config for one Dispatcher
-type DispatcherProfile struct {
- Tenant string
- ID string
- FilterIDs []string
- Strategy string
- StrategyParams map[string]any // ie for distribution, set here the pool weights
- Weight float64 // used for profile sorting on match
- Hosts DispatcherHostProfiles // dispatch to these connections
-}
-
-// DispatcherProfileWithAPIOpts is used in replicatorV1 for dispatcher
-type DispatcherProfileWithAPIOpts struct {
- *DispatcherProfile
- APIOpts map[string]any
-}
-
-func (dP *DispatcherProfile) TenantID() string {
- return utils.ConcatenatedKey(dP.Tenant, dP.ID)
-}
-
-// DispatcherProfiles is a sortable list of Dispatcher profiles
-type DispatcherProfiles []*DispatcherProfile
-
-// Sort is part of sort interface, sort based on Weight
-func (dps DispatcherProfiles) Sort() {
- sort.Slice(dps, func(i, j int) bool { return dps[i].Weight > dps[j].Weight })
-}
-
// DispatcherHost represents one virtual host used by dispatcher
type DispatcherHost struct {
Tenant string
@@ -191,83 +161,6 @@ func (dHPrflIDs DispatcherHostIDs) Clone() (cln DispatcherHostIDs) {
return
}
-func (dP *DispatcherProfile) Set(path []string, val any, newBranch bool, _ string) (err error) {
- switch len(path) {
- default:
- return utils.ErrWrongPath
- case 1:
- switch path[0] {
- default:
- if strings.HasPrefix(path[0], utils.StrategyParams) &&
- path[0][14] == '[' && path[0][len(path[0])-1] == ']' {
- dP.StrategyParams[path[0][15:len(path[0])-1]] = val
- return
- }
- return utils.ErrWrongPath
- case utils.Tenant:
- dP.Tenant = utils.IfaceAsString(val)
- case utils.ID:
- dP.ID = utils.IfaceAsString(val)
- case utils.FilterIDs:
- var valA []string
- valA, err = utils.IfaceAsStringSlice(val)
- dP.FilterIDs = append(dP.FilterIDs, valA...)
- case utils.Strategy:
- dP.Strategy = utils.IfaceAsString(val)
- case utils.Weight:
- if val != utils.EmptyString {
- dP.Weight, err = utils.IfaceAsFloat64(val)
- }
- case utils.StrategyParams:
- dP.StrategyParams, err = utils.NewMapFromCSV(utils.IfaceAsString(val))
- }
- case 2:
- switch path[0] {
- default:
- return utils.ErrWrongPath
- case utils.StrategyParams:
- dP.StrategyParams[path[1]] = val
- case utils.Hosts:
- if len(dP.Hosts) == 0 || newBranch {
- dP.Hosts = append(dP.Hosts, &DispatcherHostProfile{Params: make(map[string]any)})
- }
- switch path[1] {
- case utils.ID:
- dP.Hosts[len(dP.Hosts)-1].ID = utils.IfaceAsString(val)
- case utils.FilterIDs:
- var valA []string
- valA, err = utils.IfaceAsStringSlice(val)
- dP.Hosts[len(dP.Hosts)-1].FilterIDs = append(dP.Hosts[len(dP.Hosts)-1].FilterIDs, valA...)
- case utils.Weight:
- if val != utils.EmptyString {
- dP.Hosts[len(dP.Hosts)-1].Weight, err = utils.IfaceAsFloat64(val)
- }
- case utils.Blocker:
- dP.Hosts[len(dP.Hosts)-1].Blocker, err = utils.IfaceAsBool(val)
- case utils.Params:
- dP.Hosts[len(dP.Hosts)-1].Params, err = utils.NewMapFromCSV(utils.IfaceAsString(val))
- default:
- if strings.HasPrefix(path[1], utils.Params) &&
- path[1][6] == '[' && path[1][len(path[1])-1] == ']' {
- dP.Hosts[len(dP.Hosts)-1].Params[path[1][7:len(path[1])-1]] = val
- return
- }
- return utils.ErrWrongPath
- }
- }
- case 3:
- if path[0] != utils.Hosts ||
- path[1] != utils.Params {
- return utils.ErrWrongPath
- }
- if len(dP.Hosts) == 0 || newBranch {
- dP.Hosts = append(dP.Hosts, &DispatcherHostProfile{Params: make(map[string]any)})
- }
- dP.Hosts[len(dP.Hosts)-1].Params[path[2]] = val
- }
- return
-}
-
func (dH *DispatcherHost) Set(path []string, val any, newBranch bool, _ string) (err error) {
if len(path) != 1 {
return utils.ErrWrongPath
@@ -311,43 +204,6 @@ func (dH *DispatcherHost) Set(path []string, val any, newBranch bool, _ string)
return
}
-func (dP *DispatcherProfile) Merge(v2 any) {
- vi := v2.(*DispatcherProfile)
- if len(vi.Tenant) != 0 {
- dP.Tenant = vi.Tenant
- }
- if len(vi.ID) != 0 {
- dP.ID = vi.ID
- }
- dP.FilterIDs = append(dP.FilterIDs, vi.FilterIDs...)
- if len(dP.Hosts) == 1 && dP.Hosts[0].ID == utils.EmptyString {
- dP.Hosts = dP.Hosts[:0]
- }
- var equal bool
- for _, hostV2 := range vi.Hosts {
- for _, host := range dP.Hosts {
- if host.ID == hostV2.ID {
- host.Merge(hostV2)
- equal = true
- break
- }
- }
- if !equal && hostV2.ID != utils.EmptyString {
- dP.Hosts = append(dP.Hosts, hostV2)
- }
- equal = false
- }
- if vi.Weight != 0 {
- dP.Weight = vi.Weight
- }
- for k, v := range vi.StrategyParams {
- dP.StrategyParams[k] = v
- }
- if len(vi.Strategy) != 0 {
- dP.Strategy = vi.Strategy
- }
-}
-
func (dspHost *DispatcherHostProfile) Merge(v2 *DispatcherHostProfile) {
if v2.ID != utils.EmptyString {
dspHost.ID = v2.ID
@@ -451,84 +307,6 @@ func (dH *DispatcherHost) FieldAsInterface(fldPath []string) (_ any, err error)
}
}
-func (dP *DispatcherProfile) String() string { return utils.ToJSON(dP) }
-func (dP *DispatcherProfile) FieldAsString(fldPath []string) (_ string, err error) {
- var val any
- if val, err = dP.FieldAsInterface(fldPath); err != nil {
- return
- }
- return utils.IfaceAsString(val), nil
-}
-func (dP *DispatcherProfile) FieldAsInterface(fldPath []string) (_ any, err error) {
- if len(fldPath) == 1 {
- switch fldPath[0] {
- default:
- fld, idxStr := utils.GetPathIndexString(fldPath[0])
- if idxStr != nil {
- switch fld {
- case utils.Hosts:
- var idx int
- if idx, err = strconv.Atoi(*idxStr); err != nil {
- return
- }
- if idx < len(dP.Hosts) {
- return dP.Hosts[idx], nil
- }
- case utils.FilterIDs:
- var idx int
- if idx, err = strconv.Atoi(*idxStr); err != nil {
- return
- }
- if idx < len(dP.FilterIDs) {
- return dP.FilterIDs[idx], nil
- }
- case utils.StrategyParams:
- return utils.MapStorage(dP.StrategyParams).FieldAsInterface([]string{*idxStr})
- }
- }
- return nil, utils.ErrNotFound
- case utils.Tenant:
- return dP.Tenant, nil
- case utils.ID:
- return dP.ID, nil
- case utils.FilterIDs:
- return dP.FilterIDs, nil
- case utils.Weight:
- return dP.Weight, nil
- case utils.Hosts:
- return dP.Hosts, nil
- case utils.Strategy:
- return dP.Strategy, nil
- }
- }
- if len(fldPath) == 0 {
- return nil, utils.ErrNotFound
- }
- fld, idxStr := utils.GetPathIndexString(fldPath[0])
- switch fld {
- default:
- return nil, utils.ErrNotFound
- case utils.StrategyParams:
- path := fldPath[1:]
- if idxStr != nil {
- path = append([]string{*idxStr}, path...)
- }
- return utils.MapStorage(dP.StrategyParams).FieldAsInterface(path)
- case utils.Hosts:
- if idxStr == nil {
- return nil, utils.ErrNotFound
- }
- var idx int
- if idx, err = strconv.Atoi(*idxStr); err != nil {
- return
- }
- if idx >= len(dP.Hosts) {
- return nil, utils.ErrNotFound
- }
- return dP.Hosts[idx].FieldAsInterface(fldPath[1:])
- }
-}
-
func (dC *DispatcherHostProfile) String() string { return utils.ToJSON(dC) }
func (dC *DispatcherHostProfile) FieldAsString(fldPath []string) (_ string, err error) {
var val any
diff --git a/engine/dispatcherprfl_test.go b/engine/dispatcherprfl_test.go
index de023d370..e49772499 100644
--- a/engine/dispatcherprfl_test.go
+++ b/engine/dispatcherprfl_test.go
@@ -185,50 +185,6 @@ func TestDispatcherHostProfilesConnIDs(t *testing.T) {
}
}
-func TestDispatcherProfileTenantID(t *testing.T) {
- dProf := DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DISP_1",
- }
- eTenantID := utils.ConcatenatedKey("cgrates.org", "DISP_1")
- if dTenantID := dProf.TenantID(); !reflect.DeepEqual(eTenantID, dTenantID) {
- t.Errorf("expecting: %+v, received: %+v", utils.ToJSON(eTenantID), utils.ToJSON(dTenantID))
- }
-}
-
-func TestDispatcherProfilesSort(t *testing.T) {
- dProf := DispatcherProfiles{
- {ID: "DSP_3", Weight: 10},
- {ID: "DSP_2", Weight: 20},
- {ID: "DSP_1", Weight: 30},
- }
- eProf := DispatcherProfiles{
- {ID: "DSP_1", Weight: 30},
- {ID: "DSP_2", Weight: 20},
- {ID: "DSP_3", Weight: 10},
- }
- if dProf.Sort(); !reflect.DeepEqual(eProf, dProf) {
- t.Errorf("expecting: %+v, received: %+v", utils.ToJSON(eProf), utils.ToJSON(dProf))
- }
- dProf = DispatcherProfiles{
- {ID: "DSP_3", Weight: 10},
- {ID: "DSP_5", Weight: 50},
- {ID: "DSP_2", Weight: 20},
- {ID: "DSP_4", Weight: 40},
- {ID: "DSP_1", Weight: 30},
- }
- eProf = DispatcherProfiles{
- {ID: "DSP_5", Weight: 50},
- {ID: "DSP_4", Weight: 40},
- {ID: "DSP_1", Weight: 30},
- {ID: "DSP_2", Weight: 20},
- {ID: "DSP_3", Weight: 10},
- }
- if dProf.Sort(); !reflect.DeepEqual(eProf, dProf) {
- t.Errorf("expecting: %+v, received: %+v", utils.ToJSON(eProf), utils.ToJSON(dProf))
- }
-}
-
func TestDispatcherHostIDsProfilesReorderFromIndex(t *testing.T) {
dConns := DispatcherHostIDs{"DSP_1", "DSP_2", "DSP_3"}
eConns := DispatcherHostIDs{"DSP_1", "DSP_2", "DSP_3"}
@@ -270,105 +226,6 @@ func TestDispatcherHostIDsProfilesClone(t *testing.T) {
}
}
-func TestDispatcherProfileSet(t *testing.T) {
- dp := DispatcherProfile{}
- exp := DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"},
- Weight: 10,
- Strategy: utils.MetaRandom,
- StrategyParams: map[string]any{
- "opt1": "val1",
- "opt2": "val1",
- "opt3": "val1",
- },
- Hosts: DispatcherHostProfiles{
- {
- ID: "host1",
- FilterIDs: []string{"fltr1"},
- Weight: 10,
- Blocker: true,
- Params: map[string]any{
- "param1": "val1",
- "param2": "val1",
- },
- },
- {
- Params: map[string]any{
- "param3": "val1",
- },
- },
- },
- }
- if err := dp.Set([]string{}, "", false, utils.EmptyString); err != utils.ErrWrongPath {
- t.Error(err)
- }
- if err := dp.Set([]string{"NotAField"}, "", false, utils.EmptyString); err != utils.ErrWrongPath {
- t.Error(err)
- }
- if err := dp.Set([]string{"NotAField", "1"}, "", false, utils.EmptyString); err != utils.ErrWrongPath {
- t.Error(err)
- }
-
- if err := dp.Set([]string{utils.Tenant}, "cgrates.org", false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.ID}, "ID", false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.FilterIDs}, "fltr1;*string:~*req.Account:1001", false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.Weight}, 10, false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.Strategy}, utils.MetaRandom, false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.StrategyParams}, "opt1:val1", false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.StrategyParams + "[opt2]"}, "val1", false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.StrategyParams, "opt3"}, "val1", false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.Hosts, utils.ID}, "host1", false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.Hosts, utils.FilterIDs}, "fltr1", false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.Hosts, utils.Weight}, "10", false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.Hosts, utils.Blocker}, "true", false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.Hosts, utils.Params}, "param1:val1", false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.Hosts, utils.Params + "[param2]"}, "val1", false, utils.EmptyString); err != nil {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.Hosts, utils.Params, "param3"}, "val1", true, utils.EmptyString); err != nil {
- t.Error(err)
- }
-
- if err := dp.Set([]string{utils.Hosts, "Wrong"}, "val1", false, utils.EmptyString); err != utils.ErrWrongPath {
- t.Error(err)
- }
- if err := dp.Set([]string{utils.Hosts, "Wrong", "path"}, "", true, utils.EmptyString); err != utils.ErrWrongPath {
- t.Error(err)
- }
-
- if !reflect.DeepEqual(exp, dp) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(dp))
- }
-}
-
func TestDispatcherHostSet(t *testing.T) {
dp := DispatcherHost{RemoteHost: &config.RemoteHost{}}
exp := DispatcherHost{
@@ -444,347 +301,6 @@ func TestDispatcherHostSet(t *testing.T) {
}
}
-func TestDispatcherProfileAsInterface(t *testing.T) {
- dp := DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"},
- Weight: 10,
- Strategy: utils.MetaRandom,
- StrategyParams: map[string]any{
- "opt1": "val1",
- "opt2": "val1",
- "opt3": "val1",
- },
- Hosts: DispatcherHostProfiles{
- {
- ID: "host1",
- FilterIDs: []string{"fltr1"},
- Weight: 10,
- Blocker: true,
- Params: map[string]any{
- "param1": "val1",
- "param2": "val1",
- },
- },
- {
- Params: map[string]any{
- "param3": "val1",
- },
- },
- },
- }
- if _, err := dp.FieldAsInterface(nil); err != utils.ErrNotFound {
- t.Fatal(err)
- }
- if _, err := dp.FieldAsInterface([]string{"field"}); err != utils.ErrNotFound {
- t.Fatal(err)
- }
- if _, err := dp.FieldAsInterface([]string{"field", ""}); err != utils.ErrNotFound {
- t.Fatal(err)
- }
- if val, err := dp.FieldAsInterface([]string{utils.Tenant}); err != nil {
- t.Fatal(err)
- } else if exp := "cgrates.org"; exp != val {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, err := dp.FieldAsInterface([]string{utils.ID}); err != nil {
- t.Fatal(err)
- } else if exp := utils.ID; exp != val {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, err := dp.FieldAsInterface([]string{utils.FilterIDs}); err != nil {
- t.Fatal(err)
- } else if exp := dp.FilterIDs; !reflect.DeepEqual(exp, val) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, err := dp.FieldAsInterface([]string{utils.FilterIDs + "[0]"}); err != nil {
- t.Fatal(err)
- } else if exp := dp.FilterIDs[0]; exp != val {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, err := dp.FieldAsInterface([]string{utils.Weight}); err != nil {
- t.Fatal(err)
- } else if exp := dp.Weight; !reflect.DeepEqual(exp, val) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, err := dp.FieldAsInterface([]string{utils.Hosts}); err != nil {
- t.Fatal(err)
- } else if exp := dp.Hosts; !reflect.DeepEqual(exp, val) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, err := dp.FieldAsInterface([]string{utils.Strategy}); err != nil {
- t.Fatal(err)
- } else if exp := dp.Strategy; !reflect.DeepEqual(exp, val) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, err := dp.FieldAsInterface([]string{utils.Hosts}); err != nil {
- t.Fatal(err)
- } else if exp := dp.Hosts; !reflect.DeepEqual(exp, val) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, err := dp.FieldAsInterface([]string{utils.Hosts + "[0]"}); err != nil {
- t.Fatal(err)
- } else if exp := dp.Hosts[0]; exp != val {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- expErrMsg := `strconv.Atoi: parsing "a": invalid syntax`
- if _, err := dp.FieldAsInterface([]string{utils.FilterIDs + "[a]"}); err == nil || err.Error() != expErrMsg {
- t.Errorf("Expeceted: %v, received: %v", expErrMsg, err)
- }
- if _, err := dp.FieldAsInterface([]string{utils.Hosts + "[a]"}); err == nil || err.Error() != expErrMsg {
- t.Errorf("Expeceted: %v, received: %v", expErrMsg, err)
- }
- if _, err := dp.FieldAsInterface([]string{utils.Hosts + "[a]", ""}); err == nil || err.Error() != expErrMsg {
- t.Errorf("Expeceted: %v, received: %v", expErrMsg, err)
- }
- if _, err := dp.FieldAsInterface([]string{utils.Hosts + "[4]", ""}); err != utils.ErrNotFound {
- t.Fatal(err)
- }
- if _, err := dp.FieldAsInterface([]string{utils.Hosts + "[a]", ""}); err == nil || err.Error() != expErrMsg {
- t.Errorf("Expeceted: %v, received: %v", expErrMsg, err)
- }
- if _, err := dp.FieldAsInterface([]string{utils.Hosts + "[0]", ""}); err != utils.ErrNotFound {
- t.Fatal(err)
- }
- if _, err := dp.FieldAsInterface([]string{utils.Hosts, ""}); err != utils.ErrNotFound {
- t.Fatal(err)
- }
- if _, err := dp.FieldAsInterface([]string{utils.StrategyParams + "[a]"}); err != utils.ErrNotFound {
- t.Fatal(err)
- }
- if _, err := dp.FieldAsInterface([]string{utils.StrategyParams + "[a]", ""}); err != utils.ErrNotFound {
- t.Fatal(err)
- }
- if val, err := dp.FieldAsInterface([]string{utils.Hosts + "[0]", utils.ID}); err != nil {
- t.Fatal(err)
- } else if exp := dp.Hosts[0].ID; !reflect.DeepEqual(exp, val) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, err := dp.FieldAsInterface([]string{utils.Hosts + "[0]", utils.FilterIDs}); err != nil {
- t.Fatal(err)
- } else if exp := dp.Hosts[0].FilterIDs; !reflect.DeepEqual(exp, val) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, err := dp.FieldAsInterface([]string{utils.Hosts + "[0]", utils.Weight}); err != nil {
- t.Fatal(err)
- } else if exp := dp.Hosts[0].Weight; !reflect.DeepEqual(exp, val) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, err := dp.FieldAsInterface([]string{utils.Hosts + "[0]", utils.Blocker}); err != nil {
- t.Fatal(err)
- } else if exp := dp.Hosts[0].Blocker; !reflect.DeepEqual(exp, val) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, err := dp.FieldAsInterface([]string{utils.Hosts + "[0]", utils.FilterIDs + "[0]"}); err != nil {
- t.Fatal(err)
- } else if exp := dp.Hosts[0].FilterIDs[0]; !reflect.DeepEqual(exp, val) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if _, err := dp.FieldAsInterface([]string{utils.Hosts + "[0]", utils.FilterIDs + "[a]"}); err == nil || err.Error() != expErrMsg {
- t.Errorf("Expeceted: %v, received: %v", expErrMsg, err)
- }
- if _, err := dp.FieldAsInterface([]string{utils.Hosts + "[0]", utils.Params + "[a]"}); err != utils.ErrNotFound {
- t.Fatal(err)
- }
- if _, err := dp.FieldAsInterface([]string{utils.Hosts + "[0]", utils.Params + "[a]", ""}); err != utils.ErrNotFound {
- t.Fatal(err)
- }
- if _, err := dp.FieldAsInterface([]string{utils.Hosts + "[0]", utils.Params + "a]", ""}); err != utils.ErrNotFound {
- t.Fatal(err)
- }
-
- if _, err := dp.FieldAsString([]string{""}); err != utils.ErrNotFound {
- t.Fatal(err)
- }
- if val, err := dp.FieldAsString([]string{utils.ID}); err != nil {
- t.Fatal(err)
- } else if exp := "ID"; exp != val {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, exp := dp.String(), utils.ToJSON(dp); exp != val {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
-
- if _, err := dp.Hosts[0].FieldAsString([]string{}); err != utils.ErrNotFound {
- t.Fatal(err)
- }
- if val, err := dp.Hosts[0].FieldAsString([]string{utils.ID}); err != nil {
- t.Fatal(err)
- } else if exp := "host1"; exp != val {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
- if val, exp := dp.Hosts[0].String(), utils.ToJSON(dp.Hosts[0]); exp != val {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val))
- }
-}
-
-func TestDispatcherProfileMerge(t *testing.T) {
- dp := &DispatcherProfile{
- StrategyParams: make(map[string]any),
- }
- exp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- {
- ID: "C2",
- FilterIDs: []string{"fltr3"},
- Weight: 10,
- Params: map[string]any{
- "param3": "value3",
- },
- Blocker: false,
- },
- },
- }
- if dp.Merge(&DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{},
- Blocker: true,
- },
- {
- ID: "C2",
- FilterIDs: []string{"fltr3"},
- Weight: 10,
- Params: map[string]any{
- "param3": "value3",
- },
- Blocker: false,
- },
- },
- }); !reflect.DeepEqual(exp, dp) {
- t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(dp))
- }
-}
-
-func TestDispatcherProfileMergeEmptyHostId(t *testing.T) {
- dp := &DispatcherProfile{
- StrategyParams: make(map[string]any),
- Hosts: DispatcherHostProfiles{
- {
- ID: utils.EmptyString,
- },
- },
- }
- exp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{
- "param4": "value4",
- },
- Blocker: false,
- },
- },
- }
- if dp.Merge(&DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"fltr2"},
- Weight: 20,
- Params: map[string]any{
- "param4": "value4",
- },
- Blocker: false,
- },
- },
- }); !reflect.DeepEqual(exp, dp) {
- t.Errorf("Expected %+v \n but received \n %+v", utils.ToJSON(exp), utils.ToJSON(dp))
- }
-}
-func TestDispatcherProfileMergeEqualHosts(t *testing.T) {
- dp := &DispatcherProfile{
- StrategyParams: make(map[string]any),
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"dpFltr1"},
- Weight: 20,
- Params: map[string]any{
- "param4": "value4",
- },
- Blocker: false,
- },
- },
- }
- exp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"dpFltr1", "newFltr2"},
- Weight: 20,
- Params: map[string]any{
- "param4": "value4",
- },
- Blocker: false,
- },
- },
- }
- if dp.Merge(&DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr1"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C3",
- FilterIDs: []string{"newFltr2"},
- Weight: 20,
- Params: map[string]any{
- "param4": "value4",
- },
- Blocker: false,
- },
- },
- }); !reflect.DeepEqual(exp, dp) {
- t.Errorf("Expected %+v \n but received \n %+v", utils.ToJSON(exp), utils.ToJSON(dp))
- }
-}
func TestDispatcherHostAsInterface(t *testing.T) {
dh := DispatcherHost{
Tenant: "cgrates.org",
diff --git a/engine/libengine.go b/engine/libengine.go
index 221b1669f..621c51f2f 100644
--- a/engine/libengine.go
+++ b/engine/libengine.go
@@ -222,9 +222,6 @@ func NewDispatcherService(val any) (_ IntService, err error) {
case strings.HasPrefix(m, utils.ConfigS):
m = strings.TrimPrefix(m, utils.ConfigS)
key = utils.ConfigS
- case strings.HasPrefix(m, utils.DispatcherS):
- m = strings.TrimPrefix(m, utils.DispatcherS)
- key = utils.DispatcherS
case strings.HasPrefix(m, utils.GuardianS):
m = strings.TrimPrefix(m, utils.GuardianS)
key = utils.GuardianS
diff --git a/engine/libengine_test.go b/engine/libengine_test.go
index 4a183f78c..6fa79a451 100644
--- a/engine/libengine_test.go
+++ b/engine/libengine_test.go
@@ -190,7 +190,6 @@ func (TestRPCDspMock) AttributeSv1Do(*context.Context, any, *string) error {
func (TestRPCDspMock) CacheSv1Do(*context.Context, any, *string) error { return nil }
func (TestRPCDspMock) ChargerSv1Do(*context.Context, any, *string) error { return nil }
func (TestRPCDspMock) ConfigSv1Do(*context.Context, any, *string) error { return nil }
-func (TestRPCDspMock) DispatcherSv1Do(*context.Context, any, *string) error { return nil }
func (TestRPCDspMock) GuardianSv1Do(*context.Context, any, *string) error { return nil }
func (TestRPCDspMock) RateSv1Do(*context.Context, any, *string) error { return nil }
func (TestRPCDspMock) ReplicatorSv1Do(*context.Context, any, *string) error { return nil }
@@ -207,48 +206,6 @@ func (TestRPCDspMock) AdminSv1Do(*context.Context, any, *string) error {
func (TestRPCDspMock) LoaderSv1Do(*context.Context, any, *string) error { return nil }
func (TestRPCDspMock) ServiceManagerv1Do(*context.Context, any, *string) error { return nil }
-func TestIntServiceNewDispatcherService(t *testing.T) {
- expErrMsg := `rpc.Register: no service name for type struct {}`
- if _, err := NewDispatcherService(struct{}{}); err == nil || err.Error() != expErrMsg {
- t.Errorf("Expeceted: %v, received: %v", expErrMsg, err)
- }
-
- s, err := NewDispatcherService(new(TestRPCDspMock))
- if err != nil {
- t.Fatal(err)
- }
- methods := getMethods(s)
- exp := map[string][]string{
- "AccountSv1": {"Do", "Ping"},
- "ActionSv1": {"Do", "Ping"},
- "AttributeSv1": {"Do", "Ping"},
- "CDRsV1": {"Do", "Ping"},
- "CacheSv1": {"Do", "Ping"},
- "ChargerSv1": {"Do", "Ping"},
- "ConfigSv1": {"Do", "Ping"},
- "DispatcherSv1": {"Do", "Ping"},
- "GuardianSv1": {"Do", "Ping"},
- "RateSv1": {"Do", "Ping"},
- "ResourceSv1": {"Do", "Ping"},
- "RouteSv1": {"Do", "Ping"},
- "SessionSv1": {"Do", "Ping"},
- "StatSv1": {"Do", "Ping"},
- "TestRPCDspMock": {"AccountSv1Do", "ActionSv1Do", "AdminSv1Do", "AnalyzerSv1Do", "AttributeSv1Do", "CDRsv1Do", "CacheSv1Do", "ChargerSv1Do", "ConfigSv1Do", "CoreSv1Do", "DispatcherSv1Do", "EeSv1Do", "GuardianSv1Do", "LoaderSv1Do", "Ping", "RateSv1Do", "ReplicatorSv1Do", "ResourceSv1Do", "RouteSv1Do", "ServiceManagerv1Do", "SessionSv1Do", "StatSv1Do", "ThresholdSv1Do"},
- "ThresholdSv1": {"Do", "Ping"},
- "ReplicatorSv1": {"Do", "Ping"},
-
- "EeSv1": {"Do", "Ping"},
- "CoreSv1": {"Do", "Ping"},
- "AnalyzerSv1": {"Do", "Ping"},
- "AdminSv1": {"Do", "Ping"},
- "LoaderSv1": {"Do", "Ping"},
- "ServiceManagerV1": {"Do", "Ping"},
- }
- if !reflect.DeepEqual(exp, methods) {
- t.Errorf("Expeceted: %v, \nreceived: \n%v", utils.ToJSON(exp), utils.ToJSON(methods))
- }
-}
-
func TestNewRPCPoolUnsupportedTransport(t *testing.T) {
tmp := Cache
defer func() {
diff --git a/engine/libindex.go b/engine/libindex.go
index a707042db..248a01aa3 100644
--- a/engine/libindex.go
+++ b/engine/libindex.go
@@ -740,24 +740,6 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
}, newFlt); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
}
- case utils.CacheDispatcherFilterIndexes:
- if err = removeFilterIndexesForFilter(ctx, dm, idxItmType, newFlt.Tenant, // remove the indexes for the filter
- removeIndexKeys, indx); err != nil {
- return
- }
- idxSlice := indx.AsSlice()
- if _, err = ComputeIndexes(ctx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
- &idxSlice, utils.NonTransactional, func(tnt, id, _ string) (*[]string, error) {
- dp, e := dm.GetDispatcherProfile(ctx, tnt, id, true, false, utils.NonTransactional)
- if e != nil {
- return nil, e
- }
- fltrIDs := make([]string, len(dp.FilterIDs))
- copy(fltrIDs, dp.FilterIDs)
- return &fltrIDs, nil
- }, newFlt); err != nil && err != utils.ErrDSPProfileNotFound {
- return utils.APIErrorHandler(err)
- }
}
}
return
diff --git a/engine/libindex_health.go b/engine/libindex_health.go
index f14171d03..a213a2ee5 100644
--- a/engine/libindex_health.go
+++ b/engine/libindex_health.go
@@ -100,13 +100,6 @@ func getFilters(ctx *context.Context, dm *DataManager, indxType, tnt, id string)
return
}
filterIDs = ch.FilterIDs
- case utils.CacheDispatcherFilterIndexes:
- var ds *DispatcherProfile
- if ds, err = dm.GetDispatcherProfile(ctx, tnt, id, true, false, utils.NonTransactional); err != nil {
- return
- }
- filterIDs = ds.FilterIDs
-
case utils.CacheRateProfilesFilterIndexes:
var rp *utils.RateProfile
if rp, err = dm.GetRateProfile(ctx, tnt, id, true, false, utils.NonTransactional); err != nil {
diff --git a/engine/libindex_test.go b/engine/libindex_test.go
index 783223c3e..29a04f095 100644
--- a/engine/libindex_test.go
+++ b/engine/libindex_test.go
@@ -2449,213 +2449,6 @@ func TestUpdateFilterIndexRateProfilesErr2(t *testing.T) {
}
-func TestUpdateFilterIndexDispatcherIndex(t *testing.T) {
- tmp := Cache
- defer func() {
- Cache = tmp
- }()
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- dataDB := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := NewDataManager(dataDB, cfg.CacheCfg(), nil)
-
- oldFlt := &Filter{
- Tenant: "cgrates.org",
- ID: "fltr_test",
- Rules: []*FilterRule{
- {
- Type: utils.MetaString,
- Element: "~*req.Cost",
- Values: []string{"unRegVal2"},
- },
- },
- }
-
- if err := oldFlt.Compile(); err != nil {
- t.Error(err)
- }
-
- if err := dm.SetFilter(context.Background(), oldFlt, true); err != nil {
- t.Error(err)
- }
- dpp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "ID",
- FilterIDs: []string{"fltr_test"},
- Weight: 65,
- Strategy: utils.MetaLoad,
- StrategyParams: map[string]any{"k": "v"},
- Hosts: DispatcherHostProfiles{
- {
- ID: "C2",
- FilterIDs: []string{"fltr3"},
- Weight: 10,
- Params: map[string]any{
- "param3": "value3",
- },
- Blocker: false,
- },
- },
- }
-
- if err := dm.SetDispatcherProfile(context.Background(), dpp, true); err != nil {
- t.Error(err)
- }
-
- expindx := map[string]utils.StringSet{
- "*string:*req.Cost:unRegVal2": {"ID": {}},
- }
-
- getindx, err := dm.GetIndexes(context.Background(), utils.CacheDispatcherFilterIndexes, utils.CGRateSorg, utils.EmptyString, utils.EmptyString, true, true)
- if err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expindx, getindx) {
- t.Errorf("Expected \n<%v>, \nReceived \n<%v>", utils.ToJSON(expindx), utils.ToJSON(getindx))
- }
-
- newFlt := &Filter{
- Tenant: "cgrates.org",
- ID: "fltr_test",
- Rules: []*FilterRule{
- {
- Type: utils.MetaPrefix,
- Element: "~*req.Usage",
- Values: []string{"10s"},
- },
- },
- }
- if err := newFlt.Compile(); err != nil {
- t.Error(err)
- }
- if err := dm.SetFilter(context.Background(), newFlt, false); err != nil {
- t.Error(err)
- }
-
- if err := UpdateFilterIndex(context.Background(), dm, oldFlt, newFlt); err != nil {
- t.Error(err)
- }
-
- expindxNew := map[string]utils.StringSet{
- "*prefix:*req.Usage:10s": {"ID": {}},
- }
- getindxNew, err := dm.GetIndexes(context.Background(), utils.CacheDispatcherFilterIndexes, utils.CGRateSorg, utils.EmptyString, utils.EmptyString, true, true)
- if err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expindxNew, getindxNew) {
- t.Errorf("Expected \n<%v>, \nReceived \n<%v>", utils.ToJSON(expindxNew), utils.ToJSON(getindxNew))
- }
-
-}
-
-func TestUpdateFilterDispatcherIndexErr1(t *testing.T) {
- tmp := Cache
- defer func() {
- Cache = tmp
- }()
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- dataDB := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := NewDataManager(dataDB, cfg.CacheCfg(), nil)
-
- dm.dataDB = &DataDBMock{
- GetIndexesDrvF: func(ctx *context.Context, idxItmType, tntCtx, idxKey, transactionID string) (indexes map[string]utils.StringSet, err error) {
- return map[string]utils.StringSet{
- utils.CacheDispatcherFilterIndexes: {
- "ATTR_TEST": {},
- },
- }, nil
- },
- SetIndexesDrvF: func(ctx *context.Context, idxItmType, tntCtx string, indexes map[string]utils.StringSet, commit bool, transactionID string) (err error) {
- return utils.ErrNotImplemented
- },
- }
-
- oldFlt := &Filter{
- Tenant: "cgrates.org",
- ID: "fltr_test",
- Rules: []*FilterRule{
- {
- Type: utils.MetaString,
- Element: "~*req.Cost",
- Values: []string{"unRegVal2"},
- },
- },
- }
- newFlt := &Filter{
- Tenant: "cgrates.org",
- ID: "fltr_test",
- Rules: []*FilterRule{
- {
- Type: utils.MetaPrefix,
- Element: "~*req.Usage",
- Values: []string{"10s"},
- },
- },
- }
-
- expErr := utils.ErrNotImplemented
- if err := UpdateFilterIndex(context.Background(), dm, oldFlt, newFlt); err != expErr {
- t.Errorf("Expected error <%v>, Received error <%v>", expErr, err)
- }
-
-}
-
-func TestUpdateFilterIndexDispatcherErr2(t *testing.T) {
- tmp := Cache
- defer func() {
- Cache = tmp
- }()
- Cache.Clear(nil)
-
- cfg := config.NewDefaultCGRConfig()
- dataDB := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := NewDataManager(dataDB, cfg.CacheCfg(), nil)
-
- dm.dataDB = &DataDBMock{
- GetIndexesDrvF: func(ctx *context.Context, idxItmType, tntCtx, idxKey, transactionID string) (indexes map[string]utils.StringSet, err error) {
- return map[string]utils.StringSet{
- utils.CacheDispatcherFilterIndexes: {
- "ATTR_TEST": {},
- },
- }, nil
- },
- SetIndexesDrvF: func(ctx *context.Context, idxItmType, tntCtx string, indexes map[string]utils.StringSet, commit bool, transactionID string) (err error) {
- return nil
- },
- }
-
- oldFlt := &Filter{
- Tenant: "cgrates.org",
- ID: "fltr_test",
- Rules: []*FilterRule{
- {
- Type: utils.MetaString,
- Element: "~*req.Cost",
- Values: []string{"unRegVal2"},
- },
- },
- }
- newFlt := &Filter{
- Tenant: "cgrates.org",
- ID: "fltr_test",
- Rules: []*FilterRule{
- {
- Type: utils.MetaPrefix,
- Element: "~*req.Usage",
- Values: []string{"10s"},
- },
- },
- }
-
- expErr := "SERVER_ERROR: NOT_IMPLEMENTED"
- if err := UpdateFilterIndex(context.Background(), dm, oldFlt, newFlt); err == nil || err.Error() != expErr {
- t.Errorf("Expected error <%v>, Received error <%v>", expErr, err)
- }
-
-}
-
func TestRemoveFilterIndexesForFilterErr(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
diff --git a/engine/libtest.go b/engine/libtest.go
index e3779863f..a607be9c2 100644
--- a/engine/libtest.go
+++ b/engine/libtest.go
@@ -271,12 +271,6 @@ func GetDefaultEmptyCacheStats() map[string]*ltcache.CacheStats {
utils.CacheAttributeProfiles: {},
utils.CacheChargerFilterIndexes: {},
utils.CacheChargerProfiles: {},
- utils.CacheDispatcherFilterIndexes: {},
- utils.CacheDispatcherProfiles: {},
- utils.CacheDispatcherHosts: {},
- utils.CacheDispatcherRoutes: {},
- utils.CacheDispatcherLoads: {},
- utils.CacheDispatchers: {},
utils.CacheEventResources: {},
utils.CacheFilters: {},
utils.CacheResourceFilterIndexes: {},
diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go
index bebc91470..031aecb65 100644
--- a/engine/loader_csv_test.go
+++ b/engine/loader_csv_test.go
@@ -23,7 +23,6 @@ import (
"sort"
"strings"
"testing"
- "time"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/utils"
@@ -194,12 +193,6 @@ cgrates.org,1001,,,,,VoiceBalance,,;10,*string:~*req.Destination:1002;true;;fals
if err := csvr.LoadChargerProfiles(); err != nil {
log.Print("error in LoadChargerProfiles:", err)
}
- if err := csvr.LoadDispatcherProfiles(); err != nil {
- log.Print("error in LoadDispatcherProfiles:", err)
- }
- if err := csvr.LoadDispatcherHosts(); err != nil {
- log.Print("error in LoadDispatcherHosts:", err)
- }
if err := csvr.LoadRateProfiles(); err != nil {
log.Print("error in LoadRateProfiles:", err)
}
@@ -580,48 +573,6 @@ cgrates.org,1001,,,,,VoiceBalance,,;10,*string:~*req.Destination:1002;true;;fals
}
})
- t.Run("load DispatcherProfiles", func(t *testing.T) {
- eDispatcherProfiles := &utils.TPDispatcherProfile{
- TPid: testTPID,
- Tenant: "cgrates.org",
- ID: "D1",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Strategy: utils.MetaFirst,
- Weight: 20,
- Hosts: []*utils.TPDispatcherHostProfile{
- {
- ID: "C1",
- FilterIDs: []string{"*gt:~*req.Usage:10"},
- Weight: 10,
- Params: []any{"192.168.56.203"},
- Blocker: false,
- },
- {
- ID: "C2",
- FilterIDs: []string{"*lt:~*req.Usage:10"},
- Weight: 10,
- Params: []any{"192.168.56.204"},
- Blocker: false,
- },
- },
- }
- if len(csvr.dispatcherProfiles) != 1 {
- t.Errorf("Failed to load dispatcherProfiles: %s", utils.ToIJSON(csvr.dispatcherProfiles))
- }
- dppKey := utils.TenantID{Tenant: "cgrates.org", ID: "D1"}
- sort.Slice(eDispatcherProfiles.Hosts, func(i, j int) bool {
- return eDispatcherProfiles.Hosts[i].ID < eDispatcherProfiles.Hosts[j].ID
- })
- sort.Slice(csvr.dispatcherProfiles[dppKey].Hosts, func(i, j int) bool {
- return csvr.dispatcherProfiles[dppKey].Hosts[i].ID < csvr.dispatcherProfiles[dppKey].Hosts[j].ID
- })
-
- if !reflect.DeepEqual(eDispatcherProfiles, csvr.dispatcherProfiles[dppKey]) {
- t.Errorf("Expecting: %+v, received: %+v",
- utils.ToJSON(eDispatcherProfiles), utils.ToJSON(csvr.dispatcherProfiles[dppKey]))
- }
- })
-
t.Run("load RateProfiles", func(t *testing.T) {
eRatePrf := &utils.TPRateProfile{
TPid: testTPID,
@@ -785,32 +736,6 @@ cgrates.org,1001,,,,,VoiceBalance,,;10,*string:~*req.Destination:1002;true;;fals
}
})
- t.Run("load DispatcherHosts", func(t *testing.T) {
- eDispatcherHosts := &utils.TPDispatcherHost{
- TPid: testTPID,
- Tenant: "cgrates.org",
- ID: "ALL",
- Conn: &utils.TPDispatcherHostConn{
- Address: "127.0.0.1:6012",
- Transport: utils.MetaJSON,
- ConnectAttempts: 1,
- Reconnects: 3,
- MaxReconnectInterval: 5 * time.Minute,
- ConnectTimeout: 1 * time.Minute,
- ReplyTimeout: 2 * time.Minute,
- TLS: false,
- },
- }
-
- dphKey := utils.TenantID{Tenant: "cgrates.org", ID: "ALL"}
- if len(csvr.dispatcherHosts) != 1 {
- t.Fatalf("Failed to load DispatcherHosts: %v", len(csvr.dispatcherHosts))
- }
- if !reflect.DeepEqual(eDispatcherHosts, csvr.dispatcherHosts[dphKey]) {
- t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(eDispatcherHosts), utils.ToJSON(csvr.dispatcherHosts[dphKey]))
- }
- })
-
t.Run("load Accounts", func(t *testing.T) {
expected := &utils.TPAccount{
TPid: testTPID,
diff --git a/engine/model_helpers.go b/engine/model_helpers.go
index d8bb5bb8d..40d69c197 100644
--- a/engine/model_helpers.go
+++ b/engine/model_helpers.go
@@ -22,7 +22,6 @@ import (
"fmt"
"reflect"
"regexp"
- "slices"
"strconv"
"strings"
"time"
@@ -1730,98 +1729,7 @@ func ChargerProfileToAPI(chargerPrf *ChargerProfile) (tpCharger *utils.TPCharger
return
}
-type DispatcherProfileMdls []*DispatcherProfileMdl
-
// CSVHeader return the header for csv fields as a slice of string
-func (tps DispatcherProfileMdls) CSVHeader() (result []string) {
- return []string{"#" + utils.Tenant, utils.ID, utils.FilterIDs, utils.Weight,
- utils.Strategy, utils.StrategyParameters, utils.ConnID, utils.ConnFilterIDs,
- utils.ConnWeight, utils.ConnBlocker, utils.ConnParameters}
-}
-
-func (tps DispatcherProfileMdls) AsTPDispatcherProfiles() (result []*utils.TPDispatcherProfile) {
- mst := make(map[string]*utils.TPDispatcherProfile)
- filterMap := make(map[string]utils.StringSet)
- connsMap := make(map[string]map[string]utils.TPDispatcherHostProfile)
- connsFilterMap := make(map[string]map[string]utils.StringSet)
- for _, tp := range tps {
- tenantID := (&utils.TenantID{Tenant: tp.Tenant, ID: tp.ID}).TenantID()
- tpDPP, found := mst[tenantID]
- if !found {
- tpDPP = &utils.TPDispatcherProfile{
- TPid: tp.Tpid,
- Tenant: tp.Tenant,
- ID: tp.ID,
- }
- }
- if tp.FilterIDs != utils.EmptyString {
- if _, has := filterMap[tenantID]; !has {
- filterMap[tenantID] = make(utils.StringSet)
- }
- filterMap[tenantID].AddSlice(strings.Split(tp.FilterIDs, utils.InfieldSep))
- }
-
- if tp.Strategy != utils.EmptyString {
- tpDPP.Strategy = tp.Strategy
- }
- if tp.StrategyParameters != utils.EmptyString {
- for _, param := range strings.Split(tp.StrategyParameters, utils.InfieldSep) {
- tpDPP.StrategyParams = append(tpDPP.StrategyParams, param)
- }
- }
- if tp.ConnID != utils.EmptyString {
- if _, has := connsMap[tenantID]; !has {
- connsMap[tenantID] = make(map[string]utils.TPDispatcherHostProfile)
- }
- conn, has := connsMap[tenantID][tp.ConnID]
- if !has {
- conn = utils.TPDispatcherHostProfile{
- ID: tp.ConnID,
- Weight: tp.ConnWeight,
- Blocker: tp.ConnBlocker,
- }
- }
- for _, param := range strings.Split(tp.ConnParameters, utils.InfieldSep) {
- conn.Params = append(conn.Params, param)
- }
- connsMap[tenantID][tp.ConnID] = conn
-
- if dFilter, has := connsFilterMap[tenantID]; !has {
- connsFilterMap[tenantID] = make(map[string]utils.StringSet)
- connsFilterMap[tenantID][tp.ConnID] = make(utils.StringSet)
- } else if _, has := dFilter[tp.ConnID]; !has {
- connsFilterMap[tenantID][tp.ConnID] = make(utils.StringSet)
- }
- if tp.ConnFilterIDs != utils.EmptyString {
- connsFilterMap[tenantID][tp.ConnID].AddSlice(strings.Split(tp.ConnFilterIDs, utils.InfieldSep))
- }
-
- }
- if tp.Weight != 0 {
- tpDPP.Weight = tp.Weight
- }
- mst[tenantID] = tpDPP
- }
- result = make([]*utils.TPDispatcherProfile, len(mst))
- i := 0
- for tntID, tp := range mst {
- result[i] = tp
- result[i].FilterIDs = filterMap[tntID].AsSlice()
- for conID, conn := range connsMap[tntID] {
- conn.FilterIDs = connsFilterMap[tntID][conID].AsSlice()
- result[i].Hosts = append(result[i].Hosts,
- &utils.TPDispatcherHostProfile{
- ID: conn.ID,
- FilterIDs: conn.FilterIDs,
- Weight: conn.Weight,
- Params: conn.Params,
- Blocker: conn.Blocker,
- })
- }
- i++
- }
- return
-}
func paramsToString(sp []any) (strategy string) {
if len(sp) != 0 {
@@ -1833,265 +1741,6 @@ func paramsToString(sp []any) (strategy string) {
return
}
-func APItoModelTPDispatcherProfile(tpDPP *utils.TPDispatcherProfile) (mdls DispatcherProfileMdls) {
- if tpDPP == nil {
- return
- }
-
- filters := strings.Join(tpDPP.FilterIDs, utils.InfieldSep)
-
- strategy := paramsToString(tpDPP.StrategyParams)
-
- if len(tpDPP.Hosts) == 0 {
- return append(mdls, &DispatcherProfileMdl{
- Tpid: tpDPP.TPid,
- Tenant: tpDPP.Tenant,
- ID: tpDPP.ID,
- FilterIDs: filters,
- Strategy: tpDPP.Strategy,
- StrategyParameters: strategy,
- Weight: tpDPP.Weight,
- })
- }
-
- conFilter := strings.Join(tpDPP.Hosts[0].FilterIDs, utils.InfieldSep)
- conParam := paramsToString(tpDPP.Hosts[0].Params)
-
- mdls = append(mdls, &DispatcherProfileMdl{
- Tpid: tpDPP.TPid,
- Tenant: tpDPP.Tenant,
- ID: tpDPP.ID,
- FilterIDs: filters,
- Strategy: tpDPP.Strategy,
- StrategyParameters: strategy,
- Weight: tpDPP.Weight,
-
- ConnID: tpDPP.Hosts[0].ID,
- ConnFilterIDs: conFilter,
- ConnWeight: tpDPP.Hosts[0].Weight,
- ConnBlocker: tpDPP.Hosts[0].Blocker,
- ConnParameters: conParam,
- })
- for i := 1; i < len(tpDPP.Hosts); i++ {
- conFilter = strings.Join(tpDPP.Hosts[i].FilterIDs, utils.InfieldSep)
- conParam = paramsToString(tpDPP.Hosts[i].Params)
- mdls = append(mdls, &DispatcherProfileMdl{
- Tpid: tpDPP.TPid,
- Tenant: tpDPP.Tenant,
- ID: tpDPP.ID,
-
- ConnID: tpDPP.Hosts[i].ID,
- ConnFilterIDs: conFilter,
- ConnWeight: tpDPP.Hosts[i].Weight,
- ConnBlocker: tpDPP.Hosts[i].Blocker,
- ConnParameters: conParam,
- })
- }
-
- return
-}
-
-func APItoDispatcherProfile(tpDPP *utils.TPDispatcherProfile, timezone string) (dpp *DispatcherProfile) {
- dpp = &DispatcherProfile{
- Tenant: tpDPP.Tenant,
- ID: tpDPP.ID,
- Weight: tpDPP.Weight,
- Strategy: tpDPP.Strategy,
- FilterIDs: make([]string, len(tpDPP.FilterIDs)),
- StrategyParams: make(map[string]any),
- Hosts: make(DispatcherHostProfiles, len(tpDPP.Hosts)),
- }
- copy(dpp.FilterIDs, tpDPP.FilterIDs)
- for i, param := range tpDPP.StrategyParams {
- if param != utils.EmptyString {
- dpp.StrategyParams[strconv.Itoa(i)] = param
- }
- }
- for i, conn := range tpDPP.Hosts {
- dpp.Hosts[i] = &DispatcherHostProfile{
- ID: conn.ID,
- Weight: conn.Weight,
- Blocker: conn.Blocker,
- FilterIDs: make([]string, len(conn.FilterIDs)),
- Params: make(map[string]any),
- }
- copy(dpp.Hosts[i].FilterIDs, conn.FilterIDs)
- for j, param := range conn.Params {
- if param == utils.EmptyString {
- continue
- }
- if p := strings.SplitN(utils.IfaceAsString(param), utils.ConcatenatedKeySep, 2); len(p) == 1 {
- dpp.Hosts[i].Params[strconv.Itoa(j)] = p[0]
- } else {
- dpp.Hosts[i].Params[p[0]] = p[1]
- }
-
- }
- }
- return dpp
-}
-
-func DispatcherProfileToAPI(dpp *DispatcherProfile) (tpDPP *utils.TPDispatcherProfile) {
- tpDPP = &utils.TPDispatcherProfile{
- Tenant: dpp.Tenant,
- ID: dpp.ID,
- FilterIDs: make([]string, len(dpp.FilterIDs)),
- Strategy: dpp.Strategy,
- StrategyParams: make([]any, len(dpp.StrategyParams)),
- Weight: dpp.Weight,
- Hosts: make([]*utils.TPDispatcherHostProfile, len(dpp.Hosts)),
- }
- copy(tpDPP.FilterIDs, dpp.FilterIDs)
- for key, val := range dpp.StrategyParams {
- // here we expect that the key to be an integer because
- // according to APItoDispatcherProfile when we convert from TP to obj we use index as key
- // so we can ignore error
- idx, _ := strconv.Atoi(key)
- tpDPP.StrategyParams[idx] = val
- }
- for i, host := range dpp.Hosts {
- tpDPP.Hosts[i] = &utils.TPDispatcherHostProfile{
- ID: host.ID,
- FilterIDs: slices.Clone(host.FilterIDs),
- Weight: host.Weight,
- Params: make([]any, len(host.Params)),
- Blocker: host.Blocker,
- }
- idx := 0
- for key, val := range host.Params {
- paramVal := val
- if _, err := strconv.Atoi(key); err != nil {
- paramVal = utils.ConcatenatedKey(key, utils.IfaceAsString(val))
- }
- tpDPP.Hosts[i].Params[idx] = paramVal
- idx++
- }
- }
-
- return
-}
-
-// TPHosts
-type DispatcherHostMdls []*DispatcherHostMdl
-
-// CSVHeader return the header for csv fields as a slice of string
-func (tps DispatcherHostMdls) CSVHeader() (result []string) {
- return []string{"#" + utils.Tenant, utils.ID, utils.Address, utils.Transport, utils.SynchronousCfg, utils.ConnectAttemptsCfg, utils.ReconnectsCfg, utils.MaxReconnectIntervalCfg, utils.ConnectTimeoutCfg, utils.ReplyTimeoutCfg, utils.TLS, utils.ClientKeyCfg, utils.ClientCerificateCfg, utils.CaCertificateCfg}
-}
-
-func (tps DispatcherHostMdls) AsTPDispatcherHosts() (result []*utils.TPDispatcherHost, err error) {
- hostsMap := make(map[string]*utils.TPDispatcherHost)
- for _, tp := range tps {
- if len(tp.Address) == 0 { // empty addres do not populate conns
- continue
- }
- if len(tp.Transport) == 0 {
- tp.Transport = utils.MetaJSON
- }
- tntId := utils.ConcatenatedKey(tp.Tenant, tp.ID) // Made separate variable in order to call ConcatenatedKey only once per TP
- hostsMap[tntId] = &utils.TPDispatcherHost{
- TPid: tp.Tpid,
- Tenant: tp.Tenant,
- ID: tp.ID,
- Conn: &utils.TPDispatcherHostConn{
- Address: tp.Address,
- Transport: tp.Transport,
- TLS: tp.TLS,
- ConnectAttempts: tp.ConnectAttempts,
- Reconnects: tp.Reconnects,
- ClientKey: tp.ClientKey,
- ClientCertificate: tp.ClientCertificate,
- CaCertificate: tp.CaCertificate,
- },
- }
- if tp.MaxReconnectInterval != utils.EmptyString {
- if hostsMap[tntId].Conn.MaxReconnectInterval, err = utils.ParseDurationWithNanosecs(tp.MaxReconnectInterval); err != nil {
- return nil, err
- }
- }
- if tp.ConnectTimeout != utils.EmptyString {
- if hostsMap[tntId].Conn.ConnectTimeout, err = utils.ParseDurationWithNanosecs(tp.ConnectTimeout); err != nil {
- return nil, err
- }
- }
- if tp.ReplyTimeout != utils.EmptyString {
- if hostsMap[tntId].Conn.ReplyTimeout, err = utils.ParseDurationWithNanosecs(tp.ReplyTimeout); err != nil {
- return nil, err
- }
- }
- continue
- }
- for _, host := range hostsMap {
- result = append(result, host)
- }
- return result, nil
-}
-
-func APItoModelTPDispatcherHost(tpDPH *utils.TPDispatcherHost) (mdls *DispatcherHostMdl) {
- if tpDPH == nil {
- return
- }
- return &DispatcherHostMdl{
- Tpid: tpDPH.TPid,
- Tenant: tpDPH.Tenant,
- ID: tpDPH.ID,
- Address: tpDPH.Conn.Address,
- Transport: tpDPH.Conn.Transport,
- ConnectAttempts: tpDPH.Conn.ConnectAttempts,
- Reconnects: tpDPH.Conn.Reconnects,
- MaxReconnectInterval: tpDPH.Conn.MaxReconnectInterval.String(),
- ConnectTimeout: tpDPH.Conn.ConnectTimeout.String(),
- ReplyTimeout: tpDPH.Conn.ReplyTimeout.String(),
- TLS: tpDPH.Conn.TLS,
- ClientKey: tpDPH.Conn.ClientKey,
- ClientCertificate: tpDPH.Conn.ClientCertificate,
- CaCertificate: tpDPH.Conn.CaCertificate,
- }
-}
-
-func APItoDispatcherHost(tpDPH *utils.TPDispatcherHost) (dpp *DispatcherHost) {
- if tpDPH == nil {
- return
- }
- return &DispatcherHost{
- Tenant: tpDPH.Tenant,
- RemoteHost: &config.RemoteHost{
- ID: tpDPH.ID,
- Address: tpDPH.Conn.Address,
- Transport: tpDPH.Conn.Transport,
- ConnectAttempts: tpDPH.Conn.ConnectAttempts,
- Reconnects: tpDPH.Conn.Reconnects,
- MaxReconnectInterval: tpDPH.Conn.MaxReconnectInterval,
- ConnectTimeout: tpDPH.Conn.ConnectTimeout,
- ReplyTimeout: tpDPH.Conn.ReplyTimeout,
- TLS: tpDPH.Conn.TLS,
- ClientKey: tpDPH.Conn.ClientKey,
- ClientCertificate: tpDPH.Conn.ClientCertificate,
- CaCertificate: tpDPH.Conn.CaCertificate,
- },
- }
-}
-
-func DispatcherHostToAPI(dph *DispatcherHost) (tpDPH *utils.TPDispatcherHost) {
- return &utils.TPDispatcherHost{
- Tenant: dph.Tenant,
- ID: dph.ID,
- Conn: &utils.TPDispatcherHostConn{
- Address: dph.Address,
- Transport: dph.Transport,
- ConnectAttempts: dph.ConnectAttempts,
- Reconnects: dph.Reconnects,
- MaxReconnectInterval: dph.MaxReconnectInterval,
- ConnectTimeout: dph.ConnectTimeout,
- ReplyTimeout: dph.ReplyTimeout,
- TLS: dph.TLS,
- ClientKey: dph.ClientKey,
- ClientCertificate: dph.ClientCertificate,
- CaCertificate: dph.CaCertificate,
- },
- }
-}
-
// RateProfileMdls is used
type RateProfileMdls []*RateProfileMdl
diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go
index 288f06904..92d3620b1 100644
--- a/engine/model_helpers_test.go
+++ b/engine/model_helpers_test.go
@@ -1703,455 +1703,6 @@ func TestModelAsTPChargers3(t *testing.T) {
}
}
-func TestAPItoDispatcherProfile(t *testing.T) {
- tpDPP := &utils.TPDispatcherProfile{
- TPid: "TP1",
- Tenant: "cgrates.org",
- ID: "Dsp",
- FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", "FLTR_ACNT_dan", "FLTR_DST_DE"},
- Strategy: utils.MetaFirst,
- StrategyParams: []any{},
- Weight: 20,
- Hosts: []*utils.TPDispatcherHostProfile{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: []any{"192.168.54.203", "*ratio:2"},
- Blocker: false,
- },
- },
- }
-
- expected := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp",
- FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", "FLTR_ACNT_dan", "FLTR_DST_DE"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{},
- Weight: 20,
- Hosts: DispatcherHostProfiles{
- &DispatcherHostProfile{
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203", utils.MetaRatio: "2"},
- Blocker: false,
- },
- },
- }
- if rcv := APItoDispatcherProfile(tpDPP, "UTC"); !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
-}
-
-func TestDispatcherProfileToAPI(t *testing.T) {
- exp := &utils.TPDispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp",
- FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", "FLTR_ACNT_dan", "FLTR_DST_DE"},
- Strategy: utils.MetaFirst,
- StrategyParams: []any{},
- Weight: 20,
- Hosts: []*utils.TPDispatcherHostProfile{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: []any{"192.168.54.203", "*ratio:2"},
- Blocker: false,
- },
- },
- }
- exp2 := &utils.TPDispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp",
- FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", "FLTR_ACNT_dan", "FLTR_DST_DE"},
- Strategy: utils.MetaFirst,
- StrategyParams: []any{},
- Weight: 20,
- Hosts: []*utils.TPDispatcherHostProfile{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: []any{"*ratio:2", "192.168.54.203"},
- Blocker: false,
- },
- },
- }
-
- dspPrf := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp",
- FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", "FLTR_ACNT_dan", "FLTR_DST_DE"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{},
- Weight: 20,
- Hosts: DispatcherHostProfiles{
- &DispatcherHostProfile{
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203", utils.MetaRatio: "2"},
- Blocker: false,
- },
- },
- }
- if rcv := DispatcherProfileToAPI(dspPrf); !reflect.DeepEqual(exp, rcv) && !reflect.DeepEqual(exp2, rcv) {
- t.Errorf("Expecting : \n %+v \n or \n %+v \n ,\n received: %+v", utils.ToJSON(exp), utils.ToJSON(exp2), utils.ToJSON(rcv))
- }
-}
-
-func TestAPItoModelTPDispatcher(t *testing.T) {
- tpDPP := &utils.TPDispatcherProfile{
- TPid: "TP1",
- Tenant: "cgrates.org",
- ID: "Dsp",
- FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", "FLTR_ACNT_dan", "FLTR_DST_DE"},
- Strategy: utils.MetaFirst,
- StrategyParams: []any{},
- Weight: 20,
- Hosts: []*utils.TPDispatcherHostProfile{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: []any{"192.168.54.203"},
- Blocker: false,
- },
- {
- ID: "C2",
- FilterIDs: []string{},
- Weight: 10,
- Params: []any{"192.168.54.204"},
- Blocker: false,
- },
- },
- }
- expected := DispatcherProfileMdls{
- &DispatcherProfileMdl{
- Tpid: "TP1",
- Tenant: "cgrates.org",
- ID: "Dsp",
- FilterIDs: "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z;FLTR_ACNT_dan;FLTR_DST_DE",
- Strategy: utils.MetaFirst,
- Weight: 20,
- ConnID: "C1",
- ConnWeight: 10,
- ConnBlocker: false,
- ConnParameters: "192.168.54.203",
- },
- &DispatcherProfileMdl{
- Tpid: "TP1",
- Tenant: "cgrates.org",
- ID: "Dsp",
- ConnID: "C2",
- ConnWeight: 10,
- ConnBlocker: false,
- ConnParameters: "192.168.54.204",
- },
- }
- rcv := APItoModelTPDispatcherProfile(tpDPP)
- if !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expecting : %+v, \n received: %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
-}
-
-func TestTPDispatcherHostsCSVHeader(t *testing.T) {
- tps := &DispatcherHostMdls{}
- eOut := []string{"#" + utils.Tenant, utils.ID, utils.Address, utils.Transport, utils.SynchronousCfg, utils.ConnectAttemptsCfg, utils.ReconnectsCfg, utils.MaxReconnectIntervalCfg, utils.ConnectTimeoutCfg, utils.ReplyTimeoutCfg, utils.TLS, utils.ClientKeyCfg, utils.ClientCerificateCfg, utils.CaCertificateCfg}
- if rcv := tps.CSVHeader(); !reflect.DeepEqual(rcv, eOut) {
- t.Errorf("Expecting: %+v,\nReceived: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv))
- }
-}
-
-func TestTPDispatcherHostsAsTPDispatcherHosts(t *testing.T) {
- tps := &DispatcherHostMdls{}
- if rcv, err := tps.AsTPDispatcherHosts(); err != nil {
- t.Error(err)
- } else if rcv != nil {
- t.Errorf("Expecting: nil,\nReceived: %+v", utils.ToJSON(rcv))
- }
-
- tps = &DispatcherHostMdls{
- &DispatcherHostMdl{
- ID: "ID1",
- Tenant: "Tenant1",
- }}
- if rcv, err := tps.AsTPDispatcherHosts(); err != nil {
- t.Error(err)
- } else if rcv != nil {
- t.Errorf("Expecting: nil,\nReceived: %+v", utils.ToJSON(rcv))
- }
-
- tps = &DispatcherHostMdls{
- &DispatcherHostMdl{
- ID: "ID1",
- Tenant: "Tenant1",
- Address: "localhost:6012",
- Transport: "*json",
- ConnectAttempts: 2,
- Reconnects: 5,
- MaxReconnectInterval: "5m",
- ConnectTimeout: "2m",
- ReplyTimeout: "1m",
- TLS: true,
- ClientKey: "client_key",
- ClientCertificate: "client_certificate",
- CaCertificate: "ca_certificate",
- }}
- eOut := []*utils.TPDispatcherHost{
- {
- Tenant: "Tenant1",
- ID: "ID1",
- Conn: &utils.TPDispatcherHostConn{
- Address: "localhost:6012",
- Transport: "*json",
- ConnectAttempts: 2,
- Reconnects: 5,
- MaxReconnectInterval: 5 * time.Minute,
- ConnectTimeout: 2 * time.Minute,
- ReplyTimeout: 1 * time.Minute,
- TLS: true,
- ClientKey: "client_key",
- ClientCertificate: "client_certificate",
- CaCertificate: "ca_certificate",
- },
- },
- }
- if rcv, err := tps.AsTPDispatcherHosts(); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcv, eOut) {
- t.Errorf("Expecting: %+v,\nReceived: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv))
- }
-
- tps = &DispatcherHostMdls{
- &DispatcherHostMdl{
- Address: "Address2",
- ID: "ID2",
- Tenant: "Tenant2",
- Transport: "*gob",
- }}
- eOut = []*utils.TPDispatcherHost{
- {
- Tenant: "Tenant2",
- ID: "ID2",
- Conn: &utils.TPDispatcherHostConn{
- Address: "Address2",
- Transport: "*gob",
- },
- },
- }
- if rcv, err := tps.AsTPDispatcherHosts(); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcv, eOut) {
- t.Errorf("Expecting: %+v,\nReceived: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv))
- }
-
- tps = &DispatcherHostMdls{
- &DispatcherHostMdl{
- Address: "Address3",
- ID: "ID3",
- Tenant: "Tenant3",
- Transport: "*gob",
- },
- }
- eOut = []*utils.TPDispatcherHost{
- {
- Tenant: "Tenant3",
- ID: "ID3",
- Conn: &utils.TPDispatcherHostConn{
- Address: "Address3",
- Transport: "*gob",
- },
- },
- }
- if rcv, err := tps.AsTPDispatcherHosts(); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcv, eOut) {
- t.Errorf("Expecting: %+v,\nReceived: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv))
- }
-
- tps = &DispatcherHostMdls{
- &DispatcherHostMdl{
- Address: "Address4",
- ID: "ID4",
- Tenant: "Tenant4",
- Transport: "*gob",
- },
- }
- eOut = []*utils.TPDispatcherHost{
- {
- Tenant: "Tenant4",
- ID: "ID4",
- Conn: &utils.TPDispatcherHostConn{
- Address: "Address4",
- Transport: "*gob",
- },
- },
- }
- rcv, err := tps.AsTPDispatcherHosts()
- if err != nil {
- t.Error(err)
- }
- sort.Slice(rcv, func(i, j int) bool { return strings.Compare(rcv[i].ID, rcv[j].ID) < 0 })
- if !reflect.DeepEqual(rcv, eOut) {
- t.Errorf("Expecting: %+v,\nReceived: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv))
- }
-}
-
-func TestAPItoModelTPDispatcherHost(t *testing.T) {
- var tpDPH *utils.TPDispatcherHost
- if rcv := APItoModelTPDispatcherHost(tpDPH); rcv != nil {
- t.Errorf("Expecting: nil,\nReceived: %+v", utils.ToJSON(rcv))
- }
-
- tpDPH = &utils.TPDispatcherHost{
- Tenant: "Tenant",
- ID: "ID",
- Conn: &utils.TPDispatcherHostConn{
- Address: "Address1",
- Transport: "*json",
- ConnectAttempts: 3,
- Reconnects: 5,
- MaxReconnectInterval: 5 * time.Minute,
- ConnectTimeout: 1 * time.Minute,
- ReplyTimeout: 2 * time.Minute,
- TLS: true,
- ClientKey: "client_key",
- ClientCertificate: "client_certificate",
- CaCertificate: "ca_certificate",
- },
- }
- eOut := &DispatcherHostMdl{
- Address: "Address1",
- Transport: "*json",
- Tenant: "Tenant",
- ID: "ID",
- ConnectAttempts: 3,
- Reconnects: 5,
- MaxReconnectInterval: "5m0s",
- ConnectTimeout: "1m0s",
- ReplyTimeout: "2m0s",
- TLS: true,
- ClientKey: "client_key",
- ClientCertificate: "client_certificate",
- CaCertificate: "ca_certificate",
- }
- if rcv := APItoModelTPDispatcherHost(tpDPH); !reflect.DeepEqual(eOut, rcv) {
- t.Errorf("Expecting: %+v,\nReceived: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv))
- }
-
-}
-
-func TestAPItoDispatcherHost(t *testing.T) {
- var tpDPH *utils.TPDispatcherHost
- if rcv := APItoDispatcherHost(tpDPH); rcv != nil {
- t.Errorf("Expecting: nil,\nReceived: %+v", utils.ToJSON(rcv))
- }
-
- tpDPH = &utils.TPDispatcherHost{
- Tenant: "Tenant1",
- ID: "ID1",
- Conn: &utils.TPDispatcherHostConn{
- Address: "localhost:6012",
- Transport: "*json",
- ConnectAttempts: 3,
- Reconnects: 5,
- MaxReconnectInterval: 5 * time.Minute,
- ConnectTimeout: 1 * time.Minute,
- ReplyTimeout: 2 * time.Minute,
- TLS: true,
- ClientKey: "client_key",
- ClientCertificate: "client_certificate",
- CaCertificate: "ca_certificate",
- },
- }
-
- eOut := &DispatcherHost{
- Tenant: "Tenant1",
- RemoteHost: &config.RemoteHost{
- ID: "ID1",
- Address: "localhost:6012",
- Transport: "*json",
- Reconnects: 5,
- MaxReconnectInterval: 5 * time.Minute,
- ConnectTimeout: 1 * time.Minute,
- ReplyTimeout: 2 * time.Minute,
- TLS: true,
- ClientKey: "client_key",
- ClientCertificate: "client_certificate",
- CaCertificate: "ca_certificate",
- ConnectAttempts: 3,
- },
- }
- if rcv := APItoDispatcherHost(tpDPH); !reflect.DeepEqual(eOut, rcv) {
- t.Errorf("Expecting: %+v,\nReceived: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv))
- }
-
- tpDPH = &utils.TPDispatcherHost{
- Tenant: "Tenant2",
- ID: "ID2",
- Conn: &utils.TPDispatcherHostConn{
- Address: "Address1",
- Transport: "*json",
- TLS: true,
- },
- }
- eOut = &DispatcherHost{
- Tenant: "Tenant2",
- RemoteHost: &config.RemoteHost{
- ID: "ID2",
- Address: "Address1",
- Transport: "*json",
- TLS: true,
- },
- }
- if rcv := APItoDispatcherHost(tpDPH); !reflect.DeepEqual(eOut, rcv) {
- t.Errorf("Expecting: %+v,\nReceived: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv))
- }
-}
-
-func TestDispatcherHostToAPI(t *testing.T) {
- dph := &DispatcherHost{
- Tenant: "Tenant1",
- RemoteHost: &config.RemoteHost{
- Address: "127.0.0.1:2012",
- Transport: "*json",
- ConnectAttempts: 0,
- Reconnects: 0,
- MaxReconnectInterval: 5 * time.Minute,
- ConnectTimeout: 1 * time.Minute,
- ReplyTimeout: 1 * time.Minute,
- TLS: false,
- ClientKey: "",
- ClientCertificate: "",
- CaCertificate: "",
- },
- }
- eOut := &utils.TPDispatcherHost{
- Tenant: "Tenant1",
- Conn: &utils.TPDispatcherHostConn{
- Address: "127.0.0.1:2012",
- Transport: "*json",
- ConnectAttempts: 0,
- Reconnects: 0,
- MaxReconnectInterval: 5 * time.Minute,
- ConnectTimeout: 1 * time.Minute,
- ReplyTimeout: 1 * time.Minute,
- TLS: false,
- ClientKey: "",
- ClientCertificate: "",
- CaCertificate: "",
- },
- }
- if rcv := DispatcherHostToAPI(dph); !reflect.DeepEqual(eOut, rcv) {
- t.Errorf("Expecting: %+v,\nReceived: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv))
- }
-
-}
-
func TestTPRoutesAsTPRouteProfile(t *testing.T) {
mdl := RouteMdls{
&RouteMdl{
@@ -3392,74 +2943,6 @@ func TestRateProfileMdlsCSVHeader(t *testing.T) {
}
}
-func TestDispatcherProfileToAPICase2(t *testing.T) {
- structTest := &DispatcherProfile{
- FilterIDs: []string{"field1", "field2", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z|2014-07-15T14:35:00Z"},
- StrategyParams: map[string]any{
- "Field1": "Params1",
- },
- Hosts: []*DispatcherHostProfile{
- {
- FilterIDs: []string{"fieldA", "fieldB"},
- Params: map[string]any{},
- },
- },
- }
-
- expStruct := &utils.TPDispatcherProfile{
- FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z|2014-07-15T14:35:00Z", "field1", "field2"},
- StrategyParams: []any{"Params1"},
- Hosts: []*utils.TPDispatcherHostProfile{
- {
- FilterIDs: []string{"fieldA", "fieldB"},
- Params: []any{},
- },
- },
- }
-
- result := DispatcherProfileToAPI(structTest)
- sort.Strings(result.FilterIDs)
- if !reflect.DeepEqual(result, expStruct) {
- t.Errorf("\nExpecting <%+v>>,\n Received <%+v>", utils.ToJSON(expStruct), utils.ToJSON(result))
- }
-}
-
-func TestAPItoDispatcherProfileCase2(t *testing.T) {
- structTest := &utils.TPDispatcherProfile{
- FilterIDs: []string{},
- StrategyParams: []any{"Param1"},
- Hosts: []*utils.TPDispatcherHostProfile{{
- Params: []any{"Param1"},
- }},
- }
- expStruct := &DispatcherProfile{
- FilterIDs: []string{},
- StrategyParams: map[string]any{
- "0": "Param1",
- },
- Hosts: DispatcherHostProfiles{{
- FilterIDs: []string{},
- Params: map[string]any{
- "0": "Param1",
- },
- },
- },
- }
- result := APItoDispatcherProfile(structTest, "")
- if !reflect.DeepEqual(result, expStruct) {
- t.Errorf("\nExpecting <%+v>>,\n Received <%+v>", utils.ToJSON(expStruct), utils.ToJSON(result))
- }
-}
-
-func TestAPItoModelTPDispatcherProfileNil(t *testing.T) {
- var structTest *utils.TPDispatcherProfile = nil
- expected := "null"
- result := APItoModelTPDispatcherProfile(structTest)
- if !reflect.DeepEqual(utils.ToJSON(result), expected) {
- t.Errorf("\nExpecting <%+v>,\n Received <%+v>", expected, utils.ToJSON(result))
- }
-}
-
func TestModelHelpersParamsToString(t *testing.T) {
testInterface := []any{"Param1", "Param2"}
result := paramsToString(testInterface)
@@ -3468,57 +2951,6 @@ func TestModelHelpersParamsToString(t *testing.T) {
}
}
-func TestModelHelpersAsTPDispatcherProfiles(t *testing.T) {
- structTest := DispatcherProfileMdls{
- &DispatcherProfileMdl{
- FilterIDs: "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z|2014-08-29T15:00:00Z",
- StrategyParameters: "Param1",
- },
- }
- expStruct := []*utils.TPDispatcherProfile{{
- FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-29T15:00:00Z|2014-08-29T15:00:00Z"},
- StrategyParams: []any{"Param1"},
- },
- }
- result := structTest.AsTPDispatcherProfiles()
- if !reflect.DeepEqual(result, expStruct) {
- t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ToJSON(expStruct), utils.ToJSON(result))
- }
-}
-
-func TestTPDispatcherProfilesCSVHeader(t *testing.T) {
- structTest := DispatcherProfileMdls{
- &DispatcherProfileMdl{
- Tpid: "TP1",
- Tenant: "cgrates.org",
- ID: "Dsp",
- FilterIDs: "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z;FLTR_ACNT_dan;FLTR_DST_DE",
- Strategy: utils.MetaFirst,
- Weight: 20,
- ConnID: "C1",
- ConnWeight: 10,
- ConnBlocker: false,
- ConnParameters: "192.168.54.203",
- },
- &DispatcherProfileMdl{
- Tpid: "TP1",
- Tenant: "cgrates.org",
- ID: "Dsp",
- ConnID: "C2",
- ConnWeight: 10,
- ConnBlocker: false,
- ConnParameters: "192.168.54.204",
- },
- }
- expected := []string{"#" + utils.Tenant, utils.ID, utils.FilterIDs, utils.Weight,
- utils.Strategy, utils.StrategyParameters, utils.ConnID, utils.ConnFilterIDs,
- utils.ConnWeight, utils.ConnBlocker, utils.ConnParameters}
- result := structTest.CSVHeader()
- if !reflect.DeepEqual(result, expected) {
- t.Errorf("\nExpecting <%+v>,\n Received <%+v>", expected, result)
- }
-}
-
func TestChargerProfileToAPILastCase(t *testing.T) {
testStruct := &ChargerProfile{
Tenant: "cgrates.org",
@@ -3649,20 +3081,6 @@ func TestRateProfileMdlsAsTPRateProfileCase3(t *testing.T) {
}
-func TestAPItoModelTPDispatcherProfileCase2(t *testing.T) {
- structTest := &utils.TPDispatcherProfile{
- FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-29T15:00:00Z|2014-07-30T15:00:00Z"},
- }
- expStruct := DispatcherProfileMdls{{
- FilterIDs: "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z|2014-07-30T15:00:00Z",
- },
- }
- result := APItoModelTPDispatcherProfile(structTest)
- if !reflect.DeepEqual(result, expStruct) {
- t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ToJSON(expStruct), utils.ToJSON(result))
- }
-}
-
func ModelHelpersTestStatMdlsCSVHeader(t *testing.T) {
testStruct := ResourceMdls{
{
@@ -5449,171 +4867,6 @@ func TestAPItoModelTPActionProfileActionProfileMdl(t *testing.T) {
}
}
-func TestAsTPDispatcherHostsNilTransport(t *testing.T) {
-
- tps := &DispatcherHostMdls{
- &DispatcherHostMdl{
- ID: "ID1",
- Tenant: "Tenant1",
- Address: "localhost:6012",
- ConnectAttempts: 2,
- Reconnects: 5,
- MaxReconnectInterval: "5m",
- ConnectTimeout: "2m",
- ReplyTimeout: "1m",
- TLS: true,
- ClientKey: "client_key",
- ClientCertificate: "client_certificate",
- CaCertificate: "ca_certificate",
- }}
-
- eOut := []*utils.TPDispatcherHost{
- {
- Tenant: "Tenant1",
- ID: "ID1",
- Conn: &utils.TPDispatcherHostConn{
- Address: "localhost:6012",
- Transport: "*json",
- ConnectAttempts: 2,
- Reconnects: 5,
- MaxReconnectInterval: 5 * time.Minute,
- ConnectTimeout: 2 * time.Minute,
- ReplyTimeout: 1 * time.Minute,
- TLS: true,
- ClientKey: "client_key",
- ClientCertificate: "client_certificate",
- CaCertificate: "ca_certificate",
- },
- },
- }
- if rcv, err := tps.AsTPDispatcherHosts(); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcv, eOut) {
- t.Errorf("Expecting: %+v,\nReceived: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv))
- }
-
-}
-
-func TestAsTPDispatcherHostsMaxReconnectIntervalErr(t *testing.T) {
-
- tps := &DispatcherHostMdls{
- &DispatcherHostMdl{
- ID: "ID1",
- Tenant: "Tenant1",
- Address: "localhost:6012",
- Transport: utils.MetaJSON,
- ConnectAttempts: 2,
- Reconnects: 5,
- MaxReconnectInterval: "wrong input",
- ConnectTimeout: "2m",
- ReplyTimeout: "1m",
- TLS: true,
- ClientKey: "client_key",
- ClientCertificate: "client_certificate",
- CaCertificate: "ca_certificate",
- }}
-
- expErr := `time: invalid duration "wrong input"`
- if _, err := tps.AsTPDispatcherHosts(); err == nil || err.Error() != expErr {
- t.Errorf("expecting: \n%+v\n, received: \n%+v", expErr, err)
- }
-
-}
-
-func TestAsTPDispatcherHostsConnectTimeoutErr(t *testing.T) {
-
- tps := &DispatcherHostMdls{
- &DispatcherHostMdl{
- ID: "ID1",
- Tenant: "Tenant1",
- Address: "localhost:6012",
- Transport: utils.MetaJSON,
- ConnectAttempts: 2,
- Reconnects: 5,
- MaxReconnectInterval: "5m",
- ConnectTimeout: "wrong input",
- ReplyTimeout: "1m",
- TLS: true,
- ClientKey: "client_key",
- ClientCertificate: "client_certificate",
- CaCertificate: "ca_certificate",
- }}
-
- expErr := `time: invalid duration "wrong input"`
- if _, err := tps.AsTPDispatcherHosts(); err == nil || err.Error() != expErr {
- t.Errorf("expecting: \n%+v\n, received: \n%+v", expErr, err)
- }
-
-}
-
-func TestAsTPDispatcherHostsReplyTimeoutErr(t *testing.T) {
-
- tps := &DispatcherHostMdls{
- &DispatcherHostMdl{
- ID: "ID1",
- Tenant: "Tenant1",
- Address: "localhost:6012",
- Transport: utils.MetaJSON,
- ConnectAttempts: 2,
- Reconnects: 5,
- MaxReconnectInterval: "5m",
- ConnectTimeout: "2m",
- ReplyTimeout: "wrong input",
- TLS: true,
- ClientKey: "client_key",
- ClientCertificate: "client_certificate",
- CaCertificate: "ca_certificate",
- }}
-
- expErr := `time: invalid duration "wrong input"`
- if _, err := tps.AsTPDispatcherHosts(); err == nil || err.Error() != expErr {
- t.Errorf("expecting: \n%+v\n, received: \n%+v", expErr, err)
- }
-
-}
-
-func TestAPItoDispatcherProfileNoParams(t *testing.T) {
- tpDPP := &utils.TPDispatcherProfile{
- TPid: "TP1",
- Tenant: "cgrates.org",
- ID: "Dsp",
- FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", "FLTR_ACNT_dan", "FLTR_DST_DE"},
- Strategy: utils.MetaFirst,
- StrategyParams: []any{},
- Weight: 20,
- Hosts: []*utils.TPDispatcherHostProfile{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: []any{""},
- Blocker: false,
- },
- },
- }
-
- expected := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp",
- FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", "FLTR_ACNT_dan", "FLTR_DST_DE"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{},
- Weight: 20,
- Hosts: DispatcherHostProfiles{
- &DispatcherHostProfile{
- ID: "C1",
- FilterIDs: []string{},
- Params: make(map[string]any),
- Weight: 10,
- Blocker: false,
- },
- },
- }
- if rcv := APItoDispatcherProfile(tpDPP, "UTC"); !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expecting : \n%+v\n, received: \n%+v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
-}
-
func TestAPItoChargerProfileNewDynamicWeightsFromStringErr(t *testing.T) {
tpCPP := &utils.TPChargerProfile{
TPid: "TP1",
@@ -6045,68 +5298,3 @@ func TestCsvDumpForThresholdModels(t *testing.T) {
}
}
-
-func TestCsvDumpForDispatcherModels(t *testing.T) {
- tpDispPrf := &utils.TPDispatcherProfile{
- TPid: "TP1",
- Tenant: "cgrates.org",
- ID: "Dsp",
- FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", "FLTR_ACNT_dan", "FLTR_DST_DE"},
- Strategy: utils.MetaFirst,
- StrategyParams: []any{},
- Weight: 20,
- Hosts: []*utils.TPDispatcherHostProfile{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: []any{"192.168.54.203"},
- Blocker: false,
- },
- {
- ID: "C2",
- FilterIDs: []string{},
- Weight: 10,
- Params: []any{"192.168.54.204"},
- Blocker: false,
- },
- },
- }
- expected := DispatcherProfileMdls{
- &DispatcherProfileMdl{
- Tpid: "TP1",
- Tenant: "cgrates.org",
- ID: "Dsp",
- FilterIDs: "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z;FLTR_ACNT_dan;FLTR_DST_DE",
- Strategy: utils.MetaFirst,
- Weight: 20,
- ConnID: "C1",
- ConnWeight: 10,
- ConnBlocker: false,
- ConnParameters: "192.168.54.203",
- },
- &DispatcherProfileMdl{
- Tpid: "TP1",
- Tenant: "cgrates.org",
- ID: "Dsp",
- ConnID: "C2",
- ConnWeight: 10,
- ConnBlocker: false,
- ConnParameters: "192.168.54.204",
- },
- }
- rcv := APItoModelTPDispatcherProfile(tpDispPrf)
- if !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expecting : %+v,\n received: %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
- expRecord := []string{"cgrates.org", "Dsp", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z;FLTR_ACNT_dan;FLTR_DST_DE", "20", "*first", "", "C1", "", "10", "false", "192.168.54.203"}
- for i, model := range rcv {
- if i == 1 {
- expRecord = []string{"cgrates.org", "Dsp", "", "0", "", "", "C2", "", "10", "false", "192.168.54.204"}
- }
- if csvRecordRcv, _ := CsvDump(model); !reflect.DeepEqual(expRecord, csvRecordRcv) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expRecord), utils.ToJSON(csvRecordRcv))
- }
- }
-
-}
diff --git a/engine/models.go b/engine/models.go
index da1062bdd..646253f7a 100644
--- a/engine/models.go
+++ b/engine/models.go
@@ -295,50 +295,6 @@ func (ChargerMdl) TableName() string {
return utils.TBLTPChargers
}
-type DispatcherProfileMdl struct {
- PK uint `gorm:"primary_key"`
- Tpid string //
- Tenant string `index:"0" re:".*"`
- ID string `index:"1" re:".*"`
- FilterIDs string `index:"2" re:".*"`
- Weight float64 `index:"3" re:".*"`
- Strategy string `index:"4" re:".*"`
- StrategyParameters string `index:"5" re:".*"`
- ConnID string `index:"6" re:".*"`
- ConnFilterIDs string `index:"7" re:".*"`
- ConnWeight float64 `index:"8" re:".*"`
- ConnBlocker bool `index:"9" re:".*"`
- ConnParameters string `index:"10" re:".*"`
- CreatedAt time.Time
-}
-
-func (DispatcherProfileMdl) TableName() string {
- return utils.TBLTPDispatchers
-}
-
-type DispatcherHostMdl struct {
- PK uint `gorm:"primary_key"`
- Tpid string //
- Tenant string `index:"0" re:".*"`
- ID string `index:"1" re:".*"`
- Address string `index:"2" re:".*"`
- Transport string `index:"3" re:".*"`
- ConnectAttempts int `index:"4" re:".*"`
- Reconnects int `index:"5" re:".*"`
- MaxReconnectInterval string `index:"6" re:".*"`
- ConnectTimeout string `index:"7" re:".*"`
- ReplyTimeout string `index:"8" re:".*"`
- TLS bool `index:"9" re:".*"`
- ClientKey string `index:"10" re:".*"`
- ClientCertificate string `index:"11" re:".*"`
- CaCertificate string `index:"12" re:".*"`
- CreatedAt time.Time
-}
-
-func (DispatcherHostMdl) TableName() string {
- return utils.TBLTPDispatcherHosts
-}
-
type RateProfileMdl struct {
PK uint `gorm:"primary_key"`
Tpid string
diff --git a/engine/models_test.go b/engine/models_test.go
index fcdaa1709..f70a6137b 100644
--- a/engine/models_test.go
+++ b/engine/models_test.go
@@ -289,52 +289,7 @@ func TestChargerMdlTableName(t *testing.T) {
t.Errorf("Expected <%v>, Received <%v>", utils.TBLTPChargers, rcv)
}
}
-func TestDispatcherProfileMdlTableName(t *testing.T) {
- model := DispatcherProfileMdl{
- PK: 2,
- Tpid: "tpid",
- Tenant: "tenant",
- ID: "id",
- FilterIDs: "fltrId",
- Weight: 98,
- Strategy: "testStrategy",
- StrategyParameters: "testStratParams",
- ConnID: "testConnId",
- ConnFilterIDs: "testConnFltrIds",
- ConnWeight: 76,
- ConnBlocker: true,
- ConnParameters: "testConnParams",
- CreatedAt: time.Now(),
- }
- rcv := model.TableName()
- if !reflect.DeepEqual(rcv, utils.TBLTPDispatchers) {
- t.Errorf("Expected <%v>, Received <%v>", utils.TBLTPDispatchers, rcv)
- }
-}
-func TestDispatcherHostMdlTableName(t *testing.T) {
- model := DispatcherHostMdl{
- PK: 2,
- Tpid: "tpid",
- Tenant: "tenant",
- ID: "id",
- Address: "testAddress",
- Transport: "testTransport",
- ConnectAttempts: 3,
- Reconnects: 2,
- MaxReconnectInterval: "testMaxReconnInterval",
- ConnectTimeout: "testConnTimeout",
- ReplyTimeout: "testReplyTimeout",
- TLS: true,
- ClientKey: "testClientKey",
- ClientCertificate: "testClientCertificate",
- CaCertificate: "testCaCertificate",
- CreatedAt: time.Now(),
- }
- rcv := model.TableName()
- if !reflect.DeepEqual(rcv, utils.TBLTPDispatcherHosts) {
- t.Errorf("Expected <%v>, Received <%v>", utils.TBLTPDispatcherHosts, rcv)
- }
-}
+
func TestRateProfileMdlTableName(t *testing.T) {
model := RateProfileMdl{
PK: 2,
diff --git a/engine/storage_csv.go b/engine/storage_csv.go
index 29aaceccf..f73aa9339 100644
--- a/engine/storage_csv.go
+++ b/engine/storage_csv.go
@@ -44,44 +44,40 @@ type CSVStorage struct {
sep rune
generator func() csvReaderCloser
// file names
- resProfilesFn []string
- statsFn []string
- trendsFn []string
- rankingsFn []string
- thresholdsFn []string
- filterFn []string
- routeProfilesFn []string
- attributeProfilesFn []string
- chargerProfilesFn []string
- dispatcherProfilesFn []string
- dispatcherHostsFn []string
- rateProfilesFn []string
- actionProfilesFn []string
- accountsFn []string
+ resProfilesFn []string
+ statsFn []string
+ trendsFn []string
+ rankingsFn []string
+ thresholdsFn []string
+ filterFn []string
+ routeProfilesFn []string
+ attributeProfilesFn []string
+ chargerProfilesFn []string
+ rateProfilesFn []string
+ actionProfilesFn []string
+ accountsFn []string
}
// NewCSVStorage creates a CSV storege that takes the data from the paths specified
func NewCSVStorage(sep rune,
resProfilesFn, statsFn, rankingsFn, trendsFn, thresholdsFn, filterFn, routeProfilesFn,
- attributeProfilesFn, chargerProfilesFn, dispatcherProfilesFn, dispatcherHostsFn,
+ attributeProfilesFn, chargerProfilesFn,
rateProfilesFn, actionProfilesFn, accountsFn []string) *CSVStorage {
return &CSVStorage{
- sep: sep,
- generator: NewCsvFile,
- resProfilesFn: resProfilesFn,
- statsFn: statsFn,
- rankingsFn: rankingsFn,
- trendsFn: trendsFn,
- thresholdsFn: thresholdsFn,
- filterFn: filterFn,
- routeProfilesFn: routeProfilesFn,
- attributeProfilesFn: attributeProfilesFn,
- chargerProfilesFn: chargerProfilesFn,
- dispatcherProfilesFn: dispatcherProfilesFn,
- dispatcherHostsFn: dispatcherHostsFn,
- rateProfilesFn: rateProfilesFn,
- actionProfilesFn: actionProfilesFn,
- accountsFn: accountsFn,
+ sep: sep,
+ generator: NewCsvFile,
+ resProfilesFn: resProfilesFn,
+ statsFn: statsFn,
+ rankingsFn: rankingsFn,
+ trendsFn: trendsFn,
+ thresholdsFn: thresholdsFn,
+ filterFn: filterFn,
+ routeProfilesFn: routeProfilesFn,
+ attributeProfilesFn: attributeProfilesFn,
+ chargerProfilesFn: chargerProfilesFn,
+ rateProfilesFn: rateProfilesFn,
+ actionProfilesFn: actionProfilesFn,
+ accountsFn: accountsFn,
}
}
@@ -100,8 +96,6 @@ func NewFileCSVStorage(sep rune, dataPath string) (*CSVStorage, error) {
routesPaths := appendName(allFoldersPath, utils.RoutesCsv)
attributesPaths := appendName(allFoldersPath, utils.AttributesCsv)
chargersPaths := appendName(allFoldersPath, utils.ChargersCsv)
- dispatcherprofilesPaths := appendName(allFoldersPath, utils.DispatcherProfilesCsv)
- dispatcherhostsPaths := appendName(allFoldersPath, utils.DispatcherHostsCsv)
rateProfilesFn := appendName(allFoldersPath, utils.RatesCsv)
actionProfilesFn := appendName(allFoldersPath, utils.ActionsCsv)
accountsFn := appendName(allFoldersPath, utils.AccountsCsv)
@@ -115,8 +109,6 @@ func NewFileCSVStorage(sep rune, dataPath string) (*CSVStorage, error) {
routesPaths,
attributesPaths,
chargersPaths,
- dispatcherprofilesPaths,
- dispatcherhostsPaths,
rateProfilesFn,
actionProfilesFn,
accountsFn,
@@ -131,7 +123,7 @@ func NewStringCSVStorage(sep rune,
c := NewCSVStorage(sep,
[]string{resProfilesFn}, []string{statsFn}, []string{rankingsFn}, []string{trendsFn}, []string{thresholdsFn}, []string{filterFn},
[]string{routeProfilesFn}, []string{attributeProfilesFn}, []string{chargerProfilesFn},
- []string{dispatcherProfilesFn}, []string{dispatcherHostsFn}, []string{rateProfilesFn},
+ []string{rateProfilesFn},
[]string{actionProfilesFn}, []string{accountsFn})
c.generator = NewCsvString
return c
@@ -163,8 +155,6 @@ func NewGoogleCSVStorage(sep rune, spreadsheetID string) (*CSVStorage, error) {
getIfExist(utils.Routes),
getIfExist(utils.Attributes),
getIfExist(utils.Chargers),
- getIfExist(utils.DispatcherProfiles),
- getIfExist(utils.DispatcherHosts),
getIfExist(utils.RateProfiles),
getIfExist(utils.ActionProfiles),
getIfExist(utils.AccountsString))
@@ -188,8 +178,6 @@ func NewURLCSVStorage(sep rune, dataPath string) *CSVStorage {
var routesPaths []string
var attributesPaths []string
var chargersPaths []string
- var dispatcherprofilesPaths []string
- var dispatcherhostsPaths []string
var rateProfilesPaths []string
var actionProfilesPaths []string
var accountsPaths []string
@@ -205,8 +193,6 @@ func NewURLCSVStorage(sep rune, dataPath string) *CSVStorage {
routesPaths = append(routesPaths, joinURL(baseURL, utils.RoutesCsv))
attributesPaths = append(attributesPaths, joinURL(baseURL, utils.AttributesCsv))
chargersPaths = append(chargersPaths, joinURL(baseURL, utils.ChargersCsv))
- dispatcherprofilesPaths = append(dispatcherprofilesPaths, joinURL(baseURL, utils.DispatcherProfilesCsv))
- dispatcherhostsPaths = append(dispatcherhostsPaths, joinURL(baseURL, utils.DispatcherHostsCsv))
rateProfilesPaths = append(rateProfilesPaths, joinURL(baseURL, utils.RatesCsv))
actionProfilesPaths = append(actionProfilesPaths, joinURL(baseURL, utils.ActionsCsv))
accountsPaths = append(accountsPaths, joinURL(baseURL, utils.AccountsCsv))
@@ -231,10 +217,6 @@ func NewURLCSVStorage(sep rune, dataPath string) *CSVStorage {
attributesPaths = append(attributesPaths, baseURL)
case strings.HasSuffix(baseURL, utils.ChargersCsv):
chargersPaths = append(chargersPaths, baseURL)
- case strings.HasSuffix(baseURL, utils.DispatcherProfilesCsv):
- dispatcherprofilesPaths = append(dispatcherprofilesPaths, baseURL)
- case strings.HasSuffix(baseURL, utils.DispatcherHostsCsv):
- dispatcherhostsPaths = append(dispatcherhostsPaths, baseURL)
case strings.HasSuffix(baseURL, utils.RatesCsv):
rateProfilesPaths = append(rateProfilesPaths, baseURL)
case strings.HasSuffix(baseURL, utils.ActionsCsv):
@@ -255,8 +237,6 @@ func NewURLCSVStorage(sep rune, dataPath string) *CSVStorage {
routesPaths,
attributesPaths,
chargersPaths,
- dispatcherprofilesPaths,
- dispatcherhostsPaths,
rateProfilesPaths,
actionProfilesPaths,
accountsPaths,
@@ -436,34 +416,6 @@ func (csvs *CSVStorage) GetTPChargers(tpid, tenant, id string) ([]*utils.TPCharg
return tpCPPs.AsTPChargers(), nil
}
-func (csvs *CSVStorage) GetTPDispatcherProfiles(tpid, tenant, id string) ([]*utils.TPDispatcherProfile, error) {
- var tpDPPs DispatcherProfileMdls
- if err := csvs.proccesData(DispatcherProfileMdl{}, csvs.dispatcherProfilesFn, func(tp any) {
- dpp := tp.(DispatcherProfileMdl)
- dpp.Tpid = tpid
- tpDPPs = append(tpDPPs, &dpp)
- }); err != nil {
- return nil, err
- }
- return tpDPPs.AsTPDispatcherProfiles(), nil
-}
-
-func (csvs *CSVStorage) GetTPDispatcherHosts(tpid, tenant, id string) ([]*utils.TPDispatcherHost, error) {
- var tpDDHs DispatcherHostMdls
- if err := csvs.proccesData(DispatcherHostMdl{}, csvs.dispatcherHostsFn, func(tp any) {
- dpp := tp.(DispatcherHostMdl)
- dpp.Tpid = tpid
- tpDDHs = append(tpDDHs, &dpp)
- }); err != nil {
- return nil, err
- }
- result, err := tpDDHs.AsTPDispatcherHosts()
- if err != nil {
- return nil, err
- }
- return result, nil
-}
-
func (csvs *CSVStorage) GetTPRateProfiles(tpid, tenant, id string) ([]*utils.TPRateProfile, error) {
var tpDPPs RateProfileMdls
if err := csvs.proccesData(RateProfileMdl{}, csvs.rateProfilesFn, func(tp any) {
diff --git a/engine/storage_interface.go b/engine/storage_interface.go
index eb247e6d4..17860a890 100644
--- a/engine/storage_interface.go
+++ b/engine/storage_interface.go
@@ -88,15 +88,9 @@ type DataDB interface {
GetChargerProfileDrv(*context.Context, string, string) (*ChargerProfile, error)
SetChargerProfileDrv(*context.Context, *ChargerProfile) error
RemoveChargerProfileDrv(*context.Context, string, string) error
- GetDispatcherProfileDrv(*context.Context, string, string) (*DispatcherProfile, error)
- SetDispatcherProfileDrv(*context.Context, *DispatcherProfile) error
- RemoveDispatcherProfileDrv(*context.Context, string, string) error
GetItemLoadIDsDrv(ctx *context.Context, itemIDPrefix string) (loadIDs map[string]int64, err error)
SetLoadIDsDrv(ctx *context.Context, loadIDs map[string]int64) error
RemoveLoadIDsDrv() error
- GetDispatcherHostDrv(*context.Context, string, string) (*DispatcherHost, error)
- SetDispatcherHostDrv(*context.Context, *DispatcherHost) error
- RemoveDispatcherHostDrv(*context.Context, string, string) error
GetRateProfileDrv(*context.Context, string, string) (*utils.RateProfile, error)
GetRateProfileRatesDrv(*context.Context, string, string, string, bool) ([]string, []*utils.Rate, error)
SetRateProfileDrv(*context.Context, *utils.RateProfile, bool) error
@@ -145,8 +139,6 @@ type LoadReader interface {
GetTPRoutes(string, string, string) ([]*utils.TPRouteProfile, error)
GetTPAttributes(string, string, string) ([]*utils.TPAttributeProfile, error)
GetTPChargers(string, string, string) ([]*utils.TPChargerProfile, error)
- GetTPDispatcherProfiles(string, string, string) ([]*utils.TPDispatcherProfile, error)
- GetTPDispatcherHosts(string, string, string) ([]*utils.TPDispatcherHost, error)
GetTPRateProfiles(string, string, string) ([]*utils.TPRateProfile, error)
GetTPActionProfiles(string, string, string) ([]*utils.TPActionProfile, error)
GetTPAccounts(string, string, string) ([]*utils.TPAccount, error)
@@ -161,8 +153,6 @@ type LoadWriter interface {
SetTPRoutes([]*utils.TPRouteProfile) error
SetTPAttributes([]*utils.TPAttributeProfile) error
SetTPChargers([]*utils.TPChargerProfile) error
- SetTPDispatcherProfiles([]*utils.TPDispatcherProfile) error
- SetTPDispatcherHosts([]*utils.TPDispatcherHost) error
SetTPRateProfiles([]*utils.TPRateProfile) error
SetTPActionProfiles([]*utils.TPActionProfile) error
SetTPAccounts([]*utils.TPAccount) error
diff --git a/engine/storage_internal_datadb.go b/engine/storage_internal_datadb.go
index 51dca3473..5657556d0 100644
--- a/engine/storage_internal_datadb.go
+++ b/engine/storage_internal_datadb.go
@@ -184,7 +184,7 @@ func (iDB *InternalDB) HasDataDrv(_ *context.Context, category, subject, tenant
case utils.ResourcesPrefix, utils.ResourceProfilesPrefix, utils.StatQueuePrefix,
utils.StatQueueProfilePrefix, utils.ThresholdPrefix, utils.ThresholdProfilePrefix,
utils.FilterPrefix, utils.RouteProfilePrefix, utils.AttributeProfilePrefix,
- utils.ChargerProfilePrefix, utils.DispatcherProfilePrefix, utils.DispatcherHostPrefix:
+ utils.ChargerProfilePrefix:
return iDB.db.HasItem(utils.CachePrefixToInstance[category], utils.ConcatenatedKey(tenant, subject)), nil
}
return false, errors.New("Unsupported HasData category")
@@ -486,26 +486,6 @@ func (iDB *InternalDB) RemoveChargerProfileDrv(_ *context.Context, tenant, id st
return
}
-func (iDB *InternalDB) GetDispatcherProfileDrv(_ *context.Context, tenant, id string) (dpp *DispatcherProfile, err error) {
- x, ok := iDB.db.Get(utils.CacheDispatcherProfiles, utils.ConcatenatedKey(tenant, id))
- if !ok || x == nil {
- return nil, utils.ErrDSPProfileNotFound
- }
- return x.(*DispatcherProfile), nil
-}
-
-func (iDB *InternalDB) SetDispatcherProfileDrv(_ *context.Context, dpp *DispatcherProfile) (err error) {
- iDB.db.Set(utils.CacheDispatcherProfiles, dpp.TenantID(), dpp, nil,
- true, utils.NonTransactional)
- return
-}
-
-func (iDB *InternalDB) RemoveDispatcherProfileDrv(_ *context.Context, tenant, id string) (err error) {
- iDB.db.Remove(utils.CacheDispatcherProfiles, utils.ConcatenatedKey(tenant, id),
- true, utils.NonTransactional)
- return
-}
-
func (iDB *InternalDB) GetItemLoadIDsDrv(_ *context.Context, itemIDPrefix string) (loadIDs map[string]int64, err error) {
x, ok := iDB.db.Get(utils.CacheLoadIDs, utils.LoadIDs)
if !ok || x == nil {
@@ -524,26 +504,6 @@ func (iDB *InternalDB) SetLoadIDsDrv(_ *context.Context, loadIDs map[string]int6
return
}
-func (iDB *InternalDB) GetDispatcherHostDrv(_ *context.Context, tenant, id string) (dpp *DispatcherHost, err error) {
- x, ok := iDB.db.Get(utils.CacheDispatcherHosts, utils.ConcatenatedKey(tenant, id))
- if !ok || x == nil {
- return nil, utils.ErrDSPHostNotFound
- }
- return x.(*DispatcherHost), nil
-}
-
-func (iDB *InternalDB) SetDispatcherHostDrv(_ *context.Context, dpp *DispatcherHost) (err error) {
- iDB.db.Set(utils.CacheDispatcherHosts, dpp.TenantID(), dpp, nil,
- true, utils.NonTransactional)
- return
-}
-
-func (iDB *InternalDB) RemoveDispatcherHostDrv(_ *context.Context, tenant, id string) (err error) {
- iDB.db.Remove(utils.CacheDispatcherHosts, utils.ConcatenatedKey(tenant, id),
- true, utils.NonTransactional)
- return
-}
-
func (iDB *InternalDB) GetRateProfileDrv(_ *context.Context, tenant, id string) (rpp *utils.RateProfile, err error) {
x, ok := iDB.db.Get(utils.CacheRateProfiles, utils.ConcatenatedKey(tenant, id))
if !ok || x == nil {
diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go
index d9bba8198..baff8fb7a 100644
--- a/engine/storage_mongo_datadb.go
+++ b/engine/storage_mongo_datadb.go
@@ -72,8 +72,6 @@ const (
ColAttr = "attribute_profiles"
ColCDRs = "cdrs"
ColCpp = "charger_profiles"
- ColDpp = "dispatcher_profiles"
- ColDph = "dispatcher_hosts"
ColRpp = "rate_profiles"
ColApp = "action_profiles"
ColLID = "load_ids"
@@ -301,7 +299,7 @@ func (ms *MongoStorage) ensureIndexesForCol(col string) error { // exported for
switch col {
case ColAct, ColApl, ColAAp, ColAtr, ColRpl, ColDst, ColRds, ColLht, ColIndx:
err = ms.ensureIndex(col, true, "key")
- case ColRsP, ColRes, ColSqs, ColRgp, ColTrs, ColTrd, ColSqp, ColTps, ColThs, ColRts, ColAttr, ColFlt, ColCpp, ColDpp, ColDph, ColRpp, ColApp, ColAnp:
+ case ColRsP, ColRes, ColSqs, ColRgp, ColTrs, ColTrd, ColSqp, ColTps, ColThs, ColRts, ColAttr, ColFlt, ColCpp, ColRpp, ColApp, ColAnp:
err = ms.ensureIndex(col, true, "tenant", "id")
case ColRpf, ColShg, ColAcc:
err = ms.ensureIndex(col, true, "id")
@@ -326,7 +324,7 @@ func (ms *MongoStorage) EnsureIndexes(cols ...string) error {
cols = []string{
ColAct, ColApl, ColAAp, ColAtr, ColRpl, ColDst, ColRds, ColLht, ColIndx,
ColRsP, ColRes, ColSqs, ColSqp, ColTps, ColThs, ColRts, ColAttr, ColFlt,
- ColCpp, ColDpp, ColRpp, ColApp, ColRpf, ColShg, ColAcc, ColAnp, ColTrd, ColTrs,
+ ColCpp, ColRpp, ColApp, ColRpf, ColShg, ColAcc, ColAnp, ColTrd, ColTrs,
}
} else {
cols = []string{utils.CDRsTBL}
@@ -486,16 +484,12 @@ func (ms *MongoStorage) GetKeysForPrefix(ctx *context.Context, prefix string) (k
keys, qryErr = ms.getAllKeysMatchingTenantID(sctx, ColAttr, utils.AttributeProfilePrefix, tntID)
case utils.ChargerProfilePrefix:
keys, qryErr = ms.getAllKeysMatchingTenantID(sctx, ColCpp, utils.ChargerProfilePrefix, tntID)
- case utils.DispatcherProfilePrefix:
- keys, qryErr = ms.getAllKeysMatchingTenantID(sctx, ColDpp, utils.DispatcherProfilePrefix, tntID)
case utils.RateProfilePrefix:
keys, qryErr = ms.getAllKeysMatchingTenantID(sctx, ColRpp, utils.RateProfilePrefix, tntID)
case utils.ActionProfilePrefix:
keys, qryErr = ms.getAllKeysMatchingTenantID(sctx, ColApp, utils.ActionProfilePrefix, tntID)
case utils.AccountPrefix:
keys, qryErr = ms.getAllKeysMatchingTenantID(sctx, ColAnp, utils.AccountPrefix, tntID)
- case utils.DispatcherHostPrefix:
- keys, qryErr = ms.getAllKeysMatchingTenantID(sctx, ColDph, utils.DispatcherHostPrefix, tntID)
case utils.AttributeFilterIndexes:
keys, qryErr = ms.getAllIndexKeys(sctx, utils.AttributeFilterIndexes)
case utils.ResourceFilterIndexes:
@@ -508,8 +502,6 @@ func (ms *MongoStorage) GetKeysForPrefix(ctx *context.Context, prefix string) (k
keys, qryErr = ms.getAllIndexKeys(sctx, utils.RouteFilterIndexes)
case utils.ChargerFilterIndexes:
keys, qryErr = ms.getAllIndexKeys(sctx, utils.ChargerFilterIndexes)
- case utils.DispatcherFilterIndexes:
- keys, qryErr = ms.getAllIndexKeys(sctx, utils.DispatcherFilterIndexes)
case utils.ActionPlanIndexes:
keys, qryErr = ms.getAllIndexKeys(sctx, utils.ActionPlanIndexes)
case utils.ActionProfilesFilterIndexPrfx:
@@ -558,10 +550,6 @@ func (ms *MongoStorage) HasDataDrv(ctx *context.Context, category, subject, tena
count, err = ms.getCol(ColTrd).CountDocuments(sctx, bson.M{"tenant": tenant, "id": subject})
case utils.TrendProfilePrefix:
count, err = ms.getCol(ColTrs).CountDocuments(sctx, bson.M{"tenant": tenant, "id": subject})
- case utils.DispatcherProfilePrefix:
- count, err = ms.getCol(ColDpp).CountDocuments(sctx, bson.M{"tenant": tenant, "id": subject})
- case utils.DispatcherHostPrefix:
- count, err = ms.getCol(ColDph).CountDocuments(sctx, bson.M{"tenant": tenant, "id": subject})
case utils.RateProfilePrefix:
count, err = ms.getCol(ColRpp).CountDocuments(sctx, bson.M{"tenant": tenant, "id": subject})
case utils.ActionProfilePrefix:
@@ -1164,72 +1152,6 @@ func (ms *MongoStorage) RemoveChargerProfileDrv(ctx *context.Context, tenant, id
})
}
-func (ms *MongoStorage) GetDispatcherProfileDrv(ctx *context.Context, tenant, id string) (*DispatcherProfile, error) {
- dspProfile := new(DispatcherProfile)
- err := ms.query(ctx, func(sctx mongo.SessionContext) error {
- sr := ms.getCol(ColDpp).FindOne(sctx, bson.M{"tenant": tenant, "id": id})
- decodeErr := sr.Decode(dspProfile)
- if errors.Is(decodeErr, mongo.ErrNoDocuments) {
- return utils.ErrDSPProfileNotFound
- }
- return decodeErr
- })
- return dspProfile, err
-}
-
-func (ms *MongoStorage) SetDispatcherProfileDrv(ctx *context.Context, r *DispatcherProfile) error {
- return ms.query(ctx, func(sctx mongo.SessionContext) error {
- _, err := ms.getCol(ColDpp).UpdateOne(sctx, bson.M{"tenant": r.Tenant, "id": r.ID},
- bson.M{"$set": r},
- options.Update().SetUpsert(true),
- )
- return err
- })
-}
-
-func (ms *MongoStorage) RemoveDispatcherProfileDrv(ctx *context.Context, tenant, id string) error {
- return ms.query(ctx, func(sctx mongo.SessionContext) error {
- dr, err := ms.getCol(ColDpp).DeleteOne(sctx, bson.M{"tenant": tenant, "id": id})
- if dr.DeletedCount == 0 {
- return utils.ErrNotFound
- }
- return err
- })
-}
-
-func (ms *MongoStorage) GetDispatcherHostDrv(ctx *context.Context, tenant, id string) (*DispatcherHost, error) {
- dspHost := new(DispatcherHost)
- err := ms.query(ctx, func(sctx mongo.SessionContext) error {
- sr := ms.getCol(ColDph).FindOne(sctx, bson.M{"tenant": tenant, "id": id})
- decodeErr := sr.Decode(dspHost)
- if errors.Is(decodeErr, mongo.ErrNoDocuments) {
- return utils.ErrDSPHostNotFound
- }
- return decodeErr
- })
- return dspHost, err
-}
-
-func (ms *MongoStorage) SetDispatcherHostDrv(ctx *context.Context, r *DispatcherHost) error {
- return ms.query(ctx, func(sctx mongo.SessionContext) error {
- _, err := ms.getCol(ColDph).UpdateOne(sctx, bson.M{"tenant": r.Tenant, "id": r.ID},
- bson.M{"$set": r},
- options.Update().SetUpsert(true),
- )
- return err
- })
-}
-
-func (ms *MongoStorage) RemoveDispatcherHostDrv(ctx *context.Context, tenant, id string) error {
- return ms.query(ctx, func(sctx mongo.SessionContext) error {
- dr, err := ms.getCol(ColDph).DeleteOne(sctx, bson.M{"tenant": tenant, "id": id})
- if dr.DeletedCount == 0 {
- return utils.ErrNotFound
- }
- return err
- })
-}
-
func (ms *MongoStorage) GetItemLoadIDsDrv(ctx *context.Context, itemIDPrefix string) (map[string]int64, error) {
fop := options.FindOne()
if itemIDPrefix != "" {
diff --git a/engine/storage_redis.go b/engine/storage_redis.go
index 43e391ad3..a61e4b2db 100644
--- a/engine/storage_redis.go
+++ b/engine/storage_redis.go
@@ -284,7 +284,7 @@ func (rs *RedisStorage) HasDataDrv(ctx *context.Context, category, subject, tena
case utils.ResourcesPrefix, utils.ResourceProfilesPrefix, utils.StatQueuePrefix,
utils.StatQueueProfilePrefix, utils.ThresholdPrefix, utils.ThresholdProfilePrefix,
utils.FilterPrefix, utils.RouteProfilePrefix, utils.AttributeProfilePrefix,
- utils.ChargerProfilePrefix, utils.DispatcherProfilePrefix, utils.DispatcherHostPrefix,
+ utils.ChargerProfilePrefix,
utils.RateProfilePrefix:
err := rs.Cmd(&i, redisEXISTS, category+utils.ConcatenatedKey(tenant, subject))
return i == 1, err
@@ -772,54 +772,6 @@ func (rs *RedisStorage) RemoveChargerProfileDrv(_ *context.Context, tenant, id s
return rs.Cmd(nil, redisDEL, utils.ChargerProfilePrefix+utils.ConcatenatedKey(tenant, id))
}
-func (rs *RedisStorage) GetDispatcherProfileDrv(ctx *context.Context, tenant, id string) (r *DispatcherProfile, err error) {
- var values []byte
- if err = rs.Cmd(&values, redisGET, utils.DispatcherProfilePrefix+utils.ConcatenatedKey(tenant, id)); err != nil {
- return
- } else if len(values) == 0 {
- err = utils.ErrDSPProfileNotFound
- return
- }
- err = rs.ms.Unmarshal(values, &r)
- return
-}
-
-func (rs *RedisStorage) SetDispatcherProfileDrv(ctx *context.Context, r *DispatcherProfile) (err error) {
- var result []byte
- if result, err = rs.ms.Marshal(r); err != nil {
- return
- }
- return rs.Cmd(nil, redisSET, utils.DispatcherProfilePrefix+utils.ConcatenatedKey(r.Tenant, r.ID), string(result))
-}
-
-func (rs *RedisStorage) RemoveDispatcherProfileDrv(ctx *context.Context, tenant, id string) (err error) {
- return rs.Cmd(nil, redisDEL, utils.DispatcherProfilePrefix+utils.ConcatenatedKey(tenant, id))
-}
-
-func (rs *RedisStorage) GetDispatcherHostDrv(ctx *context.Context, tenant, id string) (r *DispatcherHost, err error) {
- var values []byte
- if err = rs.Cmd(&values, redisGET, utils.DispatcherHostPrefix+utils.ConcatenatedKey(tenant, id)); err != nil {
- return
- } else if len(values) == 0 {
- err = utils.ErrDSPHostNotFound
- return
- }
- err = rs.ms.Unmarshal(values, &r)
- return
-}
-
-func (rs *RedisStorage) SetDispatcherHostDrv(ctx *context.Context, r *DispatcherHost) (err error) {
- var result []byte
- if result, err = rs.ms.Marshal(r); err != nil {
- return
- }
- return rs.Cmd(nil, redisSET, utils.DispatcherHostPrefix+utils.ConcatenatedKey(r.Tenant, r.ID), string(result))
-}
-
-func (rs *RedisStorage) RemoveDispatcherHostDrv(ctx *context.Context, tenant, id string) (err error) {
- return rs.Cmd(nil, redisDEL, utils.DispatcherHostPrefix+utils.ConcatenatedKey(tenant, id))
-}
-
func (rs *RedisStorage) GetStorageType() string {
return utils.MetaRedis
}
diff --git a/engine/tpreader.go b/engine/tpreader.go
index 8259da7a7..54050ff6f 100644
--- a/engine/tpreader.go
+++ b/engine/tpreader.go
@@ -30,25 +30,23 @@ import (
)
type TpReader struct {
- tpid string
- timezone string
- dm *DataManager
- lr LoadReader
- resProfiles map[utils.TenantID]*utils.TPResourceProfile
- sqProfiles map[utils.TenantID]*utils.TPStatProfile
- trProfiles map[utils.TenantID]*utils.TPTrendsProfile
- rgProfiles map[utils.TenantID]*utils.TPRankingProfile
- thProfiles map[utils.TenantID]*utils.TPThresholdProfile
- filters map[utils.TenantID]*utils.TPFilterProfile
- routeProfiles map[utils.TenantID]*utils.TPRouteProfile
- attributeProfiles map[utils.TenantID]*utils.TPAttributeProfile
- chargerProfiles map[utils.TenantID]*utils.TPChargerProfile
- dispatcherProfiles map[utils.TenantID]*utils.TPDispatcherProfile
- dispatcherHosts map[utils.TenantID]*utils.TPDispatcherHost
- rateProfiles map[utils.TenantID]*utils.TPRateProfile
- actionProfiles map[utils.TenantID]*utils.TPActionProfile
- accounts map[utils.TenantID]*utils.TPAccount
- cacheConns []string
+ tpid string
+ timezone string
+ dm *DataManager
+ lr LoadReader
+ resProfiles map[utils.TenantID]*utils.TPResourceProfile
+ sqProfiles map[utils.TenantID]*utils.TPStatProfile
+ trProfiles map[utils.TenantID]*utils.TPTrendsProfile
+ rgProfiles map[utils.TenantID]*utils.TPRankingProfile
+ thProfiles map[utils.TenantID]*utils.TPThresholdProfile
+ filters map[utils.TenantID]*utils.TPFilterProfile
+ routeProfiles map[utils.TenantID]*utils.TPRouteProfile
+ attributeProfiles map[utils.TenantID]*utils.TPAttributeProfile
+ chargerProfiles map[utils.TenantID]*utils.TPChargerProfile
+ rateProfiles map[utils.TenantID]*utils.TPRateProfile
+ actionProfiles map[utils.TenantID]*utils.TPActionProfile
+ accounts map[utils.TenantID]*utils.TPAccount
+ cacheConns []string
//schedulerConns []string
isInternalDB bool // do not reload cache if we use internalDB
}
@@ -79,8 +77,6 @@ func (tpr *TpReader) Init() {
tpr.routeProfiles = make(map[utils.TenantID]*utils.TPRouteProfile)
tpr.attributeProfiles = make(map[utils.TenantID]*utils.TPAttributeProfile)
tpr.chargerProfiles = make(map[utils.TenantID]*utils.TPChargerProfile)
- tpr.dispatcherProfiles = make(map[utils.TenantID]*utils.TPDispatcherProfile)
- tpr.dispatcherHosts = make(map[utils.TenantID]*utils.TPDispatcherHost)
tpr.rateProfiles = make(map[utils.TenantID]*utils.TPRateProfile)
tpr.actionProfiles = make(map[utils.TenantID]*utils.TPActionProfile)
tpr.accounts = make(map[utils.TenantID]*utils.TPAccount)
@@ -264,39 +260,6 @@ func (tpr *TpReader) LoadChargerProfiles() error {
return tpr.LoadChargerProfilesFiltered("")
}
-func (tpr *TpReader) LoadDispatcherProfilesFiltered(tag string) (err error) {
- rls, err := tpr.lr.GetTPDispatcherProfiles(tpr.tpid, "", tag)
- if err != nil {
- return err
- }
- mapDispatcherProfile := make(map[utils.TenantID]*utils.TPDispatcherProfile)
- for _, rl := range rls {
- if err = verifyInlineFilterS(rl.FilterIDs); err != nil {
- return
- }
- mapDispatcherProfile[utils.TenantID{Tenant: rl.Tenant, ID: rl.ID}] = rl
- }
- tpr.dispatcherProfiles = mapDispatcherProfile
- return nil
-}
-
-func (tpr *TpReader) LoadDispatcherProfiles() error {
- return tpr.LoadDispatcherProfilesFiltered("")
-}
-
-func (tpr *TpReader) LoadDispatcherHostsFiltered(tag string) (err error) {
- rls, err := tpr.lr.GetTPDispatcherHosts(tpr.tpid, "", tag)
- if err != nil {
- return err
- }
- mapDispatcherHost := make(map[utils.TenantID]*utils.TPDispatcherHost)
- for _, rl := range rls {
- mapDispatcherHost[utils.TenantID{Tenant: rl.Tenant, ID: rl.ID}] = rl
- }
- tpr.dispatcherHosts = mapDispatcherHost
- return nil
-}
-
func (tpr *TpReader) LoadRateProfiles() error {
return tpr.LoadRateProfilesFiltered("")
}
@@ -357,10 +320,6 @@ func (tpr *TpReader) LoadAccountsFiltered(tag string) (err error) {
return nil
}
-func (tpr *TpReader) LoadDispatcherHosts() error {
- return tpr.LoadDispatcherHostsFiltered("")
-}
-
func (tpr *TpReader) LoadAll() (err error) {
if err = tpr.LoadFilters(); err != nil && err.Error() != utils.NotFoundCaps {
return
@@ -389,12 +348,6 @@ func (tpr *TpReader) LoadAll() (err error) {
if err = tpr.LoadChargerProfiles(); err != nil && err.Error() != utils.NotFoundCaps {
return
}
- if err = tpr.LoadDispatcherProfiles(); err != nil && err.Error() != utils.NotFoundCaps {
- return
- }
- if err = tpr.LoadDispatcherHosts(); err != nil && err.Error() != utils.NotFoundCaps {
- return
- }
if err = tpr.LoadRateProfiles(); err != nil && err.Error() != utils.NotFoundCaps {
return
}
@@ -579,37 +532,6 @@ func (tpr *TpReader) WriteToDatabase(verbose, disableReverse bool) (err error) {
if len(tpr.chargerProfiles) != 0 {
loadIDs[utils.CacheChargerProfiles] = loadID
}
- if verbose {
- log.Print("DispatcherProfiles:")
- }
- for _, tpTH := range tpr.dispatcherProfiles {
- th := APItoDispatcherProfile(tpTH, tpr.timezone)
- if err = tpr.dm.SetDispatcherProfile(context.TODO(), th, true); err != nil {
- return
- }
- if verbose {
- log.Print("\t", th.TenantID())
- }
- }
- if len(tpr.dispatcherProfiles) != 0 {
- loadIDs[utils.CacheDispatcherProfiles] = loadID
- }
- if verbose {
- log.Print("DispatcherHosts:")
- }
- for _, tpTH := range tpr.dispatcherHosts {
- th := APItoDispatcherHost(tpTH)
- if err = tpr.dm.SetDispatcherHost(context.TODO(), th); err != nil {
- return
- }
- if verbose {
- log.Print("\t", th.TenantID())
- }
- }
- if len(tpr.dispatcherHosts) != 0 {
- loadIDs[utils.CacheDispatcherHosts] = loadID
- }
-
if verbose {
log.Print("RateProfiles:")
}
@@ -685,10 +607,6 @@ func (tpr *TpReader) ShowStatistics() {
log.Print("AttributeProfiles: ", len(tpr.attributeProfiles))
// Charger profiles
log.Print("ChargerProfiles: ", len(tpr.chargerProfiles))
- // Dispatcher profiles
- log.Print("DispatcherProfiles: ", len(tpr.dispatcherProfiles))
- // Dispatcher Hosts
- log.Print("DispatcherHosts: ", len(tpr.dispatcherHosts))
// Rate profiles
log.Print("RateProfiles: ", len(tpr.rateProfiles))
// Action profiles
@@ -759,24 +677,6 @@ func (tpr *TpReader) GetLoadedIds(categ string) ([]string, error) {
i++
}
return keys, nil
- case utils.DispatcherProfilePrefix:
- keys := make([]string, len(tpr.dispatcherProfiles))
- i := 0
- for k := range tpr.dispatcherProfiles {
- keys[i] = k.TenantID()
- i++
- }
- return keys, nil
-
- case utils.DispatcherHostPrefix:
- keys := make([]string, len(tpr.dispatcherHosts))
- i := 0
- for k := range tpr.dispatcherHosts {
- keys[i] = k.TenantID()
- i++
- }
- return keys, nil
-
case utils.RateProfilePrefix:
keys := make([]string, len(tpr.rateProfiles))
i := 0
@@ -871,30 +771,6 @@ func (tpr *TpReader) RemoveFromDatabase(verbose, disableReverse bool) (err error
}
}
- if verbose {
- log.Print("DispatcherProfiles:")
- }
- for _, tpDsp := range tpr.dispatcherProfiles {
- if err = tpr.dm.RemoveDispatcherProfile(context.TODO(), tpDsp.Tenant, tpDsp.ID,
- true); err != nil {
- return
- }
- if verbose {
- log.Print("\t", utils.ConcatenatedKey(tpDsp.Tenant, tpDsp.ID))
- }
- }
- if verbose {
- log.Print("DispatcherHosts:")
- }
- for _, tpDsh := range tpr.dispatcherHosts {
- if err = tpr.dm.RemoveDispatcherHost(context.TODO(), tpDsh.Tenant, tpDsh.ID); err != nil {
- return
- }
- if verbose {
- log.Print("\t", utils.ConcatenatedKey(tpDsh.Tenant, tpDsh.ID))
- }
- }
-
if verbose {
log.Print("RateProfiles:")
}
@@ -971,12 +847,6 @@ func (tpr *TpReader) RemoveFromDatabase(verbose, disableReverse bool) (err error
if len(tpr.chargerProfiles) != 0 {
loadIDs[utils.CacheChargerProfiles] = loadID
}
- if len(tpr.dispatcherProfiles) != 0 {
- loadIDs[utils.CacheDispatcherProfiles] = loadID
- }
- if len(tpr.dispatcherHosts) != 0 {
- loadIDs[utils.CacheDispatcherHosts] = loadID
- }
if len(tpr.rateProfiles) != 0 {
loadIDs[utils.CacheRateProfiles] = loadID
}
@@ -1005,28 +875,24 @@ func (tpr *TpReader) ReloadCache(ctx *context.Context, caching string, verbose b
routeIDs, _ := tpr.GetLoadedIds(utils.RouteProfilePrefix)
apfIDs, _ := tpr.GetLoadedIds(utils.AttributeProfilePrefix)
chargerIDs, _ := tpr.GetLoadedIds(utils.ChargerProfilePrefix)
- dppIDs, _ := tpr.GetLoadedIds(utils.DispatcherProfilePrefix)
- dphIDs, _ := tpr.GetLoadedIds(utils.DispatcherHostPrefix)
ratePrfIDs, _ := tpr.GetLoadedIds(utils.RateProfilePrefix)
actionPrfIDs, _ := tpr.GetLoadedIds(utils.ActionProfilePrefix)
accountPrfIDs, _ := tpr.GetLoadedIds(utils.AccountPrefix)
//compose Reload Cache argument
cacheArgs := map[string][]string{
- utils.CacheResourceProfiles: rspIDs,
- utils.CacheResources: rspIDs,
- utils.CacheStatQueues: stqpIDs,
- utils.CacheStatQueueProfiles: stqpIDs,
- utils.CacheThresholds: trspfIDs,
- utils.CacheThresholdProfiles: trspfIDs,
- utils.CacheFilters: flrIDs,
- utils.CacheRouteProfiles: routeIDs,
- utils.CacheAttributeProfiles: apfIDs,
- utils.CacheChargerProfiles: chargerIDs,
- utils.CacheDispatcherProfiles: dppIDs,
- utils.CacheDispatcherHosts: dphIDs,
- utils.CacheRateProfiles: ratePrfIDs,
- utils.CacheActionProfiles: actionPrfIDs,
+ utils.CacheResourceProfiles: rspIDs,
+ utils.CacheResources: rspIDs,
+ utils.CacheStatQueues: stqpIDs,
+ utils.CacheStatQueueProfiles: stqpIDs,
+ utils.CacheThresholds: trspfIDs,
+ utils.CacheThresholdProfiles: trspfIDs,
+ utils.CacheFilters: flrIDs,
+ utils.CacheRouteProfiles: routeIDs,
+ utils.CacheAttributeProfiles: apfIDs,
+ utils.CacheChargerProfiles: chargerIDs,
+ utils.CacheRateProfiles: ratePrfIDs,
+ utils.CacheActionProfiles: actionPrfIDs,
}
// verify if we need to clear indexes
@@ -1049,9 +915,6 @@ func (tpr *TpReader) ReloadCache(ctx *context.Context, caching string, verbose b
if len(chargerIDs) != 0 {
cacheIDs = append(cacheIDs, utils.CacheChargerFilterIndexes)
}
- if len(dppIDs) != 0 {
- cacheIDs = append(cacheIDs, utils.CacheDispatcherFilterIndexes)
- }
if len(ratePrfIDs) != 0 {
cacheIDs = append(cacheIDs, utils.CacheRateProfilesFilterIndexes)
cacheIDs = append(cacheIDs, utils.CacheRateFilterIndexes)
diff --git a/engine/tpreader_test.go b/engine/tpreader_test.go
index 3bdc151a9..b477a9ae6 100644
--- a/engine/tpreader_test.go
+++ b/engine/tpreader_test.go
@@ -566,60 +566,6 @@ func TestTPReaderGetLoadedIdsChargerProfiles(t *testing.T) {
}
}
-func TestTPReaderGetLoadedIdsDispatcherProfiles(t *testing.T) {
- tpr := &TpReader{
- dispatcherProfiles: map[utils.TenantID]*utils.TPDispatcherProfile{
- {Tenant: "cgrates.org", ID: "cgratesID"}: {
- TPid: "tp_test",
- Tenant: "cgrates.org",
- ID: "ResGroup1",
- FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-29T15:00:00Z"},
- Strategy: utils.MetaMaxCostDisconnect,
- },
- },
- }
- rcv, err := tpr.GetLoadedIds(utils.DispatcherProfilePrefix)
- if err != nil {
- t.Error(err)
- }
- expRcv := []string{"cgrates.org:cgratesID"}
- if !reflect.DeepEqual(expRcv, rcv) {
- t.Errorf("\nExpected %v but received \n%v", expRcv, rcv)
- }
-}
-
-func TestTPReaderGetLoadedIdsEmptyObject(t *testing.T) {
- tpr := &TpReader{}
- rcv, err := tpr.GetLoadedIds(utils.DispatcherProfilePrefix)
- if err != nil {
- t.Error(err)
- }
- expRcv := make([]string, 0)
- if !reflect.DeepEqual(expRcv, rcv) {
- t.Errorf("\nExpected %v but received \n%v", expRcv, rcv)
- }
-}
-
-func TestTPReaderGetLoadedIdsDispatcherHosts(t *testing.T) {
- tpr := &TpReader{
- dispatcherHosts: map[utils.TenantID]*utils.TPDispatcherHost{
- {Tenant: "cgrates.org", ID: "cgratesID"}: {
- TPid: "tp_test",
- Tenant: "cgrates.org",
- ID: "ResGroup1",
- },
- },
- }
- rcv, err := tpr.GetLoadedIds(utils.DispatcherHostPrefix)
- if err != nil {
- t.Error(err)
- }
- expRcv := []string{"cgrates.org:cgratesID"}
- if !reflect.DeepEqual(expRcv, rcv) {
- t.Errorf("\nExpected %v but received \n%v", expRcv, rcv)
- }
-}
-
func TestTPReaderGetLoadedIdsError(t *testing.T) {
tpr := &TpReader{}
errExpect := "Unsupported load category"
@@ -642,8 +588,6 @@ func TestTPReaderReloadCache(t *testing.T) {
RouteProfileIDs: []string{"cgrates.org:routeProfilesID"},
AttributeProfileIDs: []string{"cgrates.org:attributeProfilesID"},
ChargerProfileIDs: []string{"cgrates.org:chargerProfilesID"},
- DispatcherProfileIDs: []string{"cgrates.org:dispatcherProfilesID"},
- DispatcherHostIDs: []string{"cgrates.org:dispatcherHostsID"},
ResourceIDs: []string{"cgrates.org:resourceProfilesID"},
StatsQueueIDs: []string{"cgrates.org:statProfilesID"},
ThresholdIDs: []string{"cgrates.org:thresholdProfilesID"},
@@ -690,12 +634,6 @@ func TestTPReaderReloadCache(t *testing.T) {
chargerProfiles: map[utils.TenantID]*utils.TPChargerProfile{
{Tenant: "cgrates.org", ID: "chargerProfilesID"}: {},
},
- dispatcherProfiles: map[utils.TenantID]*utils.TPDispatcherProfile{
- {Tenant: "cgrates.org", ID: "dispatcherProfilesID"}: {},
- },
- dispatcherHosts: map[utils.TenantID]*utils.TPDispatcherHost{
- {Tenant: "cgrates.org", ID: "dispatcherHostsID"}: {},
- },
dm: NewDataManager(data, config.CgrConfig().CacheCfg(), cnMgr),
cacheConns: []string{connID},
}
diff --git a/engine/version.go b/engine/version.go
index a009dd7b9..84eff9690 100644
--- a/engine/version.go
+++ b/engine/version.go
@@ -135,7 +135,6 @@ func CurrentDataDBVersions() Versions {
utils.Resource: 1,
utils.Subscribers: 1,
utils.Chargers: 2,
- utils.Dispatchers: 2,
utils.LoadIDsVrs: 1,
utils.RateProfiles: 1,
utils.ActionProfiles: 1,
@@ -154,7 +153,6 @@ func CurrentStorDBVersions() Versions {
utils.TpResources: 1,
utils.TpResource: 1,
utils.TpChargers: 1,
- utils.TpDispatchers: 1,
utils.TpRateProfiles: 1,
utils.TpActionProfiles: 1,
}
diff --git a/engine/version_test.go b/engine/version_test.go
index c2ccb2854..546fa9a33 100644
--- a/engine/version_test.go
+++ b/engine/version_test.go
@@ -55,7 +55,7 @@ func TestCurrentDBVersions(t *testing.T) {
utils.RQF: 5, utils.Resource: 1,
utils.Subscribers: 1,
utils.Chargers: 2,
- utils.Dispatchers: 2, utils.LoadIDsVrs: 1, utils.RateProfiles: 1,
+ utils.LoadIDsVrs: 1, utils.RateProfiles: 1,
utils.ActionProfiles: 1,
}
@@ -85,7 +85,6 @@ func TestCurrentStorDBVersions(t *testing.T) {
utils.TpResources: 1,
utils.TpResource: 1,
utils.TpChargers: 1,
- utils.TpDispatchers: 1,
utils.TpRateProfiles: 1,
utils.TpActionProfiles: 1,
}
@@ -118,7 +117,6 @@ func TestCurrentAllDBVersions(t *testing.T) {
utils.Resource: 1,
utils.Subscribers: 1,
utils.Chargers: 2,
- utils.Dispatchers: 2,
utils.LoadIDsVrs: 1,
utils.RateProfiles: 1,
utils.ActionProfiles: 1,
diff --git a/engine/z_filterindexer_it_test.go b/engine/z_filterindexer_it_test.go
index 9f239d8b2..9e623c32a 100644
--- a/engine/z_filterindexer_it_test.go
+++ b/engine/z_filterindexer_it_test.go
@@ -67,7 +67,6 @@ var sTests = []func(t *testing.T){
testITChargerProfileIndexes,
testITFlush,
testITIsDBEmpty,
- testITDispatcherProfileIndexes,
testITFlush,
testITIsDBEmpty,
testITActionProfileIndexes,
@@ -1487,106 +1486,6 @@ func testITChargerProfileIndexes(t *testing.T) {
}
}
-func testITDispatcherProfileIndexes(t *testing.T) {
- fltr1 := &Filter{
- Tenant: "cgrates.org",
- ID: "DISPATCHER_FLTR1",
- Rules: []*FilterRule{{Type: utils.MetaString, Element: "~*req.Destination", Values: []string{"ACC1", "ACC2", "~*req.Account"}}},
- }
- fltr2 := &Filter{
- Tenant: "cgrates.org",
- ID: "DISPATCHER_FLTR2",
- Rules: []*FilterRule{{Type: utils.MetaString, Element: "10m", Values: []string{"USAGE", "~*opts.Debited", "~*req.Usage", "~*opts.Usage"}}},
- }
- if err := dataManager.SetFilter(context.Background(), fltr1, true); err != nil {
- t.Error(err)
- } else if err := dataManager.SetFilter(context.Background(), fltr2, true); err != nil {
- t.Error(err)
- }
-
- dspPrf1 := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DISPATCHER_PRF1",
- FilterIDs: []string{"DISPATCHER_FLTR1"},
- }
- dspPrf2 := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DISPATCHER_PRF2",
- FilterIDs: []string{"DISPATCHER_FLTR2", "*prefix:23:~*req.Destination"},
- }
- if err := dataManager.SetDispatcherProfile(context.TODO(), dspPrf1, true); err != nil {
- t.Error(err)
- }
- if err := dataManager.SetDispatcherProfile(context.TODO(), dspPrf2, true); err != nil {
- t.Error(err)
- }
-
- expIdx := map[string]utils.StringSet{
- "*string:*req.Destination:ACC1": {
- "DISPATCHER_PRF1": struct{}{},
- },
- "*string:*req.Destination:ACC2": {
- "DISPATCHER_PRF1": struct{}{},
- },
- "*string:*opts.Debited:10m": {
- "DISPATCHER_PRF2": struct{}{},
- },
- "*string:*req.Usage:10m": {
- "DISPATCHER_PRF2": struct{}{},
- },
- "*string:*opts.Usage:10m": {
- "DISPATCHER_PRF2": struct{}{},
- },
- "*prefix:*req.Destination:23": {
- "DISPATCHER_PRF2": struct{}{},
- },
- }
- if rcvIDx, err := dataManager.GetIndexes(context.Background(), utils.CacheDispatcherFilterIndexes,
- "cgrates.org", utils.EmptyString,
- utils.NonTransactional, false, false); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcvIDx, expIdx) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expIdx), utils.ToJSON(rcvIDx))
- }
-
- //here we will get the reverse indexes
- expIdx = map[string]utils.StringSet{
- utils.CacheDispatcherFilterIndexes: {
- "DISPATCHER_PRF1": struct{}{},
- },
- }
- if rcvIDx, err := dataManager.GetIndexes(context.Background(), utils.CacheReverseFilterIndexes,
- "cgrates.org:DISPATCHER_FLTR1", utils.EmptyString,
- utils.NonTransactional, false, false); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcvIDx, expIdx) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expIdx), utils.ToJSON(rcvIDx))
- }
-
- expIdx = map[string]utils.StringSet{
- utils.CacheDispatcherFilterIndexes: {
- "DISPATCHER_PRF2": struct{}{},
- },
- }
- if rcvIDx, err := dataManager.GetIndexes(context.Background(), utils.CacheReverseFilterIndexes,
- "cgrates.org:DISPATCHER_FLTR2", utils.EmptyString,
- utils.NonTransactional, false, false); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcvIDx, expIdx) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expIdx), utils.ToJSON(rcvIDx))
- }
-
- //invalid tnt:context or index key
- expIdx = nil
- if rcvIDx, err := dataManager.GetIndexes(context.Background(), utils.CacheDispatcherFilterIndexes,
- "cgrates.org:attributes", utils.EmptyString,
- utils.NonTransactional, false, false); err == nil || err != utils.ErrNotFound {
- t.Errorf("Expectedd %+v, received %+v", utils.ErrNotFound, err)
- } else if !reflect.DeepEqual(rcvIDx, expIdx) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expIdx), utils.ToJSON(rcvIDx))
- }
-}
-
func testITActionProfileIndexes(t *testing.T) {
fltr1 := &Filter{
Tenant: "itsyscom",
diff --git a/engine/z_libindex_health_test.go b/engine/z_libindex_health_test.go
index c42a8290e..60b964605 100644
--- a/engine/z_libindex_health_test.go
+++ b/engine/z_libindex_health_test.go
@@ -867,166 +867,6 @@ func TestHealthIndexRoutes(t *testing.T) {
}
}
-func TestHealthIndexDispatchers(t *testing.T) {
- Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- db := NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := NewDataManager(db, cfg.CacheCfg(), nil)
-
- // we will set this dispatcherProfile but without indexing
- dspPrf := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{
- "*string:~*opts.*apikey:dps1234|dsp9876",
- "*string:~*req.AnswerTime:2013-11-07T08:42:26Z",
- "*string:~*libphonenumber.<~*req.Destination>:+443234566", // *libphonenumber will not be indexing
- "*suffix:BrokenFilter:Invalid",
- },
- Strategy: utils.MetaRandom,
- Weight: 20,
- Hosts: DispatcherHostProfiles{
- {
- ID: "ALL",
- },
- },
- }
- if err := dm.SetDispatcherProfile(context.Background(), dspPrf, false); err != nil {
- t.Error(err)
- }
-
- exp := &FilterIHReply{
- MissingIndexes: map[string][]string{
- "cgrates.org:*string:*opts.*apikey:dps1234": {"Dsp1"},
- "cgrates.org:*string:*opts.*apikey:dsp9876": {"Dsp1"},
- "cgrates.org:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
- },
- BrokenIndexes: map[string][]string{},
- MissingFilters: map[string][]string{},
- MissingObjects: []string{},
- }
-
- if rply, err := GetFltrIdxHealth(context.Background(), dm,
- ltcache.NewCache(0, 0, false, nil),
- ltcache.NewCache(0, 0, false, nil),
- ltcache.NewCache(0, 0, false, nil),
- utils.CacheDispatcherFilterIndexes); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(exp, rply) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(exp), utils.ToJSON(rply))
- }
-
- // we will set manually some indexes that points to an nil object or index is valid but the obj is missing
- indexes := map[string]utils.StringSet{
- "*string:*req.RequestType:*rated": { // obj exist but the index don't
- "Dsp1": {},
- "Dsp2": {},
- },
- "*suffix:*opts.Destination:+100": { // obj exist but the index don't
- "Dsp1": {},
- "Dsp2": {},
- },
- "*string:*req.ExtraField:Usage": { // index is valid but the obj does not exist
- "InexistingDispatcher": {},
- "InexistingDispatcher2": {},
- },
- }
- if err := dm.SetIndexes(context.Background(), utils.CacheDispatcherFilterIndexes, "cgrates.org",
- indexes, true, utils.NonTransactional); err != nil {
- t.Error(err)
- }
-
- //get the newIdxHealth for dispatchersProfile
- exp = &FilterIHReply{
- MissingIndexes: map[string][]string{
- "cgrates.org:*string:*opts.*apikey:dps1234": {"Dsp1"},
- "cgrates.org:*string:*opts.*apikey:dsp9876": {"Dsp1"},
- "cgrates.org:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
- },
- BrokenIndexes: map[string][]string{
- "cgrates.org:*suffix:*opts.Destination:+100": {"Dsp1"},
- "cgrates.org:*string:*req.RequestType:*rated": {"Dsp1"},
- },
- MissingFilters: map[string][]string{},
- MissingObjects: []string{
- "cgrates.org:Dsp2",
- "cgrates.org:InexistingDispatcher",
- "cgrates.org:InexistingDispatcher2",
- },
- }
-
- if rply, err := GetFltrIdxHealth(context.Background(), dm,
- ltcache.NewCache(0, 0, false, nil),
- ltcache.NewCache(0, 0, false, nil),
- ltcache.NewCache(0, 0, false, nil),
- utils.CacheDispatcherFilterIndexes); err != nil {
- t.Error(err)
- } else {
- sort.Strings(rply.MissingObjects)
- sort.Strings(exp.MissingObjects)
- if !reflect.DeepEqual(exp, rply) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(exp), utils.ToJSON(rply))
- }
- }
-
- //we will use an inexisting Filter(not inline) for the same DispatcherProfile
- dspPrf = &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{
- "*string:~*opts.*apikey:dps1234|dsp9876",
- "*string:~*req.AnswerTime:2013-11-07T08:42:26Z",
- "*string:~*libphonenumber.<~*req.Destination>:+443234566", // *libphonenumber will not be indexing
- "*suffix:BrokenFilter:Invalid",
- "FLTR_1_NOT_EXIST",
- },
- Strategy: utils.MetaRandom,
- Weight: 20,
- Hosts: DispatcherHostProfiles{
- {
- ID: "ALL",
- },
- },
- }
- if err := dm.SetDispatcherProfile(context.Background(), dspPrf, false); err != nil {
- t.Error(err)
- }
-
- //get the newIdxHealth for dispatchersProfile
- exp = &FilterIHReply{
- MissingIndexes: map[string][]string{
- "cgrates.org:*string:*opts.*apikey:dps1234": {"Dsp1"},
- "cgrates.org:*string:*opts.*apikey:dsp9876": {"Dsp1"},
- "cgrates.org:*string:*req.AnswerTime:2013-11-07T08:42:26Z": {"Dsp1"},
- },
- BrokenIndexes: map[string][]string{
- "cgrates.org:*suffix:*opts.Destination:+100": {"Dsp1"},
- "cgrates.org:*string:*req.RequestType:*rated": {"Dsp1"},
- },
- MissingFilters: map[string][]string{
- "cgrates.org:FLTR_1_NOT_EXIST": {"Dsp1"},
- },
- MissingObjects: []string{
- "cgrates.org:Dsp2",
- "cgrates.org:InexistingDispatcher",
- "cgrates.org:InexistingDispatcher2",
- },
- }
- if rply, err := GetFltrIdxHealth(context.Background(), dm,
- ltcache.NewCache(0, 0, false, nil),
- ltcache.NewCache(0, 0, false, nil),
- ltcache.NewCache(0, 0, false, nil),
- utils.CacheDispatcherFilterIndexes); err != nil {
- t.Error(err)
- } else {
- sort.Strings(rply.MissingObjects)
- sort.Strings(exp.MissingObjects)
- if !reflect.DeepEqual(exp, rply) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(exp), utils.ToJSON(rply))
- }
- }
-}
-
func TestIndexHealthMultipleProfiles(t *testing.T) {
Cache.Clear(nil)
cfg := config.NewDefaultCGRConfig()
diff --git a/engine/z_loader_it_test.go b/engine/z_loader_it_test.go
index b5223c82b..a6d0ddf25 100644
--- a/engine/z_loader_it_test.go
+++ b/engine/z_loader_it_test.go
@@ -150,12 +150,6 @@ func testLoaderITRemoveLoad(t *testing.T) {
if err = loader.LoadChargerProfiles(); err != nil {
t.Error("Failed loading Charger profiles: ", err.Error())
}
- if err = loader.LoadDispatcherProfiles(); err != nil {
- t.Error("Failed loading Dispatcher profiles: ", err.Error())
- }
- if err = loader.LoadDispatcherHosts(); err != nil {
- t.Error("Failed loading Dispatcher hosts: ", err.Error())
- }
if err := loader.WriteToDatabase(false, false); err != nil {
t.Error("Could not write data into dataDb: ", err.Error())
}
@@ -202,12 +196,6 @@ func testLoaderITLoadFromCSV(t *testing.T) {
if err = loader.LoadChargerProfiles(); err != nil {
t.Error("Failed loading Charger profiles: ", err.Error())
}
- if err = loader.LoadDispatcherProfiles(); err != nil {
- t.Error("Failed loading Dispatcher profiles: ", err.Error())
- }
- if err = loader.LoadDispatcherHosts(); err != nil {
- t.Error("Failed loading Dispatcher hosts: ", err.Error())
- }
if err := loader.WriteToDatabase(false, false); err != nil {
t.Error("Could not write data into dataDb: ", err.Error())
}
@@ -311,27 +299,6 @@ func testLoaderITWriteToDatabase(t *testing.T) {
}
}
- for tenatid, dpp := range loader.dispatcherProfiles {
- rcv, err := loader.dm.GetDispatcherProfile(context.TODO(), tenatid.Tenant, tenatid.ID, false, false, utils.NonTransactional)
- if err != nil {
- t.Errorf("Failed GetDispatcherProfile, tenant: %s, id: %s, error: %s ", dpp.Tenant, dpp.ID, err.Error())
- }
- dp := APItoDispatcherProfile(dpp, "UTC")
- if !reflect.DeepEqual(dp, rcv) {
- t.Errorf("Expecting: %v, received: %v", dp, rcv)
- }
- }
-
- for tenatid, dph := range loader.dispatcherHosts {
- rcv, err := loader.dm.GetDispatcherHost(context.TODO(), tenatid.Tenant, tenatid.ID, false, false, utils.NonTransactional)
- if err != nil {
- t.Errorf("Failed GetDispatcherHost, tenant: %s, id: %s, error: %s ", dph.Tenant, dph.ID, err.Error())
- }
- dp := APItoDispatcherHost(dph)
- if !reflect.DeepEqual(dp, rcv) {
- t.Errorf("Expecting: %v, received: %v", dp, rcv)
- }
- }
}
/*
diff --git a/engine/z_onstor_it_test.go b/engine/z_onstor_it_test.go
index 31148b971..8d38ffb94 100644
--- a/engine/z_onstor_it_test.go
+++ b/engine/z_onstor_it_test.go
@@ -60,7 +60,6 @@ var (
testOnStorITIsDBEmpty,
testOnStorITTestAttributeSubstituteIface,
testOnStorITChargerProfile,
- testOnStorITDispatcherProfile,
testOnStorITRateProfile,
testOnStorITActionProfile,
testOnStorITAccount,
@@ -962,59 +961,6 @@ func testOnStorITChargerProfile(t *testing.T) {
}
}
-func testOnStorITDispatcherProfile(t *testing.T) {
- dpp := &DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{"*string:Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"},
- Strategy: utils.MetaFirst,
- // Hosts: []string{"192.168.56.203"},
- Weight: 20,
- }
- if _, rcvErr := onStor.GetDispatcherProfile(context.TODO(), "cgrates.org", "Dsp1",
- true, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrDSPProfileNotFound {
- t.Error(rcvErr)
- }
- if err := onStor.SetDispatcherProfile(context.TODO(), dpp, false); err != nil {
- t.Error(err)
- }
- //get from database
- if rcv, err := onStor.GetDispatcherProfile(context.TODO(), "cgrates.org", "Dsp1",
- false, false, utils.NonTransactional); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(dpp, rcv) {
- t.Errorf("Expecting: %v, received: %v", dpp, rcv)
- }
- expectedT := []string{"dpp_cgrates.org:Dsp1"}
- if itm, err := onStor.DataDB().GetKeysForPrefix(context.TODO(), utils.DispatcherProfilePrefix); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expectedT, itm) {
- t.Errorf("Expected : %+v, but received %+v", expectedT, itm)
- }
- //update
- dpp.FilterIDs = []string{"*string:~*req.Accout:1001", "*prefix:~*req.Destination:10"}
- if err := onStor.SetDispatcherProfile(context.TODO(), dpp, false); err != nil {
- t.Error(err)
- }
-
- //get from database
- if rcv, err := onStor.GetDispatcherProfile(context.TODO(), "cgrates.org", "Dsp1",
- false, false, utils.NonTransactional); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(dpp, rcv) {
- t.Errorf("Expecting: %v, received: %v", dpp, rcv)
- }
- if err := onStor.RemoveDispatcherProfile(context.TODO(), dpp.Tenant, dpp.ID,
- false); err != nil {
- t.Error(err)
- }
- //check database if removed
- if _, rcvErr := onStor.GetDispatcherProfile(context.TODO(), "cgrates.org", "Dsp1",
- false, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrDSPProfileNotFound {
- t.Error(rcvErr)
- }
-}
-
func testOnStorITRateProfile(t *testing.T) {
rPrf := &utils.RateProfile{
Tenant: "cgrates.org",
diff --git a/engine/z_versions_it_test.go b/engine/z_versions_it_test.go
index 4c896bb41..b5d33f22e 100644
--- a/engine/z_versions_it_test.go
+++ b/engine/z_versions_it_test.go
@@ -262,26 +262,6 @@ func testUpdateVersionsAttributes(t *testing.T) {
}
}
-func testUpdateVersionsDispatchers(t *testing.T) {
- newVersions := CurrentDataDBVersions()
- newVersions[utils.Dispatchers] = 1
- if err := dm3.DataDB().SetVersions(newVersions, true); err != nil {
- t.Fatal(err)
- }
- cmd := exec.Command("cgr-engine", fmt.Sprintf(`-config_path=/usr/share/cgrates/conf/samples/%s`, versionsConfigDIR), `-scheduled_shutdown=4ms`)
- output := bytes.NewBuffer(nil)
- cmd.Stdout = output
- if err := cmd.Run(); err != nil {
- t.Log(cmd.Args)
- t.Log(output.String())
- t.Fatal(err)
- }
- errExpect := "Migration needed: please backup cgr data and run: \n"
- if output.String() != errExpect {
- t.Fatalf("Expected %q \n but received: \n %q", errExpect, output.String())
- }
-}
-
func testUpdateVersionsLoadIDs(t *testing.T) {
newVersions := CurrentDataDBVersions()
delete(newVersions, utils.LoadIDsVrs)
diff --git a/general_tests/all_cfg_rld_it_test.go b/general_tests/all_cfg_rld_it_test.go
index c95e0697b..f65d323db 100644
--- a/general_tests/all_cfg_rld_it_test.go
+++ b/general_tests/all_cfg_rld_it_test.go
@@ -160,7 +160,7 @@ func testConfigSReload(t *testing.T) {
t.Errorf("\nExpected %+v ,\n received: %+v", cfgStr, rpl5)
}
if testCfgDir == "tutmysql" || testCfgDir == "tutmongo" {
- cfgStr = `{"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_loads":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatchers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*event_charges":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*sentrypeer":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":true,"ttl":"24h0m0s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"remote_conns":[],"replication_conns":[]}}`
+ cfgStr = `{"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*event_charges":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*sentrypeer":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":true,"ttl":"24h0m0s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"remote_conns":[],"replication_conns":[]}}`
var rpl7 string
if err := testRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",
@@ -171,7 +171,7 @@ func testConfigSReload(t *testing.T) {
t.Errorf("\nExpected %+v ,\n received: %+v", cfgStr, rpl7)
}
} else if testCfgDir == "tutinternal" {
- cfgStr := `{"caches":{"partitions":{"*account_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_loads":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatchers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*event_charges":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*sentrypeer":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":true,"ttl":"24h0m0s"},"*stat_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"remote_conns":[],"replication_conns":[]}}`
+ cfgStr := `{"caches":{"partitions":{"*account_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*event_charges":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*sentrypeer":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":true,"ttl":"24h0m0s"},"*stat_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"remote_conns":[],"replication_conns":[]}}`
var rpl7 string
if err := testRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",
@@ -401,7 +401,7 @@ func testConfigSReload(t *testing.T) {
}
if testCfgDir == "tutinternal" {
- cfgStr := `{"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatcher_hosts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatchers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Attributes.Blockers","tag":"AttributeBlockers","type":"*variable","value":"~*req.6"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.7"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.8"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.9"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.5"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.10"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.11"},{"path":"Metrics.Blockers","tag":"MetricBlockers","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatID","tag":"StatID","type":"*variable","value":"~*req.3"},{"path":"Metrics","tag":"Metrics","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"CorrelationType","tag":"CorrelationType","type":"*variable","value":"~*req.8"},{"path":"Tolerance","tag":"Tolerance","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Trends.csv","flags":null,"type":"*trends"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatIDs","tag":"StatIDs","type":"*variable","value":"~*req.3"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.7"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.8"}],"file_name":"Rankings.csv","flags":null,"type":"*rankings"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.7"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.12"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.13"},{"path":"Routes.Blockers","tag":"RouteBlockers","type":"*variable","value":"~*req.14"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.5"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.4"},{"path":"StrategyParams","tag":"StrategyParameters","type":"*variable","value":"~*req.5"},{"new_branch":true,"path":"Hosts.ID","tag":"ConnID","type":"*variable","value":"~*req.6"},{"path":"Hosts.FilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.7"},{"path":"Hosts.Weight","tag":"ConnWeight","type":"*variable","value":"~*req.8"},{"path":"Hosts.Blocker","tag":"ConnBlocker","type":"*variable","value":"~*req.9"},{"path":"Hosts.Params","tag":"ConnParameters","type":"*variable","value":"~*req.10"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"ConnectAttempts","tag":"ConnectAttempts","type":"*variable","value":"~*req.4"},{"path":"Reconnects","tag":"Reconnects","type":"*variable","value":"~*req.5"},{"path":"MaxReconnectInterval","tag":"MaxReconnectInterval","type":"*variable","value":"~*req.6"},{"path":"ConnectTimeout","tag":"ConnectTimeout","type":"*variable","value":"~*req.7"},{"path":"ReplyTimeout","tag":"ReplyTimeout","type":"*variable","value":"~*req.8"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.9"},{"path":"ClientKey","tag":"ClientKey","type":"*variable","value":"~*req.10"},{"path":"ClientCertificate","tag":"ClientCertificate","type":"*variable","value":"~*req.11"},{"path":"CaCertificate","tag":"CaCertificate","type":"*variable","value":"~*req.12"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.5"},{"path":"Targets[\u003c~*req.6\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.8:"],"new_branch":true,"path":"Actions[\u003c~*req.8\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.5"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Blockers","tag":"BalanceBlockers","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.16"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.17"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}]}`
+ cfgStr := `{"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Attributes.Blockers","tag":"AttributeBlockers","type":"*variable","value":"~*req.6"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.7"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.8"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.9"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.5"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.10"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.11"},{"path":"Metrics.Blockers","tag":"MetricBlockers","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatID","tag":"StatID","type":"*variable","value":"~*req.3"},{"path":"Metrics","tag":"Metrics","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"CorrelationType","tag":"CorrelationType","type":"*variable","value":"~*req.8"},{"path":"Tolerance","tag":"Tolerance","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Trends.csv","flags":null,"type":"*trends"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatIDs","tag":"StatIDs","type":"*variable","value":"~*req.3"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.7"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.8"}],"file_name":"Rankings.csv","flags":null,"type":"*rankings"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.7"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.12"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.13"},{"path":"Routes.Blockers","tag":"RouteBlockers","type":"*variable","value":"~*req.14"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.5"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.5"},{"path":"Targets[\u003c~*req.6\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.8:"],"new_branch":true,"path":"Actions[\u003c~*req.8\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.5"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Blockers","tag":"BalanceBlockers","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.16"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.17"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}]}`
var rpl26 string
if err := testRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",
@@ -413,7 +413,7 @@ func testConfigSReload(t *testing.T) {
}
} else if testCfgDir == "tutmysql" || testCfgDir == "tutmongo" {
- cfgStr = `{"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatcher_hosts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatchers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Attributes.Blockers","tag":"AttributeBlockers","type":"*variable","value":"~*req.6"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.7"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.8"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.9"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.5"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.10"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.11"},{"path":"Metrics.Blockers","tag":"MetricBlockers","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatID","tag":"StatID","type":"*variable","value":"~*req.3"},{"path":"Metrics","tag":"Metrics","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"CorrelationType","tag":"CorrelationType","type":"*variable","value":"~*req.8"},{"path":"Tolerance","tag":"Tolerance","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Trends.csv","flags":null,"type":"*trends"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatIDs","tag":"StatIDs","type":"*variable","value":"~*req.3"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.7"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.8"}],"file_name":"Rankings.csv","flags":null,"type":"*rankings"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.7"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.12"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.13"},{"path":"Routes.Blockers","tag":"RouteBlockers","type":"*variable","value":"~*req.14"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.5"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.4"},{"path":"StrategyParams","tag":"StrategyParameters","type":"*variable","value":"~*req.5"},{"new_branch":true,"path":"Hosts.ID","tag":"ConnID","type":"*variable","value":"~*req.6"},{"path":"Hosts.FilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.7"},{"path":"Hosts.Weight","tag":"ConnWeight","type":"*variable","value":"~*req.8"},{"path":"Hosts.Blocker","tag":"ConnBlocker","type":"*variable","value":"~*req.9"},{"path":"Hosts.Params","tag":"ConnParameters","type":"*variable","value":"~*req.10"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"ConnectAttempts","tag":"ConnectAttempts","type":"*variable","value":"~*req.4"},{"path":"Reconnects","tag":"Reconnects","type":"*variable","value":"~*req.5"},{"path":"MaxReconnectInterval","tag":"MaxReconnectInterval","type":"*variable","value":"~*req.6"},{"path":"ConnectTimeout","tag":"ConnectTimeout","type":"*variable","value":"~*req.7"},{"path":"ReplyTimeout","tag":"ReplyTimeout","type":"*variable","value":"~*req.8"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.9"},{"path":"ClientKey","tag":"ClientKey","type":"*variable","value":"~*req.10"},{"path":"ClientCertificate","tag":"ClientCertificate","type":"*variable","value":"~*req.11"},{"path":"CaCertificate","tag":"CaCertificate","type":"*variable","value":"~*req.12"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.5"},{"path":"Targets[\u003c~*req.6\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.8:"],"new_branch":true,"path":"Actions[\u003c~*req.8\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.5"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Blockers","tag":"BalanceBlockers","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.16"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.17"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}]}`
+ cfgStr = `{"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Attributes.Blockers","tag":"AttributeBlockers","type":"*variable","value":"~*req.6"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.7"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.8"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.9"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.5"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.10"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.11"},{"path":"Metrics.Blockers","tag":"MetricBlockers","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatID","tag":"StatID","type":"*variable","value":"~*req.3"},{"path":"Metrics","tag":"Metrics","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"CorrelationType","tag":"CorrelationType","type":"*variable","value":"~*req.8"},{"path":"Tolerance","tag":"Tolerance","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Trends.csv","flags":null,"type":"*trends"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatIDs","tag":"StatIDs","type":"*variable","value":"~*req.3"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.7"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.8"}],"file_name":"Rankings.csv","flags":null,"type":"*rankings"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.7"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.12"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.13"},{"path":"Routes.Blockers","tag":"RouteBlockers","type":"*variable","value":"~*req.14"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.5"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.5"},{"path":"Targets[\u003c~*req.6\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.8:"],"new_branch":true,"path":"Actions[\u003c~*req.8\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.5"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Blockers","tag":"BalanceBlockers","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.16"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.17"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}]}`
var rpl26 string
if err := testRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",
@@ -469,18 +469,8 @@ func testConfigSReload(t *testing.T) {
t.Errorf("\nExpected %+v ,\n received: %+v", cfgStr, rpl30)
}
}
- cfgStr = `{"dispatchers":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*dispatchers":[]},"prefix_indexed_fields":[],"suffix_indexed_fields":[]}}`
- var rpl31 string
- if err := testRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
- Tenant: "cgrates.org",
- Sections: []string{config.DispatcherSJSON},
- }, &rpl31); err != nil {
- t.Error(err)
- } else if cfgStr != rpl31 {
- t.Errorf("\nExpected %+v ,\n received: %+v", cfgStr, rpl31)
- }
- cfgStr = `{"registrarc":{"dispatchers":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]},"rpc":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]}}}`
+ cfgStr = `{"registrarc":{"rpc":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]}}}`
var rpl32 string
if err := testRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",
diff --git a/general_tests/all_sections_cfg_rld_it_test.go b/general_tests/all_sections_cfg_rld_it_test.go
index 61e8118e3..a4e651e10 100644
--- a/general_tests/all_sections_cfg_rld_it_test.go
+++ b/general_tests/all_sections_cfg_rld_it_test.go
@@ -71,7 +71,6 @@ var (
testSectConfigSReloadSuretax,
testSectConfigSReloadLoader,
testSectConfigSReloadMigrator,
- testSectConfigSReloadDispatchers,
testSectConfigSReloadRegistrarC,
testSectConfigSReloadAnalyzer,
testSectConfigSReloadSIPAgent,
@@ -212,13 +211,13 @@ func testSectConfigSReloadDataDB(t *testing.T) {
var reply string
if err := testSectRPC.Call(context.Background(), utils.ConfigSv1SetConfigFromJSON, &config.SetConfigFromJSONArgs{
Tenant: "cgrates.org",
- Config: `{"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*internal","db_user":"cgrates","items":{"*account_action_plans":{"remote":false,"replicate":false},"*accounts":{"remote":false,"replicate":false},"*action_plans":{"remote":false,"replicate":false},"*action_triggers":{"remote":false,"replicate":false},"*actions":{"remote":false,"replicate":false},"*attribute_profiles":{"remote":false,"replicate":false},"*charger_profiles":{"remote":false,"replicate":false},"*destinations":{"remote":false,"replicate":false},"*dispatcher_hosts":{"remote":false,"replicate":false},"*dispatcher_profiles":{"remote":false,"replicate":false},"*filters":{"remote":false,"replicate":false},"*indexes":{"remote":false,"replicate":false},"*load_ids":{"remote":false,"replicate":false},"*rating_plans":{"remote":false,"replicate":false},"*rating_profiles":{"remote":false,"replicate":false},"*resource_profiles":{"remote":false,"replicate":false},"*resources":{"remote":false,"replicate":false},"*reverse_destinations":{"remote":false,"replicate":false},"*route_profiles":{"remote":false,"replicate":false},"*statqueues":{"remote":false,"replicate":false},"*threshold_profiles":{"remote":false,"replicate":false},"*thresholds":{"remote":false,"replicate":false}},"opts":{"mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false}}`,
+ Config: `{"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*internal","db_user":"cgrates","items":{"*account_action_plans":{"remote":false,"replicate":false},"*accounts":{"remote":false,"replicate":false},"*action_plans":{"remote":false,"replicate":false},"*action_triggers":{"remote":false,"replicate":false},"*actions":{"remote":false,"replicate":false},"*attribute_profiles":{"remote":false,"replicate":false},"*charger_profiles":{"remote":false,"replicate":false},"*destinations":{"remote":false,"replicate":false},"*filters":{"remote":false,"replicate":false},"*indexes":{"remote":false,"replicate":false},"*load_ids":{"remote":false,"replicate":false},"*rating_plans":{"remote":false,"replicate":false},"*rating_profiles":{"remote":false,"replicate":false},"*resource_profiles":{"remote":false,"replicate":false},"*resources":{"remote":false,"replicate":false},"*reverse_destinations":{"remote":false,"replicate":false},"*route_profiles":{"remote":false,"replicate":false},"*statqueues":{"remote":false,"replicate":false},"*threshold_profiles":{"remote":false,"replicate":false},"*thresholds":{"remote":false,"replicate":false}},"opts":{"mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false}}`,
}, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Errorf("Expected OK received: %+v", reply)
}
- cfgStr := `{"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*internal","db_user":"cgrates","items":{"*account_action_plans":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*account_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_plans":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_triggers":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*actions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*destinations":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rating_plans":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rating_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*reverse_destinations":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*stat_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoConnScheme":"mongodb","mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisConnectAttempts":20,"redisConnectTimeout":"0s","redisMaxConns":10,"redisPoolPipelineLimit":0,"redisPoolPipelineWindow":"150µs","redisReadTimeout":"0s","redisSentinel":"","redisTLS":false,"redisWriteTimeout":"0s"},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false}}`
+ cfgStr := `{"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*internal","db_user":"cgrates","items":{"*account_action_plans":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*account_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_plans":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_triggers":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*actions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*destinations":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rating_plans":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rating_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*reverse_destinations":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*stat_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoConnScheme":"mongodb","mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisConnectAttempts":20,"redisConnectTimeout":"0s","redisMaxConns":10,"redisPoolPipelineLimit":0,"redisPoolPipelineWindow":"150µs","redisReadTimeout":"0s","redisSentinel":"","redisTLS":false,"redisWriteTimeout":"0s"},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false}}`
var rpl string
if err := testSectRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",
@@ -310,13 +309,13 @@ func testSectConfigSReloadCaches(t *testing.T) {
var reply string
if err := testSectRPC.Call(context.Background(), utils.ConfigSv1SetConfigFromJSON, &config.SetConfigFromJSONArgs{
Tenant: "cgrates.org",
- Config: `{"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_loads":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*event_charges":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"replication_conns":[]}}`,
+ Config: `{"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*event_charges":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"replication_conns":[]}}`,
}, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Errorf("Expected OK received: %+v", reply)
}
- cfgStr := `{"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_loads":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*dispatchers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*event_charges":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*sentrypeer":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":true,"ttl":"24h0m0s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"remote_conns":[],"replication_conns":[]}}`
+ cfgStr := `{"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*event_charges":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*ranking_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*sentrypeer":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":true,"ttl":"24h0m0s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trend_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"remote_conns":[],"replication_conns":[]}}`
var rpl string
if err := testSectRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",
@@ -818,7 +817,7 @@ func testSectConfigSReloadLoaders(t *testing.T) {
} else if reply != utils.OK {
t.Errorf("Expected OK received: %+v", reply)
}
- cfgStr := `{"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatcher_hosts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatchers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Attributes.Blockers","tag":"AttributeBlockers","type":"*variable","value":"~*req.6"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.7"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.8"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.9"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.5"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.10"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.11"},{"path":"Metrics.Blockers","tag":"MetricBlockers","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatID","tag":"StatID","type":"*variable","value":"~*req.3"},{"path":"Metrics","tag":"Metrics","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"CorrelationType","tag":"CorrelationType","type":"*variable","value":"~*req.8"},{"path":"Tolerance","tag":"Tolerance","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Trends.csv","flags":null,"type":"*trends"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatIDs","tag":"StatIDs","type":"*variable","value":"~*req.3"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.7"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.8"}],"file_name":"Rankings.csv","flags":null,"type":"*rankings"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.7"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.12"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.13"},{"path":"Routes.Blockers","tag":"RouteBlockers","type":"*variable","value":"~*req.14"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.5"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.4"},{"path":"StrategyParams","tag":"StrategyParameters","type":"*variable","value":"~*req.5"},{"new_branch":true,"path":"Hosts.ID","tag":"ConnID","type":"*variable","value":"~*req.6"},{"path":"Hosts.FilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.7"},{"path":"Hosts.Weight","tag":"ConnWeight","type":"*variable","value":"~*req.8"},{"path":"Hosts.Blocker","tag":"ConnBlocker","type":"*variable","value":"~*req.9"},{"path":"Hosts.Params","tag":"ConnParameters","type":"*variable","value":"~*req.10"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"ConnectAttempts","tag":"ConnectAttempts","type":"*variable","value":"~*req.4"},{"path":"Reconnects","tag":"Reconnects","type":"*variable","value":"~*req.5"},{"path":"MaxReconnectInterval","tag":"MaxReconnectInterval","type":"*variable","value":"~*req.6"},{"path":"ConnectTimeout","tag":"ConnectTimeout","type":"*variable","value":"~*req.7"},{"path":"ReplyTimeout","tag":"ReplyTimeout","type":"*variable","value":"~*req.8"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.9"},{"path":"ClientKey","tag":"ClientKey","type":"*variable","value":"~*req.10"},{"path":"ClientCertificate","tag":"ClientCertificate","type":"*variable","value":"~*req.11"},{"path":"CaCertificate","tag":"CaCertificate","type":"*variable","value":"~*req.12"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.5"},{"path":"Targets[\u003c~*req.6\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.8:"],"new_branch":true,"path":"Actions[\u003c~*req.8\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.5"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Blockers","tag":"BalanceBlockers","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.16"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.17"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}]}`
+ cfgStr := `{"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rankings":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*trends":{"limit":-1,"precache":false,"remote":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Attributes.Blockers","tag":"AttributeBlockers","type":"*variable","value":"~*req.6"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.7"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.8"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.9"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.5"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.10"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.11"},{"path":"Metrics.Blockers","tag":"MetricBlockers","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatID","tag":"StatID","type":"*variable","value":"~*req.3"},{"path":"Metrics","tag":"Metrics","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.6"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.7"},{"path":"CorrelationType","tag":"CorrelationType","type":"*variable","value":"~*req.8"},{"path":"Tolerance","tag":"Tolerance","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Trends.csv","flags":null,"type":"*trends"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.2"},{"path":"StatIDs","tag":"StatIDs","type":"*variable","value":"~*req.3"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.7"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.8"}],"file_name":"Rankings.csv","flags":null,"type":"*rankings"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.5"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.7"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.12"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.13"},{"path":"Routes.Blockers","tag":"RouteBlockers","type":"*variable","value":"~*req.14"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.5"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.5"},{"path":"Targets[\u003c~*req.6\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.8:"],"new_branch":true,"path":"Actions[\u003c~*req.8\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.8:"],"path":"Actions[\u003c~*req.8\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Blockers","tag":"Blockers","type":"*variable","value":"~*req.4"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.5"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Blockers","tag":"BalanceBlockers","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.6:"],"path":"Balances[\u003c~*req.6\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.16"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.17"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}]}`
var rpl string
if err := testSectRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",
@@ -896,28 +895,6 @@ func testSectConfigSReloadMigrator(t *testing.T) {
}
}
-func testSectConfigSReloadDispatchers(t *testing.T) {
- var reply string
- if err := testSectRPC.Call(context.Background(), utils.ConfigSv1SetConfigFromJSON, &config.SetConfigFromJSONArgs{
- Tenant: "cgrates.org",
- Config: `{"dispatchers":{"attributes_conns":[],"enabled":true,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"prefix_indexed_fields":[],"suffix_indexed_fields":[]}}`,
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Errorf("Expected OK received: %+v", reply)
- }
- cfgStr := `{"dispatchers":{"attributes_conns":[],"enabled":true,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*dispatchers":[]},"prefix_indexed_fields":[],"suffix_indexed_fields":[]}}`
- var rpl string
- if err := testSectRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
- Tenant: "cgrates.org",
- Sections: []string{config.DispatcherSJSON},
- }, &rpl); err != nil {
- t.Error(err)
- } else if cfgStr != rpl {
- t.Errorf("\nExpected %+v ,\n received: %+v", cfgStr, rpl)
- }
-}
-
func testSectConfigSReloadRegistrarC(t *testing.T) {
var reply string
if err := testSectRPC.Call(context.Background(), utils.ConfigSv1SetConfigFromJSON, &config.SetConfigFromJSONArgs{
@@ -928,7 +905,7 @@ func testSectConfigSReloadRegistrarC(t *testing.T) {
} else if reply != utils.OK {
t.Errorf("Expected OK received: %+v", reply)
}
- cfgStr := `{"registrarc":{"dispatchers":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]},"rpc":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]}}}`
+ cfgStr := `{"registrarc":{"rpc":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]}}}`
var rpl string
if err := testSectRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",
diff --git a/general_tests/cacherpl_it_test.go b/general_tests/cacherpl_it_test.go
index 68e8e2d9d..b979d1b15 100644
--- a/general_tests/cacherpl_it_test.go
+++ b/general_tests/cacherpl_it_test.go
@@ -25,7 +25,6 @@ import (
"path"
"reflect"
"sort"
- "sync"
"testing"
"time"
@@ -55,8 +54,8 @@ var (
testCacheRplRpcConn,
testCacheRplAddData,
testCacheRplPing,
- testCacheRplCheckReplication,
- testCacheRplCheckLoadReplication,
+ // testCacheRplCheckReplication,
+ // testCacheRplCheckLoadReplication,
testCacheRplStopEngine,
}
@@ -68,7 +67,7 @@ var (
testCacheRplRpcConn,
testCacheRplAAAddData,
testCacheRplAACheckReplication,
- testCacheRplAACheckLoadReplication,
+ // testCacheRplAACheckLoadReplication,
testCacheRplStopEngine,
}
@@ -337,53 +336,51 @@ func testCacheRplPing(t *testing.T) {
}
}
-func testCacheRplCheckReplication(t *testing.T) {
- var reply map[string]any
- ev := utils.TenantWithAPIOpts{
- Tenant: "cgrates.org",
- }
- if err := dspEngine2RPC.Call(context.Background(), utils.CoreSv1Status, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply[utils.NodeID] != "DispatcherEngine2" {
- t.Errorf("Received: %s", utils.ToJSON(reply))
- }
- var rcvKeys []string
- expKeys := []string{"testRoute123:*core", "testRoute123:*attributes"}
- argsAPI := utils.ArgsGetCacheItemIDsWithAPIOpts{
- Tenant: "cgrates.org",
- ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
- CacheID: utils.CacheDispatcherRoutes,
- },
- }
- if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
- t.Error(err.Error())
- }
- sort.Strings(rcvKeys)
- sort.Strings(expKeys)
- if !reflect.DeepEqual(expKeys, rcvKeys) {
- t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
- }
+// func testCacheRplCheckReplication(t *testing.T) {
+// var reply map[string]any
+// ev := utils.TenantWithAPIOpts{
+// Tenant: "cgrates.org",
+// }
+// if err := dspEngine2RPC.Call(context.Background(), utils.CoreSv1Status, &ev, &reply); err != nil {
+// t.Error(err)
+// } else if reply[utils.NodeID] != "DispatcherEngine2" {
+// t.Errorf("Received: %s", utils.ToJSON(reply))
+// }
+// var rcvKeys []string
+// expKeys := []string{"testRoute123:*core", "testRoute123:*attributes"}
+// argsAPI := utils.ArgsGetCacheItemIDsWithAPIOpts{
+// Tenant: "cgrates.org",
+// ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
+// CacheID: utils.CacheDispatcherRoutes,
+// },
+// }
+// if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
+// t.Error(err.Error())
+// }
+// sort.Strings(rcvKeys)
+// sort.Strings(expKeys)
+// if !reflect.DeepEqual(expKeys, rcvKeys) {
+// t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
+// }
- var rpl string
- if err := dspEngine2RPC.Call(context.Background(), utils.AttributeSv1Ping, &utils.CGREvent{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsRouteID: "testRoute123",
- },
- }, &rpl); err != nil {
- t.Error(err)
- } else if rpl != utils.Pong {
- t.Errorf("Received: %s", rpl)
- }
-}
+// var rpl string
+// if err := dspEngine2RPC.Call(context.Background(), utils.AttributeSv1Ping, &utils.CGREvent{
+// Tenant: "cgrates.org",
+// APIOpts: map[string]any{
+// utils.OptsRouteID: "testRoute123",
+// },
+// }, &rpl); err != nil {
+// t.Error(err)
+// } else if rpl != utils.Pong {
+// t.Errorf("Received: %s", rpl)
+// }
+// }
func testCacheRplAACheckReplication(t *testing.T) {
var rcvKeys []string
argsAPI := utils.ArgsGetCacheItemIDsWithAPIOpts{
- Tenant: "cgrates.org",
- ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
- CacheID: utils.CacheDispatcherRoutes,
- },
+ Tenant: "cgrates.org",
+ ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{},
}
if err := dspEngine1RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
@@ -440,197 +437,194 @@ func testCacheRplAACheckReplication(t *testing.T) {
}
-func testCacheRplAACheckLoadReplication(t *testing.T) {
- var rcvKeys []string
- argsAPI := utils.ArgsGetCacheItemIDsWithAPIOpts{
- Tenant: "cgrates.org",
- ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
- CacheID: utils.CacheDispatcherLoads,
- },
- }
- if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
- if err := dspEngine1RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
+// func testCacheRplAACheckLoadReplication(t *testing.T) {
+// var rcvKeys []string
+// argsAPI := utils.ArgsGetCacheItemIDsWithAPIOpts{
+// Tenant: "cgrates.org",
+// ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
+// CacheID: utils.CacheDispatcherLoads,
+// },
+// }
+// if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err == nil ||
+// err.Error() != utils.ErrNotFound.Error() {
+// t.Error(err)
+// }
+// if err := dspEngine1RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err == nil ||
+// err.Error() != utils.ErrNotFound.Error() {
+// t.Error(err)
+// }
- var wgDisp1 sync.WaitGroup
- var wgDisp2 sync.WaitGroup
- for i := 0; i < 10; i++ {
- wgDisp1.Add(1)
- wgDisp2.Add(1)
- go func() {
- var rpl []*engine.ChrgSProcessEventReply
- if err := dspEngine1RPC.Call(context.Background(), utils.ChargerSv1ProcessEvent, &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testCacheRplAACheckLoadReplication",
- Event: map[string]any{
- utils.AccountField: "1007",
- utils.Destination: "+491511231234",
- "EventName": "TestLoad",
- },
+// var wgDisp1 sync.WaitGroup
+// var wgDisp2 sync.WaitGroup
+// for i := 0; i < 10; i++ {
+// wgDisp1.Add(1)
+// wgDisp2.Add(1)
+// go func() {
+// var rpl []*engine.ChrgSProcessEventReply
+// if err := dspEngine1RPC.Call(context.Background(), utils.ChargerSv1ProcessEvent, &utils.CGREvent{
+// Tenant: "cgrates.org",
+// ID: "testCacheRplAACheckLoadReplication",
+// Event: map[string]any{
+// utils.AccountField: "1007",
+// utils.Destination: "+491511231234",
+// "EventName": "TestLoad",
+// },
- APIOpts: map[string]any{
- utils.OptsRouteID: "testRouteFromDispatcher1",
- },
- }, &rpl); err != nil {
- t.Error(err)
- } else if rpl[0].ChargerSProfile != "DefaultCharger" {
- t.Errorf("Received: %+v", utils.ToJSON(rpl))
- }
- wgDisp1.Done()
- }()
- go func() {
- var rpl []*engine.ChrgSProcessEventReply
- if err := dspEngine2RPC.Call(context.Background(), utils.ChargerSv1ProcessEvent, &utils.CGREvent{
+// APIOpts: map[string]any{
+// utils.OptsRouteID: "testRouteFromDispatcher1",
+// },
+// }, &rpl); err != nil {
+// t.Error(err)
+// } else if rpl[0].ChargerSProfile != "DefaultCharger" {
+// t.Errorf("Received: %+v", utils.ToJSON(rpl))
+// }
+// wgDisp1.Done()
+// }()
+// go func() {
+// var rpl []*engine.ChrgSProcessEventReply
+// if err := dspEngine2RPC.Call(context.Background(), utils.ChargerSv1ProcessEvent, &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testCacheRplAACheckLoadReplication",
- Event: map[string]any{
- utils.AccountField: "1007",
- utils.Destination: "+491511231234",
- "EventName": "TestLoad",
- },
+// Tenant: "cgrates.org",
+// ID: "testCacheRplAACheckLoadReplication",
+// Event: map[string]any{
+// utils.AccountField: "1007",
+// utils.Destination: "+491511231234",
+// "EventName": "TestLoad",
+// },
- APIOpts: map[string]any{
- utils.OptsRouteID: "testRouteFromDispatcher2",
- },
- }, &rpl); err != nil {
- t.Error(err)
- } else if rpl[0].ChargerSProfile != "DefaultCharger" {
- t.Errorf("Received: %+v", utils.ToJSON(rpl))
- }
- wgDisp2.Done()
- }()
- }
- wgDisp1.Wait()
- wgDisp2.Wait()
- expKeys := []string{"testRouteFromDispatcher1:*attributes",
- "testRouteFromDispatcher1:*chargers", "testRouteFromDispatcher2:*attributes",
- "testRouteFromDispatcher2:*chargers"}
- argsAPI = utils.ArgsGetCacheItemIDsWithAPIOpts{
- Tenant: "cgrates.org",
- ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
- CacheID: utils.CacheDispatcherRoutes,
- },
- }
- if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
- t.Error(err.Error())
- }
- sort.Strings(rcvKeys)
- sort.Strings(expKeys)
- if !reflect.DeepEqual(expKeys, rcvKeys) {
- t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
- }
- if err := dspEngine1RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
- t.Error(err.Error())
- }
- sort.Strings(rcvKeys)
- sort.Strings(expKeys)
- if !reflect.DeepEqual(expKeys, rcvKeys) {
- t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
- }
+// APIOpts: map[string]any{
+// utils.OptsRouteID: "testRouteFromDispatcher2",
+// },
+// }, &rpl); err != nil {
+// t.Error(err)
+// } else if rpl[0].ChargerSProfile != "DefaultCharger" {
+// t.Errorf("Received: %+v", utils.ToJSON(rpl))
+// }
+// wgDisp2.Done()
+// }()
+// }
+// wgDisp1.Wait()
+// wgDisp2.Wait()
+// expKeys := []string{"testRouteFromDispatcher1:*attributes",
+// "testRouteFromDispatcher1:*chargers", "testRouteFromDispatcher2:*attributes",
+// "testRouteFromDispatcher2:*chargers"}
+// argsAPI = utils.ArgsGetCacheItemIDsWithAPIOpts{
+// Tenant: "cgrates.org",
+// }
+// if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
+// t.Error(err.Error())
+// }
+// sort.Strings(rcvKeys)
+// sort.Strings(expKeys)
+// if !reflect.DeepEqual(expKeys, rcvKeys) {
+// t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
+// }
+// if err := dspEngine1RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
+// t.Error(err.Error())
+// }
+// sort.Strings(rcvKeys)
+// sort.Strings(expKeys)
+// if !reflect.DeepEqual(expKeys, rcvKeys) {
+// t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
+// }
- expKeys = []string{"cgrates.org:Engine2"}
- argsAPI = utils.ArgsGetCacheItemIDsWithAPIOpts{
- Tenant: "cgrates.org",
- ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
- CacheID: utils.CacheDispatcherLoads,
- },
- }
- if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
- t.Error(err.Error())
- }
- sort.Strings(rcvKeys)
- sort.Strings(expKeys)
- if !reflect.DeepEqual(expKeys, rcvKeys) {
- t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
- }
- if err := dspEngine1RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
- t.Error(err.Error())
- }
- sort.Strings(rcvKeys)
- sort.Strings(expKeys)
- if !reflect.DeepEqual(expKeys, rcvKeys) {
- t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
- }
-}
+// expKeys = []string{"cgrates.org:Engine2"}
+// argsAPI = utils.ArgsGetCacheItemIDsWithAPIOpts{
+// Tenant: "cgrates.org",
+// ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
+// CacheID: utils.CacheDispatcherLoads,
+// },
+// }
+// if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
+// t.Error(err.Error())
+// }
+// sort.Strings(rcvKeys)
+// sort.Strings(expKeys)
+// if !reflect.DeepEqual(expKeys, rcvKeys) {
+// t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
+// }
+// if err := dspEngine1RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
+// t.Error(err.Error())
+// }
+// sort.Strings(rcvKeys)
+// sort.Strings(expKeys)
+// if !reflect.DeepEqual(expKeys, rcvKeys) {
+// t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
+// }
+// }
-func testCacheRplCheckLoadReplication(t *testing.T) {
- var rcvKeys []string
- argsAPI := utils.ArgsGetCacheItemIDsWithAPIOpts{
- Tenant: "cgrates.org",
- ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
- CacheID: utils.CacheDispatcherLoads,
- },
- }
- if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
+// func testCacheRplCheckLoadReplication(t *testing.T) {
+// var rcvKeys []string
+// argsAPI := utils.ArgsGetCacheItemIDsWithAPIOpts{
+// Tenant: "cgrates.org",
+// ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
+// CacheID: utils.CacheDispatcherLoads,
+// },
+// }
+// if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err == nil || err.Error() != utils.ErrNotFound.Error() {
+// t.Error(err)
+// }
- var rpl []*engine.ChrgSProcessEventReply
- var wg sync.WaitGroup
- for i := 0; i < 10; i++ {
- wg.Add(1)
- go func() {
- if err := dspEngine1RPC.Call(context.Background(), utils.ChargerSv1ProcessEvent, &utils.CGREvent{
+// var rpl []*engine.ChrgSProcessEventReply
+// var wg sync.WaitGroup
+// for i := 0; i < 10; i++ {
+// wg.Add(1)
+// go func() {
+// if err := dspEngine1RPC.Call(context.Background(), utils.ChargerSv1ProcessEvent, &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testCacheRplCheckLoadReplication",
- Event: map[string]any{
- utils.AccountField: "1007",
- utils.Destination: "+491511231234",
- "EventName": "TestLoad",
- },
+// Tenant: "cgrates.org",
+// ID: "testCacheRplCheckLoadReplication",
+// Event: map[string]any{
+// utils.AccountField: "1007",
+// utils.Destination: "+491511231234",
+// "EventName": "TestLoad",
+// },
- APIOpts: map[string]any{
- utils.OptsRouteID: "testRoute123",
- },
- }, &rpl); err != nil {
- t.Error(err)
- } else if rpl[0].ChargerSProfile != "DefaultCharger" {
- t.Errorf("Received: %+v", utils.ToJSON(rpl))
- }
- wg.Done()
- }()
- }
- wg.Wait()
- expKeys := []string{"testRoute123:*core", "testRoute123:*attributes", "testRoute123:*chargers"}
- argsAPI = utils.ArgsGetCacheItemIDsWithAPIOpts{
- Tenant: "cgrates.org",
- ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
- CacheID: utils.CacheDispatcherRoutes,
- },
- }
- if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
- t.Error(err.Error())
- }
- sort.Strings(rcvKeys)
- sort.Strings(expKeys)
- if !reflect.DeepEqual(expKeys, rcvKeys) {
- t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
- }
+// APIOpts: map[string]any{
+// utils.OptsRouteID: "testRoute123",
+// },
+// }, &rpl); err != nil {
+// t.Error(err)
+// } else if rpl[0].ChargerSProfile != "DefaultCharger" {
+// t.Errorf("Received: %+v", utils.ToJSON(rpl))
+// }
+// wg.Done()
+// }()
+// }
+// wg.Wait()
+// expKeys := []string{"testRoute123:*core", "testRoute123:*attributes", "testRoute123:*chargers"}
+// argsAPI = utils.ArgsGetCacheItemIDsWithAPIOpts{
+// Tenant: "cgrates.org",
+// ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
+// CacheID: utils.CacheDispatcherRoutes,
+// },
+// }
+// if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
+// t.Error(err.Error())
+// }
+// sort.Strings(rcvKeys)
+// sort.Strings(expKeys)
+// if !reflect.DeepEqual(expKeys, rcvKeys) {
+// t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
+// }
- expKeys = []string{"cgrates.org:Engine2"}
- argsAPI = utils.ArgsGetCacheItemIDsWithAPIOpts{
- Tenant: "cgrates.org",
- ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
- CacheID: utils.CacheDispatcherLoads,
- },
- }
- if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
- t.Error(err.Error())
- }
- sort.Strings(rcvKeys)
- sort.Strings(expKeys)
- if !reflect.DeepEqual(expKeys, rcvKeys) {
- t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
- }
+// expKeys = []string{"cgrates.org:Engine2"}
+// argsAPI = utils.ArgsGetCacheItemIDsWithAPIOpts{
+// Tenant: "cgrates.org",
+// ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
+// CacheID: utils.CacheDispatcherLoads,
+// },
+// }
+// if err := dspEngine2RPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
+// t.Error(err.Error())
+// }
+// sort.Strings(rcvKeys)
+// sort.Strings(expKeys)
+// if !reflect.DeepEqual(expKeys, rcvKeys) {
+// t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys)
+// }
-}
+// }
func testCacheRplStopEngine(t *testing.T) {
if err := engine.KillEngine(*utils.WaitRater); err != nil {
diff --git a/general_tests/dispatcher_opts_it_test.go b/general_tests/dispatcher_opts_it_test.go
deleted file mode 100644
index 90bdd9146..000000000
--- a/general_tests/dispatcher_opts_it_test.go
+++ /dev/null
@@ -1,748 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package general_tests
-
-import (
- "path"
- "reflect"
- "testing"
- "time"
-
- "github.com/cgrates/birpc"
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var (
- dspOptsCfgPath string
- adminsCfgPath string
- dspOptsCfg *config.CGRConfig
- adminsCfg *config.CGRConfig
- dspOptsRPC *birpc.Client
- adminsRPC *birpc.Client
- dspOptsConfigDIR string
- dpsOptsTest = []func(t *testing.T){
- // FIRST APRT OF THE TEST
- // Start engine without Dispatcher on engine 4012
- testDispatcherOptsAdminInitCfg,
- testDispatcherOptsAdminFlushDBs,
- testDispatcherOptsAdminStartEngine,
- testDispatcherOptsAdminRPCConn,
-
- // Sending Status requests in both engines, with *dispatchers:false
- testDispatcherOptsDSPInitCfg,
- testDispatcherOptsDSPStartEngine,
- testDispatcherOptsDSPRPCConn,
-
- testDispatcherOptsCoreStatus, // *disaptchers:false
- testDispatcherAdminCoreStatus, // *disaptchers:false
-
- testDispatcherGetItemBothEnginesFirstAttempt, // NOT FOUND
-
- testDispatcherOptsDSPStopEngine,
- testDispatcherOptsAdminStopEngine,
-
- // SECOND PART OF THE TEST
- // START HOST2 engine
- testDispatcherOptsAdminStartEngine,
- testDispatcherOptsAdminRPCConn,
-
- testDispatcherOptsAdminSetDispatcherProfile, // contains both hosts, HOST1 prio, host2 backup
-
- testDispatcherAdminCoreStatusWithRouteID, // HOST2 matched because HOST1 is not started yet
- testDispatcherAdminGetItemHOST2,
-
- // START HOST1 engine
- testDispatcherOptsDSPStartEngine,
- testDispatcherOptsDSPRPCConn,
- testDispatcherAdminCoreStatusWithRouteID, // same HOST2 will be matched, due to routeID
-
- // clear cache in order to remove routeID
- testDisaptcherCacheClear,
- testDispatcherAdminCoreStatusWithRouteIDButHost1, // due to clearing cache, HOST1 will be matched
-
- // verify cache of dispatchers, SetDispatcherProfile API should reload the dispatchers cache (instance, profile and route)
- testDispatcherAdminCheckCacheAfterRouting,
- testDispatcherSetDispatcherProfileOverwrite,
- testDispatcherCheckCacheAfterSetDispatcherDSP1,
- testDispatcherSetAnotherProifle, //DSP2
- testDispatcherCheckCacheAfterSetDispatcherDSP1, //we set DSP2, so for DSP1 nothing changed
- testDispatcherCheckCacheAfterSetDispatcherDSP2, //NOT_FOUND for every get, cause it was not used that profile before
-
- testDispatcherOptsDSPStopEngine,
- testDispatcherOptsAdminStopEngine,
- }
-)
-
-func TestDispatcherOpts(t *testing.T) {
- for _, test := range dpsOptsTest {
- t.Run(dspOptsConfigDIR, test)
- }
-}
-
-func testDispatcherOptsAdminInitCfg(t *testing.T) {
- dspOptsConfigDIR = "dispatcher_opts_admin"
- var err error
- adminsCfgPath = path.Join(*utils.DataDir, "conf", "samples", dspOptsConfigDIR)
- adminsCfg, err = config.NewCGRConfigFromPath(context.Background(), adminsCfgPath)
- if err != nil {
- t.Error(err)
- }
-}
-
-func testDispatcherOptsAdminFlushDBs(t *testing.T) {
- if err := engine.InitDataDB(adminsCfg); err != nil {
- t.Fatal(err)
- }
- if err := engine.InitStorDB(adminsCfg); err != nil {
- t.Fatal(err)
- }
-}
-
-// Start CGR Engine woth Dispatcher enabled
-func testDispatcherOptsAdminStartEngine(t *testing.T) {
- if _, err := engine.StartEngine(adminsCfgPath, *utils.WaitRater); err != nil {
- t.Fatal(err)
- }
-}
-
-func testDispatcherOptsAdminRPCConn(t *testing.T) {
- adminsRPC = engine.NewRPCClient(t, adminsCfg.ListenCfg(), *utils.Encoding)
-}
-
-func testDispatcherOptsDSPInitCfg(t *testing.T) {
- dspOptsConfigDIR = "dispatcher_opts" //changed with the cfg with dispatcher on
- var err error
- dspOptsCfgPath = path.Join(*utils.DataDir, "conf", "samples", dspOptsConfigDIR)
- dspOptsCfg, err = config.NewCGRConfigFromPath(context.Background(), dspOptsCfgPath)
- if err != nil {
- t.Error(err)
- }
-}
-
-// Start CGR Engine woth Dispatcher enabled
-func testDispatcherOptsDSPStartEngine(t *testing.T) {
- if _, err := engine.StartEngine(dspOptsCfgPath, *utils.WaitRater); err != nil {
- t.Fatal(err)
- }
-}
-
-func testDispatcherOptsDSPRPCConn(t *testing.T) {
- dspOptsRPC = engine.NewRPCClient(t, dspOptsCfg.ListenCfg(), *utils.Encoding)
-}
-
-func testDispatcherOptsCoreStatus(t *testing.T) {
- // HOST1 host matched
- var reply map[string]any
- ev := utils.TenantWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- }
- if err := dspOptsRPC.Call(context.Background(), utils.CoreSv1Status, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply[utils.NodeID] != "HOST1" {
- t.Errorf("Expected HOST1, received %v", reply[utils.NodeID])
- }
-}
-
-func testDispatcherAdminCoreStatus(t *testing.T) {
- // HOST2 host matched because it was called from engine with port :4012 -> host2
- var reply map[string]any
- ev := utils.TenantWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsRouteID: "account#dan.bogos",
- utils.MetaDispatchers: false,
- },
- }
- if err := adminsRPC.Call(context.Background(), utils.CoreSv1Status, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply[utils.NodeID] != "HOST2" {
- t.Errorf("Expected HOST2, received %v", reply[utils.NodeID])
- }
-}
-
-func testDispatcherGetItemBothEnginesFirstAttempt(t *testing.T) {
- // get for *dispatcher_routes
- argsCache := &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatcherRoutes,
- ItemID: "account#dan.bogos:*core",
- },
- }
- var reply any
- if err := dspOptsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-
- // get for *dispatcher_profiles
- argsCache = &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatcherProfiles,
- ItemID: "cgrates.org:DSP1",
- },
- }
- if err := dspOptsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-
- // get for *dispatchers
- argsCache = &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatchers,
- ItemID: "cgrates.org:DSP1",
- },
- }
- if err := dspOptsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-}
-
-func testDispatcherOptsAdminSetDispatcherProfile(t *testing.T) {
- // Set DispatcherHost
- var replyStr string
- setDispatcherHost := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "HOST1",
- Address: "127.0.0.1:2012", // CGR1
- Transport: "*json",
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- },
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- }
- if err := adminsRPC.Call(context.Background(), utils.AdminSv1SetDispatcherHost, setDispatcherHost, &replyStr); err != nil {
- t.Error("Unexpected error when calling AdminSv1.SetDispatcherHost: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- setDispatcherHost = &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "HOST2",
- Address: "127.0.0.1:4012", // CGR2
- Transport: "*json",
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- },
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- }
- if err := adminsRPC.Call(context.Background(), utils.AdminSv1SetDispatcherHost, setDispatcherHost, &replyStr); err != nil {
- t.Error("Unexpected error when calling AdminSv1.SetDispatcherHost: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Set DispatcherProfile
- setDispatcherProfile := &engine.DispatcherProfileWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DSP1",
- Strategy: "*weight",
- Weight: 10,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "HOST1",
- Weight: 10,
- },
- {
- ID: "HOST2",
- Weight: 5,
- },
- },
- },
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- }
- if err := adminsRPC.Call(context.Background(), utils.AdminSv1SetDispatcherProfile, setDispatcherProfile, &replyStr); err != nil {
- t.Error("Unexpected error when calling AdminSv1.SetDispatcherProfile: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-}
-
-func testDispatcherAdminCoreStatusWithRouteID(t *testing.T) {
- var reply map[string]any
- ev := utils.TenantWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsRouteID: "account#dan.bogos",
- },
- }
- if err := adminsRPC.Call(context.Background(), utils.CoreSv1Status, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply[utils.NodeID] != "HOST2" {
- t.Errorf("Expected HOST2, received %v", reply[utils.NodeID])
- }
-}
-
-func testDispatcherAdminGetItemHOST2(t *testing.T) {
- // get for *dispatcher_routes
- argsCache := &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatcherRoutes,
- ItemID: "account#dan.bogos:*core",
- },
- }
- var reply any
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err != nil {
- t.Error(err)
- } else {
- expected := map[string]any{
- utils.Tenant: "cgrates.org",
- utils.ProfileID: "DSP1",
- "HostID": "HOST2",
- }
- if !reflect.DeepEqual(expected, reply) {
- t.Errorf("Expected %+v, \n received %+v", utils.ToJSON(expected), utils.ToJSON(reply))
- }
- }
-
- // get for *dispatcher_profiles
- argsCache = &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatcherProfiles,
- ItemID: "cgrates.org:DSP1",
- },
- }
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err != nil {
- t.Error(err)
- } else {
- expected := map[string]any{
- utils.FilterIDs: nil,
- utils.Hosts: []any{
- map[string]any{
- utils.Blocker: false,
- utils.FilterIDs: nil,
- utils.ID: "HOST1",
- utils.Params: nil,
- utils.Weight: 10.,
- },
- map[string]any{
- utils.Blocker: false,
- utils.FilterIDs: nil,
- utils.ID: "HOST2",
- utils.Params: nil,
- utils.Weight: 5.,
- },
- },
- utils.ID: "DSP1",
- utils.Strategy: "*weight",
- utils.StrategyParams: nil,
- utils.Tenant: "cgrates.org",
- utils.Weight: 10.,
- }
- if !reflect.DeepEqual(expected, reply) {
- t.Errorf("Expected %+v, \n received %+v", expected, reply)
- }
- }
-
- // get for *dispatchers
- argsCache = &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatchers,
- ItemID: "cgrates.org:DSP1",
- },
- }
- // reply here is an interface type(singleResultDispatcher), it exists
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err != nil {
- t.Error(err)
- }
-}
-
-func testDisaptcherCacheClear(t *testing.T) {
- var reply string
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1Clear, &utils.AttrCacheIDsWithAPIOpts{
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- }, &reply); err != nil {
- t.Fatal(err)
- } else if reply != utils.OK {
- t.Errorf("Unexpected reply returned")
- }
-}
-
-func testDispatcherAdminCoreStatusWithRouteIDButHost1(t *testing.T) {
- var reply map[string]any
- ev := utils.TenantWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.OptsRouteID: "account#dan.bogos",
- },
- }
- if err := adminsRPC.Call(context.Background(), utils.CoreSv1Status, &ev, &reply); err != nil {
- t.Error(err)
- } else if reply[utils.NodeID] != "HOST1" {
- t.Errorf("Expected HOST1, received %v", reply[utils.NodeID])
- }
-}
-
-func testDispatcherAdminCheckCacheAfterRouting(t *testing.T) {
- // get for *dispatcher_routes
- argsCache := &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatcherRoutes,
- ItemID: "account#dan.bogos:*core",
- },
- }
- var reply any
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err != nil {
- t.Error(err)
- } else {
- expected := map[string]any{
- utils.Tenant: "cgrates.org",
- utils.ProfileID: "DSP1",
- "HostID": "HOST1",
- }
- if !reflect.DeepEqual(expected, reply) {
- t.Errorf("Expected %+v, \n received %+v", utils.ToJSON(expected), utils.ToJSON(reply))
- }
- }
-
- // get for *dispatcher_profiles
- argsCache = &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatcherProfiles,
- ItemID: "cgrates.org:DSP1",
- },
- }
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err != nil {
- t.Error(err)
- } else {
- expected := map[string]any{
- utils.FilterIDs: nil,
- utils.Hosts: []any{
- map[string]any{
- utils.Blocker: false,
- utils.FilterIDs: nil,
- utils.ID: "HOST1",
- utils.Params: nil,
- utils.Weight: 10.,
- },
- map[string]any{
- utils.Blocker: false,
- utils.FilterIDs: nil,
- utils.ID: "HOST2",
- utils.Params: nil,
- utils.Weight: 5.,
- },
- },
- utils.ID: "DSP1",
- utils.Strategy: "*weight",
- utils.StrategyParams: nil,
- utils.Tenant: "cgrates.org",
- utils.Weight: 10.,
- }
- if !reflect.DeepEqual(expected, reply) {
- t.Errorf("Expected %+v, \n received %+v", expected, reply)
- }
- }
-
- // get for *dispatchers
- argsCache = &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatchers,
- ItemID: "cgrates.org:DSP1",
- },
- }
- // reply here is an interface type(singleResultDispatcher), it exists
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err != nil {
- t.Error(err)
- }
-}
-
-func testDispatcherSetDispatcherProfileOverwrite(t *testing.T) {
- // as the cache was cleard, now that previously the HOST1 was matched, setting the profile wiht only HOST2 will remove the
- // DispatcherRoutes, DispatcherProfile and the DispatcherInstance
- var replyStr string
- // Set DispatcherProfile
- setDispatcherProfile := &engine.DispatcherProfileWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DSP1",
- Strategy: "*weight",
- Weight: 10,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "HOST2",
- Weight: 5,
- },
- },
- },
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- }
- if err := adminsRPC.Call(context.Background(), utils.AdminSv1SetDispatcherProfile, setDispatcherProfile, &replyStr); err != nil {
- t.Error("Unexpected error when calling AdminSv1.SetDispatcherProfile: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-}
-
-func testDispatcherCheckCacheAfterSetDispatcherDSP1(t *testing.T) {
- // get for *dispatcher_routes
- argsCache := &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatcherRoutes,
- ItemID: "account#dan.bogos:*core",
- },
- }
- var reply any // Should receive NOT_FOUND, as CallCache that was called in API will remove the DispatcherRoute
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Unexpected error returned: %v", err)
- }
-
- // get for *dispatcher_profiles
- argsCache = &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatcherProfiles,
- ItemID: "cgrates.org:DSP1",
- },
- }
- // as the DSP1 profile was overwritten, only HOST2 in profile will be contained
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err != nil {
- t.Error(err)
- } else {
- expected := map[string]any{
- utils.FilterIDs: nil,
- utils.Hosts: []any{
- map[string]any{
- utils.Blocker: false,
- utils.FilterIDs: nil,
- utils.ID: "HOST2",
- utils.Params: nil,
- utils.Weight: 5.,
- },
- },
- utils.ID: "DSP1",
- utils.Strategy: "*weight",
- utils.StrategyParams: nil,
- utils.Tenant: "cgrates.org",
- utils.Weight: 10.,
- }
- if !reflect.DeepEqual(expected, reply) {
- t.Errorf("Expected %+v, \n received %+v", utils.ToJSON(expected), utils.ToJSON(reply))
- }
- }
-
- // get for *dispatchers
- argsCache = &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatchers,
- ItemID: "cgrates.org:DSP1",
- },
- }
- // DispatcherInstance should also be removed, so it will be NOT_FOUND
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Unexpected error returned: %v", err)
- }
-}
-
-func testDispatcherSetAnotherProifle(t *testing.T) {
- var replyStr string
- // Set DispatcherProfile DSP2 with the existing hosts
- setDispatcherProfile := &engine.DispatcherProfileWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DSP2",
- Strategy: "*weight",
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "HOST1",
- Weight: 50,
- },
- {
- ID: "HOST2",
- Weight: 125,
- },
- },
- },
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- }
- if err := adminsRPC.Call(context.Background(), utils.AdminSv1SetDispatcherProfile, setDispatcherProfile, &replyStr); err != nil {
- t.Error("Unexpected error when calling AdminSv1.SetDispatcherProfile: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-}
-
-func testDispatcherCheckCacheAfterSetDispatcherDSP2(t *testing.T) {
- // get for *dispatcher_routes
- argsCache := &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatcherRoutes,
- ItemID: "account#dan.bogos:*core",
- },
- }
- var reply any
- // NOT_FOUND
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Unexpected error returned: %v", err)
- }
-
- // get for *dispatcher_profiles
- argsCache = &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatcherProfiles,
- ItemID: "cgrates.org:DSP2",
- },
- }
- // NOT_FOUND
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Unexpected error returned: %v", err)
- }
-
- // get for *dispatchers
- argsCache = &utils.ArgsGetCacheItemWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{
- utils.MetaDispatchers: false,
- },
- ArgsGetCacheItem: utils.ArgsGetCacheItem{
- CacheID: utils.CacheDispatchers,
- ItemID: "cgrates.org:DSP2",
- },
- }
- // NOT_FOUND
- if err := adminsRPC.Call(context.Background(), utils.CacheSv1GetItemWithRemote, argsCache,
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Unexpected error returned: %v", err)
- }
-}
-
-func testDispatcherOptsDSPStopEngine(t *testing.T) {
- if err := engine.KillEngine(*utils.WaitRater); err != nil {
- t.Error(err)
- }
-}
-
-func testDispatcherOptsAdminStopEngine(t *testing.T) {
- if err := engine.KillEngine(*utils.WaitRater); err != nil {
- t.Error(err)
- }
-}
diff --git a/general_tests/doubleremove_it_test.go b/general_tests/doubleremove_it_test.go
index 621d19eb7..b1e8b38ed 100644
--- a/general_tests/doubleremove_it_test.go
+++ b/general_tests/doubleremove_it_test.go
@@ -52,8 +52,6 @@ var (
testdoubleRemoveAttributeProfile,
testdoubleRemoveChargerProfile,
testdoubleRemoveResourceProfile,
- testdoubleRemoveDispatcherProfile,
- testdoubleRemoveDispatcherHost,
testdoubleRemoveRateProfile,
testdoubleRemoveActionProfile,
@@ -506,117 +504,6 @@ func testdoubleRemoveResourceProfile(t *testing.T) {
}
}
-func testdoubleRemoveDispatcherProfile(t *testing.T) {
- // check
- var reply *engine.DispatcherProfile
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1GetDispatcherProfile,
- &utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_PRF"}, &reply); err == nil ||
- err.Error() != utils.ErrDSPProfileNotFound.Error() {
- t.Error(err)
- }
- // set
- dspPrf := &engine.DispatcherProfileWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: doubleRemoveTenant,
- ID: "DSP_PRF",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- },
- }
- var result string
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1SetDispatcherProfile, dspPrf, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
- //check
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1GetDispatcherProfile,
- &utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_PRF"}, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(dspPrf.DispatcherProfile, reply) {
- t.Errorf("Expecting: %+v, received: %+v", dspPrf.DispatcherProfile, reply)
- }
-
- //remove
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1RemoveDispatcherProfile,
- &utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_PRF"}, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1RemoveDispatcherProfile,
- &utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_PRF"}, &result); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1RemoveDispatcherProfile,
- &utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_PRF"}, &result); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
- // check
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1GetDispatcherProfile,
- &utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_PRF"}, &reply); err == nil ||
- err.Error() != utils.ErrDSPProfileNotFound.Error() {
- t.Error(err)
- }
-}
-
-func testdoubleRemoveDispatcherHost(t *testing.T) {
- // check
- var reply *engine.DispatcherHost
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1GetDispatcherHost,
- &utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_HOST"}, &reply); err == nil ||
- err.Error() != utils.ErrDSPHostNotFound.Error() {
- t.Error(err)
- }
- // set
- dspHost := &engine.DispatcherHostWithAPIOpts{
- DispatcherHost: &engine.DispatcherHost{
- Tenant: doubleRemoveTenant,
- RemoteHost: &config.RemoteHost{
- ID: "DSP_HOST",
- },
- },
- }
- var result string
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1SetDispatcherHost, dspHost, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
- //check
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1GetDispatcherHost,
- &utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_HOST"}, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(dspHost.DispatcherHost, reply) {
- t.Errorf("Expecting: %+v, received: %+v", dspHost.DispatcherHost, reply)
- }
-
- //remove
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1RemoveDispatcherHost,
- &utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_HOST"}, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1RemoveDispatcherHost,
- &utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_HOST"}, &result); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1RemoveDispatcherHost,
- &utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_HOST"}, &result); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
- // check
- if err := doubleRemoveRPC.Call(context.Background(), utils.AdminSv1GetDispatcherHost,
- &utils.TenantID{Tenant: doubleRemoveTenant, ID: "DSP_HOST"}, &reply); err == nil ||
- err.Error() != utils.ErrDSPHostNotFound.Error() {
- t.Error(err)
- }
-}
-
func testdoubleRemoveRateProfile(t *testing.T) {
// check
var reply *utils.RateProfile
diff --git a/general_tests/set_rmv_prfl_dlay_it_test.go b/general_tests/set_rmv_prfl_dlay_it_test.go
index dd736ec12..62a887b9b 100644
--- a/general_tests/set_rmv_prfl_dlay_it_test.go
+++ b/general_tests/set_rmv_prfl_dlay_it_test.go
@@ -24,7 +24,6 @@ import (
"github.com/cgrates/birpc/context"
"github.com/cgrates/birpc/jsonrpc"
- "github.com/cgrates/cgrates/apis"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
@@ -122,52 +121,6 @@ func TestSetRemoveProfilesWithCachingDelay(t *testing.T) {
}
})
- t.Run("SetDispatcherProfile", func(t *testing.T) {
-
- eDspPrf := &apis.DispatcherWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DSP_1",
- },
- }
-
- var result string
- startTime := time.Now()
- if err := client.Call(context.Background(), utils.AdminSv1SetDispatcherProfile, eDspPrf, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
- elapsedTime := time.Since(startTime)
- expectedDuration := 3 * time.Second
- if elapsedTime < expectedDuration || elapsedTime >= 4*time.Second {
- t.Errorf("Expected elapsed time of at least %v, but got %v", expectedDuration, elapsedTime)
- }
- })
-
- t.Run("RemoveDispatcherProfile", func(t *testing.T) {
-
- eDspPrf := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "DSP_1",
- },
- }
-
- var result string
- startTime := time.Now()
- if err := client.Call(context.Background(), utils.AdminSv1RemoveDispatcherProfile, eDspPrf, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
- elapsedTime := time.Since(startTime)
- expectedDuration := 1 * time.Second
- if elapsedTime < expectedDuration || elapsedTime >= 2*time.Second {
- t.Errorf("Expected elapsed time of at least %v, but got %v", expectedDuration, elapsedTime)
- }
- })
-
t.Run("SetResourceProfile", func(t *testing.T) {
eRscPrf := &engine.ResourceProfileWithAPIOpts{
@@ -491,29 +444,6 @@ func TestSetRemoveProfilesWithCachingDelay(t *testing.T) {
}
})
- t.Run("ReplicatorSv1SetDispatcherProfile", func(t *testing.T) {
-
- eDspPrf := &engine.DispatcherProfileWithAPIOpts{
- DispatcherProfile: &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "DSP_1",
- },
- }
-
- var result string
- startTime := time.Now()
- if err := client.Call(context.Background(), utils.ReplicatorSv1SetDispatcherProfile, eDspPrf, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
- elapsedTime := time.Since(startTime)
- expectedDuration := 1 * time.Second
- if elapsedTime < expectedDuration || elapsedTime >= 2*time.Second {
- t.Errorf("Expected elapsed time of at least %v, but got %v", expectedDuration, elapsedTime)
- }
- })
-
t.Run("ReplicatorSv1RemoveThresholdProfile", func(t *testing.T) {
eTHPrf := &utils.TenantIDWithAPIOpts{
diff --git a/general_tests/tut_smgeneric_it_test.go b/general_tests/tut_smgeneric_it_test.go
index bb56499ae..c5f4253a2 100644
--- a/general_tests/tut_smgeneric_it_test.go
+++ b/general_tests/tut_smgeneric_it_test.go
@@ -157,7 +157,7 @@ func testTutSMGCacheStats(t *testing.T) {
expectedStats[utils.CacheRouteProfiles].Items = 12
expectedStats[utils.CacheAttributeProfiles].Items = 8
expectedStats[utils.MetaDefault].Items = 0
- expectedStats[utils.CacheLoadIDs].Items = 32
+ expectedStats[utils.CacheLoadIDs].Items = 28
expectedStats[utils.CacheChargerProfiles].Items = 3
expectedStats[utils.CacheRPCConnections].Items = 1
expectedStats[utils.CacheThresholdFilterIndexes].Items = 1
diff --git a/loaders/libloader.go b/loaders/libloader.go
index 2d8acde86..76f1c5f36 100644
--- a/loaders/libloader.go
+++ b/loaders/libloader.go
@@ -289,20 +289,6 @@ func newProfileFunc(lType string) func() profile {
return func() profile {
return new(engine.ChargerProfile)
}
- case utils.MetaDispatchers:
- return func() profile {
- return &engine.DispatcherProfile{
- StrategyParams: make(map[string]any),
- }
- }
- case utils.MetaDispatcherHosts:
- return func() profile {
- return &engine.DispatcherHost{
- RemoteHost: &config.RemoteHost{
- Transport: utils.MetaJSON,
- },
- }
- }
case utils.MetaRateProfiles:
return func() profile {
return &utils.RateProfile{
diff --git a/loaders/loader.go b/loaders/loader.go
index f013e0bba..7346521ad 100644
--- a/loaders/loader.go
+++ b/loaders/loader.go
@@ -59,10 +59,6 @@ func removeFromDB(ctx *context.Context, dm *engine.DataManager, lType string, wi
return dm.RemoveRouteProfile(ctx, tnt, id, withIndex)
case utils.MetaChargers:
return dm.RemoveChargerProfile(ctx, tnt, id, withIndex)
- case utils.MetaDispatchers:
- return dm.RemoveDispatcherProfile(ctx, tnt, id, withIndex)
- case utils.MetaDispatcherHosts:
- return dm.RemoveDispatcherHost(ctx, tnt, id)
case utils.MetaRateProfiles:
if ratesPartial {
rt := obj.(*utils.RateProfile)
@@ -102,10 +98,6 @@ func setToDB(ctx *context.Context, dm *engine.DataManager, lType string, data pr
return dm.SetRouteProfile(ctx, data.(*engine.RouteProfile), withIndex)
case utils.MetaChargers:
return dm.SetChargerProfile(ctx, data.(*engine.ChargerProfile), withIndex)
- case utils.MetaDispatchers:
- return dm.SetDispatcherProfile(ctx, data.(*engine.DispatcherProfile), withIndex)
- case utils.MetaDispatcherHosts:
- return dm.SetDispatcherHost(ctx, data.(*engine.DispatcherHost))
case utils.MetaRateProfiles:
rpl := data.(*utils.RateProfile)
if ratesPartial {
@@ -151,10 +143,6 @@ func dryRun(ctx *context.Context, lType, ldrID string, obj profile) (err error)
msg = "<%s-%s> DRY_RUN: RouteProfile: %s"
case utils.MetaChargers:
msg = "<%s-%s> DRY_RUN: ChargerProfile: %s"
- case utils.MetaDispatchers:
- msg = "<%s-%s> DRY_RUN: DispatcherProfile: %s"
- case utils.MetaDispatcherHosts:
- msg = "<%s-%s> DRY_RUN: DispatcherHost: %s"
case utils.MetaRateProfiles:
msg = "<%s-%s> DRY_RUN: RateProfile: %s"
case utils.MetaActionProfiles:
@@ -242,11 +230,6 @@ func (l *loader) process(ctx *context.Context, obj profile, lType, action string
case utils.MetaChargers:
cacheIDs = []string{utils.CacheChargerFilterIndexes}
cacheArgs[utils.CacheChargerProfiles] = []string{tntId}
- case utils.MetaDispatchers:
- cacheIDs = []string{utils.CacheDispatcherFilterIndexes}
- cacheArgs[utils.CacheDispatcherProfiles] = []string{tntId}
- case utils.MetaDispatcherHosts:
- cacheArgs[utils.CacheDispatcherHosts] = []string{tntId}
case utils.MetaRateProfiles:
cacheIDs = []string{utils.CacheRateProfilesFilterIndexes, utils.CacheRateFilterIndexes}
cacheArgs[utils.CacheRateProfiles] = []string{tntId}
diff --git a/loaders/loader_test.go b/loaders/loader_test.go
index 5e5258e08..c7342ab87 100644
--- a/loaders/loader_test.go
+++ b/loaders/loader_test.go
@@ -46,7 +46,7 @@ func TestRemoveFromDB(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
dm := engine.NewDataManager(engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items), cfg.CacheCfg(), nil)
for _, lType := range []string{utils.MetaAttributes, utils.MetaResources, utils.MetaFilters, utils.MetaStats,
- utils.MetaThresholds, utils.MetaRoutes, utils.MetaChargers, utils.MetaDispatchers, utils.MetaDispatcherHosts,
+ utils.MetaThresholds, utils.MetaRoutes, utils.MetaChargers,
utils.MetaRateProfiles, utils.MetaActionProfiles, utils.MetaAccounts} {
if err := removeFromDB(context.Background(), dm, lType, true, false, profileTest{utils.Tenant: "cgrates.org", utils.ID: "ID"}); err != utils.ErrNotFound &&
err != utils.ErrDSPProfileNotFound && err != utils.ErrDSPHostNotFound {
@@ -126,10 +126,6 @@ func TestDryRun(t *testing.T) {
testDryRun(t, utils.MetaChargers); !strings.Contains(rplyLog, expLog) {
t.Errorf("Expected %+q, received %+q", expLog, rplyLog)
}
- if expLog, rplyLog := "[INFO] DRY_RUN: DispatcherProfile: {\"ID\":\"ID\",\"Tenant\":\"cgrates.org\"}",
- testDryRun(t, utils.MetaDispatchers); !strings.Contains(rplyLog, expLog) {
- t.Errorf("Expected %+q, received %+q", expLog, rplyLog)
- }
if expLog, rplyLog := "[INFO] DRY_RUN: RateProfile: {\"ID\":\"ID\",\"Tenant\":\"cgrates.org\"}",
testDryRun(t, utils.MetaRateProfiles); !strings.Contains(rplyLog, expLog) {
@@ -143,10 +139,6 @@ func TestDryRun(t *testing.T) {
testDryRun(t, utils.MetaAccounts); !strings.Contains(rplyLog, expLog) {
t.Errorf("Expected %+q, received %+q", expLog, rplyLog)
}
- if expLog, rplyLog := "[INFO] DRY_RUN: DispatcherHost: {\"ID\":\"ID\",\"Tenant\":\"cgrates.org\"}",
- testDryRun(t, utils.MetaDispatcherHosts); !strings.Contains(rplyLog, expLog) {
- t.Errorf("Expected %+q, received %+q", expLog, rplyLog)
- }
expErrMsg := `empty RSRParser in rule: <>`
if _, err := testDryRunWithData(utils.MetaFilters, &engine.Filter{
@@ -176,9 +168,6 @@ func TestSetToDBWithDBError(t *testing.T) {
if err := setToDB(context.Background(), nil, utils.MetaChargers, newProfileFunc(utils.MetaChargers)(), true, false); err != utils.ErrNoDatabaseConn {
t.Fatal(err)
}
- if err := setToDB(context.Background(), nil, utils.MetaDispatchers, newProfileFunc(utils.MetaDispatchers)(), true, false); err != utils.ErrNoDatabaseConn {
- t.Fatal(err)
- }
if err := setToDB(context.Background(), nil, utils.MetaActionProfiles, newProfileFunc(utils.MetaActionProfiles)(), true, false); err != utils.ErrNoDatabaseConn {
t.Fatal(err)
@@ -190,9 +179,7 @@ func TestSetToDBWithDBError(t *testing.T) {
if err := setToDB(context.Background(), nil, utils.MetaRoutes, newProfileFunc(utils.MetaRoutes)(), true, false); err != utils.ErrNoDatabaseConn {
t.Fatal(err)
}
- if err := setToDB(context.Background(), nil, utils.MetaDispatcherHosts, newProfileFunc(utils.MetaDispatcherHosts)(), true, false); err != utils.ErrNoDatabaseConn {
- t.Fatal(err)
- }
+
if err := setToDB(context.Background(), nil, utils.MetaRateProfiles, newProfileFunc(utils.MetaRateProfiles)(), true, false); err != utils.ErrNoDatabaseConn {
t.Fatal(err)
}
@@ -259,16 +246,6 @@ func TestSetToDB(t *testing.T) {
t.Errorf("Expected: %v, received: %v", utils.ToJSON(v5), utils.ToJSON(prf))
}
- v6 := &engine.DispatcherProfile{Tenant: "cgrates.org", ID: "ID", StrategyParams: make(map[string]any)}
- if err := setToDB(context.Background(), dm, utils.MetaDispatchers, v6, true, false); err != nil {
- t.Fatal(err)
- }
- if prf, err := dm.GetDispatcherProfile(context.Background(), "cgrates.org", "ID", true, true, utils.NonTransactional); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(v6, prf) {
- t.Errorf("Expected: %v, received: %v", utils.ToJSON(v6), utils.ToJSON(prf))
- }
-
v7 := &engine.ActionProfile{Tenant: "cgrates.org", ID: "ID", Targets: map[string]utils.StringSet{}}
if err := setToDB(context.Background(), dm, utils.MetaActionProfiles, v7, true, false); err != nil {
t.Fatal(err)
@@ -300,16 +277,6 @@ func TestSetToDB(t *testing.T) {
t.Errorf("Expected: %v, received: %v", utils.ToJSON(v9), utils.ToJSON(prf))
}
- v10 := &engine.DispatcherHost{Tenant: "cgrates.org", RemoteHost: &config.RemoteHost{ID: "ID", Address: "127.0.0.1", Transport: utils.MetaJSON}}
- if err := setToDB(context.Background(), dm, utils.MetaDispatcherHosts, v10, true, false); err != nil {
- t.Fatal(err)
- }
- if prf, err := dm.GetDispatcherHost(context.Background(), "cgrates.org", "ID", true, true, utils.NonTransactional); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(v10, prf) {
- t.Errorf("Expected: %v, received: %v", utils.ToJSON(v10), utils.ToJSON(prf))
- }
-
v11 := &utils.RateProfile{Tenant: "cgrates.org", ID: "ID", Rates: map[string]*utils.Rate{}, MinCost: utils.NewDecimal(0, 0), MaxCost: utils.NewDecimal(0, 0)}
if err := setToDB(context.Background(), dm, utils.MetaRateProfiles, v11, true, false); err != nil {
t.Fatal(err)
@@ -611,35 +578,6 @@ func TestLoaderProcessCallCahe(t *testing.T) {
}
}
- {
- v := &engine.DispatcherProfile{Tenant: "cgrates.org", ID: "ID", StrategyParams: make(map[string]any)}
- if err := ld.process(context.Background(), v, utils.MetaDispatchers, utils.MetaStore,
- map[string]any{utils.MetaCache: utils.MetaReload}, true, false); err != nil {
- t.Error(err)
- }
- if prf, err := dm.GetDispatcherProfile(context.Background(), "cgrates.org", "ID", false, true, utils.NonTransactional); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(v, prf) {
- t.Errorf("Expected: %v, received: %v", utils.ToJSON(v), utils.ToJSON(prf))
- }
- expReload := &utils.AttrReloadCacheWithAPIOpts{
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaReload,
- },
- DispatcherProfileIDs: []string{tntID}}
- if !reflect.DeepEqual(expReload, reloadCache) {
- t.Errorf("Expected: %v, received: %v", utils.ToJSON(expReload), utils.ToJSON(reloadCache))
- }
- expClear := &utils.AttrCacheIDsWithAPIOpts{
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaReload,
- },
- CacheIDs: []string{utils.CacheDispatcherFilterIndexes}}
- if !reflect.DeepEqual(expClear, clearCache) {
- t.Errorf("Expected: %v, received: %v", utils.ToJSON(expClear), utils.ToJSON(clearCache))
- }
- }
-
{
v := &utils.RateProfile{Tenant: "cgrates.org", ID: "ID", Rates: map[string]*utils.Rate{}, MinCost: utils.NewDecimal(0, 0), MaxCost: utils.NewDecimal(0, 0)}
if err := ld.process(context.Background(), v, utils.MetaRateProfiles, utils.MetaStore,
@@ -724,30 +662,6 @@ func TestLoaderProcessCallCahe(t *testing.T) {
}
}
- {
- v := &engine.DispatcherHost{Tenant: "cgrates.org", RemoteHost: &config.RemoteHost{ID: "ID", Address: "127.0.0.1", Transport: utils.MetaJSON}}
- if err := ld.process(context.Background(), v, utils.MetaDispatcherHosts, utils.MetaStore,
- map[string]any{utils.MetaCache: utils.MetaReload}, true, false); err != nil {
- t.Error(err)
- }
- if prf, err := dm.GetDispatcherHost(context.Background(), "cgrates.org", "ID", false, true, utils.NonTransactional); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(v, prf) {
- t.Errorf("Expected: %v, received: %v", utils.ToJSON(v), utils.ToJSON(prf))
- }
- exp := &utils.AttrReloadCacheWithAPIOpts{
- APIOpts: map[string]any{
- utils.MetaCache: utils.MetaReload,
- },
- DispatcherHostIDs: []string{tntID}}
- if !reflect.DeepEqual(exp, reloadCache) {
- t.Errorf("Expected: %v, received: %v", utils.ToJSON(exp), utils.ToJSON(reloadCache))
- }
- if !reflect.DeepEqual(nil, clearCache) {
- t.Errorf("Expected: %v, received: %v", utils.ToJSON(nil), utils.ToJSON(clearCache))
- }
- }
-
reloadCache, clearCache = nil, nil
{
diff --git a/migrator/dispatchers.go b/migrator/dispatchers.go
deleted file mode 100644
index 0708e6232..000000000
--- a/migrator/dispatchers.go
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package migrator
-
-import (
- "errors"
- "fmt"
- "strings"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (m *Migrator) migrateCurrentDispatcher() (err error) {
- var ids []string
- ids, err = m.dmIN.DataManager().DataDB().GetKeysForPrefix(context.TODO(), utils.DispatcherProfilePrefix)
- if err != nil {
- return
- }
- for _, id := range ids {
- tntID := strings.SplitN(strings.TrimPrefix(id, utils.DispatcherProfilePrefix), utils.InInFieldSep, 2)
- if len(tntID) < 2 {
- return fmt.Errorf("Invalid key <%s> when migrating dispatcher profiles", id)
- }
- dpp, err := m.dmIN.DataManager().GetDispatcherProfile(context.TODO(), tntID[0], tntID[1], false, false, utils.NonTransactional)
- if err != nil {
- return err
- }
- if dpp == nil || m.dryRun {
- continue
- }
- if err := m.dmOut.DataManager().SetDispatcherProfile(context.TODO(), dpp, true); err != nil {
- return err
- }
- if err := m.dmIN.DataManager().RemoveDispatcherProfile(context.TODO(), tntID[0],
- tntID[1], false); err != nil {
- return err
- }
- m.stats[utils.Dispatchers]++
- }
- return
-}
-
-func (m *Migrator) migrateCurrentDispatcherHost() (err error) {
- var ids []string
- ids, err = m.dmIN.DataManager().DataDB().GetKeysForPrefix(context.TODO(), utils.DispatcherHostPrefix)
- if err != nil {
- return err
- }
- for _, id := range ids {
- tntID := strings.SplitN(strings.TrimPrefix(id, utils.DispatcherHostPrefix), utils.InInFieldSep, 2)
- if len(tntID) < 2 {
- return fmt.Errorf("Invalid key <%s> when migrating dispatcher hosts", id)
- }
- dpp, err := m.dmIN.DataManager().GetDispatcherHost(context.TODO(), tntID[0], tntID[1], false, false, utils.NonTransactional)
- if err != nil {
- return err
- }
- if dpp == nil || m.dryRun {
- continue
- }
- if err := m.dmOut.DataManager().SetDispatcherHost(context.TODO(), dpp); err != nil {
- return err
- }
- if err := m.dmIN.DataManager().RemoveDispatcherHost(context.TODO(), tntID[0],
- tntID[1]); err != nil {
- return err
- }
- }
- return
-}
-
-func (m *Migrator) migrateDispatchers() (err error) {
- var vrs engine.Versions
- current := engine.CurrentDataDBVersions()
- if vrs, err = m.getVersions(utils.Dispatchers); err != nil {
- return
- }
- migrated := true
- var v2 *engine.DispatcherProfile
- for {
- version := vrs[utils.Dispatchers]
- for {
- switch version {
- default:
- return fmt.Errorf("Unsupported version %v", version)
- case current[utils.Dispatchers]:
- migrated = false
- if m.sameDataDB {
- break
- }
- if err = m.migrateCurrentDispatcher(); err != nil {
- return
- }
- if err = m.migrateCurrentDispatcherHost(); err != nil {
- return
- }
- case 1:
- if v2, err = m.migrateV1ToV2Dispatchers(); err != nil && err != utils.ErrNoMoreData {
- return
- } else if err == utils.ErrNoMoreData {
- break
- }
- version = 2
- }
- if version == current[utils.Dispatchers] || err == utils.ErrNoMoreData {
- break
- }
- }
- if err == utils.ErrNoMoreData || !migrated {
- break
- }
-
- if !m.dryRun {
- //set action plan
- if err = m.dmOut.DataManager().SetDispatcherProfile(context.TODO(), v2, true); err != nil {
- return
- }
- }
- m.stats[utils.Dispatchers]++
- }
- // All done, update version wtih current one
- if err = m.setVersions(utils.Dispatchers); err != nil {
- return
- }
- return m.ensureIndexesDataDB(engine.ColDpp, engine.ColDph)
-}
-
-func (m *Migrator) migrateV1ToV2Dispatchers() (v4Cpp *engine.DispatcherProfile, err error) {
- v4Cpp, err = m.dmIN.getV1DispatcherProfile()
- if err != nil {
- return nil, err
- } else if v4Cpp == nil {
- return nil, errors.New("Dispatcher NIL")
- }
- if v4Cpp.FilterIDs, err = migrateInlineFilterV4(v4Cpp.FilterIDs); err != nil {
- return nil, err
- }
- return
-}
diff --git a/migrator/dispatchers_it_test.go b/migrator/dispatchers_it_test.go
deleted file mode 100644
index 8181c7690..000000000
--- a/migrator/dispatchers_it_test.go
+++ /dev/null
@@ -1,245 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package migrator
-
-import (
- "log"
- "path"
- "reflect"
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var (
- dspPathIn string
- dspPathOut string
- dspCfgIn *config.CGRConfig
- dspCfgOut *config.CGRConfig
- dspMigrator *Migrator
- dspAction string
-)
-
-var sTestsDspIT = []func(t *testing.T){
- testDspITConnect,
- testDspITFlush,
- testDspITMigrateAndMove,
-}
-
-func TestDispatcherITMove1(t *testing.T) {
- var err error
- dspPathIn = path.Join(*utils.DataDir, "conf", "samples", "tutmongo")
- dspCfgIn, err = config.NewCGRConfigFromPath(context.Background(), dspPathIn)
- if err != nil {
- t.Fatal(err)
- }
- dspPathOut = path.Join(*utils.DataDir, "conf", "samples", "tutmysql")
- dspCfgOut, err = config.NewCGRConfigFromPath(context.Background(), dspPathOut)
- if err != nil {
- t.Fatal(err)
- }
- dspAction = utils.Move
- for _, stest := range sTestsDspIT {
- t.Run("TestDispatcherITMove", stest)
- }
- dspMigrator.Close()
-}
-
-func TestDispatcherITMove2(t *testing.T) {
- var err error
- dspPathIn = path.Join(*utils.DataDir, "conf", "samples", "tutmysql")
- dspCfgIn, err = config.NewCGRConfigFromPath(context.Background(), dspPathIn)
- if err != nil {
- t.Fatal(err)
- }
- dspPathOut = path.Join(*utils.DataDir, "conf", "samples", "tutmongo")
- dspCfgOut, err = config.NewCGRConfigFromPath(context.Background(), dspPathOut)
- if err != nil {
- t.Fatal(err)
- }
- dspAction = utils.Move
- for _, stest := range sTestsDspIT {
- t.Run("TestDispatcherITMove", stest)
- }
-}
-
-func TestDispatcherITMoveEncoding(t *testing.T) {
- var err error
- dspPathIn = path.Join(*utils.DataDir, "conf", "samples", "tutmongo")
- dspCfgIn, err = config.NewCGRConfigFromPath(context.Background(), dspPathIn)
- if err != nil {
- t.Fatal(err)
- }
- dspPathOut = path.Join(*utils.DataDir, "conf", "samples", "tutmongojson")
- dspCfgOut, err = config.NewCGRConfigFromPath(context.Background(), dspPathOut)
- if err != nil {
- t.Fatal(err)
- }
- dspAction = utils.Move
- for _, stest := range sTestsDspIT {
- t.Run("TestDispatcherITMoveEncoding", stest)
- }
-}
-
-func TestDispatcherITMoveEncoding2(t *testing.T) {
- var err error
- dspPathIn = path.Join(*utils.DataDir, "conf", "samples", "tutmysql")
- dspCfgIn, err = config.NewCGRConfigFromPath(context.Background(), dspPathIn)
- if err != nil {
- t.Fatal(err)
- }
- dspPathOut = path.Join(*utils.DataDir, "conf", "samples", "tutmysqljson")
- dspCfgOut, err = config.NewCGRConfigFromPath(context.Background(), dspPathOut)
- if err != nil {
- t.Fatal(err)
- }
- dspAction = utils.Move
- for _, stest := range sTestsDspIT {
- t.Run("TestDispatcherITMoveEncoding2", stest)
- }
-}
-
-func testDspITConnect(t *testing.T) {
- dataDBIn, err := NewMigratorDataDB(dspCfgIn.DataDbCfg().Type,
- dspCfgIn.DataDbCfg().Host, dspCfgIn.DataDbCfg().Port,
- dspCfgIn.DataDbCfg().Name, dspCfgIn.DataDbCfg().User,
- dspCfgIn.DataDbCfg().Password, dspCfgIn.GeneralCfg().DBDataEncoding,
- config.CgrConfig().CacheCfg(), dspCfgIn.DataDbCfg().Opts, dspCfgIn.DataDbCfg().Items)
- if err != nil {
- log.Fatal(err)
- }
- dataDBOut, err := NewMigratorDataDB(dspCfgOut.DataDbCfg().Type,
- dspCfgOut.DataDbCfg().Host, dspCfgOut.DataDbCfg().Port,
- dspCfgOut.DataDbCfg().Name, dspCfgOut.DataDbCfg().User,
- dspCfgOut.DataDbCfg().Password, dspCfgOut.GeneralCfg().DBDataEncoding,
- config.CgrConfig().CacheCfg(), dspCfgOut.DataDbCfg().Opts, dspCfgOut.DataDbCfg().Items)
- if err != nil {
- log.Fatal(err)
- }
- if reflect.DeepEqual(dspPathIn, dspPathOut) {
- dspMigrator, err = NewMigrator(dataDBIn, dataDBOut,
- false, true)
- } else {
- dspMigrator, err = NewMigrator(dataDBIn, dataDBOut,
- false, false)
- }
- if err != nil {
- log.Fatal(err)
- }
-}
-
-func testDspITFlush(t *testing.T) {
- if err := dspMigrator.dmOut.DataManager().DataDB().Flush(""); err != nil {
- t.Error(err)
- }
- if isEmpty, err := dspMigrator.dmOut.DataManager().DataDB().IsDBEmpty(); err != nil {
- t.Error(err)
- } else if isEmpty != true {
- t.Errorf("Expecting: true got :%+v", isEmpty)
- }
- if err := engine.SetDBVersions(dspMigrator.dmOut.DataManager().DataDB()); err != nil {
- t.Error("Error ", err.Error())
- }
- if err := dspMigrator.dmIN.DataManager().DataDB().Flush(""); err != nil {
- t.Error(err)
- }
- if isEmpty, err := dspMigrator.dmIN.DataManager().DataDB().IsDBEmpty(); err != nil {
- t.Error(err)
- } else if isEmpty != true {
- t.Errorf("Expecting: true got :%+v", isEmpty)
- }
- if err := engine.SetDBVersions(dspMigrator.dmIN.DataManager().DataDB()); err != nil {
- t.Error("Error ", err.Error())
- }
-}
-
-func testDspITMigrateAndMove(t *testing.T) {
- dspPrf := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{"*string:~*req.Accont:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z|2014-07-14T14:26:00Z"},
- Strategy: utils.MetaRandom,
- Weight: 20,
- }
- dspHost := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "ALL",
- Address: "127.0.0.1",
- Transport: utils.MetaJSON,
- },
- }
- if err := dspMigrator.dmIN.DataManager().SetDispatcherProfile(context.TODO(), dspPrf, false); err != nil {
- t.Error(err)
- }
- if err := dspMigrator.dmIN.DataManager().SetDispatcherHost(context.TODO(), dspHost); err != nil {
- t.Error(err)
- }
- currentVersion := engine.CurrentDataDBVersions()
- err := dspMigrator.dmIN.DataManager().DataDB().SetVersions(currentVersion, false)
- if err != nil {
- t.Error("Error when setting version for Dispatchers ", err.Error())
- }
-
- _, err = dspMigrator.dmOut.DataManager().GetDispatcherProfile(context.TODO(), "cgrates.org",
- "Dsp1", false, false, utils.NonTransactional)
- if err != utils.ErrDSPProfileNotFound {
- t.Error(err)
- }
-
- err, _ = dspMigrator.Migrate([]string{utils.MetaDispatchers})
- if err != nil {
- t.Error("Error when migrating Dispatchers ", err.Error())
- }
- result, err := dspMigrator.dmOut.DataManager().GetDispatcherProfile(context.TODO(), "cgrates.org",
- "Dsp1", false, false, utils.NonTransactional)
- if err != nil {
- t.Error(err)
- }
- if !reflect.DeepEqual(result, dspPrf) {
- t.Errorf("Expecting: %+v, received: %+v", dspPrf, result)
- }
- result, err = dspMigrator.dmIN.DataManager().GetDispatcherProfile(context.TODO(), "cgrates.org",
- "Dsp1", false, false, utils.NonTransactional)
- if err != utils.ErrDSPProfileNotFound {
- t.Error(err)
- }
-
- resultHost, err := dspMigrator.dmOut.DataManager().GetDispatcherHost(context.TODO(), "cgrates.org",
- "ALL", false, false, utils.NonTransactional)
- if err != nil {
- t.Error(err)
- }
- if !reflect.DeepEqual(resultHost, dspHost) {
- t.Errorf("Expecting: %+v, received: %+v", dspHost, resultHost)
- }
- resultHost, err = dspMigrator.dmIN.DataManager().GetDispatcherHost(context.TODO(), "cgrates.org",
- "ALL", false, false, utils.NonTransactional)
- if err != utils.ErrDSPHostNotFound {
- t.Error(err)
- } else if dspMigrator.stats[utils.Dispatchers] != 1 {
- t.Errorf("Expected 1, received: %v", dspMigrator.stats[utils.Dispatchers])
- }
-}
diff --git a/migrator/filters.go b/migrator/filters.go
index 3c030054e..757f24934 100644
--- a/migrator/filters.go
+++ b/migrator/filters.go
@@ -204,9 +204,6 @@ func (m *Migrator) migrateOthersv1() (err error) {
if err = m.migrateChargerProfileFiltersV1(); err != nil {
return err
}
- if err = m.migrateDispatcherProfileFiltersV1(); err != nil {
- return err
- }
return
}
@@ -247,10 +244,6 @@ func (m *Migrator) migrateOthersV2() (err error) {
return fmt.Errorf("Error: <%s> when trying to migrate filter for ChargerProfiles",
err.Error())
}
- if err = m.migrateDispatcherProfileFiltersV2(); err != nil {
- return fmt.Errorf("Error: <%s> when trying to migrate filter for DispatcherProfiles",
- err.Error())
- }
return
}
@@ -541,35 +534,6 @@ func (m *Migrator) migrateChargerProfileFiltersV1() (err error) {
return
}
-func (m *Migrator) migrateDispatcherProfileFiltersV1() (err error) {
- var ids []string
- ids, err = m.dmIN.DataManager().DataDB().GetKeysForPrefix(context.TODO(), utils.DispatcherProfilePrefix)
- if err != nil {
- return err
- }
- for _, id := range ids {
- tntID := strings.SplitN(strings.TrimPrefix(id, utils.DispatcherProfilePrefix), utils.InInFieldSep, 2)
- if len(tntID) < 2 {
- return fmt.Errorf("Invalid key <%s> when migrating filter for dispatcherProfile", id)
- }
- dpp, err := m.dmIN.DataManager().GetDispatcherProfile(context.TODO(), tntID[0], tntID[1], false, false, utils.NonTransactional)
- if err != nil {
- return err
- }
- if dpp == nil || m.dryRun {
- continue
- }
- for i, fl := range dpp.FilterIDs {
- dpp.FilterIDs[i] = migrateInlineFilter(fl)
- }
- if err := m.dmOut.DataManager().SetDispatcherProfile(context.TODO(), dpp, true); err != nil {
- return err
- }
- m.stats[utils.RQF]++
- }
- return
-}
-
// migrate filters from v2 to v3 for items
func (m *Migrator) migrateResourceProfileFiltersV2() (err error) {
var ids []string
@@ -762,37 +726,6 @@ func (m *Migrator) migrateChargerProfileFiltersV2() (err error) {
return
}
-func (m *Migrator) migrateDispatcherProfileFiltersV2() (err error) {
- var ids []string
- ids, err = m.dmIN.DataManager().DataDB().GetKeysForPrefix(context.TODO(), utils.DispatcherProfilePrefix)
- if err != nil {
- return fmt.Errorf("error: <%s> when getting dispatcher profile IDs", err)
- }
- for _, id := range ids {
- tntID := strings.SplitN(strings.TrimPrefix(id, utils.DispatcherProfilePrefix), utils.InInFieldSep, 2)
- if len(tntID) < 2 {
- return fmt.Errorf("Invalid key <%s> when migrating filter for dispatcherProfile", id)
- }
- dpp, err := m.dmIN.DataManager().GetDispatcherProfile(context.TODO(), tntID[0], tntID[1], false, false, utils.NonTransactional)
- if err != nil {
- return fmt.Errorf("error: <%s> when getting dispatcher profile with tenant: <%s> and id: <%s>",
- err.Error(), tntID[0], tntID[1])
- }
- if dpp == nil || m.dryRun {
- continue
- }
- for i, fl := range dpp.FilterIDs {
- dpp.FilterIDs[i] = migrateInlineFilterV2(fl)
- }
- if err := m.dmOut.DataManager().SetDispatcherProfile(context.TODO(), dpp, true); err != nil {
- return fmt.Errorf("error: <%s> when setting dispatcher profile with tenant: <%s> and id: <%s>",
- err.Error(), tntID[0], tntID[1])
- }
- m.stats[utils.RQF]++
- }
- return
-}
-
type v1Filter struct {
Tenant string
ID string
diff --git a/migrator/migrator.go b/migrator/migrator.go
index b34349efa..0736f9128 100644
--- a/migrator/migrator.go
+++ b/migrator/migrator.go
@@ -101,8 +101,6 @@ func (m *Migrator) Migrate(taskIDs []string) (err error, stats map[string]int) {
err = m.migrateSubscribers()
case utils.MetaChargers:
err = m.migrateChargers()
- case utils.MetaDispatchers:
- err = m.migrateDispatchers()
//TPs
case utils.MetaLoadIDs:
err = m.migrateLoadIDs()
@@ -129,9 +127,6 @@ func (m *Migrator) Migrate(taskIDs []string) (err error, stats map[string]int) {
if err := m.migrateSubscribers(); err != nil {
log.Print("ERROR: ", utils.MetaSubscribers, " ", err)
}
- if err := m.migrateDispatchers(); err != nil {
- log.Print("ERROR: ", utils.MetaDispatchers, " ", err)
- }
if err = m.migrateLoadIDs(); err != nil {
log.Print("ERROR: ", utils.MetaLoadIDs, " ", err)
}
diff --git a/migrator/migrator_datadb.go b/migrator/migrator_datadb.go
index f5edf7750..57a3b21f4 100644
--- a/migrator/migrator_datadb.go
+++ b/migrator/migrator_datadb.go
@@ -54,7 +54,6 @@ type MigratorDataDB interface {
remSupplier(tenant, id string) (err error)
getV1ChargerProfile() (v1chrPrf *engine.ChargerProfile, err error)
- getV1DispatcherProfile() (v1chrPrf *engine.DispatcherProfile, err error)
getV1RouteProfile() (v1chrPrf *engine.RouteProfile, err error)
getV3Stats() (v1st *engine.StatQueueProfile, err error)
diff --git a/migrator/storage_map_datadb.go b/migrator/storage_map_datadb.go
index 732b61e1f..33aaffdec 100644
--- a/migrator/storage_map_datadb.go
+++ b/migrator/storage_map_datadb.go
@@ -189,10 +189,6 @@ func (iDBMig *internalMigrator) getV1ChargerProfile() (v1chrPrf *engine.ChargerP
return nil, utils.ErrNotImplemented
}
-func (iDBMig *internalMigrator) getV1DispatcherProfile() (v1chrPrf *engine.DispatcherProfile, err error) {
- return nil, utils.ErrNotImplemented
-}
-
func (iDBMig *internalMigrator) getV1RouteProfile() (v1chrPrf *engine.RouteProfile, err error) {
return nil, utils.ErrNotImplemented
}
diff --git a/migrator/storage_mongo_datadb.go b/migrator/storage_mongo_datadb.go
index b65df4b12..bf3b4f9c9 100644
--- a/migrator/storage_mongo_datadb.go
+++ b/migrator/storage_mongo_datadb.go
@@ -431,25 +431,6 @@ func (v1ms *mongoMigrator) getV1ChargerProfile() (v1chrPrf *engine.ChargerProfil
return
}
-func (v1ms *mongoMigrator) getV1DispatcherProfile() (v1dppPrf *engine.DispatcherProfile, err error) {
- if v1ms.cursor == nil {
- v1ms.cursor, err = v1ms.mgoDB.DB().Collection(engine.ColDpp).Find(v1ms.mgoDB.GetContext(), bson.D{})
- if err != nil {
- return nil, err
- }
- }
- if !(*v1ms.cursor).Next(v1ms.mgoDB.GetContext()) {
- (*v1ms.cursor).Close(v1ms.mgoDB.GetContext())
- v1ms.cursor = nil
- return nil, utils.ErrNoMoreData
- }
- v1dppPrf = new(engine.DispatcherProfile)
- if err := (*v1ms.cursor).Decode(v1dppPrf); err != nil {
- return nil, err
- }
- return
-}
-
func (v1ms *mongoMigrator) getV1RouteProfile() (v1dppPrf *engine.RouteProfile, err error) {
if v1ms.cursor == nil {
v1ms.cursor, err = v1ms.mgoDB.DB().Collection(engine.ColRpp).Find(v1ms.mgoDB.GetContext(), bson.D{})
diff --git a/migrator/storage_redis.go b/migrator/storage_redis.go
index cc2c60483..18b41c46a 100644
--- a/migrator/storage_redis.go
+++ b/migrator/storage_redis.go
@@ -585,32 +585,6 @@ func (v1rs *redisMigrator) getV1ChargerProfile() (v1chrPrf *engine.ChargerProfil
return
}
-func (v1rs *redisMigrator) getV1DispatcherProfile() (v1chrPrf *engine.DispatcherProfile, err error) {
- if v1rs.qryIdx == nil {
- v1rs.dataKeys, err = v1rs.rds.GetKeysForPrefix(context.TODO(), utils.DispatcherProfilePrefix)
- if err != nil {
- return
- } else if len(v1rs.dataKeys) == 0 {
- return nil, utils.ErrNoMoreData
- }
- v1rs.qryIdx = utils.IntPointer(0)
- }
- if *v1rs.qryIdx <= len(v1rs.dataKeys)-1 {
- var strVal []byte
- if err = v1rs.rds.Cmd(&strVal, "GET", v1rs.dataKeys[*v1rs.qryIdx]); err != nil {
- return nil, err
- }
- if err := v1rs.rds.Marshaler().Unmarshal(strVal, &v1chrPrf); err != nil {
- return nil, err
- }
- *v1rs.qryIdx = *v1rs.qryIdx + 1
- } else {
- v1rs.qryIdx = nil
- return nil, utils.ErrNoMoreData
- }
- return
-}
-
func (v1rs *redisMigrator) getV1RouteProfile() (v1chrPrf *engine.RouteProfile, err error) {
if v1rs.qryIdx == nil {
v1rs.dataKeys, err = v1rs.rds.GetKeysForPrefix(context.TODO(), utils.RouteProfilePrefix)
diff --git a/registrarc/libregistrarc.go b/registrarc/libregistrarc.go
index 452928625..b7c901c7a 100644
--- a/registrarc/libregistrarc.go
+++ b/registrarc/libregistrarc.go
@@ -148,38 +148,6 @@ func register(req *http.Request) (*json.RawMessage, error) {
utils.Logger.Warning(fmt.Sprintf("<%s> Failed to register hosts because: %s",
utils.RegistrarC, err))
return sReq.Id, err
- case utils.RegistrarSv1UnregisterDispatcherHosts:
- var args UnregisterArgs
- params := []any{&args}
- if err = json.Unmarshal(*sReq.Params, ¶ms); err != nil {
- utils.Logger.Warning(fmt.Sprintf("<%s> Failed to decode params because: %s",
- utils.RegistrarC, err))
- return sReq.Id, err
- }
- for _, id := range args.IDs {
- if err = engine.Cache.Remove(context.TODO(), utils.CacheDispatcherHosts, utils.ConcatenatedKey(args.Tenant, id), true, utils.NonTransactional); err != nil {
- utils.Logger.Warning(fmt.Sprintf("<%s> Failed to remove DispatcherHost <%s> from cache because: %s",
- utils.RegistrarC, id, err))
- hasErrors = true
- continue
- }
- }
-
- case utils.RegistrarSv1RegisterDispatcherHosts:
- dH, err := unmarshallRegisterArgs(req, *sReq.Params)
- if err != nil {
- return sReq.Id, err
- }
-
- for _, dH := range dH {
- if err = engine.Cache.Set(context.TODO(), utils.CacheDispatcherHosts, dH.TenantID(), dH, nil,
- true, utils.NonTransactional); err != nil {
- utils.Logger.Warning(fmt.Sprintf("<%s> Failed to set DispatcherHost <%s> in cache because: %s",
- utils.RegistrarC, dH.TenantID(), err))
- hasErrors = true
- continue
- }
- }
case utils.RegistrarSv1UnregisterRPCHosts:
var args UnregisterArgs
diff --git a/registrarc/libregistrarc_test.go b/registrarc/libregistrarc_test.go
index e4e228594..ea70786a7 100644
--- a/registrarc/libregistrarc_test.go
+++ b/registrarc/libregistrarc_test.go
@@ -23,7 +23,6 @@ import (
"encoding/json"
"io"
"net/http"
- "net/http/httptest"
"reflect"
"testing"
@@ -33,50 +32,6 @@ import (
"github.com/cgrates/rpcclient"
)
-func TestRegisterArgsAsDispatcherHosts(t *testing.T) {
- args := &RegisterArgs{
- Tenant: "cgrates.org",
- Hosts: []*RegisterHostCfg{
- {
- ID: "Host1",
- Port: "2012",
- TLS: true,
- Transport: utils.MetaJSON,
- },
- {
- ID: "Host2",
- Port: "2013",
- TLS: false,
- Transport: utils.MetaGOB,
- },
- },
- Opts: make(map[string]any),
- }
- exp := []*engine.DispatcherHost{
- {
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "Host1",
- Address: "127.0.0.1:2012",
- TLS: true,
- Transport: utils.MetaJSON,
- },
- },
- {
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "Host2",
- Address: "127.0.0.1:2013",
- TLS: false,
- Transport: utils.MetaGOB,
- },
- },
- }
- if rply := args.AsDispatcherHosts("127.0.0.1"); !reflect.DeepEqual(exp, rply) {
- t.Errorf("Expected: %s ,received: %s", utils.ToJSON(exp), utils.ToJSON(rply))
- }
-}
-
func TestGetConnPort(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
@@ -124,204 +79,151 @@ func TestGetConnPort(t *testing.T) {
}
}
-func TestRegister(t *testing.T) {
- ra := &RegisterArgs{
- Tenant: "cgrates.org",
- Hosts: []*RegisterHostCfg{
- {
- ID: "Host1",
- Port: "2012",
- TLS: true,
- Transport: utils.MetaJSON,
- },
- {
- ID: "Host2",
- Port: "2013",
- TLS: false,
- Transport: utils.MetaGOB,
- },
- },
- Opts: make(map[string]any),
- }
- raJSON, err := json.Marshal([]any{ra})
- id := json.RawMessage("1")
- if err != nil {
- t.Fatal(err)
- }
- args := utils.NewServerRequest(utils.RegistrarSv1RegisterDispatcherHosts, raJSON, id)
- argsJSON, err := json.Marshal(args)
- if err != nil {
- t.Fatal(err)
- }
- req, err := http.NewRequest(http.MethodPost, "http://127.0.0.1:2080/json_rpc", bytes.NewBuffer(argsJSON))
- if err != nil {
- t.Fatal(err)
- }
- req.RemoteAddr = "127.0.0.1:2356"
- engine.Cache = engine.NewCacheS(config.CgrConfig(), nil, nil, nil)
- if rplyID, err := register(req); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(id, *rplyID) {
- t.Errorf("Expected: %q ,received: %q", string(id), string(*rplyID))
- }
+// func TestRegister(t *testing.T) {
+// ra := &RegisterArgs{
+// Tenant: "cgrates.org",
+// Hosts: []*RegisterHostCfg{
+// {
+// ID: "Host1",
+// Port: "2012",
+// TLS: true,
+// Transport: utils.MetaJSON,
+// },
+// {
+// ID: "Host2",
+// Port: "2013",
+// TLS: false,
+// Transport: utils.MetaGOB,
+// },
+// },
+// Opts: make(map[string]any),
+// }
+// raJSON, err := json.Marshal([]any{ra})
+// id := json.RawMessage("1")
+// if err != nil {
+// t.Fatal(err)
+// }
+// args := utils.NewServerRequest(utils.RegistrarSv1RegisterDispatcherHosts, raJSON, id)
+// argsJSON, err := json.Marshal(args)
+// if err != nil {
+// t.Fatal(err)
+// }
+// req, err := http.NewRequest(http.MethodPost, "http://127.0.0.1:2080/json_rpc", bytes.NewBuffer(argsJSON))
+// if err != nil {
+// t.Fatal(err)
+// }
+// req.RemoteAddr = "127.0.0.1:2356"
+// engine.Cache = engine.NewCacheS(config.CgrConfig(), nil, nil, nil)
+// if rplyID, err := register(req); err != nil {
+// t.Fatal(err)
+// } else if !reflect.DeepEqual(id, *rplyID) {
+// t.Errorf("Expected: %q ,received: %q", string(id), string(*rplyID))
+// }
- host1 := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "Host1",
- Address: "127.0.0.1:2012",
- TLS: true,
- Transport: utils.MetaJSON,
- },
- }
- host2 := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "Host2",
- Address: "127.0.0.1:2013",
- TLS: false,
- Transport: utils.MetaGOB,
- },
- }
+// if _, err := register(req); err != io.EOF {
+// t.Errorf("Expected error: %s ,received: %v", io.EOF, err)
+// }
- if x, ok := engine.Cache.Get(utils.CacheDispatcherHosts, host1.TenantID()); !ok {
- t.Errorf("Expected to find Host1 in cache")
- } else if !reflect.DeepEqual(host1, x) {
- t.Errorf("Expected: %s ,received: %s", utils.ToJSON(host1), utils.ToJSON(x))
- }
- if x, ok := engine.Cache.Get(utils.CacheDispatcherHosts, host2.TenantID()); !ok {
- t.Errorf("Expected to find Host2 in cache")
- } else if !reflect.DeepEqual(host2, x) {
- t.Errorf("Expected: %s ,received: %s", utils.ToJSON(host2), utils.ToJSON(x))
- }
+// ua := &UnregisterArgs{
+// Tenant: "cgrates.org",
+// IDs: []string{"Host1", "Host2"},
+// Opts: make(map[string]any),
+// }
+// uaJSON, err := json.Marshal([]any{ua})
+// id = json.RawMessage("2")
+// if err != nil {
+// t.Fatal(err)
+// }
+// uargs := utils.NewServerRequest(utils.RegistrarSv1UnregisterDispatcherHosts, uaJSON, id)
+// uargsJSON, err := json.Marshal(uargs)
+// if err != nil {
+// t.Fatal(err)
+// }
+// req, err = http.NewRequest(http.MethodPost, "http://127.0.0.1:2080/json_rpc", bytes.NewBuffer(uargsJSON))
+// if err != nil {
+// t.Fatal(err)
+// }
+// req.RemoteAddr = "127.0.0.1:2356"
+// if rplyID, err := register(req); err != nil {
+// t.Fatal(err)
+// } else if !reflect.DeepEqual(id, *rplyID) {
+// t.Errorf("Expected: %q ,received: %q", string(id), string(*rplyID))
+// }
- if _, err := register(req); err != io.EOF {
- t.Errorf("Expected error: %s ,received: %v", io.EOF, err)
- }
+// errCfg := config.NewDefaultCGRConfig()
- ua := &UnregisterArgs{
- Tenant: "cgrates.org",
- IDs: []string{"Host1", "Host2"},
- Opts: make(map[string]any),
- }
- uaJSON, err := json.Marshal([]any{ua})
- id = json.RawMessage("2")
- if err != nil {
- t.Fatal(err)
- }
- uargs := utils.NewServerRequest(utils.RegistrarSv1UnregisterDispatcherHosts, uaJSON, id)
- uargsJSON, err := json.Marshal(uargs)
- if err != nil {
- t.Fatal(err)
- }
- req, err = http.NewRequest(http.MethodPost, "http://127.0.0.1:2080/json_rpc", bytes.NewBuffer(uargsJSON))
- if err != nil {
- t.Fatal(err)
- }
- req.RemoteAddr = "127.0.0.1:2356"
- if rplyID, err := register(req); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(id, *rplyID) {
- t.Errorf("Expected: %q ,received: %q", string(id), string(*rplyID))
- }
- if x, ok := engine.Cache.Get(utils.CacheDispatcherHosts, host1.TenantID()); ok {
- t.Errorf("Expected to not find Host1 in cache %+v", x)
- }
- if x, ok := engine.Cache.Get(utils.CacheDispatcherHosts, host2.TenantID()); ok {
- t.Errorf("Expected to not find Host2 in cache %+v", x)
- }
- errCfg := config.NewDefaultCGRConfig()
+// errCfg.CacheCfg().ReplicationConns = []string{"errCon"}
+// req.Body = io.NopCloser(bytes.NewBuffer(uargsJSON))
+// if _, err := register(req); err != utils.ErrPartiallyExecuted {
+// t.Errorf("Expected error: %s ,received: %v", utils.ErrPartiallyExecuted, err)
+// }
- connMgr := engine.NewConnManager(errCfg)
- errCfg.CacheCfg().Partitions[utils.CacheDispatcherHosts].Replicate = true
- errCfg.RPCConns()["errCon"] = &config.RPCConn{
- Strategy: utils.MetaFirst,
- PoolSize: 1,
- Conns: []*config.RemoteHost{
- {
- Address: "127.0.0.1:5612",
- Transport: "*json",
- TLS: false,
- },
- },
- }
- errCfg.CacheCfg().ReplicationConns = []string{"errCon"}
- engine.Cache = engine.NewCacheS(errCfg, nil, connMgr, nil)
- req.Body = io.NopCloser(bytes.NewBuffer(uargsJSON))
- if _, err := register(req); err != utils.ErrPartiallyExecuted {
- t.Errorf("Expected error: %s ,received: %v", utils.ErrPartiallyExecuted, err)
- }
+// req.Body = io.NopCloser(bytes.NewBuffer(argsJSON))
+// if _, err := register(req); err != utils.ErrPartiallyExecuted {
+// t.Errorf("Expected error: %s ,received: %v", utils.ErrPartiallyExecuted, err)
+// }
- req.Body = io.NopCloser(bytes.NewBuffer(argsJSON))
- if _, err := register(req); err != utils.ErrPartiallyExecuted {
- t.Errorf("Expected error: %s ,received: %v", utils.ErrPartiallyExecuted, err)
- }
+// req.RemoteAddr = "127.0.0"
+// req.Body = io.NopCloser(bytes.NewBuffer(argsJSON))
+// if _, err := register(req); err == nil {
+// t.Errorf("Expected error,received: nil")
+// }
+// args2 := utils.NewServerRequest(utils.RegistrarSv1RegisterDispatcherHosts, id, id)
+// args2JSON, err := json.Marshal(args2)
+// if err != nil {
+// t.Fatal(err)
+// }
+// req.Body = io.NopCloser(bytes.NewBuffer(args2JSON))
+// if _, err := register(req); err == nil {
+// t.Errorf("Expected error,received: nil")
+// }
+// args2 = utils.NewServerRequest(utils.RegistrarSv1UnregisterDispatcherHosts, id, id)
+// args2JSON, err = json.Marshal(args2)
+// if err != nil {
+// t.Fatal(err)
+// }
+// req.Body = io.NopCloser(bytes.NewBuffer(args2JSON))
+// if _, err := register(req); err == nil {
+// t.Errorf("Expected error,received: nil")
+// }
- req.RemoteAddr = "127.0.0"
- req.Body = io.NopCloser(bytes.NewBuffer(argsJSON))
- if _, err := register(req); err == nil {
- t.Errorf("Expected error,received: nil")
- }
- args2 := utils.NewServerRequest(utils.RegistrarSv1RegisterDispatcherHosts, id, id)
- args2JSON, err := json.Marshal(args2)
- if err != nil {
- t.Fatal(err)
- }
- req.Body = io.NopCloser(bytes.NewBuffer(args2JSON))
- if _, err := register(req); err == nil {
- t.Errorf("Expected error,received: nil")
- }
- args2 = utils.NewServerRequest(utils.RegistrarSv1UnregisterDispatcherHosts, id, id)
- args2JSON, err = json.Marshal(args2)
- if err != nil {
- t.Fatal(err)
- }
- req.Body = io.NopCloser(bytes.NewBuffer(args2JSON))
- if _, err := register(req); err == nil {
- t.Errorf("Expected error,received: nil")
- }
- args2 = utils.NewServerRequest(utils.DispatcherSv1GetProfilesForEvent, id, id)
- args2JSON, err = json.Marshal(args2)
- if err != nil {
- t.Fatal(err)
- }
- req.Body = io.NopCloser(bytes.NewBuffer(args2JSON))
- if _, err := register(req); err == nil {
- t.Errorf("Expected error,received: nil")
- }
- args2 = utils.NewServerRequest(utils.DispatcherSv1GetProfilesForEvent, id, id)
- args2JSON, err = json.Marshal(args2)
- if err != nil {
- t.Fatal(err)
- }
- req.Body = io.NopCloser(bytes.NewBuffer(args2JSON))
- if _, err := register(req); err == nil {
- t.Errorf("Expected error,received: nil")
- }
- req.Body = io.NopCloser(bytes.NewBuffer(argsJSON))
- if _, err := register(req); err == nil {
- t.Errorf("Expected error,received: nil")
- }
- args2 = utils.NewServerRequest(utils.RegistrarSv1RegisterRPCHosts, id, id)
- args2JSON, err = json.Marshal(args2)
- if err != nil {
- t.Fatal(err)
- }
- req.Body = io.NopCloser(bytes.NewBuffer(args2JSON))
- if _, err := register(req); err == nil {
- t.Errorf("Expected error,received: nil")
- }
- args2 = utils.NewServerRequest(utils.RegistrarSv1UnregisterRPCHosts, id, id)
- args2JSON, err = json.Marshal(args2)
- if err != nil {
- t.Fatal(err)
- }
- req.Body = io.NopCloser(bytes.NewBuffer(args2JSON))
- if _, err := register(req); err == nil {
- t.Errorf("Expected error,received: nil")
- }
- engine.Cache = engine.NewCacheS(config.CgrConfig(), nil, nil, nil)
-}
+// req.Body = io.NopCloser(bytes.NewBuffer(args2JSON))
+// if _, err := register(req); err == nil {
+// t.Errorf("Expected error,received: nil")
+// }
+// args2 = utils.NewServerRequest(utils.DispatcherSv1GetProfilesForEvent, id, id)
+// args2JSON, err = json.Marshal(args2)
+// if err != nil {
+// t.Fatal(err)
+// }
+// req.Body = io.NopCloser(bytes.NewBuffer(args2JSON))
+// if _, err := register(req); err == nil {
+// t.Errorf("Expected error,received: nil")
+// }
+// req.Body = io.NopCloser(bytes.NewBuffer(argsJSON))
+// if _, err := register(req); err == nil {
+// t.Errorf("Expected error,received: nil")
+// }
+// args2 = utils.NewServerRequest(utils.RegistrarSv1RegisterRPCHosts, id, id)
+// args2JSON, err = json.Marshal(args2)
+// if err != nil {
+// t.Fatal(err)
+// }
+// req.Body = io.NopCloser(bytes.NewBuffer(args2JSON))
+// if _, err := register(req); err == nil {
+// t.Errorf("Expected error,received: nil")
+// }
+// args2 = utils.NewServerRequest(utils.RegistrarSv1UnregisterRPCHosts, id, id)
+// args2JSON, err = json.Marshal(args2)
+// if err != nil {
+// t.Fatal(err)
+// }
+// req.Body = io.NopCloser(bytes.NewBuffer(args2JSON))
+// if _, err := register(req); err == nil {
+// t.Errorf("Expected error,received: nil")
+// }
+// engine.Cache = engine.NewCacheS(config.CgrConfig(), nil, nil, nil)
+// }
type errRecorder struct{}
@@ -329,57 +231,57 @@ func (*errRecorder) Header() http.Header { return make(http.Header) }
func (*errRecorder) Write([]byte) (int, error) { return 0, io.EOF }
func (*errRecorder) WriteHeader(statusCode int) {}
-func TestRegistrar(t *testing.T) {
- w := httptest.NewRecorder()
- ra := &RegisterArgs{
- Tenant: "cgrates.org",
- Hosts: []*RegisterHostCfg{
- {
- ID: "Host1",
- Port: "2012",
- TLS: true,
- Transport: utils.MetaJSON,
- },
- {
- ID: "Host2",
- Port: "2013",
- TLS: false,
- Transport: utils.MetaGOB,
- },
- },
- Opts: make(map[string]any),
- }
- raJSON, err := json.Marshal([]any{ra})
- id := json.RawMessage("1")
- if err != nil {
- t.Fatal(err)
- }
- args := utils.NewServerRequest(utils.RegistrarSv1RegisterDispatcherHosts, raJSON, id)
- argsJSON, err := json.Marshal(args)
- if err != nil {
- t.Fatal(err)
- }
- req, err := http.NewRequest(http.MethodPost, "http://127.0.0.1:2080/json_rpc", bytes.NewBuffer(argsJSON))
- if err != nil {
- t.Fatal(err)
- }
- req.RemoteAddr = "127.0.0.1:2356"
+// func TestRegistrar(t *testing.T) {
+// w := httptest.NewRecorder()
+// ra := &RegisterArgs{
+// Tenant: "cgrates.org",
+// Hosts: []*RegisterHostCfg{
+// {
+// ID: "Host1",
+// Port: "2012",
+// TLS: true,
+// Transport: utils.MetaJSON,
+// },
+// {
+// ID: "Host2",
+// Port: "2013",
+// TLS: false,
+// Transport: utils.MetaGOB,
+// },
+// },
+// Opts: make(map[string]any),
+// }
+// raJSON, err := json.Marshal([]any{ra})
+// id := json.RawMessage("1")
+// if err != nil {
+// t.Fatal(err)
+// }
+// args := utils.NewServerRequest(utils.RegistrarSv1RegisterDispatcherHosts, raJSON, id)
+// argsJSON, err := json.Marshal(args)
+// if err != nil {
+// t.Fatal(err)
+// }
+// req, err := http.NewRequest(http.MethodPost, "http://127.0.0.1:2080/json_rpc", bytes.NewBuffer(argsJSON))
+// if err != nil {
+// t.Fatal(err)
+// }
+// req.RemoteAddr = "127.0.0.1:2356"
- Registrar(w, req)
- exp := "{\"id\":1,\"result\":\"OK\",\"error\":null}\n"
- if w.Body.String() != exp {
- t.Errorf("Expected: %q ,received: %q", exp, w.Body.String())
- }
+// Registrar(w, req)
+// exp := "{\"id\":1,\"result\":\"OK\",\"error\":null}\n"
+// if w.Body.String() != exp {
+// t.Errorf("Expected: %q ,received: %q", exp, w.Body.String())
+// }
- w = httptest.NewRecorder()
- Registrar(w, req)
- exp = "{\"id\":0,\"result\":null,\"error\":\"EOF\"}\n"
- if w.Body.String() != exp {
- t.Errorf("Expected: %q ,received: %q", exp, w.Body.String())
- }
+// w = httptest.NewRecorder()
+// Registrar(w, req)
+// exp = "{\"id\":0,\"result\":null,\"error\":\"EOF\"}\n"
+// if w.Body.String() != exp {
+// t.Errorf("Expected: %q ,received: %q", exp, w.Body.String())
+// }
- Registrar(new(errRecorder), req)
-}
+// Registrar(new(errRecorder), req)
+// }
func TestLibRegistrarcRegister(t *testing.T) {
req := &http.Request{
diff --git a/registrarc/registrarc.go b/registrarc/registrarc.go
index 8159947f6..f4a6839d8 100644
--- a/registrarc/registrarc.go
+++ b/registrarc/registrarc.go
@@ -48,10 +48,6 @@ type RegistrarCService struct {
func (dhS *RegistrarCService) ListenAndServe(stopChan, rldChan <-chan struct{}) {
dTm, rTm := &time.Timer{}, &time.Timer{}
var dTmStarted, rTmStarted bool
- if len(dhS.cfg.RegistrarCCfg().Dispatchers.RegistrarSConns) != 0 {
- dTm = time.NewTimer(dhS.cfg.RegistrarCCfg().Dispatchers.RefreshInterval)
- dhS.registerDispHosts()
- }
if len(dhS.cfg.RegistrarCCfg().RPC.RegistrarSConns) != 0 {
rTm = time.NewTimer(dhS.cfg.RegistrarCCfg().RPC.RefreshInterval)
dhS.registerRPCHosts()
@@ -65,25 +61,15 @@ func (dhS *RegistrarCService) ListenAndServe(stopChan, rldChan <-chan struct{})
if dTmStarted {
dTm.Stop()
}
- if len(dhS.cfg.RegistrarCCfg().Dispatchers.RegistrarSConns) != 0 {
- dTm = time.NewTimer(dhS.cfg.RegistrarCCfg().Dispatchers.RefreshInterval)
- dhS.registerDispHosts()
- }
if len(dhS.cfg.RegistrarCCfg().RPC.RegistrarSConns) != 0 {
rTm = time.NewTimer(dhS.cfg.RegistrarCCfg().RPC.RefreshInterval)
dhS.registerRPCHosts()
}
case <-stopChan:
- if len(dhS.cfg.RegistrarCCfg().Dispatchers.RegistrarSConns) != 0 {
- dTm.Stop()
- }
if len(dhS.cfg.RegistrarCCfg().RPC.RegistrarSConns) != 0 {
rTm.Stop()
}
return
- case <-dTm.C:
- dhS.registerDispHosts()
- dTm.Reset(dhS.cfg.RegistrarCCfg().Dispatchers.RefreshInterval)
case <-rTm.C:
dhS.registerRPCHosts()
rTm.Reset(dhS.cfg.RegistrarCCfg().RPC.RefreshInterval)
@@ -93,36 +79,12 @@ func (dhS *RegistrarCService) ListenAndServe(stopChan, rldChan <-chan struct{})
// Shutdown is called to shutdown the service
func (dhS *RegistrarCService) Shutdown() {
- if len(dhS.cfg.RegistrarCCfg().Dispatchers.RegistrarSConns) != 0 {
- unregisterHosts(dhS.connMgr, dhS.cfg.RegistrarCCfg().Dispatchers,
- dhS.cfg.GeneralCfg().DefaultTenant, utils.RegistrarSv1UnregisterDispatcherHosts)
- }
if len(dhS.cfg.RegistrarCCfg().RPC.RegistrarSConns) != 0 {
unregisterHosts(dhS.connMgr, dhS.cfg.RegistrarCCfg().RPC,
dhS.cfg.GeneralCfg().DefaultTenant, utils.RegistrarSv1UnregisterRPCHosts)
}
}
-func (dhS *RegistrarCService) registerDispHosts() {
- for _, connID := range dhS.cfg.RegistrarCCfg().Dispatchers.RegistrarSConns {
- for tnt, hostCfgs := range dhS.cfg.RegistrarCCfg().Dispatchers.Hosts {
- if tnt == utils.MetaDefault {
- tnt = dhS.cfg.GeneralCfg().DefaultTenant
- }
- args, err := NewRegisterArgs(dhS.cfg, tnt, hostCfgs)
- if err != nil {
- continue
- }
- var rply string
- if err := dhS.connMgr.Call(context.TODO(), []string{connID}, utils.RegistrarSv1RegisterDispatcherHosts, args, &rply); err != nil {
- utils.Logger.Warning(fmt.Sprintf("<%s> Unable to set the hosts to the conn with ID <%s> because : %s",
- utils.RegistrarC, connID, err))
- continue
- }
- }
- }
-}
-
func (dhS *RegistrarCService) registerRPCHosts() {
for _, connID := range dhS.cfg.RegistrarCCfg().RPC.RegistrarSConns {
for tnt, hostCfgs := range dhS.cfg.RegistrarCCfg().RPC.Hosts {
diff --git a/registrarc/registrarc_it_test.go b/registrarc/registrarc_it_test.go
index a9dd7458c..b00f9a04f 100644
--- a/registrarc/registrarc_it_test.go
+++ b/registrarc/registrarc_it_test.go
@@ -20,159 +20,159 @@ along with this program. If not, see
package registrarc
-import (
- "fmt"
- "testing"
- "time"
+// import (
+// "fmt"
+// "testing"
+// "time"
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
+// "github.com/cgrates/birpc/context"
+// "github.com/cgrates/cgrates/engine"
+// "github.com/cgrates/cgrates/utils"
+// )
-func TestRegistrarC(t *testing.T) {
- dbCfg := engine.DBCfg{
- StorDB: &engine.DBParams{
- Type: utils.StringPointer(utils.MetaInternal),
- },
- }
- switch *utils.DBType {
- case utils.MetaMySQL:
- case utils.MetaMongo:
- dbCfg.DataDB = engine.MongoDBCfg.DataDB
- case utils.MetaInternal, utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
+// func TestRegistrarC(t *testing.T) {
+// dbCfg := engine.DBCfg{
+// StorDB: &engine.DBParams{
+// Type: utils.StringPointer(utils.MetaInternal),
+// },
+// }
+// switch *utils.DBType {
+// case utils.MetaMySQL:
+// case utils.MetaMongo:
+// dbCfg.DataDB = engine.MongoDBCfg.DataDB
+// case utils.MetaInternal, utils.MetaPostgres:
+// t.SkipNow()
+// default:
+// t.Fatal("Unknown Database type")
+// }
- const (
- dspCfg = `{
-"general": {
- "node_id": "dispatcher",
- "reconnects": 1
-},
-"caches": {
- "partitions": {
- "*dispatcher_hosts": {
- "limit": -1,
- "ttl": "150ms"
- }
- }
-},
-"dispatchers": {
- "enabled": true
-}
-}`
- workerCfg = `{
-"general": {
- "node_id": "%s"
-},
-"listen": {
- "rpc_json": ":%[2]d12",
- "rpc_gob": ":%[2]d13",
- "http": ":%[2]d80"
-},
-"rpc_conns": {
- "dispConn": {
- "strategy": "*first",
- "conns": [{
- "address": "http://127.0.0.1:2080/registrar",
- "transport": "*http_jsonrpc"
- }]
- }
-},
-"registrarc": {
- "dispatchers": {
- "enabled": true,
- "registrars_conns": ["dispConn"],
- "hosts": [{
- "Tenant": "*default",
- "ID": "hostB",
- "transport": "*json",
- "tls": false
- }],
- "refresh_interval": "1s"
- }
-}
-}`
- )
+// const (
+// dspCfg = `{
+// "general": {
+// "node_id": "dispatcher",
+// "reconnects": 1
+// },
+// "caches": {
+// "partitions": {
+// "*dispatcher_hosts": {
+// "limit": -1,
+// "ttl": "150ms"
+// }
+// }
+// },
+// "dispatchers": {
+// "enabled": true
+// }
+// }`
+// workerCfg = `{
+// "general": {
+// "node_id": "%s"
+// },
+// "listen": {
+// "rpc_json": ":%[2]d12",
+// "rpc_gob": ":%[2]d13",
+// "http": ":%[2]d80"
+// },
+// "rpc_conns": {
+// "dispConn": {
+// "strategy": "*first",
+// "conns": [{
+// "address": "http://127.0.0.1:2080/registrar",
+// "transport": "*http_jsonrpc"
+// }]
+// }
+// },
+// "registrarc": {
+// "dispatchers": {
+// "enabled": true,
+// "registrars_conns": ["dispConn"],
+// "hosts": [{
+// "Tenant": "*default",
+// "ID": "hostB",
+// "transport": "*json",
+// "tls": false
+// }],
+// "refresh_interval": "1s"
+// }
+// }
+// }`
+// )
- disp := engine.TestEngine{
- ConfigJSON: dspCfg,
- DBCfg: dbCfg,
- Encoding: *utils.Encoding,
- }
- client, cfg := disp.Run(t)
+// disp := engine.TestEngine{
+// ConfigJSON: dspCfg,
+// DBCfg: dbCfg,
+// Encoding: *utils.Encoding,
+// }
+// client, cfg := disp.Run(t)
- tpFiles := map[string]string{
- utils.DispatcherProfilesCsv: `#Tenant,ID,FilterIDs,Weight,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters
-cgrates.org,dsp_test,,,*weight,,hostA,,20,,
-cgrates.org,dsp_test,,,,,hostB,,10,,`,
- }
- engine.LoadCSVsWithCGRLoader(t, cfg.ConfigPath, "", nil, tpFiles, "-caches_address=")
+// tpFiles := map[string]string{
+// utils.DispatcherProfilesCsv: `#Tenant,ID,FilterIDs,Weight,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters
+// cgrates.org,dsp_test,,,*weight,,hostA,,20,,
+// cgrates.org,dsp_test,,,,,hostB,,10,,`,
+// }
+// engine.LoadCSVsWithCGRLoader(t, cfg.ConfigPath, "", nil, tpFiles, "-caches_address=")
- checkNodeID := func(t *testing.T, expected string) {
- t.Helper()
- var status map[string]any
- err := client.Call(context.Background(), utils.CoreSv1Status,
- utils.TenantWithAPIOpts{
- Tenant: "cgrates.org",
- APIOpts: map[string]any{},
- }, &status)
- if err != nil && expected != "" {
- t.Fatalf("DispatcherSv1.RemoteStatus unexpected err: %v", err)
- }
- nodeID := utils.IfaceAsString(status[utils.NodeID])
- if expected == "" &&
- (err == nil || err.Error() != utils.ErrDSPHostNotFound.Error()) {
- t.Errorf("DispatcherSv1.RemoteStatus err=%q, want %q", err, utils.ErrDSPHostNotFound)
- }
- if nodeID != expected {
- t.Errorf("DispatcherSv1.RemoteStatus nodeID=%q, want %q", nodeID, expected)
- }
- }
+// checkNodeID := func(t *testing.T, expected string) {
+// t.Helper()
+// var status map[string]any
+// err := client.Call(context.Background(), utils.CoreSv1Status,
+// utils.TenantWithAPIOpts{
+// Tenant: "cgrates.org",
+// APIOpts: map[string]any{},
+// }, &status)
+// if err != nil && expected != "" {
+// t.Fatalf("DispatcherSv1.RemoteStatus unexpected err: %v", err)
+// }
+// nodeID := utils.IfaceAsString(status[utils.NodeID])
+// if expected == "" &&
+// (err == nil || err.Error() != utils.ErrDSPHostNotFound.Error()) {
+// t.Errorf("DispatcherSv1.RemoteStatus err=%q, want %q", err, utils.ErrDSPHostNotFound)
+// }
+// if nodeID != expected {
+// t.Errorf("DispatcherSv1.RemoteStatus nodeID=%q, want %q", nodeID, expected)
+// }
+// }
- /*
- Currently, only a dispatcher profile can be found in dataDB.
- It references 2 hosts that don't exist yet: hostA (weight=20) and hostB (weight=10).
- Its sorting strategy is "*weight".
- */
+// /*
+// Currently, only a dispatcher profile can be found in dataDB.
+// It references 2 hosts that don't exist yet: hostA (weight=20) and hostB (weight=10).
+// Its sorting strategy is "*weight".
+// */
- checkNodeID(t, "") // no hosts registered yet; will fail
+// checkNodeID(t, "") // no hosts registered yet; will fail
- // Workers will be automatically closed at the end of the subtest.
- t.Run("start workers and dispatch", func(t *testing.T) {
- workerB := engine.TestEngine{
- ConfigJSON: fmt.Sprintf(workerCfg, "workerB", 70),
- DBCfg: dbCfg,
- PreserveDataDB: true,
- PreserveStorDB: true,
- Encoding: *utils.Encoding,
- }
- workerB.Run(t)
+// // Workers will be automatically closed at the end of the subtest.
+// t.Run("start workers and dispatch", func(t *testing.T) {
+// workerB := engine.TestEngine{
+// ConfigJSON: fmt.Sprintf(workerCfg, "workerB", 70),
+// DBCfg: dbCfg,
+// PreserveDataDB: true,
+// PreserveStorDB: true,
+// Encoding: *utils.Encoding,
+// }
+// workerB.Run(t)
- // workerB is now active and has registered hostB.
- // The status request will be dispatched to hostB, because
- // hostA, which should have had priority, has not yet been
- // registered.
- checkNodeID(t, "workerB")
+// // workerB is now active and has registered hostB.
+// // The status request will be dispatched to hostB, because
+// // hostA, which should have had priority, has not yet been
+// // registered.
+// checkNodeID(t, "workerB")
- workerA := engine.TestEngine{
- ConfigJSON: fmt.Sprintf(workerCfg, "workerA", 60),
- DBCfg: dbCfg,
- PreserveDataDB: true,
- PreserveStorDB: true,
- Encoding: *utils.Encoding,
- }
- workerA.Run(t)
+// workerA := engine.TestEngine{
+// ConfigJSON: fmt.Sprintf(workerCfg, "workerA", 60),
+// DBCfg: dbCfg,
+// PreserveDataDB: true,
+// PreserveStorDB: true,
+// Encoding: *utils.Encoding,
+// }
+// workerA.Run(t)
- // workerA is now active and has overwritten hostB's port with
- // its own, instead of registering hostA. The request will be
- // dispatched based on hostB again.
- checkNodeID(t, "workerA")
- })
+// // workerA is now active and has overwritten hostB's port with
+// // its own, instead of registering hostA. The request will be
+// // dispatched based on hostB again.
+// checkNodeID(t, "workerA")
+// })
- time.Sleep(150 * time.Millisecond) // wait for cached hosts to expire
- checkNodeID(t, "") // no hosts left
-}
+// time.Sleep(150 * time.Millisecond) // wait for cached hosts to expire
+// checkNodeID(t, "") // no hosts left
+// }
diff --git a/registrarc/registrarc_test.go b/registrarc/registrarc_test.go
index 6f0d019b0..dafc1d040 100644
--- a/registrarc/registrarc_test.go
+++ b/registrarc/registrarc_test.go
@@ -19,123 +19,119 @@ along with this program. If not, see
package registrarc
import (
- "net/http"
- "net/http/httptest"
"reflect"
"testing"
- "time"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
- "github.com/cgrates/rpcclient"
)
-func TestDispatcherHostsService(t *testing.T) {
- ts := httptest.NewServer(http.HandlerFunc(Registrar))
- defer ts.Close()
- cfg := config.NewDefaultCGRConfig()
+// func TestDispatcherHostsService(t *testing.T) {
+// ts := httptest.NewServer(http.HandlerFunc(Registrar))
+// defer ts.Close()
+// cfg := config.NewDefaultCGRConfig()
- cfg.RPCConns()["conn1"] = &config.RPCConn{
- Strategy: rpcclient.PoolFirst,
- Conns: []*config.RemoteHost{{
- Address: ts.URL,
- TLS: false,
- Transport: rpcclient.HTTPjson,
- }},
- }
- cfg.RegistrarCCfg().Dispatchers.Hosts = map[string][]*config.RemoteHost{
- utils.MetaDefault: {
- {
- ID: "Host1",
- Transport: utils.MetaJSON,
- },
- },
- }
- cfg.RegistrarCCfg().Dispatchers.RefreshInterval = 100 * time.Millisecond
- cfg.RegistrarCCfg().Dispatchers.RegistrarSConns = []string{"conn1"}
+// cfg.RPCConns()["conn1"] = &config.RPCConn{
+// Strategy: rpcclient.PoolFirst,
+// Conns: []*config.RemoteHost{{
+// Address: ts.URL,
+// TLS: false,
+// Transport: rpcclient.HTTPjson,
+// }},
+// }
+// cfg.RegistrarCCfg().Dispatchers.Hosts = map[string][]*config.RemoteHost{
+// utils.MetaDefault: {
+// {
+// ID: "Host1",
+// Transport: utils.MetaJSON,
+// },
+// },
+// }
+// cfg.RegistrarCCfg().Dispatchers.RefreshInterval = 100 * time.Millisecond
+// cfg.RegistrarCCfg().Dispatchers.RegistrarSConns = []string{"conn1"}
- ds := NewRegistrarCService(cfg, engine.NewConnManager(cfg))
+// ds := NewRegistrarCService(cfg, engine.NewConnManager(cfg))
- ds.registerDispHosts()
+// ds.registerDispHosts()
- host1 := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "Host1",
- Address: "127.0.0.1:2012",
- Transport: utils.MetaJSON,
- },
- }
+// host1 := &engine.DispatcherHost{
+// Tenant: "cgrates.org",
+// RemoteHost: &config.RemoteHost{
+// ID: "Host1",
+// Address: "127.0.0.1:2012",
+// Transport: utils.MetaJSON,
+// },
+// }
- if x, ok := engine.Cache.Get(utils.CacheDispatcherHosts, host1.TenantID()); !ok {
- t.Errorf("Expected to find Host1 in cache")
- } else if !reflect.DeepEqual(host1, x) {
- t.Errorf("Expected: %s ,received: %s", utils.ToJSON(host1), utils.ToJSON(x))
- }
- cfg.RegistrarCCfg().Dispatchers.Hosts = map[string][]*config.RemoteHost{
- utils.MetaDefault: {
- {
- ID: "Host2",
- Transport: utils.MetaJSON,
- },
- },
- }
- config.CgrConfig().CacheCfg().Partitions[utils.CacheDispatcherHosts].Replicate = true
- config.CgrConfig().CacheCfg().ReplicationConns = []string{"*localhost"}
- ds.registerDispHosts()
- host1.ID = "Host2"
- if x, ok := engine.Cache.Get(utils.CacheDispatcherHosts, host1.TenantID()); !ok {
- t.Errorf("Expected to find Host2 in cache")
- } else if !reflect.DeepEqual(host1, x) {
- t.Errorf("Expected: %s ,received: %s", utils.ToJSON(host1), utils.ToJSON(x))
- }
- unregisterHosts(ds.connMgr, cfg.RegistrarCCfg().Dispatchers, "cgrates.org", utils.RegistrarSv1UnregisterDispatcherHosts)
- if _, ok := engine.Cache.Get(utils.CacheDispatcherHosts, host1.TenantID()); ok {
- t.Errorf("Expected to not find Host2 in cache")
- }
+// if x, ok := engine.Cache.Get(utils.CacheDispatcherHosts, host1.TenantID()); !ok {
+// t.Errorf("Expected to find Host1 in cache")
+// } else if !reflect.DeepEqual(host1, x) {
+// t.Errorf("Expected: %s ,received: %s", utils.ToJSON(host1), utils.ToJSON(x))
+// }
+// cfg.RegistrarCCfg().Dispatchers.Hosts = map[string][]*config.RemoteHost{
+// utils.MetaDefault: {
+// {
+// ID: "Host2",
+// Transport: utils.MetaJSON,
+// },
+// },
+// }
+// config.CgrConfig().CacheCfg().Partitions[utils.CacheDispatcherHosts].Replicate = true
+// config.CgrConfig().CacheCfg().ReplicationConns = []string{"*localhost"}
+// ds.registerDispHosts()
+// host1.ID = "Host2"
+// if x, ok := engine.Cache.Get(utils.CacheDispatcherHosts, host1.TenantID()); !ok {
+// t.Errorf("Expected to find Host2 in cache")
+// } else if !reflect.DeepEqual(host1, x) {
+// t.Errorf("Expected: %s ,received: %s", utils.ToJSON(host1), utils.ToJSON(x))
+// }
+// unregisterHosts(ds.connMgr, cfg.RegistrarCCfg().Dispatchers, "cgrates.org", utils.RegistrarSv1UnregisterDispatcherHosts)
+// if _, ok := engine.Cache.Get(utils.CacheDispatcherHosts, host1.TenantID()); ok {
+// t.Errorf("Expected to not find Host2 in cache")
+// }
- config.CgrConfig().CacheCfg().Partitions[utils.CacheDispatcherHosts].Replicate = false
- config.CgrConfig().CacheCfg().ReplicationConns = []string{}
+// config.CgrConfig().CacheCfg().Partitions[utils.CacheDispatcherHosts].Replicate = false
+// config.CgrConfig().CacheCfg().ReplicationConns = []string{}
- host1.ID = "Host1"
- cfg.RegistrarCCfg().Dispatchers.Hosts = map[string][]*config.RemoteHost{
- utils.MetaDefault: {
- {
- ID: "Host1",
- Transport: utils.MetaJSON,
- },
- },
- }
- ds.Shutdown()
- if _, ok := engine.Cache.Get(utils.CacheDispatcherHosts, host1.TenantID()); ok {
- t.Errorf("Expected to not find Host2 in cache")
- }
+// host1.ID = "Host1"
+// cfg.RegistrarCCfg().Dispatchers.Hosts = map[string][]*config.RemoteHost{
+// utils.MetaDefault: {
+// {
+// ID: "Host1",
+// Transport: utils.MetaJSON,
+// },
+// },
+// }
+// ds.Shutdown()
+// if _, ok := engine.Cache.Get(utils.CacheDispatcherHosts, host1.TenantID()); ok {
+// t.Errorf("Expected to not find Host2 in cache")
+// }
- cfg.ListenCfg().RPCJSONListen = "2012"
- ds.registerDispHosts()
+// cfg.ListenCfg().RPCJSONListen = "2012"
+// ds.registerDispHosts()
- ds = NewRegistrarCService(cfg, engine.NewConnManager(cfg))
- ds.Shutdown()
- stopChan := make(chan struct{})
- close(stopChan)
- ds.ListenAndServe(stopChan, make(chan struct{}))
-}
+// ds = NewRegistrarCService(cfg, engine.NewConnManager(cfg))
+// ds.Shutdown()
+// stopChan := make(chan struct{})
+// close(stopChan)
+// ds.ListenAndServe(stopChan, make(chan struct{}))
+// }
-func TestRegistrarcListenAndServe(t *testing.T) {
- //cover purposes only
- cfg := config.NewDefaultCGRConfig()
- regStSrv := NewRegistrarCService(cfg, nil)
- stopChan := make(chan struct{}, 1)
- rldChan := make(chan struct{}, 1)
- rldChan <- struct{}{}
- go func() {
- time.Sleep(10 * time.Millisecond)
- close(stopChan)
- }()
- regStSrv.ListenAndServe(stopChan, rldChan)
- regStSrv.Shutdown()
-}
+// func TestRegistrarcListenAndServe(t *testing.T) {
+// //cover purposes only
+// cfg := config.NewDefaultCGRConfig()
+// regStSrv := NewRegistrarCService(cfg, nil)
+// stopChan := make(chan struct{}, 1)
+// rldChan := make(chan struct{}, 1)
+// rldChan <- struct{}{}
+// go func() {
+// time.Sleep(10 * time.Millisecond)
+// close(stopChan)
+// }()
+// regStSrv.ListenAndServe(stopChan, rldChan)
+// regStSrv.Shutdown()
+// }
func TestRegistrarcregisterRPCHostsErr(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
@@ -185,32 +181,32 @@ func TestRegisterRPCHosts(t *testing.T) {
}
}
-func TestRegistrarcListenAndServedTmCDispatcher(t *testing.T) {
- //cover purposes only
- cfg := config.NewDefaultCGRConfig()
- cfg.RegistrarCCfg().Dispatchers.RefreshInterval = 1
- regStSrv := NewRegistrarCService(cfg, nil)
- stopChan := make(chan struct{}, 1)
- rldChan := make(chan struct{}, 1)
- go func() {
- time.Sleep(20 * time.Millisecond)
- close(stopChan)
- }()
- regStSrv.ListenAndServe(stopChan, rldChan)
- regStSrv.Shutdown()
-}
+// func TestRegistrarcListenAndServedTmCDispatcher(t *testing.T) {
+// //cover purposes only
+// cfg := config.NewDefaultCGRConfig()
+// cfg.RegistrarCCfg().Dispatchers.RefreshInterval = 1
+// regStSrv := NewRegistrarCService(cfg, nil)
+// stopChan := make(chan struct{}, 1)
+// rldChan := make(chan struct{}, 1)
+// go func() {
+// time.Sleep(20 * time.Millisecond)
+// close(stopChan)
+// }()
+// regStSrv.ListenAndServe(stopChan, rldChan)
+// regStSrv.Shutdown()
+// }
-func TestRegistrarcListenAndServedTmCRPC(t *testing.T) {
- //cover purposes only
- cfg := config.NewDefaultCGRConfig()
- cfg.RegistrarCCfg().RPC.RefreshInterval = 1
- regStSrv := NewRegistrarCService(cfg, nil)
- stopChan := make(chan struct{}, 1)
- rldChan := make(chan struct{}, 1)
- go func() {
- time.Sleep(20 * time.Millisecond)
- close(stopChan)
- }()
- regStSrv.ListenAndServe(stopChan, rldChan)
- regStSrv.Shutdown()
-}
+// func TestRegistrarcListenAndServedTmCRPC(t *testing.T) {
+// //cover purposes only
+// cfg := config.NewDefaultCGRConfig()
+// cfg.RegistrarCCfg().RPC.RefreshInterval = 1
+// regStSrv := NewRegistrarCService(cfg, nil)
+// stopChan := make(chan struct{}, 1)
+// rldChan := make(chan struct{}, 1)
+// go func() {
+// time.Sleep(20 * time.Millisecond)
+// close(stopChan)
+// }()
+// regStSrv.ListenAndServe(stopChan, rldChan)
+// regStSrv.Shutdown()
+// }
diff --git a/services/accounts.go b/services/accounts.go
index 5df4ecfef..2ff193a27 100644
--- a/services/accounts.go
+++ b/services/accounts.go
@@ -88,9 +88,7 @@ func (acts *AccountService) Start(shutdown *utils.SyncedChan, registry *servmana
return err
}
- if !acts.cfg.DispatcherSCfg().Enabled {
- acts.cl.RpcRegister(srv)
- }
+ acts.cl.RpcRegister(srv)
cms.AddInternalConn(utils.AccountS, srv)
return
diff --git a/services/actions.go b/services/actions.go
index a6c4fbb9a..eb9bfeb76 100644
--- a/services/actions.go
+++ b/services/actions.go
@@ -88,9 +88,7 @@ func (acts *ActionService) Start(shutdown *utils.SyncedChan, registry *servmanag
return
}
// srv, _ := birpc.NewService(apis.NewActionSv1(acts.acts), "", false)
- if !acts.cfg.DispatcherSCfg().Enabled {
- acts.cl.RpcRegister(srv)
- }
+ acts.cl.RpcRegister(srv)
cms.AddInternalConn(utils.ActionS, srv)
return
}
diff --git a/services/adminsv1.go b/services/adminsv1.go
index ca08c6875..eac0b44ab 100644
--- a/services/adminsv1.go
+++ b/services/adminsv1.go
@@ -76,14 +76,12 @@ func (apiService *AdminSv1Service) Start(_ *utils.SyncedChan, registry *servmana
srv, _ := engine.NewService(apiService.api)
// srv, _ := birpc.NewService(apiService.api, "", false)
- if !apiService.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- apiService.cl.RpcRegister(s)
- }
- rpl, _ := engine.NewService(apis.NewReplicatorSv1(dbs.DataManager(), apiService.api))
- for _, s := range rpl {
- apiService.cl.RpcRegister(s)
- }
+ for _, s := range srv {
+ apiService.cl.RpcRegister(s)
+ }
+ rpl, _ := engine.NewService(apis.NewReplicatorSv1(dbs.DataManager(), apiService.api))
+ for _, s := range rpl {
+ apiService.cl.RpcRegister(s)
}
cms.AddInternalConn(utils.AdminS, srv)
return
diff --git a/services/analyzers.go b/services/analyzers.go
index f96daf4ca..cb301f8e9 100644
--- a/services/analyzers.go
+++ b/services/analyzers.go
@@ -95,10 +95,8 @@ func (anz *AnalyzerService) start(registry *servmanager.ServiceRegistry) {
srv, _ := engine.NewService(anz.anz)
// srv, _ := birpc.NewService(apis.NewAnalyzerSv1(anz.anz), "", false)
- if !anz.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- anz.cl.RpcRegister(s)
- }
+ for _, s := range srv {
+ anz.cl.RpcRegister(s)
}
anz.Unlock()
}
diff --git a/services/attributes.go b/services/attributes.go
index e14be5b36..cb9773ef8 100644
--- a/services/attributes.go
+++ b/services/attributes.go
@@ -80,24 +80,9 @@ func (attrS *AttributeService) Start(shutdown *utils.SyncedChan, registry *servm
attrS.rpc = apis.NewAttributeSv1(attrS.attrS)
srv, _ := engine.NewService(attrS.rpc)
// srv, _ := birpc.NewService(attrS.rpc, "", false)
- if !attrS.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- attrS.cl.RpcRegister(s)
- }
+ for _, s := range srv {
+ attrS.cl.RpcRegister(s)
}
- dsps := registry.Lookup(utils.DispatcherS).(*DispatcherService)
- dspShtdChan := dsps.RegisterShutdownChan(attrS.ServiceName())
- go func() {
- for {
- if _, closed := <-dspShtdChan; closed {
- return
- }
- if servmanager.IsServiceInState(attrS, utils.StateServiceUP) {
- attrS.cl.RpcRegister(srv)
- }
-
- }
- }()
cms.AddInternalConn(utils.AttributeS, srv)
return
}
@@ -111,8 +96,6 @@ func (attrS *AttributeService) Reload(_ *utils.SyncedChan, _ *servmanager.Servic
func (attrS *AttributeService) Shutdown(registry *servmanager.ServiceRegistry) (err error) {
attrS.Lock()
attrS.cl.RpcUnregisterName(utils.AttributeSv1)
- dsps := registry.Lookup(utils.DispatcherS).(*DispatcherService)
- dsps.UnregisterShutdownChan(attrS.ServiceName())
attrS.Unlock()
return
}
diff --git a/services/caches.go b/services/caches.go
index c4826a360..b338c7951 100644
--- a/services/caches.go
+++ b/services/caches.go
@@ -74,10 +74,8 @@ func (cS *CacheService) Start(shutdown *utils.SyncedChan, registry *servmanager.
srv, _ := engine.NewService(engine.Cache)
// srv, _ := birpc.NewService(apis.NewCacheSv1(engine.Cache), "", false)
- if !cS.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- cS.cl.RpcRegister(s)
- }
+ for _, s := range srv {
+ cS.cl.RpcRegister(s)
}
cms.AddInternalConn(utils.CacheS, srv)
return
diff --git a/services/cdrs.go b/services/cdrs.go
index c3acaf397..abe738936 100644
--- a/services/cdrs.go
+++ b/services/cdrs.go
@@ -78,9 +78,7 @@ func (cs *CDRService) Start(_ *utils.SyncedChan, registry *servmanager.ServiceRe
if err != nil {
return err
}
- if !cs.cfg.DispatcherSCfg().Enabled {
- cs.cl.RpcRegister(srv)
- }
+ cs.cl.RpcRegister(srv)
cms.AddInternalConn(utils.CDRServer, srv)
return
}
diff --git a/services/chargers.go b/services/chargers.go
index a7462faf0..79594cbf1 100644
--- a/services/chargers.go
+++ b/services/chargers.go
@@ -77,10 +77,8 @@ func (chrS *ChargerService) Start(shutdown *utils.SyncedChan, registry *servmana
chrS.chrS = engine.NewChargerService(dbs.DataManager(), fs.FilterS(), chrS.cfg, cms.ConnManager())
srv, _ := engine.NewService(chrS.chrS)
// srv, _ := birpc.NewService(apis.NewChargerSv1(chrS.chrS), "", false)
- if !chrS.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- chrS.cl.RpcRegister(s)
- }
+ for _, s := range srv {
+ chrS.cl.RpcRegister(s)
}
cms.AddInternalConn(utils.ChargerS, srv)
return nil
diff --git a/services/config.go b/services/config.go
index c8024bf5d..5b2053ddb 100644
--- a/services/config.go
+++ b/services/config.go
@@ -59,10 +59,8 @@ func (s *ConfigService) Start(_ *utils.SyncedChan, registry *servmanager.Service
cms := srvDeps[utils.ConnManager].(*ConnManagerService)
svcs, _ := engine.NewServiceWithName(s.cfg, utils.ConfigS, true)
- if !s.cfg.DispatcherSCfg().Enabled {
- for _, svc := range svcs {
- s.cl.RpcRegister(svc)
- }
+ for _, svc := range svcs {
+ s.cl.RpcRegister(svc)
}
cms.AddInternalConn(utils.ConfigS, svcs)
return nil
diff --git a/services/connmanager.go b/services/connmanager.go
index c6e795165..4c9dcdf96 100644
--- a/services/connmanager.go
+++ b/services/connmanager.go
@@ -198,10 +198,6 @@ var serviceMethods = map[string]internalRoute{
receiver: utils.RateSv1,
internalPath: utils.ConcatenatedKey(utils.MetaInternal, utils.MetaRates),
},
- utils.DispatcherS: {
- receiver: utils.DispatcherSv1,
- internalPath: utils.ConcatenatedKey(utils.MetaInternal, utils.MetaDispatchers),
- },
utils.AccountS: {
receiver: utils.AccountSv1,
internalPath: utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAccounts),
diff --git a/services/cores.go b/services/cores.go
index d8a007945..b723b2d4e 100644
--- a/services/cores.go
+++ b/services/cores.go
@@ -76,10 +76,8 @@ func (s *CoreService) Start(shutdown *utils.SyncedChan, registry *servmanager.Se
if err != nil {
return err
}
- if !s.cfg.DispatcherSCfg().Enabled {
- for _, svc := range srv {
- s.cl.RpcRegister(svc)
- }
+ for _, svc := range srv {
+ s.cl.RpcRegister(svc)
}
cms.AddInternalConn(utils.CoreS, srv)
return nil
diff --git a/services/dispatchers.go b/services/dispatchers.go
deleted file mode 100644
index fb17a85bb..000000000
--- a/services/dispatchers.go
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package services
-
-import (
- "sync"
-
- "github.com/cgrates/cgrates/commonlisteners"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/dispatchers"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/servmanager"
- "github.com/cgrates/cgrates/utils"
-)
-
-// NewDispatcherService returns the Dispatcher Service
-func NewDispatcherService(cfg *config.CGRConfig) *DispatcherService {
- return &DispatcherService{
- cfg: cfg,
- srvsReload: make(map[string]chan struct{}),
- stateDeps: NewStateDependencies([]string{utils.StateServiceUP, utils.StateServiceDOWN}),
- }
-}
-
-// DispatcherService implements Service interface
-type DispatcherService struct {
- sync.RWMutex
- cfg *config.CGRConfig
- dspS *dispatchers.DispatcherService
- cl *commonlisteners.CommonListenerS
- connMgr *engine.ConnManager
- srvsReload map[string]chan struct{}
- stateDeps *StateDependencies // channel subscriptions for state changes
-}
-
-// Start should handle the sercive start
-func (dspS *DispatcherService) Start(shutdown *utils.SyncedChan, registry *servmanager.ServiceRegistry) (err error) {
- srvDeps, err := WaitForServicesToReachState(utils.StateServiceUP,
- []string{
- utils.CommonListenerS,
- utils.ConnManager,
- utils.CacheS,
- utils.FilterS,
- utils.DataDB,
- utils.AttributeS,
- },
- registry, dspS.cfg.GeneralCfg().ConnectTimeout)
- if err != nil {
- return err
- }
- dspS.cl = srvDeps[utils.CommonListenerS].(*CommonListenerService).CLS()
- cms := srvDeps[utils.ConnManager].(*ConnManagerService)
- dspS.connMgr = cms.ConnManager()
- cacheS := srvDeps[utils.CacheS].(*CacheService)
- if err = cacheS.WaitToPrecache(shutdown,
- utils.CacheDispatcherProfiles,
- utils.CacheDispatcherHosts,
- utils.CacheDispatcherFilterIndexes); err != nil {
- return
- }
- fs := srvDeps[utils.FilterS].(*FilterService)
- dbs := srvDeps[utils.DataDB].(*DataDBService)
-
- dspS.Lock()
- defer dspS.Unlock()
-
- dspS.dspS = dispatchers.NewDispatcherService(dbs.DataManager(), dspS.cfg, fs.FilterS(), dspS.connMgr)
-
- dspS.unregisterAllDispatchedSubsystems() // unregister all rpc services that can be dispatched
-
- srv, _ := engine.NewDispatcherService(dspS.dspS)
- // srv, _ := birpc.NewService(apis.NewDispatcherSv1(dspS.dspS), "", false)
- for _, s := range srv {
- dspS.cl.RpcRegister(s)
- }
- dspS.connMgr.EnableDispatcher(srv)
- // for the moment we dispable Apier through dispatcher
- // until we figured out a better sollution in case of gob server
- // dspS.server.SetDispatched()
- cms.AddInternalConn(utils.DispatcherS, srv)
- return
-}
-
-// Reload handles the change of config
-func (dspS *DispatcherService) Reload(_ *utils.SyncedChan, _ *servmanager.ServiceRegistry) (err error) {
- return // for the momment nothing to reload
-}
-
-// Shutdown stops the service
-func (dspS *DispatcherService) Shutdown(_ *servmanager.ServiceRegistry) (err error) {
- dspS.Lock()
- defer dspS.Unlock()
- dspS.dspS = nil
- dspS.cl.RpcUnregisterName(utils.DispatcherSv1)
- dspS.cl.RpcUnregisterName(utils.AttributeSv1)
-
- dspS.unregisterAllDispatchedSubsystems()
- dspS.connMgr.DisableDispatcher()
- dspS.sync()
- return
-}
-
-// ServiceName returns the service name
-func (dspS *DispatcherService) ServiceName() string {
- return utils.DispatcherS
-}
-
-// ShouldRun returns if the service should be running
-func (dspS *DispatcherService) ShouldRun() bool {
- return dspS.cfg.DispatcherSCfg().Enabled
-}
-
-func (dspS *DispatcherService) unregisterAllDispatchedSubsystems() {
- dspS.cl.RpcUnregisterName(utils.AttributeSv1)
-}
-
-func (dspS *DispatcherService) RegisterShutdownChan(subsys string) (c chan struct{}) {
- c = make(chan struct{})
- dspS.Lock()
- dspS.srvsReload[subsys] = c
- dspS.Unlock()
- return
-}
-
-func (dspS *DispatcherService) UnregisterShutdownChan(subsys string) {
- dspS.Lock()
- if dspS.srvsReload[subsys] != nil {
- close(dspS.srvsReload[subsys])
- }
- delete(dspS.srvsReload, subsys)
- dspS.Unlock()
-}
-
-func (dspS *DispatcherService) sync() {
- for _, c := range dspS.srvsReload {
- c <- struct{}{}
- }
-}
-
-// StateChan returns signaling channel of specific state
-func (dspS *DispatcherService) StateChan(stateID string) chan struct{} {
- return dspS.stateDeps.StateChan(stateID)
-}
diff --git a/services/dispatchers_it_test.go b/services/dispatchers_it_test.go
deleted file mode 100644
index da640d6ae..000000000
--- a/services/dispatchers_it_test.go
+++ /dev/null
@@ -1,109 +0,0 @@
-//go:build integration
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-package services
-
-// import (
-// "path"
-// "runtime"
-// "sync"
-// "testing"
-// "time"
-//
-// "github.com/cgrates/birpc"
-// "github.com/cgrates/birpc/context"
-// "github.com/cgrates/cgrates/commonlisteners"
-// "github.com/cgrates/cgrates/config"
-// "github.com/cgrates/cgrates/engine"
-// "github.com/cgrates/cgrates/servmanager"
-// "github.com/cgrates/cgrates/utils"
-// )
-//
-// func TestDispatcherSReload(t *testing.T) {
-// cfg := config.NewDefaultCGRConfig()
-//
-// cfg.AttributeSCfg().Enabled = true
-// shdWg := new(sync.WaitGroup)
-// chS := engine.NewCacheS(cfg, nil, nil, nil)
-// close(chS.GetPrecacheChannel(utils.CacheAttributeProfiles))
-// close(chS.GetPrecacheChannel(utils.CacheAttributeFilterIndexes))
-// close(chS.GetPrecacheChannel(utils.CacheDispatcherProfiles))
-// close(chS.GetPrecacheChannel(utils.CacheDispatcherHosts))
-// close(chS.GetPrecacheChannel(utils.CacheDispatcherFilterIndexes))
-// chSCh := make(chan *engine.CacheS, 1)
-// chSCh <- chS
-// css := &CacheService{cacheCh: chSCh}
-// filterSChan := make(chan *engine.FilterS, 1)
-// filterSChan <- nil
-// cls := commonlisteners.NewCommonListenerS(nil)
-// srvMngr := servmanager.NewServiceManager(shdWg, nil, cfg)
-// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
-// db := NewDataDBService(cfg, nil, false, srvDep)
-// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
-// srv := NewDispatcherService(cfg, db, css, filterSChan, cls,
-// make(chan birpc.ClientConnector, 1), nil, anz, srvDep)
-// attrS := NewAttributeService(cfg, db, css, filterSChan, cls, make(chan birpc.ClientConnector, 1), anz, srv, srvDep)
-// engine.NewConnManager(cfg)
-// srvMngr.AddServices(attrS, srv,
-// NewLoaderService(cfg, db, filterSChan, cls,
-// make(chan birpc.ClientConnector, 1), nil, anz, srvDep), db)
-// ctx, cancel := context.WithCancel(context.TODO())
-// srvMngr.StartServices(ctx, cancel)
-// if srv.IsRunning() {
-// t.Errorf("Expected service to be down")
-// }
-// if db.IsRunning() {
-// t.Errorf("Expected service to be down")
-// }
-// var reply string
-// cfg.ConfigPath = path.Join("/usr", "share", "cgrates", "conf", "samples", "dispatchers", "dispatchers_mysql")
-// if err := cfg.V1ReloadConfig(context.Background(), &config.ReloadArgs{
-// Section: config.DispatcherSJSON,
-// }, &reply); err != nil {
-// t.Error(err)
-// } else if reply != utils.OK {
-// t.Errorf("Expecting OK ,received %s", reply)
-// }
-// runtime.Gosched()
-// runtime.Gosched()
-// time.Sleep(10 * time.Millisecond) //need to switch to gorutine
-// if !srv.IsRunning() {
-// t.Fatalf("Expected service to be running")
-// }
-// if !db.IsRunning() {
-// t.Errorf("Expected service to be running")
-// }
-// err := srv.Start(ctx, cancel)
-// if err == nil || err != utils.ErrServiceAlreadyRunning {
-// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ErrServiceAlreadyRunning, err)
-// }
-// err = srv.Reload(ctx, cancel)
-// if err != nil {
-// t.Errorf("\nExpecting ,\n Received <%+v>", err)
-// }
-// cfg.DispatcherSCfg().Enabled = false
-// cfg.GetReloadChan() <- config.SectionToService[config.DispatcherSJSON]
-// time.Sleep(10 * time.Millisecond)
-// if srv.IsRunning() {
-// t.Errorf("Expected service to be down")
-// }
-// cancel()
-// time.Sleep(10 * time.Millisecond)
-// }
diff --git a/services/dispatchers_test.go b/services/dispatchers_test.go
deleted file mode 100644
index 323bb6f7f..000000000
--- a/services/dispatchers_test.go
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-package services
-
-// import (
-// "sync"
-// "testing"
-//
-// "github.com/cgrates/birpc"
-// "github.com/cgrates/birpc/context"
-// "github.com/cgrates/cgrates/commonlisteners"
-// "github.com/cgrates/cgrates/dispatchers"
-//
-// "github.com/cgrates/cgrates/config"
-// "github.com/cgrates/cgrates/engine"
-// "github.com/cgrates/cgrates/utils"
-// )
-//
-// // TestDispatcherSCoverage for cover testing
-// func TestDispatcherSCoverage(t *testing.T) {
-// cfg := config.NewDefaultCGRConfig()
-// cfg.AttributeSCfg().Enabled = true
-// filterSChan := make(chan *engine.FilterS, 1)
-// filterSChan <- nil
-// cls := commonlisteners.NewCommonListenerS(nil)
-// srvDep := map[string]*sync.WaitGroup{utils.DataDB: new(sync.WaitGroup)}
-// db := NewDataDBService(cfg, nil, false, srvDep)
-// anz := NewAnalyzerService(cfg, cls, filterSChan, make(chan birpc.ClientConnector, 1), srvDep)
-// chS := NewCacheService(cfg, db, nil, cls, make(chan context.ClientConnector, 1), anz, nil, srvDep)
-// srv := NewDispatcherService(cfg, db, chS, filterSChan, cls,
-// make(chan birpc.ClientConnector, 1), engine.NewConnManager(cfg), anz, srvDep)
-// if srv.IsRunning() {
-// t.Errorf("Expected service to be down")
-// }
-// srv2 := DispatcherService{
-// RWMutex: sync.RWMutex{},
-// cfg: cfg,
-// dm: db,
-// cacheS: chS,
-// filterSChan: filterSChan,
-// cls: cls,
-// connMgr: srv.connMgr,
-// connChan: make(chan birpc.ClientConnector, 1),
-// anz: anz,
-// srvDep: srvDep,
-// }
-// srv2.dspS = &dispatchers.DispatcherService{}
-// if !srv2.IsRunning() {
-// t.Errorf("Expected service to be running")
-// }
-//
-// serviceName := srv2.ServiceName()
-// if serviceName != utils.DispatcherS {
-// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.DispatcherS, serviceName)
-// }
-// shouldRun := srv2.ShouldRun()
-// if shouldRun != false {
-// t.Errorf("\nExpecting <%+v>,\n Received <%+v>", false, shouldRun)
-// }
-//
-// srv2.connChan <- &testMockClients{}
-// shutErr := srv2.Shutdown()
-// if shutErr != nil {
-// t.Errorf("\nExpecting ,\n Received <%+v>", shutErr)
-// }
-// if srv2.IsRunning() {
-// t.Errorf("Expected service to be down")
-// }
-// }
diff --git a/services/ees.go b/services/ees.go
index 5ed306a9e..e031d2496 100644
--- a/services/ees.go
+++ b/services/ees.go
@@ -102,9 +102,7 @@ func (es *EventExporterService) Start(_ *utils.SyncedChan, registry *servmanager
srv, _ := engine.NewServiceWithPing(es.eeS, utils.EeSv1, utils.V1Prfx)
// srv, _ := birpc.NewService(es.rpc, "", false)
- if !es.cfg.DispatcherSCfg().Enabled {
- es.cl.RpcRegister(srv)
- }
+ es.cl.RpcRegister(srv)
cms.AddInternalConn(utils.EEs, srv)
return nil
}
diff --git a/services/ers.go b/services/ers.go
index 8242bbfaa..1f7acc1a8 100644
--- a/services/ers.go
+++ b/services/ers.go
@@ -83,9 +83,7 @@ func (erS *EventReaderService) Start(shutdown *utils.SyncedChan, registry *servm
if err != nil {
return err
}
- if !erS.cfg.DispatcherSCfg().Enabled {
- erS.cl.RpcRegister(srv)
- }
+ erS.cl.RpcRegister(srv)
cms.AddInternalConn(utils.ERs, srv)
return
}
diff --git a/services/guardian.go b/services/guardian.go
index 5253dcbe9..69bd1f072 100644
--- a/services/guardian.go
+++ b/services/guardian.go
@@ -63,10 +63,8 @@ func (s *GuardianService) Start(_ *utils.SyncedChan, registry *servmanager.Servi
defer s.mu.Unlock()
svcs, _ := engine.NewServiceWithName(guardian.Guardian, utils.GuardianS, true)
- if !s.cfg.DispatcherSCfg().Enabled {
- for _, svc := range svcs {
- s.cl.RpcRegister(svc)
- }
+ for _, svc := range svcs {
+ s.cl.RpcRegister(svc)
}
cms.AddInternalConn(utils.GuardianS, svcs)
return nil
diff --git a/services/loaders.go b/services/loaders.go
index 966fd97e7..d474d4466 100644
--- a/services/loaders.go
+++ b/services/loaders.go
@@ -82,10 +82,8 @@ func (ldrs *LoaderService) Start(_ *utils.SyncedChan, registry *servmanager.Serv
}
srv, _ := engine.NewService(ldrs.ldrs)
// srv, _ := birpc.NewService(apis.NewLoaderSv1(ldrs.ldrs), "", false)
- if !ldrs.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- ldrs.cl.RpcRegister(s)
- }
+ for _, s := range srv {
+ ldrs.cl.RpcRegister(s)
}
cms.AddInternalConn(utils.LoaderS, srv)
return
diff --git a/services/rankings.go b/services/rankings.go
index c917292f7..9b462bc92 100644
--- a/services/rankings.go
+++ b/services/rankings.go
@@ -83,10 +83,8 @@ func (ran *RankingService) Start(shutdown *utils.SyncedChan, registry *servmanag
if err != nil {
return err
}
- if !ran.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- ran.cl.RpcRegister(s)
- }
+ for _, s := range srv {
+ ran.cl.RpcRegister(s)
}
cms.AddInternalConn(utils.RankingS, srv)
return nil
diff --git a/services/rates.go b/services/rates.go
index 25f460deb..2082e2db2 100644
--- a/services/rates.go
+++ b/services/rates.go
@@ -113,9 +113,7 @@ func (rs *RateService) Start(shutdown *utils.SyncedChan, registry *servmanager.S
return err
}
// srv, _ := birpc.NewService(apis.NewRateSv1(rs.rateS), "", false)
- if !rs.cfg.DispatcherSCfg().Enabled {
- rs.cl.RpcRegister(srv)
- }
+ rs.cl.RpcRegister(srv)
cms.AddInternalConn(utils.RateS, srv)
return
}
diff --git a/services/registrarc.go b/services/registrarc.go
index 326bcb980..bdd07177c 100644
--- a/services/registrarc.go
+++ b/services/registrarc.go
@@ -88,8 +88,7 @@ func (dspS *RegistrarCService) ServiceName() string {
// ShouldRun returns if the service should be running
func (dspS *RegistrarCService) ShouldRun() bool {
- return len(dspS.cfg.RegistrarCCfg().RPC.RegistrarSConns) != 0 ||
- len(dspS.cfg.RegistrarCCfg().Dispatchers.RegistrarSConns) != 0
+ return len(dspS.cfg.RegistrarCCfg().RPC.RegistrarSConns) != 0
}
// StateChan returns signaling channel of specific state
diff --git a/services/resources.go b/services/resources.go
index 28e025581..602d95661 100644
--- a/services/resources.go
+++ b/services/resources.go
@@ -80,10 +80,8 @@ func (reS *ResourceService) Start(shutdown *utils.SyncedChan, registry *servmana
reS.reS.StartLoop(context.TODO())
srv, _ := engine.NewService(reS.reS)
// srv, _ := birpc.NewService(apis.NewResourceSv1(reS.reS), "", false)
- if !reS.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- reS.cl.RpcRegister(s)
- }
+ for _, s := range srv {
+ reS.cl.RpcRegister(s)
}
cms.AddInternalConn(utils.ResourceS, srv)
return
diff --git a/services/routes.go b/services/routes.go
index 5500ddb6c..f8e1a0225 100644
--- a/services/routes.go
+++ b/services/routes.go
@@ -77,10 +77,8 @@ func (routeS *RouteService) Start(shutdown *utils.SyncedChan, registry *servmana
routeS.routeS = engine.NewRouteService(dbs.DataManager(), fs.FilterS(), routeS.cfg, cms.ConnManager())
srv, _ := engine.NewService(routeS.routeS)
// srv, _ := birpc.NewService(apis.NewRouteSv1(routeS.routeS), "", false)
- if !routeS.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- routeS.cl.RpcRegister(s)
- }
+ for _, s := range srv {
+ routeS.cl.RpcRegister(s)
}
cms.AddInternalConn(utils.RouteS, srv)
return
diff --git a/services/sessions.go b/services/sessions.go
index 5c5ae3e12..57de1c2d6 100644
--- a/services/sessions.go
+++ b/services/sessions.go
@@ -83,10 +83,8 @@ func (smg *SessionService) Start(shutdown *utils.SyncedChan, registry *servmanag
// Register RPC handler
srv, _ := engine.NewServiceWithName(smg.sm, utils.SessionS, true) // methods with multiple options
// srv, _ := birpc.NewService(apis.NewSessionSv1(smg.sm), utils.EmptyString, false) // methods with multiple options
- if !smg.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- smg.cl.RpcRegister(s)
- }
+ for _, s := range srv {
+ smg.cl.RpcRegister(s)
}
// Register BiRpc handlers
if smg.cfg.SessionSCfg().ListenBijson != utils.EmptyString {
diff --git a/services/stats.go b/services/stats.go
index e89969431..557b76d39 100644
--- a/services/stats.go
+++ b/services/stats.go
@@ -80,10 +80,8 @@ func (sts *StatService) Start(shutdown *utils.SyncedChan, registry *servmanager.
sts.sts.StartLoop(context.TODO())
srv, _ := engine.NewService(sts.sts)
// srv, _ := birpc.NewService(apis.NewStatSv1(sts.sts), "", false)
- if !sts.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- sts.cl.RpcRegister(s)
- }
+ for _, s := range srv {
+ sts.cl.RpcRegister(s)
}
cms.AddInternalConn(utils.StatS, srv)
return
diff --git a/services/thresholds.go b/services/thresholds.go
index 29b2ea729..eeb3d0592 100644
--- a/services/thresholds.go
+++ b/services/thresholds.go
@@ -80,10 +80,8 @@ func (thrs *ThresholdService) Start(shutdown *utils.SyncedChan, registry *servma
thrs.thrs.StartLoop(context.TODO())
srv, _ := engine.NewService(thrs.thrs)
// srv, _ := birpc.NewService(apis.NewThresholdSv1(thrs.thrs), "", false)
- if !thrs.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- thrs.cl.RpcRegister(s)
- }
+ for _, s := range srv {
+ thrs.cl.RpcRegister(s)
}
cms.AddInternalConn(utils.ThresholdS, srv)
return
diff --git a/services/trends.go b/services/trends.go
index 728992c93..3c294df16 100644
--- a/services/trends.go
+++ b/services/trends.go
@@ -82,10 +82,8 @@ func (trs *TrendService) Start(shutdown *utils.SyncedChan, registry *servmanager
if err != nil {
return err
}
- if !trs.cfg.DispatcherSCfg().Enabled {
- for _, s := range srv {
- trs.cl.RpcRegister(s)
- }
+ for _, s := range srv {
+ trs.cl.RpcRegister(s)
}
cms.AddInternalConn(utils.TrendS, srv)
return nil
diff --git a/servmanager/servmanager.go b/servmanager/servmanager.go
index 9cd111629..da9cabd9e 100644
--- a/servmanager/servmanager.go
+++ b/servmanager/servmanager.go
@@ -229,9 +229,6 @@ func toggleService(id string, status bool, srvMngr *ServiceManager) (err error)
case utils.ChargerS:
srvMngr.cfg.ChargerSCfg().Enabled = status
srvMngr.cfg.GetReloadChan() <- id
- case utils.DispatcherS:
- srvMngr.cfg.DispatcherSCfg().Enabled = status
- srvMngr.cfg.GetReloadChan() <- id
case utils.EEs:
srvMngr.cfg.EEsCfg().Enabled = status
srvMngr.cfg.GetReloadChan() <- id
diff --git a/tpes/tpe_dispatcher_hosts.go b/tpes/tpe_dispatcher_hosts.go
deleted file mode 100644
index f91c98ff4..000000000
--- a/tpes/tpe_dispatcher_hosts.go
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package tpes
-
-import (
- "encoding/csv"
- "fmt"
- "io"
-
- "github.com/cgrates/birpc/context"
-
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-type TPDispatcherHosts struct {
- dm *engine.DataManager
-}
-
-// newTPDispatcherHosts is the constructor for TPDispatcherHosts
-func newTPDispatcherHosts(dm *engine.DataManager) *TPDispatcherHosts {
- return &TPDispatcherHosts{
- dm: dm,
- }
-}
-
-// exportItems for TPDispatcherHosts will implement the method for tpExporter interface
-func (tpDspHst TPDispatcherHosts) exportItems(ctx *context.Context, wrtr io.Writer, tnt string, itmIDs []string) (err error) {
- csvWriter := csv.NewWriter(wrtr)
- csvWriter.Comma = utils.CSVSep
- // before writing the profiles, we must write the headers
- if err = csvWriter.Write([]string{"#Tenant", "ID", "Address", "Transport", "ConnectAttempts", "Reconnects", "MaxReconnectInterval", "ConnectTimeout", "ReplyTimeout", "Tls", "ClientKey", "ClientCertificate", "CaCertificate"}); err != nil {
- return
- }
- for _, dspHostID := range itmIDs {
- var dspHostPrf *engine.DispatcherHost
- dspHostPrf, err = tpDspHst.dm.GetDispatcherHost(ctx, tnt, dspHostID, true, true, utils.NonTransactional)
- if err != nil {
- if err.Error() == utils.ErrDSPHostNotFound.Error() {
- return fmt.Errorf("<%s> cannot find DispatcherHost with id: <%v>", err, dspHostID)
- }
- return err
- }
- dspHstsMdl := engine.APItoModelTPDispatcherHost(engine.DispatcherHostToAPI(dspHostPrf))
- // for every profile, convert it into model to be compatible in csv format
- // transform every record into a []string
- record, err := engine.CsvDump(dspHstsMdl)
- if err != nil {
- return err
- }
- // record is a line of a csv file
- if err := csvWriter.Write(record); err != nil {
- return err
- }
-
- }
- csvWriter.Flush()
- return
-}
diff --git a/tpes/tpe_dispatcher_hosts_test.go b/tpes/tpe_dispatcher_hosts_test.go
deleted file mode 100644
index 70861096e..000000000
--- a/tpes/tpe_dispatcher_hosts_test.go
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package tpes
-
-import (
- "bytes"
- "testing"
- "time"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestTPEnewTPDispatchersHost(t *testing.T) {
- // dataDB := &engine.DataDBM
- // dm := &engine.NewDataManager()
- cfg := config.NewDefaultCGRConfig()
- connMng := engine.NewConnManager(cfg)
- dm := engine.NewDataManager(&engine.DataDBMock{
- GetDispatcherHostDrvF: func(ctx *context.Context, str1 string, str2 string) (*engine.DispatcherHost, error) {
- dsph := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "DSH1",
- Address: "*internal",
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- }
- return dsph, nil
- },
- }, nil, connMng)
- exp := &TPDispatcherHosts{
- dm: dm,
- }
- rcv := newTPDispatcherHosts(dm)
- if rcv.dm != exp.dm {
- t.Errorf("Expected %v \nbut received %v", exp, rcv)
- }
-}
-
-func TestTPEExportItemsDispatchersHost(t *testing.T) {
- wrtr := new(bytes.Buffer)
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- tpDsph := TPDispatcherHosts{
- dm: dm,
- }
- dsph := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "DSH1",
- Address: "*internal",
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- }
- tpDsph.dm.SetDispatcherHost(context.Background(), dsph)
- err := tpDsph.exportItems(context.Background(), wrtr, "cgrates.org", []string{"DSH1"})
- if err != nil {
- t.Errorf("Expected nil\n but received %v", err)
- }
-}
-
-func TestTPEExportItemsDispatcherHostsNoDbConn(t *testing.T) {
- engine.Cache.Clear(nil)
- wrtr := new(bytes.Buffer)
- tpDsph := TPDispatcherHosts{
- dm: nil,
- }
- dsph := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "DSH1",
- Address: "*internal",
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- }
- tpDsph.dm.SetDispatcherHost(context.Background(), dsph)
- err := tpDsph.exportItems(context.Background(), wrtr, "cgrates.org", []string{"DSH1"})
- if err != utils.ErrNoDatabaseConn {
- t.Errorf("Expected %v\n but received %v", utils.ErrNoDatabaseConn, err)
- }
-}
-
-func TestTPEExportItemsDispatchersIDNotFoundHost(t *testing.T) {
- wrtr := new(bytes.Buffer)
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- tpDsph := TPDispatcherHosts{
- dm: dm,
- }
- dsph := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "DSH1",
- Address: "*internal",
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- }
- tpDsph.dm.SetDispatcherHost(context.Background(), dsph)
- err := tpDsph.exportItems(context.Background(), wrtr, "cgrates.org", []string{"DSH2"})
- errExpect := " cannot find DispatcherHost with id: "
- if err.Error() != errExpect {
- t.Errorf("Expected %v\n but received %v", errExpect, err)
- }
-}
diff --git a/tpes/tpe_dispatchers.go b/tpes/tpe_dispatchers.go
deleted file mode 100644
index 79ed99f48..000000000
--- a/tpes/tpe_dispatchers.go
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package tpes
-
-import (
- "encoding/csv"
- "fmt"
- "io"
-
- "github.com/cgrates/birpc/context"
-
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-type TPDispatchers struct {
- dm *engine.DataManager
-}
-
-// newTPDispatchers is the constructor for TPDispatchers
-func newTPDispatchers(dm *engine.DataManager) *TPDispatchers {
- return &TPDispatchers{
- dm: dm,
- }
-}
-
-// exportItems for TPDispatchers will implement the method for tpExporter interface
-func (tpDsp TPDispatchers) exportItems(ctx *context.Context, wrtr io.Writer, tnt string, itmIDs []string) (err error) {
- csvWriter := csv.NewWriter(wrtr)
- csvWriter.Comma = utils.CSVSep
- // before writing the profiles, we must write the headers
- if err = csvWriter.Write([]string{"#Tenant", "ID", "FilterIDs", "Weight", "Strategy", "StrategyParameters", "ConnID", "ConnFilterIDs", "ConnWeight", "ConnBlocker", "ConnParameters"}); err != nil {
- return
- }
- for _, dspID := range itmIDs {
- var dspPrf *engine.DispatcherProfile
- dspPrf, err = tpDsp.dm.GetDispatcherProfile(ctx, tnt, dspID, true, true, utils.NonTransactional)
- if err != nil {
- if err.Error() == utils.ErrDSPProfileNotFound.Error() {
- return fmt.Errorf("<%s> cannot find DispatcherProfile with id: <%v>", err, dspID)
- }
- return err
- }
- dspMdls := engine.APItoModelTPDispatcherProfile(engine.DispatcherProfileToAPI(dspPrf))
- if len(dspMdls) == 0 {
- return
- }
- // for every profile, convert it into model to be compatible in csv format
- for _, tpItem := range dspMdls {
- // transform every record into a []string
- var record []string
- record, err = engine.CsvDump(tpItem)
- if err != nil {
- return err
- }
- // record is a line of a csv file
- if err = csvWriter.Write(record); err != nil {
- return err
- }
- }
- }
- csvWriter.Flush()
- return
-}
diff --git a/tpes/tpe_dispatchers_test.go b/tpes/tpe_dispatchers_test.go
deleted file mode 100644
index 7791ac6e1..000000000
--- a/tpes/tpe_dispatchers_test.go
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package tpes
-
-import (
- "bytes"
- "testing"
-
- "github.com/cgrates/birpc/context"
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestTPEnewTPDispatchers(t *testing.T) {
- // dataDB := &engine.DataDBM
- // dm := &engine.NewDataManager()
- cfg := config.NewDefaultCGRConfig()
- connMng := engine.NewConnManager(cfg)
- dm := engine.NewDataManager(&engine.DataDBMock{
- GetDispatcherProfileDrvF: func(ctx *context.Context, str1 string, str2 string) (*engine.DispatcherProfile, error) {
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: "false",
- },
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203"},
- Blocker: false,
- },
- },
- }
- return dsp, nil
- },
- }, nil, connMng)
- exp := &TPDispatchers{
- dm: dm,
- }
- rcv := newTPDispatchers(dm)
- if rcv.dm != exp.dm {
- t.Errorf("Expected %v \nbut received %v", exp, rcv)
- }
-}
-
-func TestTPEExportItemsDispatchers(t *testing.T) {
- wrtr := new(bytes.Buffer)
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- tpDsp := TPDispatchers{
- dm: dm,
- }
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: "false",
- },
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203"},
- Blocker: false,
- },
- },
- }
- tpDsp.dm.SetDispatcherProfile(context.Background(), dsp, false)
- err := tpDsp.exportItems(context.Background(), wrtr, "cgrates.org", []string{"Dsp1"})
- if err != nil {
- t.Errorf("Expected nil\n but received %v", err)
- }
-}
-
-func TestTPEExportItemsDispatchersNoDbConn(t *testing.T) {
- engine.Cache.Clear(nil)
- wrtr := new(bytes.Buffer)
- tpDsp := TPDispatchers{
- dm: nil,
- }
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: "false",
- },
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203"},
- Blocker: false,
- },
- },
- }
- tpDsp.dm.SetDispatcherProfile(context.Background(), dsp, false)
- err := tpDsp.exportItems(context.Background(), wrtr, "cgrates.org", []string{"Dsp1"})
- if err != utils.ErrNoDatabaseConn {
- t.Errorf("Expected %v\n but received %v", utils.ErrNoDatabaseConn, err)
- }
-}
-
-func TestTPEExportItemsDispatchersIDNotFound(t *testing.T) {
- wrtr := new(bytes.Buffer)
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, cfg.DataDbCfg().Items)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- tpDsp := TPDispatchers{
- dm: dm,
- }
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: "false",
- },
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203"},
- Blocker: false,
- },
- },
- }
- tpDsp.dm.SetDispatcherProfile(context.Background(), dsp, false)
- err := tpDsp.exportItems(context.Background(), wrtr, "cgrates.org", []string{"Dsp2"})
- errExpect := " cannot find DispatcherProfile with id: "
- if err.Error() != errExpect {
- t.Errorf("Expected %v\n but received %v", errExpect, err)
- }
-}
diff --git a/tpes/tpes.go b/tpes/tpes.go
index c1d5dcf90..a7e889787 100644
--- a/tpes/tpes.go
+++ b/tpes/tpes.go
@@ -91,10 +91,6 @@ func getTariffPlansKeys(ctx *context.Context, dm *engine.DataManager, tnt, expTy
prfx = utils.RankingProfilePrefix + tnt + utils.ConcatenatedKeySep
case utils.MetaTrends:
prfx = utils.TrendProfilePrefix + tnt + utils.ConcatenatedKeySep
- case utils.MetaDispatchers:
- prfx = utils.DispatcherProfilePrefix + tnt + utils.ConcatenatedKeySep
- case utils.MetaDispatcherHosts:
- prfx = utils.DispatcherHostPrefix + tnt + utils.ConcatenatedKeySep
default:
return nil, fmt.Errorf("Unsuported exporter type")
}
diff --git a/tpes/tpes_test.go b/tpes/tpes_test.go
index 46c2ce537..951b86f82 100644
--- a/tpes/tpes_test.go
+++ b/tpes/tpes_test.go
@@ -21,7 +21,6 @@ package tpes
import (
"reflect"
"testing"
- "time"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
@@ -347,52 +346,6 @@ func TestGetTariffPlansKeys(t *testing.T) {
t.Errorf("Expected %v\n but received %v", exp, rcv)
}
- //Dispatchers
- dsp := &engine.DispatcherProfile{
- Tenant: "cgrates.org",
- ID: "Dsp1",
- FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"},
- Strategy: utils.MetaFirst,
- StrategyParams: map[string]any{
- utils.MetaDefaultRatio: "false",
- },
- Weight: 20,
- Hosts: engine.DispatcherHostProfiles{
- {
- ID: "C1",
- FilterIDs: []string{},
- Weight: 10,
- Params: map[string]any{"0": "192.168.54.203"},
- Blocker: false,
- },
- },
- }
- dm.SetDispatcherProfile(context.Background(), dsp, false)
- rcv, _ = getTariffPlansKeys(context.Background(), dm, "cgrates.org", utils.MetaDispatchers)
- exp = []string{"Dsp1"}
- if !reflect.DeepEqual(rcv, exp) {
- t.Errorf("Expected %v\n but received %v", exp, rcv)
- }
-
- //DispatcherHosts
- dsph := &engine.DispatcherHost{
- Tenant: "cgrates.org",
- RemoteHost: &config.RemoteHost{
- ID: "DSH1",
- Address: "*internal",
- ConnectAttempts: 1,
- Reconnects: 3,
- ConnectTimeout: time.Minute,
- ReplyTimeout: 2 * time.Minute,
- },
- }
- dm.SetDispatcherHost(context.Background(), dsph)
- rcv, _ = getTariffPlansKeys(context.Background(), dm, "cgrates.org", utils.MetaDispatcherHosts)
- exp = []string{"DSH1"}
- if !reflect.DeepEqual(rcv, exp) {
- t.Errorf("Expected %v\n but received %v", exp, rcv)
- }
-
//Unsupported
_, err := getTariffPlansKeys(context.Background(), dm, "cgrates.org", "not_valid")
errExpect := "Unsuported exporter type"
diff --git a/tpes/tpexporter.go b/tpes/tpexporter.go
index 452d9ef50..d8ae69483 100644
--- a/tpes/tpexporter.go
+++ b/tpes/tpexporter.go
@@ -38,24 +38,20 @@ var tpExporterTypes = utils.NewStringSet([]string{
utils.MetaStats,
utils.MetaActions,
utils.MetaThresholds,
- utils.MetaDispatchers,
- utils.MetaDispatcherHosts,
})
var exportFileName = map[string]string{
- utils.MetaAttributes: utils.AttributesCsv,
- utils.MetaResources: utils.ResourcesCsv,
- utils.MetaFilters: utils.FiltersCsv,
- utils.MetaStats: utils.StatsCsv,
- utils.MetaThresholds: utils.ThresholdsCsv,
- utils.MetaTrends: utils.TrendsCsv,
- utils.MetaRoutes: utils.RoutesCsv,
- utils.MetaChargers: utils.ChargersCsv,
- utils.MetaDispatchers: utils.DispatcherProfilesCsv,
- utils.MetaDispatcherHosts: utils.DispatcherHostsCsv,
- utils.MetaRates: utils.RatesCsv,
- utils.MetaActions: utils.ActionsCsv,
- utils.MetaAccounts: utils.AccountsCsv,
+ utils.MetaAttributes: utils.AttributesCsv,
+ utils.MetaResources: utils.ResourcesCsv,
+ utils.MetaFilters: utils.FiltersCsv,
+ utils.MetaStats: utils.StatsCsv,
+ utils.MetaThresholds: utils.ThresholdsCsv,
+ utils.MetaTrends: utils.TrendsCsv,
+ utils.MetaRoutes: utils.RoutesCsv,
+ utils.MetaChargers: utils.ChargersCsv,
+ utils.MetaRates: utils.RatesCsv,
+ utils.MetaActions: utils.ActionsCsv,
+ utils.MetaAccounts: utils.AccountsCsv,
}
// tpExporter is the interface implementing exports of tariff plan items
@@ -90,10 +86,6 @@ func newTPExporter(expType string, dm *engine.DataManager) (tpE tpExporter, err
return newTPActions(dm), nil
case utils.MetaThresholds:
return newTPThresholds(dm), nil
- case utils.MetaDispatchers:
- return newTPDispatchers(dm), nil
- case utils.MetaDispatcherHosts:
- return newTPDispatcherHosts(dm), nil
default:
return nil, utils.ErrPrefix(utils.ErrUnsupportedTPExporterType, expType)
}
diff --git a/tpes/tpexporter_test.go b/tpes/tpexporter_test.go
index 9b76f9add..53041b277 100644
--- a/tpes/tpexporter_test.go
+++ b/tpes/tpexporter_test.go
@@ -146,30 +146,6 @@ func TestNewTPExporter(t *testing.T) {
t.Errorf("Expected %v\n but received %v", expThd, rcv)
}
- //Dispatchers
- rcv, err = newTPExporter(utils.MetaDispatchers, nil)
- if err != nil {
- t.Error(err)
- }
- expDsp := &TPDispatchers{
- dm: nil,
- }
- if !reflect.DeepEqual(rcv, expDsp) {
- t.Errorf("Expected %v\n but received %v", expDsp, rcv)
- }
-
- //DispatcherHost
- rcv, err = newTPExporter(utils.MetaDispatcherHosts, nil)
- if err != nil {
- t.Error(err)
- }
- expDsph := &TPDispatcherHosts{
- dm: nil,
- }
- if !reflect.DeepEqual(rcv, expDsph) {
- t.Errorf("Expected %v\n but received %v", expDsph, rcv)
- }
-
//Unsupported type
_, err = newTPExporter("does not exist", nil)
errExpect := "UNSUPPORTED_TPEXPORTER_TYPE:does not exist"
diff --git a/utils/apitpdata.go b/utils/apitpdata.go
index f21642b8e..c20230a64 100644
--- a/utils/apitpdata.go
+++ b/utils/apitpdata.go
@@ -161,25 +161,23 @@ type ArgsComputeFilterIndexIDs struct {
RouteIDs []string
ThresholdIDs []string
ChargerIDs []string
- DispatcherIDs []string
RateProfileIDs []string
AccountIDs []string
ActionProfileIDs []string
}
type ArgsComputeFilterIndexes struct {
- Tenant string
- APIOpts map[string]any
- AttributeS bool
- ResourceS bool
- StatS bool
- RouteS bool
- ThresholdS bool
- ChargerS bool
- DispatcherS bool
- RateS bool
- AccountS bool
- ActionS bool
+ Tenant string
+ APIOpts map[string]any
+ AttributeS bool
+ ResourceS bool
+ StatS bool
+ RouteS bool
+ ThresholdS bool
+ ChargerS bool
+ RateS bool
+ AccountS bool
+ ActionS bool
}
// TPActivationInterval represents an activation interval for an item
@@ -375,50 +373,6 @@ type TPTntID struct {
ID string
}
-// TPDispatcherProfile is used in APIs to manage remotely offline DispatcherProfile
-type TPDispatcherProfile struct {
- TPid string
- Tenant string
- ID string
- FilterIDs []string
- Strategy string
- StrategyParams []any // ie for distribution, set here the pool weights
- Weight float64
- Hosts []*TPDispatcherHostProfile
-}
-
-// TPDispatcherHostProfile is used in TPDispatcherProfile
-type TPDispatcherHostProfile struct {
- ID string
- FilterIDs []string
- Weight float64 // applied in case of multiple connections need to be ordered
- Params []any // additional parameters stored for a session
- Blocker bool // no connection after this one
-}
-
-// TPDispatcherHost is used in APIs to manage remotely offline DispatcherHost
-type TPDispatcherHost struct {
- TPid string
- Tenant string
- ID string
- Conn *TPDispatcherHostConn
-}
-
-// TPDispatcherHostConn is used in TPDispatcherHost
-type TPDispatcherHostConn struct {
- Address string
- Transport string
- ConnectAttempts int
- Reconnects int
- MaxReconnectInterval time.Duration
- ConnectTimeout time.Duration
- ReplyTimeout time.Duration
- TLS bool
- ClientKey string
- ClientCertificate string
- CaCertificate string
-}
-
type AttrRemoteLock struct {
ReferenceID string // reference ID for this lock if available
LockIDs []string // List of IDs to obtain lock for
@@ -459,9 +413,6 @@ func NewAttrReloadCacheWithOpts() *AttrReloadCacheWithAPIOpts {
RouteProfileIDs: []string{MetaAny},
AttributeProfileIDs: []string{MetaAny},
ChargerProfileIDs: []string{MetaAny},
- DispatcherProfileIDs: []string{MetaAny},
- DispatcherHostIDs: []string{MetaAny},
- Dispatchers: []string{MetaAny},
RateProfileIDs: []string{MetaAny},
ActionProfileIDs: []string{MetaAny},
AccountIDs: []string{MetaAny},
@@ -473,7 +424,6 @@ func NewAttrReloadCacheWithOpts() *AttrReloadCacheWithAPIOpts {
ThresholdFilterIndexIDs: []string{MetaAny},
RouteFilterIndexIDs: []string{MetaAny},
ChargerFilterIndexIDs: []string{MetaAny},
- DispatcherFilterIndexIDs: []string{MetaAny},
RateProfilesFilterIndexIDs: []string{MetaAny},
RateFilterIndexIDs: []string{MetaAny},
FilterIndexIDs: []string{MetaAny},
@@ -499,9 +449,6 @@ func NewAttrReloadCacheWithOptsFromMap(arg map[string][]string, tnt string, opts
RouteProfileIDs: arg[CacheRouteProfiles],
AttributeProfileIDs: arg[CacheAttributeProfiles],
ChargerProfileIDs: arg[CacheChargerProfiles],
- DispatcherProfileIDs: arg[CacheDispatcherProfiles],
- DispatcherHostIDs: arg[CacheDispatcherHosts],
- Dispatchers: arg[CacheDispatchers],
RateProfileIDs: arg[CacheRateProfiles],
ActionProfileIDs: arg[CacheActionProfiles],
AccountIDs: arg[CacheAccounts],
@@ -511,7 +458,6 @@ func NewAttrReloadCacheWithOptsFromMap(arg map[string][]string, tnt string, opts
RouteFilterIndexIDs: arg[CacheRouteFilterIndexes],
AttributeFilterIndexIDs: arg[CacheAttributeFilterIndexes],
ChargerFilterIndexIDs: arg[CacheChargerFilterIndexes],
- DispatcherFilterIndexIDs: arg[CacheDispatcherFilterIndexes],
RateProfilesFilterIndexIDs: arg[CacheRateProfilesFilterIndexes],
ActionProfilesFilterIndexIDs: arg[CacheActionProfilesFilterIndexes],
AccountsFilterIndexIDs: arg[CacheAccountsFilterIndexes],
@@ -540,9 +486,6 @@ type AttrReloadCacheWithAPIOpts struct {
RouteProfileIDs []string `json:",omitempty"`
AttributeProfileIDs []string `json:",omitempty"`
ChargerProfileIDs []string `json:",omitempty"`
- DispatcherProfileIDs []string `json:",omitempty"`
- DispatcherHostIDs []string `json:",omitempty"`
- Dispatchers []string `json:",omitempty"`
RateProfileIDs []string `json:",omitempty"`
ActionProfileIDs []string `json:",omitempty"`
AccountIDs []string `json:",omitempty"`
@@ -553,7 +496,6 @@ type AttrReloadCacheWithAPIOpts struct {
ThresholdFilterIndexIDs []string `json:",omitempty"`
RouteFilterIndexIDs []string `json:",omitempty"`
ChargerFilterIndexIDs []string `json:",omitempty"`
- DispatcherFilterIndexIDs []string `json:",omitempty"`
RateProfilesFilterIndexIDs []string `json:",omitempty"`
RateFilterIndexIDs []string `json:",omitempty"`
FilterIndexIDs []string `json:",omitempty"`
@@ -577,9 +519,6 @@ func (a *AttrReloadCacheWithAPIOpts) Map() map[string][]string {
CacheChargerProfiles: a.ChargerProfileIDs,
CacheRankingProfiles: a.RankingProfileIDs,
CacheRankings: a.RankingIDs,
- CacheDispatcherProfiles: a.DispatcherProfileIDs,
- CacheDispatcherHosts: a.DispatcherHostIDs,
- CacheDispatchers: a.Dispatchers,
CacheRateProfiles: a.RateProfileIDs,
CacheActionProfiles: a.ActionProfileIDs,
CacheAccounts: a.AccountIDs,
@@ -589,7 +528,6 @@ func (a *AttrReloadCacheWithAPIOpts) Map() map[string][]string {
CacheRouteFilterIndexes: a.RouteFilterIndexIDs,
CacheAttributeFilterIndexes: a.AttributeFilterIndexIDs,
CacheChargerFilterIndexes: a.ChargerFilterIndexIDs,
- CacheDispatcherFilterIndexes: a.DispatcherFilterIndexIDs,
CacheRateProfilesFilterIndexes: a.RateProfilesFilterIndexIDs,
CacheActionProfilesFilterIndexes: a.ActionProfilesFilterIndexIDs,
CacheAccountsFilterIndexes: a.AccountsFilterIndexIDs,
diff --git a/utils/apitpdata_test.go b/utils/apitpdata_test.go
index 5053ea191..d31d85f02 100644
--- a/utils/apitpdata_test.go
+++ b/utils/apitpdata_test.go
@@ -124,9 +124,6 @@ func TestNewAttrReloadCacheWithOpts(t *testing.T) {
RouteProfileIDs: []string{MetaAny},
AttributeProfileIDs: []string{MetaAny},
ChargerProfileIDs: []string{MetaAny},
- DispatcherProfileIDs: []string{MetaAny},
- DispatcherHostIDs: []string{MetaAny},
- Dispatchers: []string{MetaAny},
RateProfileIDs: []string{MetaAny},
AttributeFilterIndexIDs: []string{MetaAny},
ResourceFilterIndexIDs: []string{MetaAny},
@@ -134,7 +131,6 @@ func TestNewAttrReloadCacheWithOpts(t *testing.T) {
ThresholdFilterIndexIDs: []string{MetaAny},
RouteFilterIndexIDs: []string{MetaAny},
ChargerFilterIndexIDs: []string{MetaAny},
- DispatcherFilterIndexIDs: []string{MetaAny},
RateProfilesFilterIndexIDs: []string{MetaAny},
RateFilterIndexIDs: []string{MetaAny},
FilterIndexIDs: []string{MetaAny},
diff --git a/utils/consts.go b/utils/consts.go
index 83e81ea17..7cc8f332a 100644
--- a/utils/consts.go
+++ b/utils/consts.go
@@ -31,17 +31,17 @@ var (
GitCommitDate string // If set, it will be processed as part of versioning
GitCommitHash string // If set, it will be processed as part of versioning
- extraDBPartition = NewStringSet([]string{CacheDispatchers,
- CacheDispatcherRoutes, CacheDispatcherLoads, CacheDiameterMessages, CacheRPCResponses, CacheClosedSessions,
+ extraDBPartition = NewStringSet([]string{
+ CacheDiameterMessages, CacheRPCResponses, CacheClosedSessions,
CacheCDRIDs, CacheRPCConnections, CacheUCH, CacheSTIR, CacheEventCharges, MetaAPIBan, MetaSentryPeer,
CacheCapsEvents, CacheReplicationHosts})
DataDBPartitions = NewStringSet([]string{
CacheResourceProfiles, CacheResources, CacheEventResources, CacheStatQueueProfiles, CacheStatQueues,
CacheThresholdProfiles, CacheThresholds, CacheFilters, CacheRouteProfiles, CacheAttributeProfiles, CacheTrendProfiles,
- CacheChargerProfiles, CacheActionProfiles, CacheDispatcherProfiles, CacheDispatcherHosts, CacheRankingProfiles, CacheRankings, CacheTrends,
+ CacheChargerProfiles, CacheActionProfiles, CacheRankingProfiles, CacheRankings, CacheTrends,
CacheResourceFilterIndexes, CacheStatFilterIndexes, CacheThresholdFilterIndexes, CacheRouteFilterIndexes,
- CacheAttributeFilterIndexes, CacheChargerFilterIndexes, CacheDispatcherFilterIndexes, CacheLoadIDs,
+ CacheAttributeFilterIndexes, CacheChargerFilterIndexes, CacheLoadIDs,
CacheRateProfiles, CacheRateProfilesFilterIndexes, CacheRateFilterIndexes,
CacheActionProfilesFilterIndexes, CacheAccountsFilterIndexes, CacheReverseFilterIndexes,
CacheAccounts})
@@ -64,8 +64,6 @@ var (
CacheRankings: RankingProfilePrefix,
CacheAttributeProfiles: AttributeProfilePrefix,
CacheChargerProfiles: ChargerProfilePrefix,
- CacheDispatcherProfiles: DispatcherProfilePrefix,
- CacheDispatcherHosts: DispatcherHostPrefix,
CacheRateProfiles: RateProfilePrefix,
CacheActionProfiles: ActionProfilePrefix,
CacheAccounts: AccountPrefix,
@@ -75,7 +73,6 @@ var (
CacheRouteFilterIndexes: RouteFilterIndexes,
CacheAttributeFilterIndexes: AttributeFilterIndexes,
CacheChargerFilterIndexes: ChargerFilterIndexes,
- CacheDispatcherFilterIndexes: DispatcherFilterIndexes,
CacheRateProfilesFilterIndexes: RateProfilesFilterIndexPrfx,
CacheActionProfilesFilterIndexes: ActionProfilesFilterIndexPrfx,
CacheAccountsFilterIndexes: AccountFilterIndexPrfx,
@@ -84,7 +81,6 @@ var (
CacheRateFilterIndexes: RateFilterIndexPrfx,
CacheReverseFilterIndexes: FilterIndexPrfx,
MetaAPIBan: MetaAPIBan, // special case as it is not in a DB
- CacheDispatchers: MetaDispatchers,
}
CachePrefixToInstance map[string]string // will be built on init
CacheIndexesToPrefix = map[string]string{ // used by match index to get all the ids when index selects is disabled and for compute indexes
@@ -94,7 +90,6 @@ var (
CacheRouteFilterIndexes: RouteProfilePrefix,
CacheAttributeFilterIndexes: AttributeProfilePrefix,
CacheChargerFilterIndexes: ChargerProfilePrefix,
- CacheDispatcherFilterIndexes: DispatcherProfilePrefix,
CacheRateProfilesFilterIndexes: RateProfilePrefix,
CacheActionProfilesFilterIndexes: ActionProfilePrefix,
CacheAccountsFilterIndexes: AccountPrefix,
@@ -102,17 +97,16 @@ var (
}
CacheInstanceToCacheIndex = map[string]string{
- CacheThresholdProfiles: CacheThresholdFilterIndexes,
- CacheResourceProfiles: CacheResourceFilterIndexes,
- CacheStatQueueProfiles: CacheStatFilterIndexes,
- CacheRouteProfiles: CacheRouteFilterIndexes,
- CacheAttributeProfiles: CacheAttributeFilterIndexes,
- CacheChargerProfiles: CacheChargerFilterIndexes,
- CacheDispatcherProfiles: CacheDispatcherFilterIndexes,
- CacheRateProfiles: CacheRateProfilesFilterIndexes,
- CacheActionProfiles: CacheActionProfilesFilterIndexes,
- CacheFilters: CacheReverseFilterIndexes,
- CacheAccounts: CacheAccountsFilterIndexes,
+ CacheThresholdProfiles: CacheThresholdFilterIndexes,
+ CacheResourceProfiles: CacheResourceFilterIndexes,
+ CacheStatQueueProfiles: CacheStatFilterIndexes,
+ CacheRouteProfiles: CacheRouteFilterIndexes,
+ CacheAttributeProfiles: CacheAttributeFilterIndexes,
+ CacheChargerProfiles: CacheChargerFilterIndexes,
+ CacheRateProfiles: CacheRateProfilesFilterIndexes,
+ CacheActionProfiles: CacheActionProfilesFilterIndexes,
+ CacheFilters: CacheReverseFilterIndexes,
+ CacheAccounts: CacheAccountsFilterIndexes,
}
// ProtectedSFlds are the fields that sessions should not alter
@@ -257,11 +251,9 @@ const (
RouteProfilePrefix = "rpp_"
AttributeProfilePrefix = "alp_"
ChargerProfilePrefix = "cpp_"
- DispatcherProfilePrefix = "dpp_"
RateProfilePrefix = "rtp_"
ActionProfilePrefix = "acp_"
AccountPrefix = "acn_"
- DispatcherHostPrefix = "dph_"
ThresholdProfilePrefix = "thp_"
StatQueuePrefix = "stq_"
RankingProfilePrefix = "rgp_"
@@ -367,8 +359,6 @@ const (
MetaChargers = "*chargers"
MetaConfig = "*config"
MetaTpes = "*tpes"
- MetaDispatchers = "*dispatchers"
- MetaDispatcherHosts = "*dispatcher_hosts"
MetaFilters = "*filters"
MetaCDRs = "*cdrs"
MetaDC = "*dc"
@@ -420,8 +410,6 @@ const (
Rankings = "Rankings"
Trends = "Trends"
Filters = "Filters"
- DispatcherProfiles = "DispatcherProfiles"
- DispatcherHosts = "DispatcherHosts"
RateProfiles = "RateProfiles"
ActionProfiles = "ActionProfiles"
AccountsString = "Accounts"
@@ -452,7 +440,6 @@ const (
Routes = "Routes"
Attributes = "Attributes"
Chargers = "Chargers"
- Dispatchers = "Dispatchers"
StatS = "StatS"
LoadIDsVrs = "LoadIDs"
GlobalVarS = "GlobalVarS"
@@ -934,26 +921,25 @@ const (
// Meta Items
const (
- MetaAccounts = "*accounts"
- MetaActions = "*actions"
- MetaResourceProfile = "*resource_profiles"
- MetaStatQueueProfiles = "*statqueue_profiles"
- MetaStatQueues = "*statqueues"
- MetaRankingProfiles = "*ranking_profiles"
- MetaTrendProfiles = "*trend_profiles"
- MetaThresholdProfiles = "*threshold_profiles"
- MetaRouteProfiles = "*route_profiles"
- MetaAttributeProfiles = "*attribute_profiles"
- MetaDispatcherProfiles = "*dispatcher_profiles"
- MetaRateProfiles = "*rate_profiles"
- MetaRateProfileRates = "*rate_profile_rates"
- MetaChargerProfiles = "*charger_profiles"
- MetaThresholds = "*thresholds"
- MetaRoutes = "*routes"
- MetaAttributes = "*attributes"
- MetaActionProfiles = "*action_profiles"
- MetaLoadIDs = "*load_ids"
- MetaNodeID = "*node_id"
+ MetaAccounts = "*accounts"
+ MetaActions = "*actions"
+ MetaResourceProfile = "*resource_profiles"
+ MetaStatQueueProfiles = "*statqueue_profiles"
+ MetaStatQueues = "*statqueues"
+ MetaRankingProfiles = "*ranking_profiles"
+ MetaTrendProfiles = "*trend_profiles"
+ MetaThresholdProfiles = "*threshold_profiles"
+ MetaRouteProfiles = "*route_profiles"
+ MetaAttributeProfiles = "*attribute_profiles"
+ MetaRateProfiles = "*rate_profiles"
+ MetaRateProfileRates = "*rate_profile_rates"
+ MetaChargerProfiles = "*charger_profiles"
+ MetaThresholds = "*thresholds"
+ MetaRoutes = "*routes"
+ MetaAttributes = "*attributes"
+ MetaActionProfiles = "*action_profiles"
+ MetaLoadIDs = "*load_ids"
+ MetaNodeID = "*node_id"
)
// MetaMetrics
@@ -982,7 +968,6 @@ const (
ThresholdS = "ThresholdS"
TrendS = "TrendS"
RankingS = "RankingS"
- DispatcherS = "DispatcherS"
RegistrarC = "RegistrarC"
LoaderS = "LoaderS"
ChargerS = "ChargerS"
@@ -1007,7 +992,6 @@ const (
ResourcesLow = "resources"
StatServiceLow = "stats"
ThresholdsLow = "thresholds"
- DispatcherSLow = "dispatchers"
AnalyzerSLow = "analyzers"
SchedulerSLow = "schedulers"
LoaderSLow = "loaders"
@@ -1063,7 +1047,6 @@ const (
MetaTpRateProfiles = "*tp_rate_profiles"
MetaTpResources = "*tp_resources"
MetaTpChargers = "*tp_chargers"
- MetaTpDispatchers = "*tp_dispatchers"
MetaDurationSeconds = "*duration_seconds"
MetaDurationNanoseconds = "*duration_nanoseconds"
CapAttributes = "Attributes"
@@ -1076,20 +1059,17 @@ const (
)
const (
- TpFilters = "TpFilters"
- TpThresholds = "TpThresholds"
- TpRoutes = "TpRoutes"
- TpAttributes = "TpAttributes"
- TpStats = "TpStats"
- TpResources = "TpResources"
- TpResource = "TpResource"
- TpChargers = "TpChargers"
- TpDispatchers = "TpDispatchers"
- TpDispatcherProfiles = "TpDispatcherProfiles"
- TpDispatcherHosts = "TpDispatcherHosts"
- TpRateProfiles = "TpRateProfiles"
- TpActionProfiles = "TpActionProfiles"
- TpAccounts = "TpAccounts"
+ TpFilters = "TpFilters"
+ TpThresholds = "TpThresholds"
+ TpRoutes = "TpRoutes"
+ TpAttributes = "TpAttributes"
+ TpStats = "TpStats"
+ TpResources = "TpResources"
+ TpResource = "TpResource"
+ TpChargers = "TpChargers"
+ TpRateProfiles = "TpRateProfiles"
+ TpActionProfiles = "TpActionProfiles"
+ TpAccounts = "TpAccounts"
)
// Dispatcher Const
@@ -1197,40 +1177,36 @@ const (
ReplicatorSv1SetRanking = "ReplicatorSv1.SetRanking"
ReplicatorSv1SetTrendProfile = "ReplicatorSv1.SetTrendProfile"
ReplicatorSv1SetTrend
- ReplicatorSv1SetResource = "ReplicatorSv1.SetResource"
- ReplicatorSv1SetResourceProfile = "ReplicatorSv1.SetResourceProfile"
- ReplicatorSv1SetRouteProfile = "ReplicatorSv1.SetRouteProfile"
- ReplicatorSv1SetAttributeProfile = "ReplicatorSv1.SetAttributeProfile"
- ReplicatorSv1SetChargerProfile = "ReplicatorSv1.SetChargerProfile"
- ReplicatorSv1SetDispatcherProfile = "ReplicatorSv1.SetDispatcherProfile"
- ReplicatorSv1SetRateProfile = "ReplicatorSv1.SetRateProfile"
- ReplicatorSv1SetActionProfile = "ReplicatorSv1.SetActionProfile"
- ReplicatorSv1SetAccount = "ReplicatorSv1.SetAccount"
- ReplicatorSv1SetDispatcherHost = "ReplicatorSv1.SetDispatcherHost"
- ReplicatorSv1SetLoadIDs = "ReplicatorSv1.SetLoadIDs"
- ReplicatorSv1RemoveThreshold = "ReplicatorSv1.RemoveThreshold"
+ ReplicatorSv1SetResource = "ReplicatorSv1.SetResource"
+ ReplicatorSv1SetResourceProfile = "ReplicatorSv1.SetResourceProfile"
+ ReplicatorSv1SetRouteProfile = "ReplicatorSv1.SetRouteProfile"
+ ReplicatorSv1SetAttributeProfile = "ReplicatorSv1.SetAttributeProfile"
+ ReplicatorSv1SetChargerProfile = "ReplicatorSv1.SetChargerProfile"
+ ReplicatorSv1SetRateProfile = "ReplicatorSv1.SetRateProfile"
+ ReplicatorSv1SetActionProfile = "ReplicatorSv1.SetActionProfile"
+ ReplicatorSv1SetAccount = "ReplicatorSv1.SetAccount"
+ ReplicatorSv1SetLoadIDs = "ReplicatorSv1.SetLoadIDs"
+ ReplicatorSv1RemoveThreshold = "ReplicatorSv1.RemoveThreshold"
- ReplicatorSv1RemoveStatQueue = "ReplicatorSv1.RemoveStatQueue"
- ReplicatorSv1RemoveFilter = "ReplicatorSv1.RemoveFilter"
- ReplicatorSv1RemoveThresholdProfile = "ReplicatorSv1.RemoveThresholdProfile"
- ReplicatorSv1RemoveStatQueueProfile = "ReplicatorSv1.RemoveStatQueueProfile"
- ReplicatorSv1RemoveRankingProfile = "ReplicatorSv1.RemoveRankingProfile"
- ReplicatorSv1RemoveRanking = "ReplicatorSv1.RemoveRanking"
- ReplicatorSv1RemoveTrendProfile = "ReplicatorSv1.RemoveTrendProfile"
- ReplicatorSv1RemoveTrend = "ReplicatorSv1.RemoveTrend"
- ReplicatorSv1RemoveResource = "ReplicatorSv1.RemoveResource"
- ReplicatorSv1RemoveResourceProfile = "ReplicatorSv1.RemoveResourceProfile"
- ReplicatorSv1RemoveRouteProfile = "ReplicatorSv1.RemoveRouteProfile"
- ReplicatorSv1RemoveAttributeProfile = "ReplicatorSv1.RemoveAttributeProfile"
- ReplicatorSv1RemoveChargerProfile = "ReplicatorSv1.RemoveChargerProfile"
- ReplicatorSv1RemoveDispatcherProfile = "ReplicatorSv1.RemoveDispatcherProfile"
- ReplicatorSv1RemoveRateProfile = "ReplicatorSv1.RemoveRateProfile"
- ReplicatorSv1RemoveActionProfile = "ReplicatorSv1.RemoveActionProfile"
- ReplicatorSv1RemoveDispatcherHost = "ReplicatorSv1.RemoveDispatcherHost"
- ReplicatorSv1RemoveAccount = "ReplicatorSv1.RemoveAccount"
- ReplicatorSv1GetIndexes = "ReplicatorSv1.GetIndexes"
- ReplicatorSv1SetIndexes = "ReplicatorSv1.SetIndexes"
- ReplicatorSv1RemoveIndexes = "ReplicatorSv1.RemoveIndexes"
+ ReplicatorSv1RemoveStatQueue = "ReplicatorSv1.RemoveStatQueue"
+ ReplicatorSv1RemoveFilter = "ReplicatorSv1.RemoveFilter"
+ ReplicatorSv1RemoveThresholdProfile = "ReplicatorSv1.RemoveThresholdProfile"
+ ReplicatorSv1RemoveStatQueueProfile = "ReplicatorSv1.RemoveStatQueueProfile"
+ ReplicatorSv1RemoveRankingProfile = "ReplicatorSv1.RemoveRankingProfile"
+ ReplicatorSv1RemoveRanking = "ReplicatorSv1.RemoveRanking"
+ ReplicatorSv1RemoveTrendProfile = "ReplicatorSv1.RemoveTrendProfile"
+ ReplicatorSv1RemoveTrend = "ReplicatorSv1.RemoveTrend"
+ ReplicatorSv1RemoveResource = "ReplicatorSv1.RemoveResource"
+ ReplicatorSv1RemoveResourceProfile = "ReplicatorSv1.RemoveResourceProfile"
+ ReplicatorSv1RemoveRouteProfile = "ReplicatorSv1.RemoveRouteProfile"
+ ReplicatorSv1RemoveAttributeProfile = "ReplicatorSv1.RemoveAttributeProfile"
+ ReplicatorSv1RemoveChargerProfile = "ReplicatorSv1.RemoveChargerProfile"
+ ReplicatorSv1RemoveRateProfile = "ReplicatorSv1.RemoveRateProfile"
+ ReplicatorSv1RemoveActionProfile = "ReplicatorSv1.RemoveActionProfile"
+ ReplicatorSv1RemoveAccount = "ReplicatorSv1.RemoveAccount"
+ ReplicatorSv1GetIndexes = "ReplicatorSv1.GetIndexes"
+ ReplicatorSv1SetIndexes = "ReplicatorSv1.SetIndexes"
+ ReplicatorSv1RemoveIndexes = "ReplicatorSv1.RemoveIndexes"
)
// AdminSv1 APIs
@@ -1734,20 +1710,18 @@ const (
// CSV file name
const (
- ResourcesCsv = "Resources.csv"
- StatsCsv = "Stats.csv"
- RankingsCsv = "Rankings.csv"
- TrendsCsv = "Trends.csv"
- ThresholdsCsv = "Thresholds.csv"
- FiltersCsv = "Filters.csv"
- RoutesCsv = "Routes.csv"
- AttributesCsv = "Attributes.csv"
- ChargersCsv = "Chargers.csv"
- DispatcherProfilesCsv = "DispatcherProfiles.csv"
- DispatcherHostsCsv = "DispatcherHosts.csv"
- RatesCsv = "Rates.csv"
- ActionsCsv = "Actions.csv"
- AccountsCsv = "Accounts.csv"
+ ResourcesCsv = "Resources.csv"
+ StatsCsv = "Stats.csv"
+ RankingsCsv = "Rankings.csv"
+ TrendsCsv = "Trends.csv"
+ ThresholdsCsv = "Thresholds.csv"
+ FiltersCsv = "Filters.csv"
+ RoutesCsv = "Routes.csv"
+ AttributesCsv = "Attributes.csv"
+ ChargersCsv = "Chargers.csv"
+ RatesCsv = "Rates.csv"
+ ActionsCsv = "Actions.csv"
+ AccountsCsv = "Accounts.csv"
)
// Table Name
@@ -1790,11 +1764,6 @@ const (
CacheRouteProfiles = "*route_profiles"
CacheAttributeProfiles = "*attribute_profiles"
CacheChargerProfiles = "*charger_profiles"
- CacheDispatcherProfiles = "*dispatcher_profiles"
- CacheDispatcherHosts = "*dispatcher_hosts"
- CacheDispatchers = "*dispatchers"
- CacheDispatcherRoutes = "*dispatcher_routes"
- CacheDispatcherLoads = "*dispatcher_loads"
CacheRateProfiles = "*rate_profiles"
CacheActionProfiles = "*action_profiles"
CacheAccounts = "*accounts"
@@ -1804,7 +1773,6 @@ const (
CacheRouteFilterIndexes = "*route_filter_indexes"
CacheAttributeFilterIndexes = "*attribute_filter_indexes"
CacheChargerFilterIndexes = "*charger_filter_indexes"
- CacheDispatcherFilterIndexes = "*dispatcher_filter_indexes"
CacheDiameterMessages = "*diameter_messages"
CacheRPCResponses = "*rpc_responses"
CacheClosedSessions = "*closed_sessions"
@@ -2182,9 +2150,6 @@ const (
AttributeIDsCfg = "attribute_ids"
ConcurrentRequestsCfg = "concurrent_requests"
- // DispatcherSCfg
- MetaDispatcherSCfg = "*dispatchers"
-
//LoaderSCfg
DryRunCfg = "dry_run"
LockFilePathCfg = "lockfile_path"
@@ -2423,7 +2388,7 @@ var CGROptionsSet = NewStringSet([]string{OptsRatesProfileIDs, OptsRatesStartTim
OptsStirPublicKeyPath, OptsStirPrivateKeyPath, OptsAPIKey, OptsRouteID, OptsContext, OptsAttributesProfileIDs,
OptsAttributesProcessRuns, OptsAttributesProfileRuns, OptsRoutesLimit, OptsRoutesOffset, OptsRoutesMaxItems,
OptsSesChargeable, RemoteHostOpt, MetaCache, OptsThresholdsProfileIDs, OptsRoutesProfilesCount,
- OptsDispatchersProfilesCount, OptsSesAttributeSDerivedReply, OptsSesBlockerError, OptsRoutesUsage,
+ OptsSesAttributeSDerivedReply, OptsSesBlockerError, OptsRoutesUsage,
MetaCDRs, OptsSesCDRsDerivedReply, MetaResources, OptsSesResourceSAuthorize,
OptsSesResourceSAllocate, OptsSesResourceSRelease, OptsSesResourceSDerivedReply, MetaRoutes,
OptsSesRouteSDerivedReply, OptsSesStatSDerivedReply, OptsSesSTIRAuthenticate, OptsSesSTIRDerivedReply,
@@ -2432,7 +2397,7 @@ var CGROptionsSet = NewStringSet([]string{OptsRatesProfileIDs, OptsRatesStartTim
OptsSesMessage, MetaAttributes, MetaChargers, OptsCDRsExport, OptsCDRsRefund,
OptsCDRsRerate, MetaStats, OptsCDRsStore, MetaThresholds, MetaRates, MetaAccounts,
OptsAccountsUsage, OptsStatsProfileIDs, OptsActionsProfileIDs, MetaProfileIgnoreFilters,
- OptsRoundingDecimals, MetaDispatchers})
+ OptsRoundingDecimals})
// Event Opts
const (
diff --git a/utils/errors_test.go b/utils/errors_test.go
index a7b8739a7..f61aa3f02 100644
--- a/utils/errors_test.go
+++ b/utils/errors_test.go
@@ -223,14 +223,6 @@ func TestNewAttributeS(t *testing.T) {
}
}
-func TestNewDispatcherS(t *testing.T) {
- err := errors.New("TEST_DISPATCHER_ERROR")
- exp := "DISPATCHER_ERROR:TEST_DISPATCHER_ERROR"
- if rcv := NewErrDispatcherS(err); rcv.Error() != exp {
- t.Errorf("Expected %v \n but received %v\n", exp, rcv)
- }
-}
-
func TestAPIErrorHandler(t *testing.T) {
errIn := &CGRError{
context: "*sessions",
diff --git a/utils/map_test.go b/utils/map_test.go
index 1e2d66cbc..77d9a5273 100644
--- a/utils/map_test.go
+++ b/utils/map_test.go
@@ -245,10 +245,6 @@ func TestFlagsWithParamsClone(t *testing.T) {
if !reflect.DeepEqual(cln, fWp) {
t.Errorf("Expecting: %+v, received: %+v", ToJSON(fWp), ToJSON(cln))
}
- cln[MetaDispatchers] = FlagParams{}
- if _, has := fWp[MetaDispatchers]; has {
- t.Errorf("Expected clone to not modify the cloned")
- }
cln[MetaThresholds][MetaIDs][0] = ""
if fWp[MetaThresholds][MetaIDs][0] != "ID1" {
t.Errorf("Expected clone to not modify the cloned")