Replace dispatcher test with CoreSv1.Status

This commit is contained in:
TeoV
2019-06-04 14:29:21 +03:00
committed by Dan Christian Bogos
parent cbc9c73d3e
commit 2afcae57e0
7 changed files with 41 additions and 10 deletions

View File

@@ -41,3 +41,9 @@ func (cS *CoreSv1) Call(serviceMethod string,
func (cS *CoreSv1) Status(arg *utils.TenantWithArgDispatcher, reply *map[string]interface{}) error {
return cS.cS.Status(arg, reply)
}
// Ping used to detreminate if component is active
func (cS *CoreSv1) Ping(ign *utils.CGREventWithArgDispatcher, reply *string) error {
*reply = utils.Pong
return nil
}

View File

@@ -778,3 +778,8 @@ type DispatcherCoreSv1 struct {
func (dS *DispatcherCoreSv1) Status(args *utils.TenantWithArgDispatcher, 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.CGREventWithArgDispatcher, reply *string) error {
return dS.dS.CoreSv1Ping(args, reply)
}

View File

@@ -98,7 +98,6 @@ type ResponderInterface interface {
RefundIncrements(arg *engine.CallDescriptorWithArgDispatcher, reply *engine.Account) (err error)
RefundRounding(arg *engine.CallDescriptorWithArgDispatcher, reply *float64) (err error)
GetMaxSessionTime(arg *engine.CallDescriptorWithArgDispatcher, reply *time.Duration) (err error)
Status(arg *utils.TenantWithArgDispatcher, reply *map[string]interface{}) (err error)
Shutdown(arg *utils.TenantWithArgDispatcher, reply *string) (err error)
Ping(ign *utils.CGREventWithArgDispatcher, reply *string) error
}

View File

@@ -10,7 +10,7 @@ cgrates.org,ATTR_API_SUP_AUTH,*auth,*string:~APIKey:sup12345,,,APIMethods,*const
cgrates.org,ATTR_API_STAT_AUTH,*auth,*string:~APIKey:stat12345,,,APIMethods,*constant,StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics,false,20
cgrates.org,ATTR_API_RES_AUTH,*auth,*string:~APIKey:res12345,,,APIMethods,*constant,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources,false,20
cgrates.org,ATTR_API_SES_AUTH,*auth,*string:~APIKey:ses12345,,,APIMethods,*constant,SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessEvent&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession,false,20
cgrates.org,ATTR_API_RSP_AUTH,*auth,*string:~APIKey:rsp12345,,,APIMethods,*constant,Responder.GetTimeout&Responder.Shutdown&Responder.Ping,false,20
cgrates.org,ATTR_API_RSP_AUTH,*auth,*string:~APIKey:rsp12345,,,APIMethods,*constant,CoreSv1.Status&CoreSv1.Ping&Responder.GetTimeout&Responder.Shutdown&Responder.Ping,false,20
cgrates.org,ATTR_API_CHC_AUTH,*auth,*string:~APIKey:chc12345,,,APIMethods,*constant,CacheSv1.Ping&CacheSv1.GetCacheStats&CacheSv1.LoadCache&CacheSv1.PrecacheStatus&CacheSv1.GetItemIDs&CacheSv1.HasItem&CacheSv1.GetItemExpiryTime&CacheSv1.ReloadCache&CacheSv1.RemoveItem&CacheSv1.FlushCache&CacheSv1.Clear,false,20
cgrates.org,ATTR_API_GRD_AUTH,*auth,*string:~APIKey:grd12345,,,APIMethods,*constant,GuardianSv1.Ping&GuardianSv1.RemoteLock&GuardianSv1.RemoteUnlock,false,20
cgrates.org,ATTR_API_SCHD_AUTH,*auth,*string:~APIKey:sched12345,,,APIMethods,*constant,SchedulerSv1.Ping,false,20
1 #Tenant ID Contexts FilterIDs ActivationInterval AttributeFilterIDs FieldName Type Value Blocker Weight
10 cgrates.org ATTR_API_STAT_AUTH *auth *string:~APIKey:stat12345 APIMethods *constant StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics false 20
11 cgrates.org ATTR_API_RES_AUTH *auth *string:~APIKey:res12345 APIMethods *constant ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources false 20
12 cgrates.org ATTR_API_SES_AUTH *auth *string:~APIKey:ses12345 APIMethods *constant SessionSv1.Ping&SessionSv1.AuthorizeEvent&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSession&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.SyncSessions&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessEvent&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.ReplicateSessions&SessionSv1.SetPassiveSession false 20
13 cgrates.org ATTR_API_RSP_AUTH *auth *string:~APIKey:rsp12345 APIMethods *constant Responder.GetTimeout&Responder.Shutdown&Responder.Ping CoreSv1.Status&CoreSv1.Ping&Responder.GetTimeout&Responder.Shutdown&Responder.Ping false 20
14 cgrates.org ATTR_API_CHC_AUTH *auth *string:~APIKey:chc12345 APIMethods *constant CacheSv1.Ping&CacheSv1.GetCacheStats&CacheSv1.LoadCache&CacheSv1.PrecacheStatus&CacheSv1.GetItemIDs&CacheSv1.HasItem&CacheSv1.GetItemExpiryTime&CacheSv1.ReloadCache&CacheSv1.RemoveItem&CacheSv1.FlushCache&CacheSv1.Clear false 20
15 cgrates.org ATTR_API_GRD_AUTH *auth *string:~APIKey:grd12345 APIMethods *constant GuardianSv1.Ping&GuardianSv1.RemoteLock&GuardianSv1.RemoteUnlock false 20
16 cgrates.org ATTR_API_SCHD_AUTH *auth *string:~APIKey:sched12345 APIMethods *constant SchedulerSv1.Ping false 20

View File

@@ -43,3 +43,23 @@ func (dS *DispatcherService) CoreSv1Status(args *utils.TenantWithArgDispatcher,
return dS.Dispatch(&utils.CGREvent{Tenant: tnt}, utils.MetaCore,
routeID, utils.CoreSv1Status, args, reply)
}
func (dS *DispatcherService) CoreSv1Ping(args *utils.CGREventWithArgDispatcher, reply *string) (err error) {
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
if dS.attrS != nil {
if args.ArgDispatcher == nil {
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
}
if err = dS.authorize(utils.CoreSv1Ping,
args.Tenant,
args.APIKey, args.Time); err != nil {
return
}
}
var routeID *string
if args.ArgDispatcher != nil {
routeID = args.ArgDispatcher.RouteID
}
return dS.Dispatch(args.CGREvent, utils.MetaCore, routeID,
utils.CoreSv1Ping, args, reply)
}

View File

@@ -47,7 +47,7 @@ func TestDspResponderMongo(t *testing.T) {
func testDspResponderStatus(t *testing.T) {
var reply map[string]interface{}
if err := allEngine.RCP.Call(utils.ResponderStatus, utils.TenantWithArgDispatcher{}, &reply); err != nil {
if err := allEngine.RCP.Call(utils.CoreSv1Status, utils.TenantWithArgDispatcher{}, &reply); err != nil {
t.Error(err)
} else if reply[utils.NodeID] != "ALL" {
t.Errorf("Received: %s", reply)
@@ -60,13 +60,13 @@ func testDspResponderStatus(t *testing.T) {
APIKey: utils.StringPointer("rsp12345"),
},
}
if err := dispEngine.RCP.Call(utils.ResponderStatus, &ev, &reply); err != nil {
if err := dispEngine.RCP.Call(utils.CoreSv1Status, &ev, &reply); err != nil {
t.Error(err)
} else if reply[utils.NodeID] != "ALL" {
t.Errorf("Received: %s", utils.ToJSON(reply))
}
allEngine.stopEngine(t)
if err := dispEngine.RCP.Call(utils.ResponderStatus, &ev, &reply); err != nil {
if err := dispEngine.RCP.Call(utils.CoreSv1Status, &ev, &reply); err != nil {
t.Error(err)
} else if reply[utils.NodeID] != "ALL2" {
t.Errorf("Received: %s", utils.ToJSON(reply))
@@ -99,12 +99,12 @@ func getNodeWithRoute(route string, t *testing.T) string {
},
}
if err := dispEngine.RCP.Call(utils.ResponderPing, pingEv, &pingReply); err != nil {
if err := dispEngine.RCP.Call(utils.CoreSv1Ping, pingEv, &pingReply); err != nil {
t.Error(err)
} else if pingReply != utils.Pong {
t.Errorf("Received: %s", pingReply)
}
if err := dispEngine.RCP.Call(utils.ResponderStatus, ev, &reply); err != nil {
if err := dispEngine.RCP.Call(utils.CoreSv1Status, ev, &reply); err != nil {
t.Error(err)
}
if reply[utils.NodeID] == nil {
@@ -139,7 +139,7 @@ func testDspResponderShutdown(t *testing.T) {
} else if reply != "Done!" {
t.Errorf("Received: %s", utils.ToJSON(reply))
}
if err := dispEngine.RCP.Call(utils.ResponderStatus, &ev, &statusReply); err != nil {
if err := dispEngine.RCP.Call(utils.CoreSv1Status, &ev, &statusReply); err != nil {
t.Error(err)
} else if statusReply[utils.NodeID] != "ALL2" {
t.Errorf("Received: %s", utils.ToJSON(statusReply))
@@ -213,12 +213,12 @@ func testDspResponderInternal(t *testing.T) {
RouteID: &route,
},
}
if err := dispEngine.RCP.Call(utils.ResponderPing, pingEv, &pingReply); err != nil {
if err := dispEngine.RCP.Call(utils.CoreSv1Ping, pingEv, &pingReply); err != nil {
t.Error(err)
} else if pingReply != utils.Pong {
t.Errorf("Received: %s", pingReply)
}
if err := dispEngine.RCP.Call(utils.ResponderStatus, &ev, &reply); err != nil {
if err := dispEngine.RCP.Call(utils.CoreSv1Status, &ev, &reply); err != nil {
t.Error(err)
}
if reply[utils.NodeID] == nil {

View File

@@ -780,6 +780,7 @@ const (
CoreS = "CoreS"
CoreSv1 = "CoreSv1"
CoreSv1Status = "CoreSv1.Status"
CoreSv1Ping = "CoreSv1.Ping"
)
// SupplierS APIs