diff --git a/apier/v1/apier_it_test.go b/apier/v1/apier_it_test.go index fe3fcaaf4..2d1567ddd 100644 --- a/apier/v1/apier_it_test.go +++ b/apier/v1/apier_it_test.go @@ -1101,7 +1101,10 @@ func TestApierGetAccountActionPlan(t *testing.T) { // Make sure we have scheduled actions func TestApierITGetScheduledActionsForAccount(t *testing.T) { var rply []*scheduler.ScheduledAction - if err := rater.Call("ApierV1.GetScheduledActions", scheduler.ArgsGetScheduledActions{Tenant: utils.StringPointer("cgrates.org"), Account: utils.StringPointer("dan7")}, &rply); err != nil { + if err := rater.Call("ApierV1.GetScheduledActions", + scheduler.ArgsGetScheduledActions{ + Tenant: utils.StringPointer("cgrates.org"), + Account: utils.StringPointer("dan7")}, &rply); err != nil { t.Error("Unexpected error: ", err) } else if len(rply) == 0 { t.Errorf("ScheduledActions: %+v", rply) diff --git a/apier/v1/smgenericv1_it_test.go b/apier/v1/smgenericv1_it_test.go deleted file mode 100644 index ef7acacea..000000000 --- a/apier/v1/smgenericv1_it_test.go +++ /dev/null @@ -1,143 +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 -*/ -package v1 - -import ( - "encoding/json" - "net/rpc" - "net/rpc/jsonrpc" - "path" - "reflect" - "testing" - "time" - - "github.com/cgrates/cgrates/config" - "github.com/cgrates/cgrates/engine" - "github.com/cgrates/cgrates/sessionmanager" - "github.com/cgrates/cgrates/utils" -) - -var smgV1CfgPath string -var smgV1Cfg *config.CGRConfig -var smgV1Rpc *rpc.Client -var smgV1LoadInst utils.LoadInstance // Share load information between tests - -func TestSMGV1InitCfg(t *testing.T) { - smgV1CfgPath = path.Join(*dataDir, "conf", "samples", "smgeneric") - // Init config first - var err error - smgV1Cfg, err = config.NewCGRConfigFromFolder(smgV1CfgPath) - if err != nil { - t.Error(err) - } - smgV1Cfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush() - config.SetCgrConfig(smgV1Cfg) -} - -// Remove data in both rating and accounting db -func TestSMGV1ResetDataDb(t *testing.T) { - if err := engine.InitDataDb(smgV1Cfg); err != nil { - t.Fatal(err) - } -} - -// Wipe out the cdr database -func TestSMGV1ResetStorDb(t *testing.T) { - if err := engine.InitStorDb(smgV1Cfg); err != nil { - t.Fatal(err) - } -} - -// Start CGR Engine -func TestSMGV1StartEngine(t *testing.T) { - if _, err := engine.StopStartEngine(smgV1CfgPath, *waitRater); err != nil { - t.Fatal(err) - } -} - -// Connect rpc client to rater -func TestSMGV1RpcConn(t *testing.T) { - var err error - smgV1Rpc, err = jsonrpc.Dial("tcp", smgV1Cfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed - if err != nil { - t.Fatal(err) - } -} - -// Load the tariff plan, creating accounts and their balances -func TestSMGV1LoadTariffPlanFromFolder(t *testing.T) { - var reply string - attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutorial")} - if err := smgV1Rpc.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil { - t.Error(err) - } - time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups -} - -// Check loaded stats -func TestSMGV1CacheStats(t *testing.T) { - var reply string - if err := smgV1Rpc.Call("ApierV1.LoadCache", utils.AttrReloadCache{}, &reply); err != nil { - t.Error(err) - } else if reply != "OK" { - t.Error(reply) - } - var rcvStats *utils.CacheStats - expectedStats := &utils.CacheStats{Destinations: 5, ReverseDestinations: 7, RatingPlans: 4, RatingProfiles: 10, - Actions: 9, ActionPlans: 4, AccountActionPlans: 5, SharedGroups: 1, DerivedChargers: 1, - LcrProfiles: 5, CdrStats: 6, Users: 3, Aliases: 1, ReverseAliases: 2, ResourceProfiles: 3, Resources: 3, StatQueues: 1, - StatQueueProfiles: 1, Thresholds: 7, ThresholdProfiles: 7, Filters: 16, SupplierProfiles: 3, AttributeProfiles: 1} - var args utils.AttrCacheStats - if err := smgV1Rpc.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil { - t.Error("Got error on ApierV1.GetCacheStats: ", err.Error()) - } else if !reflect.DeepEqual(expectedStats, rcvStats) { - t.Errorf("Calling ApierV1.GetCacheStats expected: %+v, received: %+v", expectedStats, rcvStats) - } -} - -// Make sure account was debited properly -func TestSMGV1AccountsBefore(t *testing.T) { - var reply *engine.Account - attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"} - if err := smgV1Rpc.Call("ApierV2.GetAccount", attrs, &reply); err != nil { - t.Error("Got error on ApierV2.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 { // Make sure we debitted - jsn, _ := json.Marshal(reply) - t.Errorf("Received: %s", jsn) - } -} - -// Make sure account was debited properly -func TestSMGV1GetMaxUsage(t *testing.T) { - setupReq := &sessionmanager.SMGenericEvent{utils.RequestType: utils.META_PREPAID, utils.Tenant: "cgrates.org", - utils.Account: "1003", utils.Destination: "1002", utils.SetupTime: "2015-11-10T15:20:00Z"} - var maxTime float64 - if err := smgV1Rpc.Call("SMGenericV1.GetMaxUsage", setupReq, &maxTime); err != nil { - t.Error(err) - } else if maxTime != 2700 { - t.Errorf("Calling ApierV1.GetMaxUsage got maxTime: %f", maxTime) - } -} - -func TestSMGV1StopCgrEngine(t *testing.T) { - if err := engine.KillEngine(100); err != nil { - t.Error(err) - } -} diff --git a/data/conf/samples/dmtagent/cgrates.json b/data/conf/samples/dmtagent/cgrates.json index 6f7f967ca..9624cac60 100644 --- a/data/conf/samples/dmtagent/cgrates.json +++ b/data/conf/samples/dmtagent/cgrates.json @@ -84,7 +84,7 @@ "enabled": true, }, -"smg": { +"sessions": { "enabled": true, }, diff --git a/data/conf/samples/hapool/cgrsmg1/cgr.json b/data/conf/samples/hapool/cgrsmg1/cgr.json index 0473fb2bc..727dfec6b 100644 --- a/data/conf/samples/hapool/cgrsmg1/cgr.json +++ b/data/conf/samples/hapool/cgrsmg1/cgr.json @@ -14,7 +14,7 @@ "cdrstats": "", // address where to reach the cdrstats service, empty to disable stats functionality<""|internal|x.y.z.y:1234> }, -"sm_generic": { +"sessions": { "enabled": true, "rals_conns": [ {"address": "127.0.0.1:2014"}, diff --git a/data/conf/samples/hapool/cgrsmg2/cgr.json b/data/conf/samples/hapool/cgrsmg2/cgr.json index 645a8ccf3..bb5233c64 100644 --- a/data/conf/samples/hapool/cgrsmg2/cgr.json +++ b/data/conf/samples/hapool/cgrsmg2/cgr.json @@ -14,7 +14,7 @@ "cdrstats": "", // address where to reach the cdrstats service, empty to disable stats functionality<""|internal|x.y.z.y:1234> }, -"sm_generic": { +"sessions": { "enabled": true, "rals_conns": [ {"address": "127.0.0.1:2014"}, diff --git a/data/conf/samples/hapool/dagent/cgr.json b/data/conf/samples/hapool/dagent/cgr.json index bf06a164c..0c136b1df 100644 --- a/data/conf/samples/hapool/dagent/cgr.json +++ b/data/conf/samples/hapool/dagent/cgr.json @@ -2,7 +2,7 @@ "diameter_agent": { "enabled": true, "listen": "127.0.0.1:3868", - "sm_generic_conns": [ + "sessions_conns": [ {"address": "127.0.0.1:2018"}, {"address": "127.0.0.1:2020"} ], diff --git a/data/conf/samples/radagent/cgrates.json b/data/conf/samples/radagent/cgrates.json index cc6e946bd..dd422ac18 100644 --- a/data/conf/samples/radagent/cgrates.json +++ b/data/conf/samples/radagent/cgrates.json @@ -86,14 +86,14 @@ "enabled": true, }, -"smg": { +"sessions": { "enabled": true, "debit_interval": "10s", }, "radius_agent": { "enabled": true, - "sm_generic_conns": [ + "sessions_conns": [ {"address": "127.0.0.1:2012", "transport": "*json"} // connection towards SMG component for session management ], "request_processors": [ diff --git a/data/conf/samples/smg/cgrates.json b/data/conf/samples/smg/cgrates.json index 03afaeeea..a3827cda5 100644 --- a/data/conf/samples/smg/cgrates.json +++ b/data/conf/samples/smg/cgrates.json @@ -48,7 +48,7 @@ "enabled": true, }, -"smg": { +"sessions": { "enabled": true, "session_ttl": "50ms", "rals_conns": [ diff --git a/data/conf/samples/smg_automatic_debits/cgrates.json b/data/conf/samples/smg_automatic_debits/cgrates.json index 2c3b6b931..6382532ca 100644 --- a/data/conf/samples/smg_automatic_debits/cgrates.json +++ b/data/conf/samples/smg_automatic_debits/cgrates.json @@ -23,7 +23,7 @@ "enabled": true, // start the CDR Server service: }, -"smg": { +"sessions": { "enabled": true, "debit_interval": "1ms", // interval to perform debits on. }, diff --git a/data/conf/samples/smgeneric/cgrates.json b/data/conf/samples/smgeneric/cgrates.json index 266bfbe62..bdafc9f43 100644 --- a/data/conf/samples/smgeneric/cgrates.json +++ b/data/conf/samples/smgeneric/cgrates.json @@ -74,7 +74,7 @@ }, -"smg": { +"sessions": { "enabled": true, // starts SessionManager service: }, diff --git a/data/conf/samples/smgreplcmaster/cgrates.json b/data/conf/samples/smgreplcmaster/cgrates.json index c5d4e5fff..2eaa67b4c 100644 --- a/data/conf/samples/smgreplcmaster/cgrates.json +++ b/data/conf/samples/smgreplcmaster/cgrates.json @@ -27,9 +27,9 @@ "enabled": true, }, -"sm_generic": { +"sessions": { "enabled": true, - "smg_replication_conns": [ + "session_replication_conns": [ {"address": "127.0.0.1:22012", "transport": "*json"}, ], }, diff --git a/data/conf/samples/tutmysql/cgrates.json b/data/conf/samples/tutmysql/cgrates.json index 1ee8f00e0..d37b039f1 100644 --- a/data/conf/samples/tutmysql/cgrates.json +++ b/data/conf/samples/tutmysql/cgrates.json @@ -165,7 +165,7 @@ }, -"smg": { +"sessions": { "enabled": true, }, diff --git a/data/conf/samples/tutpostgres/cgrates.json b/data/conf/samples/tutpostgres/cgrates.json index 5523dda81..e4c024ee6 100644 --- a/data/conf/samples/tutpostgres/cgrates.json +++ b/data/conf/samples/tutpostgres/cgrates.json @@ -102,7 +102,7 @@ }, -"smg": { +"sessions": { "enabled": true, }, diff --git a/data/tutorials/asterisk_ari/cgrates/etc/cgrates/cgrates.json b/data/tutorials/asterisk_ari/cgrates/etc/cgrates/cgrates.json index 7608d36e0..036565064 100644 --- a/data/tutorials/asterisk_ari/cgrates/etc/cgrates/cgrates.json +++ b/data/tutorials/asterisk_ari/cgrates/etc/cgrates/cgrates.json @@ -125,7 +125,7 @@ }, -"sm_generic": { +"sessions": { "enabled": true, "debit_interval": "5s", // interval to perform debits on. }, diff --git a/data/tutorials/osips_native/cgrates/etc/cgrates/cgrates.json b/data/tutorials/osips_native/cgrates/etc/cgrates/cgrates.json index 3539bb321..16cac4945 100644 --- a/data/tutorials/osips_native/cgrates/etc/cgrates/cgrates.json +++ b/data/tutorials/osips_native/cgrates/etc/cgrates/cgrates.json @@ -126,7 +126,7 @@ }, -"sm_generic": { +"sessions": { "enabled": true, "debit_interval": "10s", }, diff --git a/docs/architecture.rst b/docs/architecture.rst index 42937c665..393b65c8f 100644 --- a/docs/architecture.rst +++ b/docs/architecture.rst @@ -127,13 +127,6 @@ Responsible with call control on the Telecommunication Switch side. Operates in All call actions are logged into CGRateS's LogDB. -Right now there are **five** session manager types. - - sm_freeswitch - - sm_kamailio - - sm_opensips - - sm_asterisk - - **sm_generic** - - Communicates via: - RPC - internal/in-process *within the same running* **cgr-engine** process. @@ -142,12 +135,6 @@ Right now there are **five** session manager types. "stor_db" - (cdrDb) -- Config section in the CGRateS configuration file: - - ``"sm_freeswitch": {...}`` - - ``"sm_kamailio": {...}`` - - ``"sm_opensips": {...}`` - - ``"sm_asterisk": {...}`` - - ``"sm_generic": {...}`` 2.1.4. DiameterAgent service ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -165,7 +152,7 @@ Despite the name it is a flexible **Diameter Server**. - Config section in the CGRateS configuration file: - ``"diameter_agent": {...}`` -2.1.5. CDRS service +2.1.5. CDR service ~~~~~~~~~~~~~~~~~~~ Centralized CDR server and CDR (raw or rated) **replicator**.