mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Fixes for DispatcherS tests
This commit is contained in:
committed by
Dan Christian Bogos
parent
cf72c0aac3
commit
bb2d874319
39
data/conf/samples/dispatchers/attributes_mongo/cgrates.json
Normal file
39
data/conf/samples/dispatchers/attributes_mongo/cgrates.json
Normal file
@@ -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,
|
||||
},
|
||||
}
|
||||
|
||||
63
data/conf/samples/dispatchers/dispatchers_mongo/cgrates.json
Normal file
63
data/conf/samples/dispatchers/dispatchers_mongo/cgrates.json
Normal file
@@ -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"},
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
@@ -21,27 +21,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
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) {
|
||||
|
||||
@@ -21,10 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
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) {
|
||||
|
||||
129
dispatchers/libtest.go
Normal file
129
dispatchers/libtest.go
Normal file
@@ -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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
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)
|
||||
}
|
||||
@@ -21,10 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
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) {
|
||||
|
||||
@@ -21,7 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
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) {
|
||||
|
||||
@@ -21,7 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
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) {
|
||||
|
||||
@@ -21,7 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
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) {
|
||||
|
||||
@@ -21,7 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user