Correctly type of arguments when LoaderS calling CacheS

This commit is contained in:
TeoV
2019-07-18 15:25:17 +03:00
committed by Dan Christian Bogos
parent 9470060e65
commit 1842b6d856
3 changed files with 48 additions and 26 deletions

View File

@@ -29,8 +29,8 @@ import (
)
var (
testTPID = "LoaderCSVTests"
destinations = `
testTPID = "LoaderCSVTests"
DestinationsCsv = `
#Tag,Prefix
GERMANY,49
GERMANY_O2,41
@@ -53,13 +53,13 @@ URG,112
EU_LANDLINE,444
EXOTIC,999
`
timings = `
TimingsCsv = `
WORKDAYS_00,*any,*any,*any,1;2;3;4;5,00:00:00
WORKDAYS_18,*any,*any,*any,1;2;3;4;5,18:00:00
WEEKENDS,*any,*any,*any,6;7,00:00:00
ONE_TIME_RUN,2012,,,,*asap
`
rates = `
RatesCsv = `
R1,0,0.2,60s,1s,0s
R2,0,0.1,60s,1s,0s
R3,0,0.05,60s,1s,0s
@@ -77,7 +77,7 @@ MX,0,1,1s,1s,0s
DY,0.15,0.05,60s,1s,0s
CF,1.12,0,1s,1s,0s
`
destinationRates = `
DestinationRatesCsv = `
RT_STANDARD,GERMANY,R1,*middle,4,0,
RT_STANDARD,GERMANY_O2,R2,*middle,4,0,
RT_STANDARD,GERMANY_PREMIUM,R2,*middle,4,0,
@@ -100,7 +100,7 @@ MX_DISC,RET,MX,*middle,4,10,*disconnect
RT_DY,RET,DY,*up,2,0,
RT_DY,EU_LANDLINE,CF,*middle,4,0,
`
ratingPlans = `
RatingPlansCsv = `
STANDARD,RT_STANDARD,WORKDAYS_00,10
STANDARD,RT_STD_WEEKEND,WORKDAYS_18,10
STANDARD,RT_STD_WEEKEND,WEEKENDS,10
@@ -125,7 +125,7 @@ GER_ONLY,GER,*any,10
ANY_PLAN,DATA_RATE,*any,10
DY_PLAN,RT_DY,*any,10
`
ratingProfiles = `
RatingProfilesCsv = `
CUSTOMER_1,0,rif:from:tm,2012-01-01T00:00:00Z,PREMIUM,danb
CUSTOMER_1,0,rif:from:tm,2012-02-28T00:00:00Z,STANDARD,danb
CUSTOMER_2,0,danb:87.139.12.167,2012-01-01T00:00:00Z,STANDARD,danb
@@ -154,12 +154,12 @@ cgrates.org,call,dy,2015-02-28T00:00:00Z,DY_PLAN,
cgrates.org,call,block,2015-02-28T00:00:00Z,DY_PLAN,
cgrates.org,call,round,2016-06-30T00:00:00Z,DEFAULT,
`
sharedGroups = `
SharedGroupsCsv = `
SG1,*any,*lowest,
SG2,*any,*lowest,one
SG3,*any,*lowest,
`
actions = `
ActionsCsv = `
MINI,*topup_reset,,,,*monetary,,,,,*unlimited,,10,10,false,false,10
MINI,*topup,,,,*voice,,NAT,test,,*unlimited,,100s,10,false,false,10
SHARED,*topup,,,,*monetary,,,,SG1,*unlimited,,100,10,false,false,10
@@ -182,7 +182,7 @@ NOEXP,*topup,,,,*voice,,,,,*unlimited,*any,50s,10,false,false,10
VF,*debit,,,,*monetary,,,,,*unlimited,*any,"{""Method"":""*incremental"",""Params"":{""Units"":10, ""Interval"":""month"", ""Increment"":""day""}}",10,false,false,10
TOPUP_RST_GNR_1000,*topup_reset,"{""*voice"": 60.0,""*data"":1024.0,""*sms"":1.0}",,,*generic,,*any,,,*unlimited,,1000,20,false,false,10
`
actionPlans = `
ActionPlansCsv = `
MORE_MINUTES,MINI,ONE_TIME_RUN,10
MORE_MINUTES,SHARED,ONE_TIME_RUN,10
TOPUP10_AT,TOPUP10_AC,*asap,10
@@ -196,14 +196,14 @@ BLOCK_EMPTY_AT,BLOCK_EMPTY,*asap,10
EXP_AT,EXP,*asap,10
`
actionTriggers = `
ActionTriggersCsv = `
STANDARD_TRIGGER,st0,*min_event_counter,10,false,0,,,,*voice,,GERMANY_O2,,,,,,,,SOME_1,10
STANDARD_TRIGGER,st1,*max_balance,200,false,0,,,,*voice,,GERMANY,,,,,,,,SOME_2,10
STANDARD_TRIGGERS,,*min_balance,2,false,0,,,,*monetary,,,,,,,,,,LOG_WARNING,10
STANDARD_TRIGGERS,,*max_balance,20,false,0,,,,*monetary,,,,,,,,,,LOG_WARNING,10
STANDARD_TRIGGERS,,*max_event_counter,5,false,0,,,,*monetary,,FS_USERS,,,,,,,,LOG_WARNING,10
`
accountActions = `
AccountActionsCsv = `
vdf,minitsboy,MORE_MINUTES,STANDARD_TRIGGER,,
cgrates.org,12345,TOPUP10_AT,STANDARD_TRIGGERS,,
cgrates.org,123456,TOPUP10_AT,STANDARD_TRIGGERS,,
@@ -222,12 +222,12 @@ cgrates.org,expnoexp,,,false,false
cgrates.org,vf,,,false,false
cgrates.org,round,TOPUP10_AT,,false,false
`
resProfiles = `
ResourcesCsv = `
#Tenant[0],Id[1],FilterIDs[2],ActivationInterval[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],Weight[9],Thresholds[10]
cgrates.org,ResGroup21,FLTR_1,2014-07-29T15:00:00Z,1s,2,call,true,true,10,
cgrates.org,ResGroup22,FLTR_ACNT_dan,2014-07-29T15:00:00Z,3600s,2,premium_call,true,true,10,
`
stats = `
StatsCsv = `
#Tenant[0],Id[1],FilterIDs[2],ActivationInterval[3],QueueLength[4],TTL[5],MinItems[6],Metrics[7],MetricFilterIDs[8],Stored[9],Blocker[10],Weight[11],ThresholdIDs[12]
cgrates.org,TestStats,FLTR_1,2014-07-29T15:00:00Z,100,1s,2,*sum#Value;*average#Value,,true,true,20,Th1;Th2
cgrates.org,TestStats,,,,,2,*sum#Usage,,true,true,20,
@@ -235,12 +235,12 @@ cgrates.org,TestStats2,FLTR_1,2014-07-29T15:00:00Z,100,1s,2,*sum#Value;*sum#Usag
cgrates.org,TestStats2,,,,,2,*sum#Cost;*average#Cost,,true,true,20,
`
thresholds = `
ThresholdsCsv = `
#Tenant[0],Id[1],FilterIDs[2],ActivationInterval[3],MaxHits[4],MinHits[5],MinSleep[6],Blocker[7],Weight[8],ActionIDs[9],Async[10]
cgrates.org,Threshold1,FLTR_1;FLTR_ACNT_dan,2014-07-29T15:00:00Z,12,10,1s,true,10,THRESH1,true
`
filters = `
FiltersCsv = `
#Tenant[0],ID[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5]
cgrates.org,FLTR_1,*string,Account,1001;1002,2014-07-29T15:00:00Z
cgrates.org,FLTR_1,*prefix,Destination,10;20,2014-07-29T15:00:00Z
@@ -249,28 +249,28 @@ 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
`
sppProfiles = `
SuppliersCsv = `
#Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParameters,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,SupplierBlocker,SupplierParameters,Weight
cgrates.org,SPP_1,FLTR_ACNT_dan,2014-07-29T15:00:00Z,*lowest_cost,,supplier1,FLTR_ACNT_dan,Account1;Account1_1,RPL_1,ResGroup1,Stat1,10,true,param1,20
cgrates.org,SPP_1,,,,,supplier1,,,RPL_2,ResGroup2,,10,,,
cgrates.org,SPP_1,,,,,supplier1,FLTR_DST_DE,Account2,RPL_3,ResGroup3,Stat2,10,,,
cgrates.org,SPP_1,,,,,supplier1,,,,ResGroup4,Stat3,10,,,
`
attributeProfiles = `
AttributesCsv = `
#Tenant,ID,Contexts,FilterIDs,ActivationInterval,AttributeFilterIDs,FieldName,Type,Value,Blocker,Weight
cgrates.org,ALS1,con1,FLTR_1,2014-07-29T15:00:00Z,*string:Field1:Initial,Field1,*variable,Sub1,true,20
cgrates.org,ALS1,con2;con3,,,,Field2,*variable,Sub2,true,20
`
chargerProfiles = `
ChargersCsv = `
#Tenant,ID,FilterIDs,ActivationInterval,RunID,AttributeIDs,Weight
cgrates.org,Charger1,*string:Account:1001,2014-07-29T15:00:00Z,*rated,ATTR_1001_SIMPLEAUTH,20
`
dispatcherProfiles = `
DispatcherCsv = `
#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 = `
DispatcherHostCsv = `
#Tenant[0],ID[1],Address[2],Transport[3],TLS[4]
cgrates.org,ALL1,127.0.0.1:2012,*json,true
cgrates.org,ALL1,127.0.0.1:3012,*json,false
@@ -280,10 +280,10 @@ cgrates.org,ALL1,127.0.0.1:3012,*json,false
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, dispatcherHosts), testTPID, "", nil, nil)
csvr = NewTpReader(dm.dataDB, NewStringCSVStorage(',', DestinationsCsv, TimingsCsv, RatesCsv, DestinationRatesCsv,
RatingPlansCsv, RatingProfilesCsv, SharedGroupsCsv, ActionsCsv, ActionPlansCsv, ActionTriggersCsv,
AccountActionsCsv, ResourcesCsv, StatsCsv, ThresholdsCsv, FiltersCsv, SuppliersCsv, AttributesCsv,
ChargersCsv, DispatcherCsv, DispatcherHostCsv), testTPID, "", nil, nil)
if err := csvr.LoadDestinations(); err != nil {
log.Print("error in LoadDestinations:", err)

View File

@@ -528,7 +528,9 @@ func (ldr *Loader) storeLoadedData(loaderType string,
if ldr.cacheS != nil {
var reply string
if err = ldr.cacheS.Call(utils.CacheSv1ReloadCache, cacheArgs, &reply); err != nil {
if err = ldr.cacheS.Call(utils.CacheSv1ReloadCache,
utils.AttrReloadCacheWithArgDispatcher{
AttrReloadCache: cacheArgs}, &reply); err != nil {
return err
}
}

20
loaders/loader_it_test.go Normal file
View File

@@ -0,0 +1,20 @@
// +build integration
/*
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 loaders