mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added stats csv read methods and test
This commit is contained in:
@@ -272,6 +272,10 @@ ResGroup21,*string,HdrAccount,1001;1002,2014-07-29T15:00:00Z,1s,2,call,10,
|
||||
ResGroup21,*string_prefix,HdrDestination,10;20,,,,,,
|
||||
ResGroup21,*rsr_fields,,HdrSubject(~^1.*1$);HdrDestination(1002),,,,,,
|
||||
ResGroup22,*destinations,HdrDestination,DST_FS,2014-07-29T15:00:00Z,3600s,2,premium_call,10,
|
||||
`
|
||||
stats = `
|
||||
#Id,FilterType,FilterFieldName,FilterFieldValues,ActivationInterval,QueueLength,TTL,Metrics,Store,Thresholds,Weight
|
||||
Stats1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*acd;*acc,true,THRESH1;THRESH2,20
|
||||
`
|
||||
)
|
||||
|
||||
@@ -279,7 +283,7 @@ var csvr *TpReader
|
||||
|
||||
func init() {
|
||||
csvr = NewTpReader(dataStorage, NewStringCSVStorage(',', destinations, timings, rates, destinationRates, ratingPlans, ratingProfiles,
|
||||
sharedGroups, lcrs, actions, actionPlans, actionTriggers, accountActions, derivedCharges, cdrStats, users, aliases, resLimits), testTPID, "")
|
||||
sharedGroups, lcrs, actions, actionPlans, actionTriggers, accountActions, derivedCharges, cdrStats, users, aliases, resLimits, stats), testTPID, "")
|
||||
if err := csvr.LoadDestinations(); err != nil {
|
||||
log.Print("error in LoadDestinations:", err)
|
||||
}
|
||||
@@ -330,6 +334,8 @@ func init() {
|
||||
}
|
||||
if err := csvr.LoadResourceLimits(); err != nil {
|
||||
}
|
||||
if err := csvr.LoadStats(); err != nil {
|
||||
}
|
||||
csvr.WriteToDatabase(false, false, false)
|
||||
cache.Flush()
|
||||
dataStorage.LoadRatingCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
@@ -1413,3 +1419,31 @@ func TestLoadResourceLimits(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestLoadStats(t *testing.T) {
|
||||
eStats := map[string]*utils.TPStats{
|
||||
"Stats1": &utils.TPStats{
|
||||
TPid: testTPID,
|
||||
ID: "Stats1",
|
||||
Filters: []*utils.TPRequestFilter{
|
||||
&utils.TPRequestFilter{Type: MetaString, FieldName: "Account", Values: []string{"1001", "1002"}},
|
||||
},
|
||||
ActivationInterval: &utils.TPActivationInterval{
|
||||
ActivationTime: "2014-07-29T15:00:00Z",
|
||||
},
|
||||
QueueLength: 100,
|
||||
TTL: "1s",
|
||||
Metrics: "*asr;*acd;*acc",
|
||||
Store: true,
|
||||
Thresholds: "THRESH1;THRESH2",
|
||||
Weight: 20,
|
||||
},
|
||||
}
|
||||
|
||||
// if len(csvr.stats) != len(eStats) {
|
||||
// t.Error("Failed to load stats: ", len(csvr.stats))
|
||||
// } else
|
||||
if !reflect.DeepEqual(eStats["Stats1"], csvr.stats["Stats1"]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eStats["Stats1"], csvr.stats["Stats1"])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user