diff --git a/data/conf/samples/dispatchers/attributes_mongo/cgrates.json b/data/conf/samples/dispatchers/attributes_mongo/cgrates.json new file mode 100644 index 000000000..2b508c985 --- /dev/null +++ b/data/conf/samples/dispatchers/attributes_mongo/cgrates.json @@ -0,0 +1,39 @@ +{ +// CGRateS Configuration file +// + + +"general": { + "node_id": "AttributeS1", + "log_level": 7 +}, + +"listen": { + "rpc_json": ":5012", + "rpc_gob": ":5013", + "http": ":5080", +}, + +"data_db": { + "db_type": "mongo", + "db_name": "10", + "db_port": 27017, +}, + + +"stor_db": { + "db_type": "mongo", + "db_name": "cgrates", + "db_port": 27017, +}, + + +"attributes": { + "enabled": true +}, + +"rals": { + "enabled": true, +}, +} + \ No newline at end of file diff --git a/data/conf/samples/dispatchers/dispatchers_mongo/cgrates.json b/data/conf/samples/dispatchers/dispatchers_mongo/cgrates.json new file mode 100644 index 000000000..382bc9b00 --- /dev/null +++ b/data/conf/samples/dispatchers/dispatchers_mongo/cgrates.json @@ -0,0 +1,63 @@ +{ + +// Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +// Copyright (C) ITsysCOM GmbH +// +// This file contains the default configuration hardcoded into CGRateS. +// This is what you get when you load CGRateS with an empty configuration file. + +"general": { + "node_id": "DispatcherS1", + "reconnects": 1, +}, + + +"listen": { + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080", +}, + +"data_db": { + "db_type": "mongo", + "db_name": "10", + "db_port": 27017, +}, + + +"stor_db": { + "db_type": "mongo", + "db_name": "cgrates", + "db_port": 27017, +}, + +"cache":{ + "dispatcher_routes": {"limit": -1, "ttl": "2s"} +}, + + +"attributes": { + "enabled": false +}, + + +"dispatchers":{ + "enabled": true, + "attributes_conns": [ + {"address": "127.0.0.1:5012", "transport": "*json"}, + ], + "conns": { + "AttributeS1": [ + {"address": "127.0.0.1:5012", "transport": "*json"}, + ], + "ALL": [ + {"address": "127.0.0.1:6012", "transport": "*json"}, + ], + "ALL2": [ + {"address": "127.0.0.1:7012", "transport": "*json"}, + ], + }, +}, + + +} \ No newline at end of file diff --git a/dispatchers/attributes_it_test.go b/dispatchers/attributes_it_test.go index 6389c0df0..b846db31f 100755 --- a/dispatchers/attributes_it_test.go +++ b/dispatchers/attributes_it_test.go @@ -21,27 +21,14 @@ along with this program. If not, see package dispatchers import ( - "net/rpc" - "net/rpc/jsonrpc" - "os/exec" - "path" "reflect" - "strconv" "testing" - "time" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" ) -var ( - attrEngine *testDispatcher - dispEngine *testDispatcher - allEngine *testDispatcher - allEngine2 *testDispatcher -) - var sTestsDspAttr = []func(t *testing.T){ testDspAttrPingFailover, testDspAttrGetAttrFailover, @@ -54,94 +41,13 @@ var sTestsDspAttr = []func(t *testing.T){ testDspAttrTestAuthKey3, } -type testDispatcher struct { - CfgParh string - Cfg *config.CGRConfig - RCP *rpc.Client - cmd *exec.Cmd -} - -func newTestEngine(t *testing.T, cfgPath string, initDataDB, intitStoreDB bool) (d *testDispatcher) { - d = new(testDispatcher) - d.CfgParh = cfgPath - var err error - d.Cfg, err = config.NewCGRConfigFromFolder(d.CfgParh) - if err != nil { - t.Fatalf("Error at config init :%v\n", err) - } - d.Cfg.DataFolderPath = dspDataDir // Share DataFolderPath through config towards StoreDb for Flush() - - if initDataDB { - d.initDataDb(t) - } - - if intitStoreDB { - d.resetStorDb(t) - } - d.startEngine(t) - return d -} - -func (d *testDispatcher) startEngine(t *testing.T) { - var err error - if d.cmd, err = engine.StartEngine(d.CfgParh, dspDelay); err != nil { - t.Fatalf("Error at engine start:%v\n", err) - } - - if d.RCP, err = jsonrpc.Dial("tcp", d.Cfg.ListenCfg().RPCJSONListen); err != nil { - t.Fatalf("Error at dialing rcp client:%v\n", err) - } -} - -func (d *testDispatcher) stopEngine(t *testing.T) { - pid := strconv.Itoa(d.cmd.Process.Pid) - if err := exec.Command("kill", "-9", pid).Run(); err != nil { - t.Fatalf("Error at stop engine:%v\n", err) - } - // // if err := d.cmd.Process.Kill(); err != nil { - // // t.Fatalf("Error at stop engine:%v\n", err) - // } -} - -func (d *testDispatcher) initDataDb(t *testing.T) { - if err := engine.InitDataDb(d.Cfg); err != nil { - t.Fatalf("Error at DataDB init:%v\n", err) - } -} - -// Wipe out the cdr database -func (d *testDispatcher) resetStorDb(t *testing.T) { - if err := engine.InitStorDb(d.Cfg); err != nil { - t.Fatalf("Error at DataDB init:%v\n", err) - } -} -func (d *testDispatcher) loadData(t *testing.T, path string) { - var reply string - attrs := &utils.AttrLoadTpFromFolder{FolderPath: path} - if err := d.RCP.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil { - t.Errorf("Error at loading data from folder:%v", err) - } -} - //Test start here -func TestDspAttributeS(t *testing.T) { - engine.KillEngine(0) - allEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all"), true, true) - allEngine2 = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all2"), true, true) - attrEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "attributes"), true, true) - dispEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "dispatchers"), true, true) - allEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "tutorial")) - allEngine2.loadData(t, path.Join(dspDataDir, "tariffplans", "oldtutorial")) - attrEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "dispatchers")) - time.Sleep(500 * time.Millisecond) - for _, stest := range sTestsDspAttr { - t.Run("TestDspAttributeS", stest) - } - attrEngine.stopEngine(t) - dispEngine.stopEngine(t) - allEngine.stopEngine(t) - allEngine2.stopEngine(t) - engine.KillEngine(0) +func TestDspAttributeSTMySQL(t *testing.T) { + testDsp(t, sTestsDspAttr, "TestDspAttributeS", "all", "all2", "attributes", "dispatchers", "tutorial", "oldtutorial", "dispatchers") +} + +func TestDspAttributeSMongo(t *testing.T) { + testDsp(t, sTestsDspAttr, "TestDspAttributeS", "all", "all2", "attributes_mongo", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") } func testDspAttrPingFailover(t *testing.T) { diff --git a/dispatchers/chargers_it_test.go b/dispatchers/chargers_it_test.go index 0c4f4e966..e0b77f860 100755 --- a/dispatchers/chargers_it_test.go +++ b/dispatchers/chargers_it_test.go @@ -21,10 +21,8 @@ along with this program. If not, see package dispatchers import ( - "path" "reflect" "testing" - "time" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -40,24 +38,12 @@ var sTestsDspCpp = []func(t *testing.T){ } //Test start here -func TestDspChargerS(t *testing.T) { - engine.KillEngine(0) - allEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all"), true, true) - allEngine2 = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all2"), true, true) - attrEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "attributes"), true, true) - dispEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "dispatchers"), true, true) - allEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "tutorial")) - allEngine2.loadData(t, path.Join(dspDataDir, "tariffplans", "oldtutorial")) - attrEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "dispatchers")) - time.Sleep(500 * time.Millisecond) - for _, stest := range sTestsDspCpp { - t.Run("", stest) - } - attrEngine.stopEngine(t) - dispEngine.stopEngine(t) - allEngine.stopEngine(t) - allEngine2.stopEngine(t) - engine.KillEngine(0) +func TestDspChargerSTMySQL(t *testing.T) { + testDsp(t, sTestsDspCpp, "TestDspChargerS", "all", "all2", "attributes", "dispatchers", "tutorial", "oldtutorial", "dispatchers") +} + +func TestDspChargerSMongo(t *testing.T) { + testDsp(t, sTestsDspCpp, "TestDspChargerS", "all", "all2", "attributes_mongo", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") } func testDspCppPingFailover(t *testing.T) { diff --git a/dispatchers/libtest.go b/dispatchers/libtest.go new file mode 100644 index 000000000..7947e0f05 --- /dev/null +++ b/dispatchers/libtest.go @@ -0,0 +1,129 @@ +/* +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 dispatchers + +import ( + "net/rpc" + "net/rpc/jsonrpc" + "os/exec" + "path" + "strconv" + "testing" + "time" + + "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" +) + +var ( + attrEngine *testDispatcher + dispEngine *testDispatcher + allEngine *testDispatcher + allEngine2 *testDispatcher +) + +type testDispatcher struct { + CfgParh string + Cfg *config.CGRConfig + RCP *rpc.Client + cmd *exec.Cmd +} + +func newTestEngine(t *testing.T, cfgPath string, initDataDB, intitStoreDB bool) (d *testDispatcher) { + d = new(testDispatcher) + d.CfgParh = cfgPath + var err error + d.Cfg, err = config.NewCGRConfigFromFolder(d.CfgParh) + if err != nil { + t.Fatalf("Error at config init :%v\n", err) + } + d.Cfg.DataFolderPath = dspDataDir // Share DataFolderPath through config towards StoreDb for Flush() + + if initDataDB { + d.initDataDb(t) + } + + if intitStoreDB { + d.resetStorDb(t) + } + d.startEngine(t) + return d +} + +func (d *testDispatcher) startEngine(t *testing.T) { + var err error + if d.cmd, err = engine.StartEngine(d.CfgParh, dspDelay); err != nil { + t.Fatalf("Error at engine start:%v\n", err) + } + + if d.RCP, err = jsonrpc.Dial("tcp", d.Cfg.ListenCfg().RPCJSONListen); err != nil { + t.Fatalf("Error at dialing rcp client:%v\n", err) + } +} + +func (d *testDispatcher) stopEngine(t *testing.T) { + pid := strconv.Itoa(d.cmd.Process.Pid) + if err := exec.Command("kill", "-9", pid).Run(); err != nil { + t.Fatalf("Error at stop engine:%v\n", err) + } + // // if err := d.cmd.Process.Kill(); err != nil { + // // t.Fatalf("Error at stop engine:%v\n", err) + // } +} + +func (d *testDispatcher) initDataDb(t *testing.T) { + if err := engine.InitDataDb(d.Cfg); err != nil { + t.Fatalf("Error at DataDB init:%v\n", err) + } +} + +// Wipe out the cdr database +func (d *testDispatcher) resetStorDb(t *testing.T) { + if err := engine.InitStorDb(d.Cfg); err != nil { + t.Fatalf("Error at DataDB init:%v\n", err) + } +} +func (d *testDispatcher) loadData(t *testing.T, path string) { + var reply string + attrs := &utils.AttrLoadTpFromFolder{FolderPath: path} + if err := d.RCP.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil { + t.Errorf("Error at loading data from folder:%v", err) + } +} + +func testDsp(t *testing.T, tests []func(t *testing.T), testName, all, all2, attr, disp, allTF, all2TF, attrTF string) { + engine.KillEngine(0) + allEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", all), true, true) + allEngine2 = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", all2), true, true) + attrEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", attr), true, true) + dispEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", disp), true, true) + allEngine.loadData(t, path.Join(dspDataDir, "tariffplans", allTF)) + allEngine2.loadData(t, path.Join(dspDataDir, "tariffplans", all2TF)) + attrEngine.loadData(t, path.Join(dspDataDir, "tariffplans", attrTF)) + time.Sleep(500 * time.Millisecond) + for _, stest := range tests { + t.Run(testName, stest) + } + attrEngine.stopEngine(t) + dispEngine.stopEngine(t) + allEngine.stopEngine(t) + allEngine2.stopEngine(t) + engine.KillEngine(0) +} diff --git a/dispatchers/resources_it_test.go b/dispatchers/resources_it_test.go index fc2f137aa..5d5b50e94 100755 --- a/dispatchers/resources_it_test.go +++ b/dispatchers/resources_it_test.go @@ -21,10 +21,8 @@ along with this program. If not, see package dispatchers import ( - "path" "reflect" "testing" - "time" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -40,24 +38,12 @@ var sTestsDspRes = []func(t *testing.T){ } //Test start here -func TestDspResourceS(t *testing.T) { - engine.KillEngine(0) - allEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all"), true, true) - allEngine2 = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all2"), true, true) - attrEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "attributes"), true, true) - dispEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "dispatchers"), true, true) - allEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "tutorial")) - allEngine2.loadData(t, path.Join(dspDataDir, "tariffplans", "oldtutorial")) - attrEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "dispatchers")) - time.Sleep(500 * time.Millisecond) - for _, stest := range sTestsDspRes { - t.Run("", stest) - } - attrEngine.stopEngine(t) - dispEngine.stopEngine(t) - allEngine.stopEngine(t) - allEngine2.stopEngine(t) - engine.KillEngine(0) +func TestDspResourceSTMySQL(t *testing.T) { + testDsp(t, sTestsDspRes, "TestDspResourceS", "all", "all2", "attributes", "dispatchers", "tutorial", "oldtutorial", "dispatchers") +} + +func TestDspResourceSMongo(t *testing.T) { + testDsp(t, sTestsDspRes, "TestDspResourceS", "all", "all2", "attributes_mongo", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") } func testDspResPingFailover(t *testing.T) { diff --git a/dispatchers/sessions_it_test.go b/dispatchers/sessions_it_test.go index 016ab8853..4e0230743 100755 --- a/dispatchers/sessions_it_test.go +++ b/dispatchers/sessions_it_test.go @@ -21,7 +21,6 @@ along with this program. If not, see package dispatchers import ( - "path" "reflect" "sort" "strings" @@ -49,24 +48,12 @@ var sTestsDspSession = []func(t *testing.T){ } //Test start here -func TestDspSessionS(t *testing.T) { - engine.KillEngine(0) - allEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all"), true, true) - allEngine2 = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all2"), true, true) - attrEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "attributes"), true, true) - dispEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "dispatchers"), true, true) - allEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "testit")) - allEngine2.loadData(t, path.Join(dspDataDir, "tariffplans", "oldtutorial")) - attrEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "dispatchers")) - time.Sleep(500 * time.Millisecond) - for _, stest := range sTestsDspSession { - t.Run("", stest) - } - attrEngine.stopEngine(t) - dispEngine.stopEngine(t) - allEngine.stopEngine(t) - allEngine2.stopEngine(t) - engine.KillEngine(0) +func TestDspSessionSTMySQL(t *testing.T) { + testDsp(t, sTestsDspSession, "TestDspSessionS", "all", "all2", "attributes", "dispatchers", "testit", "oldtutorial", "dispatchers") +} + +func TestDspSessionSMongo(t *testing.T) { + testDsp(t, sTestsDspSession, "TestDspSessionS", "all", "all2", "attributes_mongo", "dispatchers_mongo", "testit", "oldtutorial", "dispatchers") } func testDspSessionAddBalacne(t *testing.T) { diff --git a/dispatchers/stats_it_test.go b/dispatchers/stats_it_test.go index bac185490..e8525e805 100755 --- a/dispatchers/stats_it_test.go +++ b/dispatchers/stats_it_test.go @@ -21,7 +21,6 @@ along with this program. If not, see package dispatchers import ( - "path" "reflect" "testing" "time" @@ -41,24 +40,12 @@ var sTestsDspSts = []func(t *testing.T){ } //Test start here -func TestDspStatS(t *testing.T) { - engine.KillEngine(0) - allEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all"), true, true) - allEngine2 = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all2"), true, true) - attrEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "attributes"), true, true) - dispEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "dispatchers"), true, true) - allEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "tutorial")) - allEngine2.loadData(t, path.Join(dspDataDir, "tariffplans", "oldtutorial")) - attrEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "dispatchers")) - time.Sleep(500 * time.Millisecond) - for _, stest := range sTestsDspSts { - t.Run("", stest) - } - attrEngine.stopEngine(t) - dispEngine.stopEngine(t) - allEngine.stopEngine(t) - allEngine2.stopEngine(t) - engine.KillEngine(0) +func TestDspStatSTMySQL(t *testing.T) { + testDsp(t, sTestsDspSts, "TestDspStatS", "all", "all2", "attributes", "dispatchers", "tutorial", "oldtutorial", "dispatchers") +} + +func TestDspStatSMongo(t *testing.T) { + testDsp(t, sTestsDspSts, "TestDspStatS", "all", "all2", "attributes_mongo", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") } func testDspStsPingFailover(t *testing.T) { diff --git a/dispatchers/suppliers_it_test.go b/dispatchers/suppliers_it_test.go index 4e0f608fc..642d4c6a4 100755 --- a/dispatchers/suppliers_it_test.go +++ b/dispatchers/suppliers_it_test.go @@ -21,7 +21,6 @@ along with this program. If not, see package dispatchers import ( - "path" "reflect" "testing" "time" @@ -40,24 +39,12 @@ var sTestsDspSup = []func(t *testing.T){ } //Test start here -func TestDspSupplierS(t *testing.T) { - engine.KillEngine(0) - allEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all"), true, true) - allEngine2 = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all2"), true, true) - attrEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "attributes"), true, true) - dispEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "dispatchers"), true, true) - allEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "tutorial")) - allEngine2.loadData(t, path.Join(dspDataDir, "tariffplans", "oldtutorial")) - attrEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "dispatchers")) - time.Sleep(500 * time.Millisecond) - for _, stest := range sTestsDspSup { - t.Run("", stest) - } - attrEngine.stopEngine(t) - dispEngine.stopEngine(t) - allEngine.stopEngine(t) - allEngine2.stopEngine(t) - engine.KillEngine(0) +func TestDspSupplierSTMySQL(t *testing.T) { + testDsp(t, sTestsDspSup, "TestDspSupplierS", "all", "all2", "attributes", "dispatchers", "tutorial", "oldtutorial", "dispatchers") +} + +func TestDspSupplierSMongo(t *testing.T) { + testDsp(t, sTestsDspSup, "TestDspSupplierS", "all", "all2", "attributes_mongo", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") } func testDspSupPing(t *testing.T) { diff --git a/dispatchers/thresholds_it_test.go b/dispatchers/thresholds_it_test.go index 817663666..46d3e90f5 100755 --- a/dispatchers/thresholds_it_test.go +++ b/dispatchers/thresholds_it_test.go @@ -21,7 +21,6 @@ along with this program. If not, see package dispatchers import ( - "path" "reflect" "sort" "testing" @@ -42,24 +41,12 @@ var sTestsDspTh = []func(t *testing.T){ } //Test start here -func TestDspThresholdS(t *testing.T) { - engine.KillEngine(0) - allEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all"), true, true) - allEngine2 = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "all2"), true, true) - attrEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "attributes"), true, true) - dispEngine = newTestEngine(t, path.Join(dspDataDir, "conf", "samples", "dispatchers", "dispatchers"), true, true) - allEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "tutorial")) - allEngine2.loadData(t, path.Join(dspDataDir, "tariffplans", "oldtutorial")) - attrEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "dispatchers")) - time.Sleep(500 * time.Millisecond) - for _, stest := range sTestsDspTh { - t.Run("", stest) - } - attrEngine.stopEngine(t) - dispEngine.stopEngine(t) - allEngine.stopEngine(t) - allEngine2.stopEngine(t) - engine.KillEngine(0) +func TestDspThresholdSTMySQL(t *testing.T) { + testDsp(t, sTestsDspTh, "TestDspThresholdS", "all", "all2", "attributes", "dispatchers", "tutorial", "oldtutorial", "dispatchers") +} + +func TestDspThresholdSMongo(t *testing.T) { + testDsp(t, sTestsDspTh, "TestDspThresholdS", "all", "all2", "attributes_mongo", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers") } func testDspThPingFailover(t *testing.T) { diff --git a/engine/model_helpers.go b/engine/model_helpers.go index da6b7ab04..a880496df 100644 --- a/engine/model_helpers.go +++ b/engine/model_helpers.go @@ -2821,7 +2821,9 @@ func APItoDispatcherProfile(tpDPP *utils.TPDispatcherProfile, timezone string) ( dpp.Subsystems[i] = sub } for i, param := range tpDPP.StrategyParams { - dpp.StrategyParams[string(i)] = param + if param != "" { + dpp.StrategyParams[strconv.Itoa(i)] = param + } } for i, conn := range tpDPP.Conns { dpp.Conns[i] = &DispatcherConn{ @@ -2835,7 +2837,9 @@ func APItoDispatcherProfile(tpDPP *utils.TPDispatcherProfile, timezone string) ( dpp.Conns[i].FilterIDs[j] = fltr } for j, param := range conn.Params { - dpp.Conns[i].Params[string(j)] = param + if param != "" { + dpp.Conns[i].Params[strconv.Itoa(j)] = param + } } } if tpDPP.ActivationInterval != nil {