From 49a88987f426b206f10ead33029b26916619c079 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 29 Nov 2019 16:39:45 +0200 Subject: [PATCH] Updated engine integration tests for gob RPC --- agents/astagent_test.go | 2 +- agents/diamagent.go | 4 +- agents/diamagent_test.go | 2 +- agents/fsagent_test.go | 2 +- agents/kamagent_test.go | 2 +- apier/v1/dm_remote_it_test.go | 4 +- apier/v1/filter_indexes_it_test.go | 4 +- apier/v1/filterindexecache_it_test.go | 6 +- apier/v1/stats_it_test.go | 2 +- apier/v1/thresholds.go | 7 +- apier/v1/thresholds_it_test.go | 6 +- apier/v2/cdrs_offline_it_test.go | 4 +- console/threshold_set.go | 7 +- data/conf/samples/gob/actions/cgradmin.json | 60 +++++++ .../conf/samples/gob/cdrsv2mongo/cgrates.json | 77 +++++++++ engine/actions2_it_test.go | 6 +- engine/actions_it_test.go | 146 ++++++++++-------- engine/thresholds.go | 5 + general_tests/cdrs_it_test.go | 2 +- gob_integration_test.sh | 8 +- sessions/libsessions.go | 4 +- 21 files changed, 261 insertions(+), 99 deletions(-) create mode 100644 data/conf/samples/gob/actions/cgradmin.json create mode 100644 data/conf/samples/gob/cdrsv2mongo/cgrates.json diff --git a/agents/astagent_test.go b/agents/astagent_test.go index 6fa0cc113..30017fe9e 100644 --- a/agents/astagent_test.go +++ b/agents/astagent_test.go @@ -24,5 +24,5 @@ import ( ) func TestAAsSessionSClientIface(t *testing.T) { - _ = sessions.SessionSClient(new(AsteriskAgent)) + _ = sessions.BiRPClient(new(AsteriskAgent)) } diff --git a/agents/diamagent.go b/agents/diamagent.go index dc4672627..6a88afd04 100644 --- a/agents/diamagent.go +++ b/agents/diamagent.go @@ -433,7 +433,7 @@ func (da *DiameterAgent) Call(serviceMethod string, args interface{}, reply inte return utils.RPCCall(da, serviceMethod, args, reply) } -// V1DisconnectSession is part of the sessions.SessionSClient +// V1DisconnectSession is part of the sessions.BiRPClient func (da *DiameterAgent) V1DisconnectSession(args utils.AttrDisconnectSession, reply *string) (err error) { ssID, has := args.EventStart[utils.OriginID] if !has { @@ -479,7 +479,7 @@ func (da *DiameterAgent) V1DisconnectSession(args utils.AttrDisconnectSession, r return } -// V1GetActiveSessionIDs is part of the sessions.SessionSClient +// V1GetActiveSessionIDs is part of the sessions.BiRPClient func (da *DiameterAgent) V1GetActiveSessionIDs(ignParam string, sessionIDs *[]*sessions.SessionID) error { return utils.ErrNotImplemented diff --git a/agents/diamagent_test.go b/agents/diamagent_test.go index d3c40824e..3a950ea7f 100644 --- a/agents/diamagent_test.go +++ b/agents/diamagent_test.go @@ -31,7 +31,7 @@ import ( ) func TestDAsSessionSClientIface(t *testing.T) { - _ = sessions.SessionSClient(new(DiameterAgent)) + _ = sessions.BiRPClient(new(DiameterAgent)) } type testMockSessionConn struct { diff --git a/agents/fsagent_test.go b/agents/fsagent_test.go index 76b0e03aa..0be8df8b1 100644 --- a/agents/fsagent_test.go +++ b/agents/fsagent_test.go @@ -24,5 +24,5 @@ import ( ) func TestFAsSessionSClientIface(t *testing.T) { - _ = sessions.SessionSClient(new(FSsessions)) + _ = sessions.BiRPClient(new(FSsessions)) } diff --git a/agents/kamagent_test.go b/agents/kamagent_test.go index 8cd9729c8..96ac1fa24 100644 --- a/agents/kamagent_test.go +++ b/agents/kamagent_test.go @@ -24,5 +24,5 @@ import ( ) func TestKAsSessionSClientIface(t *testing.T) { - _ = sessions.SessionSClient(new(KamailioAgent)) + _ = sessions.BiRPClient(new(KamailioAgent)) } diff --git a/apier/v1/dm_remote_it_test.go b/apier/v1/dm_remote_it_test.go index abff27434..23d538e38 100644 --- a/apier/v1/dm_remote_it_test.go +++ b/apier/v1/dm_remote_it_test.go @@ -278,7 +278,7 @@ func testInternalRemoteITGetThreshold(t *testing.T) { func testInternalRemoteITGetThresholdProfile(t *testing.T) { var reply *engine.ThresholdProfile - tPrfl = &ThresholdWithCache{ + tPrfl = &engine.ThresholdWithCache{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_ACNT_1001", @@ -633,7 +633,7 @@ func testInternalReplicationSetThreshold(t *testing.T) { expectedIDX, utils.ToJSON(indexes)) } - tPrfl := &ThresholdWithCache{ + tPrfl := &engine.ThresholdWithCache{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Replication", diff --git a/apier/v1/filter_indexes_it_test.go b/apier/v1/filter_indexes_it_test.go index 03d851d48..9636699e2 100644 --- a/apier/v1/filter_indexes_it_test.go +++ b/apier/v1/filter_indexes_it_test.go @@ -182,7 +182,7 @@ func testV1FIdxSetThresholdProfile(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl = &ThresholdWithCache{ + tPrfl = &engine.ThresholdWithCache{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: tenant, ID: "TEST_PROFILE1", @@ -277,7 +277,7 @@ func testV1FIdxSetSecondThresholdProfile(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl = &ThresholdWithCache{ + tPrfl = &engine.ThresholdWithCache{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: tenant, ID: "TEST_PROFILE2", diff --git a/apier/v1/filterindexecache_it_test.go b/apier/v1/filterindexecache_it_test.go index 2d0ff8c7f..68a2f416b 100644 --- a/apier/v1/filterindexecache_it_test.go +++ b/apier/v1/filterindexecache_it_test.go @@ -179,7 +179,7 @@ func testV1FIdxCaSetThresholdProfile(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - tPrfl = &ThresholdWithCache{ + tPrfl = &engine.ThresholdWithCache{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TEST_PROFILE1", @@ -272,7 +272,7 @@ func testV1FIdxCaUpdateThresholdProfile(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - tPrfl = &ThresholdWithCache{ + tPrfl = &engine.ThresholdWithCache{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TEST_PROFILE1", @@ -367,7 +367,7 @@ func testV1FIdxCaUpdateThresholdProfileFromTP(t *testing.T) { } reply.FilterIDs = []string{"TestFilter3"} - if err := tFIdxCaRpc.Call(utils.ApierV1SetThresholdProfile, &ThresholdWithCache{ThresholdProfile: reply}, &result); err != nil { + if err := tFIdxCaRpc.Call(utils.ApierV1SetThresholdProfile, &engine.ThresholdWithCache{ThresholdProfile: reply}, &result); err != nil { t.Error(err) } else if result != utils.OK { t.Error("Unexpected reply returned", result) diff --git a/apier/v1/stats_it_test.go b/apier/v1/stats_it_test.go index e3b644c10..12714c167 100644 --- a/apier/v1/stats_it_test.go +++ b/apier/v1/stats_it_test.go @@ -726,7 +726,7 @@ func testV1STSProcessStatWithThreshold(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - thSts := &ThresholdWithCache{ + thSts := &engine.ThresholdWithCache{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Stat", diff --git a/apier/v1/thresholds.go b/apier/v1/thresholds.go index 592e37b20..896c6ee07 100644 --- a/apier/v1/thresholds.go +++ b/apier/v1/thresholds.go @@ -94,13 +94,8 @@ func (apierV1 *ApierV1) GetThresholdProfileIDs(args utils.TenantArgWithPaginator return nil } -type ThresholdWithCache struct { - *engine.ThresholdProfile - Cache *string -} - // SetThresholdProfile alters/creates a ThresholdProfile -func (apierV1 *ApierV1) SetThresholdProfile(args *ThresholdWithCache, reply *string) error { +func (apierV1 *ApierV1) SetThresholdProfile(args *engine.ThresholdWithCache, reply *string) error { if missing := utils.MissingStructFields(args.ThresholdProfile, []string{"Tenant", "ID"}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } diff --git a/apier/v1/thresholds_it_test.go b/apier/v1/thresholds_it_test.go index 63610dc36..b401f9476 100644 --- a/apier/v1/thresholds_it_test.go +++ b/apier/v1/thresholds_it_test.go @@ -36,7 +36,7 @@ var ( tSv1CfgPath string tSv1Cfg *config.CGRConfig tSv1Rpc *rpc.Client - tPrfl *ThresholdWithCache + tPrfl *engine.ThresholdWithCache tSv1ConfDIR string //run tests for specific configuration ) @@ -398,7 +398,7 @@ func testV1TSSetThresholdProfile(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl = &ThresholdWithCache{ + tPrfl = &engine.ThresholdWithCache{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", @@ -477,7 +477,7 @@ func testV1TSMaxHits(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl = &ThresholdWithCache{ + tPrfl = &engine.ThresholdWithCache{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH3", diff --git a/apier/v2/cdrs_offline_it_test.go b/apier/v2/cdrs_offline_it_test.go index 4bcd5a5c7..954424c27 100644 --- a/apier/v2/cdrs_offline_it_test.go +++ b/apier/v2/cdrs_offline_it_test.go @@ -161,7 +161,7 @@ func testV2CDRsOfflineBalanceUpdate(t *testing.T) { t.Error(err) } //create a threshold that match out account - tPrfl := v1.ThresholdWithCache{ + tPrfl := engine.ThresholdWithCache{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", @@ -277,7 +277,7 @@ func testV2CDRsOfflineExpiryBalance(t *testing.T) { t.Error(err) } //create a threshold that match out account - tPrfl := &v1.ThresholdWithCache{ + tPrfl := &engine.ThresholdWithCache{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test2", diff --git a/console/threshold_set.go b/console/threshold_set.go index 79ac8704e..532ec4d92 100644 --- a/console/threshold_set.go +++ b/console/threshold_set.go @@ -19,7 +19,6 @@ along with this program. If not, see package console import ( - v1 "github.com/cgrates/cgrates/apier/v1" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" ) @@ -28,7 +27,7 @@ func init() { c := &CmdSetThreshold{ name: "threshold_set", rpcMethod: utils.ApierV1SetThresholdProfile, - rpcParams: &v1.ThresholdWithCache{}, + rpcParams: &engine.ThresholdWithCache{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -38,7 +37,7 @@ func init() { type CmdSetThreshold struct { name string rpcMethod string - rpcParams *v1.ThresholdWithCache + rpcParams *engine.ThresholdWithCache *CommandExecuter } @@ -52,7 +51,7 @@ func (self *CmdSetThreshold) RpcMethod() string { func (self *CmdSetThreshold) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &v1.ThresholdWithCache{ThresholdProfile: new(engine.ThresholdProfile)} + self.rpcParams = &engine.ThresholdWithCache{ThresholdProfile: new(engine.ThresholdProfile)} } return self.rpcParams } diff --git a/data/conf/samples/gob/actions/cgradmin.json b/data/conf/samples/gob/actions/cgradmin.json new file mode 100644 index 000000000..9633a6369 --- /dev/null +++ b/data/conf/samples/gob/actions/cgradmin.json @@ -0,0 +1,60 @@ +{ +// CGRateS Configuration file +// +// Used for cgradmin +// Starts rater, scheduler + +"general": { + "log_level": 7, +}, + +"listen": { + "rpc_json": ":2012", // RPC JSON listening address + "rpc_gob": ":2013", // RPC GOB listening address + "http": ":2080", // HTTP listening address +}, + + +"stor_db": { // database used to store offline tariff plans and CDRs + "db_password": "CGRateS.org", // password to use when connecting to stordb +}, + + +"rals": { + "enabled": true, // enable Rater service: +}, + +"scheduler": { + "enabled": true, // start Scheduler service: + "cdrs_conns": [ + {"address": "*internal"} // address where to reach CDR Server, empty to disable CDR capturing <*internal|x.y.z.y:1234> + ], +}, + +"cdrs": { + "enabled": true, // start the CDR Server service: + "chargers_conns":[ + {"address": "127.0.0.1:2013", "transport":"*gob"}, + ], +}, + +"chargers": { + "enabled": true, +}, + +"users": { + "enabled": true, // starts users service: . +}, + +"thresholds": { + "enabled": true, + "store_interval": "1s", +}, + +"apier": { + "scheduler_conns": [ // connections to SchedulerS for reloads + {"address": "*internal"}, + ], +}, + +} diff --git a/data/conf/samples/gob/cdrsv2mongo/cgrates.json b/data/conf/samples/gob/cdrsv2mongo/cgrates.json new file mode 100644 index 000000000..81a7e9965 --- /dev/null +++ b/data/conf/samples/gob/cdrsv2mongo/cgrates.json @@ -0,0 +1,77 @@ +{ +// CGRateS Configuration file +// +// Used in apier_local_tests +// Starts rater, cdrs and mediator connecting over internal channel + +"general": { + "log_level": 7, +}, + +"stor_db": { + "db_type": "mongo", // stor database type to use: + "db_port": 27017, // the port to reach the stordb +}, + + +"rals": { + "enabled": true, // enable Rater service: + "thresholds_conns": [ + {"address": "127.0.0.1:2013", "transport":"*gob"}, + ], +}, + +"scheduler": { + "enabled": true, +}, + +"cdrs": { + "enabled": true, + "attributes_conns":[ + {"address": "*internal"}, + ], + "chargers_conns":[ + {"address": "127.0.0.1:2013", "transport":"*gob"}, + ], + "rals_conns": [ + {"address": "127.0.0.1:2013", "transport":"*gob"}, + ], + "stats_conns": [ + {"address": "127.0.0.1:2013", "transport":"*gob"}, + ], + "thresholds_conns": [ + {"address": "127.0.0.1:2013", "transport":"*gob"}, + ], +}, + +"attributes": { + "enabled": true, +}, + +"stats": { + "enabled": true, + "store_interval": "1s", + "thresholds_conns": [ + {"address": "*internal"} + ], +}, + +"thresholds": { + "enabled": true, + "store_interval": "1s", +}, + +"chargers": { + "enabled": true, + "attributes_conns": [ + {"address": "*internal"}, + ], +}, + +"apier": { + "scheduler_conns": [ // connections to SchedulerS for reloads + {"address": "*internal"}, + ], +}, + +} diff --git a/engine/actions2_it_test.go b/engine/actions2_it_test.go index dd5ac5e9a..a83edcf16 100644 --- a/engine/actions2_it_test.go +++ b/engine/actions2_it_test.go @@ -21,7 +21,6 @@ package engine import ( "net/rpc" - "net/rpc/jsonrpc" "path" "testing" "time" @@ -69,6 +68,9 @@ func TestActionsITRemoveSMCostMongo(t *testing.T) { func testActionsInitCfg(t *testing.T) { var err error actsCfgPath = path.Join(*dataDir, "conf", "samples", actsCfgDir) + if *encoding == utils.MetaGOBrpc { + actsCfgPath = path.Join(*dataDir, "conf", "samples", "gob", actsCfgDir) + } actsCfg, err = config.NewCGRConfigFromPath(actsCfgPath) if err != nil { t.Error(err) @@ -117,7 +119,7 @@ func testActionsStartEngine(t *testing.T) { // Connect rpc client to rater func testActionsRPCConn(t *testing.T) { var err error - actsRPC, err = jsonrpc.Dial("tcp", actsCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + actsRPC, err = newRPCClient(actsCfg.ListenCfg()) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } diff --git a/engine/actions_it_test.go b/engine/actions_it_test.go index bad6329dd..62911e045 100644 --- a/engine/actions_it_test.go +++ b/engine/actions_it_test.go @@ -20,6 +20,7 @@ along with this program. If not, see package engine import ( + "errors" "flag" "net/rpc" "net/rpc/jsonrpc" @@ -33,13 +34,30 @@ import ( "github.com/cgrates/cgrates/utils" ) -var actsLclCfg *config.CGRConfig -var actsLclRpc *rpc.Client -var actsLclCfgPath = path.Join(*dataDir, "conf", "samples", "actions") +var ( + actsLclCfg *config.CGRConfig + actsLclRpc *rpc.Client + actsLclCfgPath = path.Join(*dataDir, "conf", "samples", "actions") -var waitRater = flag.Int("wait_rater", 500, "Number of miliseconds to wait for rater to start and cache") + waitRater = flag.Int("wait_rater", 500, "Number of miliseconds to wait for rater to start and cache") + encoding = flag.String("rpc", utils.MetaJSONrpc, "what encoding whould be uused for rpc comunication") +) + +func newRPCClient(cfg *config.ListenCfg) (c *rpc.Client, err error) { + switch *encoding { + case utils.MetaJSONrpc: + return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen) + case utils.MetaGOBrpc: + return rpc.Dial(utils.TCP, cfg.RPCGOBListen) + default: + return nil, errors.New("UNSUPPORTED_RPC") + } +} func TestActionsitInitCfg(t *testing.T) { + if *encoding == utils.MetaGOBrpc { + actsLclCfgPath = path.Join(*dataDir, "conf", "samples", "gob", "actions") + } // Init config first var err error actsLclCfg, err = config.NewCGRConfigFromPath(actsLclCfgPath) @@ -70,7 +88,7 @@ func TestActionsitStartEngine(t *testing.T) { func TestActionsitRpcConn(t *testing.T) { var err error // time.Sleep(500 * time.Millisecond) - actsLclRpc, err = jsonrpc.Dial("tcp", actsLclCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + actsLclRpc, err = newRPCClient(actsLclCfg.ListenCfg()) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } @@ -261,20 +279,22 @@ func TestActionsitThresholdCDrLog(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl := &ThresholdProfile{ - Tenant: "cgrates.org", - ID: "THD_Test", - FilterIDs: []string{"*string:~*req.Account:th_acc"}, - ActivationInterval: &utils.ActivationInterval{ - ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), - ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), + tPrfl := ThresholdWithCache{ + ThresholdProfile: &ThresholdProfile{ + Tenant: "cgrates.org", + ID: "THD_Test", + FilterIDs: []string{"*string:~*req.Account:th_acc"}, + ActivationInterval: &utils.ActivationInterval{ + ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), + ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), + }, + MaxHits: -1, + MinSleep: time.Duration(5 * time.Minute), + Blocker: false, + Weight: 20.0, + ActionIDs: []string{"ACT_TH_CDRLOG"}, + Async: false, }, - MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), - Blocker: false, - Weight: 20.0, - ActionIDs: []string{"ACT_TH_CDRLOG"}, - Async: false, } if err := actsLclRpc.Call(utils.ApierV1SetThresholdProfile, tPrfl, &result); err != nil { t.Error(err) @@ -284,36 +304,38 @@ func TestActionsitThresholdCDrLog(t *testing.T) { if err := actsLclRpc.Call(utils.ApierV1GetThresholdProfile, &utils.TenantID{Tenant: "cgrates.org", ID: "THD_Test"}, &thReply); err != nil { t.Error(err) - } else if !reflect.DeepEqual(tPrfl, thReply) { - t.Errorf("Expecting: %+v, received: %+v", tPrfl, thReply) + } else if !reflect.DeepEqual(tPrfl.ThresholdProfile, thReply) { + t.Errorf("Expecting: %+v, received: %+v", tPrfl.ThresholdProfile, thReply) } - ev := &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "cdrev1", - Event: map[string]interface{}{ - utils.EventType: utils.CDR, - "field_extr1": "val_extr1", - "fieldextr2": "valextr2", - utils.CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), - utils.RunID: utils.MetaRaw, - utils.OrderID: 123, - utils.OriginHost: "192.168.1.1", - utils.Source: utils.UNIT_TEST, - utils.OriginID: "dsafdsaf", - utils.ToR: utils.VOICE, - utils.RequestType: utils.META_RATED, - utils.Direction: "*out", - utils.Tenant: "cgrates.org", - utils.Category: "call", - utils.Account: "th_acc", - utils.Subject: "th_acc", - utils.Destination: "+4986517174963", - utils.SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), - utils.PDD: time.Duration(0) * time.Second, - utils.AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - utils.Usage: time.Duration(10) * time.Second, - utils.SUPPLIER: "SUPPL1", - utils.COST: -1.0, + ev := &ArgsProcessEvent{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "cdrev1", + Event: map[string]interface{}{ + utils.EventType: utils.CDR, + "field_extr1": "val_extr1", + "fieldextr2": "valextr2", + utils.CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), + utils.RunID: utils.MetaRaw, + utils.OrderID: 123, + utils.OriginHost: "192.168.1.1", + utils.Source: utils.UNIT_TEST, + utils.OriginID: "dsafdsaf", + utils.ToR: utils.VOICE, + utils.RequestType: utils.META_RATED, + utils.Direction: "*out", + utils.Tenant: "cgrates.org", + utils.Category: "call", + utils.Account: "th_acc", + utils.Subject: "th_acc", + utils.Destination: "+4986517174963", + utils.SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), + utils.PDD: time.Duration(0) * time.Second, + utils.AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), + utils.Usage: time.Duration(10) * time.Second, + utils.SUPPLIER: "SUPPL1", + utils.COST: -1.0, + }, }, } var ids []string @@ -471,19 +493,21 @@ func TestActionsitThresholdPostEvent(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl := &ThresholdProfile{ - Tenant: "cgrates.org", - ID: "THD_PostEvent", - ActivationInterval: &utils.ActivationInterval{ - ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), - ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), + tPrfl := &ThresholdWithCache{ + ThresholdProfile: &ThresholdProfile{ + Tenant: "cgrates.org", + ID: "THD_PostEvent", + ActivationInterval: &utils.ActivationInterval{ + ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), + ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC), + }, + MaxHits: -1, + MinSleep: time.Duration(5 * time.Minute), + Blocker: false, + Weight: 20.0, + ActionIDs: []string{"ACT_TH_POSTEVENT"}, + Async: false, }, - MaxHits: -1, - MinSleep: time.Duration(5 * time.Minute), - Blocker: false, - Weight: 20.0, - ActionIDs: []string{"ACT_TH_POSTEVENT"}, - Async: false, } if err := actsLclRpc.Call(utils.ApierV1SetThresholdProfile, tPrfl, &result); err != nil { t.Error(err) @@ -493,8 +517,8 @@ func TestActionsitThresholdPostEvent(t *testing.T) { if err := actsLclRpc.Call(utils.ApierV1GetThresholdProfile, &utils.TenantID{Tenant: "cgrates.org", ID: "THD_PostEvent"}, &thReply); err != nil { t.Error(err) - } else if !reflect.DeepEqual(tPrfl, thReply) { - t.Errorf("Expecting: %+v, received: %+v", tPrfl, thReply) + } else if !reflect.DeepEqual(tPrfl.ThresholdProfile, thReply) { + t.Errorf("Expecting: %+v, received: %+v", tPrfl.ThresholdProfile, thReply) } ev := &utils.CGREvent{ Tenant: "cgrates.org", diff --git a/engine/thresholds.go b/engine/thresholds.go index ee0ad1b82..24be9aee4 100644 --- a/engine/thresholds.go +++ b/engine/thresholds.go @@ -29,6 +29,11 @@ import ( "github.com/cgrates/cgrates/utils" ) +type ThresholdWithCache struct { + *ThresholdProfile + Cache *string +} + type ThresholdProfile struct { Tenant string ID string diff --git a/general_tests/cdrs_it_test.go b/general_tests/cdrs_it_test.go index d7708c0e7..ee009726d 100644 --- a/general_tests/cdrs_it_test.go +++ b/general_tests/cdrs_it_test.go @@ -524,7 +524,7 @@ func testV2CDRsSetThresholdProfile(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl := &v1.ThresholdWithCache{ + tPrfl := &engine.ThresholdWithCache{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_PoccessCDR", diff --git a/gob_integration_test.sh b/gob_integration_test.sh index 28f025cc8..e6043e12d 100755 --- a/gob_integration_test.sh +++ b/gob_integration_test.sh @@ -8,9 +8,9 @@ ap1=$? echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration -rpc=*gob' go test github.com/cgrates/cgrates/apier/v2 -tags=integration -rpc=*gob ap2=$? -# echo 'go test github.com/cgrates/cgrates/engine -tags=integration' -# go test github.com/cgrates/cgrates/engine -tags=integration -# en=$? +echo 'go test github.com/cgrates/cgrates/engine -tags=integration -rpc=*gob' +go test github.com/cgrates/cgrates/engine -tags=integration -rpc=*gob +en=$? # echo 'go test github.com/cgrates/cgrates/cdrc -tags=integration' # go test github.com/cgrates/cgrates/cdrc -tags=integration # cdrc=$? @@ -48,4 +48,4 @@ ap2=$? # go test github.com/cgrates/cgrates/apier/v1 -tags=offline # offline=$? -exit $gen && $ap1 && $ap2 #&& $en && $cdrc && $cfg && $utl && $gnr && $agts && $smg && $mgr && $dis && $lds && $ers && $srv && $offline +exit $gen && $ap1 && $ap2 && $en #&& $cdrc && $cfg && $utl && $gnr && $agts && $smg && $mgr && $dis && $lds && $ers && $srv && $offline diff --git a/sessions/libsessions.go b/sessions/libsessions.go index 41c68005f..019ba4702 100644 --- a/sessions/libsessions.go +++ b/sessions/libsessions.go @@ -45,9 +45,9 @@ var authReqs = engine.MapEvent{ utils.META_PSEUDOPREPAID: struct{}{}, } -// SessionSClient is the interface implemented by Agents which are able to +// BiRPClient is the interface implemented by Agents which are able to // communicate bidirectionally with SessionS and remote Communication Switch -type SessionSClient interface { +type BiRPClient interface { Call(serviceMethod string, args interface{}, reply interface{}) error V1DisconnectSession(args utils.AttrDisconnectSession, reply *string) (err error) V1GetActiveSessionIDs(ignParam string, sessionIDs *[]*SessionID) (err error)