mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Added unit tests for dispatchers
This commit is contained in:
committed by
Dan Christian Bogos
parent
763310e46c
commit
ebd4ae3b6d
@@ -496,6 +496,7 @@ func TestDspCacheSv1GetItemWithRemote(t *testing.T) {
|
||||
"Opt": "Disp",
|
||||
},
|
||||
}
|
||||
|
||||
if err := dm.SetDispatcherProfile(&engine.DispatcherProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "DSP_Test1",
|
||||
@@ -515,7 +516,46 @@ func TestDspCacheSv1GetItemWithRemote(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
var reply any
|
||||
if err := dsp.CacheSv1GetItemWithRemote(args, &reply); err == nil { //not finished
|
||||
if err := dsp.CacheSv1GetItemWithRemote(args, &reply); err == nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCacheSv1GetItem(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
dm := engine.NewDataManager(engine.NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items), cfg.CacheCfg(), nil)
|
||||
dsp := NewDispatcherService(dm, cfg, engine.NewFilterS(cfg, nil, dm), nil)
|
||||
args := &utils.ArgsGetCacheItemWithAPIOpts{
|
||||
Tenant: "cgrates.org",
|
||||
ArgsGetCacheItem: utils.ArgsGetCacheItem{
|
||||
CacheID: utils.CacheChargerProfiles,
|
||||
ItemID: "cgrates.org:DISP1 ",
|
||||
},
|
||||
APIOpts: map[string]any{
|
||||
"Opt": "Disp",
|
||||
},
|
||||
}
|
||||
if err := dm.SetDispatcherProfile(&engine.DispatcherProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "DSP_Test1",
|
||||
FilterIDs: []string{"*string:~*opts.Opt:Disp"},
|
||||
Strategy: utils.MetaRoundRobin,
|
||||
Subsystems: []string{utils.MetaAny},
|
||||
Hosts: engine.DispatcherHostProfiles{
|
||||
&engine.DispatcherHostProfile{
|
||||
ID: "ALL2",
|
||||
FilterIDs: []string{},
|
||||
Weight: 20,
|
||||
Params: make(map[string]any),
|
||||
},
|
||||
},
|
||||
Weight: 20,
|
||||
}, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
var reply any
|
||||
if err := dsp.CacheSv1GetItem(args, &reply); err == nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -294,3 +294,92 @@ func TestDspResponderShutdownErrorNil(t *testing.T) {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspResponderGetCostOnRatingPlans(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
dm := engine.NewDataManager(engine.NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items), cfg.CacheCfg(), nil)
|
||||
dsp := NewDispatcherService(dm, cfg, nil, nil)
|
||||
args := &utils.GetCostOnRatingPlansArgs{
|
||||
Account: "1002",
|
||||
RatingPlanIDs: []string{
|
||||
"RP1",
|
||||
"RP2",
|
||||
},
|
||||
Subject: "1002",
|
||||
Destination: "1001",
|
||||
Usage: 2 * time.Minute,
|
||||
Tenant: "cgrates.org",
|
||||
}
|
||||
if err := dm.SetDispatcherHost(&engine.DispatcherHost{
|
||||
Tenant: "cgrates.org",
|
||||
RemoteHost: &config.RemoteHost{
|
||||
ID: "ALL2",
|
||||
},
|
||||
}); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err := dm.SetDispatcherProfile(&engine.DispatcherProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "DSP_Test1",
|
||||
FilterIDs: []string{},
|
||||
Strategy: utils.MetaRoundRobin,
|
||||
Subsystems: []string{utils.MetaAny},
|
||||
Hosts: engine.DispatcherHostProfiles{
|
||||
&engine.DispatcherHostProfile{
|
||||
ID: "ALL2",
|
||||
FilterIDs: []string{},
|
||||
Weight: 20,
|
||||
Params: make(map[string]any),
|
||||
},
|
||||
},
|
||||
Weight: 20,
|
||||
}, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
var reply map[string]any
|
||||
if err := dsp.ResponderGetCostOnRatingPlans(args, &reply); err == nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
// func TestDspResponderGetMaxSessionTimeOnAccounts(t *testing.T) {
|
||||
// cfg := config.NewDefaultCGRConfig()
|
||||
// dm := engine.NewDataManager(engine.NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items), cfg.CacheCfg(), nil)
|
||||
// dsp := NewDispatcherService(dm, cfg, nil, nil)
|
||||
// args := &utils.GetMaxSessionTimeOnAccountsArgs{
|
||||
// Subject: "1002",
|
||||
// Destination: "1001",
|
||||
// Usage: 2 * time.Minute,
|
||||
// Tenant: "cgrates.org",
|
||||
// }
|
||||
// if err := dm.SetDispatcherHost(&engine.DispatcherHost{
|
||||
// Tenant: "cgrates.org",
|
||||
// RemoteHost: &config.RemoteHost{
|
||||
// ID: "ALL2",
|
||||
// },
|
||||
// }); err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// if err := dm.SetDispatcherProfile(&engine.DispatcherProfile{
|
||||
// Tenant: "cgrates.org",
|
||||
// ID: "DSP_Test1",
|
||||
// FilterIDs: []string{},
|
||||
// Strategy: utils.MetaRoundRobin,
|
||||
// Subsystems: []string{utils.MetaAny},
|
||||
// Hosts: engine.DispatcherHostProfiles{
|
||||
// &engine.DispatcherHostProfile{
|
||||
// ID: "ALL2",
|
||||
// FilterIDs: []string{},
|
||||
// Weight: 20,
|
||||
// Params: make(map[string]any),
|
||||
// },
|
||||
// },
|
||||
// Weight: 20,
|
||||
// }, true); err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// var reply map[string]any
|
||||
// if err := dsp.ResponderGetMaxSessionTimeOnAccounts(args, &reply); err == nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user