mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-25 09:08:45 +05:00
LCRProfile(2)
This commit is contained in:
committed by
Dan Christian Bogos
parent
be388e0aa4
commit
ffcee28567
@@ -289,6 +289,10 @@ cgrates.org,FLTR_1,*rsr_fields,,Subject(~^1.*1$);Destination(1002),
|
||||
cgrates.org,FLTR_ACNT_dan,*string,Account,dan,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_DST_DE,*destinations,Destination,DST_DE,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_DST_NL,*destinations,Destination,DST_NL,2014-07-29T15:00:00Z
|
||||
`
|
||||
lcrProfiles = `
|
||||
#Tenant,ID,FilterIDs,ActivationInterval,Strategy,StrategyParams,SupplierID,RatingPlanIDs,StatIDs,Weight
|
||||
cgrates.org,LCR_1,FLTR_ACNT_dan;FLTR_DST_DE,2014-07-29T15:00:00Z,*lowest_cost,,supplier1,RPL_1,,20
|
||||
`
|
||||
)
|
||||
|
||||
@@ -296,7 +300,7 @@ var csvr *TpReader
|
||||
|
||||
func init() {
|
||||
csvr = NewTpReader(dm.dataDB, NewStringCSVStorage(',', destinations, timings, rates, destinationRates, ratingPlans, ratingProfiles,
|
||||
sharedGroups, lcrs, actions, actionPlans, actionTriggers, accountActions, derivedCharges, cdrStats, users, aliases, resProfiles, stats, thresholds, filters), testTPID, "")
|
||||
sharedGroups, lcrs, actions, actionPlans, actionTriggers, accountActions, derivedCharges, cdrStats, users, aliases, resProfiles, stats, thresholds, filters, lcrProfiles), testTPID, "")
|
||||
|
||||
if err := csvr.LoadDestinations(); err != nil {
|
||||
log.Print("error in LoadDestinations:", err)
|
||||
@@ -358,9 +362,12 @@ func init() {
|
||||
if err := csvr.LoadThresholds(); err != nil {
|
||||
log.Print("error in LoadThresholds:", err)
|
||||
}
|
||||
if err := csvr.LoadLCRProfiles(); err != nil {
|
||||
log.Print("error in LoadThresholds:", err)
|
||||
}
|
||||
csvr.WriteToDatabase(false, false, false)
|
||||
cache.Flush()
|
||||
dm.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
dm.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
}
|
||||
|
||||
func TestLoadDestinations(t *testing.T) {
|
||||
@@ -1439,7 +1446,6 @@ func TestLoadResourceProfiles(t *testing.T) {
|
||||
} else if !reflect.DeepEqual(eResProfiles[resKey], csvr.resProfiles[resKey]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eResProfiles[resKey], csvr.resProfiles[resKey])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestLoadStatProfiles(t *testing.T) {
|
||||
@@ -1612,6 +1618,32 @@ func TestLoadFilters(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadLCRProfiles(t *testing.T) {
|
||||
eLCRprofiles := map[utils.TenantID]*utils.TPLCRProfile{
|
||||
utils.TenantID{Tenant: "cgrates.org", ID: "LCR_1"}: &utils.TPLCRProfile{
|
||||
TPid: testTPID,
|
||||
Tenant: "cgrates.org",
|
||||
ID: "LCR_1",
|
||||
FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
|
||||
ActivationInterval: &utils.TPActivationInterval{
|
||||
ActivationTime: "2014-07-29T15:00:00Z",
|
||||
},
|
||||
Strategy: "*lowest_cost",
|
||||
StrategyParams: nil,
|
||||
SupplierID: "supplier1",
|
||||
RatingPlanIDs: []string{"RPL_1"},
|
||||
StatIDs: nil,
|
||||
Weight: 20,
|
||||
},
|
||||
}
|
||||
resKey := utils.TenantID{Tenant: "cgrates.org", ID: "LCR_1"}
|
||||
if len(csvr.lcrProfiles) != len(eLCRprofiles) {
|
||||
t.Errorf("Failed to load LCRProfiles: %s", utils.ToIJSON(csvr.lcrProfiles))
|
||||
} else if !reflect.DeepEqual(eLCRprofiles[resKey], csvr.lcrProfiles[resKey]) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eLCRprofiles[resKey], csvr.lcrProfiles[resKey])
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadResource(t *testing.T) {
|
||||
eResources := []*utils.TenantID{
|
||||
&utils.TenantID{
|
||||
|
||||
Reference in New Issue
Block a user