Adding prepaid1centpsec rate sample files

This commit is contained in:
DanB
2013-04-11 15:29:30 +02:00
parent 44d5ef8854
commit 2e649e7330
17 changed files with 76 additions and 44 deletions

View File

@@ -0,0 +1,6 @@
Tenant,Account,Direction,ActionTimingsTag,ActionTriggersTag
0,1000,OUT,TOPUP_10,
0,1001,OUT,TOPUP_10,
0,1002,OUT,TOPUP_10,
0,1003,OUT,TOPUP_10,
0,1004,OUT,TOPUP_10,
1 Tenant Account Direction ActionTimingsTag ActionTriggersTag
2 0 1000 OUT TOPUP_10
3 0 1001 OUT TOPUP_10
4 0 1002 OUT TOPUP_10
5 0 1003 OUT TOPUP_10
6 0 1004 OUT TOPUP_10

View File

@@ -0,0 +1,2 @@
Tag,ActionsTag,TimingTag, Weight
TOPUP_10,TOPUP_10,ONE_TIME_RUN,10
1 Tag ActionsTag TimingTag Weight
2 TOPUP_10 TOPUP_10 ONE_TIME_RUN 10

View File

@@ -0,0 +1 @@
Tag,BalanceTag,Direction,ThresholdValue,DestinationTag,ActionsTag,Weight
1 Tag BalanceTag Direction ThresholdValue DestinationTag ActionsTag Weight

View File

@@ -0,0 +1,2 @@
Tag,Action,BalanceTag,Direction,Units,DestinationTag,PriceType,PriceValue,MinutesWeight,Weight
TOPUP_10,TOPUP_RESET,MONETARY,OUT,10,*all,,,,10
1 Tag Action BalanceTag Direction Units DestinationTag PriceType PriceValue MinutesWeight Weight
2 TOPUP_10 TOPUP_RESET MONETARY OUT 10 *all 10

View File

@@ -0,0 +1,2 @@
Tag,Prefix
FS_USERS,10
1 Tag Prefix
2 FS_USERS 10

View File

@@ -0,0 +1,10 @@
CGRateS - Prepaid1CentPSec
===========================
Scenario:
--------
* Creates 5 prepaid accounts
* Loads prepaid accounts each with 10 units of credit
* Defines rates of 1 cent per second for TOR 0, Tenant 0, independent of time of the call.

View File

@@ -0,0 +1,2 @@
Tag,RatesTag,TimingProfile,Weight
1CENTPERSEC,1CENTPERSEC,ALWAYS,10
1 Tag RatesTag TimingProfile Weight
2 1CENTPERSEC 1CENTPERSEC ALWAYS 10

View File

@@ -0,0 +1,2 @@
Tag,DestinationsTag,ConnectFee,Price,PricedUnits,RateIncrements
1CENTPERSEC,FS_USERS,0,0.01,1,1
1 Tag DestinationsTag ConnectFee Price PricedUnits RateIncrements
2 1CENTPERSEC FS_USERS 0 0.01 1 1

View File

@@ -0,0 +1,2 @@
Tenant,TOR,Direction,Subject,RatesFallbackSubject,RatesTimingTag,ActivationTime
0,0,OUT,*all,,1CENTPERSEC,2013-01-01T00:00:00Z
1 Tenant TOR Direction Subject RatesFallbackSubject RatesTimingTag ActivationTime
2 0 0 OUT *all 1CENTPERSEC 2013-01-01T00:00:00Z

View File

@@ -0,0 +1,3 @@
Tag,Years,Months,MonthDays,WeekDays,Time
ALWAYS,*all,*all,*all,*all,00:00:00
ONE_TIME_RUN,,,,,*asap
1 Tag Years Months MonthDays WeekDays Time
2 ALWAYS *all *all *all *all 00:00:00
3 ONE_TIME_RUN *asap

View File

