moved test data from tut and renamed prepaid1cent

This commit is contained in:
Radu Ioan Fericean
2016-01-29 10:52:59 +02:00
parent 06d33d0dec
commit 583b53c143
25 changed files with 9 additions and 75 deletions

View File

@@ -52,7 +52,7 @@ README:
* Flush tables in storDb to start clean.
* Start engine with default configuration and give it some time to listen (here caching can slow down, hence the command argument parameter).
* Connect rpc client depending on encoding defined in configuration.
* Execute remote Apis and test their replies(follow prepaid1cent scenario so we can test load in dataDb also).
* Execute remote Apis and test their replies(follow testtp scenario so we can test load in dataDb also).
*/
var cfgPath string
@@ -1226,7 +1226,7 @@ func TestApierLoadTariffPlanFromFolder(t *testing.T) {
t.Error(err)
}
// Simple test that command is executed without errors
attrs = &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "prepaid1centpsec")}
attrs = &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testtp")}
if err := rater.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil {
t.Error("Got error on ApierV1.LoadTariffPlanFromFolder: ", err.Error())
} else if reply != "OK" {

View File

@@ -5,71 +5,6 @@ import (
"github.com/cgrates/cgrates/utils"
)
type AttrAddActionTrigger struct {
ActionTriggersId string
ActionTriggersUniqueId string
Tenant string
Account string
ThresholdType string
ThresholdValue float64
BalanceId string
BalanceType string
BalanceDirection string
BalanceDestinationIds string
BalanceRatingSubject string //ToDo
BalanceWeight float64
BalanceExpiryTime string
BalanceSharedGroup string //ToDo
Weight float64
ActionsId string
}
func (self *ApierV1) AddTriggeredAction(attr AttrAddActionTrigger, reply *string) error {
if attr.BalanceDirection == "" {
attr.BalanceDirection = utils.OUT
}
balExpiryTime, err := utils.ParseTimeDetectLayout(attr.BalanceExpiryTime, self.Config.DefaultTimezone)
if err != nil {
return utils.NewErrServerError(err)
}
at := &engine.ActionTrigger{
ID: attr.ActionTriggersId,
UniqueID: attr.ActionTriggersUniqueId,
ThresholdType: attr.ThresholdType,
ThresholdValue: attr.ThresholdValue,
BalanceId: attr.BalanceId,
BalanceType: attr.BalanceType,
BalanceDirections: utils.ParseStringMap(attr.BalanceDirection),
BalanceDestinationIds: utils.ParseStringMap(attr.BalanceDestinationIds),
BalanceWeight: attr.BalanceWeight,
BalanceExpirationDate: balExpiryTime,
Weight: attr.Weight,
ActionsId: attr.ActionsId,
Executed: false,
}
tag := utils.AccountKey(attr.Tenant, attr.Account)
_, err = engine.Guardian.Guard(func() (interface{}, error) {
userBalance, err := self.AccountDb.GetAccount(tag)
if err != nil {
return 0, err
}
userBalance.ActionTriggers = append(userBalance.ActionTriggers, at)
if err = self.AccountDb.SetAccount(userBalance); err != nil {
return 0, err
}
return 0, nil
}, 0, tag)
if err != nil {
*reply = err.Error()
return err
}
*reply = OK
return nil
}
type AttrSetAccountActionTriggers struct {
Tenant string
Account string

View File

@@ -4,3 +4,4 @@ cgrates.org,1002,PREPAID_10,STANDARD_TRIGGERS,,
cgrates.org,1003,PREPAID_10,STANDARD_TRIGGERS,,
cgrates.org,1004,PREPAID_10,STANDARD_TRIGGERS,,
cgrates.org,1005,PREPAID_10,STANDARD_TRIGGERS,,
cgrates.org,1009,TEST_EXE,,,
1 #Tenant Account ActionPlanId ActionTriggersId AllowNegative Disabled
4 cgrates.org 1003 PREPAID_10 STANDARD_TRIGGERS
5 cgrates.org 1004 PREPAID_10 STANDARD_TRIGGERS
6 cgrates.org 1005 PREPAID_10 STANDARD_TRIGGERS
7 cgrates.org 1009 TEST_EXE

View File

@@ -1,3 +1,4 @@
#Tag,ActionsTag,TimingTag,Weight
PREPAID_10,PREPAID_10,ASAP,10
PREPAID_10,BONUS_1,ASAP,10
TEST_EXE,TOPUP_EXE,ALWAYS,10
1 #Tag ActionsTag TimingTag Weight
2 PREPAID_10 PREPAID_10 ASAP 10
3 PREPAID_10 BONUS_1 ASAP 10
4 TEST_EXE TOPUP_EXE ALWAYS 10

View File

@@ -4,3 +4,4 @@ BONUS_1,*topup,,,,*monetary,*out,,*any,,,*unlimited,,1,10,false,false,10
LOG_BALANCE,*log,,,,,,,,,,,,,,false,false,10
CDRST_WARN_HTTP,*call_url,http://localhost:8080,,,,,,,,,,,,,false,false,10
CDRST_LOG,*log,,,,,,,,,,,,,,false,false,10
TOPUP_EXE,*topup,,,,*monetary,*out,,*any,,,*unlimited,,5,10,false,false,10
1 #ActionsTag[0] Action[1] ActionExtraParameters[2] Filter[3] BalanceTag[4] BalanceType[5] Directions[6] Categories[7] DestinationIds[8] RatingSubject[9] SharedGroup[10] ExpiryTime[11] TimingTags[12] Units[13] BalanceWeight[14] BalanceBlocker[15] BalanceDisabled[16] Weight[17]
4 LOG_BALANCE *log false false 10
5 CDRST_WARN_HTTP *call_url http://localhost:8080 false false 10
6 CDRST_LOG *log false false 10
7 TOPUP_EXE *topup *monetary *out *any *unlimited 5 10 false false 10

View File

@@ -1,3 +1,3 @@
#Tag,Years,Months,MonthDays,WeekDays,Time
ALWAYS,*any,*any,*any,*any,00:00:00
ASAP,*any,*any,*any,*any,*asap
ASAP,*any,*any,*any,*any,*asap
1 #Tag Years Months MonthDays WeekDays Time
2 ALWAYS *any *any *any *any 00:00:00
3 ASAP *any *any *any *any *asap

View File

@@ -4,4 +4,3 @@ cgrates.org,1002,PACKAGE_10,STANDARD_TRIGGERS,,
cgrates.org,1003,PACKAGE_10,STANDARD_TRIGGERS,,
cgrates.org,1004,PACKAGE_10,STANDARD_TRIGGERS,,
cgrates.org,1007,USE_SHARED_A,STANDARD_TRIGGERS,,
cgrates.org,1009,TEST_EXE,,,
1 #Tenant Account ActionPlanId ActionTriggersId AllowNegative Disabled
4 cgrates.org 1003 PACKAGE_10 STANDARD_TRIGGERS
5 cgrates.org 1004 PACKAGE_10 STANDARD_TRIGGERS
6 cgrates.org 1007 USE_SHARED_A STANDARD_TRIGGERS
cgrates.org 1009 TEST_EXE

View File

@@ -6,4 +6,3 @@ USE_SHARED_A,SHARED_A_0,*asap,10
PACKAGE_1001,TOPUP_RST_5,*asap,10
PACKAGE_1001,TOPUP_RST_SHARED_5,*asap,10
PACKAGE_1001,TOPUP_120_DST1003,*asap,10
TEST_EXE,TOPUP_EXE,DAILY,10
1 #Id ActionsId TimingId Weight
6 PACKAGE_1001 TOPUP_RST_5 *asap 10
7 PACKAGE_1001 TOPUP_RST_SHARED_5 *asap 10
8 PACKAGE_1001 TOPUP_120_DST1003 *asap 10
TEST_EXE TOPUP_EXE DAILY 10

View File

@@ -4,7 +4,6 @@ TOPUP_RST_5,*topup_reset,,,,*monetary,*out,,*any,,,*unlimited,,5,20,false,false,
TOPUP_RST_5,*topup_reset,,,,*voice,*out,,DST_1002,SPECIAL_1002,,*unlimited,,90,20,false,false,10
TOPUP_120_DST1003,*topup_reset,,,,*voice,*out,,DST_1003,,,*unlimited,,120,20,false,false,10
TOPUP_RST_SHARED_5,*topup,,,,*monetary,*out,,*any,,SHARED_A,*unlimited,,5,10,false,false,10
TOPUP_EXE,*topup,,,,*monetary,*out,,*any,,,*unlimited,,5,10,false,false,10
SHARED_A_0,*topup_reset,,,,*monetary,*out,,*any,,SHARED_A,*unlimited,,0,10,false,false,10
LOG_WARNING,*log,,,,,,,,,,,,,,false,false,10
DISABLE_AND_LOG,*log,,,,,,,,,,,,,,false,false,10
1 #ActionsId[0] Action[1] ExtraParameters[2] Filter[3] BalanceId[4] BalanceType[5] Directions[6] Categories[7] DestinationIds[8] RatingSubject[9] SharedGroup[10] ExpiryTime[11] TimingIds[12] Units[13] BalanceWeight[14] BalanceBlocker[15] BalanceDisabled[16] Weight[17]
4 TOPUP_RST_5 *topup_reset *voice *out DST_1002 SPECIAL_1002 *unlimited 90 20 false false 10
5 TOPUP_120_DST1003 *topup_reset *voice *out DST_1003 *unlimited 120 20 false false 10
6 TOPUP_RST_SHARED_5 *topup *monetary *out *any SHARED_A *unlimited 5 10 false false 10
TOPUP_EXE *topup *monetary *out *any *unlimited 5 10 false false 10
7 SHARED_A_0 *topup_reset *monetary *out *any SHARED_A *unlimited 0 10 false false 10
8 LOG_WARNING *log false false 10
9 DISABLE_AND_LOG *log false false 10

View File

@@ -4,5 +4,4 @@ ASAP,*any,*any,*any,*any,*asap
PEAK,*any,*any,*any,1;2;3;4;5,08:00:00
OFFPEAK_MORNING,*any,*any,*any,1;2;3;4;5,00:00:00
OFFPEAK_EVENING,*any,*any,*any,1;2;3;4;5,19:00:00
OFFPEAK_WEEKEND,*any,*any,*any,6;7,00:00:00
DAILY,*any,*any,*any,*any,00:00:00
OFFPEAK_WEEKEND,*any,*any,*any,6;7,00:00:00
1 #Tag Years Months MonthDays WeekDays Time
4 PEAK *any *any *any 1;2;3;4;5 08:00:00
5 OFFPEAK_MORNING *any *any *any 1;2;3;4;5 00:00:00
6 OFFPEAK_EVENING *any *any *any 1;2;3;4;5 19:00:00
7 OFFPEAK_WEEKEND *any *any *any 6;7 00:00:00
DAILY *any *any *any *any 00:00:00

View File

@@ -47,7 +47,7 @@ var accountDbCsv, accountDbStor, accountDbApier AccountingStorage // Each rating
var storDb LoadStorage
var lCfg *config.CGRConfig
var tpCsvScenario = flag.String("tp_scenario", "prepaid1centpsec", "Use this scenario folder to import tp csv data from")
var tpCsvScenario = flag.String("tp_scenario", "testtp", "Use this scenario folder to import tp csv data from")
// Create connection to ratingDb
// Will use 3 different datadbs in order to be able to see differences in data loaded

View File

@@ -135,7 +135,7 @@ func TestMCDRCApierLoadTariffPlanFromFolder(t *testing.T) {
}
reply := ""
// Simple test that command is executed without errors
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "prepaid1centpsec")}
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testtp")}
if err := rater.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err != nil {
t.Error("Got error on ApierV1.LoadTariffPlanFromFolder: ", err.Error())
} else if reply != "OK" {