Fix SMGV1 tests

This commit is contained in:
DanB
2016-12-27 15:31:16 +01:00
parent 4a46ca0781
commit e5f8a4147b
3 changed files with 34 additions and 11 deletions

View File

@@ -1111,7 +1111,6 @@ func (self *ApierV1) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
if attrs.Validate {
if !loader.IsValid() {
*reply = OK
return errors.New("invalid data")
}
}
@@ -1151,6 +1150,7 @@ func (self *ApierV1) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
if len(aps) != 0 {
sched := self.ServManager.GetScheduler()
if sched != nil {
utils.Logger.Info("ApierV1.LoadTariffPlanFromFolder, reloading scheduler.")
sched.Reload()
}
}

View File

@@ -83,25 +83,31 @@ func TestSMGV1RpcConn(t *testing.T) {
// 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("ApierV2.LoadTariffPlanFromFolder", attrs, &smgV1LoadInst); err != nil {
if err := smgV1Rpc.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil {
t.Error(err)
} else if smgV1LoadInst.RatingLoadID != "" && smgV1LoadInst.AccountingLoadID != "" {
t.Error("Non Empty loadId received, loadInstance: ", smgV1LoadInst)
}
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.PreloadCache", utils.AttrReloadCache{}, &reply); err != nil {
t.Error(err)
} else if reply != "OK" {
t.Error(reply)
}
var rcvStats *utils.CacheStats
expectedStats := &utils.CacheStats{Destinations: 0, RatingPlans: 4, RatingProfiles: 0, Actions: 7, ActionPlans: 4, SharedGroups: 0, Aliases: 0, ResourceLimits: 0,
DerivedChargers: 0, LcrProfiles: 0, CdrStats: 6, Users: 3}
expectedStats := &utils.CacheStats{Destinations: 5, ReverseDestinations: 7, RatingPlans: 4, RatingProfiles: 9,
Actions: 8, ActionPlans: 4, SharedGroups: 1, DerivedChargers: 1,
LcrProfiles: 5, CdrStats: 6, Users: 3, Aliases: 1, ReverseAliases: 2, ResourceLimits: 2}
var args utils.AttrCacheStats
if err := smgV1Rpc.Call("ApierV2.GetCacheStats", args, &rcvStats); err != nil {
t.Error("Got error on ApierV2.GetCacheStats: ", err.Error())
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 ApierV2.GetCacheStats expected: %+v, received: %+v", expectedStats, rcvStats)
t.Errorf("Calling ApierV1.GetCacheStats expected: %+v, received: %+v", expectedStats, rcvStats)
}
}
@@ -113,7 +119,7 @@ func TestSMGV1AccountsBefore(t *testing.T) {
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("Calling ApierV2.GetBalance received: %s", jsn)
t.Errorf("Received: %s", jsn)
}
}
@@ -125,7 +131,7 @@ func TestSMGV1GetMaxUsage(t *testing.T) {
if err := smgV1Rpc.Call("SMGenericV1.MaxUsage", setupReq, &maxTime); err != nil {
t.Error(err)
} else if maxTime != 2700 {
t.Errorf("Calling ApierV2.MaxUsage got maxTime: %f", maxTime)
t.Errorf("Calling ApierV1.MaxUsage got maxTime: %f", maxTime)
}
}

View File

@@ -12,6 +12,23 @@
"http": "0.0.0.0:3080", // HTTP listening address
},
"cache":{
"destinations": {"limit": 10000, "ttl":"0s", "precache": true},
"reverse_destinations": {"limit": 10000, "ttl":"0s", "precache": true},
"rating_plans": {"limit": 10000, "ttl":"0s","precache": true},
"rating_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"lcr": {"limit": 10000, "ttl":"0s", "precache": true},
"cdr_stats": {"limit": 10000, "ttl":"0s", "precache": true},
"actions": {"limit": 10000, "ttl":"0s", "precache": true},
"action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"action_triggers": {"limit": 10000, "ttl":"0s", "precache": true},
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
"aliases": {"limit": 10000, "ttl":"0s", "precache": true},
"reverse_aliases": {"limit": 10000, "ttl":"0s", "precache": true},
"derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_limits": {"limit": 10000, "ttl":"0s", "precache": true},
},
"rals": {
"enabled": true, // enable Rater service: <true|false>