diff --git a/apier/v1/apier_it_test.go b/apier/v1/apier_it_test.go index f809403a2..a5811c5e9 100644 --- a/apier/v1/apier_it_test.go +++ b/apier/v1/apier_it_test.go @@ -1821,6 +1821,35 @@ func TestApierGetStorDBVesions(t *testing.T) { } } +func TestApierPing(t *testing.T) { + var reply string + if err := rater.Call(utils.StatSv1Ping, "", &reply); err != nil { + t.Error(err) + } else if reply != utils.Pong { + t.Errorf("Received: %s", reply) + } + if err := rater.Call(utils.ResourceSv1Ping, "", &reply); err != nil { + t.Error(err) + } else if reply != utils.Pong { + t.Errorf("Received: %s", reply) + } + if err := rater.Call(utils.SupplierSv1Ping, "", &reply); err != nil { + t.Error(err) + } else if reply != utils.Pong { + t.Errorf("Received: %s", reply) + } + if err := rater.Call(utils.ThresholdSv1Ping, "", &reply); err != nil { + t.Error(err) + } else if reply != utils.Pong { + t.Errorf("Received: %s", reply) + } + if err := rater.Call(utils.AttributeSv1Ping, "", &reply); err != nil { + t.Error(err) + } else if reply != utils.Pong { + t.Errorf("Received: %s", reply) + } +} + // Simply kill the engine after we are done with tests within this file func TestApierStopEngine(t *testing.T) { exec.Command("pkill", "cgr-engine").Run() diff --git a/apier/v1/attributes.go b/apier/v1/attributes.go index 0e166e0e7..87ca93fb8 100644 --- a/apier/v1/attributes.go +++ b/apier/v1/attributes.go @@ -98,3 +98,8 @@ func (alSv1 *AttributeSv1) ProcessEvent(ev *utils.CGREvent, reply *engine.AttrSProcessEventReply) error { return alSv1.attrS.V1ProcessEvent(ev, reply) } + +func (alSv1 *AttributeSv1) Ping(ign string, reply *string) error { + *reply = utils.Pong + return nil +} diff --git a/apier/v1/attributes_it_test.go b/apier/v1/attributes_it_test.go index e200979e8..4bd0594fc 100644 --- a/apier/v1/attributes_it_test.go +++ b/apier/v1/attributes_it_test.go @@ -61,6 +61,7 @@ var sTestsAlsPrf = []func(t *testing.T){ testAttributeSSetAlsPrf, testAttributeSUpdateAlsPrf, testAttributeSRemAlsPrf, + testAttributeSPing, testAttributeSKillEngine, } @@ -648,6 +649,15 @@ func testAttributeSRemAlsPrf(t *testing.T) { } } +func testAttributeSPing(t *testing.T) { + var resp string + if err := attrSRPC.Call(utils.AttributeSv1Ping, "", &resp); err != nil { + t.Error(err) + } else if resp != utils.Pong { + t.Error("Unexpected reply returned", resp) + } +} + func testAttributeSKillEngine(t *testing.T) { if err := engine.KillEngine(alsPrfDelay); err != nil { t.Error(err) diff --git a/apier/v1/caches.go b/apier/v1/caches.go index 1fd0d83ef..29e0d70cb 100644 --- a/apier/v1/caches.go +++ b/apier/v1/caches.go @@ -22,6 +22,7 @@ import ( "time" "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" "github.com/cgrates/ltcache" ) @@ -92,3 +93,8 @@ func (chSv1 *CacheSv1) RemoveGroup(args *engine.ArgsGetGroup, rply *string) (err error) { return chSv1.cacheS.V1RemoveGroup(args, rply) } + +func (chSv1 *CacheSv1) Ping(ign string, reply *string) error { + *reply = utils.Pong + return nil +} diff --git a/apier/v1/resourcesv1.go b/apier/v1/resourcesv1.go index 0ba8e8566..59aeb2b31 100644 --- a/apier/v1/resourcesv1.go +++ b/apier/v1/resourcesv1.go @@ -105,3 +105,8 @@ func (apierV1 *ApierV1) RemoveResourceProfile(arg utils.TenantID, reply *string) *reply = utils.OK return nil } + +func (rsv1 *ResourceSv1) Ping(ign string, reply *string) error { + *reply = utils.Pong + return nil +} diff --git a/apier/v1/resourcesv1_it_test.go b/apier/v1/resourcesv1_it_test.go index 8248cae40..a3a05d7b4 100644 --- a/apier/v1/resourcesv1_it_test.go +++ b/apier/v1/resourcesv1_it_test.go @@ -61,6 +61,7 @@ var sTestsRLSV1 = []func(t *testing.T){ testV1RsGetResourceProfileAfterUpdate, testV1RsRemResourceProfile, testV1RsGetResourceProfileAfterDelete, + testV1RsResourcePing, testV1RsStopEngine, } @@ -684,6 +685,15 @@ func testV1RsGetResourceProfileAfterDelete(t *testing.T) { } } +func testV1RsResourcePing(t *testing.T) { + var resp string + if err := rlsV1Rpc.Call(utils.ResourceSv1Ping, "", &resp); err != nil { + t.Error(err) + } else if resp != utils.Pong { + t.Error("Unexpected reply returned", resp) + } +} + func testV1RsStopEngine(t *testing.T) { if err := engine.KillEngine(resDelay); err != nil { t.Error(err) diff --git a/apier/v1/sessions.go b/apier/v1/sessions.go index f32e692b8..d80ba2c07 100644 --- a/apier/v1/sessions.go +++ b/apier/v1/sessions.go @@ -133,3 +133,8 @@ func (ssv1 *SessionSv1) BiRPCV1GetPassiveSessions(clnt *rpc2.Client, args map[st rply *[]*sessions.ActiveSession) error { return ssv1.SMG.BiRPCV1GetPassiveSessions(clnt, args, rply) } + +func (ssv1 *SessionSv1) Ping(ign string, reply *string) error { + *reply = utils.Pong + return nil +} diff --git a/apier/v1/sessionsv1_it_test.go b/apier/v1/sessionsv1_it_test.go index ca595fe32..480c307e2 100644 --- a/apier/v1/sessionsv1_it_test.go +++ b/apier/v1/sessionsv1_it_test.go @@ -441,6 +441,15 @@ func TestSSv1ItProcessEvent(t *testing.T) { } } +func TestV1STSSessionPing(t *testing.T) { + var resp string + if err := sSv1BiRpc.Call(utils.SessionSv1Ping, "", &resp); err != nil { + t.Error(err) + } else if resp != utils.Pong { + t.Error("Unexpected reply returned", resp) + } +} + func TestSSv1ItStopCgrEngine(t *testing.T) { if err := sSv1BiRpc.Close(); err != nil { // Close the connection so we don't get EOF warnings from client t.Error(err) diff --git a/apier/v1/stats.go b/apier/v1/stats.go index 322283c12..6312a7752 100644 --- a/apier/v1/stats.go +++ b/apier/v1/stats.go @@ -114,3 +114,8 @@ func (stsv1 *StatSv1) GetQueueStringMetrics(args *utils.TenantID, reply *map[str func (stsv1 *StatSv1) GetQueueFloatMetrics(args *utils.TenantID, reply *map[string]float64) (err error) { return stsv1.sS.V1GetQueueFloatMetrics(args, reply) } + +func (stSv1 *StatSv1) Ping(ign string, reply *string) error { + *reply = utils.Pong + return nil +} diff --git a/apier/v1/stats_it_test.go b/apier/v1/stats_it_test.go index 92f739d93..b518b482e 100644 --- a/apier/v1/stats_it_test.go +++ b/apier/v1/stats_it_test.go @@ -83,6 +83,7 @@ var sTestsStatSV1 = []func(t *testing.T){ testV1STSSetStatQueueProfile, testV1STSUpdateStatQueueProfile, testV1STSRemoveStatQueueProfile, + testV1STSStatsPing, testV1STSStopEngine, } @@ -400,6 +401,15 @@ func testV1STSRemoveStatQueueProfile(t *testing.T) { } } +func testV1STSStatsPing(t *testing.T) { + var resp string + if err := stsV1Rpc.Call(utils.StatSv1Ping, "", &resp); err != nil { + t.Error(err) + } else if resp != utils.Pong { + t.Error("Unexpected reply returned", resp) + } +} + func testV1STSStopEngine(t *testing.T) { if err := engine.KillEngine(statsDelay); err != nil { t.Error(err) diff --git a/apier/v1/suppliers.go b/apier/v1/suppliers.go index 173580d02..f642c9b5b 100644 --- a/apier/v1/suppliers.go +++ b/apier/v1/suppliers.go @@ -86,3 +86,8 @@ func (splv1 *SupplierSv1) GetSuppliers(args *engine.ArgsGetSuppliers, reply *engine.SortedSuppliers) error { return splv1.splS.V1GetSuppliers(args, reply) } + +func (splv1 *SupplierSv1) Ping(ign string, reply *string) error { + *reply = utils.Pong + return nil +} diff --git a/apier/v1/suppliers_it_test.go b/apier/v1/suppliers_it_test.go index d25a84584..f42b6843d 100644 --- a/apier/v1/suppliers_it_test.go +++ b/apier/v1/suppliers_it_test.go @@ -54,6 +54,7 @@ var sTestsSupplierSV1 = []func(t *testing.T){ testV1SplSSetSupplierProfiles, testV1SplSUpdateSupplierProfiles, testV1SplSRemSupplierProfiles, + testV1SplSupplierPing, testV1SplSStopEngine, } @@ -368,6 +369,15 @@ func testV1SplSRemSupplierProfiles(t *testing.T) { } } +func testV1SplSupplierPing(t *testing.T) { + var resp string + if err := splSv1Rpc.Call(utils.SupplierSv1Ping, "", &resp); err != nil { + t.Error(err) + } else if resp != utils.Pong { + t.Error("Unexpected reply returned", resp) + } +} + func testV1SplSStopEngine(t *testing.T) { if err := engine.KillEngine(100); err != nil { t.Error(err) diff --git a/apier/v1/thresholds.go b/apier/v1/thresholds.go index 55604e693..a62f9a1b9 100644 --- a/apier/v1/thresholds.go +++ b/apier/v1/thresholds.go @@ -100,3 +100,8 @@ func (apierV1 *ApierV1) RemoveThresholdProfile(args *utils.TenantID, reply *stri *reply = utils.OK return nil } + +func (tSv1 *ThresholdSv1) Ping(ign string, reply *string) error { + *reply = utils.Pong + return nil +} diff --git a/console/attribute_ping.go b/console/attribute_ping.go new file mode 100644 index 000000000..ca4aba11f --- /dev/null +++ b/console/attribute_ping.go @@ -0,0 +1,62 @@ +/* +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 := &CmdAttributePing{ + name: "attribute_ping", + rpcMethod: utils.AttributeSv1Ping, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdAttributePing struct { + name string + rpcMethod string + rpcParams *EmptyWrapper + *CommandExecuter +} + +func (self *CmdAttributePing) Name() string { + return self.name +} + +func (self *CmdAttributePing) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdAttributePing) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &EmptyWrapper{} + } + return self.rpcParams +} + +func (self *CmdAttributePing) PostprocessRpcParams() error { + return nil +} + +func (self *CmdAttributePing) RpcResult() interface{} { + var s string + return &s +} diff --git a/console/resource_ping.go b/console/resource_ping.go new file mode 100644 index 000000000..144e745b6 --- /dev/null +++ b/console/resource_ping.go @@ -0,0 +1,62 @@ +/* +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 := &CmdResourcePing{ + name: "resource_ping", + rpcMethod: utils.ResourceSv1Ping, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdResourcePing struct { + name string + rpcMethod string + rpcParams *EmptyWrapper + *CommandExecuter +} + +func (self *CmdResourcePing) Name() string { + return self.name +} + +func (self *CmdResourcePing) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdResourcePing) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &EmptyWrapper{} + } + return self.rpcParams +} + +func (self *CmdResourcePing) PostprocessRpcParams() error { + return nil +} + +func (self *CmdResourcePing) RpcResult() interface{} { + var s string + return &s +} diff --git a/console/session_ping.go b/console/session_ping.go new file mode 100644 index 000000000..8aaad2855 --- /dev/null +++ b/console/session_ping.go @@ -0,0 +1,62 @@ +/* +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 := &CmdSessionPing{ + name: "session_ping", + rpcMethod: utils.SessionSv1Ping, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdSessionPing struct { + name string + rpcMethod string + rpcParams *EmptyWrapper + *CommandExecuter +} + +func (self *CmdSessionPing) Name() string { + return self.name +} + +func (self *CmdSessionPing) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdSessionPing) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &EmptyWrapper{} + } + return self.rpcParams +} + +func (self *CmdSessionPing) PostprocessRpcParams() error { + return nil +} + +func (self *CmdSessionPing) RpcResult() interface{} { + var s string + return &s +} diff --git a/console/stats_ping.go b/console/stats_ping.go new file mode 100644 index 000000000..4e73d8ca3 --- /dev/null +++ b/console/stats_ping.go @@ -0,0 +1,62 @@ +/* +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 := &CmdStatsPing{ + name: "stats_ping", + rpcMethod: utils.StatSv1Ping, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdStatsPing struct { + name string + rpcMethod string + rpcParams *EmptyWrapper + *CommandExecuter +} + +func (self *CmdStatsPing) Name() string { + return self.name +} + +func (self *CmdStatsPing) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdStatsPing) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &EmptyWrapper{} + } + return self.rpcParams +} + +func (self *CmdStatsPing) PostprocessRpcParams() error { + return nil +} + +func (self *CmdStatsPing) RpcResult() interface{} { + var s string + return &s +} diff --git a/console/supplier_ping.go b/console/supplier_ping.go new file mode 100644 index 000000000..3c1ef847c --- /dev/null +++ b/console/supplier_ping.go @@ -0,0 +1,62 @@ +/* +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 := &CmdSupplierPing{ + name: "supplier_ping", + rpcMethod: utils.SupplierSv1Ping, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdSupplierPing struct { + name string + rpcMethod string + rpcParams *EmptyWrapper + *CommandExecuter +} + +func (self *CmdSupplierPing) Name() string { + return self.name +} + +func (self *CmdSupplierPing) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdSupplierPing) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &EmptyWrapper{} + } + return self.rpcParams +} + +func (self *CmdSupplierPing) PostprocessRpcParams() error { + return nil +} + +func (self *CmdSupplierPing) RpcResult() interface{} { + var s string + return &s +} diff --git a/console/threshold_ping.go b/console/threshold_ping.go new file mode 100644 index 000000000..a42f10ff2 --- /dev/null +++ b/console/threshold_ping.go @@ -0,0 +1,62 @@ +/* +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 := &CmdThresholdPing{ + name: "threshold_ping", + rpcMethod: utils.ThresholdSv1Ping, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdThresholdPing struct { + name string + rpcMethod string + rpcParams *EmptyWrapper + *CommandExecuter +} + +func (self *CmdThresholdPing) Name() string { + return self.name +} + +func (self *CmdThresholdPing) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdThresholdPing) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &EmptyWrapper{} + } + return self.rpcParams +} + +func (self *CmdThresholdPing) PostprocessRpcParams() error { + return nil +} + +func (self *CmdThresholdPing) RpcResult() interface{} { + var s string + return &s +} diff --git a/data/conf/samples/apier/apier.json b/data/conf/samples/apier/apier.json index 6ea2d5d86..b81198c1c 100644 --- a/data/conf/samples/apier/apier.json +++ b/data/conf/samples/apier/apier.json @@ -65,6 +65,29 @@ ], }, +"attributes": { // Attribute service + "enabled": true, // starts Alias service: . +}, + + +"resources": { + "enabled": true, +}, + + +"stats": { + "enabled": true, +}, + +"thresholds": { + "enabled": true, +}, + + +"suppliers": { + "enabled": true, +}, + "aliases": { "enabled": true, // start the CDR Server service: }, diff --git a/utils/consts.go b/utils/consts.go index 1f24028a9..10c70beac 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -531,6 +531,7 @@ const ( Append = "Append" MetaRound = "*round" LoaderS = "LoaderS" + Pong = "Pong" ) //MetaMetrics @@ -599,12 +600,14 @@ const ( // MetaSupplierAPIs const ( SupplierSv1GetSuppliers = "SupplierSv1.GetSuppliers" + SupplierSv1Ping = "SupplierSv1.Ping" ) // AttributeS APIs const ( AttributeSv1GetAttributeForEvent = "AttributeSv1.GetAttributeForEvent" AttributeSv1ProcessEvent = "AttributeSv1.ProcessEvent" + AttributeSv1Ping = "AttributeSv1.Ping" ) //ThresholdS APIs @@ -612,6 +615,7 @@ const ( ThresholdSv1ProcessEvent = "ThresholdSv1.ProcessEvent" ThresholdSv1GetThreshold = "ThresholdSv1.GetThreshold" ThresholdSv1GetThresholdIDs = "ThresholdSv1.GetThresholdIDs" + ThresholdSv1Ping = "ThresholdSv1.Ping" ) //StatS APIs @@ -619,6 +623,7 @@ const ( StatSv1ProcessEvent = "StatSv1.ProcessEvent" StatSv1GetQueueIDs = "StatSv1.GetQueueIDs" StatSv1GetQueueStringMetrics = "StatSv1.GetQueueStringMetrics" + StatSv1Ping = "StatSv1.Ping" ) //ResourceS APIs @@ -627,6 +632,7 @@ const ( ResourceSv1GetResourcesForEvent = "ResourceSv1.GetResourcesForEvent" ResourceSv1AllocateResources = "ResourceSv1.AllocateResources" ResourceSv1ReleaseResources = "ResourceSv1.ReleaseResources" + ResourceSv1Ping = "ResourceSv1.Ping" ) //SessionS APIs @@ -644,6 +650,7 @@ const ( SMGenericV1InitiateSession = "SMGenericV1.InitiateSession" SMGenericV2InitiateSession = "SMGenericV2.InitiateSession" SMGenericV2UpdateSession = "SMGenericV2.UpdateSession" + SessionSv1Ping = "SessionSv1.Ping" ) // Cache