mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Repair dispatcher opts tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
9dc0133207
commit
9f9e73ca45
@@ -20,11 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package dispatchers
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"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) {
|
||||
@@ -78,6 +77,23 @@ func (dS *DispatcherService) CacheSv1GetGroupItemIDs(ctx *context.Context, args
|
||||
}
|
||||
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 *interface{}) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args != nil && len(args.Tenant) != 0 {
|
||||
tnt = args.Tenant
|
||||
}
|
||||
ev := make(map[string]interface{})
|
||||
opts := make(map[string]interface{})
|
||||
if args != nil {
|
||||
opts = args.APIOpts
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(ctx, utils.CacheSv1GetItem, tnt, utils.IfaceAsString(opts[utils.OptsAPIKey])); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
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 {
|
||||
@@ -112,6 +128,23 @@ func (dS *DispatcherService) CacheSv1GetItemIDs(ctx *context.Context, args *util
|
||||
}
|
||||
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 *interface{}) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args != nil && len(args.Tenant) != 0 {
|
||||
tnt = args.Tenant
|
||||
}
|
||||
ev := make(map[string]interface{})
|
||||
opts := make(map[string]interface{})
|
||||
if args != nil {
|
||||
opts = args.APIOpts
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(ctx, utils.CacheSv1GetItemWithRemote, tnt, utils.IfaceAsString(opts[utils.OptsAPIKey])); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
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 {
|
||||
@@ -146,40 +179,6 @@ func (dS *DispatcherService) CacheSv1HasItem(ctx *context.Context, args *utils.A
|
||||
}
|
||||
return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1HasItem, args, reply)
|
||||
}
|
||||
func (dS *DispatcherService) CacheSv1GetItem(ctx *context.Context, args *utils.ArgsGetCacheItemWithAPIOpts, reply *interface{}) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args != nil && len(args.Tenant) != 0 {
|
||||
tnt = args.Tenant
|
||||
}
|
||||
ev := make(map[string]interface{})
|
||||
opts := make(map[string]interface{})
|
||||
if args != nil {
|
||||
opts = args.APIOpts
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(ctx, utils.CacheSv1GetItem, tnt, utils.IfaceAsString(opts[utils.OptsAPIKey])); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1GetItem, args, reply)
|
||||
}
|
||||
func (dS *DispatcherService) CacheSv1GetItemWithRemote(ctx *context.Context, args *utils.ArgsGetCacheItemWithAPIOpts, reply *interface{}) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args != nil && len(args.Tenant) != 0 {
|
||||
tnt = args.Tenant
|
||||
}
|
||||
ev := make(map[string]interface{})
|
||||
opts := make(map[string]interface{})
|
||||
if args != nil {
|
||||
opts = args.APIOpts
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(ctx, utils.CacheSv1GetItemWithRemote, tnt, utils.IfaceAsString(opts[utils.OptsAPIKey])); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(ctx, &utils.CGREvent{Tenant: tnt, Event: ev, APIOpts: opts}, utils.MetaCaches, utils.CacheSv1GetItemWithRemote, 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 {
|
||||
|
||||
@@ -84,7 +84,7 @@ func TestCMgetConnUnsupportedBiRPC(t *testing.T) {
|
||||
}
|
||||
|
||||
experr := rpcclient.ErrUnsupportedBiRPC
|
||||
exp, err := NewRPCPool(context.Background(), "*first", "", "", "", cfg.GeneralCfg().ConnectAttempts,
|
||||
exp, err := NewRPCPool(context.Background(), utils.MetaFirst, "", "", "", cfg.GeneralCfg().ConnectAttempts,
|
||||
cfg.GeneralCfg().Reconnects, cfg.GeneralCfg().MaxReconnectInterval, cfg.GeneralCfg().ConnectTimeout,
|
||||
cfg.GeneralCfg().ReplyTimeout, nil, cc, true, nil, "", cM.connCache)
|
||||
if err != nil {
|
||||
@@ -129,7 +129,7 @@ func TestCMgetConnNotInternalRPC(t *testing.T) {
|
||||
|
||||
cM.connCache.Set(connID, nil, nil)
|
||||
|
||||
exp, err := NewRPCPool(context.Background(), "*first", cfg.TLSCfg().ClientKey, cfg.TLSCfg().ClientCerificate,
|
||||
exp, err := NewRPCPool(context.Background(), utils.MetaFirst, cfg.TLSCfg().ClientKey, cfg.TLSCfg().ClientCerificate,
|
||||
cfg.TLSCfg().CaCertificate, cfg.GeneralCfg().ConnectAttempts,
|
||||
cfg.GeneralCfg().Reconnects, cfg.GeneralCfg().MaxReconnectInterval,
|
||||
cfg.GeneralCfg().ConnectTimeout, cfg.GeneralCfg().ReplyTimeout,
|
||||
|
||||
@@ -458,7 +458,7 @@ func TestLoadDispatcherProfiles(t *testing.T) {
|
||||
Tenant: "cgrates.org",
|
||||
ID: "D1",
|
||||
FilterIDs: []string{"*string:~*req.Account:1001"},
|
||||
Strategy: "*first",
|
||||
Strategy: utils.MetaFirst,
|
||||
Weight: 20,
|
||||
Hosts: []*utils.TPDispatcherHostProfile{
|
||||
{
|
||||
|
||||
@@ -190,7 +190,7 @@ func testDispatcherOptsCoreStatus(t *testing.T) {
|
||||
ev := utils.TenantWithAPIOpts{
|
||||
Tenant: "cgrates.org",
|
||||
/* APIOpts: map[string]interface{}{
|
||||
utils.MetaDispatchers: false,
|
||||
utils.OptsDispatchers: false,
|
||||
}, */
|
||||
}
|
||||
if err := dspOptsRPC.Call(context.Background(), utils.CoreSv1Status, &ev, &reply); err != nil {
|
||||
@@ -219,7 +219,7 @@ func testDispatcherOptsAdminSetDispatcherHost4012(t *testing.T) {
|
||||
},
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.MetaDispatchers: false,
|
||||
utils.OptsDispatchers: false,
|
||||
},
|
||||
}
|
||||
if err := adminsRPC.Call(context.Background(), utils.AdminSv1SetDispatcherHost, setDispatcherHost, &replyStr); err != nil {
|
||||
@@ -243,7 +243,7 @@ func testDispatcherOptsAdminSetDispatcherHost4012(t *testing.T) {
|
||||
},
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.MetaDispatchers: false,
|
||||
utils.OptsDispatchers: false,
|
||||
},
|
||||
}
|
||||
if err := adminsRPC.Call(context.Background(), utils.AdminSv1SetDispatcherProfile, setDispatcherProfile, &replyStr); err != nil {
|
||||
@@ -288,7 +288,7 @@ func testDispatcherOptsAdminSetDispatcherProfileDoubleHost(t *testing.T) {
|
||||
},
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.MetaDispatchers: false,
|
||||
utils.OptsDispatchers: false,
|
||||
},
|
||||
}
|
||||
var replyStr string
|
||||
@@ -334,7 +334,7 @@ func testDispatcherOptsAdminSetDispatcherHostInexistent(t *testing.T) {
|
||||
},
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.MetaDispatchers: false,
|
||||
utils.OptsDispatchers: false,
|
||||
},
|
||||
}
|
||||
if err := adminsRPC.Call(context.Background(), utils.AdminSv1SetDispatcherHost, setDispatcherHost, &replyStr); err != nil {
|
||||
@@ -358,7 +358,7 @@ func testDispatcherOptsAdminSetDispatcherHostInexistent(t *testing.T) {
|
||||
},
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.MetaDispatchers: false,
|
||||
utils.OptsDispatchers: false,
|
||||
},
|
||||
}
|
||||
if err := adminsRPC.Call(context.Background(), utils.AdminSv1SetDispatcherProfile, setDispatcherProfile, &replyStr); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user