mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated tests with dispatcher hosts
This commit is contained in:
committed by
Dan Christian Bogos
parent
ad54df15f7
commit
b2cd78af5d
@@ -361,6 +361,7 @@ func testCacheSPrecacheStatus(t *testing.T) {
|
||||
utils.CacheAttributeProfiles: utils.MetaReady,
|
||||
utils.CacheChargerProfiles: utils.MetaReady,
|
||||
utils.CacheDispatcherProfiles: utils.MetaReady,
|
||||
utils.CacheDispatcherHosts: utils.MetaReady,
|
||||
utils.CacheDiameterMessages: utils.MetaReady,
|
||||
utils.CacheAttributeFilterIndexes: utils.MetaReady,
|
||||
utils.CacheResourceFilterIndexes: utils.MetaReady,
|
||||
|
||||
@@ -191,6 +191,10 @@ func testPrecacheGetCacheStatsAfterRestart(t *testing.T) {
|
||||
Items: 0,
|
||||
Groups: 0,
|
||||
},
|
||||
utils.CacheDispatcherHosts: {
|
||||
Items: 0,
|
||||
Groups: 0,
|
||||
},
|
||||
utils.CacheDispatcherRoutes: {
|
||||
Items: 0,
|
||||
Groups: 0,
|
||||
|
||||
@@ -141,6 +141,7 @@ const CGRATES_CFG_JSON = `
|
||||
"attribute_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control attribute profile caching
|
||||
"charger_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control charger profile caching
|
||||
"dispatcher_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control dispatcher profile caching
|
||||
"dispatcher_hosts": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control dispatcher hosts caching
|
||||
"resource_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false}, // control resource filter indexes caching
|
||||
"stat_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false}, // control stat filter indexes caching
|
||||
"threshold_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false}, // control threshold filter indexes caching
|
||||
|
||||
@@ -136,6 +136,9 @@ func TestCacheJsonCfg(t *testing.T) {
|
||||
utils.CacheDispatcherProfiles: &CacheParamJsonCfg{Limit: utils.IntPointer(-1),
|
||||
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
|
||||
Precache: utils.BoolPointer(false)},
|
||||
utils.CacheDispatcherHosts: &CacheParamJsonCfg{Limit: utils.IntPointer(-1),
|
||||
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
|
||||
Precache: utils.BoolPointer(false)},
|
||||
utils.CacheResourceFilterIndexes: &CacheParamJsonCfg{Limit: utils.IntPointer(-1),
|
||||
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false)},
|
||||
utils.CacheStatFilterIndexes: &CacheParamJsonCfg{Limit: utils.IntPointer(-1),
|
||||
|
||||
@@ -687,6 +687,8 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) {
|
||||
TTL: time.Duration(0), StaticTTL: false, Precache: false},
|
||||
utils.CacheDispatcherProfiles: &CacheParamCfg{Limit: -1,
|
||||
TTL: time.Duration(0), StaticTTL: false, Precache: false},
|
||||
utils.CacheDispatcherHosts: &CacheParamCfg{Limit: -1,
|
||||
TTL: time.Duration(0), StaticTTL: false, Precache: false},
|
||||
utils.CacheResourceFilterIndexes: &CacheParamCfg{Limit: -1,
|
||||
TTL: time.Duration(0), StaticTTL: false, Precache: false},
|
||||
utils.CacheStatFilterIndexes: &CacheParamCfg{Limit: -1,
|
||||
|
||||
@@ -119,6 +119,7 @@
|
||||
// "attribute_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control attribute profile caching
|
||||
// "charger_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control charger profile caching
|
||||
// "dispatcher_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control dispatcher profile caching
|
||||
// "dispatcher_hosts": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control dispatcher hosts caching
|
||||
// "resource_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false}, // control resource filter indexes caching
|
||||
// "stat_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false}, // control stat filter indexes caching
|
||||
// "threshold_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false}, // control threshold filter indexes caching
|
||||
|
||||
@@ -447,6 +447,25 @@ CREATE TABLE tp_dispatchers (
|
||||
`id`,`filter_ids`,`strategy`,`conn_id`,`conn_filter_ids`)
|
||||
);
|
||||
|
||||
--
|
||||
-- Table structure for table `tp_dispatchers`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS tp_dispatcher_hosts;
|
||||
CREATE TABLE tp_dispatcher_hosts (
|
||||
`pk` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tpid` varchar(64) NOT NULL,
|
||||
`tenant` varchar(64) NOT NULL,
|
||||
`id` varchar(64) NOT NULL,
|
||||
`address` varchar(64) NOT NULL,
|
||||
`transport` varchar(64) NOT NULL,
|
||||
`created_at` TIMESTAMP,
|
||||
PRIMARY KEY (`pk`),
|
||||
KEY `tpid` (`tpid`),
|
||||
UNIQUE KEY `unique_tp_dispatchers_hosts` (`tpid`,`tenant`,
|
||||
`id`,`address`)
|
||||
);
|
||||
|
||||
--
|
||||
-- Table structure for table `versions`
|
||||
--
|
||||
|
||||
@@ -408,8 +408,8 @@ CREATE INDEX tp_suppliers_unique ON tp_suppliers ("tpid", "tenant", "id",
|
||||
CREATE INDEX tp_chargers_unique ON tp_chargers ("tpid", "tenant", "id",
|
||||
"filter_ids","run_id","attribute_ids");
|
||||
|
||||
--
|
||||
-- Table structure for table `tp_chargers`
|
||||
--
|
||||
-- Table structure for table `tp_dispatchers`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS tp_dispatchers;
|
||||
@@ -435,6 +435,24 @@ CREATE INDEX tp_suppliers_unique ON tp_suppliers ("tpid", "tenant", "id",
|
||||
CREATE INDEX tp_dispatchers_unique ON tp_dispatchers ("tpid", "tenant", "id",
|
||||
"filter_ids","strategy","conn_id","conn_filter_ids");
|
||||
|
||||
--
|
||||
-- Table structure for table `tp_dispatchers`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS tp_dispatcher_hosts;
|
||||
CREATE TABLE tp_dispatcher_hosts (
|
||||
"pk" SERIAL PRIMARY KEY,
|
||||
"tpid" varchar(64) NOT NULL,
|
||||
"tenant" varchar(64) NOT NULL,
|
||||
"id" varchar(64) NOT NULL,
|
||||
"address" varchar(64) NOT NULL,
|
||||
"transport" varchar(64) NOT NULL,
|
||||
"created_at" TIMESTAMP WITH TIME ZONE
|
||||
);
|
||||
CREATE INDEX tp_dispatchers_hosts_ids ON tp_dispatcher_hosts (tpid);
|
||||
CREATE INDEX tp_dispatcher_hosts_unique ON tp_dispatcher_hosts ("tpid", "tenant", "id",
|
||||
"address");
|
||||
|
||||
--
|
||||
-- Table structure for table `versions`
|
||||
--
|
||||
|
||||
@@ -157,6 +157,7 @@ func testDspChcPrecacheStatus(t *testing.T) {
|
||||
utils.CacheAttributeProfiles: utils.MetaReady,
|
||||
utils.CacheChargerProfiles: utils.MetaReady,
|
||||
utils.CacheDispatcherProfiles: utils.MetaReady,
|
||||
utils.CacheDispatcherHosts: utils.MetaReady,
|
||||
utils.CacheDiameterMessages: utils.MetaReady,
|
||||
utils.CacheAttributeFilterIndexes: utils.MetaReady,
|
||||
utils.CacheResourceFilterIndexes: utils.MetaReady,
|
||||
|
||||
@@ -21,6 +21,7 @@ package engine
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
@@ -404,7 +405,7 @@ func IfaceAsEventCost(itm interface{}) (ec *EventCost, err error) {
|
||||
case map[string]interface{}:
|
||||
ec, err = IfaceAsEventCost(utils.ToJSON(otm))
|
||||
default:
|
||||
err = utils.ErrNotConvertibleNoCaps
|
||||
err = utils.ErrNotConvertibleTF(reflect.TypeOf(otm).String(), "*EventCost")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ package engine
|
||||
import (
|
||||
"log"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -267,6 +269,11 @@ cgrates.org,Charger1,*string:Account:1001,2014-07-29T15:00:00Z,*rated,ATTR_1001_
|
||||
#Tenant,ID,FilterIDs,ActivationInterval,Strategy,Hosts,Weight
|
||||
cgrates.org,D1,*any,*string:Account:1001,2014-07-29T15:00:00Z,*first,,C1,*gt:Usage:10,10,false,192.168.56.203,20
|
||||
cgrates.org,D1,,,,*first,,C2,*lt:Usage:10,10,false,192.168.56.204,
|
||||
`
|
||||
dispatcherHosts = `
|
||||
#Tenant[0],ID[1],Address[2],Transport[3]
|
||||
cgrates.org,ALL1,127.0.0.1:2012,*json
|
||||
cgrates.org,ALL1,127.0.0.1:3012,*json
|
||||
`
|
||||
)
|
||||
|
||||
@@ -275,8 +282,8 @@ var csvr *TpReader
|
||||
func init() {
|
||||
csvr = NewTpReader(dm.dataDB, NewStringCSVStorage(',', destinations, timings, rates, destinationRates,
|
||||
ratingPlans, ratingProfiles, sharedGroups, actions, actionPlans, actionTriggers,
|
||||
accountActions, resProfiles, stats, thresholds,
|
||||
filters, sppProfiles, attributeProfiles, chargerProfiles, dispatcherProfiles), testTPID, "", nil)
|
||||
accountActions, resProfiles, stats, thresholds, filters, sppProfiles, attributeProfiles,
|
||||
chargerProfiles, dispatcherProfiles, dispatcherHosts), testTPID, "", nil)
|
||||
|
||||
if err := csvr.LoadDestinations(); err != nil {
|
||||
log.Print("error in LoadDestinations:", err)
|
||||
@@ -335,6 +342,9 @@ func init() {
|
||||
if err := csvr.LoadDispatcherProfiles(); err != nil {
|
||||
log.Print("error in LoadDispatcherProfiles:", err)
|
||||
}
|
||||
if err := csvr.LoadDispatcherHosts(); err != nil {
|
||||
log.Print("error in LoadDispatcherHosts:", err)
|
||||
}
|
||||
csvr.WriteToDatabase(false, false, false)
|
||||
Cache.Clear(nil)
|
||||
//dm.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
@@ -1624,6 +1634,35 @@ func TestLoadDispatcherProfiles(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadDispatcherHosts(t *testing.T) {
|
||||
eDispatcherHosts := &utils.TPDispatcherHost{
|
||||
TPid: testTPID,
|
||||
Tenant: "cgrates.org",
|
||||
ID: "ALL1",
|
||||
Conns: []*utils.TPDispatcherHostConn{
|
||||
&utils.TPDispatcherHostConn{
|
||||
Address: "127.0.0.1:2012",
|
||||
Transport: utils.MetaJSONrpc,
|
||||
},
|
||||
&utils.TPDispatcherHostConn{
|
||||
Address: "127.0.0.1:3012",
|
||||
Transport: utils.MetaJSONrpc,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
dphKey := utils.TenantID{Tenant: "cgrates.org", ID: "ALL1"}
|
||||
if len(csvr.dispatcherHosts) != 1 {
|
||||
t.Fatalf("Failed to load chargerProfiles: %s", utils.ToIJSON(csvr.chargerProfiles))
|
||||
}
|
||||
sort.Slice(csvr.dispatcherHosts[dphKey].Conns, func(i, j int) bool {
|
||||
return strings.Compare(csvr.dispatcherHosts[dphKey].Conns[i].Address, csvr.dispatcherHosts[dphKey].Conns[j].Address) == -1
|
||||
})
|
||||
if !reflect.DeepEqual(eDispatcherHosts, csvr.dispatcherHosts[dphKey]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(eDispatcherHosts), utils.ToJSON(csvr.dispatcherHosts[dphKey]))
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadResource(t *testing.T) {
|
||||
eResources := []*utils.TenantID{
|
||||
&utils.TenantID{
|
||||
|
||||
@@ -115,6 +115,7 @@ func TestLoaderITRemoveLoad(t *testing.T) {
|
||||
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.AttributesCsv),
|
||||
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.ChargersCsv),
|
||||
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.DispatchersCsv),
|
||||
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.DispatcherHostsCsv),
|
||||
), "", "", nil)
|
||||
|
||||
if err = loader.LoadDestinations(); err != nil {
|
||||
@@ -169,7 +170,10 @@ func TestLoaderITRemoveLoad(t *testing.T) {
|
||||
t.Error("Failed loading Charger profiles: ", err.Error())
|
||||
}
|
||||
if err = loader.LoadDispatcherProfiles(); err != nil {
|
||||
t.Error("Failed loading Charger profiles: ", err.Error())
|
||||
t.Error("Failed loading Dispatcher profiles: ", err.Error())
|
||||
}
|
||||
if err = loader.LoadDispatcherHosts(); err != nil {
|
||||
t.Error("Failed loading Dispatcher hosts: ", err.Error())
|
||||
}
|
||||
if err := loader.WriteToDatabase(true, false, false); err != nil {
|
||||
t.Error("Could not write data into dataDb: ", err.Error())
|
||||
@@ -207,6 +211,7 @@ func TestLoaderITLoadFromCSV(t *testing.T) {
|
||||
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.AttributesCsv),
|
||||
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.ChargersCsv),
|
||||
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.DispatchersCsv),
|
||||
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.DispatcherHostsCsv),
|
||||
), "", "", nil)
|
||||
|
||||
if err = loader.LoadDestinations(); err != nil {
|
||||
@@ -261,7 +266,10 @@ func TestLoaderITLoadFromCSV(t *testing.T) {
|
||||
t.Error("Failed loading Charger profiles: ", err.Error())
|
||||
}
|
||||
if err = loader.LoadDispatcherProfiles(); err != nil {
|
||||
t.Error("Failed loading Charger profiles: ", err.Error())
|
||||
t.Error("Failed loading Dispatcher profiles: ", err.Error())
|
||||
}
|
||||
if err = loader.LoadDispatcherHosts(); err != nil {
|
||||
t.Error("Failed loading Dispatcher hosts: ", err.Error())
|
||||
}
|
||||
if err := loader.WriteToDatabase(true, false, false); err != nil {
|
||||
t.Error("Could not write data into dataDb: ", err.Error())
|
||||
@@ -458,6 +466,17 @@ func TestLoaderITWriteToDatabase(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
for tenatid, dph := range loader.dispatcherHosts {
|
||||
rcv, err := loader.dm.GetDispatcherHost(tenatid.Tenant, tenatid.ID, false, false, utils.NonTransactional)
|
||||
if err != nil {
|
||||
t.Errorf("Failed GetDispatcherHost, tenant: %s, id: %s, error: %s ", dph.Tenant, dph.ID, err.Error())
|
||||
}
|
||||
dp := APItoDispatcherHost(dph)
|
||||
if !reflect.DeepEqual(dp, rcv) {
|
||||
t.Errorf("Expecting: %v, received: %v", dp, rcv)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Imports data from csv files in tpScenario to storDb
|
||||
|
||||
@@ -412,4 +412,5 @@ type TPDispatcherHost struct {
|
||||
ID string `index:"1" re:""`
|
||||
Address string `index:"2" re:""`
|
||||
Transport string `index:"3" re:""`
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ func (ms *MapStorage) HasDataDrv(category, subject, tenant string) (bool, error)
|
||||
case utils.ResourcesPrefix, utils.ResourceProfilesPrefix, utils.StatQueuePrefix,
|
||||
utils.StatQueueProfilePrefix, utils.ThresholdPrefix, utils.ThresholdProfilePrefix,
|
||||
utils.FilterPrefix, utils.SupplierProfilePrefix, utils.AttributeProfilePrefix,
|
||||
utils.ChargerProfilePrefix, utils.DispatcherProfilePrefix:
|
||||
utils.ChargerProfilePrefix, utils.DispatcherProfilePrefix, utils.DispatcherHostPrefix:
|
||||
_, exists := ms.dict[category+utils.ConcatenatedKey(tenant, subject)]
|
||||
return exists, nil
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ ENABLE_ACNT,*enable_account,,,,,,,,,,,,,false,false,10`
|
||||
csvr := engine.NewTpReader(dbAcntActs.DataDB(), engine.NewStringCSVStorage(',', destinations, timings,
|
||||
rates, destinationRates, ratingPlans, ratingProfiles, sharedGroups,
|
||||
actions, actionPlans, actionTriggers, accountActions,
|
||||
resLimits, stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``), "", "", nil)
|
||||
resLimits, stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, ""), "", "", nil)
|
||||
if err := csvr.LoadAll(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -65,7 +65,7 @@ ENABLE_ACNT,*enable_account,,,,,,,,,,,,,false,false,10`
|
||||
|
||||
engine.Cache.Clear(nil)
|
||||
dbAcntActs.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil,
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
|
||||
expectAcnt := &engine.Account{ID: "cgrates.org:1"}
|
||||
if acnt, err := dbAcntActs.DataDB().GetAccount("cgrates.org:1"); err != nil {
|
||||
|
||||
@@ -64,7 +64,7 @@ cgrates.org,call,*any,2013-01-06T00:00:00Z,RP_ANY,`
|
||||
chargerProfiles := ``
|
||||
csvr := engine.NewTpReader(dbAuth.DataDB(), engine.NewStringCSVStorage(',', destinations, timings, rates, destinationRates,
|
||||
ratingPlans, ratingProfiles, sharedGroups, actions, actionPlans, actionTriggers, accountActions,
|
||||
resLimits, stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``), "", "", nil)
|
||||
resLimits, stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, ""), "", "", nil)
|
||||
if err := csvr.LoadAll(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -77,7 +77,7 @@ cgrates.org,call,*any,2013-01-06T00:00:00Z,RP_ANY,`
|
||||
|
||||
engine.Cache.Clear(nil)
|
||||
dbAuth.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil,
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
|
||||
if cachedDests := len(engine.Cache.GetItemIDs(utils.CacheDestinations, "")); cachedDests != 0 {
|
||||
t.Error("Wrong number of cached destinations found", cachedDests)
|
||||
|
||||
@@ -54,7 +54,7 @@ RP_SMS1,DR_SMS_1,ALWAYS,10`
|
||||
cgrates.org,data,*any,2012-01-01T00:00:00Z,RP_DATA1,
|
||||
cgrates.org,sms,*any,2012-01-01T00:00:00Z,RP_SMS1,`
|
||||
csvr := engine.NewTpReader(dataDB.DataDB(), engine.NewStringCSVStorage(',', dests, timings, rates, destinationRates, ratingPlans, ratingProfiles,
|
||||
"", "", "", "", "", "", "", "", "", "", "", "", ""), "", "", nil)
|
||||
"", "", "", "", "", "", "", "", "", "", "", "", "", ""), "", "", nil)
|
||||
|
||||
if err := csvr.LoadTimings(); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -77,7 +77,7 @@ cgrates.org,sms,*any,2012-01-01T00:00:00Z,RP_SMS1,`
|
||||
csvr.WriteToDatabase(false, false, false)
|
||||
engine.Cache.Clear(nil)
|
||||
dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil,
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
|
||||
if cachedRPlans := len(engine.Cache.GetItemIDs(utils.CacheRatingPlans, "")); cachedRPlans != 3 {
|
||||
t.Error("Wrong number of cached rating plans found", cachedRPlans)
|
||||
|
||||
@@ -42,7 +42,7 @@ DR_DATA_2,*any,RT_DATA_1c,*up,4,0,`
|
||||
RP_DATA1,DR_DATA_2,TM2,10`
|
||||
ratingProfiles := `cgrates.org,data,*any,2012-01-01T00:00:00Z,RP_DATA1,`
|
||||
csvr := engine.NewTpReader(dataDB.DataDB(), engine.NewStringCSVStorage(',', "", timings, rates, destinationRates, ratingPlans, ratingProfiles,
|
||||
"", "", "", "", "", "", "", "", "", "", "", "", ""), "", "", nil)
|
||||
"", "", "", "", "", "", "", "", "", "", "", "", "", ""), "", "", nil)
|
||||
if err := csvr.LoadTimings(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -61,7 +61,7 @@ RP_DATA1,DR_DATA_2,TM2,10`
|
||||
csvr.WriteToDatabase(false, false, false)
|
||||
engine.Cache.Clear(nil)
|
||||
dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil,
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
|
||||
if cachedRPlans := len(engine.Cache.GetItemIDs(utils.CacheRatingPlans, "")); cachedRPlans != 1 {
|
||||
t.Error("Wrong number of cached rating plans found", cachedRPlans)
|
||||
|
||||
@@ -66,7 +66,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10`
|
||||
destinationRates, ratingPlans, ratingProfiles,
|
||||
sharedGroups, actions, actionPlans, actionTriggers, accountActions,
|
||||
resLimits, stats, thresholds, filters, suppliers,
|
||||
attrProfiles, chargerProfiles, ``), "", "", nil)
|
||||
attrProfiles, chargerProfiles, ``, ""), "", "", nil)
|
||||
if err := csvr.LoadDestinations(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -109,7 +109,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10`
|
||||
engine.Cache.Clear(nil)
|
||||
|
||||
dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil,
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
|
||||
if cachedDests := len(engine.Cache.GetItemIDs(utils.CacheDestinations, "")); cachedDests != 0 {
|
||||
t.Error("Wrong number of cached destinations found", cachedDests)
|
||||
|
||||
@@ -64,7 +64,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10`
|
||||
csvr := engine.NewTpReader(dataDB2.DataDB(), engine.NewStringCSVStorage(',', destinations, timings,
|
||||
rates, destinationRates, ratingPlans, ratingProfiles, sharedGroups, actions, actionPlans,
|
||||
actionTriggers, accountActions, resLimits,
|
||||
stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``), "", "", nil)
|
||||
stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, ""), "", "", nil)
|
||||
if err := csvr.LoadDestinations(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -106,7 +106,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10`
|
||||
}
|
||||
engine.Cache.Clear(nil)
|
||||
dataDB2.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil,
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
|
||||
if cachedDests := len(engine.Cache.GetItemIDs(utils.CacheDestinations, "")); cachedDests != 0 {
|
||||
t.Error("Wrong number of cached destinations found", cachedDests)
|
||||
|
||||
@@ -62,7 +62,7 @@ cgrates.org,call,discounted_minutes,2013-01-06T00:00:00Z,RP_UK_Mobile_BIG5_PKG,`
|
||||
csvr := engine.NewTpReader(dataDB3.DataDB(), engine.NewStringCSVStorage(',', destinations, timings, rates,
|
||||
destinationRates, ratingPlans, ratingProfiles, sharedGroups, actions, actionPlans, actionTriggers,
|
||||
accountActions, resLimits, stats,
|
||||
thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``), "", "", nil)
|
||||
thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, ""), "", "", nil)
|
||||
if err := csvr.LoadDestinations(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -105,7 +105,7 @@ cgrates.org,call,discounted_minutes,2013-01-06T00:00:00Z,RP_UK_Mobile_BIG5_PKG,`
|
||||
}
|
||||
engine.Cache.Clear(nil)
|
||||
dataDB3.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil,
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
|
||||
if cachedDests := len(engine.Cache.GetItemIDs(utils.CacheDestinations, "")); cachedDests != 0 {
|
||||
t.Error("Wrong number of cached destinations found", cachedDests)
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestSMSLoadCsvTpSmsChrg1(t *testing.T) {
|
||||
ratingPlans := `RP_SMS1,DR_SMS_1,ALWAYS,10`
|
||||
ratingProfiles := `cgrates.org,sms,*any,2012-01-01T00:00:00Z,RP_SMS1,`
|
||||
csvr := engine.NewTpReader(dataDB.DataDB(), engine.NewStringCSVStorage(',', "", timings, rates, destinationRates, ratingPlans, ratingProfiles,
|
||||
"", "", "", "", "", "", "", "", "", "", "", "", ""), "", "", nil)
|
||||
"", "", "", "", "", "", "", "", "", "", "", "", "", ""), "", "", nil)
|
||||
if err := csvr.LoadTimings(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func TestSMSLoadCsvTpSmsChrg1(t *testing.T) {
|
||||
csvr.WriteToDatabase(false, false, false)
|
||||
engine.Cache.Clear(nil)
|
||||
dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil,
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
|
||||
if cachedRPlans := len(engine.Cache.GetItemIDs(utils.CacheRatingPlans, "")); cachedRPlans != 1 {
|
||||
t.Error("Wrong number of cached rating plans found", cachedRPlans)
|
||||
|
||||
@@ -217,3 +217,7 @@ func IsNetworkError(err error) bool {
|
||||
func ErrPathNotReachable(path string) error {
|
||||
return fmt.Errorf("path:%+q is not reachable", path)
|
||||
}
|
||||
|
||||
func ErrNotConvertibleTF(from, to string) error {
|
||||
return fmt.Errorf("%s : from: %s to:%s", ErrNotConvertibleNoCaps.Error(), from, to)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user