@@ -19,12 +19,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package rater
import (
"log"
"testing"
"time"
"log"
)
func ATestAccountLock(t *testing.T) {
func ATestAccountLock(t *testing.T) {
go AccLock.Guard("1", func() (float64, error) {
log.Print("first 1")
time.Sleep(1 * time.Second)

View File

@@ -40,30 +40,30 @@ type Action struct {
type actionTypeFunc func(*UserBalance, *Action) error
func getActionFunc(typ string)(actionTypeFunc, bool) {
func getActionFunc(typ string) (actionTypeFunc, bool) {
switch typ {
case "LOG":
return logAction, true
case "RESET_TRIGGERS":
return resetTriggersAction, true
case "SET_POSTPAID":
return setPostpaidAction, true
case "RESET_POSTPAID":
return resetPostpaidAction, true
case "SET_PREPAID":
return setPrepaidAction, true
case "RESET_PREPAID":
return resetPrepaidAction, true
case "TOPUP_RESET":
return topupResetAction, true
case "TOPUP":
return topupAction, true
case "DEBIT":
return debitAction, true
case "RESET_COUNTER":
return resetCounterAction, true
case "RESET_COUNTERS":
return resetCountersAction, true
case "LOG":
return logAction, true
case "RESET_TRIGGERS":
return resetTriggersAction, true
case "SET_POSTPAID":
return setPostpaidAction, true
case "RESET_POSTPAID":
return resetPostpaidAction, true
case "SET_PREPAID":
return setPrepaidAction, true
case "RESET_PREPAID":
return resetPrepaidAction, true
case "TOPUP_RESET":
return topupResetAction, true
case "TOPUP":
return topupAction, true
case "DEBIT":
return debitAction, true
case "RESET_COUNTER":
return resetCounterAction, true
case "RESET_COUNTERS":
return resetCountersAction, true
}
return nil, false
}
@@ -79,7 +79,7 @@ func resetTriggersAction(ub *UserBalance, a *Action) (err error) {
}
func setPostpaidAction(ub *UserBalance, a *Action) (err error) {
ub.Type = UB_TYPE_POSTPAID
ub.Type = UB_TYPE_POSTPAID
return
}

View File

@@ -305,7 +305,7 @@ func (at *ActionTiming) restore(input string) {
at.Id = elements[0]
at.Tag = elements[1]
for _, ubi := range strings.Split(elements[2], ",") {
if strings.TrimSpace(ubi) != ""{
if strings.TrimSpace(ubi) != "" {
at.UserBalanceIds = append(at.UserBalanceIds, ubi)
}
}

View File

@@ -350,10 +350,10 @@ func (cd *CallDescriptor) Debit() (cc *CallCost, err error) {
Logger.Err(fmt.Sprintf("<Rater> Error getting cost for account key %v: %v", cd.GetUserBalanceKey(), err))
return
}
if userBalance, err := cd.getUserBalance(); err == nil && userBalance != nil {
if userBalance, err := cd.getUserBalance(); err != nil {
Logger.Err(fmt.Sprintf("<Rater> Error retrieving user balance: %v", err))
} else if userBalance == nil {
Logger.Debug(fmt.Sprintf("<Rater> No user balance defined: %v",cd.GetUserBalanceKey()))
Logger.Debug(fmt.Sprintf("<Rater> No user balance defined: %v", cd.GetUserBalanceKey()))
} else {
Logger.Debug(fmt.Sprintf("<Rater> Attempting to debit from %v, value: %v", cd.GetUserBalanceKey(), cc.Cost+cc.ConnectFee))
defer storageGetter.SetUserBalance(userBalance)

View File

@@ -207,14 +207,14 @@ func (sm *FSSessionManager) OnChannelHangupComplete(ev Event) {
return
}
cd := rater.CallDescriptor{
Direction: ev.GetDirection(),
Tenant: ev.GetTenant(),
TOR: ev.GetTOR(),
Subject: ev.GetSubject(),
Account: ev.GetAccount(),
Destination: ev.GetDestination(),
TimeStart: startTime,
TimeEnd: endTime,
Direction: ev.GetDirection(),
Tenant: ev.GetTenant(),
TOR: ev.GetTOR(),
Subject: ev.GetSubject(),
Account: ev.GetAccount(),
Destination: ev.GetDestination(),
TimeStart: startTime,
TimeEnd: endTime,
FallbackSubject: ev.GetFallbackSubj(),
}
cc := &rater.CallCost{}
@@ -342,8 +342,8 @@ func (sm *FSSessionManager) Shutdown() (err error) {
rater.Logger.Info("Shutting down all sessions...")
cmdKillPrepaid := "hupall MANAGER_REQUEST cgr_reqtype prepaid"
cmdKillPostpaid := "hupall MANAGER_REQUEST cgr_reqtype postpaid"
for _,cmd := range[]string{cmdKillPrepaid, cmdKillPostpaid} {
if err = fsock.FS.SendApiCmd(cmd); err!= nil {
for _, cmd := range []string{cmdKillPrepaid, cmdKillPostpaid} {
if err = fsock.FS.SendApiCmd(cmd); err != nil {
rater.Logger.Err(fmt.Sprintf("Error on calls shutdown: %s", err))
return
}

View File

@@ -43,7 +43,7 @@ func NewSession(ev Event, sm SessionManager) (s *Session) {
return
}
// Make sure cgr_type is enforced even if not set by FreeSWITCH
if err := fsock.FS.SendApiCmd(fmt.Sprintf("uuid_setvar %s cgr_reqtype %s\n\n", ev.GetUUID(), ev.GetReqType())); err!=nil {
if err := fsock.FS.SendApiCmd(fmt.Sprintf("uuid_setvar %s cgr_reqtype %s\n\n", ev.GetUUID(), ev.GetReqType())); err != nil {
rater.Logger.Err(fmt.Sprintf("Error on attempting to overwrite cgr_type in chan variables: %v", err))
}
startTime, err := ev.GetStartTime(START_TIME)

View File

@@ -19,8 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package sessionmanager
import (
"testing"
"github.com/cgrates/cgrates/config"
"testing"
// "time"
)
@@ -67,9 +67,9 @@ var (
func TestSessionNilSession(t *testing.T) {
cfgTestPath := "../config/test_data.txt"
var errCfg error
cfg,errCfg = config.NewCGRConfig(&cfgTestPath) // Needed here to avoid nil on cfg variable
if errCfg!= nil {
t.Errorf("Cannot get configuration %v",errCfg)
cfg, errCfg = config.NewCGRConfig(&cfgTestPath) // Needed here to avoid nil on cfg variable
if errCfg != nil {
t.Errorf("Cannot get configuration %v", errCfg)
}
newEvent := new(FSEvent).New("")
sm := &FSSessionManager{}