mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Removed coresv1 from dispatchers
This commit is contained in:
committed by
Dan Christian Bogos
parent
3f6e333e29
commit
f10f9351ec
@@ -100,7 +100,6 @@ func TestConfigSv1Interface(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCoreSv1Interface(t *testing.T) {
|
||||
_ = CoreSv1Interface(NewDispatcherCoreSv1(nil))
|
||||
_ = CoreSv1Interface(NewCoreSv1(nil))
|
||||
}
|
||||
|
||||
|
||||
@@ -870,44 +870,6 @@ func (dS *DispatcherConfigSv1) GetConfigAsJSON(args *config.SectionWithAPIOpts,
|
||||
return dS.dS.ConfigSv1GetConfigAsJSON(args, reply)
|
||||
}
|
||||
|
||||
func NewDispatcherCoreSv1(dps *dispatchers.DispatcherService) *DispatcherCoreSv1 {
|
||||
return &DispatcherCoreSv1{dS: dps}
|
||||
}
|
||||
|
||||
// Exports RPC from RLs
|
||||
type DispatcherCoreSv1 struct {
|
||||
dS *dispatchers.DispatcherService
|
||||
}
|
||||
|
||||
func (dS *DispatcherCoreSv1) Status(args *utils.TenantWithAPIOpts, reply *map[string]interface{}) error {
|
||||
return dS.dS.CoreSv1Status(args, reply)
|
||||
}
|
||||
|
||||
// Ping used to detreminate if component is active
|
||||
func (dS *DispatcherCoreSv1) Ping(args *utils.CGREvent, reply *string) error {
|
||||
return dS.dS.CoreSv1Ping(args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherCoreSv1) Sleep(arg *utils.DurationArgs, reply *string) error {
|
||||
return dS.dS.CoreSv1Sleep(arg, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherCoreSv1) StartCPUProfiling(args *utils.DirectoryArgs, reply *string) error {
|
||||
return dS.dS.CoreSv1StartCPUProfiling(args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherCoreSv1) StopCPUProfiling(args *utils.TenantWithAPIOpts, reply *string) error {
|
||||
return dS.dS.CoreSv1StopCPUProfiling(args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherCoreSv1) StartMemoryProfiling(args *utils.MemoryPrf, reply *string) error {
|
||||
return dS.dS.CoreSv1StartMemoryProfiling(args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherCoreSv1) StopMemoryProfiling(args *utils.TenantWithAPIOpts, reply *string) error {
|
||||
return dS.dS.CoreSv1StopMemoryProfiling(args, reply)
|
||||
}
|
||||
|
||||
func NewDispatcherRALsV1(dps *dispatchers.DispatcherService) *DispatcherRALsV1 {
|
||||
return &DispatcherRALsV1{dS: dps}
|
||||
}
|
||||
|
||||
@@ -1,147 +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package dispatchers
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func (dS *DispatcherService) CoreSv1Status(args *utils.TenantWithAPIOpts,
|
||||
reply *map[string]interface{}) (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(utils.CoreSv1Status, tnt,
|
||||
utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
APIOpts: args.APIOpts,
|
||||
}, utils.MetaCore, utils.CoreSv1Status, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) CoreSv1Ping(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(utils.CoreSv1Ping, tnt,
|
||||
utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), args.Time); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(args, utils.MetaCore, utils.CoreSv1Ping, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) CoreSv1Sleep(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(utils.CoreSv1Sleep, tnt,
|
||||
utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
APIOpts: args.APIOpts,
|
||||
}, utils.MetaCore, utils.CoreSv1Sleep, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) CoreSv1StartCPUProfiling(args *utils.DirectoryArgs,
|
||||
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(utils.CoreSv1StartCPUProfiling, tnt,
|
||||
utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
APIOpts: args.APIOpts,
|
||||
}, utils.MetaCore, utils.CoreSv1StartCPUProfiling, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) CoreSv1StopCPUProfiling(args *utils.TenantWithAPIOpts,
|
||||
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(utils.CoreSv1StopCPUProfiling, tnt,
|
||||
utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
APIOpts: args.APIOpts,
|
||||
}, utils.MetaCore, utils.CoreSv1StopCPUProfiling, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) CoreSv1StartMemoryProfiling(args *utils.MemoryPrf,
|
||||
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(utils.CoreSv1StartMemoryProfiling, tnt,
|
||||
utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
APIOpts: args.APIOpts,
|
||||
}, utils.MetaCore, utils.CoreSv1StartMemoryProfiling, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) CoreSv1StopMemoryProfiling(args *utils.TenantWithAPIOpts,
|
||||
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(utils.CoreSv1StopMemoryProfiling, tnt,
|
||||
utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
APIOpts: args.APIOpts,
|
||||
}, utils.MetaCore, utils.CoreSv1StopMemoryProfiling, args, reply)
|
||||
}
|
||||
|
||||
@@ -1,246 +0,0 @@
|
||||
// +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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package dispatchers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/rpc"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var sTestsDspCore = []func(t *testing.T){
|
||||
testDspCoreLoad,
|
||||
testDspCoreCPUProfile,
|
||||
testDspCoreMemoryProfile,
|
||||
}
|
||||
|
||||
//Test start here
|
||||
func TestDspCoreIT(t *testing.T) {
|
||||
var config1, config2, config3 string
|
||||
switch *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 *encoding == utils.MetaGOB {
|
||||
dispDIR += "_gob"
|
||||
}
|
||||
testDsp(t, sTestsDspCore, "TestDspCoreIT", config1, config2, config3, "tutorial", "oldtutorial", dispDIR)
|
||||
}
|
||||
|
||||
func testDspCoreLoad(t *testing.T) {
|
||||
var status map[string]interface{}
|
||||
statusTnt := utils.TenantWithAPIOpts{
|
||||
Tenant: "cgrates.org",
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsAPIKey: "core12345",
|
||||
utils.OptsRouteID: "core1",
|
||||
"EventType": "LoadDispatcher",
|
||||
},
|
||||
}
|
||||
expNodeID := "ALL"
|
||||
if err := dispEngine.RPC.Call(utils.CoreSv1Status, statusTnt, &status); err != nil {
|
||||
t.Error(err)
|
||||
} else if status[utils.NodeID] == "ALL2" {
|
||||
expNodeID = "ALL2"
|
||||
}
|
||||
dur := &utils.DurationArgs{
|
||||
Duration: 500 * time.Millisecond,
|
||||
Tenant: "cgrates.org",
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsAPIKey: "core12345",
|
||||
utils.OptsRouteID: "core1",
|
||||
"EventType": "LoadDispatcher",
|
||||
},
|
||||
}
|
||||
var rply string
|
||||
statusTnt2 := utils.TenantWithAPIOpts{
|
||||
Tenant: "cgrates.org",
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsAPIKey: "core12345",
|
||||
"EventType": "LoadDispatcher",
|
||||
},
|
||||
}
|
||||
call := dispEngine.RPC.Go(utils.CoreSv1Sleep, dur, &rply, make(chan *rpc.Call, 1))
|
||||
if err := dispEngine.RPC.Call(utils.CoreSv1Status, statusTnt2, &status); err != nil {
|
||||
t.Error(err)
|
||||
} else if status[utils.NodeID] != expNodeID {
|
||||
t.Errorf("Expected status to be called on node <%s> but it was called on <%s>", expNodeID, status[utils.NodeID])
|
||||
}
|
||||
if ans := <-call.Done; ans.Error != nil {
|
||||
t.Fatal(ans.Error)
|
||||
} else if rply != utils.OK {
|
||||
t.Errorf("Expected: %q ,received: %q", utils.OK, rply)
|
||||
}
|
||||
}
|
||||
|
||||
func testDspCoreCPUProfile(t *testing.T) {
|
||||
var reply string
|
||||
args := &utils.DirectoryArgs{
|
||||
DirPath: "/tmp",
|
||||
}
|
||||
//apikey is missing
|
||||
expectedErr := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if err := dispEngine.RPC.Call(utils.CoreSv1StartCPUProfiling,
|
||||
args, &reply); err == nil || err.Error() != expectedErr {
|
||||
t.Errorf("Expected %+v, received %+v", expectedErr, err)
|
||||
}
|
||||
|
||||
args = &utils.DirectoryArgs{
|
||||
DirPath: "/tmp",
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsAPIKey: "core12345",
|
||||
},
|
||||
}
|
||||
if err := dispEngine.RPC.Call(utils.CoreSv1StartCPUProfiling,
|
||||
args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Unexpected reply returned")
|
||||
}
|
||||
|
||||
argsStop := &utils.TenantWithAPIOpts{
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsAPIKey: "core12345",
|
||||
},
|
||||
}
|
||||
if err := dispEngine.RPC.Call(utils.CoreSv1StopCPUProfiling,
|
||||
argsStop, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Unexpected reply returned")
|
||||
}
|
||||
file, err := os.Open(path.Join("/tmp", utils.CpuPathCgr))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
//compare the size
|
||||
size, err := file.Stat()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
} else if size.Size() < int64(415) {
|
||||
t.Errorf("Size of CPUProfile %v is lower that expected", size.Size())
|
||||
}
|
||||
//after we checked that CPUProfile was made successfully, can delete it
|
||||
if err := os.Remove(path.Join("/tmp", utils.CpuPathCgr)); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testDspCoreMemoryProfile(t *testing.T) {
|
||||
var reply string
|
||||
args := &utils.MemoryPrf{
|
||||
DirPath: "/tmp",
|
||||
Interval: 100 * time.Millisecond,
|
||||
NrFiles: 2,
|
||||
}
|
||||
//missing apiKey
|
||||
expectedErr := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if err := dispEngine.RPC.Call(utils.CoreSv1StartMemoryProfiling,
|
||||
args, &reply); err == nil || err.Error() != expectedErr {
|
||||
t.Errorf("Expected %+v, received %+v", expectedErr, err)
|
||||
}
|
||||
args = &utils.MemoryPrf{
|
||||
DirPath: "/tmp",
|
||||
Interval: 100 * time.Millisecond,
|
||||
NrFiles: 2,
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsAPIKey: "core12345",
|
||||
},
|
||||
}
|
||||
if err := dispEngine.RPC.Call(utils.CoreSv1StartMemoryProfiling,
|
||||
args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Unexpected reply returned")
|
||||
}
|
||||
|
||||
dur := &utils.DurationArgs{
|
||||
Duration: 500 * time.Millisecond,
|
||||
Tenant: "cgrates.org",
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsAPIKey: "core12345",
|
||||
utils.OptsRouteID: "core1",
|
||||
"EventType": "LoadDispatcher",
|
||||
},
|
||||
}
|
||||
|
||||
if err := dispEngine.RPC.Call(utils.CoreSv1Sleep,
|
||||
dur, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Unexpected reply returned")
|
||||
}
|
||||
|
||||
argsStop := &utils.TenantWithAPIOpts{
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsAPIKey: "core12345",
|
||||
},
|
||||
}
|
||||
if err := dispEngine.RPC.Call(utils.CoreSv1StopMemoryProfiling,
|
||||
argsStop , &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Unexpected reply returned")
|
||||
}
|
||||
|
||||
//mem_prof1, mem_prof2
|
||||
for i := 1; i <= 2; i++ {
|
||||
file, err := os.Open(path.Join("/tmp", fmt.Sprintf("mem%v.prof", i)))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
//compare the size
|
||||
size, err := file.Stat()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
} else if size.Size() < int64(415) {
|
||||
t.Errorf("Size of MemoryProfile %v is lower that expected", size.Size())
|
||||
}
|
||||
//after we checked that CPUProfile was made successfully, can delete it
|
||||
if err := os.Remove(path.Join("/tmp", fmt.Sprintf("mem%v.prof", i))); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package dispatchers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestDspCoreSv1StatusNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.TenantWithAPIOpts{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *map[string]interface{}
|
||||
result := dspSrv.CoreSv1Status(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1StatusErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.TenantWithAPIOpts{}
|
||||
var reply *map[string]interface{}
|
||||
result := dspSrv.CoreSv1Status(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1PingNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.CGREvent{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Ping(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1PingErrorNil(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.CoreSv1Ping(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1SleepNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
CGREvent := &utils.DurationArgs{
|
||||
Tenant: "tenant",
|
||||
}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Sleep(CGREvent, reply)
|
||||
expected := "DISPATCHER_ERROR:NO_DATABASE_CONNECTION"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDspCoreSv1SleepErrorNil(t *testing.T) {
|
||||
cgrCfg := config.NewDefaultCGRConfig()
|
||||
dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil)
|
||||
cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"}
|
||||
CGREvent := &utils.DurationArgs{}
|
||||
var reply *string
|
||||
result := dspSrv.CoreSv1Sleep(CGREvent, reply)
|
||||
expected := "MANDATORY_IE_MISSING: [ApiKey]"
|
||||
if result == nil || result.Error() != expected {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
@@ -133,9 +133,6 @@ func (dspS *DispatcherService) Start() (err error) {
|
||||
dspS.server.RpcRegisterName(utils.ConfigSv1,
|
||||
v1.NewDispatcherConfigSv1(dspS.dspS))
|
||||
|
||||
dspS.server.RpcRegisterName(utils.CoreSv1,
|
||||
v1.NewDispatcherCoreSv1(dspS.dspS))
|
||||
|
||||
dspS.server.RpcRegisterName(utils.RALsV1,
|
||||
v1.NewDispatcherRALsV1(dspS.dspS))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user