diff --git a/accounts/abstractbalance.go b/accounts/abstractbalance.go
deleted file mode 100644
index 02fcd661e..000000000
--- a/accounts/abstractbalance.go
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OerS) 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
-*/
-
-package accounts
-
-import (
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
- "github.com/ericlagergren/decimal"
-)
-
-// newAbstractBalance constructs an abstractBalanceOperator
-func newAbstractBalanceOperator(acntID string, blnCfg *utils.Balance,
- cncrtBlncs []*concreteBalance,
- fltrS *engine.FilterS, connMgr *engine.ConnManager,
- attrSConns, rateSConns []string) balanceOperator {
- return &abstractBalance{acntID, blnCfg, cncrtBlncs, fltrS, connMgr, attrSConns, rateSConns}
-}
-
-// abstractBalance is the operator for *abstract balance type
-type abstractBalance struct {
- acntID string
- blnCfg *utils.Balance
- cncrtBlncs []*concreteBalance // paying balances
- fltrS *engine.FilterS
- connMgr *engine.ConnManager
- attrSConns,
- rateSConns []string
-}
-
-// debitAbstracts implements the balanceOperator interface
-func (aB *abstractBalance) debitAbstracts(usage *decimal.Big,
- cgrEv *utils.CGREvent) (ec *utils.EventCharges, err error) {
-
- evNm := utils.MapStorage{
- utils.MetaOpts: cgrEv.APIOpts,
- utils.MetaReq: cgrEv.Event,
- }
-
- // pass the general balance filters
- var pass bool
- if pass, err = aB.fltrS.Pass(cgrEv.Tenant, aB.blnCfg.FilterIDs, evNm); err != nil {
- return
- } else if !pass {
- return nil, utils.ErrFilterNotPassingNoCaps
- }
-
- // balanceLimit
- var hasLmt bool
- var blncLmt *utils.Decimal
- if blncLmt, err = balanceLimit(aB.blnCfg.Opts); err != nil {
- return
- }
- if blncLmt != nil && blncLmt.Cmp(decimal.New(0, 0)) != 0 {
- aB.blnCfg.Units.Big = utils.SubstractBig(aB.blnCfg.Units.Big, blncLmt.Big)
- hasLmt = true
- }
- // unitFactor
- var uF *utils.UnitFactor
- if uF, err = unitFactor(aB.blnCfg.UnitFactors, aB.fltrS, cgrEv.Tenant, evNm); err != nil {
- return
- }
- var hasUF bool
- if uF != nil && uF.Factor.Cmp(decimal.New(1, 0)) != 0 {
- usage = utils.MultiplyBig(usage, uF.Factor.Big)
- hasUF = true
- }
-
- // costIncrement
- var costIcrm *utils.CostIncrement
- if costIcrm, err = costIncrement(aB.blnCfg.CostIncrements, aB.fltrS,
- cgrEv.Tenant, evNm); err != nil {
- return
- }
-
- // balance smaller than usage, correct usage if the balance has limit
- if aB.blnCfg.Units.Big.Cmp(usage) == -1 && blncLmt != nil {
- // decrease the usage to match the maximum increments
- // will use special rounding to 0 since otherwise we go negative (ie: 0.05 as increment)
- usage = roundUnitsWithIncrements(aB.blnCfg.Units.Big, costIcrm.Increment.Big)
- }
- if costIcrm.RecurrentFee.Cmp(decimal.New(0, 0)) == 0 &&
- (costIcrm.FixedFee == nil ||
- costIcrm.FixedFee.Cmp(decimal.New(0, 0)) == 0) {
- // cost 0, no need of concrete
- ec = utils.NewEventCharges()
- ec.Abstracts = &utils.Decimal{usage}
- // UnitFactors
- var ufID string
- if hasUF {
- ufID = utils.UUIDSha1Prefix()
- ec.UnitFactors[ufID] = uF
- }
- // Rating
- ratingID := utils.UUIDSha1Prefix()
- // ec.Rating[ratingID] = &utils.RateSInterval{
- // IntervalStart: utils.NewDecimal(0, 0),
- // Increments: []*utils.RateSIncrement{
- // {
- // IncrementStart: utils.NewDecimal(0, 0),
- // Rate: &utils.Rate{
- // ID: utils.MetaCostIncrement,
- // IntervalRates: []*utils.IntervalRate{
- // {
- // FixedFee: utils.NewDecimal(0, 0),
- // },
- // },
- // },
- // CompressFactor: 1,
- // Usage: &utils.Decimal{usage},
- // },
- // },
- // CompressFactor: 1,
- // }
- acntID := utils.UUIDSha1Prefix()
- ec.Accounting[acntID] = &utils.AccountCharge{
- AccountID: aB.acntID,
- BalanceID: aB.blnCfg.ID,
- Units: &utils.Decimal{usage},
- BalanceLimit: blncLmt,
- UnitFactorID: ufID,
- RatingID: ratingID,
- }
- ec.ChargingIntervals = []*utils.ChargingInterval{
- {
- Increments: []*utils.ChargingIncrement{
- {
- Units: &utils.Decimal{usage},
- AccountChargeID: acntID,
- CompressFactor: 1,
- },
- },
- CompressFactor: 1,
- },
- }
- }
- // else {
- // // attempt to debit usage with cost
- // if ec, err = maxDebitAbstractsFromConcretes(usage,
- // aB.acntID, aB.cncrtBlncs,
- // aB.connMgr, cgrEv,
- // aB.attrSConns, aB.blnCfg.AttributeIDs,
- // aB.rateSConns, aB.blnCfg.RateProfileIDs,
- // costIcrm); err != nil {
- // return
- // }
- // }
-
- if ec.Abstracts.Cmp(decimal.New(0, 0)) != 0 {
- aB.blnCfg.Units.Big = utils.SubstractBig(aB.blnCfg.Units.Big, ec.Abstracts.Big)
- }
- if hasLmt { // put back the limit
- aB.blnCfg.Units.Big = utils.SumBig(aB.blnCfg.Units.Big, blncLmt.Big)
- }
- if hasUF {
- usage = utils.DivideBig(usage, uF.Factor.Big)
- }
- return
-}
-
-// debitConcretes implements the balanceOperator interface
-func (aB *abstractBalance) debitConcretes(usage *decimal.Big,
- cgrEv *utils.CGREvent) (ec *utils.EventCharges, err error) {
- return nil, utils.ErrNotImplemented
-}
diff --git a/accounts/abstractbalance_test.go b/accounts/abstractbalance_test.go
deleted file mode 100644
index 9bc9a7ed6..000000000
--- a/accounts/abstractbalance_test.go
+++ /dev/null
@@ -1,1183 +0,0 @@
-/*
-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
-*/
-
-package accounts
-
-import (
- "reflect"
- "testing"
- "time"
-
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
- "github.com/ericlagergren/decimal"
-)
-
-func TestABDebitUsageFromConcretes1(t *testing.T) {
- aB := &abstractBalance{
- cncrtBlncs: []*concreteBalance{
- {
- blnCfg: &utils.Balance{
- ID: "CB1",
- Type: utils.MetaConcrete,
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: -200.0,
- },
- UnitFactors: []*utils.UnitFactor{
- {
- Factor: utils.NewDecimal(100, 0), // EuroCents
- },
- },
- Units: utils.NewDecimal(500, 0), // 500 EuroCents
- },
- },
- {
- blnCfg: &utils.Balance{
- ID: "CB2",
- Type: utils.MetaConcrete,
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: -1.0,
- },
- Units: utils.NewDecimal(125, 2),
- },
- },
- },
- }
-
- // consume only from first balance
- expectedEvCharg := &utils.EventCharges{
- Concretes: utils.NewDecimal(5, 0),
- Accounting: make(map[string]*utils.AccountCharge),
- UnitFactors: make(map[string]*utils.UnitFactor),
- // Rating: make(map[string]*utils.RateSInterval),
- }
- if evCh, err := debitConcreteUnits(decimal.New(5, 0),
- utils.EmptyString, aB.cncrtBlncs, new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(0, 0)) != 0 {
- t.Errorf("Unexpected units in first balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
- } else if aB.cncrtBlncs[1].blnCfg.Units.Compare(utils.NewDecimal(125, 2)) != 0 {
- t.Errorf("Unexpected units in second balance: %s", aB.cncrtBlncs[1].blnCfg.Units)
- } else if !reflect.DeepEqual(evCh, expectedEvCharg) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expectedEvCharg), utils.ToJSON(evCh))
- }
-
- //back with the main units
- aB.cncrtBlncs[0].blnCfg.Units = utils.NewDecimal(500, 0)
- expectedEvCharg = &utils.EventCharges{
- Concretes: utils.NewDecimal(9, 0),
- Accounting: make(map[string]*utils.AccountCharge),
- UnitFactors: make(map[string]*utils.UnitFactor),
- // Rating: make(map[string]*utils.RateSInterval),
- }
-
- if evCh, err := debitConcreteUnits(decimal.New(9, 0),
- utils.EmptyString, aB.cncrtBlncs, new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(-200, 0)) != 0 {
- t.Errorf("Unexpected units in first balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
- } else if aB.cncrtBlncs[1].blnCfg.Units.Compare(utils.NewDecimal(-75, 2)) != 0 {
- t.Errorf("Unexpected units in second balance: %s", aB.cncrtBlncs[1].blnCfg.Units)
- } else if !reflect.DeepEqual(evCh, expectedEvCharg) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expectedEvCharg), utils.ToJSON(evCh))
- }
-
- //back with the main units
- aB.cncrtBlncs[0].blnCfg.Units = utils.NewDecimal(500, 0)
- aB.cncrtBlncs[1].blnCfg.Units = utils.NewDecimal(125, 2)
-
- if _, err := debitConcreteUnits(decimal.New(int64(time.Duration(10*time.Minute)), 0),
- utils.EmptyString, aB.cncrtBlncs, new(utils.CGREvent)); err == nil || err != utils.ErrInsufficientCredit {
- t.Error(err)
- } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(500, 0)) != 0 {
- t.Errorf("Unexpected units in first balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
- } else if aB.cncrtBlncs[1].blnCfg.Units.Compare(utils.NewDecimal(125, 2)) != 0 {
- t.Errorf("Unexpected units in second balance: %s", aB.cncrtBlncs[1].blnCfg.Units)
- }
-
- expectedEvCharg = &utils.EventCharges{
- Concretes: utils.NewDecimal(925, 2),
- Accounting: make(map[string]*utils.AccountCharge),
- UnitFactors: make(map[string]*utils.UnitFactor),
- // Rating: make(map[string]*utils.RateSInterval),
- }
- if evCh, err := debitConcreteUnits(decimal.New(925, 2),
- utils.EmptyString, aB.cncrtBlncs, new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(-200, 0)) != 0 {
- t.Errorf("Unexpected units in first balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
- } else if aB.cncrtBlncs[1].blnCfg.Units.Compare(utils.NewDecimal(-1, 0)) != 0 {
- t.Errorf("Unexpected units in second balance: %s", aB.cncrtBlncs[1].blnCfg.Units)
- } else if !reflect.DeepEqual(evCh, expectedEvCharg) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expectedEvCharg), utils.ToJSON(evCh))
- }
-
-}
-
-// func TestABDebitAbstracts(t *testing.T) {
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "AB1",
-// Type: utils.MetaAbstract,
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
-// RecurrentFee: utils.NewDecimal(1, 0)},
-// },
-// Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
-// },
-// cncrtBlncs: []*concreteBalance{
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB1",
-// Type: utils.MetaConcrete,
-// UnitFactors: []*utils.UnitFactor{
-// {
-// Factor: utils.NewDecimal(1, 0), // EuroCents
-// },
-// },
-// Units: utils.NewDecimal(50, 0), // 50 EURcents
-// },
-// },
-// },
-// fltrS: new(engine.FilterS),
-// }
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(30*time.Second), 0),
-// new(utils.CGREvent)); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(int64(30*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(30*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(20, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// }
-
-// // limited by concrete
-// aB.blnCfg.Units = utils.NewDecimal(int64(time.Duration(60*time.Second)), 0)
-// aB.cncrtBlncs[0].blnCfg.Units = utils.NewDecimal(29, 0) // not enough concrete
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(30*time.Second), 0),
-// new(utils.CGREvent)); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(int64(29*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(time.Duration(31*time.Second)), 0)) != 0 { // used 29 units
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(0, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// }
-
-// // limited by concrete
-// aB.cncrtBlncs[0].blnCfg.Units = utils.NewDecimal(0, 0) // not enough concrete
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(30*time.Second), 0),
-// new(utils.CGREvent)); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(0, 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(31*time.Second), 0)) != 0 { // same as above
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(0, 0)) != 0 { // same as above
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// }
-
-// // limited by abstract
-// aB.blnCfg.Units = utils.NewDecimal(int64(time.Duration(29*time.Second)), 0) // not enough abstract
-// aB.cncrtBlncs[0].blnCfg.Units = utils.NewDecimal(60, 0)
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(30*time.Second), 0),
-// new(utils.CGREvent)); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(int64(29*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(0, 0)) != 0 { // should be all used
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(31, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// }
-// }
-
-func TestABCost0WithConcrete(t *testing.T) {
- // consume units only from abstract balance
- aB := &abstractBalance{
- blnCfg: &utils.Balance{
- ID: "AB_COST_0",
- Type: utils.MetaAbstract,
- Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
- CostIncrements: []*utils.CostIncrement{
- {
- Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
- RecurrentFee: utils.NewDecimal(0, 0),
- },
- },
- },
- cncrtBlncs: []*concreteBalance{
- {
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(10, 0),
- },
- },
- },
- fltrS: new(engine.FilterS),
- }
-
- if ec, err := aB.debitAbstracts(decimal.New(int64(30*time.Second), 0),
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if ec.Abstracts.Cmp(decimal.New(int64(30*time.Second), 0)) != 0 {
- t.Errorf("Unexpected debited units: %s", ec.Abstracts)
- } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(30*time.Second), 0)) != 0 {
- t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
- } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(10, 0)) != 0 {
- t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
- }
-}
-
-func TestABCost0WithoutConcrete(t *testing.T) {
- // consume units only from abstract balance
- aB := &abstractBalance{
- blnCfg: &utils.Balance{
- ID: "AB_COST_0",
- Type: utils.MetaAbstract,
- Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
- CostIncrements: []*utils.CostIncrement{
- {
- Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
- RecurrentFee: utils.NewDecimal(0, 0),
- },
- },
- },
- fltrS: new(engine.FilterS),
- }
-
- if ec, err := aB.debitAbstracts(decimal.New(int64(30*time.Second), 0),
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if ec.Abstracts.Cmp(decimal.New(int64(30*time.Second), 0)) != 0 {
- t.Errorf("Unexpected debited units: %s", ec.Abstracts)
- } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(30*time.Second), 0)) != 0 {
- t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
- }
-}
-
-func TestABCost0Exceed(t *testing.T) {
- // consume more units that has an abstract balance
- aB := &abstractBalance{
- blnCfg: &utils.Balance{
- ID: "AB_COST_0",
- Type: utils.MetaAbstract,
- Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
- CostIncrements: []*utils.CostIncrement{
- {
- Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
- RecurrentFee: utils.NewDecimal(0, 0),
- },
- },
- },
- cncrtBlncs: []*concreteBalance{
- {
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(10, 0),
- },
- },
- },
- fltrS: new(engine.FilterS),
- }
-
- if ec, err := aB.debitAbstracts(decimal.New(int64(70*time.Second), 0),
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if ec.Abstracts.Cmp(decimal.New(int64(60*time.Second), 0)) != 0 {
- t.Errorf("Unexpected debited units: %s", ec.Abstracts)
- } else if aB.blnCfg.Units.Compare(utils.NewDecimal(0, 0)) != 0 {
- t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
- } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(10, 0)) != 0 {
- t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
- }
-}
-
-func TestABCost0ExceedWithoutConcrete(t *testing.T) {
- // consume more units that has an abstract balance
- aB := &abstractBalance{
- blnCfg: &utils.Balance{
- ID: "AB_COST_0",
- Type: utils.MetaAbstract,
- Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
- CostIncrements: []*utils.CostIncrement{
- {
- Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
- RecurrentFee: utils.NewDecimal(0, 0),
- },
- },
- },
- fltrS: new(engine.FilterS),
- }
-
- if ec, err := aB.debitAbstracts(decimal.New(int64(70*time.Second), 0),
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if ec.Abstracts.Cmp(decimal.New(int64(60*time.Second), 0)) != 0 {
- t.Errorf("Unexpected debited units: %s", ec.Abstracts)
- } else if aB.blnCfg.Units.Compare(utils.NewDecimal(0, 0)) != 0 {
- t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
- }
-}
-
-func TestABCost0WithUnlimitedWithConcrete(t *testing.T) {
- // consume more units that has an abstract balance
- aB := &abstractBalance{
- blnCfg: &utils.Balance{
- ID: "AB_COST_0",
- Type: utils.MetaAbstract,
- Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
- Opts: map[string]interface{}{
- utils.MetaBalanceUnlimited: true,
- },
- CostIncrements: []*utils.CostIncrement{
- {
- Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
- RecurrentFee: utils.NewDecimal(0, 0),
- },
- },
- },
- cncrtBlncs: []*concreteBalance{
- {
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(10, 0),
- },
- },
- },
- fltrS: new(engine.FilterS),
- }
-
- if ec, err := aB.debitAbstracts(decimal.New(int64(80*time.Second), 0),
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if ec.Abstracts.Cmp(decimal.New(int64(80*time.Second), 0)) != 0 {
- t.Errorf("Unexpected debited units: %s", ec.Abstracts)
- } else if aB.blnCfg.Units.Compare(utils.NewDecimal(-int64(time.Duration(20*time.Second)), 0)) != 0 {
- t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
- } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(10, 0)) != 0 {
- t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
- }
-}
-
-func TestABCost0WithLimit(t *testing.T) {
- // consume more units that has an abstract balance
- aB := &abstractBalance{
- blnCfg: &utils.Balance{
- ID: "AB_COST_0",
- Type: utils.MetaAbstract,
- Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: 30000000000.0,
- },
- UnitFactors: []*utils.UnitFactor{
- {
- Factor: utils.NewDecimal(int64(2*time.Second), 0),
- },
- },
- CostIncrements: []*utils.CostIncrement{
- {
- Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
- RecurrentFee: utils.NewDecimal(0, 0),
- },
- },
- },
- fltrS: new(engine.FilterS),
- }
-
- if ec, err := aB.debitAbstracts(decimal.New(int64(30*time.Second), 0),
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(time.Duration(30*time.Second)), 0)) != 0 {
- t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
- } else if ec.Abstracts.Cmp(decimal.New(int64(30*time.Second), 0)) != 0 {
- t.Errorf("Expected %+v, received %+v", decimal.New(int64(30*time.Second), 0), ec.Abstracts)
- }
-}
-
-func TestABCost0WithLimitWithConcrete(t *testing.T) {
- // consume more units that has an abstract balance
- aB := &abstractBalance{
- blnCfg: &utils.Balance{
- ID: "AB_COST_0",
- Type: utils.MetaAbstract,
- Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: 30000000000.0,
- },
- CostIncrements: []*utils.CostIncrement{
- {
- Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
- RecurrentFee: utils.NewDecimal(0, 0),
- },
- },
- },
- cncrtBlncs: []*concreteBalance{
- {
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(10, 0),
- },
- },
- },
- fltrS: new(engine.FilterS),
- }
-
- if ec, err := aB.debitAbstracts(decimal.New(int64(30*time.Second), 0),
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if ec.Abstracts.Cmp(decimal.New(int64(30*time.Second), 0)) != 0 {
- t.Errorf("Unexpected debited units: %s", ec.Abstracts)
- } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(time.Duration(30*time.Second)), 0)) != 0 {
- t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
- } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(10, 0)) != 0 {
- t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
- }
-}
-
-func TestABCost0WithLimitExceed(t *testing.T) {
- // consume more units that has an abstract balance
- aB := &abstractBalance{
- blnCfg: &utils.Balance{
- ID: "AB_COST_0",
- Type: utils.MetaAbstract,
- Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: 30000000000.0,
- },
- CostIncrements: []*utils.CostIncrement{
- {
- Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
- RecurrentFee: utils.NewDecimal(0, 0),
- },
- },
- },
- fltrS: new(engine.FilterS),
- }
-
- if ec, err := aB.debitAbstracts(decimal.New(int64(50*time.Second), 0),
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if ec.Abstracts.Cmp(decimal.New(int64(30*time.Second), 0)) != 0 {
- t.Errorf("Unexpected debited units: %s", ec.Abstracts)
- } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(time.Duration(30*time.Second)), 0)) != 0 {
- t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
- }
-}
-
-func TestABCost0WithLimitExceedWithConcrete(t *testing.T) {
- // consume more units that has an abstract balance
- aB := &abstractBalance{
- blnCfg: &utils.Balance{
- ID: "AB_COST_0",
- Type: utils.MetaAbstract,
- Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: 30000000000.0,
- },
- CostIncrements: []*utils.CostIncrement{
- {
- Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
- RecurrentFee: utils.NewDecimal(0, 0),
- },
- },
- },
- cncrtBlncs: []*concreteBalance{
- {
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(10, 0),
- },
- },
- },
- fltrS: new(engine.FilterS),
- }
-
- if ec, err := aB.debitAbstracts(decimal.New(int64(50*time.Second), 0),
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if ec.Abstracts.Cmp(decimal.New(int64(30*time.Second), 0)) != 0 {
- t.Errorf("Unexpected debited units: %s", ec.Abstracts)
- } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(time.Duration(30*time.Second)), 0)) != 0 {
- t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
- } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(10, 0)) != 0 {
- t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
- }
-}
-
-func TestDebitUsageFiltersError(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- filters := engine.NewFilterS(cfg, nil, nil)
- aB := &abstractBalance{
- blnCfg: &utils.Balance{
- ID: "ID_TEST",
- Type: utils.MetaAbstract,
- FilterIDs: []string{"*string:*~req.Usage:10s"},
- CostIncrements: []*utils.CostIncrement{
- {
- Increment: utils.NewDecimal(int64(1*time.Second), 0),
- RecurrentFee: utils.NewDecimal(2, 0),
- },
- },
- Units: utils.NewDecimal(int64(50*time.Second), 0),
- },
- fltrS: filters,
- }
-
- cgrEv := &utils.CGREvent{
- Tenant: "cgrates.org",
- Event: map[string]interface{}{
- utils.Usage: "10s",
- },
- }
- _, err := aB.debitAbstracts(decimal.New(int64(40*time.Second), 0),
- cgrEv)
- if err == nil || err != utils.ErrFilterNotPassingNoCaps {
- t.Errorf("Expected %+v, received %+v", utils.ErrFilterNotPassingNoCaps, err)
- }
-
- aB.blnCfg.FilterIDs = []string{"invalid_filter_format"}
- _, err = aB.debitAbstracts(decimal.New(int64(40*time.Second), 0),
- cgrEv)
- if err == nil || err != utils.ErrNoDatabaseConn {
- t.Errorf("Expected %+v, received %+v", utils.ErrNoDatabaseConn, err)
- }
-}
-
-// func TestDebitUsageBalanceLimitErrors(t *testing.T) {
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "ID_TEST",
-// Type: utils.MetaAbstract,
-// Opts: map[string]interface{}{
-// utils.MetaBalanceLimit: "not_FLOAT64",
-// },
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(int64(1*time.Second), 0),
-// RecurrentFee: utils.NewDecimal(2, 0),
-// },
-// },
-// Units: utils.NewDecimal(int64(60*time.Second), 0),
-// },
-// fltrS: new(engine.FilterS),
-// }
-
-// cgrEv := &utils.CGREvent{
-// Tenant: "cgrates.org",
-// Event: map[string]interface{}{
-// utils.Usage: "10s",
-// },
-// }
-
-// expectedErr := "unsupported *balanceLimit format"
-// _, err := aB.debitAbstracts(decimal.New(int64(40*time.Second), 0),
-// cgrEv)
-// if err == nil || err.Error() != expectedErr {
-// t.Errorf("Expected %+v, received %+v", expectedErr, err)
-// }
-
-// aB.blnCfg.Opts[utils.MetaBalanceLimit] = float64(16 * time.Second)
-// if _, err = aB.debitAbstracts(decimal.New(int64(40*time.Second), 0),
-// cgrEv); err != nil {
-// t.Error(err)
-// }
-// if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(60*time.Second), 0)) != 0 {
-// t.Errorf("Expected %+v, received %+v", aB.blnCfg.Units.Big, utils.NewDecimal(int64(50*time.Second), 0))
-// }
-// }
-
-// func TestDebitUsageUnitFactorsErrors(t *testing.T) {
-// cfg := config.NewDefaultCGRConfig()
-// filters := engine.NewFilterS(cfg, nil, nil)
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "ID_TEST",
-// Type: utils.MetaAbstract,
-// UnitFactors: []*utils.UnitFactor{
-// {
-// FilterIDs: []string{"invalid_filter_fromat"},
-// Factor: utils.NewDecimal(2, 0),
-// },
-// },
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(int64(1*time.Second), 0),
-// RecurrentFee: utils.NewDecimal(2, 0),
-// },
-// },
-// Units: utils.NewDecimal(int64(60*time.Second), 0),
-// },
-// fltrS: filters,
-// }
-
-// cgrEv := &utils.CGREvent{
-// Tenant: "cgrates.org",
-// Event: map[string]interface{}{
-// utils.Usage: "10s",
-// },
-// }
-
-// if _, err := aB.debitAbstracts(decimal.New(int64(20*time.Second), 0), cgrEv); err == nil ||
-// err != utils.ErrNoDatabaseConn {
-// t.Errorf("Expected %+v, received %+v", utils.ErrNoDatabaseConn, err)
-// }
-
-// aB.blnCfg.UnitFactors[0].FilterIDs = []string{"*string:*~req.Usage:10s"}
-// if ec, err := aB.debitAbstracts(decimal.New(int64(20*time.Second), 0), cgrEv); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(0, 0)) != 0 {
-// t.Error(err)
-// }
-// }
-
-// func TestDebitUsageCostIncrementError(t *testing.T) {
-// cfg := config.NewDefaultCGRConfig()
-// filters := engine.NewFilterS(cfg, nil, nil)
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "ID_TEST",
-// Type: utils.MetaAbstract,
-// CostIncrements: []*utils.CostIncrement{
-// {
-// FilterIDs: []string{"INVALID_FILTER_FORMAT"},
-// Increment: utils.NewDecimal(int64(1*time.Second), 0),
-// RecurrentFee: utils.NewDecimal(2, 0),
-// },
-// },
-// Units: utils.NewDecimal(int64(60*time.Second), 0),
-// },
-// fltrS: filters,
-// }
-// cgrEv := &utils.CGREvent{
-// Tenant: "cgrates.org",
-// Event: map[string]interface{}{
-// utils.Usage: "10s",
-// },
-// }
-
-// if _, err := aB.debitAbstracts(decimal.New(int64(20*time.Second), 0), cgrEv); err == nil ||
-// err != utils.ErrNoDatabaseConn {
-// t.Errorf("Expected %+v, received %+v", utils.ErrNoDatabaseConn, err)
-// }
-
-// //Will check the error by making the event charge
-// //the cost is unknown, will use attributes to query from rates
-// aB.blnCfg.CostIncrements = nil
-// aB.blnCfg.AttributeIDs = []string{"attr11"}
-// expected := "NOT_CONNECTED: AttributeS"
-// if _, err := aB.debitAbstracts(decimal.New(int64(20*time.Second), 0), cgrEv); err == nil ||
-// err.Error() != expected {
-// t.Errorf("Expected %+v, received %+v", expected, err)
-// }
-// }
-
-// func TestABCost(t *testing.T) {
-// // debit 10 seconds with cost of 0.1 per second
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "AB_COST_0",
-// Type: utils.MetaAbstract,
-// Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
-// RecurrentFee: utils.NewDecimal(1, 1),
-// },
-// },
-// },
-// cncrtBlncs: []*concreteBalance{
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(10, 0),
-// },
-// },
-// },
-// fltrS: new(engine.FilterS),
-// }
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(10*time.Second), 0),
-// new(utils.CGREvent)); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(int64(10*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(time.Duration(50*time.Second)), 0)) != 0 {
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(9, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// }
-// }
-
-// func TestABCostWithFiltersNotMatch(t *testing.T) {
-// cfg := config.NewDefaultCGRConfig()
-// data := engine.NewInternalDB(nil, nil, true)
-// dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
-// filterS := engine.NewFilterS(cfg, nil, dm)
-// // we expect to receive an error because it will try calculate the cost from rates
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "AB_COST_0",
-// Type: utils.MetaAbstract,
-// Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
-// CostIncrements: []*utils.CostIncrement{
-// {
-// FilterIDs: []string{"*string:~*req.CustomField:CustomValue"},
-// Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
-// RecurrentFee: utils.NewDecimal(1, 1),
-// },
-// },
-// },
-// cncrtBlncs: []*concreteBalance{
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(10, 0),
-// },
-// },
-// },
-// fltrS: filterS,
-// }
-// cgrEv := &utils.CGREvent{
-// Tenant: "cgrates.org",
-// ID: "EV",
-// Event: map[string]interface{}{
-// "CustomField2": "CustomValue2",
-// },
-// }
-// if _, err := aB.debitAbstracts(decimal.New(int64(10*time.Second), 0),
-// cgrEv); err == nil || err.Error() != "RATES_ERROR:NOT_CONNECTED: RateS" {
-// t.Error(err)
-// }
-// }
-
-// func TestABCostWithFilters(t *testing.T) {
-// // debit 10 seconds with cost of 0.1 per second
-// cfg := config.NewDefaultCGRConfig()
-// data := engine.NewInternalDB(nil, nil, true)
-// dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
-// filterS := engine.NewFilterS(cfg, nil, dm)
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "AB_COST_0",
-// Type: utils.MetaAbstract,
-// Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
-// CostIncrements: []*utils.CostIncrement{
-// {
-// FilterIDs: []string{"*string:~*req.CustomField:CustomValue"},
-// Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
-// RecurrentFee: utils.NewDecimal(1, 1),
-// },
-// },
-// },
-// cncrtBlncs: []*concreteBalance{
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(10, 0),
-// },
-// },
-// },
-// fltrS: filterS,
-// }
-// cgrEv := &utils.CGREvent{
-// Tenant: "cgrates.org",
-// ID: "EV",
-// Event: map[string]interface{}{
-// "CustomField": "CustomValue",
-// },
-// }
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(10*time.Second), 0),
-// cgrEv); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(int64(10*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(time.Duration(50*time.Second)), 0)) != 0 {
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(9, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// }
-// }
-
-// func TestABCostExceed(t *testing.T) {
-// // debit 70 seconds with cost of 0.1 per second
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "AB_COST_0",
-// Type: utils.MetaAbstract,
-// Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
-// RecurrentFee: utils.NewDecimal(1, 1),
-// },
-// },
-// },
-// cncrtBlncs: []*concreteBalance{
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(10, 0),
-// },
-// },
-// },
-// fltrS: new(engine.FilterS),
-// }
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(70*time.Second), 0),
-// new(utils.CGREvent)); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(int64(60*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(0, 0)) != 0 {
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(4, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// }
-// }
-
-// func TestABCostUnlimitedExceed(t *testing.T) {
-// // debit 70 seconds with cost of 0.1 per second
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "AB_COST_0",
-// Type: utils.MetaAbstract,
-// Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
-// Opts: map[string]interface{}{
-// utils.MetaBalanceUnlimited: true,
-// },
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
-// RecurrentFee: utils.NewDecimal(1, 1),
-// },
-// },
-// },
-// cncrtBlncs: []*concreteBalance{
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(10, 0),
-// },
-// },
-// },
-// fltrS: new(engine.FilterS),
-// }
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(70*time.Second), 0),
-// new(utils.CGREvent)); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(int64(70*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(-int64(time.Duration(10*time.Second)), 0)) != 0 {
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(3, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// }
-// }
-
-// func TestABCostLimit(t *testing.T) {
-// // debit 70 seconds with cost of 0.1 per second
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "AB_COST_0",
-// Type: utils.MetaAbstract,
-// Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
-// Opts: map[string]interface{}{
-// utils.MetaBalanceLimit: 30000000000.0,
-// },
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
-// RecurrentFee: utils.NewDecimal(1, 1),
-// },
-// },
-// },
-// cncrtBlncs: []*concreteBalance{
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(10, 0),
-// },
-// },
-// },
-// fltrS: new(engine.FilterS),
-// }
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(30*time.Second), 0),
-// new(utils.CGREvent)); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(int64(30*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(time.Duration(30*time.Second)), 0)) != 0 {
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(7, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// }
-// }
-
-// func TestABCostLimitExceed(t *testing.T) {
-// // debit 70 seconds with cost of 0.1 per second
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "AB_COST_0",
-// Type: utils.MetaAbstract,
-// Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
-// Opts: map[string]interface{}{
-// utils.MetaBalanceLimit: 30000000000.0,
-// },
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
-// RecurrentFee: utils.NewDecimal(1, 1),
-// },
-// },
-// },
-// cncrtBlncs: []*concreteBalance{
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(10, 0),
-// },
-// },
-// },
-// fltrS: new(engine.FilterS),
-// }
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(70*time.Second), 0),
-// new(utils.CGREvent)); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(int64(30*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(time.Duration(30*time.Second)), 0)) != 0 {
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(7, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// }
-// }
-
-// func TestABCostNotEnoughConcrete(t *testing.T) {
-// // debit 55 seconds with cost of 0.1 per second
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "AB_COST_0",
-// Type: utils.MetaAbstract,
-// Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
-// RecurrentFee: utils.NewDecimal(1, 1),
-// },
-// },
-// },
-// cncrtBlncs: []*concreteBalance{
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(5, 0),
-// },
-// },
-// },
-// fltrS: new(engine.FilterS),
-// }
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(55*time.Second), 0),
-// new(utils.CGREvent)); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(int64(50*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(time.Duration(10*time.Second)), 0)) != 0 {
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(0, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// }
-// }
-
-// func TestABCostMultipleConcrete(t *testing.T) {
-// // debit 55 seconds with cost of 0.1 per second
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "AB_COST_0",
-// Type: utils.MetaAbstract,
-// Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
-// RecurrentFee: utils.NewDecimal(1, 1),
-// },
-// },
-// },
-// cncrtBlncs: []*concreteBalance{
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB1",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(5, 0),
-// },
-// },
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB2",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(5, 0),
-// },
-// },
-// },
-// fltrS: new(engine.FilterS),
-// }
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(55*time.Second), 0),
-// new(utils.CGREvent)); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(int64(55*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(time.Duration(5*time.Second)), 0)) != 0 {
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(0, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// } else if aB.cncrtBlncs[1].blnCfg.Units.Compare(utils.NewDecimal(45, 1)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[1].blnCfg.Units)
-// }
-// }
-
-// func TestABCostMultipleConcreteUnlimited(t *testing.T) {
-// // debit 55 seconds with cost of 0.1 per second
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "AB_COST_0",
-// Type: utils.MetaAbstract,
-// Units: utils.NewDecimal(int64(time.Duration(60*time.Second)), 0), // 1 Minute
-// Opts: map[string]interface{}{
-// utils.MetaBalanceUnlimited: true,
-// },
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(int64(time.Duration(time.Second)), 0),
-// RecurrentFee: utils.NewDecimal(1, 1),
-// },
-// },
-// },
-// cncrtBlncs: []*concreteBalance{
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB1",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(5, 0),
-// },
-// },
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB2",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(5, 0),
-// },
-// },
-// },
-// fltrS: new(engine.FilterS),
-// }
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(70*time.Second), 0),
-// new(utils.CGREvent)); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(int64(70*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(-int64(time.Duration(10*time.Second)), 0)) != 0 {
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(0, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// } else if aB.cncrtBlncs[1].blnCfg.Units.Compare(utils.NewDecimal(3, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[1].blnCfg.Units)
-// }
-// }
-
-// func TestAMCostWithUnitFactor(t *testing.T) {
-// cfg := config.NewDefaultCGRConfig()
-// data := engine.NewInternalDB(nil, nil, true)
-// dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
-// filterS := engine.NewFilterS(cfg, nil, dm)
-
-// aB := &abstractBalance{
-// blnCfg: &utils.Balance{
-// ID: "ID_TEST",
-// Type: utils.MetaAbstract,
-// Units: utils.NewDecimal(int64(60*time.Second), 0),
-// UnitFactors: []*utils.UnitFactor{
-// {
-// Factor: utils.NewDecimal(2, 0),
-// },
-// },
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(int64(1*time.Second), 0),
-// RecurrentFee: utils.NewDecimal(1, 0),
-// },
-// },
-// },
-// cncrtBlncs: []*concreteBalance{
-// {
-// blnCfg: &utils.Balance{
-// ID: "CB1",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(50, 0),
-// },
-// },
-// },
-// fltrS: filterS,
-// }
-
-// cgrEv := &utils.CGREvent{
-// Tenant: "cgrates.org",
-// ID: "EV",
-// Event: map[string]interface{}{
-// "CustomField": "CustomValue",
-// },
-// }
-
-// if ec, err := aB.debitAbstracts(decimal.New(int64(10*time.Second), 0),
-// cgrEv); err != nil {
-// t.Error(err)
-// } else if ec.Abstracts.Cmp(decimal.New(int64(20*time.Second), 0)) != 0 {
-// t.Errorf("Unexpected debited units: %s", ec.Abstracts)
-// } else if aB.blnCfg.Units.Compare(utils.NewDecimal(int64(time.Duration(40*time.Second)), 0)) != 0 {
-// t.Errorf("Unexpected units in abstract balance: %s", aB.blnCfg.Units)
-// } else if aB.cncrtBlncs[0].blnCfg.Units.Compare(utils.NewDecimal(30, 0)) != 0 {
-// t.Errorf("Unexpected units in concrete balance: %s", aB.cncrtBlncs[0].blnCfg.Units)
-// }
-// }
diff --git a/accounts/actsetbalance.go b/accounts/actsetbalance.go
deleted file mode 100644
index ee53a3541..000000000
--- a/accounts/actsetbalance.go
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OerS) 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
-*/
-
-package accounts
-
-import (
- "fmt"
- "strconv"
- "strings"
-
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-// actSetAccount updates the balances base on the diktat
-func actSetAccount(dm *engine.DataManager, tnt, acntID string, diktats []*utils.BalDiktat, reset bool) (err error) {
- var qAcnt *utils.AccountProfile
- if qAcnt, err = dm.GetAccountProfile(tnt, acntID); err != nil {
- if err != utils.ErrNotFound {
- return
- }
- // in case the account doesn't exist create it with minimal information
- qAcnt = &utils.AccountProfile{
- Tenant: tnt,
- ID: acntID,
- }
- }
- for _, dk := range diktats {
- // check if we have a valid path(e.g. *balance.Test.ID)
- path := strings.Split(dk.Path, utils.NestingSep)
- // check the path to be a valid one
-
- switch path[0] {
- case utils.MetaBalance:
- if len(path) < 3 {
- return utils.ErrWrongPath
- }
- bal, has := qAcnt.Balances[path[1]]
- if !has {
- // no balance for that ID create one
- bal = utils.NewDefaultBalance(path[1])
- if qAcnt.Balances == nil {
- // in case the account has no balance create the balance map
- qAcnt.Balances = make(map[string]*utils.Balance)
- }
- qAcnt.Balances[path[1]] = bal
- }
- if err = actSetBalance(bal, path[2:], dk.Value, reset); err != nil {
- return
- }
- case utils.MetaAccount:
- // special case in order to handle account field set in *set_balance/*add_balance action
- if len(path) < 2 {
- return utils.ErrWrongPath
- }
- if err = actSetAccountFields(qAcnt, path[1:], dk.Value); err != nil {
- return
- }
- default:
- return utils.ErrWrongPath
- }
- }
- return dm.SetAccountProfile(qAcnt, false)
-}
-
-// actSetAccountFields sets the fields inside the account
-func actSetAccountFields(ac *utils.AccountProfile, path []string, value string) (err error) {
- switch path[0] {
- // the tenant and ID should come from user and should not change
- case utils.FilterIDs:
- ac.FilterIDs = utils.NewStringSet(strings.Split(value, utils.InfieldSep)).AsSlice()
- case utils.ActivationIntervalString:
- // similar how the TP are loaded split the value based on ;
- // the first element is ActivationTime and the second if any ExpiryTime
- ac.ActivationInterval = &utils.ActivationInterval{}
- valSpl := strings.SplitN(value, utils.InfieldSep, 2)
- if ac.ActivationInterval.ActivationTime, err = utils.ParseTimeDetectLayout(valSpl[0], utils.EmptyString); err != nil {
- return
- }
- if len(valSpl) == 2 {
- ac.ActivationInterval.ExpiryTime, err = utils.ParseTimeDetectLayout(valSpl[1], utils.EmptyString)
- }
- case utils.Weights:
- ac.Weights, err = utils.NewDynamicWeightsFromString(value, utils.InfieldSep, utils.ANDSep)
- case utils.Opts:
- if ac.Opts == nil { // if the options are not initialized already init them here
- ac.Opts = make(map[string]interface{})
- }
- err = utils.MapStorage(ac.Opts).Set(path[1:], value)
- case utils.ThresholdIDs:
- ac.ThresholdIDs = utils.NewStringSet(strings.Split(value, utils.InfieldSep)).AsSlice()
- default:
- err = utils.ErrWrongPath
- }
- return
-}
-
-// actSetBalance will set the field at path from balance with value
-// value is string as the value received from action is string
-// the balance must not be nil
-func actSetBalance(bal *utils.Balance, path []string, value string, reset bool) (err error) {
- // check if we have path past *balance
- if len(path) == 0 {
- return utils.ErrWrongPath
- }
- // select what field is update based on the first value from path
- // special case for CostIncrements and UnitFactors
- // that are converted from string similar to how are loaded from CSVs
- switch path[0] {
- case utils.ID:
- bal.ID = value
- case utils.FilterIDs:
- if value != utils.EmptyString {
- bal.FilterIDs = utils.NewStringSet(strings.Split(value, utils.InfieldSep)).AsSlice()
- }
- case utils.Weights:
- if value != utils.EmptyString {
- bal.Weights, err = utils.NewDynamicWeightsFromString(value, utils.InfieldSep, utils.ANDSep)
- }
- case utils.Type:
- bal.Type = value
- case utils.Units:
- var z *utils.Decimal
- if z, err = utils.NewDecimalFromString(value); err != nil {
- return
- }
- // do not overwrite the Units if the action is *add_balance
- // this flag makes the difference between the *add_balance and *set_balance actions
- if !reset && bal.Units != nil {
- bal.Units.Add(bal.Units.Big, z.Big)
- } else {
- bal.Units = z
- }
- case utils.UnitFactors:
- // just recreate them from string
- if value != utils.EmptyString {
- bal.UnitFactors, err = actNewUnitFactorsFromString(value)
- }
- case utils.Opts:
- if bal.Opts == nil { // if the options are not initilized already init them here
- bal.Opts = make(map[string]interface{})
- }
- err = utils.MapStorage(bal.Opts).Set(path[1:], value)
- case utils.CostIncrements:
- // just recreate them from string
- if value != utils.EmptyString {
- bal.CostIncrements, err = actNewCostIncrementsFromString(value)
- }
- case utils.AttributeIDs:
- if value != utils.EmptyString {
- bal.AttributeIDs = strings.Split(value, utils.InfieldSep)
- }
- // case utils.RateProfileIDs:
- // if value != utils.EmptyString {
- // bal.RateProfileIDs = utils.NewStringSet(strings.Split(value, utils.InfieldSep)).AsSlice()
- // }
- default:
- // we modify the UnitFactors explicit
- // e.g. *balance.TEST.UnitFactors[0].Factor
- if strings.HasPrefix(path[0], utils.UnitFactors) {
- bal.UnitFactors, err = actSetUnitFactor(bal.UnitFactors, path, value)
- return
- }
-
- // we modify the CostIncrements explicit
- // e.g. *balance.TEST.CostIncrements[0].Increment
- if strings.HasPrefix(path[0], utils.CostIncrements) {
- bal.CostIncrements, err = actSetCostIncrement(bal.CostIncrements, path, value)
- return
- }
- // not a valid path
- err = utils.ErrWrongPath
- }
- return
-}
-
-// actNewUnitFactorsFromString converts a string to a list of UnitFactors
-// similar to the how the TP are loaded from CSV
-func actNewUnitFactorsFromString(value string) (units []*utils.UnitFactor, err error) {
- sls := strings.Split(value, utils.InfieldSep)
- if len(sls)%2 != 0 {
- return nil, fmt.Errorf("invalid key: <%s> for BalanceUnitFactors", value)
- }
- units = make([]*utils.UnitFactor, 0, len(sls)/2)
-
- for j := 0; j < len(sls); j += 2 {
- var z *utils.Decimal
- if z, err = utils.NewDecimalFromString(sls[j+1]); err != nil {
- return
- }
- var fltrs []string
- if sls[j] != utils.EmptyString {
- fltrs = strings.Split(sls[j], utils.ANDSep)
- }
- units = append(units, &utils.UnitFactor{
- FilterIDs: fltrs,
- Factor: z,
- })
- }
- return
-}
-
-// actNewCostIncrementsFromString converts a string to a list of CostIncrements
-// similar to the how the TP are loaded from CSV
-func actNewCostIncrementsFromString(value string) (costs []*utils.CostIncrement, err error) {
- sls := strings.Split(value, utils.InfieldSep)
- if len(sls)%4 != 0 {
- return nil, fmt.Errorf("invalid key: <%s> for BalanceCostIncrements", value)
- }
- costs = make([]*utils.CostIncrement, 0, len(sls)/4)
- for j := 0; j < len(sls); j += 4 {
- cost := &utils.CostIncrement{}
- if sls[j] != utils.EmptyString {
- cost.FilterIDs = strings.Split(sls[j], utils.ANDSep)
- }
- if incrementStr := sls[j+1]; incrementStr != utils.EmptyString {
- if cost.Increment, err = utils.NewDecimalFromString(incrementStr); err != nil {
- return
- }
- }
- if fixedFeeStr := sls[j+2]; fixedFeeStr != utils.EmptyString {
- if cost.FixedFee, err = utils.NewDecimalFromString(fixedFeeStr); err != nil {
- return
- }
- }
- if recurrentFeeStr := sls[j+3]; recurrentFeeStr != utils.EmptyString {
- if cost.RecurrentFee, err = utils.NewDecimalFromString(recurrentFeeStr); err != nil {
- return
- }
- }
- costs = append(costs, cost)
- }
- return
-}
-
-// actSetUnitFactor will update the UnitFactors
-func actSetUnitFactor(uFs []*utils.UnitFactor, path []string, value string) (untFctr []*utils.UnitFactor, err error) {
- pathVal := path[0][11:]
- lp := len(pathVal)
- // check path requierments
- // exact 2 elements
- // and the first element have an index between brackets
- if len(path) != 2 ||
- pathVal[0] != '[' ||
- pathVal[lp-1] != ']' {
- return nil, utils.ErrWrongPath
- }
- pathVal = pathVal[1 : lp-1]
- var idx int
- // convert the index from string to int
- if idx, err = strconv.Atoi(pathVal); err != nil {
- return
- }
- if len(uFs) == idx { // special case add a new unitFactor
- uFs = append(uFs, &utils.UnitFactor{})
- } else if len(uFs) < idx { // make sure we are in slice range
- return nil, utils.ErrWrongPath
- }
-
- switch path[1] {
- case utils.FilterIDs:
- uFs[idx].FilterIDs = utils.NewStringSet(strings.Split(value, utils.InfieldSep)).AsSlice()
- case utils.Factor:
- uFs[idx].Factor, err = utils.NewDecimalFromString(value)
- default:
- err = utils.ErrWrongPath
- }
- return uFs, err
-}
-
-func actSetCostIncrement(cIs []*utils.CostIncrement, path []string, value string) (cstIncr []*utils.CostIncrement, err error) {
- pathVal := path[0][14:]
- lp := len(pathVal)
- // check path requierments
- // exact 2 elements
- // and the first element have an index between brackets
- if len(path) != 2 ||
- pathVal[0] != '[' ||
- pathVal[lp-1] != ']' {
- return nil, utils.ErrWrongPath
- }
- pathVal = pathVal[1 : lp-1]
- var idx int
- // convert the index from string to int
- if idx, err = strconv.Atoi(pathVal); err != nil {
- return
- }
- if len(cIs) == idx { // special case add a new CostIncrement
- cIs = append(cIs, &utils.CostIncrement{})
- } else if len(cIs) < idx { // make sure we are in slice range
- return nil, utils.ErrWrongPath
- }
-
- switch path[1] {
- case utils.FilterIDs:
- cIs[idx].FilterIDs = utils.NewStringSet(strings.Split(value, utils.InfieldSep)).AsSlice()
- case utils.Increment:
- cIs[idx].Increment, err = utils.NewDecimalFromString(value)
- case utils.FixedFee:
- cIs[idx].FixedFee, err = utils.NewDecimalFromString(value)
- case utils.RecurrentFee:
- cIs[idx].RecurrentFee, err = utils.NewDecimalFromString(value)
- default:
- err = utils.ErrWrongPath
- }
- return cIs, err
-}
diff --git a/accounts/actsetbalance_test.go b/accounts/actsetbalance_test.go
deleted file mode 100644
index 1d83d7da4..000000000
--- a/accounts/actsetbalance_test.go
+++ /dev/null
@@ -1,456 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OerS) 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
-*/
-
-package accounts
-
-import (
- "reflect"
- "testing"
- "time"
-
- "github.com/cgrates/cgrates/utils"
-
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/ericlagergren/decimal"
-)
-
-func TestActSetAccountBalance(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
-
- acntID := "TestActSetAccount"
- diktats := []*utils.BalDiktat{
- {
- Path: "*balance.Concrete1",
- Value: ";10",
- },
- }
-
- expected := "NO_DATA_BASE_CONNECTION"
- if err := actSetAccount(nil, "cgrates.org", acntID, diktats, false); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
-
- expected = "WRONG_PATH"
- if err := actSetAccount(dm, "cgrates.org", acntID, diktats, false); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
- diktats[0].Path = "*balance.Concrete1.NOT_A_FIELD"
-
- if err := actSetAccount(dm, "cgrates.org", acntID, diktats, false); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
- diktats[0].Path = "*balance.Concrete1.Weights"
-
- expectedAcc := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: acntID,
- Balances: map[string]*utils.Balance{
- "Concrete1": {
- ID: "Concrete1",
- Type: utils.MetaConcrete,
- Units: &utils.Decimal{decimal.New(0, 0)},
- Weights: []*utils.DynamicWeight{
- {
- Weight: 10,
- },
- },
- CostIncrements: []*utils.CostIncrement{
- {
- FilterIDs: []string{"*string:~*req.ToR:*voice"},
- Increment: utils.NewDecimal(int64(time.Second), 0),
- RecurrentFee: utils.NewDecimal(0, 0),
- },
- {
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: utils.NewDecimal(1024*1024, 0),
- RecurrentFee: utils.NewDecimal(0, 0),
- },
- {
- FilterIDs: []string{"*string:~*req.ToR:*sms"},
- Increment: utils.NewDecimal(1, 0),
- RecurrentFee: utils.NewDecimal(0, 0),
- },
- },
- },
- },
- }
- if err := actSetAccount(dm, "cgrates.org", acntID, diktats, false); err != nil {
- t.Error(err)
- } else if rcv, err := dm.GetAccountProfile("cgrates.org", acntID); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcv, expectedAcc) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expectedAcc), utils.ToJSON(rcv))
- }
-}
-
-func TestActSetAccount(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
-
- acntID := "TestActSetAccount"
- diktats := []*utils.BalDiktat{
- {
- Path: "*accountFilterIDs",
- Value: "10",
- },
- }
-
- expected := "WRONG_PATH"
- if err := actSetAccount(dm, "cgrates.org", acntID, diktats, false); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
- diktats[0].Path = "*account"
-
- if err := actSetAccount(dm, "cgrates.org", acntID, diktats, false); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
- diktats[0].Path = "*account.Weights"
-
- expected = "invalid DynamicWeight format for string <10>"
- if err := actSetAccount(dm, "cgrates.org", acntID, diktats, false); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
- diktats[0].Value = ";10"
-
- expectedAcc := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: acntID,
- Weights: []*utils.DynamicWeight{
- {
- Weight: 10,
- },
- },
- }
- if err := actSetAccount(dm, "cgrates.org", acntID, diktats, false); err != nil {
- t.Error(err)
- } else if rcv, err := dm.GetAccountProfile("cgrates.org", acntID); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcv, expectedAcc) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expectedAcc), utils.ToJSON(rcv))
- }
-}
-
-func TestActSetAccountFields(t *testing.T) {
- accPrf := &utils.AccountProfile{}
-
- expectedAccprf := &utils.AccountProfile{
- FilterIDs: []string{"*string:~*req.ToR:*sms"},
- ActivationInterval: &utils.ActivationInterval{
- ActivationTime: time.Date(2014, 7, 29, 15, 0, 0, 0, time.UTC),
- ExpiryTime: time.Date(2014, 8, 29, 15, 0, 0, 0, time.UTC),
- },
- Weights: []*utils.DynamicWeight{
- {
- Weight: 10,
- },
- },
- Opts: map[string]interface{}{
- utils.AccountField: "1004",
- },
- ThresholdIDs: []string{"TH_ID1"},
- }
- if err := actSetAccountFields(accPrf, []string{utils.FilterIDs}, "*string:~*req.ToR:*sms"); err != nil {
- t.Error(err)
- } else if err := actSetAccountFields(accPrf, []string{utils.ActivationIntervalString}, "2014-07-29T15:00:00Z;2014-08-29T15:00:00Z"); err != nil {
- t.Error(err)
- } else if err := actSetAccountFields(accPrf, []string{utils.Weights}, ";10"); err != nil {
- t.Error(err)
- } else if err := actSetAccountFields(accPrf, []string{utils.Opts, utils.AccountField}, "1004"); err != nil {
- t.Error(err)
- } else if err := actSetAccountFields(accPrf, []string{utils.ThresholdIDs}, "TH_ID1"); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expectedAccprf, accPrf) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expectedAccprf), utils.ToJSON(accPrf))
- }
-
- expected := "Unsupported time format"
- if err := actSetAccountFields(accPrf, []string{utils.ActivationIntervalString}, "not_a_time"); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
- expected = "WRONG_PATH"
- if err := actSetAccountFields(accPrf, []string{"not_an_account_field"}, utils.EmptyString); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-}
-
-func TestActSetBalanceFields(t *testing.T) {
- bal := &utils.Balance{}
-
- expectedBal := &utils.Balance{
- ID: "TestActSetBalanceFields",
- FilterIDs: []string{"*string:~*req.ToR:*sms"},
- Weights: []*utils.DynamicWeight{
- {
- Weight: 10,
- },
- },
- Type: utils.MetaAbstract,
- Units: &utils.Decimal{decimal.New(20, 0)},
- UnitFactors: []*utils.UnitFactor{
- {
- FilterIDs: []string{"fltr1"},
- Factor: &utils.Decimal{decimal.New(100, 0)},
- },
- },
- Opts: map[string]interface{}{
- utils.AccountField: "1004",
- },
- CostIncrements: []*utils.CostIncrement{
- {
- FilterIDs: []string{"fltr1"},
- Increment: &utils.Decimal{decimal.New(1, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 0)},
- },
- },
- AttributeIDs: []string{"ATTR_ID"},
- // RateProfileIDs: []string{"RATE_ID"},
- }
- if err := actSetBalance(bal, []string{utils.ID}, "TestActSetBalanceFields", true); err != nil {
- t.Error(err)
- } else if err := actSetBalance(bal, []string{utils.FilterIDs}, "*string:~*req.ToR:*sms", true); err != nil {
- t.Error(err)
- } else if err := actSetBalance(bal, []string{utils.Weights}, ";10", true); err != nil {
- t.Error(err)
- } else if err := actSetBalance(bal, []string{utils.Type}, utils.MetaAbstract, true); err != nil {
- t.Error(err)
- } else if err := actSetBalance(bal, []string{utils.Units}, "20", true); err != nil {
- t.Error(err)
- } else if err := actSetBalance(bal, []string{utils.UnitFactors}, "fltr1;100", true); err != nil {
- t.Error(err)
- } else if err := actSetBalance(bal, []string{utils.Opts, utils.AccountField}, "1004", true); err != nil {
- t.Error(err)
- } else if err := actSetBalance(bal, []string{utils.CostIncrements}, "fltr1;1;0;1", true); err != nil {
- t.Error(err)
- } else if err := actSetBalance(bal, []string{utils.AttributeIDs}, "ATTR_ID", true); err != nil {
- t.Error(err)
- // } else if err := actSetBalance(bal, []string{utils.RateProfileIDs}, "RATE_ID", true); err != nil {
- // t.Error(err)
- } else if !reflect.DeepEqual(bal, expectedBal) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expectedBal), utils.ToJSON(bal))
- }
-
- expected := "WRONG_PATH"
- if err := actSetBalance(bal, []string{}, utils.EmptyString, true); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- } else if err := actSetBalance(bal, []string{"not_a_balance_field"}, utils.EmptyString, true); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- } else if err := actSetBalance(bal, []string{"UnitFactors[0].Factor"}, "200", true); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- } else if err := actSetBalance(bal, []string{"CostIncrements[0].Increment"}, "2", true); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-
- expected = "can't convert to decimal"
- if err := actSetBalance(bal, []string{utils.Units}, "not_converting_decimal", true); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-}
-
-func TestActNewUnitFactorsFromString(t *testing.T) {
- value := "OneValue"
- expected := "invalid key: for BalanceUnitFactors"
- if _, err := actNewUnitFactorsFromString(value); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-
- expected = "can't convert to decimal"
- value = ";not_decimal"
- if _, err := actNewUnitFactorsFromString(value); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-}
-
-func TestActNewCostIncrementsFromString(t *testing.T) {
- value := "OneValue"
- expected := "invalid key: for BalanceCostIncrements"
- if _, err := actNewCostIncrementsFromString(value); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-
- value = ";invalid_decimal;;"
- expected = "can't convert to decimal"
- if _, err := actNewCostIncrementsFromString(value); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-
- value = ";;invalid_decimal;"
- if _, err := actNewCostIncrementsFromString(value); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-
- value = ";;;invalid_decimal"
- if _, err := actNewCostIncrementsFromString(value); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-}
-
-func TestActSetUnitFactor(t *testing.T) {
- unitFctr := []*utils.UnitFactor{
- {
- Factor: &utils.Decimal{decimal.New(100, 0)},
- },
- }
- path := []string{"UnitFactors[0]", utils.Factor}
- value := "200"
-
- expected := []*utils.UnitFactor{
- {
- Factor: &utils.Decimal{decimal.New(200, 0)},
- },
- }
- if rcv, err := actSetUnitFactor(unitFctr, path, value); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expected %+v, received %+v", expected, rcv)
- }
-
- //change the filters
- unitFctr = []*utils.UnitFactor{
- {
- FilterIDs: []string{"fltr1"},
- },
- }
- path = []string{"UnitFactors[1]", utils.FilterIDs}
- value = "fltr2"
- expected = []*utils.UnitFactor{
- {
- FilterIDs: []string{"fltr1"},
- },
- {
- FilterIDs: []string{"fltr2"},
- },
- }
- if rcv, err := actSetUnitFactor(unitFctr, path, value); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
-}
-
-func TestActSetUnitFactorErrors(t *testing.T) {
- unitFctr := []*utils.UnitFactor{
- {
- FilterIDs: []string{"fltr1"},
- },
- }
- path := []string{"UnitFactors[a]", utils.FilterIDs}
- value := "fltr2"
- expected := "strconv.Atoi: parsing \"a\": invalid syntax"
- if _, err := actSetUnitFactor(unitFctr, path, value); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-
- path = []string{"UnitFactors[7]", utils.FilterIDs}
- expected = "WRONG_PATH"
- if _, err := actSetUnitFactor(unitFctr, path, value); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-
- path = []string{"UnitFactors[0]", "not_a_field"}
- expected = "WRONG_PATH"
- if _, err := actSetUnitFactor(unitFctr, path, value); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-}
-
-func TestActSetCostIncrement(t *testing.T) {
- costIncr := []*utils.CostIncrement{
- {
- FilterIDs: []string{"fltr1"},
- Increment: &utils.Decimal{decimal.New(1, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 0)},
- },
- }
-
- expected := []*utils.CostIncrement{
- {
- FilterIDs: []string{"fltr1"},
- Increment: &utils.Decimal{decimal.New(1, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(2, 0)},
- },
- }
- if rcv, err := actSetCostIncrement(costIncr, []string{"CostIncrements[0]", utils.RecurrentFee}, "2"); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
-
- expected[0].FilterIDs = []string{"fltr2"}
- if rcv, err := actSetCostIncrement(costIncr, []string{"CostIncrements[0]", utils.FilterIDs}, "fltr2"); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
-
- expected[0].FixedFee = &utils.Decimal{decimal.New(1, 0)}
- if rcv, err := actSetCostIncrement(costIncr, []string{"CostIncrements[0]", utils.FixedFee}, "1"); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
-
- expected[0].Increment = &utils.Decimal{decimal.New(2, 0)}
- if rcv, err := actSetCostIncrement(costIncr, []string{"CostIncrements[0]", utils.Increment}, "2"); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
-
- expected = []*utils.CostIncrement{
- {
- FilterIDs: []string{"fltr2"},
- Increment: &utils.Decimal{decimal.New(2, 0)},
- FixedFee: &utils.Decimal{decimal.New(1, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(2, 0)},
- },
- {
- Increment: &utils.Decimal{decimal.New(2, 0)},
- },
- }
- if rcv, err := actSetCostIncrement(costIncr, []string{"CostIncrements[1]", utils.Increment}, "2"); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
- }
-}
-
-func TestActSetCostIncrementErrors(t *testing.T) {
- costIncr := []*utils.CostIncrement{}
- expected := "strconv.Atoi: parsing \"a\": invalid syntax"
- if _, err := actSetCostIncrement(costIncr, []string{"CostIncrements[a]", utils.Increment}, "2"); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-
- expected = "WRONG_PATH"
- if _, err := actSetCostIncrement(costIncr, []string{"CostIncrements[8]", utils.Increment}, "2"); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-
- if _, err := actSetCostIncrement(costIncr, []string{"CostIncrements[0]", "not_a_field"}, "2"); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-}
diff --git a/accounts/concretebalance.go b/accounts/concretebalance.go
deleted file mode 100644
index 77846bcdf..000000000
--- a/accounts/concretebalance.go
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OerS) 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
-*/
-
-package accounts
-
-import (
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
- "github.com/ericlagergren/decimal"
-)
-
-// cloneUnitsFromConcretes returns cloned units from the concrete balances passed as parameters
-func cloneUnitsFromConcretes(cBs []*concreteBalance) (clnedUnts []*utils.Decimal) {
- if cBs == nil {
- return
- }
- clnedUnts = make([]*utils.Decimal, len(cBs))
- for i := range cBs {
- clnedUnts[i] = cBs[i].blnCfg.Units.Clone()
- }
- return
-}
-
-// restoreUnitsFromClones will restore the units from the clones
-func restoreUnitsFromClones(cBs []*concreteBalance, clnedUnts []*utils.Decimal) {
- for i, clnedUnt := range clnedUnts {
- cBs[i].blnCfg.Units.Big = clnedUnt.Big
- }
-}
-
-// newConcreteBalance constructs a concreteBalanceOperator
-func newConcreteBalanceOperator(acntID string, blnCfg *utils.Balance,
- fltrS *engine.FilterS, connMgr *engine.ConnManager,
- attrSConns, rateSConns []string) balanceOperator {
- return &concreteBalance{acntID, blnCfg, fltrS, connMgr, attrSConns, rateSConns}
-}
-
-// concreteBalance is the operator for *concrete balance type
-type concreteBalance struct {
- acntID string
- blnCfg *utils.Balance
- fltrS *engine.FilterS
- connMgr *engine.ConnManager
- attrSConns,
- rateSConns []string
-}
-
-// debitAbstracts implements the balanceOperator interface
-func (cB *concreteBalance) debitAbstracts(aUnits *decimal.Big,
- cgrEv *utils.CGREvent) (ec *utils.EventCharges, err error) {
- evNm := cgrEv.AsDataProvider()
- // pass the general balance filters
- var pass bool
- if pass, err = cB.fltrS.Pass(cgrEv.Tenant, cB.blnCfg.FilterIDs, evNm); err != nil {
- return
- } else if !pass {
- return nil, utils.ErrFilterNotPassingNoCaps
- }
-
- // costIncrement
- // var costIcrm *utils.CostIncrement
- // if costIcrm, err = costIncrement(cB.blnCfg.CostIncrements,
- // cB.fltrS, cgrEv.Tenant, evNm); err != nil {
- // return
- // }
- // if ec, err = maxDebitAbstractsFromConcretes(aUnits,
- // cB.acntID, []*concreteBalance{cB},
- // cB.connMgr, cgrEv,
- // cB.attrSConns, cB.blnCfg.AttributeIDs,
- // cB.rateSConns, cB.blnCfg.RateProfileIDs,
- // costIcrm); err != nil {
- // return
- // }
- return
-}
-
-// debitConcretes implements the balanceOperator interface
-func (cB *concreteBalance) debitConcretes(cUnits *decimal.Big,
- cgrEv *utils.CGREvent) (ec *utils.EventCharges, err error) {
- evNm := cgrEv.AsDataProvider()
- // pass the general balance filters
- var pass bool
- if pass, err = cB.fltrS.Pass(cgrEv.Tenant, cB.blnCfg.FilterIDs, evNm); err != nil {
- return
- } else if !pass {
- return nil, utils.ErrFilterNotPassingNoCaps
- }
-
- // unitFactor
- var uF *utils.UnitFactor
- if uF, err = unitFactor(cB.blnCfg.UnitFactors, cB.fltrS, cgrEv.Tenant, evNm); err != nil {
- return
- }
- var hasUF bool
- if uF != nil && uF.Factor.Cmp(decimal.New(1, 0)) != 0 {
- hasUF = true
- cUnits = utils.MultiplyBig(cUnits, uF.Factor.Big)
- }
-
- // balanceLimit
- var hasLmt bool
- var blncLmt *utils.Decimal
- if blncLmt, err = balanceLimit(cB.blnCfg.Opts); err != nil {
- return
- }
- if blncLmt != nil && blncLmt.Big.Cmp(decimal.New(0, 0)) != 0 {
- cB.blnCfg.Units.Big = utils.SubstractBig(cB.blnCfg.Units.Big, blncLmt.Big)
- hasLmt = true
- }
- var dbted *decimal.Big
- if cB.blnCfg.Units.Big.Cmp(cUnits) <= 0 && blncLmt != nil { // balance smaller than debit and limited
- dbted = cB.blnCfg.Units.Big
- cB.blnCfg.Units.Big = blncLmt.Big
- } else {
- cB.blnCfg.Units.Big = utils.SubstractBig(cB.blnCfg.Units.Big, cUnits)
- if hasLmt { // put back the limit
- cB.blnCfg.Units.Big = utils.SumBig(cB.blnCfg.Units.Big, blncLmt.Big)
- }
- dbted = cUnits
- }
- if hasUF {
- dbted = utils.DivideBig(dbted, uF.Factor.Big)
- }
- if dbted.Cmp(decimal.New(0, 0)) == 0 {
- return // no event cost for 0 debit
- }
- // EventCharges
- ec = utils.NewEventCharges()
- ec.Concretes = &utils.Decimal{dbted}
- // UnitFactors
- var ufID string
- if hasUF {
- ufID = utils.UUIDSha1Prefix()
- ec.UnitFactors[ufID] = uF
- }
- acntID := utils.UUIDSha1Prefix()
- ec.Accounting[acntID] = &utils.AccountCharge{
- AccountID: cB.acntID,
- BalanceID: cB.blnCfg.ID,
- Units: &utils.Decimal{dbted},
- BalanceLimit: blncLmt,
- UnitFactorID: ufID,
- }
- ec.ChargingIntervals = []*utils.ChargingInterval{
- {
- Increments: []*utils.ChargingIncrement{
- {
- Units: &utils.Decimal{dbted},
- AccountChargeID: acntID,
- CompressFactor: 1,
- },
- },
- CompressFactor: 1,
- },
- }
-
- return
-}
diff --git a/accounts/concretebalance_test.go b/accounts/concretebalance_test.go
deleted file mode 100644
index 47f807bbb..000000000
--- a/accounts/concretebalance_test.go
+++ /dev/null
@@ -1,832 +0,0 @@
-/*
-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
-*/
-
-package accounts
-
-import (
- "reflect"
- "testing"
-
- "github.com/cgrates/cgrates/config"
-
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
- "github.com/ericlagergren/decimal"
-)
-
-func TestCBDebitUnits(t *testing.T) {
- // with limit and unit factor
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "TestCBDebitUnits",
- Type: utils.MetaConcrete,
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: -200.0,
- },
- UnitFactors: []*utils.UnitFactor{
- {
- Factor: utils.NewDecimal(100, 0), // EuroCents
- },
- },
- Units: utils.NewDecimal(500, 0), // 500 EURcents
- },
- fltrS: new(engine.FilterS),
- }
- cgrEvent := &utils.CGREvent{
- Tenant: "cgrates.org",
- }
- unitFct := &utils.UnitFactor{
- Factor: utils.NewDecimal(100, 0),
- }
- toDebit := utils.NewDecimal(6, 0)
- if evChrgr, err := cb.debitConcretes(toDebit.Big,
- cgrEvent); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(cb.blnCfg.UnitFactors[0], unitFct) {
- t.Errorf("received unit factor: %+v", unitFct)
- } else if evChrgr.Concretes.Compare(toDebit) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(-100, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-
- //with increment and not enough balance
- cb = &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "TestCBDebitUnits",
- Type: utils.MetaConcrete,
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: -1.0,
- },
- Units: utils.NewDecimal(125, 2), // 1.25
- },
- fltrS: new(engine.FilterS),
- }
- toDebit = utils.NewDecimal(25, 1) //2.5
- if evChrgr, err := cb.debitConcretes(toDebit.Big,
- cgrEvent); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Cmp(decimal.New(225, 2)) != 0 { // 2.25 debited
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(-1, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-
- //with increment and unlimited balance
- cb = &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "TestCBDebitUnits",
- Type: utils.MetaConcrete,
- Opts: map[string]interface{}{
- utils.MetaBalanceUnlimited: true,
- },
- Units: utils.NewDecimal(125, 2), // 1.25
- },
- fltrS: new(engine.FilterS),
- }
- toDebit = utils.NewDecimal(25, 1) // 2.5
- if evChrgr, err := cb.debitConcretes(toDebit.Big,
- cgrEvent); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Cmp(decimal.New(25, 1)) != 0 { // debit more than available since we have unlimited
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(-125, 2)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-
- //with increment and positive limit
- cb = &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "TestCBDebitUnits",
- Type: utils.MetaConcrete,
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: 0.5, // 0.5 as limit
- },
- Units: utils.NewDecimal(125, 2), // 1.25
- },
- fltrS: new(engine.FilterS),
- }
- toDebit = utils.NewDecimal(25, 1) //2.5
- if evChrgr, err := cb.debitConcretes(toDebit.Big,
- cgrEvent); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Cmp(decimal.New(75, 2)) != 0 { // limit is 0.5
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(5, 1)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBSimpleDebit(t *testing.T) {
- // debit 10 units from a concrete balance with 500 units
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: new(engine.FilterS),
- }
- toDebit := utils.NewDecimal(10, 0)
- if evChrgr, err := cb.debitConcretes(toDebit.Big,
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Compare(toDebit) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(490, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBDebitExceed(t *testing.T) {
- // debit 510 units from a concrete balance with 500 units
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: new(engine.FilterS),
- }
- if evChrgr, err := cb.debitConcretes(utils.NewDecimal(510, 0).Big,
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Compare(utils.NewDecimal(500, 0)) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(0, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBDebitUnlimited(t *testing.T) {
- // debit 510 units from an unlimited concrete balance with 100 units
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Opts: map[string]interface{}{
- utils.MetaBalanceUnlimited: true,
- },
- Units: utils.NewDecimal(100, 0),
- },
- fltrS: new(engine.FilterS),
- }
- if evChrgr, err := cb.debitConcretes(utils.NewDecimal(510, 0).Big,
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Compare(utils.NewDecimal(510, 0)) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(-410, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBDebitLimit(t *testing.T) {
- // debit 190 units from a concrete balance with 500 units and limit of 300
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: 300.0, // 300 as limit
- },
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: new(engine.FilterS),
- }
- toDebit := utils.NewDecimal(190, 0)
- if evChrgr, err := cb.debitConcretes(toDebit.Big,
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Compare(toDebit) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(310, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBDebitLimitExceed(t *testing.T) {
- // debit 210 units from a concrete balance with 500 units and limit of 300
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: 300.0, // 300 as limit
- },
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: new(engine.FilterS),
- }
- if evChrgr, err := cb.debitConcretes(utils.NewDecimal(210, 0).Big,
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Compare(utils.NewDecimal(200, 0)) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(300, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBDebitLimitExceed2(t *testing.T) {
- // debit 510 units from a concrete balance with 500 units but because of limit it will debit only 200
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: 300.0, // 300 as limit
- },
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: new(engine.FilterS),
- }
- if evChrgr, err := cb.debitConcretes(utils.NewDecimal(510, 0).Big,
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Compare(utils.NewDecimal(200, 0)) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(300, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBDebitWithUnitFactor(t *testing.T) {
- // debit 1 unit from balance but because of unit factor it will debit 100
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- UnitFactors: []*utils.UnitFactor{
- &utils.UnitFactor{
- Factor: utils.NewDecimal(100, 0),
- },
- },
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: new(engine.FilterS),
- }
- toDebit := utils.NewDecimal(1, 0)
- if evChrgr, err := cb.debitConcretes(toDebit.Big,
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Compare(toDebit) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(400, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBDebitWithUnitFactorWithLimit(t *testing.T) {
- // debit 3 units from balance but because of unit factor and limit it will debit 200
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- UnitFactors: []*utils.UnitFactor{
- &utils.UnitFactor{
- Factor: utils.NewDecimal(100, 0),
- },
- },
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: 300.0, // 300 as limit
- },
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: new(engine.FilterS),
- }
- if evChrgr, err := cb.debitConcretes(utils.NewDecimal(3, 0).Big,
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Compare(utils.NewDecimal(2, 0)) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(300, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBDebitWithUnitFactorWithUnlimited(t *testing.T) {
- // debit 3 units from balance but because of unit factor and limit it will debit 200
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- UnitFactors: []*utils.UnitFactor{
- &utils.UnitFactor{
- Factor: utils.NewDecimal(100, 0),
- },
- },
- Opts: map[string]interface{}{
- utils.MetaBalanceUnlimited: true,
- },
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: new(engine.FilterS),
- }
- if evChrgr, err := cb.debitConcretes(utils.NewDecimal(7, 0).Big,
- new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Compare(utils.NewDecimal(7, 0)) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(-200, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBDebitWithUnitFactorWithFilters1(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- filterS := engine.NewFilterS(cfg, nil, dm)
- // debit 100 units from a balance ( the unit factor doesn't match )
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- UnitFactors: []*utils.UnitFactor{
- &utils.UnitFactor{
- FilterIDs: []string{"*string:~*req.CustomField:CustomValue"},
- Factor: utils.NewDecimal(100, 0),
- },
- },
- Opts: map[string]interface{}{
- utils.MetaBalanceUnlimited: true,
- },
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
-
- cgrEvent := &utils.CGREvent{
- Event: map[string]interface{}{
- "CustomField": "CustomValueee",
- },
- }
- if evChrgr, err := cb.debitConcretes(utils.NewDecimal(100, 0).Big,
- cgrEvent); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Compare(utils.NewDecimal(100, 0)) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(400, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBDebitWithUnitFactorWithFiltersWithLimit(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- filterS := engine.NewFilterS(cfg, nil, dm)
- // debit 100 units from a balance ( the unit factor match)
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- UnitFactors: []*utils.UnitFactor{
- &utils.UnitFactor{
- FilterIDs: []string{"*string:~*req.CustomField:CustomValue"},
- Factor: utils.NewDecimal(100, 0),
- },
- },
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: 300.0, // 300 as limit
- },
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
- cgrEvent := &utils.CGREvent{
- Event: map[string]interface{}{
- "CustomField": "CustomValue",
- },
- }
- if evChrgr, err := cb.debitConcretes(utils.NewDecimal(3, 0).Big,
- cgrEvent); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Compare(utils.NewDecimal(2, 0)) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(300, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBDebitWithMultipleUnitFactor(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- filterS := engine.NewFilterS(cfg, nil, dm)
- // debit 100 units from a balance ( the unit factor doesn't match )
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- UnitFactors: []*utils.UnitFactor{
- &utils.UnitFactor{
- FilterIDs: []string{"*string:~*req.CustomField:CustomValue"},
- Factor: utils.NewDecimal(100, 0),
- },
- &utils.UnitFactor{
- FilterIDs: []string{"*string:~*req.CustomField2:CustomValue2"},
- Factor: utils.NewDecimal(50, 0),
- },
- },
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
- cgrEvent := &utils.CGREvent{
- Event: map[string]interface{}{
- "CustomField2": "CustomValue2",
- },
- }
- if evChrgr, err := cb.debitConcretes(utils.NewDecimal(3, 0).Big,
- cgrEvent); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Compare(utils.NewDecimal(3, 0)) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(350, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBDebitWithBalanceFilter(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- filterS := engine.NewFilterS(cfg, nil, dm)
- // debit 3 units from a balance (the filter match)
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- FilterIDs: []string{"*string:~*req.CustomField:CustomValue"},
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
- cgrEvent := &utils.CGREvent{
- Event: map[string]interface{}{
- "CustomField": "CustomValue",
- },
- }
- if evChrgr, err := cb.debitConcretes(utils.NewDecimal(3, 0).Big,
- cgrEvent); err != nil {
- t.Error(err)
- } else if evChrgr.Concretes.Compare(utils.NewDecimal(3, 0)) != 0 {
- t.Errorf("debited: %s", evChrgr.Concretes)
- } else if cb.blnCfg.Units.Cmp(decimal.New(497, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb.blnCfg.Units)
- }
-}
-
-func TestCBDebitWithBalanceFilterNotPassing(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- filterS := engine.NewFilterS(cfg, nil, dm)
- // filter doesn't match )
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- FilterIDs: []string{"*string:~*req.CustomField2:CustomValue2"},
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
- cgrEvent := &utils.CGREvent{
- Event: map[string]interface{}{
- "CustomField": "CustomValue",
- },
- }
- if _, err := cb.debitConcretes(utils.NewDecimal(3, 0).Big,
- cgrEvent); err == nil || err != utils.ErrFilterNotPassingNoCaps {
- t.Error(err)
- }
-}
-
-func TestCBDebitWithBalanceInvalidFilter(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- filterS := engine.NewFilterS(cfg, nil, dm)
- // debit 100 units from a balance ( the unit factor doesn't match )
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- FilterIDs: []string{"*string"},
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
- cgrEvent := &utils.CGREvent{
- Event: map[string]interface{}{
- "CustomField": "CustomValue",
- },
- }
- if _, err := cb.debitConcretes(utils.NewDecimal(3, 0).Big,
- cgrEvent); err == nil || err.Error() != "inline parse error for string: <*string>" {
- t.Error(err)
- }
-}
-
-func TestCBDebitWithInvalidUnitFactorFilter(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- filterS := engine.NewFilterS(cfg, nil, dm)
- // debit 100 units from a balance ( the unit factor doesn't match )
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- UnitFactors: []*utils.UnitFactor{
- &utils.UnitFactor{
- FilterIDs: []string{"*string"},
- Factor: utils.NewDecimal(100, 0),
- },
- },
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
- cgrEvent := &utils.CGREvent{
- Event: map[string]interface{}{
- "CustomField": "CustomValue",
- },
- }
- if _, err := cb.debitConcretes(utils.NewDecimal(3, 0).Big,
- cgrEvent); err == nil || err.Error() != "inline parse error for string: <*string>" {
- t.Error(err)
- }
-}
-
-func TestCBDebitWithInvalidLimit(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- filterS := engine.NewFilterS(cfg, nil, dm)
- // debit 100 units from a balance ( the unit factor doesn't match )
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: "invalid",
- },
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
- cgrEvent := &utils.CGREvent{
- Event: map[string]interface{}{
- "CustomField": "CustomValue",
- },
- }
- if _, err := cb.debitConcretes(utils.NewDecimal(3, 0).Big,
- cgrEvent); err == nil || err.Error() != "unsupported *balanceLimit format" {
- t.Error(err)
- }
-}
-
-// func TestCBSDebitAbstracts(t *testing.T) {
-// // debit 10 units from a concrete balance with 500 units
-// cb := &concreteBalance{
-// blnCfg: &utils.Balance{
-// ID: "CB",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(500, 0), // 500 Units
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(5, 0),
-// RecurrentFee: utils.NewDecimal(1, 0),
-// },
-// },
-// },
-// fltrS: new(engine.FilterS),
-// }
-// toDebit := decimal.New(10, 0)
-// if dbted, err := cb.debitAbstracts(toDebit,
-// new(utils.CGREvent)); err != nil {
-// t.Error(err)
-// } else if dbted.Abstracts.Big.Cmp(toDebit) != 0 {
-// t.Errorf("debited: %+v", dbted)
-// } else if cb.blnCfg.Units.Cmp(decimal.New(498, 0)) != 0 {
-// t.Errorf("balance remaining: %s", cb.blnCfg.Units)
-// }
-// }
-
-func TestCBSDebitAbstractsInvalidFilter(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- filterS := engine.NewFilterS(cfg, nil, dm)
- // debit 10 units from a concrete balance with 500 units
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- FilterIDs: []string{"*string"},
- CostIncrements: []*utils.CostIncrement{
- {
- Increment: utils.NewDecimal(5, 0),
- RecurrentFee: utils.NewDecimal(1, 0),
- },
- },
- },
- fltrS: filterS,
- }
- toDebit := decimal.New(10, 0)
- if _, err := cb.debitAbstracts(toDebit, new(utils.CGREvent)); err == nil ||
- err.Error() != "inline parse error for string: <*string>" {
- t.Error(err)
- }
-}
-
-func TestCBSDebitAbstractsNoMatchFilter(t *testing.T) {
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- filterS := engine.NewFilterS(cfg, nil, dm)
- // debit 10 units from a concrete balance with 500 units
- cb := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- FilterIDs: []string{"*string:~*req.CustomField:CustomValue"},
- CostIncrements: []*utils.CostIncrement{
- {
- Increment: utils.NewDecimal(5, 0),
- RecurrentFee: utils.NewDecimal(1, 0),
- },
- },
- },
- fltrS: filterS,
- }
- cgrEv := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "EV",
- Event: map[string]interface{}{
- "CustomField2": "CustomValue2",
- },
- }
- toDebit := decimal.New(10, 0)
- if _, err := cb.debitAbstracts(toDebit, cgrEv); err == nil ||
- err != utils.ErrFilterNotPassingNoCaps {
- t.Error(err)
- }
-}
-
-// func TestCBSDebitAbstractsInvalidCostIncrementFilter(t *testing.T) {
-// cfg := config.NewDefaultCGRConfig()
-// data := engine.NewInternalDB(nil, nil, true)
-// dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
-// filterS := engine.NewFilterS(cfg, nil, dm)
-// // debit 10 units from a concrete balance with 500 units
-// cb := &concreteBalance{
-// blnCfg: &utils.Balance{
-// ID: "CB",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(500, 0), // 500 Units
-// CostIncrements: []*utils.CostIncrement{
-// {
-// FilterIDs: []string{"*string"},
-// Increment: utils.NewDecimal(5, 0),
-// RecurrentFee: utils.NewDecimal(1, 0),
-// },
-// },
-// },
-// fltrS: filterS,
-// }
-// toDebit := decimal.New(10, 0)
-// if _, err := cb.debitAbstracts(toDebit, new(utils.CGREvent)); err == nil ||
-// err.Error() != "inline parse error for string: <*string>" {
-// t.Error(err)
-// }
-// }
-
-// func TestCBSDebitAbstractsCoverProcessAttributes(t *testing.T) { // coverage purpose
-// cfg := config.NewDefaultCGRConfig()
-// data := engine.NewInternalDB(nil, nil, true)
-// dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
-// filterS := engine.NewFilterS(cfg, nil, dm)
-
-// engine.Cache.Clear(nil)
-
-// sTestMock := &testMockCall{
-// calls: map[string]func(args interface{}, reply interface{}) error{
-// utils.AttributeSv1ProcessEvent: func(args interface{}, reply interface{}) error {
-// return utils.ErrNotImplemented
-// },
-// },
-// }
-// chanInternal := make(chan rpcclient.ClientConnector, 1)
-// chanInternal <- sTestMock
-// connMgr := engine.NewConnManager(cfg, map[string]chan rpcclient.ClientConnector{
-// utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes): chanInternal,
-// })
-
-// // debit 10 units from a concrete balance with 500 units
-// cb := &concreteBalance{
-// blnCfg: &utils.Balance{
-// ID: "CB",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(500, 0), // 500 Units
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(5, 0),
-// RecurrentFee: utils.NewDecimal(-1, 0),
-// },
-// },
-// AttributeIDs: []string{"CustomAttr"},
-// },
-// fltrS: filterS,
-// connMgr: connMgr,
-// }
-// toDebit := decimal.New(10, 0)
-// if _, err := cb.debitAbstracts(toDebit, new(utils.CGREvent)); err == nil ||
-// err.Error() != "NOT_CONNECTED: AttributeS" {
-// t.Error(err)
-// }
-// }
-
-// func TestCBSDebitAbstractsCoverProcessAttributes2(t *testing.T) { // coverage purpose
-// cfg := config.NewDefaultCGRConfig()
-// data := engine.NewInternalDB(nil, nil, true)
-// dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
-// filterS := engine.NewFilterS(cfg, nil, dm)
-
-// engine.Cache.Clear(nil)
-
-// sTestMock := &testMockCall{
-// calls: map[string]func(args interface{}, reply interface{}) error{
-// utils.AttributeSv1ProcessEvent: func(args interface{}, reply interface{}) error {
-// rplCast, canCast := reply.(*engine.AttrSProcessEventReply)
-// if !canCast {
-// t.Errorf("Wrong argument type : %T", reply)
-// return nil
-// }
-// customEv := &engine.AttrSProcessEventReply{
-// MatchedProfiles: nil,
-// AlteredFields: []string{"CustomField2"},
-// CGREvent: &utils.CGREvent{
-// Tenant: "cgrates.org",
-// ID: "EV",
-// Event: map[string]interface{}{
-// "CustomField2": "CustomValue2",
-// },
-// },
-// }
-// *rplCast = *customEv
-// return nil
-// },
-// },
-// }
-// chanInternal := make(chan rpcclient.ClientConnector, 1)
-// chanInternal <- sTestMock
-// connMgr := engine.NewConnManager(cfg, map[string]chan rpcclient.ClientConnector{
-// utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes): chanInternal,
-// })
-
-// // debit 10 units from a concrete balance with 500 units
-// cb := &concreteBalance{
-// blnCfg: &utils.Balance{
-// ID: "CB",
-// Type: utils.MetaConcrete,
-// Units: utils.NewDecimal(500, 0), // 500 Units
-// CostIncrements: []*utils.CostIncrement{
-// {
-// Increment: utils.NewDecimal(5, 0),
-// RecurrentFee: utils.NewDecimal(-1, 0),
-// },
-// },
-// AttributeIDs: []string{"CustomAttr"},
-// },
-// fltrS: filterS,
-// connMgr: connMgr,
-// attrSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes)},
-// }
-// toDebit := decimal.New(10, 0)
-// if _, err := cb.debitAbstracts(toDebit, new(utils.CGREvent)); err == nil ||
-// err.Error() != "RATES_ERROR:NOT_CONNECTED: RateS" {
-// t.Error(err)
-// }
-// }
diff --git a/accounts/libaccounts.go b/accounts/libaccounts.go
deleted file mode 100644
index 253b21f69..000000000
--- a/accounts/libaccounts.go
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OerS) 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
-*/
-
-package accounts
-
-import (
- "errors"
- "fmt"
-
- "github.com/cgrates/cgrates/config"
-
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/guardian"
- "github.com/cgrates/cgrates/utils"
- "github.com/ericlagergren/decimal"
-)
-
-// newAccountBalances constructs accountBalances
-func newBalanceOperators(acntID string, blnCfgs []*utils.Balance,
- fltrS *engine.FilterS, connMgr *engine.ConnManager,
- attrSConns, rateSConns []string) (blncOpers []balanceOperator, err error) {
-
- blncOpers = make([]balanceOperator, len(blnCfgs))
- var cncrtBlncs []*concreteBalance
- for i, blnCfg := range blnCfgs { // build the concrete balances
- if blnCfg.Type != utils.MetaConcrete {
- continue
- }
- blncOpers[i] = newConcreteBalanceOperator(acntID, blnCfg,
- fltrS, connMgr, attrSConns, rateSConns)
- cncrtBlncs = append(cncrtBlncs, blncOpers[i].(*concreteBalance))
- }
-
- for i, blnCfg := range blnCfgs { // build the abstract balances
- if blnCfg.Type == utils.MetaConcrete {
- continue
- }
- if blncOpers[i], err = newBalanceOperator(acntID, blnCfg, cncrtBlncs,
- fltrS, connMgr, attrSConns, rateSConns); err != nil {
- return
- }
- }
-
- return
-}
-
-// newBalanceOperator instantiates balanceOperator interface
-// cncrtBlncs are needed for abstract balance debits
-func newBalanceOperator(acntID string, blncCfg *utils.Balance, cncrtBlncs []*concreteBalance,
- fltrS *engine.FilterS, connMgr *engine.ConnManager,
- attrSConns, rateSConns []string) (bP balanceOperator, err error) {
- switch blncCfg.Type {
- default:
- return nil, fmt.Errorf("unsupported balance type: <%s>", blncCfg.Type)
- case utils.MetaConcrete:
- return newConcreteBalanceOperator(acntID, blncCfg, fltrS, connMgr, attrSConns, rateSConns), nil
- case utils.MetaAbstract:
- return newAbstractBalanceOperator(acntID, blncCfg, cncrtBlncs, fltrS, connMgr, attrSConns, rateSConns), nil
- }
-}
-
-// balanceOperator is the implementation of a balance type
-type balanceOperator interface {
- debitAbstracts(usage *decimal.Big, cgrEv *utils.CGREvent) (ec *utils.EventCharges, err error)
- debitConcretes(usage *decimal.Big, cgrEv *utils.CGREvent) (ec *utils.EventCharges, err error)
-}
-
-// roundUnitsWithIncrements rounds the usage based on increments
-func roundUnitsWithIncrements(usage, incrm *decimal.Big) (rndedUsage *decimal.Big) {
- usgMaxIncrm := decimal.WithContext(
- decimal.Context{RoundingMode: decimal.ToZero}).Quo(usage,
- incrm).RoundToInt()
- rndedUsage = utils.MultiplyBig(usgMaxIncrm, incrm)
- return
-}
-
-// processAttributeS will process the event with AttributeS
-func processAttributeS(connMgr *engine.ConnManager, cgrEv *utils.CGREvent,
- attrSConns, attrIDs []string) (rplyEv *engine.AttrSProcessEventReply, err error) {
- if len(attrSConns) == 0 {
- return nil, utils.NewErrNotConnected(utils.AttributeS)
- }
- var procRuns *int
- if val, has := cgrEv.APIOpts[utils.OptsAttributesProcessRuns]; has {
- if v, err := utils.IfaceAsTInt64(val); err == nil {
- procRuns = utils.IntPointer(int(v))
- }
- }
- attrArgs := &engine.AttrArgsProcessEvent{
- Context: utils.StringPointer(utils.FirstNonEmpty(
- engine.MapEvent(cgrEv.APIOpts).GetStringIgnoreErrors(utils.OptsContext),
- utils.MetaAccounts)),
- CGREvent: cgrEv,
- AttributeIDs: attrIDs,
- ProcessRuns: procRuns,
- }
- var tmpReply engine.AttrSProcessEventReply
- if err = connMgr.Call(attrSConns, nil, utils.AttributeSv1ProcessEvent,
- attrArgs, &tmpReply); err != nil {
- return
- }
- return &tmpReply, nil
-}
-
-// costIncrement computes the costIncrement for the event
-func costIncrement(cfgCostIncrmts []*utils.CostIncrement,
- fltrS *engine.FilterS, tnt string, ev utils.DataProvider) (costIcrm *utils.CostIncrement, err error) {
- for _, cIcrm := range cfgCostIncrmts {
- var pass bool
- if pass, err = fltrS.Pass(tnt, cIcrm.FilterIDs, ev); err != nil {
- return
- } else if !pass {
- continue
- }
- costIcrm = cIcrm
- break
- }
- if costIcrm == nil {
- costIcrm = new(utils.CostIncrement)
- }
- if costIcrm.Increment == nil {
- costIcrm.Increment = utils.NewDecimal(1, 0)
- }
- if costIcrm.RecurrentFee == nil {
- costIcrm.RecurrentFee = utils.NewDecimal(-1, 0)
- }
- return
-}
-
-// unitFactor detects the unitFactor for the event
-func unitFactor(cfgUnitFactors []*utils.UnitFactor,
- fltrS *engine.FilterS, tnt string, ev utils.DataProvider) (uF *utils.UnitFactor, err error) {
- for _, uFcfg := range cfgUnitFactors {
- var pass bool
- if pass, err = fltrS.Pass(tnt, uFcfg.FilterIDs, ev); err != nil {
- return
- } else if !pass {
- continue
- }
- uF = uFcfg
- return
- }
- return
-}
-
-// balanceLimit returns the balance limit based on configuration
-func balanceLimit(optsCfg map[string]interface{}) (bL *utils.Decimal, err error) {
- if _, isUnlimited := optsCfg[utils.MetaBalanceUnlimited]; isUnlimited {
- return // unlimited is nil pointer
- }
- if lmtIface, has := optsCfg[utils.MetaBalanceLimit]; has {
- flt64Lmt, canCast := lmtIface.(float64)
- if !canCast {
- return nil, errors.New("unsupported *balanceLimit format")
- }
- return utils.NewDecimalFromFloat64(flt64Lmt), nil
- }
- // nothing matched, return default
- bL = utils.NewDecimal(0, 0)
- return
-}
-
-// debitConcreteUnits debits concrete units out of concrete balances
-// returns utils.ErrInsufficientCredit if complete usage cannot be debited
-func debitConcreteUnits(cUnits *decimal.Big,
- acntID string, cncrtBlncs []*concreteBalance,
- cgrEv *utils.CGREvent) (ec *utils.EventCharges, err error) {
-
- clnedUnts := cloneUnitsFromConcretes(cncrtBlncs)
- for _, cB := range cncrtBlncs {
- var ecCncrt *utils.EventCharges
- if ecCncrt, err = cB.debitConcretes(new(decimal.Big).Copy(cUnits), cgrEv); err != nil {
- restoreUnitsFromClones(cncrtBlncs, clnedUnts)
- return nil, err
- }
- if ecCncrt == nil { // no debit performed
- continue
- }
- if ec == nil {
- ec = utils.NewEventCharges()
- }
- ec.Merge(ecCncrt)
- cUnits = utils.SubstractBig(cUnits, ecCncrt.Concretes.Big)
- if cUnits.Cmp(decimal.New(0, 0)) <= 0 {
- return // have debited all, total is smaller or equal to 0
- }
- }
- // we could not debit all, put back what we have debited
- restoreUnitsFromClones(cncrtBlncs, clnedUnts)
- return nil, utils.ErrInsufficientCredit
-}
-
-// maxDebitAbstractsFromConcretes will debit the maximum possible abstract units out of concretes
-func maxDebitAbstractsFromConcretes(aUnits *decimal.Big,
- acndID string, cncrtBlncs []*concreteBalance,
- connMgr *engine.ConnManager, cgrEv *utils.CGREvent,
- attrSConns, attributeIDs, rateSConns, rpIDs []string,
- costIcrm *utils.CostIncrement) (ec *utils.EventCharges, err error) {
- // Init EventCharges
- calculateCost := costIcrm.RecurrentFee.Cmp(decimal.New(-1, 0)) == 0 && costIcrm.FixedFee == nil
- //var attrIDs []string // will be populated if attributes are processed successfully
- // process AttributeS if needed
- if calculateCost && len(attributeIDs) != 0 { // cost unknown, apply AttributeS to query from RateS
- var rplyAttrS *engine.AttrSProcessEventReply
- if rplyAttrS, err = processAttributeS(connMgr, cgrEv, attrSConns,
- attributeIDs); err != nil {
- return
- }
- if len(rplyAttrS.AlteredFields) != 0 { // event was altered
- cgrEv = rplyAttrS.CGREvent
- //attrIDs = rplyAttrS.MatchedProfiles
- }
- }
- // fix the maximum number of iterations
- origConcrtUnts := cloneUnitsFromConcretes(cncrtBlncs) // so we can revert on errors
- paidConcrtUnts := origConcrtUnts // so we can revert when higher abstracts are not possible
- var aPaid, aDenied *decimal.Big
- maxItr := config.CgrConfig().AccountSCfg().MaxIterations
- for i := 0; i <= maxItr; i++ {
- if i != 0 {
- restoreUnitsFromClones(cncrtBlncs, origConcrtUnts)
- }
- if i == maxItr {
- return nil, utils.ErrMaxIncrementsExceeded
- }
- var cUnits *decimal.Big // concrete units to debit
- if costIcrm.FixedFee != nil {
- cUnits = costIcrm.FixedFee.Big
- }
- // RecurrentFee is configured, used it with increments
- if costIcrm.RecurrentFee.Big.Cmp(decimal.New(-1, 0)) != 0 {
- rcrntCost := utils.MultiplyBig(
- utils.DivideBig(aUnits, costIcrm.Increment.Big),
- costIcrm.RecurrentFee.Big)
- if cUnits == nil {
- cUnits = rcrntCost
- } else {
- cUnits = utils.SumBig(cUnits, rcrntCost)
- }
- }
- aQried := aUnits // so we can detect loops
- var ecDbt *utils.EventCharges
- if ecDbt, err = debitConcreteUnits(cUnits, acndID, cncrtBlncs, cgrEv); err != nil {
- if err != utils.ErrInsufficientCredit {
- return
- }
- err = nil
- // ErrInsufficientCredit
- aDenied = new(decimal.Big).Copy(aUnits)
- if aPaid == nil { // going backwards
- aUnits = utils.DivideBig( // divide by 2
- aUnits, decimal.New(2, 0))
- aUnits = roundUnitsWithIncrements(aUnits, costIcrm.Increment.Big) // make sure abstracts are multiple of increments
- if aUnits.Cmp(aDenied) >= 0 ||
- aUnits.Cmp(decimal.New(0, 0)) == 0 ||
- aUnits.Cmp(aQried) == 0 { // loop
- break
- }
- continue
- }
- } else { // debit for the usage succeeded
- aPaid = new(decimal.Big).Copy(aUnits)
- paidConcrtUnts = cloneUnitsFromConcretes(cncrtBlncs)
- ec = utils.NewEventCharges()
- ec.Merge(ecDbt)
- if i == 0 { // no estimation done, covering full
- break
- }
- }
- // going upwards
- aUnits = utils.SumBig(aPaid,
- utils.DivideBig(aPaid, decimal.New(2, 0)).RoundToInt())
- if aUnits.Cmp(aDenied) >= 0 {
- aUnits = utils.SumBig(aPaid, costIcrm.Increment.Big)
- }
- aUnits = roundUnitsWithIncrements(aUnits, costIcrm.Increment.Big)
- if aUnits.Cmp(aPaid) <= 0 ||
- aUnits.Cmp(aDenied) >= 0 ||
- aUnits.Cmp(aQried) == 0 { // loop
- break
- }
- }
- // Nothing paid
- if aPaid == nil {
- // since we are erroring, we restore the concerete balances
- aPaid = decimal.New(0, 0)
- ec = utils.NewEventCharges()
- }
- ec.Abstracts = &utils.Decimal{aPaid}
- restoreUnitsFromClones(cncrtBlncs, paidConcrtUnts)
- return
-}
-
-// restoreAccounts will restore the accounts in DataDB out of their backups if present
-func restoreAccounts(dm *engine.DataManager,
- acnts []*utils.AccountProfileWithWeight, bkps []utils.AccountBalancesBackup) {
- for i, bkp := range bkps {
- if bkp == nil ||
- !acnts[i].AccountProfile.BalancesAltered(bkp) {
- continue
- }
- acnts[i].AccountProfile.RestoreFromBackup(bkp)
- if err := dm.SetAccountProfile(acnts[i].AccountProfile, false); err != nil {
- utils.Logger.Warning(fmt.Sprintf("<%s> error <%s> restoring account <%s>",
- utils.AccountS, err, acnts[i].AccountProfile.TenantID()))
- }
- }
-}
-
-// unlockAccountProfiles is used to unlock the accounts based on their lock identifiers
-func unlockAccountProfiles(acnts utils.AccountProfilesWithWeight) {
- for _, lkID := range acnts.LockIDs() {
- guardian.Guardian.UnguardIDs(lkID)
- }
-}
diff --git a/accounts/libaccounts_test.go b/accounts/libaccounts_test.go
deleted file mode 100644
index a84971d51..000000000
--- a/accounts/libaccounts_test.go
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OerS) 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
-*/
-
-package accounts
-
-import (
- "bytes"
- "log"
- "os"
- "reflect"
- "strings"
- "testing"
- "time"
-
- "github.com/ericlagergren/decimal"
-
- "github.com/cgrates/cgrates/config"
-
- "github.com/cgrates/rpcclient"
-
- "github.com/cgrates/cgrates/engine"
-
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestNewAccountBalanceOperators(t *testing.T) {
- acntPrf := &utils.AccountProfile{
- ID: "TEST_ID",
- Tenant: "cgrates.org",
- Balances: map[string]*utils.Balance{
- "BL0": {
- ID: "BALANCE1",
- Type: utils.MetaAbstract,
- },
- "BL1": {
- ID: "BALANCE1",
- Type: utils.MetaConcrete,
- CostIncrements: []*utils.CostIncrement{
- {
- Increment: utils.NewDecimal(int64(time.Second), 0),
- },
- },
- },
- },
- }
- filters := engine.NewFilterS(config.NewDefaultCGRConfig(), nil, nil)
-
- concrete, err := newBalanceOperator(acntPrf.ID, acntPrf.Balances["BL1"], nil, filters, nil, nil, nil)
- if err != nil {
- t.Error(err)
- }
- var cncrtBlncs []*concreteBalance
- cncrtBlncs = append(cncrtBlncs, concrete.(*concreteBalance))
-
- expected := &abstractBalance{
- acntID: acntPrf.ID,
- blnCfg: acntPrf.Balances["BL0"],
- fltrS: filters,
- cncrtBlncs: cncrtBlncs,
- }
- blnCfgs := []*utils.Balance{acntPrf.Balances["BL0"], acntPrf.Balances["BL1"]}
- if blcOp, err := newBalanceOperators(acntPrf.ID, blnCfgs, filters, nil,
- nil, nil); err != nil {
- t.Error(err)
- } else {
- for _, bal := range blcOp {
- if rcv, canCast := bal.(*abstractBalance); canCast {
- if !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expected %+v, received %+v", expected, rcv)
- }
- }
- }
- }
-
- acntPrf.Balances["BL1"].Type = "INVALID_TYPE"
- expectedErr := "unsupported balance type: "
- if _, err := newBalanceOperators(acntPrf.ID, blnCfgs, filters, nil,
- nil, nil); err == nil || err.Error() != expectedErr {
- t.Errorf("Expected %+v, received %+v", expectedErr, err)
- }
-}
-
-type testMockCall struct {
- calls map[string]func(args interface{}, reply interface{}) error
-}
-
-func (tS *testMockCall) Call(method string, args interface{}, rply interface{}) error {
- if call, has := tS.calls[method]; !has {
- return rpcclient.ErrUnsupporteServiceMethod
- } else {
- return call(args, rply)
- }
-}
-
-func TestProcessAttributeS(t *testing.T) {
- engine.Cache.Clear(nil)
-
- config := config.NewDefaultCGRConfig()
- sTestMock := &testMockCall{ // coverage purpose
- calls: map[string]func(args interface{}, reply interface{}) error{
- utils.AttributeSv1ProcessEvent: func(args interface{}, reply interface{}) error {
- return utils.ErrNotImplemented
- },
- },
- }
- chanInternal := make(chan rpcclient.ClientConnector, 1)
- chanInternal <- sTestMock
- connMgr := engine.NewConnManager(config, map[string]chan rpcclient.ClientConnector{
- utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes): chanInternal,
- })
- cgrEvent := &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "TEST_ID1",
- APIOpts: map[string]interface{}{
- utils.OptsAttributesProcessRuns: "20",
- },
- }
-
- attrsConns := []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes)}
-
- if _, err := processAttributeS(connMgr, cgrEvent, attrsConns, nil); err == nil || err != utils.ErrNotImplemented {
- t.Errorf("Expected %+v, received %+v", utils.ErrNotImplemented, err)
- }
-}
-
-func TestDebitUsageFromConcretes(t *testing.T) {
- engine.Cache.Clear(nil)
-
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- cfg := config.NewDefaultCGRConfig()
-
- filterS := engine.NewFilterS(cfg, nil, dm)
- cb1 := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB1",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
- cb2 := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB2",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
- expectedEvCh := &utils.EventCharges{
- Concretes: utils.NewDecimal(700, 0),
- Accounting: make(map[string]*utils.AccountCharge),
- UnitFactors: make(map[string]*utils.UnitFactor),
- }
-
- if evCh, err := debitConcreteUnits(decimal.New(700, 0), utils.EmptyString,
- []*concreteBalance{cb1, cb2}, new(utils.CGREvent)); err != nil {
- t.Error(err)
- } else if cb1.blnCfg.Units.Cmp(decimal.New(0, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb1.blnCfg.Units)
- } else if cb2.blnCfg.Units.Cmp(decimal.New(300, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb2.blnCfg.Units)
- } else if !reflect.DeepEqual(expectedEvCh, evCh) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(expectedEvCh), utils.ToJSON(evCh))
- }
-
- cb1.blnCfg.Units = utils.NewDecimal(500, 0)
- cb2.blnCfg.Units = utils.NewDecimal(500, 0)
-
- if _, err := debitConcreteUnits(decimal.New(1100, 0), utils.EmptyString,
- []*concreteBalance{cb1, cb2}, new(utils.CGREvent)); err == nil || err != utils.ErrInsufficientCredit {
- t.Errorf("Expected %+v, received %+v", utils.ErrInsufficientCredit, err)
- } else if cb1.blnCfg.Units.Cmp(decimal.New(500, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb1.blnCfg.Units)
- } else if cb2.blnCfg.Units.Cmp(decimal.New(500, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb2.blnCfg.Units)
- }
-}
-
-func TestDebitUsageFromConcretesRestore(t *testing.T) {
- engine.Cache.Clear(nil)
-
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- cfg := config.NewDefaultCGRConfig()
-
- filterS := engine.NewFilterS(cfg, nil, dm)
- cb1 := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB1",
- Type: utils.MetaConcrete,
- FilterIDs: []string{"*string"},
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
- cb2 := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB2",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
-
- if _, err := debitConcreteUnits(decimal.New(200, 0), utils.EmptyString,
- []*concreteBalance{cb1, cb2},
- new(utils.CGREvent)); err == nil || err.Error() != "inline parse error for string: <*string>" {
- t.Error(err)
- } else if cb1.blnCfg.Units.Cmp(decimal.New(500, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb1.blnCfg.Units)
- } else if cb2.blnCfg.Units.Cmp(decimal.New(500, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb2.blnCfg.Units)
- }
-}
-
-func TestMaxDebitUsageFromConcretes(t *testing.T) {
- engine.Cache.Clear(nil)
-
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- cfg := config.NewDefaultCGRConfig()
- cfg.AccountSCfg().MaxIterations = 100
- config.SetCgrConfig(cfg)
- filterS := engine.NewFilterS(cfg, nil, dm)
- cb1 := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB1",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
- cb2 := &concreteBalance{
- blnCfg: &utils.Balance{
- ID: "CB2",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- fltrS: filterS,
- }
-
- if _, err := maxDebitAbstractsFromConcretes(decimal.New(900, 0), utils.EmptyString,
- []*concreteBalance{cb1, cb2}, nil, new(utils.CGREvent),
- nil, nil, nil, nil, &utils.CostIncrement{
- Increment: utils.NewDecimal(1, 0),
- RecurrentFee: utils.NewDecimal(1, 0),
- }); err != nil {
- t.Error(err)
- } else if cb1.blnCfg.Units.Cmp(decimal.New(0, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb1.blnCfg.Units)
- } else if cb2.blnCfg.Units.Cmp(decimal.New(100, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb2.blnCfg.Units)
- }
-
- //debit more than we have in balances with the restored units
- cb1.blnCfg.Units = utils.NewDecimal(500, 0)
- cb2.blnCfg.Units = utils.NewDecimal(500, 0)
- if _, err := maxDebitAbstractsFromConcretes(decimal.New(1100, 0), utils.EmptyString,
- []*concreteBalance{cb1, cb2}, nil, new(utils.CGREvent),
- nil, nil, nil, nil, &utils.CostIncrement{
- Increment: utils.NewDecimal(1, 0),
- RecurrentFee: utils.NewDecimal(1, 0),
- }); err == nil || err != utils.ErrMaxIncrementsExceeded {
- t.Error(err)
- } else if cb1.blnCfg.Units.Cmp(decimal.New(500, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb1.blnCfg.Units)
- } else if cb2.blnCfg.Units.Cmp(decimal.New(500, 0)) != 0 {
- t.Errorf("balance remaining: %s", cb2.blnCfg.Units)
- }
-}
-
-func TestRestoreAccount(t *testing.T) { //coverage purpose
- engine.Cache.Clear(nil)
-
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- acntPrf := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "1001",
- Balances: map[string]*utils.Balance{
- "CB1": {
- ID: "CB1",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0),
- },
- "CB2": {
- ID: "CB2",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(300, 0),
- },
- },
- }
- if err := dm.SetAccountProfile(acntPrf, false); err != nil {
- t.Error(err)
- }
-
- restoreAccounts(dm, []*utils.AccountProfileWithWeight{
- {acntPrf, 0, utils.EmptyString},
- }, []utils.AccountBalancesBackup{
- map[string]*decimal.Big{"CB2": decimal.New(100, 0)},
- })
-
- if rcv, err := dm.GetAccountProfile("cgrates.org", "1001"); err != nil {
- t.Error(err)
- } else if len(rcv.Balances) != 2 {
- t.Errorf("Unexpected number of balances received")
- } else if rcv.Balances["CB2"].Units.Cmp(decimal.New(100, 0)) != 0 {
- t.Errorf("Unexpected balance received after restore")
- }
-}
-
-type dataDBMockError struct {
- *engine.DataDBMock
-}
-
-func TestRestoreAccount2(t *testing.T) { //coverage purpose
- engine.Cache.Clear(nil)
-
- dm := engine.NewDataManager(&dataDBMockError{}, config.CgrConfig().CacheCfg(), nil)
- acntPrf := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "1001",
- Balances: map[string]*utils.Balance{
- "CB1": {
- ID: "CB1",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- "CB2": {
- ID: "CB2",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(100, 0), // 500 Units
- },
- },
- }
- var err error
- utils.Logger, err = utils.Newlogger(utils.MetaStdLog, utils.EmptyString)
- if err != nil {
- t.Error(err)
- }
- utils.Logger.SetLogLevel(7)
- buff := new(bytes.Buffer)
- log.SetOutput(buff)
-
- restoreAccounts(dm, []*utils.AccountProfileWithWeight{
- {acntPrf, 0, utils.EmptyString},
- }, []utils.AccountBalancesBackup{
- map[string]*decimal.Big{"CB1": decimal.New(100, 0)},
- })
-
- subString := " error restoring account "
- if rcv := buff.String(); !strings.Contains(rcv, subString) {
- t.Errorf("Expected %+q, received %+q", subString, rcv)
- }
-
- log.SetOutput(os.Stderr)
-}
-
-func TestRestoreAccount3(t *testing.T) { //coverage purpose
- engine.Cache.Clear(nil)
-
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil)
- acntPrf := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "1001",
- Balances: map[string]*utils.Balance{
- "CB1": {
- ID: "CB1",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(500, 0), // 500 Units
- },
- "CB2": {
- ID: "CB2",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(100, 0), // 500 Units
- },
- },
- }
- if err := dm.SetAccountProfile(acntPrf, false); err != nil {
- t.Error(err)
- }
-
- restoreAccounts(dm, []*utils.AccountProfileWithWeight{
- {acntPrf, 0, utils.EmptyString},
- }, []utils.AccountBalancesBackup{
- nil,
- })
-}
-
-/*
-func TestDebitFromBothBalances(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- fltr := engine.NewFilterS(cfg, nil, dm)
- rates := rates2.NewRateS(cfg, fltr, dm)
- //RateS
- rpcClientConn := make(chan rpcclient.ClientConnector, 1)
- rpcClientConn <- rates
- connMngr := engine.NewConnManager(cfg, map[string]chan rpcclient.ClientConnector{
- utils.ConcatenatedKey(utils.MetaInternal, utils.MetaRateS): rpcClientConn,
- })
- cfg.AccountSCfg().RateSConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaRateS)}
- //AccountS
- accnts := NewAccountS(cfg, fltr, connMngr, dm)
-
- accPrf := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "1002",
- FilterIDs: []string{"*string:~*req.Account:2003"},
- Balances: map[string]*utils.Balance{
- "AbstractBalance": {
- ID: "AbstractBalance",
- Type: utils.MetaAbstract,
- Units: utils.NewDecimal(1500, 0),
- Weights: []*utils.DynamicWeight{
- {
- Weight: 50,
- },
- },
- },
- "ConcreteBalance1": {
- ID: "ConcreteCalance1",
- Type: utils.MetaConcrete,
- Weights: []*utils.DynamicWeight{
- {
- Weight: 10,
- },
- },
- Units: utils.NewDecimal(20, 0),
- },
- "ConcreteBalance2": {
- ID: "ConcreteCalance2",
- Type: utils.MetaConcrete,
- Weights: []*utils.DynamicWeight{
- {
- Weight: 20,
- },
- },
- Units: utils.NewDecimal(50, 0),
- },
- },
- }
-
- if err := dm.SetAccountProfile(accPrf, true); err != nil {
- t.Error(err)
- }
-
- minDecimal, err := utils.NewDecimalFromUsage("1s")
- if err != nil {
- t.Error(err)
- }
- secDecimal, err := utils.NewDecimalFromUsage("1ns")
- if err != nil {
- t.Error(err)
- }
- rtPrf := &utils.RateProfile{
- Tenant: "cgrates.org",
- ID: "RATE_1",
- FilterIDs: []string{"*string:~*req.Account:2003"},
- Rates: map[string]*utils.Rate{
- "RT_ALWAYS": {
- ID: "RT_ALWAYS",
- FilterIDs: nil,
- ActivationTimes: "* * * * *",
- IntervalRates: []*utils.IntervalRate{
- {
- IntervalStart: utils.NewDecimal(0, 0),
- RecurrentFee: utils.NewDecimal(1, 2),
- Unit: minDecimal,
- Increment: secDecimal,
- FixedFee: utils.NewDecimal(0, 0),
- },
- },
- },
- },
- }
- if err := dm.SetRateProfile(rtPrf, true); err != nil {
- t.Error(err)
- }
-
- args := &utils.ArgsAccountsForEvent{
- CGREvent: &utils.CGREvent{
- ID: "TestV1DebitID",
- Tenant: "cgrates.org",
- Event: map[string]interface{}{
- utils.AccountField: "2003",
- utils.Usage: "300",
- },
- },
- }
-
- var reply utils.ExtEventCharges
- exEvCh := utils.ExtEventCharges{
- Abstracts: utils.Float64Pointer(300),
- }
- if err := accnts.V1DebitAbstracts(args, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(exEvCh, reply) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(exEvCh), utils.ToJSON(reply))
- }
-
- accPrf.Balances["AbstractBalance"].Units = utils.NewDecimal(1200, 0)
- accPrf.Balances["ConcreteBalance2"].Units = utils.NewDecimal(49999999997, 9)
- //as we debited, the account is changed
- if rcvAcc, err := dm.GetAccountProfile(accPrf.Tenant, accPrf.ID); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcvAcc, accPrf) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(accPrf), utils.ToJSON(rcvAcc))
- }
-
- if err := dm.RemoveAccountProfile(accPrf.Tenant, accPrf.ID,
- utils.NonTransactional, true); err != nil {
- t.Error(err)
- } else if err := dm.RemoveRateProfile(rtPrf.Tenant, rtPrf.ID,
- utils.NonTransactional, true); err != nil {
- t.Error(err)
- }
-}
-*/
-
-func TestMaxDebitAbstractFromConcretesInsufficientCredit(t *testing.T) {
- engine.Cache.Clear(nil)
- cfg := config.NewDefaultCGRConfig()
- data := engine.NewInternalDB(nil, nil, true)
- dm := engine.NewDataManager(data, cfg.CacheCfg(), nil)
- filters := engine.NewFilterS(cfg, nil, dm)
- cncrtBlncs := []*concreteBalance{
- {
- blnCfg: &utils.Balance{
- ID: "CB1",
- Type: utils.MetaAbstract,
- UnitFactors: []*utils.UnitFactor{
- {
- FilterIDs: []string{"*test"},
- Factor: utils.NewDecimal(10, 0), // EuroCents
- },
- },
- Units: utils.NewDecimal(80, 0), // 500 EuroCents
- },
- fltrS: filters,
- },
- {
- blnCfg: &utils.Balance{
- ID: "CB2",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(1, 0),
- },
- fltrS: filters,
- },
- }
-
- expectedErr := "inline parse error for string: <*test>"
- if _, err := maxDebitAbstractsFromConcretes(decimal.New(110, 0), utils.EmptyString,
- cncrtBlncs, nil, new(utils.CGREvent),
- nil, nil, nil, nil, &utils.CostIncrement{
- Increment: utils.NewDecimal(2, 0),
- RecurrentFee: utils.NewDecimal(1, 0),
- }); err == nil || err.Error() != expectedErr {
- t.Errorf("Expected %+v, received %+v", expectedErr, err)
- }
-
-}
diff --git a/actions/accounts.go b/actions/accounts.go
deleted file mode 100644
index cf0b70bb8..000000000
--- a/actions/accounts.go
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OerS) 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
-*/
-
-package actions
-
-import (
- "context"
-
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-// actSetBalance will update the account
-type actSetBalance struct {
- config *config.CGRConfig
- connMgr *engine.ConnManager
- aCfg *engine.APAction
- tnt string
- reset bool
-}
-
-func (aL *actSetBalance) id() string {
- return aL.aCfg.ID
-}
-
-func (aL *actSetBalance) cfg() *engine.APAction {
- return aL.aCfg
-}
-
-// execute implements actioner interface
-func (aL *actSetBalance) execute(ctx context.Context, data utils.MapStorage, trgID string) (err error) {
- return
-}
-
-// actRemBalance will remove multiple balances from account
-type actRemBalance struct {
- config *config.CGRConfig
- connMgr *engine.ConnManager
- aCfg *engine.APAction
- tnt string
-}
-
-func (aL *actRemBalance) id() string {
- return aL.aCfg.ID
-}
-
-func (aL *actRemBalance) cfg() *engine.APAction {
- return aL.aCfg
-}
-
-// execute implements actioner interface
-func (aL *actRemBalance) execute(ctx context.Context, data utils.MapStorage, trgID string) (err error) {
- return
-}
diff --git a/apier/v1/accountsv1_it_test.go b/apier/v1/accountsv1_it_test.go
deleted file mode 100644
index 5b9719529..000000000
--- a/apier/v1/accountsv1_it_test.go
+++ /dev/null
@@ -1,1326 +0,0 @@
-// +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
-*/
-
-package v1
-
-import (
- "net/rpc"
- "path"
- "reflect"
- "testing"
- "time"
-
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
- "github.com/ericlagergren/decimal"
-)
-
-var (
- acntSConfigDIR string //run tests for specific configuration
- acntSCfgPath string
- acntSCfg *config.CGRConfig
- acntSRPC *rpc.Client
-)
-
-//Test start here
-func TestAccountSv1IT(t *testing.T) {
- sTestsAccountS := []func(t *testing.T){
- testAccountSv1InitCfg,
- testAccountSv1InitDataDb,
- testAccountSv1ResetStorDb,
- testAccountSv1StartEngine,
- testAccountSv1RPCConn,
- testAccountSv1LoadFromFolder,
- //testAccountSv1AccountProfilesForEvent,
- //testAccountSv1MaxAbstracts,
- //testAccountSv1DebitAbstracts,
- //testAccountSv1SimpleDebit,
- //testAccountSv1DebitMultipleAcc,
- //testAccountSv1DebitMultipleAccLimited,
- testAccountSv1DebitWithAttributeSandRateS,
- //testAccountSv1DebitWithRateS,
- //testAccountSv1DebitWithRateS2,
- //testAccountSv1MaxConcretes,
- //testAccountSv1DebitConcretes,
- //testAccountSv1ActionSetBalance,
- //testAccountSv1ActionRemoveBalance,
- testAccountSv1KillEngine,
- }
- switch *dbType {
- case utils.MetaInternal:
- acntSConfigDIR = "accounts_internal"
- case utils.MetaMySQL:
- t.SkipNow()
- case utils.MetaMongo:
- t.SkipNow()
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatalf("unknown Database type <%s>", *dbType)
- }
- for _, stest := range sTestsAccountS {
- t.Run(acntSConfigDIR, stest)
- }
-}
-
-func testAccountSv1InitCfg(t *testing.T) {
- var err error
- acntSCfgPath = path.Join(*dataDir, "conf", "samples", acntSConfigDIR)
- acntSCfg, err = config.NewCGRConfigFromPath(acntSCfgPath)
- if err != nil {
- t.Error(err)
- }
-}
-
-func testAccountSv1InitDataDb(t *testing.T) {
- if err := engine.InitDataDb(acntSCfg); err != nil {
- t.Fatal(err)
- }
-}
-
-// Wipe out the cdr database
-func testAccountSv1ResetStorDb(t *testing.T) {
- if err := engine.InitStorDb(acntSCfg); err != nil {
- t.Fatal(err)
- }
-}
-
-// Start CGR Engine
-func testAccountSv1StartEngine(t *testing.T) {
- if _, err := engine.StopStartEngine(acntSCfgPath, *waitRater); err != nil {
- t.Fatal(err)
- }
-}
-
-// Connect rpc client to rater
-func testAccountSv1RPCConn(t *testing.T) {
- var err error
- acntSRPC, err = newRPCClient(acntSCfg.ListenCfg()) // We connect over JSON so we can also troubleshoot if needed
- if err != nil {
- t.Fatal(err)
- }
-}
-
-func testAccountSv1LoadFromFolder(t *testing.T) {
- var reply string
- attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutaccounts")}
- if err := acntSRPC.Call(utils.APIerSv1LoadTariffPlanFromFolder, attrs, &reply); err != nil {
- t.Error(err)
- }
- time.Sleep(100 * time.Millisecond)
-}
-
-func testAccountSv1AccountProfilesForEvent(t *testing.T) {
- eAcnts := []*utils.AccountProfile{
- {
- Tenant: "cgrates.org",
- ID: "1001",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Balances: map[string]*utils.Balance{
- "GenericBalance1": &utils.Balance{
- ID: "GenericBalance1",
- Weights: utils.DynamicWeights{
- {
- Weight: 20,
- },
- },
- Type: utils.MetaAbstract,
- Units: &utils.Decimal{decimal.New(int64(time.Hour), 0)},
- UnitFactors: []*utils.UnitFactor{
- &utils.UnitFactor{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Factor: &utils.Decimal{decimal.New(1024, 3)},
- },
- },
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*voice"},
- Increment: &utils.Decimal{decimal.New(int64(time.Second), 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 2)},
- },
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(1024, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 2)},
- },
- },
- },
- "MonetaryBalance1": &utils.Balance{
- ID: "MonetaryBalance1",
- Weights: utils.DynamicWeights{
- {
- Weight: 30,
- },
- },
- Type: utils.MetaConcrete,
- Units: &utils.Decimal{decimal.New(5, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*voice"},
- Increment: &utils.Decimal{decimal.New(int64(time.Second), 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 2)},
- },
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(1024, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 2)},
- },
- },
- },
- "MonetaryBalance2": &utils.Balance{
- ID: "MonetaryBalance2",
- Weights: utils.DynamicWeights{
- {
- Weight: 10,
- },
- },
- Type: utils.MetaConcrete,
- Units: &utils.Decimal{decimal.New(3, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*voice"},
- Increment: &utils.Decimal{decimal.New(int64(time.Second), 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 0)},
- },
- },
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- },
- }
- var acnts []*utils.AccountProfile
- if err := acntSRPC.Call(utils.AccountSv1AccountProfilesForEvent,
- &utils.ArgsAccountsForEvent{
- CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAccountSv1AccountProfileForEvent",
- Event: map[string]interface{}{
- utils.AccountField: "1001",
- }}}, &acnts); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eAcnts, acnts) {
- t.Errorf("Expecting : %s \n received: %s", utils.ToJSON(eAcnts), utils.ToJSON(acnts))
- }
-}
-
-func testAccountSv1MaxAbstracts(t *testing.T) {
- var eEc *utils.ExtEventCharges
- if err := acntSRPC.Call(utils.AccountSv1MaxAbstracts,
- &utils.ArgsAccountsForEvent{CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAccountSv1MaxUsage",
- Event: map[string]interface{}{
- utils.AccountField: "1001",
- utils.ToR: utils.MetaVoice,
- utils.Usage: "15m",
- }}}, &eEc); err != nil {
- t.Error(err)
- } else if eEc.Abstracts == nil || *eEc.Abstracts != 800000000000.0 { // 500s from first monetary + 300s from last monetary
- t.Errorf("received usage: %v", *eEc.Abstracts)
- }
-
- // Make sure we did not Debit anything from Account
- eAcnt := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "1001",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Balances: map[string]*utils.Balance{
- "GenericBalance1": &utils.Balance{
- ID: "GenericBalance1",
- Weights: utils.DynamicWeights{
- {
- Weight: 20,
- },
- },
- Type: utils.MetaAbstract,
- Units: &utils.Decimal{decimal.New(int64(time.Hour), 0)},
- UnitFactors: []*utils.UnitFactor{
- &utils.UnitFactor{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Factor: &utils.Decimal{decimal.New(1024, 3)},
- },
- },
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*voice"},
- Increment: &utils.Decimal{decimal.New(int64(time.Second), 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 2)},
- },
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(1024, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 2)},
- },
- },
- },
- "MonetaryBalance1": &utils.Balance{
- ID: "MonetaryBalance1",
- Weights: utils.DynamicWeights{
- {
- Weight: 30,
- },
- },
- Type: utils.MetaConcrete,
- Units: &utils.Decimal{decimal.New(5, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*voice"},
- Increment: &utils.Decimal{decimal.New(int64(time.Second), 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 2)},
- },
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(1024, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 2)},
- },
- },
- },
- "MonetaryBalance2": &utils.Balance{
- ID: "MonetaryBalance2",
- Weights: utils.DynamicWeights{
- {
- Weight: 10,
- },
- },
- Type: utils.MetaConcrete,
- Units: &utils.Decimal{decimal.New(3, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*voice"},
- Increment: &utils.Decimal{decimal.New(int64(time.Second), 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 0)},
- },
- },
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- }
-
- var reply *utils.AccountProfile
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile,
- utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1001"}}, &reply); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(eAcnt, reply) {
- t.Errorf("Expecting : %+v \n received: %+v", utils.ToJSON(eAcnt), utils.ToJSON(reply))
- }
-}
-
-func testAccountSv1DebitAbstracts(t *testing.T) {
- var eEc *utils.ExtEventCharges
- if err := acntSRPC.Call(utils.AccountSv1DebitAbstracts,
- &utils.ArgsAccountsForEvent{CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAccountSv1MaxUsage",
- Event: map[string]interface{}{
- utils.AccountField: "1001",
- utils.ToR: utils.MetaVoice,
- utils.Usage: "15m",
- }}}, &eEc); err != nil {
- t.Error(err)
- } else if eEc.Abstracts == nil || *eEc.Abstracts != 800000000000.0 { // 500s from first monetary + 300s from last monetary
- t.Fatalf("received usage: %v", *eEc.Abstracts)
- }
-
- // Make sure we debit the right units from Account
- eAcnt := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "1001",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Balances: map[string]*utils.Balance{
- "GenericBalance1": &utils.Balance{
- ID: "GenericBalance1",
- Weights: utils.DynamicWeights{
- {
- Weight: 20,
- },
- },
- Type: utils.MetaAbstract,
- Units: &utils.Decimal{decimal.New(int64(3300*time.Second), 0)},
- UnitFactors: []*utils.UnitFactor{
- &utils.UnitFactor{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Factor: &utils.Decimal{decimal.New(1024, 3)},
- },
- },
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*voice"},
- Increment: &utils.Decimal{decimal.New(int64(time.Second), 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 2)},
- },
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(1024, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 2)},
- },
- },
- },
- "MonetaryBalance1": &utils.Balance{
- ID: "MonetaryBalance1",
- Weights: utils.DynamicWeights{
- {
- Weight: 30,
- },
- },
- Type: utils.MetaConcrete,
- Units: &utils.Decimal{decimal.New(0, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*voice"},
- Increment: &utils.Decimal{decimal.New(int64(time.Second), 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 2)},
- },
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(1024, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 2)},
- },
- },
- },
- "MonetaryBalance2": &utils.Balance{
- ID: "MonetaryBalance2",
- Weights: utils.DynamicWeights{
- {
- Weight: 10,
- },
- },
- Type: utils.MetaConcrete,
- Units: &utils.Decimal{decimal.New(0, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*voice"},
- Increment: &utils.Decimal{decimal.New(int64(time.Second), 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 0)},
- },
- },
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- }
-
- var reply *utils.AccountProfile
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile,
- utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1001"}}, &reply); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(eAcnt, reply) {
- t.Errorf("Expecting : %+v \n received: %+v", utils.ToJSON(eAcnt), utils.ToJSON(reply))
- }
-}
-
-func testAccountSv1SimpleDebit(t *testing.T) {
- accPrfAPI := &utils.APIAccountProfileWithOpts{
- APIAccountProfile: &utils.APIAccountProfile{
- Tenant: "cgrates.org",
- ID: "CustomAccount",
- FilterIDs: []string{"*string:~*req.Account:CustomAccount"},
- Weights: ";10",
- Balances: map[string]*utils.APIBalance{
- "Balance1": &utils.APIBalance{
- ID: "Balance1",
- Weights: ";10",
- Type: utils.MetaConcrete,
- Units: 100,
- CostIncrements: []*utils.APICostIncrement{
- {
- Increment: utils.Float64Pointer(1),
- RecurrentFee: utils.Float64Pointer(0.1),
- },
- },
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- },
- }
- var result string
- expErr := utils.ErrNotFound.Error()
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount"}}, &result); err == nil || err.Error() != expErr {
- t.Errorf("Expected error: %v received: %v", expErr, err)
- }
- var reply string
- if err := acntSRPC.Call(utils.APIerSv1SetAccountProfile, accPrfAPI, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Error("Unexpected reply returned", reply)
- }
- var err error
- var convAcc *utils.AccountProfile
- if convAcc, err = accPrfAPI.AsAccountProfile(); err != nil {
- t.Error(err)
- }
- var reply2 *utils.AccountProfile
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount"}}, &reply2); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(convAcc, reply2) {
- t.Errorf("Expecting : %+v, received: %+v", convAcc, reply2)
- }
-
- var eEc *utils.ExtEventCharges
- if err := acntSRPC.Call(utils.AccountSv1DebitAbstracts,
- &utils.ArgsAccountsForEvent{CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAccountSv1SimpleDebit",
- Event: map[string]interface{}{
- utils.AccountField: "CustomAccount",
- utils.Usage: "10",
- }}}, &eEc); err != nil {
- t.Error(err)
- } else if eEc.Abstracts == nil || *eEc.Abstracts != 10.0 {
- t.Fatalf("received usage: %v", *eEc.Abstracts)
- }
-
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount"}}, &reply2); err != nil {
- t.Error(err)
- } else if reply2.Balances["Balance1"].Units.Cmp(decimal.New(99, 0)) != 0 {
- t.Errorf("Expecting : %+v, received: %s", decimal.New(99, 0), reply2.Balances["Balance1"].Units)
- }
-}
-
-func testAccountSv1DebitMultipleAcc(t *testing.T) {
- accPrfAPI := &utils.APIAccountProfileWithOpts{
- APIAccountProfile: &utils.APIAccountProfile{
- Tenant: "cgrates.org",
- ID: "CustomAccount",
- FilterIDs: []string{"*string:~*req.Account:CustomAccount"},
- Weights: ";20",
- Balances: map[string]*utils.APIBalance{
- "Balance1": &utils.APIBalance{
- ID: "Balance1",
- Weights: ";10",
- Type: utils.MetaConcrete,
- Units: 100,
- CostIncrements: []*utils.APICostIncrement{
- {
- Increment: utils.Float64Pointer(1),
- RecurrentFee: utils.Float64Pointer(0.1),
- },
- },
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- },
- }
- var reply string
- if err := acntSRPC.Call(utils.APIerSv1SetAccountProfile, accPrfAPI, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Error("Unexpected reply returned", reply)
- }
- var err error
- var convAcc *utils.AccountProfile
- if convAcc, err = accPrfAPI.AsAccountProfile(); err != nil {
- t.Error(err)
- }
- var reply2 *utils.AccountProfile
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount"}}, &reply2); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(convAcc, reply2) {
- t.Errorf("Expecting : %+v, received: %+v", convAcc, reply2)
- }
-
- accPrfAPI2 := &utils.APIAccountProfileWithOpts{
- APIAccountProfile: &utils.APIAccountProfile{
- Tenant: "cgrates.org",
- ID: "CustomAccount2",
- FilterIDs: []string{"*string:~*req.Account:CustomAccount"},
- Weights: ";10",
- Balances: map[string]*utils.APIBalance{
- "Balance1": &utils.APIBalance{
- ID: "Balance1",
- Weights: ";10",
- Type: utils.MetaConcrete,
- Units: 50,
- CostIncrements: []*utils.APICostIncrement{
- {
- Increment: utils.Float64Pointer(1),
- RecurrentFee: utils.Float64Pointer(0.1),
- },
- },
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- },
- }
- if err := acntSRPC.Call(utils.APIerSv1SetAccountProfile, accPrfAPI2, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Error("Unexpected reply returned", reply)
- }
- var convAcc2 *utils.AccountProfile
- if convAcc2, err = accPrfAPI2.AsAccountProfile(); err != nil {
- t.Fatal(err)
- }
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount2"}}, &reply2); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(convAcc2, reply2) {
- t.Errorf("Expecting : %+v, received: %+v", convAcc2, reply2)
- }
-
- var eEc *utils.ExtEventCharges
- if err := acntSRPC.Call(utils.AccountSv1DebitAbstracts,
- &utils.ArgsAccountsForEvent{CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAccountSv1SimpleDebit",
- Event: map[string]interface{}{
- utils.AccountField: "CustomAccount",
- utils.Usage: "1400",
- }}}, &eEc); err != nil {
- t.Error(err)
- } else if eEc.Abstracts == nil || *eEc.Abstracts != 1400.0 {
- t.Fatalf("received usage: %v", *eEc.Abstracts)
- }
-
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount"}}, &reply2); err != nil {
- t.Error(err)
- } else if reply2.Balances["Balance1"].Units.Cmp(decimal.New(0, 0)) != 0 {
- t.Errorf("Expecting : %s, received: %s", decimal.New(0, 0), reply2.Balances["Balance1"].Units)
- }
-
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount2"}}, &reply2); err != nil {
- t.Error(err)
- } else if reply2.Balances["Balance1"].Units.Cmp(decimal.New(10, 0)) != 0 {
- t.Errorf("Expecting : %s, received: %s", decimal.New(10, 0), reply2.Balances["Balance1"].Units)
- }
-}
-
-func testAccountSv1DebitMultipleAccLimited(t *testing.T) {
- accPrfAPI := &utils.APIAccountProfileWithOpts{
- APIAccountProfile: &utils.APIAccountProfile{
- Tenant: "cgrates.org",
- ID: "CustomAccount",
- FilterIDs: []string{"*string:~*req.Account:CustomAccount"},
- Weights: ";20",
- Balances: map[string]*utils.APIBalance{
- "Balance1": &utils.APIBalance{
- ID: "Balance1",
- Weights: ";10",
- Type: utils.MetaConcrete,
- Units: 100,
- Opts: map[string]interface{}{
- utils.MetaBalanceLimit: 50.0,
- },
- CostIncrements: []*utils.APICostIncrement{
- {
- Increment: utils.Float64Pointer(1),
- RecurrentFee: utils.Float64Pointer(0.1),
- },
- },
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- },
- }
- var reply string
- if err := acntSRPC.Call(utils.APIerSv1SetAccountProfile, accPrfAPI, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Error("Unexpected reply returned", reply)
- }
- var err error
- var convAcc *utils.AccountProfile
- if convAcc, err = accPrfAPI.AsAccountProfile(); err != nil {
- t.Error(err)
- }
- var reply2 *utils.AccountProfile
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount"}}, &reply2); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(convAcc, reply2) {
- t.Errorf("Expecting : %+v, received: %+v", convAcc, reply2)
- }
-
- accPrfAPI2 := &utils.APIAccountProfileWithOpts{
- APIAccountProfile: &utils.APIAccountProfile{
- Tenant: "cgrates.org",
- ID: "CustomAccount2",
- FilterIDs: []string{"*string:~*req.Account:CustomAccount"},
- Weights: ";10",
- Balances: map[string]*utils.APIBalance{
- "Balance1": &utils.APIBalance{
- ID: "Balance1",
- Weights: ";10",
- Type: utils.MetaConcrete,
- Units: 50,
- CostIncrements: []*utils.APICostIncrement{
- {
- Increment: utils.Float64Pointer(1),
- RecurrentFee: utils.Float64Pointer(0.1),
- },
- },
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- },
- }
- if err := acntSRPC.Call(utils.APIerSv1SetAccountProfile, accPrfAPI2, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Error("Unexpected reply returned", reply)
- }
- var convAcc2 *utils.AccountProfile
- if convAcc2, err = accPrfAPI2.AsAccountProfile(); err != nil {
- t.Fatal(err)
- }
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount2"}}, &reply2); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(convAcc2, reply2) {
- t.Errorf("Expecting : %+v, received: %+v", convAcc2, reply2)
- }
-
- var eEc *utils.ExtEventCharges
- if err := acntSRPC.Call(utils.AccountSv1DebitAbstracts,
- &utils.ArgsAccountsForEvent{CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAccountSv1SimpleDebit",
- Event: map[string]interface{}{
- utils.AccountField: "CustomAccount",
- utils.Usage: "900",
- }}}, &eEc); err != nil {
- t.Error(err)
- } else if eEc.Abstracts == nil || *eEc.Abstracts != 900.0 {
- t.Fatalf("received usage: %v", *eEc.Abstracts)
- }
-
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount"}}, &reply2); err != nil {
- t.Error(err)
- } else if reply2.Balances["Balance1"].Units.Cmp(decimal.New(50, 0)) != 0 {
- t.Errorf("Expecting : %s, received: %s", decimal.New(50, 0), reply2.Balances["Balance1"].Units)
- }
-
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "CustomAccount2"}}, &reply2); err != nil {
- t.Error(err)
- } else if reply2.Balances["Balance1"].Units.Cmp(decimal.New(10, 0)) != 0 {
- t.Errorf("Expecting : %s, received: %s", decimal.New(10, 0), reply2.Balances["Balance1"].Units)
- }
-}
-
-func testAccountSv1DebitWithAttributeSandRateS(t *testing.T) {
- accPrfAPI := &utils.APIAccountProfileWithOpts{
- APIAccountProfile: &utils.APIAccountProfile{
- Tenant: "cgrates.org",
- ID: "ACC_WITH_ATTRIBUTES",
- FilterIDs: []string{"*string:~*req.Account:ACC_WITH_ATTRIBUTES"},
- Weights: ";10",
- Balances: map[string]*utils.APIBalance{
- "Balance1": &utils.APIBalance{
- ID: "Balance1",
- Weights: ";10",
- Type: utils.MetaConcrete,
- Units: 100,
- CostIncrements: []*utils.APICostIncrement{
- {
- Increment: utils.Float64Pointer(1),
- RecurrentFee: utils.Float64Pointer(-1),
- },
- },
- AttributeIDs: []string{"*constant:*req.CustomField:CustomValue"},
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- },
- }
- var reply string
- if err := acntSRPC.Call(utils.APIerSv1SetAccountProfile, accPrfAPI, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Error("Unexpected reply returned", reply)
- }
- var err error
- var convAcc *utils.AccountProfile
- if convAcc, err = accPrfAPI.AsAccountProfile(); err != nil {
- t.Error(err)
- }
- var reply2 *utils.AccountProfile
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ACC_WITH_ATTRIBUTES"}}, &reply2); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(convAcc, reply2) {
- t.Errorf("Expecting : %+v, received: %+v", convAcc, reply2)
- }
-
- var eEc *utils.ExtEventCharges
- if err := acntSRPC.Call(utils.AccountSv1DebitAbstracts,
- &utils.ArgsAccountsForEvent{CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAccountSv1DebitWithAttributeS",
- Event: map[string]interface{}{
- utils.AccountField: "ACC_WITH_ATTRIBUTES",
- utils.Usage: "10",
- }}}, &eEc); err != nil {
- t.Error(err)
- } else if eEc.Abstracts == nil || *eEc.Abstracts != 10.0 {
- t.Fatalf("received usage: %v", *eEc.Abstracts)
- }
-
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ACC_WITH_ATTRIBUTES"}}, &reply2); err != nil {
- t.Error(err)
- } else if reply2.Balances["Balance1"].Units.Cmp(decimal.New(99, 0)) != 0 {
- t.Errorf("Expecting : %+v, received: %s", decimal.New(99, 0), reply2.Balances["Balance1"].Units)
- }
-}
-
-func testAccountSv1DebitWithRateS(t *testing.T) {
- accPrfAPI := &utils.APIAccountProfileWithOpts{
- APIAccountProfile: &utils.APIAccountProfile{
- Tenant: "cgrates.org",
- ID: "ACC_WITH_RATES",
- FilterIDs: []string{"*string:~*req.Account:ACC_WITH_RATES"},
- Weights: ";10",
- Balances: map[string]*utils.APIBalance{
- "Balance1": &utils.APIBalance{
- ID: "Balance1",
- Weights: ";10",
- Type: utils.MetaConcrete,
- Units: 100,
- CostIncrements: []*utils.APICostIncrement{
- {
- Increment: utils.Float64Pointer(1),
- RecurrentFee: utils.Float64Pointer(-1),
- },
- },
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- },
- }
- var reply string
- if err := acntSRPC.Call(utils.APIerSv1SetAccountProfile, accPrfAPI, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Error("Unexpected reply returned", reply)
- }
- var err error
- var convAcc *utils.AccountProfile
- if convAcc, err = accPrfAPI.AsAccountProfile(); err != nil {
- t.Error(err)
- }
- var reply2 *utils.AccountProfile
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ACC_WITH_RATES"}}, &reply2); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(convAcc, reply2) {
- t.Errorf("Expecting : %+v, received: %+v", convAcc, reply2)
- }
-
- var eEc *utils.ExtEventCharges
- if err := acntSRPC.Call(utils.AccountSv1DebitAbstracts,
- &utils.ArgsAccountsForEvent{CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAccountSv1DebitWithAttributeS",
- Event: map[string]interface{}{
- utils.AccountField: "ACC_WITH_RATES",
- utils.Usage: "20",
- }}}, &eEc); err != nil {
- t.Error(err)
- } else if eEc.Abstracts == nil || *eEc.Abstracts != 20.0 {
- t.Fatalf("received usage: %v", *eEc.Abstracts)
- }
-
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ACC_WITH_RATES"}}, &reply2); err != nil {
- t.Error(err)
- } else if reply2.Balances["Balance1"].Units.Cmp(decimal.New(95, 0)) != 0 {
- t.Errorf("Expecting : %+v, received: %s", decimal.New(95, 0), reply2.Balances["Balance1"].Units)
- }
-}
-
-func testAccountSv1DebitWithRateS2(t *testing.T) {
- accPrfAPI := &utils.APIAccountProfileWithOpts{
- APIAccountProfile: &utils.APIAccountProfile{
- Tenant: "cgrates.org",
- ID: "ACC_WITH_RATES2",
- FilterIDs: []string{"*string:~*req.Account:ACC_WITH_RATES2"},
- Weights: ";10",
- Balances: map[string]*utils.APIBalance{
- "Balance1": &utils.APIBalance{
- ID: "Balance1",
- Weights: ";10",
- Type: utils.MetaAbstract,
- Units: 100,
- CostIncrements: []*utils.APICostIncrement{
- {
- Increment: utils.Float64Pointer(1),
- RecurrentFee: utils.Float64Pointer(-1),
- },
- },
- },
- "Balance2": &utils.APIBalance{
- ID: "Balance2",
- Weights: ";10",
- Type: utils.MetaConcrete,
- Units: 100,
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- },
- }
- var reply string
- if err := acntSRPC.Call(utils.APIerSv1SetAccountProfile, accPrfAPI, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Error("Unexpected reply returned", reply)
- }
- var err error
- var convAcc *utils.AccountProfile
- if convAcc, err = accPrfAPI.AsAccountProfile(); err != nil {
- t.Error(err)
- }
- var reply2 *utils.AccountProfile
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ACC_WITH_RATES2"}}, &reply2); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(convAcc, reply2) {
- t.Errorf("Expecting : %+v, received: %+v", convAcc, reply2)
- }
-
- var eEc *utils.ExtEventCharges
- if err := acntSRPC.Call(utils.AccountSv1DebitAbstracts,
- &utils.ArgsAccountsForEvent{CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAccountSv1DebitWithAttributeS",
- Event: map[string]interface{}{
- utils.AccountField: "ACC_WITH_RATES2",
- utils.Usage: "20",
- }}}, &eEc); err != nil {
- t.Error(err)
- } else if eEc.Abstracts == nil || *eEc.Abstracts != 20.0 {
- t.Fatalf("received usage: %v", *eEc.Abstracts)
- }
-
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ACC_WITH_RATES2"}}, &reply2); err != nil {
- t.Error(err)
- } else if reply2.Balances["Balance1"].Units.Cmp(decimal.New(80, 0)) != 0 {
- t.Errorf("Expecting : %+v, received: %s", decimal.New(80, 0), reply2.Balances["Balance1"].Units)
- }
-}
-
-func testAccountSv1MaxConcretes(t *testing.T) {
- apiAccPrf = &utils.APIAccountProfileWithOpts{
- APIAccountProfile: &utils.APIAccountProfile{
- Tenant: "cgrates.org",
- ID: "1004",
- FilterIDs: []string{"*string:~*req.Account:1004"},
- Balances: map[string]*utils.APIBalance{
- "ConcreteBalance1": &utils.APIBalance{
- ID: "ConcreteBalance1",
- Weights: ";20",
- Type: utils.MetaConcrete,
- Units: 21,
- CostIncrements: []*utils.APICostIncrement{
- &utils.APICostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: utils.Float64Pointer(1),
- FixedFee: utils.Float64Pointer(0),
- RecurrentFee: utils.Float64Pointer(1),
- },
- },
- },
- "ConcreteBalance2": &utils.APIBalance{
- ID: "ConcreteBalance2",
- Weights: ";10",
- Type: utils.MetaConcrete,
- Units: 20,
- CostIncrements: []*utils.APICostIncrement{
- &utils.APICostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: utils.Float64Pointer(1),
- FixedFee: utils.Float64Pointer(0),
- RecurrentFee: utils.Float64Pointer(1),
- },
- },
- },
- "AbstractBalance1": &utils.APIBalance{
- ID: "AbstractBalance1",
- Weights: ";5",
- Type: utils.MetaAbstract,
- Units: 20,
- CostIncrements: []*utils.APICostIncrement{
- &utils.APICostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: utils.Float64Pointer(float64(time.Second)),
- FixedFee: utils.Float64Pointer(0),
- RecurrentFee: utils.Float64Pointer(1),
- },
- },
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- },
- }
-
- var reply string
- if err := acntSRPC.Call(utils.APIerSv1SetAccountProfile, apiAccPrf, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Error("Unexpected reply returned", reply)
- }
-
- exp, err := apiAccPrf.AsAccountProfile()
- if err != nil {
- t.Error(err)
- }
- var result *utils.AccountProfile
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1004"}}, &result); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(exp, result) {
- t.Errorf("Expected %+v\n, received %+v", utils.ToJSON(exp), utils.ToJSON(result))
- }
-
- var eEc *utils.ExtEventCharges
- if err := acntSRPC.Call(utils.AccountSv1MaxConcretes,
- &utils.ArgsAccountsForEvent{CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAccountSv1MaxConcretes",
- Event: map[string]interface{}{
- utils.AccountField: "1004",
- utils.ToR: utils.MetaData,
- utils.Usage: "50ns",
- },
- }}, &eEc); err != nil {
- t.Error(err)
- } else if eEc.Concretes == nil || *eEc.Concretes != 41 {
- t.Errorf("received usage: %v", *eEc.Concretes)
- }
-
- //make sure we did not Debit from our Account
- exp, err = apiAccPrf.AsAccountProfile()
- if err != nil {
- t.Error(err)
- }
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1004"}}, &result); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(exp, result) {
- t.Errorf("Expected %+v\n, received %+v", utils.ToJSON(exp), utils.ToJSON(result))
- }
-}
-func testAccountSv1DebitConcretes(t *testing.T) {
- var eEc *utils.ExtEventCharges
- //Now we know the usage, we will debit it from account
- if err := acntSRPC.Call(utils.AccountSv1DebitConcretes,
- &utils.ArgsAccountsForEvent{CGREvent: &utils.CGREvent{
- Tenant: "cgrates.org",
- ID: "testAccountSv1MaxConcretes",
- Event: map[string]interface{}{
- utils.AccountField: "1004",
- utils.ToR: utils.MetaData,
- utils.Usage: "50ns",
- },
- }}, &eEc); err != nil {
- t.Error(err)
- } else if eEc.Concretes == nil || *eEc.Concretes != 41 {
- t.Errorf("received usage: %v", *eEc.Concretes)
- }
-
- exp := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "1004",
- FilterIDs: []string{"*string:~*req.Account:1004"},
- Balances: map[string]*utils.Balance{
- "ConcreteBalance1": &utils.Balance{
- ID: "ConcreteBalance1",
- Weights: utils.DynamicWeights{
- {
- Weight: 20,
- },
- },
- Type: utils.MetaConcrete,
- Units: &utils.Decimal{decimal.New(0, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(1, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 0)},
- },
- },
- },
- "ConcreteBalance2": &utils.Balance{
- ID: "ConcreteBalance2",
- Weights: utils.DynamicWeights{
- {
- Weight: 10,
- },
- },
- Type: utils.MetaConcrete,
- Units: &utils.Decimal{decimal.New(0, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(1, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 0)},
- },
- },
- },
- "AbstractBalance1": &utils.Balance{
- ID: "AbstractBalance1",
- Weights: utils.DynamicWeights{
- {
- Weight: 5,
- },
- },
- Type: utils.MetaAbstract,
- Units: &utils.Decimal{decimal.New(20, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(int64(time.Second), 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 0)},
- },
- },
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- }
-
- var result *utils.AccountProfile
- //As we debit, our Account balances are changed now
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1004"}}, &result); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(exp, result) {
- t.Errorf("Expected %+v\n, received %+v", utils.ToJSON(exp), utils.ToJSON(result))
- }
-}
-
-func testAccountSv1ActionSetBalance(t *testing.T) {
- expectedSetBalance := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "1004",
- FilterIDs: []string{"*string:~*req.Account:1004"},
- Balances: map[string]*utils.Balance{
- "ConcreteBalance1": &utils.Balance{
- ID: "ConcreteBalance1",
- Weights: utils.DynamicWeights{
- {
- FilterIDs: []string{"fltr1", "fltr2"},
- Weight: 20,
- },
- {
- FilterIDs: []string{"fltr1"},
- Weight: 30,
- },
- },
- Type: utils.MetaConcrete,
- Units: &utils.Decimal{decimal.New(0, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(1, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 0)},
- },
- },
- },
- "ConcreteBalance2": &utils.Balance{
- ID: "ConcreteBalance2",
- Weights: utils.DynamicWeights{
- {
- Weight: 10,
- },
- },
- Type: utils.MetaConcrete,
- Units: &utils.Decimal{decimal.New(0, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(1, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 0)},
- },
- },
- },
- "AbstractBalance1": &utils.Balance{
- ID: "AbstractBalance1",
- Weights: utils.DynamicWeights{
- {
- Weight: 5,
- },
- },
- Type: utils.MetaAbstract,
- Units: &utils.Decimal{decimal.New(120, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(int64(time.Second), 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 0)},
- },
- },
- },
- },
- ThresholdIDs: []string{"TH_ID1"},
- }
- var reply string
- if err := acntSRPC.Call(utils.AccountSv1ActionSetBalance, &utils.ArgsActSetBalance{
- Tenant: "cgrates.org", AccountID: "1004",
- Diktats: []*utils.BalDiktat{
- {
- Path: "*account.ThresholdIDs",
- Value: "TH_ID1",
- },
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Errorf("Unexpected reply returned")
- }
- if err := acntSRPC.Call(utils.AccountSv1ActionSetBalance, &utils.ArgsActSetBalance{
- Tenant: "cgrates.org", AccountID: "1004",
- Diktats: []*utils.BalDiktat{
- {
- Path: "*balance.AbstractBalance1.Units",
- Value: "120",
- },
- },
- Reset: true,
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Errorf("Unexpected reply returned")
- }
- if err := acntSRPC.Call(utils.AccountSv1ActionSetBalance, &utils.ArgsActSetBalance{
- Tenant: "cgrates.org", AccountID: "1004",
- Diktats: []*utils.BalDiktat{
- {
- Path: "*balance.ConcreteBalance1.Weights",
- Value: "fltr1&fltr2;20;fltr1;30",
- },
- },
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Errorf("Unexpected reply returned")
- }
-
- var result *utils.AccountProfile
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1004"}}, &result); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expectedSetBalance, result) {
- t.Errorf("Expected %+v\n, received %+v", utils.ToJSON(expectedSetBalance), utils.ToJSON(result))
- }
-}
-
-func testAccountSv1ActionRemoveBalance(t *testing.T) {
- var reply string
- if err := acntSRPC.Call(utils.AccountSv1ActionRemoveBalance, &utils.ArgsActRemoveBalances{
- Tenant: "cgrates.org", AccountID: "1004",
- BalanceIDs: []string{"AbstractBalance1"},
- }, &reply); err != nil {
- t.Error(err)
- } else if reply != utils.OK {
- t.Errorf("Unexpected reply returned")
- }
-
- expectedSetBalance := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "1004",
- FilterIDs: []string{"*string:~*req.Account:1004"},
- Balances: map[string]*utils.Balance{
- "ConcreteBalance1": &utils.Balance{
- ID: "ConcreteBalance1",
- Weights: utils.DynamicWeights{
- {
- FilterIDs: []string{"fltr1", "fltr2"},
- Weight: 20,
- },
- {
- FilterIDs: []string{"fltr1"},
- Weight: 30,
- },
- },
- Type: utils.MetaConcrete,
- Units: &utils.Decimal{decimal.New(0, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(1, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 0)},
- },
- },
- },
- "ConcreteBalance2": &utils.Balance{
- ID: "ConcreteBalance2",
- Weights: utils.DynamicWeights{
- {
- Weight: 10,
- },
- },
- Type: utils.MetaConcrete,
- Units: &utils.Decimal{decimal.New(0, 0)},
- CostIncrements: []*utils.CostIncrement{
- &utils.CostIncrement{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: &utils.Decimal{decimal.New(1, 0)},
- FixedFee: &utils.Decimal{decimal.New(0, 0)},
- RecurrentFee: &utils.Decimal{decimal.New(1, 0)},
- },
- },
- },
- },
- ThresholdIDs: []string{"TH_ID1"},
- }
-
- var result *utils.AccountProfile
- if err := acntSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1004"}}, &result); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expectedSetBalance, result) {
- t.Errorf("Expected %+v\n, received %+v", utils.ToJSON(expectedSetBalance), utils.ToJSON(result))
- }
-}
-
-func testAccountSv1KillEngine(t *testing.T) {
- if err := engine.KillEngine(100); err != nil {
- t.Error(err)
- }
-}
diff --git a/apier/v1/tprateprofiles_it_test.go b/apier/v1/tprateprofiles_it_test.go
deleted file mode 100644
index 741ecb096..000000000
--- a/apier/v1/tprateprofiles_it_test.go
+++ /dev/null
@@ -1,232 +0,0 @@
-// +build offline
-
-/*
-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
-*/
-
-package v1
-
-import (
- "net/rpc"
- "net/rpc/jsonrpc"
- "path"
- "reflect"
- "sort"
- "testing"
-
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var (
- tpRatePrfCfgPath string
- tpRatePrfCfg *config.CGRConfig
- tpRatePrfRPC *rpc.Client
- tpRatePrf *utils.TPRateProfile
- tpRatePrfDelay int
- tpRatePrfConfigDIR string //run tests for specific configuration
-)
-
-var sTestsTPRatePrf = []func(t *testing.T){
- testTPRatePrfInitCfg,
- testTPRatePrfResetStorDb,
- testTPRatePrfStartEngine,
- testTPRatePrfRPCConn,
- testTPRatePrfGetTPRatePrfBeforeSet,
- testTPRatePrfSetTPRatePrf,
- testTPRatePrfGetTPRatePrfAfterSet,
- testTPRatePrfGetTPRatePrfIDs,
- testTPRatePrfUpdateTPRatePrf,
- testTPRatePrfGetTPRatePrfAfterUpdate,
- testTPRatePrfRemTPRatePrf,
- testTPRatePrfKillEngine,
-}
-
-//Test start here
-func TestTPRatePrfIT(t *testing.T) {
- switch *dbType {
- case utils.MetaInternal:
- tpRatePrfConfigDIR = "tutinternal"
- case utils.MetaMySQL:
- tpRatePrfConfigDIR = "tutmysql"
- case utils.MetaMongo:
- tpRatePrfConfigDIR = "tutmongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
- for _, stest := range sTestsTPRatePrf {
- t.Run(tpRatePrfConfigDIR, stest)
- }
-}
-
-func testTPRatePrfInitCfg(t *testing.T) {
- var err error
- tpRatePrfCfgPath = path.Join(*dataDir, "conf", "samples", tpRatePrfConfigDIR)
- tpRatePrfCfg, err = config.NewCGRConfigFromPath(tpRatePrfCfgPath)
- if err != nil {
- t.Error(err)
- }
- tpRatePrfDelay = 1000
-}
-
-// Wipe out the cdr database
-func testTPRatePrfResetStorDb(t *testing.T) {
- if err := engine.InitStorDb(tpRatePrfCfg); err != nil {
- t.Fatal(err)
- }
-}
-
-// Start CGR Engine
-func testTPRatePrfStartEngine(t *testing.T) {
- if _, err := engine.StopStartEngine(tpRatePrfCfgPath, tpRatePrfDelay); err != nil {
- t.Fatal(err)
- }
-}
-
-// Connect rpc client to rater
-func testTPRatePrfRPCConn(t *testing.T) {
- var err error
- tpRatePrfRPC, err = jsonrpc.Dial(utils.TCP, tpRatePrfCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
- if err != nil {
- t.Fatal(err)
- }
-}
-
-func testTPRatePrfGetTPRatePrfBeforeSet(t *testing.T) {
- var reply *utils.TPRateProfile
- if err := tpRatePrfRPC.Call(utils.APIerSv1GetTPRateProfile,
- &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Attr1"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-}
-
-func testTPRatePrfSetTPRatePrf(t *testing.T) {
- tpRatePrf = &utils.TPRateProfile{
- TPid: "TP1",
- Tenant: "cgrates.org",
- ID: "RT_SPECIAL_1002",
- Weights: ";10",
- Rates: map[string]*utils.TPRate{
- "RT_ALWAYS": {
- ID: "RT_ALWAYS",
- FilterIDs: []string{"* * * * *"},
- Weights: ";0",
- Blocker: false,
- IntervalRates: []*utils.TPIntervalRate{
- {
- IntervalStart: "0s",
- RecurrentFee: 0.01,
- Unit: "1m",
- Increment: "1s",
- },
- },
- },
- },
- }
- var result string
- if err := tpRatePrfRPC.Call(utils.APIerSv1SetTPRateProfile, tpRatePrf, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-}
-
-func testTPRatePrfGetTPRatePrfAfterSet(t *testing.T) {
- var reply *utils.TPRateProfile
- if err := tpRatePrfRPC.Call(utils.APIerSv1GetTPRateProfile,
- &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "RT_SPECIAL_1002"}, &reply); err != nil {
- t.Fatal(err)
- }
- sort.Strings(reply.FilterIDs)
- if !reflect.DeepEqual(tpRatePrf, reply) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(tpRatePrf), utils.ToJSON(reply))
- }
-}
-
-func testTPRatePrfGetTPRatePrfIDs(t *testing.T) {
- var result []string
- expectedTPID := []string{"cgrates.org:RT_SPECIAL_1002"}
- if err := tpRatePrfRPC.Call(utils.APIerSv1GetTPRateProfileIds,
- &AttrGetTPRateProfileIds{TPid: "TP1"}, &result); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expectedTPID, result) {
- t.Errorf("Expecting: %+v, received: %+v", expectedTPID, result)
- }
-}
-
-func testTPRatePrfUpdateTPRatePrf(t *testing.T) {
- tpRatePrf.Rates = map[string]*utils.TPRate{
- "RT_ALWAYS": {
- ID: "RT_ALWAYS",
- FilterIDs: []string{"* * * * *"},
- Weights: ";0",
- Blocker: false,
- IntervalRates: []*utils.TPIntervalRate{
- {
- IntervalStart: "0s",
- RecurrentFee: 0.01,
- Unit: "1m",
- Increment: "1s",
- },
- },
- },
- }
- var result string
- if err := tpRatePrfRPC.Call(utils.APIerSv1SetTPRateProfile, tpRatePrf, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-}
-
-func testTPRatePrfGetTPRatePrfAfterUpdate(t *testing.T) {
- var reply *utils.TPRateProfile
- revTPRatePrf := &utils.TPRateProfile{
- TPid: "TP1",
- Tenant: "cgrates.org",
- ID: "RT_SPECIAL_1002",
- Weights: ";10",
- }
-
- if err := tpRatePrfRPC.Call(utils.APIerSv1GetTPRateProfile,
- &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "RT_SPECIAL_1002"}, &reply); err != nil {
- t.Fatal(err)
- }
- if !reflect.DeepEqual(tpRatePrf, reply) && !reflect.DeepEqual(revTPRatePrf, reply) {
- t.Errorf("Expecting : %+v, \n received: %+v", utils.ToJSON(tpRatePrf), utils.ToJSON(reply))
- }
-}
-
-func testTPRatePrfRemTPRatePrf(t *testing.T) {
- var resp string
- if err := tpRatePrfRPC.Call(utils.APIerSv1RemoveTPRateProfile,
- &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "RT_SPECIAL_1002"},
- &resp); err != nil {
- t.Error(err)
- } else if resp != utils.OK {
- t.Error("Unexpected reply returned", resp)
- }
-}
-
-func testTPRatePrfKillEngine(t *testing.T) {
- if err := engine.KillEngine(tpRatePrfDelay); err != nil {
- t.Error(err)
- }
-}
diff --git a/apier/v1/versions_it_test.go b/apier/v1/versions_it_test.go
index 415d6aa5e..1ec547d98 100644
--- a/apier/v1/versions_it_test.go
+++ b/apier/v1/versions_it_test.go
@@ -123,8 +123,7 @@ func testVrsDataDB(t *testing.T) {
"Actions": 2, "RQF": 5, "ReverseDestinations": 1, "Attributes": 6, "RatingPlan": 1,
"RatingProfile": 1, "Accounts": 3, "ActionPlans": 3, "Chargers": 2,
"Destinations": 1, "LoadIDs": 1, "SharedGroups": 2, "Stats": 4, "Resource": 1,
- "Subscribers": 1, "Routes": 2, "Thresholds": 4, "Timing": 1, "Dispatchers": 2,
- "RateProfiles": 1}
+ "Subscribers": 1, "Routes": 2, "Thresholds": 4, "Timing": 1, "Dispatchers": 2}
if err := vrsRPC.Call(utils.APIerSv1GetDataDBVersions, utils.StringPointer(utils.EmptyString), &result); err != nil {
t.Error(err)
} else if expectedVrs.Compare(result, vrsStorageType, true) != "" {
@@ -165,7 +164,7 @@ func testVrsSetDataDBVrs(t *testing.T) {
"RatingProfile": 1, "Accounts": 3, "ActionPlans": 3, "Chargers": 2,
"Destinations": 1, "LoadIDs": 1, "SharedGroups": 2, "Stats": 4, "Resource": 1,
"Subscribers": 1, "Routes": 2, "Thresholds": 4, "Timing": 1,
- "RateProfiles": 1, "Dispatchers": 2}
+ "Dispatchers": 2}
if err := vrsRPC.Call(utils.APIerSv1GetDataDBVersions, utils.StringPointer(utils.EmptyString), &result); err != nil {
t.Error(err)
} else if expectedVrs.Compare(result, vrsStorageType, true) != "" {
diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go
index ee6ee6515..b5acb971e 100644
--- a/cmd/cgr-engine/cgr-engine.go
+++ b/cmd/cgr-engine/cgr-engine.go
@@ -144,8 +144,7 @@ func startRPC(server *cores.Server, internalRaterChan,
internalAttrSChan, internalChargerSChan, internalThdSChan, internalSuplSChan,
internalSMGChan, internalAnalyzerSChan, internalDispatcherSChan,
internalLoaderSChan, internalRALsv1Chan, internalCacheSChan,
- internalEEsChan, internalRateSChan,
- internalAccountSChan chan rpcclient.ClientConnector,
+ internalEEsChan chan rpcclient.ClientConnector,
shdChan *utils.SyncedChan) {
if !cfg.DispatcherSCfg().Enabled {
select { // Any of the rpc methods will unlock listening to rpc requests
@@ -177,10 +176,6 @@ func startRPC(server *cores.Server, internalRaterChan,
internalCacheSChan <- chS
case eeS := <-internalEEsChan:
internalEEsChan <- eeS
- case rateS := <-internalRateSChan:
- internalRateSChan <- rateS
- case accountS := <-internalAccountSChan:
- internalAccountSChan <- accountS
case <-shdChan.Done():
return
}
@@ -496,8 +491,6 @@ func main() {
internalAPIerSv2Chan := make(chan rpcclient.ClientConnector, 1)
internalLoaderSChan := make(chan rpcclient.ClientConnector, 1)
internalEEsChan := make(chan rpcclient.ClientConnector, 1)
- internalRateSChan := make(chan rpcclient.ClientConnector, 1)
- internalAccountSChan := make(chan rpcclient.ClientConnector, 1)
// initialize the connManager before creating the DMService
// because we need to pass the connection to it
@@ -522,9 +515,7 @@ func main() {
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCore): internalCoreSv1Chan,
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaRALs): internalRALsChan,
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaEEs): internalEEsChan,
- utils.ConcatenatedKey(utils.MetaInternal, utils.MetaRateS): internalRateSChan,
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaDispatchers): internalDispatcherSChan,
- utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAccounts): internalAccountSChan,
utils.ConcatenatedKey(rpcclient.BiRPCInternal, utils.MetaSessionS): internalSessionSChan,
})
@@ -551,7 +542,6 @@ func main() {
utils.LoaderS: new(sync.WaitGroup),
utils.RadiusAgent: new(sync.WaitGroup),
utils.RALService: new(sync.WaitGroup),
- utils.RateS: new(sync.WaitGroup),
utils.ResourceS: new(sync.WaitGroup),
utils.ResponderS: new(sync.WaitGroup),
utils.RouteS: new(sync.WaitGroup),
@@ -704,10 +694,8 @@ func main() {
engine.IntRPC.AddInternalRPCClient(utils.ConfigSv1, internalConfigChan)
engine.IntRPC.AddInternalRPCClient(utils.CoreSv1, internalCoreSv1Chan)
engine.IntRPC.AddInternalRPCClient(utils.RALsV1, internalRALsChan)
- engine.IntRPC.AddInternalRPCClient(utils.RateSv1, internalRateSChan)
engine.IntRPC.AddInternalRPCClient(utils.EeSv1, internalEEsChan)
engine.IntRPC.AddInternalRPCClient(utils.DispatcherSv1, internalDispatcherSChan)
- engine.IntRPC.AddInternalRPCClient(utils.AccountSv1, internalAccountSChan)
initConfigSv1(internalConfigChan, server, anz)
@@ -721,8 +709,7 @@ func main() {
internalAttributeSChan, internalChargerSChan, internalThresholdSChan,
internalRouteSChan, internalSessionSChan, internalAnalyzerSChan,
internalDispatcherSChan, internalLoaderSChan, internalRALsChan,
- internalCacheSChan, internalEEsChan, internalRateSChan,
- internalAccountSChan, shdChan)
+ internalCacheSChan, internalEEsChan, shdChan)
<-shdChan.Done()
shtdDone := make(chan struct{})
diff --git a/config/accountscfg.go b/config/accountscfg.go
deleted file mode 100644
index 9c8f998c1..000000000
--- a/config/accountscfg.go
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
-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
-*/
-
-package config
-
-import "github.com/cgrates/cgrates/utils"
-
-// AccountSCfg is the configuration of ActionS
-type AccountSCfg struct {
- Enabled bool
- AttributeSConns []string
- RateSConns []string
- ThresholdSConns []string
- IndexedSelects bool
- StringIndexedFields *[]string
- PrefixIndexedFields *[]string
- SuffixIndexedFields *[]string
- NestedFields bool
- MaxIterations int
- MaxUsage *utils.Decimal
-}
-
-func (acS *AccountSCfg) loadFromJSONCfg(jsnCfg *AccountSJsonCfg) (err error) {
- if jsnCfg == nil {
- return
- }
- if jsnCfg.Enabled != nil {
- acS.Enabled = *jsnCfg.Enabled
- }
- if jsnCfg.Indexed_selects != nil {
- acS.IndexedSelects = *jsnCfg.Indexed_selects
- }
- if jsnCfg.Attributes_conns != nil {
- acS.AttributeSConns = make([]string, len(*jsnCfg.Attributes_conns))
- for idx, conn := range *jsnCfg.Attributes_conns {
- // if we have the connection internal we change the name so we can have internal rpc for each subsystem
- acS.AttributeSConns[idx] = conn
- if conn == utils.MetaInternal {
- acS.AttributeSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes)
- }
- }
- }
- if jsnCfg.Rates_conns != nil {
- acS.RateSConns = make([]string, len(*jsnCfg.Rates_conns))
- for idx, conn := range *jsnCfg.Rates_conns {
- // if we have the connection internal we change the name so we can have internal rpc for each subsystem
- acS.RateSConns[idx] = conn
- if conn == utils.MetaInternal {
- acS.RateSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaRateS)
- }
- }
- }
- if jsnCfg.Thresholds_conns != nil {
- acS.ThresholdSConns = make([]string, len(*jsnCfg.Thresholds_conns))
- for idx, conn := range *jsnCfg.Thresholds_conns {
- // if we have the connection internal we change the name so we can have internal rpc for each subsystem
- acS.ThresholdSConns[idx] = conn
- if conn == utils.MetaInternal {
- acS.ThresholdSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaThresholds)
- }
- }
- }
- if jsnCfg.String_indexed_fields != nil {
- sif := make([]string, len(*jsnCfg.String_indexed_fields))
- for i, fID := range *jsnCfg.String_indexed_fields {
- sif[i] = fID
- }
- acS.StringIndexedFields = &sif
- }
- if jsnCfg.Prefix_indexed_fields != nil {
- pif := make([]string, len(*jsnCfg.Prefix_indexed_fields))
- for i, fID := range *jsnCfg.Prefix_indexed_fields {
- pif[i] = fID
- }
- acS.PrefixIndexedFields = &pif
- }
- if jsnCfg.Suffix_indexed_fields != nil {
- sif := make([]string, len(*jsnCfg.Suffix_indexed_fields))
- for i, fID := range *jsnCfg.Suffix_indexed_fields {
- sif[i] = fID
- }
- acS.SuffixIndexedFields = &sif
- }
- if jsnCfg.Nested_fields != nil {
- acS.NestedFields = *jsnCfg.Nested_fields
- }
- if jsnCfg.Max_iterations != nil {
- acS.MaxIterations = *jsnCfg.Max_iterations
- }
- if jsnCfg.Max_usage != nil {
- if acS.MaxUsage, err = utils.NewDecimalFromUsage(*jsnCfg.Max_usage); err != nil {
- return err
- }
- }
- return
-}
-
-// AsMapInterface returns the config as a map[string]interface{}
-func (acS *AccountSCfg) AsMapInterface() (initialMP map[string]interface{}) {
- initialMP = map[string]interface{}{
- utils.EnabledCfg: acS.Enabled,
- utils.IndexedSelectsCfg: acS.IndexedSelects,
- utils.NestedFieldsCfg: acS.NestedFields,
- utils.MaxIterations: acS.MaxIterations,
- }
- if acS.AttributeSConns != nil {
- attributeSConns := make([]string, len(acS.AttributeSConns))
- for i, item := range acS.AttributeSConns {
- attributeSConns[i] = item
- if item == utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes) {
- attributeSConns[i] = utils.MetaInternal
- }
- }
- initialMP[utils.AttributeSConnsCfg] = attributeSConns
- }
- if acS.RateSConns != nil {
- rateSConns := make([]string, len(acS.RateSConns))
- for i, item := range acS.RateSConns {
- rateSConns[i] = item
- if item == utils.ConcatenatedKey(utils.MetaInternal, utils.MetaRateS) {
- rateSConns[i] = utils.MetaInternal
- }
- }
- initialMP[utils.RateSConnsCfg] = rateSConns
- }
- if acS.ThresholdSConns != nil {
- thresholdSConns := make([]string, len(acS.ThresholdSConns))
- for i, item := range acS.ThresholdSConns {
- thresholdSConns[i] = item
- if item == utils.ConcatenatedKey(utils.MetaInternal, utils.MetaThresholds) {
- thresholdSConns[i] = utils.MetaInternal
- }
- }
- initialMP[utils.ThresholdSConnsCfg] = thresholdSConns
- }
- if acS.StringIndexedFields != nil {
- stringIndexedFields := make([]string, len(*acS.StringIndexedFields))
- for i, item := range *acS.StringIndexedFields {
- stringIndexedFields[i] = item
- }
- initialMP[utils.StringIndexedFieldsCfg] = stringIndexedFields
- }
- if acS.PrefixIndexedFields != nil {
- prefixIndexedFields := make([]string, len(*acS.PrefixIndexedFields))
- for i, item := range *acS.PrefixIndexedFields {
- prefixIndexedFields[i] = item
- }
- initialMP[utils.PrefixIndexedFieldsCfg] = prefixIndexedFields
- }
- if acS.SuffixIndexedFields != nil {
- suffixIndexedFields := make([]string, len(*acS.SuffixIndexedFields))
- for i, item := range *acS.SuffixIndexedFields {
- suffixIndexedFields[i] = item
- }
- initialMP[utils.SuffixIndexedFieldsCfg] = suffixIndexedFields
- }
- if acS.MaxUsage != nil {
- initialMP[utils.MaxUsage] = acS.MaxUsage
- }
- return
-}
-
-// Clone returns a deep copy of AccountSCfg
-func (acS AccountSCfg) Clone() (cln *AccountSCfg) {
- cln = &AccountSCfg{
- Enabled: acS.Enabled,
- IndexedSelects: acS.IndexedSelects,
- NestedFields: acS.NestedFields,
- MaxIterations: acS.MaxIterations,
- MaxUsage: acS.MaxUsage,
- }
- if acS.AttributeSConns != nil {
- cln.AttributeSConns = make([]string, len(acS.AttributeSConns))
- for i, con := range acS.AttributeSConns {
- cln.AttributeSConns[i] = con
- }
- }
- if acS.RateSConns != nil {
- cln.RateSConns = make([]string, len(acS.RateSConns))
- for i, con := range acS.RateSConns {
- cln.RateSConns[i] = con
- }
- }
- if acS.ThresholdSConns != nil {
- cln.ThresholdSConns = make([]string, len(acS.ThresholdSConns))
- for i, con := range acS.ThresholdSConns {
- cln.ThresholdSConns[i] = con
- }
- }
- if acS.StringIndexedFields != nil {
- idx := make([]string, len(*acS.StringIndexedFields))
- for i, dx := range *acS.StringIndexedFields {
- idx[i] = dx
- }
- cln.StringIndexedFields = &idx
- }
- if acS.PrefixIndexedFields != nil {
- idx := make([]string, len(*acS.PrefixIndexedFields))
- for i, dx := range *acS.PrefixIndexedFields {
- idx[i] = dx
- }
- cln.PrefixIndexedFields = &idx
- }
- if acS.SuffixIndexedFields != nil {
- idx := make([]string, len(*acS.SuffixIndexedFields))
- for i, dx := range *acS.SuffixIndexedFields {
- idx[i] = dx
- }
- cln.SuffixIndexedFields = &idx
- }
- return
-}
diff --git a/config/accountscfg_test.go b/config/accountscfg_test.go
deleted file mode 100644
index e16f224b8..000000000
--- a/config/accountscfg_test.go
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
-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
-*/
-
-package config
-
-import (
- "reflect"
- "testing"
-
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestAccountSCfgLoadFromJSONCfg(t *testing.T) {
- jsonCfg := &AccountSJsonCfg{
- Enabled: utils.BoolPointer(true),
- Attributes_conns: &[]string{utils.MetaInternal},
- Rates_conns: &[]string{utils.MetaInternal},
- Thresholds_conns: &[]string{utils.MetaInternal},
- Indexed_selects: utils.BoolPointer(false),
- String_indexed_fields: &[]string{"*req.index1"},
- Prefix_indexed_fields: &[]string{"*req.index1"},
- Suffix_indexed_fields: &[]string{"*req.index1"},
- Nested_fields: utils.BoolPointer(true),
- Max_iterations: utils.IntPointer(1000),
- Max_usage: utils.StringPointer("200h"),
- }
- usage, err := utils.NewDecimalFromUsage("200h")
- if err != nil {
- t.Error(err)
- }
- expected := &AccountSCfg{
- Enabled: true,
- AttributeSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes)},
- RateSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaRateS)},
- ThresholdSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaThresholds)},
- IndexedSelects: false,
- StringIndexedFields: &[]string{"*req.index1"},
- PrefixIndexedFields: &[]string{"*req.index1"},
- SuffixIndexedFields: &[]string{"*req.index1"},
- NestedFields: true,
- MaxIterations: 1000,
- MaxUsage: usage,
- }
- jsnCfg := NewDefaultCGRConfig()
- if err = jsnCfg.accountSCfg.loadFromJSONCfg(jsonCfg); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, jsnCfg.accountSCfg) {
- t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ToJSON(expected), utils.ToJSON(jsnCfg.accountSCfg))
- }
-}
-
-func TestAccountsCfLoadConfigError(t *testing.T) {
- accountsJson := &AccountSJsonCfg{
- Max_usage: utils.StringPointer("invalid_Decimal"),
- }
- actsCfg := new(AccountSCfg)
- expected := "strconv.ParseInt: parsing \"invalid_Decimal\": invalid syntax"
- if err := actsCfg.loadFromJSONCfg(accountsJson); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-}
-
-func TestAccountSCfgAsMapInterface(t *testing.T) {
- cfgJSONStr := `{
-"accounts": {
- "enabled": true,
- "indexed_selects": false,
- "attributes_conns": ["*internal:*attributes"],
- "rates_conns": ["*internal:*rates"],
- "thresholds_conns": ["*internal:*thresholds"],
- "string_indexed_fields": ["*req.index1"],
- "prefix_indexed_fields": ["*req.index1"],
- "suffix_indexed_fields": ["*req.index1"],
- "nested_fields": true,
- "max_iterations": 100,
- "max_usage": "72h",
-},
-}`
-
- eMap := map[string]interface{}{
- utils.EnabledCfg: true,
- utils.IndexedSelectsCfg: false,
- utils.AttributeSConnsCfg: []string{utils.MetaInternal},
- utils.RateSConnsCfg: []string{utils.MetaInternal},
- utils.ThresholdSConnsCfg: []string{utils.MetaInternal},
- utils.StringIndexedFieldsCfg: []string{"*req.index1"},
- utils.PrefixIndexedFieldsCfg: []string{"*req.index1"},
- utils.SuffixIndexedFieldsCfg: []string{"*req.index1"},
- utils.NestedFieldsCfg: true,
- utils.MaxIterations: 100,
- }
- usage, err := utils.NewDecimalFromUsage("72h")
- if err != nil {
- t.Error(err)
- }
- eMap[utils.MaxUsage] = usage
-
- if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
- t.Error(err)
- } else if rcv := cgrCfg.accountSCfg.AsMapInterface(); !reflect.DeepEqual(eMap, rcv) {
- t.Errorf("Expected: %+v\n Received: %+v", utils.ToJSON(eMap), utils.ToJSON(rcv))
- }
-}
-
-func TestAccountSCfgClone(t *testing.T) {
- usage, err := utils.NewDecimalFromUsage("24h")
- if err != nil {
- t.Error(err)
- }
- ban := &AccountSCfg{
- Enabled: true,
- IndexedSelects: false,
- AttributeSConns: []string{"*req.index1"},
- RateSConns: []string{"*req.index1"},
- ThresholdSConns: []string{"*req.index1"},
- StringIndexedFields: &[]string{"*req.index1"},
- PrefixIndexedFields: &[]string{"*req.index1", "*req.index2"},
- SuffixIndexedFields: &[]string{"*req.index1"},
- NestedFields: true,
- MaxIterations: 1000,
- MaxUsage: usage,
- }
- rcv := ban.Clone()
- if !reflect.DeepEqual(ban, rcv) {
- t.Errorf("\nExpected: %+v\nReceived: %+v", utils.ToJSON(ban), utils.ToJSON(rcv))
- }
- if (rcv.AttributeSConns)[0] = utils.EmptyString; (ban.AttributeSConns)[0] != "*req.index1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
- if (rcv.RateSConns)[0] = utils.EmptyString; (ban.RateSConns)[0] != "*req.index1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
- if (rcv.ThresholdSConns)[0] = utils.EmptyString; (ban.ThresholdSConns)[0] != "*req.index1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
- if (*rcv.StringIndexedFields)[0] = utils.EmptyString; (*ban.StringIndexedFields)[0] != "*req.index1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
- if (*rcv.PrefixIndexedFields)[0] = utils.EmptyString; (*ban.PrefixIndexedFields)[0] != "*req.index1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
- if (*rcv.SuffixIndexedFields)[0] = utils.EmptyString; (*ban.SuffixIndexedFields)[0] != "*req.index1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
-}
diff --git a/config/config.go b/config/config.go
index c390aa48c..b8a77c399 100644
--- a/config/config.go
+++ b/config/config.go
@@ -197,12 +197,10 @@ func newCGRConfig(config []byte) (cfg *CGRConfig, err error) {
cfg.ersCfg = new(ERsCfg)
cfg.eesCfg = new(EEsCfg)
cfg.eesCfg.Cache = make(map[string]*CacheParamCfg)
- cfg.rateSCfg = new(RateSCfg)
cfg.sipAgentCfg = new(SIPAgentCfg)
cfg.configSCfg = new(ConfigSCfg)
cfg.apiBanCfg = new(APIBanCfg)
cfg.coreSCfg = new(CoreSCfg)
- cfg.accountSCfg = new(AccountSCfg)
cfg.cacheDP = make(map[string]utils.MapStorage)
@@ -332,12 +330,10 @@ type CGRConfig struct {
apier *ApierCfg // APIer config
ersCfg *ERsCfg // EventReader config
eesCfg *EEsCfg // EventExporter config
- rateSCfg *RateSCfg // RateS config
sipAgentCfg *SIPAgentCfg // SIPAgent config
configSCfg *ConfigSCfg // ConfigS config
apiBanCfg *APIBanCfg // APIBan config
coreSCfg *CoreSCfg // CoreS config
- accountSCfg *AccountSCfg // AccountS config
cacheDP map[string]utils.MapStorage
cacheDPMux sync.RWMutex
@@ -407,9 +403,8 @@ func (cfg *CGRConfig) loadFromJSONCfg(jsnCfg *CgrJsonCfg) (err error) {
cfg.loadMailerCfg, cfg.loadSureTaxCfg, cfg.loadDispatcherSCfg,
cfg.loadLoaderCgrCfg, cfg.loadMigratorCgrCfg, cfg.loadTLSCgrCfg,
cfg.loadAnalyzerCgrCfg, cfg.loadApierCfg, cfg.loadErsCfg, cfg.loadEesCfg,
- cfg.loadRateSCfg, cfg.loadSIPAgentCfg, cfg.loadRegistrarCCfg,
- cfg.loadConfigSCfg, cfg.loadAPIBanCgrCfg, cfg.loadCoreSCfg,
- cfg.loadAccountSCfg} {
+ cfg.loadSIPAgentCfg, cfg.loadRegistrarCCfg,
+ cfg.loadConfigSCfg, cfg.loadAPIBanCgrCfg, cfg.loadCoreSCfg} {
if err = loadFunc(jsnCfg); err != nil {
return
}
@@ -815,15 +810,6 @@ func (cfg *CGRConfig) loadEesCfg(jsnCfg *CgrJsonCfg) (err error) {
return cfg.eesCfg.loadFromJSONCfg(jsnEEsCfg, cfg.templates, cfg.generalCfg.RSRSep, cfg.dfltEvExp)
}
-// loadRateSCfg loads the rates section of the configuration
-func (cfg *CGRConfig) loadRateSCfg(jsnCfg *CgrJsonCfg) (err error) {
- var jsnRateCfg *RateSJsonCfg
- if jsnRateCfg, err = jsnCfg.RateCfgJson(); err != nil {
- return
- }
- return cfg.rateSCfg.loadFromJSONCfg(jsnRateCfg)
-}
-
// loadSIPAgentCfg loads the sip_agent section of the configuration
func (cfg *CGRConfig) loadSIPAgentCfg(jsnCfg *CgrJsonCfg) (err error) {
var jsnSIPAgentCfg *SIPAgentJsonCfg
@@ -855,15 +841,6 @@ func (cfg *CGRConfig) loadConfigSCfg(jsnCfg *CgrJsonCfg) (err error) {
return cfg.configSCfg.loadFromJSONCfg(jsnConfigSCfg)
}
-// loadAccountSCfg loads the AccountS section of the configuration
-func (cfg *CGRConfig) loadAccountSCfg(jsnCfg *CgrJsonCfg) (err error) {
- var jsnActionCfg *AccountSJsonCfg
- if jsnActionCfg, err = jsnCfg.AccountSCfgJson(); err != nil {
- return
- }
- return cfg.accountSCfg.loadFromJSONCfg(jsnActionCfg)
-}
-
// SureTaxCfg use locking to retrieve the configuration, possibility later for runtime reload
func (cfg *CGRConfig) SureTaxCfg() *SureTaxCfg {
cfg.lks[SURETAX_JSON].Lock()
@@ -1121,20 +1098,6 @@ func (cfg *CGRConfig) EEsNoLksCfg() *EEsCfg {
return cfg.eesCfg
}
-// RateSCfg reads the RateS configuration
-func (cfg *CGRConfig) RateSCfg() *RateSCfg {
- cfg.lks[RateSJson].RLock()
- defer cfg.lks[RateSJson].RUnlock()
- return cfg.rateSCfg
-}
-
-// AccountSCfg reads the AccountS configuration
-func (cfg *CGRConfig) AccountSCfg() *AccountSCfg {
- cfg.lks[AccountSCfgJson].RLock()
- defer cfg.lks[AccountSCfgJson].RUnlock()
- return cfg.accountSCfg
-}
-
// SIPAgentCfg reads the Apier configuration
func (cfg *CGRConfig) SIPAgentCfg() *SIPAgentCfg {
cfg.lks[SIPAgentJson].Lock()
@@ -1283,13 +1246,11 @@ func (cfg *CGRConfig) getLoadFunctions() map[string]func(*CgrJsonCfg) error {
AnalyzerCfgJson: cfg.loadAnalyzerCgrCfg,
ApierS: cfg.loadApierCfg,
RPCConnsJsonName: cfg.loadRPCConns,
- RateSJson: cfg.loadRateSCfg,
SIPAgentJson: cfg.loadSIPAgentCfg,
TemplatesJson: cfg.loadTemplateSCfg,
ConfigSJson: cfg.loadConfigSCfg,
APIBanCfgJson: cfg.loadAPIBanCgrCfg,
CoreSCfgJson: cfg.loadCoreSCfg,
- AccountSCfgJson: cfg.loadAccountSCfg,
}
}
@@ -1451,7 +1412,7 @@ func (cfg *CGRConfig) reloadSections(sections ...string) {
subsystemsThatNeedDataDB := utils.NewStringSet([]string{DATADB_JSN, SCHEDULER_JSN,
RALS_JSN, CDRS_JSN, SessionSJson, ATTRIBUTE_JSN,
ChargerSCfgJson, RESOURCES_JSON, STATS_JSON, THRESHOLDS_JSON,
- RouteSJson, LoaderJson, DispatcherSJson, RateSJson, ApierS, AccountSCfgJson,
+ RouteSJson, LoaderJson, DispatcherSJson, ApierS,
})
subsystemsThatNeedStorDB := utils.NewStringSet([]string{STORDB_JSN, RALS_JSN, CDRS_JSN, ApierS})
needsDataDB := false
@@ -1539,12 +1500,8 @@ func (cfg *CGRConfig) reloadSections(sections ...string) {
cfg.rldChans[EEsJson] <- struct{}{}
case SIPAgentJson:
cfg.rldChans[SIPAgentJson] <- struct{}{}
- case RateSJson:
- cfg.rldChans[RateSJson] <- struct{}{}
case RegistrarCJson:
cfg.rldChans[RegistrarCJson] <- struct{}{}
- case AccountSCfgJson:
- cfg.rldChans[AccountSCfgJson] <- struct{}{}
}
}
}
@@ -1590,12 +1547,10 @@ func (cfg *CGRConfig) AsMapInterface(separator string) (mp map[string]interface{
ERsJson: cfg.ersCfg.AsMapInterface(separator),
APIBanCfgJson: cfg.apiBanCfg.AsMapInterface(),
EEsJson: cfg.eesCfg.AsMapInterface(separator),
- RateSJson: cfg.rateSCfg.AsMapInterface(),
SIPAgentJson: cfg.sipAgentCfg.AsMapInterface(separator),
TemplatesJson: cfg.templates.AsMapInterface(separator),
ConfigSJson: cfg.configSCfg.AsMapInterface(),
CoreSCfgJson: cfg.coreSCfg.AsMapInterface(),
- AccountSCfgJson: cfg.accountSCfg.AsMapInterface(),
}
}
@@ -1754,12 +1709,8 @@ func (cfg *CGRConfig) V1GetConfig(args *SectionWithAPIOpts, reply *map[string]in
mp = cfg.MailerCfg().AsMapInterface()
case AnalyzerCfgJson:
mp = cfg.AnalyzerSCfg().AsMapInterface()
- case RateSJson:
- mp = cfg.RateSCfg().AsMapInterface()
case CoreSCfgJson:
mp = cfg.CoreSCfg().AsMapInterface()
- case AccountSCfgJson:
- mp = cfg.AccountSCfg().AsMapInterface()
default:
return errors.New("Invalid section")
}
@@ -1922,12 +1873,8 @@ func (cfg *CGRConfig) V1GetConfigAsJSON(args *SectionWithAPIOpts, reply *string)
mp = cfg.MailerCfg().AsMapInterface()
case AnalyzerCfgJson:
mp = cfg.AnalyzerSCfg().AsMapInterface()
- case RateSJson:
- mp = cfg.RateSCfg().AsMapInterface()
case CoreSCfgJson:
mp = cfg.CoreSCfg().AsMapInterface()
- case AccountSCfgJson:
- mp = cfg.AccountSCfg().AsMapInterface()
default:
return errors.New("Invalid section")
}
@@ -2020,12 +1967,10 @@ func (cfg *CGRConfig) Clone() (cln *CGRConfig) {
apier: cfg.apier.Clone(),
ersCfg: cfg.ersCfg.Clone(),
eesCfg: cfg.eesCfg.Clone(),
- rateSCfg: cfg.rateSCfg.Clone(),
sipAgentCfg: cfg.sipAgentCfg.Clone(),
configSCfg: cfg.configSCfg.Clone(),
apiBanCfg: cfg.apiBanCfg.Clone(),
coreSCfg: cfg.coreSCfg.Clone(),
- accountSCfg: cfg.accountSCfg.Clone(),
cacheDP: make(map[string]utils.MapStorage),
}
diff --git a/config/config_defaults.go b/config/config_defaults.go
index af40a84ba..808e1d48e 100644
--- a/config/config_defaults.go
+++ b/config/config_defaults.go
@@ -917,22 +917,6 @@ const CGRATES_CFG_JSON = `
},
-"rates": {
- "enabled": false,
- "indexed_selects": true, // enable profile matching exclusively on indexes
- //"string_indexed_fields": [], // query indexes based on these fields for faster processing
- "prefix_indexed_fields": [], // query indexes based on these fields for faster processing
- "suffix_indexed_fields": [], // query indexes based on these fields for faster processing
- "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level)
- "rate_indexed_selects": true, // enable profile matching exclusively on indexes
- //"rate_string_indexed_fields": [], // query indexes based on these fields for faster processing
- "rate_prefix_indexed_fields": [], // query indexes based on these fields for faster processing
- "rate_suffix_indexed_fields": [], // query indexes based on these fields for faster processing
- "rate_nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level)
- "verbosity": 1000, // number of increment iterations allowed
-},
-
-
"sip_agent": { // SIP Agents, only used for redirections
"enabled": false, // enables the SIP agent:
"listen": "127.0.0.1:5060", // address where to listen for SIP requests
@@ -1048,21 +1032,4 @@ const CGRATES_CFG_JSON = `
},
-
-
-"accounts": { // AccountS config
- "enabled": false, // starts service:
- "indexed_selects": true, // enable profile matching exclusively on indexes
- "attributes_conns": [], // connections to AttributeS for account/balance updates, empty to disable attributes functionality: <""|*internal|$rpc_conns_id>
- "rates_conns": [], // connections to RatesS for account/balance updates, empty to disable rates functionality: <""|*internal|$rpc_conns_id>
- "thresholds_conns": [], // connections to ThresholdS for account/balance updates, empty to disable thresholds functionality: <""|*internal|$rpc_conns_id>
- //"string_indexed_fields": [], // query indexes based on these fields for faster processing
- "prefix_indexed_fields": [], // query indexes based on these fields for faster processing
- "suffix_indexed_fields": [], // query indexes based on these fields for faster processing
- "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level)
- "max_iterations": 1000, // maximum number of iterations
- "max_usage": "72h", // maximum time of usage
-},
-
-
}`
diff --git a/config/config_json.go b/config/config_json.go
index 7c2857a6f..36a7f6774 100644
--- a/config/config_json.go
+++ b/config/config_json.go
@@ -59,14 +59,12 @@ const (
DNSAgentJson = "dns_agent"
ERsJson = "ers"
EEsJson = "ees"
- RateSJson = "rates"
RPCConnsJsonName = "rpc_conns"
SIPAgentJson = "sip_agent"
TemplatesJson = "templates"
ConfigSJson = "configs"
APIBanCfgJson = "apiban"
CoreSCfgJson = "cores"
- AccountSCfgJson = "accounts"
)
var (
@@ -74,8 +72,7 @@ var (
CACHE_JSN, FilterSjsn, RALS_JSN, CDRS_JSN, ERsJson, SessionSJson, AsteriskAgentJSN, FreeSWITCHAgentJSN,
KamailioAgentJSN, DA_JSN, RA_JSN, HttpAgentJson, DNSAgentJson, ATTRIBUTE_JSN, ChargerSCfgJson, RESOURCES_JSON, STATS_JSON,
THRESHOLDS_JSON, RouteSJson, LoaderJson, MAILER_JSN, SURETAX_JSON, CgrLoaderCfgJson, CgrMigratorCfgJson, DispatcherSJson,
- AnalyzerCfgJson, ApierS, EEsJson, RateSJson, SIPAgentJson, RegistrarCJson, TemplatesJson, ConfigSJson, APIBanCfgJson, CoreSCfgJson,
- AccountSCfgJson}
+ AnalyzerCfgJson, ApierS, EEsJson, SIPAgentJson, RegistrarCJson, TemplatesJson, ConfigSJson, APIBanCfgJson, CoreSCfgJson}
)
// Loads the json config out of io.Reader, eg other sources than file, maybe over http
@@ -514,18 +511,6 @@ func (jsnCfg CgrJsonCfg) ApierCfgJson() (*ApierJsonCfg, error) {
return cfg, nil
}
-func (jsnCfg CgrJsonCfg) RateCfgJson() (*RateSJsonCfg, error) {
- rawCfg, hasKey := jsnCfg[RateSJson]
- if !hasKey {
- return nil, nil
- }
- cfg := new(RateSJsonCfg)
- if err := json.Unmarshal(*rawCfg, cfg); err != nil {
- return nil, err
- }
- return cfg, nil
-}
-
func (jsnCfg CgrJsonCfg) SIPAgentJsonCfg() (*SIPAgentJsonCfg, error) {
rawCfg, hasKey := jsnCfg[SIPAgentJson]
if !hasKey {
@@ -585,15 +570,3 @@ func (jsnCfg CgrJsonCfg) CoreSCfgJson() (*CoreSJsonCfg, error) {
}
return cfg, nil
}
-
-func (jsnCfg CgrJsonCfg) AccountSCfgJson() (*AccountSJsonCfg, error) {
- rawCfg, hasKey := jsnCfg[AccountSCfgJson]
- if !hasKey {
- return nil, nil
- }
- cfg := new(AccountSJsonCfg)
- if err := json.Unmarshal(*rawCfg, cfg); err != nil {
- return nil, err
- }
- return cfg, nil
-}
diff --git a/config/config_json_test.go b/config/config_json_test.go
index d6d5c4cc2..4a14f971d 100644
--- a/config/config_json_test.go
+++ b/config/config_json_test.go
@@ -1859,32 +1859,6 @@ func TestDfEventExporterCfg(t *testing.T) {
}
}
-func TestDfRateSJsonCfg(t *testing.T) {
- eCfg := &RateSJsonCfg{
- Enabled: utils.BoolPointer(false),
- Indexed_selects: utils.BoolPointer(true),
- String_indexed_fields: nil,
- Prefix_indexed_fields: &[]string{},
- Suffix_indexed_fields: &[]string{},
- Nested_fields: utils.BoolPointer(false),
- Rate_indexed_selects: utils.BoolPointer(true),
- Rate_string_indexed_fields: nil,
- Rate_prefix_indexed_fields: &[]string{},
- Rate_suffix_indexed_fields: &[]string{},
- Rate_nested_fields: utils.BoolPointer(false),
- Verbosity: utils.IntPointer(1000),
- }
- dfCgrJSONCfg, err := NewCgrJsonCfgFromBytes([]byte(CGRATES_CFG_JSON))
- if err != nil {
- t.Error(err)
- }
- if cfg, err := dfCgrJSONCfg.RateCfgJson(); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eCfg, cfg) {
- t.Error("Received: ", utils.ToJSON(cfg))
- }
-}
-
func TestDfTemplateSJsonCfg(t *testing.T) {
eCfg := map[string][]*FcTemplateJsonCfg{
"*errSip": {
diff --git a/config/config_test.go b/config/config_test.go
index cd83fb5ea..0ac81caa2 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -1811,24 +1811,6 @@ func TestLoadCoreSCfgError(t *testing.T) {
}
}
-func TestLoadRateSCfgError(t *testing.T) {
- cfgJSONStr := `{
- "rates": {
- "string_indexed_fields": "*req.index",
- },
-}`
- expected := "json: cannot unmarshal string into Go struct field RateSJsonCfg.String_indexed_fields of type []string"
- cgrConfig := NewDefaultCGRConfig()
- if err != nil {
- t.Error(err)
- }
- if cgrCfgJSON, err := NewCgrJsonCfgFromBytes([]byte(cfgJSONStr)); err != nil {
- t.Error(err)
- } else if err := cgrConfig.loadRateSCfg(cgrCfgJSON); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-}
-
func TestLoadSIPAgentCfgError(t *testing.T) {
cfgJSONStr := `{
"sip_agent": {
@@ -2456,29 +2438,6 @@ func TestEEsNoLksConfig(t *testing.T) {
}
}
-func TestRateSConfig(t *testing.T) {
- expected := &RateSCfg{
- Enabled: false,
- IndexedSelects: true,
- PrefixIndexedFields: &[]string{},
- SuffixIndexedFields: &[]string{},
- NestedFields: false,
- RateIndexedSelects: true,
- RatePrefixIndexedFields: &[]string{},
- RateSuffixIndexedFields: &[]string{},
- RateNestedFields: false,
- Verbosity: 1000,
- }
- cgrConfig := NewDefaultCGRConfig()
- if err != nil {
- t.Error(err)
- }
- newConfig := cgrConfig.RateSCfg()
- if !reflect.DeepEqual(expected, newConfig) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(newConfig))
- }
-}
-
func TestSIPAgentConfig(t *testing.T) {
expected := &SIPAgentCfg{
Enabled: false,
@@ -3256,10 +3215,12 @@ func TestCgrLoaderCfgITDefaults(t *testing.T) {
},
},
},
- {
- Type: utils.MetaAccountProfiles,
- Filename: utils.AccountProfilesCsv,
- Fields: []*FCTemplate{
+ },
+ },
+ }
+ for _, profile := range eCfg {
+ for _, fields := range profile.Data {
+ for _, v := range fields.Fields {
v.ComputePath()
}
}
@@ -3440,26 +3401,6 @@ func TestCgrCfgJSONDefaultApierCfg(t *testing.T) {
}
}
-func TestCgrCfgJSONDefaultRateCfg(t *testing.T) {
- eCfg := &RateSCfg{
- Enabled: false,
- IndexedSelects: true,
- StringIndexedFields: nil,
- PrefixIndexedFields: &[]string{},
- SuffixIndexedFields: &[]string{},
- NestedFields: false,
- RateIndexedSelects: true,
- RateStringIndexedFields: nil,
- RatePrefixIndexedFields: &[]string{},
- RateSuffixIndexedFields: &[]string{},
- RateNestedFields: false,
- Verbosity: 1000,
- }
- if !reflect.DeepEqual(cgrCfg.rateSCfg, eCfg) {
- t.Errorf("received: %+v, expecting: %+v", cgrCfg.rateSCfg, eCfg)
- }
-}
-
func TestCgrCfgV1GetConfigAllConfig(t *testing.T) {
var rcv map[string]interface{}
cgrCfg := NewDefaultCGRConfig()
@@ -4183,34 +4124,6 @@ func TestV1GetConfigThresholds(t *testing.T) {
}
}
-func TestV1GetConfigAcounts(t *testing.T) {
- var reply map[string]interface{}
- usage, err := utils.NewDecimalFromUsage("72h")
- if err != nil {
- t.Error(err)
- }
- expected := map[string]interface{}{
- AccountSCfgJson: map[string]interface{}{
- utils.EnabledCfg: false,
- utils.IndexedSelectsCfg: true,
- utils.AttributeSConnsCfg: []string{},
- utils.RateSConnsCfg: []string{},
- utils.ThresholdSConnsCfg: []string{},
- utils.PrefixIndexedFieldsCfg: []string{},
- utils.SuffixIndexedFieldsCfg: []string{},
- utils.NestedFieldsCfg: false,
- utils.MaxIterations: 1000,
- utils.MaxUsage: usage,
- },
- }
- cfg := NewDefaultCGRConfig()
- if err := cfg.V1GetConfig(&SectionWithAPIOpts{Section: AccountSCfgJson}, &reply); err != nil {
- t.Error(expected)
- } else if !reflect.DeepEqual(reply, expected) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(reply))
- }
-}
-
func TestV1GetConfigRoutes(t *testing.T) {
var reply map[string]interface{}
expected := map[string]interface{}{
@@ -4703,30 +4616,6 @@ func TestV1GetConfigSectionAnalyzer(t *testing.T) {
}
}
-func TestV1GetConfigSectionRateS(t *testing.T) {
- var reply map[string]interface{}
- expected := map[string]interface{}{
- RateSJson: map[string]interface{}{
- utils.EnabledCfg: false,
- utils.IndexedSelectsCfg: true,
- utils.PrefixIndexedFieldsCfg: []string{},
- utils.SuffixIndexedFieldsCfg: []string{},
- utils.NestedFieldsCfg: false,
- utils.RateIndexedSelectsCfg: true,
- utils.RatePrefixIndexedFieldsCfg: []string{},
- utils.RateSuffixIndexedFieldsCfg: []string{},
- utils.RateNestedFieldsCfg: false,
- utils.Verbosity: 1000,
- },
- }
- cfgCgr := NewDefaultCGRConfig()
- if err := cfgCgr.V1GetConfig(&SectionWithAPIOpts{Section: RateSJson}, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(reply, expected) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(reply))
- }
-}
-
func TestV1GetConfigSectionInvalidSection(t *testing.T) {
var reply map[string]interface{}
expected := "Invalid section"
@@ -4813,7 +4702,7 @@ func TestV1GetConfigAsJSONGeneral(t *testing.T) {
func TestV1GetConfigAsJSONDataDB(t *testing.T) {
var reply string
- expected := `{"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*account_action_plans":{"remote":false,"replicate":false},"*accounts":{"remote":false,"replicate":false},"*action_plans":{"remote":false,"replicate":false},"*action_profiles":{"remote":false,"replicate":false},"*action_triggers":{"remote":false,"replicate":false},"*actions":{"remote":false,"replicate":false},"*attribute_profiles":{"remote":false,"replicate":false},"*charger_profiles":{"remote":false,"replicate":false},"*destinations":{"remote":false,"replicate":false},"*dispatcher_hosts":{"remote":false,"replicate":false},"*dispatcher_profiles":{"remote":false,"replicate":false},"*filters":{"remote":false,"replicate":false},"*indexes":{"remote":false,"replicate":false},"*load_ids":{"remote":false,"replicate":false},"*rate_profiles":{"remote":false,"replicate":false},"*rating_plans":{"remote":false,"replicate":false},"*rating_profiles":{"remote":false,"replicate":false},"*resource_profiles":{"remote":false,"replicate":false},"*resources":{"remote":false,"replicate":false},"*reverse_destinations":{"remote":false,"replicate":false},"*route_profiles":{"remote":false,"replicate":false},"*shared_groups":{"remote":false,"replicate":false},"*statqueue_profiles":{"remote":false,"replicate":false},"*statqueues":{"remote":false,"replicate":false},"*threshold_profiles":{"remote":false,"replicate":false},"*thresholds":{"remote":false,"replicate":false},"*timings":{"remote":false,"replicate":false}},"opts":{"query_timeout":"10s","redis_ca_certificate":"","redis_client_certificate":"","redis_client_key":"","redis_cluster":false,"redis_cluster_ondown_delay":"0","redis_cluster_sync":"5s","redis_sentinel":"","redis_tls":false},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false}}`
+ expected := `{"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*account_action_plans":{"remote":false,"replicate":false},"*accounts":{"remote":false,"replicate":false},"*action_plans":{"remote":false,"replicate":false},"*action_triggers":{"remote":false,"replicate":false},"*actions":{"remote":false,"replicate":false},"*attribute_profiles":{"remote":false,"replicate":false},"*charger_profiles":{"remote":false,"replicate":false},"*destinations":{"remote":false,"replicate":false},"*dispatcher_hosts":{"remote":false,"replicate":false},"*dispatcher_profiles":{"remote":false,"replicate":false},"*filters":{"remote":false,"replicate":false},"*indexes":{"remote":false,"replicate":false},"*load_ids":{"remote":false,"replicate":false},"*rating_plans":{"remote":false,"replicate":false},"*rating_profiles":{"remote":false,"replicate":false},"*resource_profiles":{"remote":false,"replicate":false},"*resources":{"remote":false,"replicate":false},"*reverse_destinations":{"remote":false,"replicate":false},"*route_profiles":{"remote":false,"replicate":false},"*shared_groups":{"remote":false,"replicate":false},"*statqueue_profiles":{"remote":false,"replicate":false},"*statqueues":{"remote":false,"replicate":false},"*threshold_profiles":{"remote":false,"replicate":false},"*thresholds":{"remote":false,"replicate":false},"*timings":{"remote":false,"replicate":false}},"opts":{"query_timeout":"10s","redis_ca_certificate":"","redis_client_certificate":"","redis_client_key":"","redis_cluster":false,"redis_cluster_ondown_delay":"0","redis_cluster_sync":"5s","redis_sentinel":"","redis_tls":false},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false}}`
cfgCgr := NewDefaultCGRConfig()
if err := cfgCgr.V1GetConfigAsJSON(&SectionWithAPIOpts{Section: DATADB_JSN}, &reply); err != nil {
t.Error(err)
@@ -4824,7 +4713,7 @@ func TestV1GetConfigAsJSONDataDB(t *testing.T) {
func TestV1GetConfigAsJSONStorDB(t *testing.T) {
var reply string
- expected := `{"stor_db":{"db_host":"127.0.0.1","db_name":"cgrates","db_password":"","db_port":3306,"db_type":"*mysql","db_user":"cgrates","items":{"*cdrs":{"remote":false,"replicate":false},"*session_costs":{"remote":false,"replicate":false},"*tp_account_actions":{"remote":false,"replicate":false},"*tp_action_plans":{"remote":false,"replicate":false},"*tp_action_profiles":{"remote":false,"replicate":false},"*tp_action_triggers":{"remote":false,"replicate":false},"*tp_actions":{"remote":false,"replicate":false},"*tp_attributes":{"remote":false,"replicate":false},"*tp_chargers":{"remote":false,"replicate":false},"*tp_destination_rates":{"remote":false,"replicate":false},"*tp_destinations":{"remote":false,"replicate":false},"*tp_dispatcher_hosts":{"remote":false,"replicate":false},"*tp_dispatcher_profiles":{"remote":false,"replicate":false},"*tp_filters":{"remote":false,"replicate":false},"*tp_rate_profiles":{"remote":false,"replicate":false},"*tp_rates":{"remote":false,"replicate":false},"*tp_rating_plans":{"remote":false,"replicate":false},"*tp_rating_profiles":{"remote":false,"replicate":false},"*tp_resources":{"remote":false,"replicate":false},"*tp_routes":{"remote":false,"replicate":false},"*tp_shared_groups":{"remote":false,"replicate":false},"*tp_stats":{"remote":false,"replicate":false},"*tp_thresholds":{"remote":false,"replicate":false},"*tp_timings":{"remote":false,"replicate":false},"*versions":{"remote":false,"replicate":false}},"opts":{"conn_max_lifetime":0,"max_idle_conns":10,"max_open_conns":100,"mysql_location":"Local","query_timeout":"10s","sslmode":"disable"},"prefix_indexed_fields":[],"remote_conns":null,"replication_conns":null,"string_indexed_fields":[]}}`
+ expected := `{"stor_db":{"db_host":"127.0.0.1","db_name":"cgrates","db_password":"","db_port":3306,"db_type":"*mysql","db_user":"cgrates","items":{"*cdrs":{"remote":false,"replicate":false},"*session_costs":{"remote":false,"replicate":false},"*tp_account_actions":{"remote":false,"replicate":false},"*tp_action_plans":{"remote":false,"replicate":false},"*tp_action_triggers":{"remote":false,"replicate":false},"*tp_actions":{"remote":false,"replicate":false},"*tp_attributes":{"remote":false,"replicate":false},"*tp_chargers":{"remote":false,"replicate":false},"*tp_destination_rates":{"remote":false,"replicate":false},"*tp_destinations":{"remote":false,"replicate":false},"*tp_dispatcher_hosts":{"remote":false,"replicate":false},"*tp_dispatcher_profiles":{"remote":false,"replicate":false},"*tp_filters":{"remote":false,"replicate":false},"*tp_rates":{"remote":false,"replicate":false},"*tp_rating_plans":{"remote":false,"replicate":false},"*tp_rating_profiles":{"remote":false,"replicate":false},"*tp_resources":{"remote":false,"replicate":false},"*tp_routes":{"remote":false,"replicate":false},"*tp_shared_groups":{"remote":false,"replicate":false},"*tp_stats":{"remote":false,"replicate":false},"*tp_thresholds":{"remote":false,"replicate":false},"*tp_timings":{"remote":false,"replicate":false},"*versions":{"remote":false,"replicate":false}},"opts":{"conn_max_lifetime":0,"max_idle_conns":10,"max_open_conns":100,"mysql_location":"Local","query_timeout":"10s","sslmode":"disable"},"prefix_indexed_fields":[],"remote_conns":null,"replication_conns":null,"string_indexed_fields":[]}}`
cfgCgr := NewDefaultCGRConfig()
if err := cfgCgr.V1GetConfigAsJSON(&SectionWithAPIOpts{Section: STORDB_JSN}, &reply); err != nil {
t.Error(err)
@@ -4846,7 +4735,7 @@ func TestV1GetConfigAsJSONTls(t *testing.T) {
func TestV1GetConfigAsJSONTCache(t *testing.T) {
var reply string
- expected := `{"caches":{"partitions":{"*account_action_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_triggers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*actions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*apiban":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*attribute_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*caps_events":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*cdr_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*cdrs":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*charger_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*charger_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*closed_sessions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*destinations":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*diameter_messages":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_loads":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*event_charges":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*load_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rate_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rating_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rating_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*replication_hosts":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resource_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resource_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*reverse_destinations":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*reverse_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*route_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*route_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rpc_connections":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rpc_responses":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*session_costs":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*shared_groups":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*stat_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*statqueue_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*statqueues":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*stir":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*threshold_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*timings":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_account_actions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_action_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_action_triggers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_actions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_attributes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_chargers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_destination_rates":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_destinations":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rates":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rating_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rating_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_shared_groups":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_stats":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_timings":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*uch":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*versions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""}},"replication_conns":[]}}`
+ expected := `{"caches":{"partitions":{"*account_action_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_triggers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*actions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*apiban":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*attribute_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*caps_events":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*cdr_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*cdrs":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*charger_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*charger_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*closed_sessions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*destinations":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*diameter_messages":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_loads":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*event_charges":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*load_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rating_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rating_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*replication_hosts":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resource_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resource_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*reverse_destinations":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*reverse_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*route_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*route_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rpc_connections":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rpc_responses":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*session_costs":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*shared_groups":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*stat_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*statqueue_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*statqueues":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*stir":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*threshold_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*timings":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_account_actions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_action_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_action_triggers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_actions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_attributes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_chargers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_destination_rates":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_destinations":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rates":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rating_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rating_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_shared_groups":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_stats":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_timings":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*uch":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*versions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""}},"replication_conns":[]}}`
cfgCgr := NewDefaultCGRConfig()
if err := cfgCgr.V1GetConfigAsJSON(&SectionWithAPIOpts{Section: CACHE_JSN}, &reply); err != nil {
t.Error(err)
@@ -4866,17 +4755,6 @@ func TestV1GetConfigAsJSONTListen(t *testing.T) {
}
}
-func TestV1GetConfigAsJSONAccounts(t *testing.T) {
- var reply string
- expected := `{"accounts":{"attributes_conns":[],"enabled":false,"indexed_selects":true,"max_iterations":1000,"max_usage":259200000000000,"nested_fields":false,"prefix_indexed_fields":[],"rates_conns":[],"suffix_indexed_fields":[],"thresholds_conns":[]}}`
- cfg := NewDefaultCGRConfig()
- if err := cfg.V1GetConfigAsJSON(&SectionWithAPIOpts{Section: AccountSCfgJson}, &reply); err != nil {
- t.Error(err)
- } else if expected != reply {
- t.Errorf("Expected %+v \n, received %+v", expected, reply)
- }
-}
-
func TestV1GetConfigAsJSONHTTP(t *testing.T) {
var reply string
expected := `{"http":{"auth_users":{},"client_opts":{"dialFallbackDelay":"300ms","dialKeepAlive":"30s","dialTimeout":"30s","disableCompression":false,"disableKeepAlives":false,"expectContinueTimeout":"0","forceAttemptHttp2":true,"idleConnTimeout":"90s","maxConnsPerHost":0,"maxIdleConns":100,"maxIdleConnsPerHost":2,"responseHeaderTimeout":"0","skipTlsVerify":false,"tlsHandshakeTimeout":"10s"},"freeswitch_cdrs_url":"/freeswitch_json","http_cdrs":"/cdr_http","json_rpc_url":"/jsonrpc","registrars_url":"/registrar","use_basic_auth":false,"ws_url":"/ws"}}`
@@ -5112,7 +4990,7 @@ func TestV1GetConfigAsJSONDispatcherH(t *testing.T) {
func TestV1GetConfigAsJSONLoaders(t *testing.T) {
var reply string
- expected := `{"loaders":[{"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"Contexts","tag":"Contexts","type":"*variable","value":"~*req.2"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.3"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.4"},{"path":"AttributeFilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Path","tag":"Path","type":"*variable","value":"~*req.6"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.7"},{"path":"Value","tag":"Value","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.10"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Values","tag":"Values","type":"*variable","value":"~*req.4"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.5"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.9"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.10"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.6"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.7"},{"path":"MetricFilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.11"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.8"},{"path":"ActionIDs","tag":"ActionIDs","type":"*variable","value":"~*req.9"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.10"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.4"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.5"},{"path":"RouteID","tag":"RouteID","type":"*variable","value":"~*req.6"},{"path":"RouteFilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.7"},{"path":"RouteAccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.8"},{"path":"RouteRatingPlanIDs","tag":"RouteRatingPlanIDs","type":"*variable","value":"~*req.9"},{"path":"RouteResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.10"},{"path":"RouteStatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.11"},{"path":"RouteWeight","tag":"RouteWeight","type":"*variable","value":"~*req.12"},{"path":"RouteBlocker","tag":"RouteBlocker","type":"*variable","value":"~*req.13"},{"path":"RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.14"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.4"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.5"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Contexts","tag":"Contexts","type":"*variable","value":"~*req.2"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.3"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.4"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.5"},{"path":"StrategyParameters","tag":"StrategyParameters","type":"*variable","value":"~*req.6"},{"path":"ConnID","tag":"ConnID","type":"*variable","value":"~*req.7"},{"path":"ConnFilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.8"},{"path":"ConnWeight","tag":"ConnWeight","type":"*variable","value":"~*req.9"},{"path":"ConnBlocker","tag":"ConnBlocker","type":"*variable","value":"~*req.10"},{"path":"ConnParameters","tag":"ConnParameters","type":"*variable","value":"~*req.11"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.12"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.4"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.4"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.5"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.6"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.7"},{"path":"RateID","tag":"RateID","type":"*variable","value":"~*req.8"},{"path":"RateFilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.9"},{"path":"RateActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.10"},{"path":"RateWeight","tag":"RateWeight","type":"*variable","value":"~*req.11"},{"path":"RateBlocker","tag":"RateBlocker","type":"*variable","value":"~*req.12"},{"path":"RateIntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.13"},{"path":"RateFixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.14"},{"path":"RateRecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.15"},{"path":"RateUnit","tag":"RateUnit","type":"*variable","value":"~*req.16"},{"path":"RateIncrement","tag":"RateIncrement","type":"*variable","value":"~*req.17"}],"file_name":"RateProfiles.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.4"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.5"},{"path":"TargetType","tag":"TargetType","type":"*variable","value":"~*req.6"},{"path":"TargetIDs","tag":"TargetIDs","type":"*variable","value":"~*req.7"},{"path":"ActionID","tag":"ActionID","type":"*variable","value":"~*req.8"},{"path":"ActionFilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.9"},{"path":"ActionBlocker","tag":"ActionBlocker","type":"*variable","value":"~*req.10"},{"path":"ActionTTL","tag":"ActionTTL","type":"*variable","value":"~*req.11"},{"path":"ActionType","tag":"ActionType","type":"*variable","value":"~*req.12"},{"path":"ActionOpts","tag":"ActionOpts","type":"*variable","value":"~*req.13"},{"path":"ActionPath","tag":"ActionPath","type":"*variable","value":"~*req.14"},{"path":"ActionValue","tag":"ActionValue","type":"*variable","value":"~*req.15"}],"file_name":"ActionProfiles.csv","flags":null,"type":"*action_profiles"}],"dry_run":false,"enabled":false,"field_separator":",","id":"*default","lock_filename":".cgr.lck","run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}]}`
+ expected := `{"loaders":[{"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"Contexts","tag":"Contexts","type":"*variable","value":"~*req.2"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.3"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.4"},{"path":"AttributeFilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Path","tag":"Path","type":"*variable","value":"~*req.6"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.7"},{"path":"Value","tag":"Value","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.10"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Values","tag":"Values","type":"*variable","value":"~*req.4"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.5"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.9"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.10"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.6"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.7"},{"path":"MetricFilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.11"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.8"},{"path":"ActionIDs","tag":"ActionIDs","type":"*variable","value":"~*req.9"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.10"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.4"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.5"},{"path":"RouteID","tag":"RouteID","type":"*variable","value":"~*req.6"},{"path":"RouteFilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.7"},{"path":"RouteAccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.8"},{"path":"RouteRatingPlanIDs","tag":"RouteRatingPlanIDs","type":"*variable","value":"~*req.9"},{"path":"RouteResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.10"},{"path":"RouteStatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.11"},{"path":"RouteWeight","tag":"RouteWeight","type":"*variable","value":"~*req.12"},{"path":"RouteBlocker","tag":"RouteBlocker","type":"*variable","value":"~*req.13"},{"path":"RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.14"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.4"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.5"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Contexts","tag":"Contexts","type":"*variable","value":"~*req.2"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.3"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.4"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.5"},{"path":"StrategyParameters","tag":"StrategyParameters","type":"*variable","value":"~*req.6"},{"path":"ConnID","tag":"ConnID","type":"*variable","value":"~*req.7"},{"path":"ConnFilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.8"},{"path":"ConnWeight","tag":"ConnWeight","type":"*variable","value":"~*req.9"},{"path":"ConnBlocker","tag":"ConnBlocker","type":"*variable","value":"~*req.10"},{"path":"ConnParameters","tag":"ConnParameters","type":"*variable","value":"~*req.11"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.12"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.4"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"}],"dry_run":false,"enabled":false,"field_separator":",","id":"*default","lock_filename":".cgr.lck","run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}]}`
cgrCfg := NewDefaultCGRConfig()
if err := cgrCfg.V1GetConfigAsJSON(&SectionWithAPIOpts{Section: LoaderJson}, &reply); err != nil {
t.Error(err)
@@ -5264,17 +5142,6 @@ func TestV1GetConfigAsJSONAnalyzer(t *testing.T) {
}
}
-func TestV1GetConfigAsJSONRateS(t *testing.T) {
- var reply string
- expected := `{"rates":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"rate_indexed_selects":true,"rate_nested_fields":false,"rate_prefix_indexed_fields":[],"rate_suffix_indexed_fields":[],"suffix_indexed_fields":[],"verbosity":1000}}`
- cgrCfg := NewDefaultCGRConfig()
- if err := cgrCfg.V1GetConfigAsJSON(&SectionWithAPIOpts{Section: RateSJson}, &reply); err != nil {
- t.Error(err)
- } else if expected != reply {
- t.Errorf("Expected %+v \n, received %+v", expected, reply)
- }
-}
-
func TestV1GetConfigAsJSONCoreS(t *testing.T) {
var reply string
expected := `{"cores":{"caps":10,"caps_stats_interval":"0","caps_strategy":"*busy","shutdown_timeout":"1s"}}`
@@ -5346,7 +5213,7 @@ func TestV1GetConfigAsJSONAllConfig(t *testing.T) {
}
}`
var reply string
- expected := `{"accounts":{"attributes_conns":[],"enabled":false,"indexed_selects":true,"max_iterations":1000,"max_usage":259200000000000,"nested_fields":false,"prefix_indexed_fields":[],"rates_conns":[],"suffix_indexed_fields":[],"thresholds_conns":[]},"actions":{"accounts_conns":[],"cdrs_conns":[],"ees_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"stats_conns":[],"suffix_indexed_fields":[],"tenants":[],"thresholds_conns":[]},"analyzers":{"cleanup_interval":"1h0m0s","db_path":"/var/spool/cgrates/analyzers","enabled":false,"index_type":"*scorch","ttl":"24h0m0s"},"apiban":{"enabled":false,"keys":[]},"apiers":{"attributes_conns":[],"caches_conns":["*internal"],"ees_conns":[],"enabled":false,"scheduler_conns":[]},"asterisk_agent":{"asterisk_conns":[{"address":"127.0.0.1:8088","alias":"","connect_attempts":3,"password":"CGRateS.org","reconnects":5,"user":"cgrates"}],"create_cdr":false,"enabled":false,"sessions_conns":["*birpc_internal"]},"attributes":{"apiers_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"process_runs":1,"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"caches":{"partitions":{"*account_action_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_triggers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*actions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*apiban":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*attribute_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*caps_events":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*cdr_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*cdrs":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*charger_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*charger_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*closed_sessions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*destinations":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*diameter_messages":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_loads":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*event_charges":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*load_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rate_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rating_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rating_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*replication_hosts":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resource_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resource_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*reverse_destinations":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*reverse_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*route_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*route_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rpc_connections":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rpc_responses":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*session_costs":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*shared_groups":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*stat_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*statqueue_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*statqueues":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*stir":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*threshold_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*timings":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_account_actions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_action_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_action_triggers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_actions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_attributes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_chargers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_destination_rates":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_destinations":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rates":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rating_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rating_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_shared_groups":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_stats":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_timings":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*uch":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*versions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""}},"replication_conns":[]},"cdrs":{"attributes_conns":[],"chargers_conns":[],"ees_conns":[],"enabled":false,"extra_fields":[],"online_cdr_exports":[],"rals_conns":[],"scheduler_conns":[],"session_cost_retries":5,"stats_conns":[],"store_cdrs":true,"thresholds_conns":[]},"chargers":{"attributes_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"configs":{"enabled":false,"root_dir":"/var/spool/cgrates/configs","url":"/configs/"},"cores":{"caps":0,"caps_stats_interval":"0","caps_strategy":"*busy","shutdown_timeout":"1s"},"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*account_action_plans":{"remote":false,"replicate":false},"*accounts":{"remote":false,"replicate":false},"*action_plans":{"remote":false,"replicate":false},"*action_profiles":{"remote":false,"replicate":false},"*action_triggers":{"remote":false,"replicate":false},"*actions":{"remote":false,"replicate":false},"*attribute_profiles":{"remote":false,"replicate":false},"*charger_profiles":{"remote":false,"replicate":false},"*destinations":{"remote":false,"replicate":false},"*dispatcher_hosts":{"remote":false,"replicate":false},"*dispatcher_profiles":{"remote":false,"replicate":false},"*filters":{"remote":false,"replicate":false},"*indexes":{"remote":false,"replicate":false},"*load_ids":{"remote":false,"replicate":false},"*rate_profiles":{"remote":false,"replicate":false},"*rating_plans":{"remote":false,"replicate":false},"*rating_profiles":{"remote":false,"replicate":false},"*resource_profiles":{"remote":false,"replicate":false},"*resources":{"remote":false,"replicate":false},"*reverse_destinations":{"remote":false,"replicate":false},"*route_profiles":{"remote":false,"replicate":false},"*shared_groups":{"remote":false,"replicate":false},"*statqueue_profiles":{"remote":false,"replicate":false},"*statqueues":{"remote":false,"replicate":false},"*threshold_profiles":{"remote":false,"replicate":false},"*thresholds":{"remote":false,"replicate":false},"*timings":{"remote":false,"replicate":false}},"opts":{"query_timeout":"10s","redis_ca_certificate":"","redis_client_certificate":"","redis_client_key":"","redis_cluster":false,"redis_cluster_ondown_delay":"0","redis_cluster_sync":"5s","redis_sentinel":"","redis_tls":false},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false},"diameter_agent":{"asr_template":"","concurrent_requests":-1,"dictionaries_path":"/usr/share/cgrates/diameter/dict/","enabled":false,"forced_disconnect":"*none","listen":"127.0.0.1:3868","listen_net":"tcp","origin_host":"CGR-DA","origin_realm":"cgrates.org","product_name":"CGRateS","rar_template":"","request_processors":[],"sessions_conns":["*birpc_internal"],"synced_conn_requests":false,"vendor_id":0},"dispatchers":{"attributes_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"dns_agent":{"enabled":false,"listen":"127.0.0.1:2053","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"],"timezone":""},"ees":{"attributes_conns":[],"cache":{"*file_csv":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"enabled":false,"exporters":[{"attempts":1,"attribute_context":"","attribute_ids":[],"export_path":"/var/spool/cgrates/ees","field_separator":",","fields":[],"filters":[],"flags":[],"id":"*default","opts":{},"synchronous":false,"tenant":"","timezone":"","type":"*none"}]},"ers":{"enabled":false,"readers":[{"cache_dump_fields":[],"concurrent_requests":1024,"failed_calls_prefix":"","field_separator":",","fields":[{"mandatory":true,"path":"*cgreq.ToR","tag":"ToR","type":"*variable","value":"~*req.2"},{"mandatory":true,"path":"*cgreq.OriginID","tag":"OriginID","type":"*variable","value":"~*req.3"},{"mandatory":true,"path":"*cgreq.RequestType","tag":"RequestType","type":"*variable","value":"~*req.4"},{"mandatory":true,"path":"*cgreq.Tenant","tag":"Tenant","type":"*variable","value":"~*req.6"},{"mandatory":true,"path":"*cgreq.Category","tag":"Category","type":"*variable","value":"~*req.7"},{"mandatory":true,"path":"*cgreq.Account","tag":"Account","type":"*variable","value":"~*req.8"},{"mandatory":true,"path":"*cgreq.Subject","tag":"Subject","type":"*variable","value":"~*req.9"},{"mandatory":true,"path":"*cgreq.Destination","tag":"Destination","type":"*variable","value":"~*req.10"},{"mandatory":true,"path":"*cgreq.SetupTime","tag":"SetupTime","type":"*variable","value":"~*req.11"},{"mandatory":true,"path":"*cgreq.AnswerTime","tag":"AnswerTime","type":"*variable","value":"~*req.12"},{"mandatory":true,"path":"*cgreq.Usage","tag":"Usage","type":"*variable","value":"~*req.13"}],"filters":[],"flags":[],"header_define_character":":","id":"*default","opts":{},"partial_cache_expiry_action":"","partial_record_cache":"0","processed_path":"/var/spool/cgrates/ers/out","row_length":0,"run_delay":"0","source_path":"/var/spool/cgrates/ers/in","tenant":"","timezone":"","type":"*none","xml_root_path":[""]}],"sessions_conns":["*internal"]},"filters":{"apiers_conns":[],"resources_conns":[],"stats_conns":[]},"freeswitch_agent":{"create_cdr":false,"empty_balance_ann_file":"","empty_balance_context":"","enabled":false,"event_socket_conns":[{"address":"127.0.0.1:8021","alias":"127.0.0.1:8021","password":"ClueCon","reconnects":5}],"extra_fields":"","low_balance_ann_file":"","max_wait_connection":"2s","sessions_conns":["*birpc_internal"],"subscribe_park":true},"general":{"connect_attempts":5,"connect_timeout":"1s","dbdata_encoding":"*msgpack","default_caching":"*reload","default_category":"call","default_request_type":"*rated","default_tenant":"cgrates.org","default_timezone":"Local","digest_equal":":","digest_separator":",","failed_posts_dir":"/var/spool/cgrates/failed_posts","failed_posts_ttl":"5s","locking_timeout":"0","log_level":6,"logger":"*syslog","max_parallel_conns":100,"node_id":"ENGINE1","poster_attempts":3,"reconnects":-1,"reply_timeout":"2s","rounding_decimals":5,"rsr_separator":";","tpexport_dir":"/var/spool/cgrates/tpe"},"http":{"auth_users":{},"client_opts":{"dialFallbackDelay":"300ms","dialKeepAlive":"30s","dialTimeout":"30s","disableCompression":false,"disableKeepAlives":false,"expectContinueTimeout":"0","forceAttemptHttp2":true,"idleConnTimeout":"90s","maxConnsPerHost":0,"maxIdleConns":100,"maxIdleConnsPerHost":2,"responseHeaderTimeout":"0","skipTlsVerify":false,"tlsHandshakeTimeout":"10s"},"freeswitch_cdrs_url":"/freeswitch_json","http_cdrs":"/cdr_http","json_rpc_url":"/jsonrpc","registrars_url":"/registrar","use_basic_auth":false,"ws_url":"/ws"},"http_agent":[],"kamailio_agent":{"create_cdr":false,"enabled":false,"evapi_conns":[{"address":"127.0.0.1:8448","alias":"","reconnects":5}],"sessions_conns":["*birpc_internal"],"timezone":""},"listen":{"http":"127.0.0.1:2080","http_tls":"127.0.0.1:2280","rpc_gob":"127.0.0.1:2013","rpc_gob_tls":"127.0.0.1:2023","rpc_json":"127.0.0.1:2012","rpc_json_tls":"127.0.0.1:2022"},"loader":{"caches_conns":["*localhost"],"data_path":"./","disable_reverse":false,"field_separator":",","gapi_credentials":".gapi/credentials.json","gapi_token":".gapi/token.json","scheduler_conns":["*localhost"],"tpid":""},"loaders":[{"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"Contexts","tag":"Contexts","type":"*variable","value":"~*req.2"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.3"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.4"},{"path":"AttributeFilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Path","tag":"Path","type":"*variable","value":"~*req.6"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.7"},{"path":"Value","tag":"Value","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.10"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Values","tag":"Values","type":"*variable","value":"~*req.4"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.5"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.9"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.10"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.6"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.7"},{"path":"MetricFilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.11"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.8"},{"path":"ActionIDs","tag":"ActionIDs","type":"*variable","value":"~*req.9"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.10"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.4"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.5"},{"path":"RouteID","tag":"RouteID","type":"*variable","value":"~*req.6"},{"path":"RouteFilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.7"},{"path":"RouteAccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.8"},{"path":"RouteRatingPlanIDs","tag":"RouteRatingPlanIDs","type":"*variable","value":"~*req.9"},{"path":"RouteResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.10"},{"path":"RouteStatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.11"},{"path":"RouteWeight","tag":"RouteWeight","type":"*variable","value":"~*req.12"},{"path":"RouteBlocker","tag":"RouteBlocker","type":"*variable","value":"~*req.13"},{"path":"RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.14"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.4"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.5"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Contexts","tag":"Contexts","type":"*variable","value":"~*req.2"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.3"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.4"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.5"},{"path":"StrategyParameters","tag":"StrategyParameters","type":"*variable","value":"~*req.6"},{"path":"ConnID","tag":"ConnID","type":"*variable","value":"~*req.7"},{"path":"ConnFilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.8"},{"path":"ConnWeight","tag":"ConnWeight","type":"*variable","value":"~*req.9"},{"path":"ConnBlocker","tag":"ConnBlocker","type":"*variable","value":"~*req.10"},{"path":"ConnParameters","tag":"ConnParameters","type":"*variable","value":"~*req.11"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.12"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.4"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.4"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.5"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.6"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.7"},{"path":"RateID","tag":"RateID","type":"*variable","value":"~*req.8"},{"path":"RateFilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.9"},{"path":"RateActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.10"},{"path":"RateWeight","tag":"RateWeight","type":"*variable","value":"~*req.11"},{"path":"RateBlocker","tag":"RateBlocker","type":"*variable","value":"~*req.12"},{"path":"RateIntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.13"},{"path":"RateFixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.14"},{"path":"RateRecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.15"},{"path":"RateUnit","tag":"RateUnit","type":"*variable","value":"~*req.16"},{"path":"RateIncrement","tag":"RateIncrement","type":"*variable","value":"~*req.17"}],"file_name":"RateProfiles.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.4"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.5"},{"path":"TargetType","tag":"TargetType","type":"*variable","value":"~*req.6"},{"path":"TargetIDs","tag":"TargetIDs","type":"*variable","value":"~*req.7"},{"path":"ActionID","tag":"ActionID","type":"*variable","value":"~*req.8"},{"path":"ActionFilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.9"},{"path":"ActionBlocker","tag":"ActionBlocker","type":"*variable","value":"~*req.10"},{"path":"ActionTTL","tag":"ActionTTL","type":"*variable","value":"~*req.11"},{"path":"ActionType","tag":"ActionType","type":"*variable","value":"~*req.12"},{"path":"ActionOpts","tag":"ActionOpts","type":"*variable","value":"~*req.13"},{"path":"ActionPath","tag":"ActionPath","type":"*variable","value":"~*req.14"},{"path":"ActionValue","tag":"ActionValue","type":"*variable","value":"~*req.15"}],"file_name":"ActionProfiles.csv","flags":null,"type":"*action_profiles"}],"dry_run":false,"enabled":false,"field_separator":",","id":"*default","lock_filename":".cgr.lck","run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}],"mailer":{"auth_password":"CGRateS.org","auth_user":"cgrates","from_address":"cgr-mailer@localhost.localdomain","server":"localhost"},"migrator":{"out_datadb_encoding":"msgpack","out_datadb_host":"127.0.0.1","out_datadb_name":"10","out_datadb_opts":{"redis_ca_certificate":"","redis_client_certificate":"","redis_client_key":"","redis_cluster":false,"redis_cluster_ondown_delay":"0","redis_cluster_sync":"5s","redis_sentinel":"","redis_tls":false},"out_datadb_password":"","out_datadb_port":"6379","out_datadb_type":"redis","out_datadb_user":"cgrates","out_stordb_host":"127.0.0.1","out_stordb_name":"cgrates","out_stordb_opts":{},"out_stordb_password":"","out_stordb_port":"3306","out_stordb_type":"mysql","out_stordb_user":"cgrates","users_filters":[]},"radius_agent":{"client_dictionaries":{"*default":"/usr/share/cgrates/radius/dict/"},"client_secrets":{"*default":"CGRateS.org"},"enabled":false,"listen_acct":"127.0.0.1:1813","listen_auth":"127.0.0.1:1812","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"]},"rals":{"balance_rating_subject":{"*any":"*zero1ns","*voice":"*zero1s"},"caches_conns":["*internal"],"dynaprepaid_actionplans":[],"enabled":false,"max_computed_usage":{"*any":"189h0m0s","*data":"107374182400","*mms":"10000","*sms":"10000","*voice":"72h0m0s"},"max_increments":1000000,"remove_expired":true,"rp_subject_prefix_matching":false,"stats_conns":[],"thresholds_conns":[]},"rates":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"rate_indexed_selects":true,"rate_nested_fields":false,"rate_prefix_indexed_fields":[],"rate_suffix_indexed_fields":[],"suffix_indexed_fields":[],"verbosity":1000},"registrarc":{"dispatcher":{"enabled":false,"hosts":{},"refresh_interval":"5m0s","registrars_conns":[]},"rpc":{"enabled":false,"hosts":{},"refresh_interval":"5m0s","registrars_conns":[]}},"resources":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[],"thresholds_conns":[]},"routes":{"attributes_conns":[],"default_ratio":1,"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"rals_conns":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"rpc_conns":{"*bijson_localhost":{"conns":[{"address":"127.0.0.1:2014","transport":"*birpc_json"}],"poolSize":0,"strategy":"*first"},"*birpc_internal":{"conns":[{"address":"*birpc_internal","transport":""}],"poolSize":0,"strategy":"*first"},"*internal":{"conns":[{"address":"*internal","transport":""}],"poolSize":0,"strategy":"*first"},"*localhost":{"conns":[{"address":"127.0.0.1:2012","transport":"*json"}],"poolSize":0,"strategy":"*first"}},"schedulers":{"cdrs_conns":[],"enabled":false,"filters":[],"stats_conns":[],"thresholds_conns":[]},"sessions":{"alterable_fields":[],"attributes_conns":[],"cdrs_conns":[],"channel_sync_interval":"0","chargers_conns":[],"client_protocol":1,"debit_interval":"0","default_usage":{"*any":"3h0m0s","*data":"1048576","*sms":"1","*voice":"3h0m0s"},"enabled":false,"listen_bigob":"","listen_bijson":"127.0.0.1:2014","min_dur_low_balance":"0","rals_conns":[],"replication_conns":[],"resources_conns":[],"routes_conns":[],"scheduler_conns":[],"session_indexes":[],"session_ttl":"0","stats_conns":[],"stir":{"allowed_attest":["*any"],"default_attest":"A","payload_maxduration":"-1","privatekey_path":"","publickey_path":""},"store_session_costs":false,"terminate_attempts":5,"thresholds_conns":[]},"sip_agent":{"enabled":false,"listen":"127.0.0.1:5060","listen_net":"udp","request_processors":[],"retransmission_timer":1000000000,"sessions_conns":["*internal"],"timezone":""},"stats":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"store_interval":"","store_uncompressed_limit":0,"suffix_indexed_fields":[],"thresholds_conns":[]},"stor_db":{"db_host":"127.0.0.1","db_name":"cgrates","db_password":"","db_port":3306,"db_type":"*mysql","db_user":"cgrates","items":{"*cdrs":{"remote":false,"replicate":false},"*session_costs":{"remote":false,"replicate":false},"*tp_account_actions":{"remote":false,"replicate":false},"*tp_action_plans":{"remote":false,"replicate":false},"*tp_action_profiles":{"remote":false,"replicate":false},"*tp_action_triggers":{"remote":false,"replicate":false},"*tp_actions":{"remote":false,"replicate":false},"*tp_attributes":{"remote":false,"replicate":false},"*tp_chargers":{"remote":false,"replicate":false},"*tp_destination_rates":{"remote":false,"replicate":false},"*tp_destinations":{"remote":false,"replicate":false},"*tp_dispatcher_hosts":{"remote":false,"replicate":false},"*tp_dispatcher_profiles":{"remote":false,"replicate":false},"*tp_filters":{"remote":false,"replicate":false},"*tp_rate_profiles":{"remote":false,"replicate":false},"*tp_rates":{"remote":false,"replicate":false},"*tp_rating_plans":{"remote":false,"replicate":false},"*tp_rating_profiles":{"remote":false,"replicate":false},"*tp_resources":{"remote":false,"replicate":false},"*tp_routes":{"remote":false,"replicate":false},"*tp_shared_groups":{"remote":false,"replicate":false},"*tp_stats":{"remote":false,"replicate":false},"*tp_thresholds":{"remote":false,"replicate":false},"*tp_timings":{"remote":false,"replicate":false},"*versions":{"remote":false,"replicate":false}},"opts":{"conn_max_lifetime":0,"max_idle_conns":10,"max_open_conns":100,"mysql_location":"Local","query_timeout":"10s","sslmode":"disable"},"prefix_indexed_fields":[],"remote_conns":null,"replication_conns":null,"string_indexed_fields":[]},"suretax":{"bill_to_number":"","business_unit":"","client_number":"","client_tracking":"~*req.CGRID","customer_number":"~*req.Subject","include_local_cost":false,"orig_number":"~*req.Subject","p2pplus4":"","p2pzipcode":"","plus4":"","regulatory_code":"03","response_group":"03","response_type":"D4","return_file_code":"0","sales_type_code":"R","tax_exemption_code_list":"","tax_included":"0","tax_situs_rule":"04","term_number":"~*req.Destination","timezone":"UTC","trans_type_code":"010101","unit_type":"00","units":"1","url":"","validation_key":"","zipcode":""},"templates":{"*asr":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"}],"*cca":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"path":"*rep.Result-Code","tag":"ResultCode","type":"*constant","value":"2001"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"},{"mandatory":true,"path":"*rep.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"mandatory":true,"path":"*rep.CC-Request-Type","tag":"CCRequestType","type":"*variable","value":"~*req.CC-Request-Type"},{"mandatory":true,"path":"*rep.CC-Request-Number","tag":"CCRequestNumber","type":"*variable","value":"~*req.CC-Request-Number"}],"*cdrLog":[{"mandatory":true,"path":"*cdr.ToR","tag":"ToR","type":"*variable","value":"~*req.BalanceType"},{"mandatory":true,"path":"*cdr.OriginHost","tag":"OriginHost","type":"*constant","value":"127.0.0.1"},{"mandatory":true,"path":"*cdr.RequestType","tag":"RequestType","type":"*constant","value":"*none"},{"mandatory":true,"path":"*cdr.Tenant","tag":"Tenant","type":"*variable","value":"~*req.Tenant"},{"mandatory":true,"path":"*cdr.Account","tag":"Account","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Subject","tag":"Subject","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Cost","tag":"Cost","type":"*variable","value":"~*req.Cost"},{"mandatory":true,"path":"*cdr.Source","tag":"Source","type":"*constant","value":"*cdrLog"},{"mandatory":true,"path":"*cdr.Usage","tag":"Usage","type":"*constant","value":"1"},{"mandatory":true,"path":"*cdr.RunID","tag":"RunID","type":"*variable","value":"~*req.ActionType"},{"mandatory":true,"path":"*cdr.SetupTime","tag":"SetupTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.AnswerTime","tag":"AnswerTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.PreRated","tag":"PreRated","type":"*constant","value":"true"}],"*err":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"}],"*errSip":[{"mandatory":true,"path":"*rep.Request","tag":"Request","type":"*constant","value":"SIP/2.0 500 Internal Server Error"}],"*rar":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"path":"*diamreq.Re-Auth-Request-Type","tag":"ReAuthRequestType","type":"*constant","value":"0"}]},"thresholds":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[]},"tls":{"ca_certificate":"","client_certificate":"","client_key":"","server_certificate":"","server_key":"","server_name":"","server_policy":4}}`
+ expected := `{"analyzers":{"cleanup_interval":"1h0m0s","db_path":"/var/spool/cgrates/analyzers","enabled":false,"index_type":"*scorch","ttl":"24h0m0s"},"apiban":{"enabled":false,"keys":[]},"apiers":{"attributes_conns":[],"caches_conns":["*internal"],"ees_conns":[],"enabled":false,"scheduler_conns":[]},"asterisk_agent":{"asterisk_conns":[{"address":"127.0.0.1:8088","alias":"","connect_attempts":3,"password":"CGRateS.org","reconnects":5,"user":"cgrates"}],"create_cdr":false,"enabled":false,"sessions_conns":["*birpc_internal"]},"attributes":{"apiers_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"process_runs":1,"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"caches":{"partitions":{"*account_action_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_triggers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*actions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*apiban":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*attribute_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*caps_events":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*cdr_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*cdrs":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*charger_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*charger_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*closed_sessions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*destinations":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*diameter_messages":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_loads":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*event_charges":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*load_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rating_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rating_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*replication_hosts":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resource_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resource_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*reverse_destinations":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*reverse_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*route_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*route_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rpc_connections":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rpc_responses":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*session_costs":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*shared_groups":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*stat_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*statqueue_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*statqueues":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*stir":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*threshold_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*timings":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_account_actions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_action_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_action_triggers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_actions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_attributes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_chargers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_destination_rates":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_destinations":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rates":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rating_plans":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rating_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_shared_groups":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_stats":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_timings":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*uch":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*versions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""}},"replication_conns":[]},"cdrs":{"attributes_conns":[],"chargers_conns":[],"ees_conns":[],"enabled":false,"extra_fields":[],"online_cdr_exports":[],"rals_conns":[],"scheduler_conns":[],"session_cost_retries":5,"stats_conns":[],"store_cdrs":true,"thresholds_conns":[]},"chargers":{"attributes_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"configs":{"enabled":false,"root_dir":"/var/spool/cgrates/configs","url":"/configs/"},"cores":{"caps":0,"caps_stats_interval":"0","caps_strategy":"*busy","shutdown_timeout":"1s"},"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*account_action_plans":{"remote":false,"replicate":false},"*accounts":{"remote":false,"replicate":false},"*action_plans":{"remote":false,"replicate":false},"*action_triggers":{"remote":false,"replicate":false},"*actions":{"remote":false,"replicate":false},"*attribute_profiles":{"remote":false,"replicate":false},"*charger_profiles":{"remote":false,"replicate":false},"*destinations":{"remote":false,"replicate":false},"*dispatcher_hosts":{"remote":false,"replicate":false},"*dispatcher_profiles":{"remote":false,"replicate":false},"*filters":{"remote":false,"replicate":false},"*indexes":{"remote":false,"replicate":false},"*load_ids":{"remote":false,"replicate":false},"*rating_plans":{"remote":false,"replicate":false},"*rating_profiles":{"remote":false,"replicate":false},"*resource_profiles":{"remote":false,"replicate":false},"*resources":{"remote":false,"replicate":false},"*reverse_destinations":{"remote":false,"replicate":false},"*route_profiles":{"remote":false,"replicate":false},"*shared_groups":{"remote":false,"replicate":false},"*statqueue_profiles":{"remote":false,"replicate":false},"*statqueues":{"remote":false,"replicate":false},"*threshold_profiles":{"remote":false,"replicate":false},"*thresholds":{"remote":false,"replicate":false},"*timings":{"remote":false,"replicate":false}},"opts":{"query_timeout":"10s","redis_ca_certificate":"","redis_client_certificate":"","redis_client_key":"","redis_cluster":false,"redis_cluster_ondown_delay":"0","redis_cluster_sync":"5s","redis_sentinel":"","redis_tls":false},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false},"diameter_agent":{"asr_template":"","concurrent_requests":-1,"dictionaries_path":"/usr/share/cgrates/diameter/dict/","enabled":false,"forced_disconnect":"*none","listen":"127.0.0.1:3868","listen_net":"tcp","origin_host":"CGR-DA","origin_realm":"cgrates.org","product_name":"CGRateS","rar_template":"","request_processors":[],"sessions_conns":["*birpc_internal"],"synced_conn_requests":false,"vendor_id":0},"dispatchers":{"attributes_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"dns_agent":{"enabled":false,"listen":"127.0.0.1:2053","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"],"timezone":""},"ees":{"attributes_conns":[],"cache":{"*file_csv":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"enabled":false,"exporters":[{"attempts":1,"attribute_context":"","attribute_ids":[],"export_path":"/var/spool/cgrates/ees","field_separator":",","fields":[],"filters":[],"flags":[],"id":"*default","opts":{},"synchronous":false,"tenant":"","timezone":"","type":"*none"}]},"ers":{"enabled":false,"readers":[{"cache_dump_fields":[],"concurrent_requests":1024,"failed_calls_prefix":"","field_separator":",","fields":[{"mandatory":true,"path":"*cgreq.ToR","tag":"ToR","type":"*variable","value":"~*req.2"},{"mandatory":true,"path":"*cgreq.OriginID","tag":"OriginID","type":"*variable","value":"~*req.3"},{"mandatory":true,"path":"*cgreq.RequestType","tag":"RequestType","type":"*variable","value":"~*req.4"},{"mandatory":true,"path":"*cgreq.Tenant","tag":"Tenant","type":"*variable","value":"~*req.6"},{"mandatory":true,"path":"*cgreq.Category","tag":"Category","type":"*variable","value":"~*req.7"},{"mandatory":true,"path":"*cgreq.Account","tag":"Account","type":"*variable","value":"~*req.8"},{"mandatory":true,"path":"*cgreq.Subject","tag":"Subject","type":"*variable","value":"~*req.9"},{"mandatory":true,"path":"*cgreq.Destination","tag":"Destination","type":"*variable","value":"~*req.10"},{"mandatory":true,"path":"*cgreq.SetupTime","tag":"SetupTime","type":"*variable","value":"~*req.11"},{"mandatory":true,"path":"*cgreq.AnswerTime","tag":"AnswerTime","type":"*variable","value":"~*req.12"},{"mandatory":true,"path":"*cgreq.Usage","tag":"Usage","type":"*variable","value":"~*req.13"}],"filters":[],"flags":[],"header_define_character":":","id":"*default","opts":{},"partial_cache_expiry_action":"","partial_record_cache":"0","processed_path":"/var/spool/cgrates/ers/out","row_length":0,"run_delay":"0","source_path":"/var/spool/cgrates/ers/in","tenant":"","timezone":"","type":"*none","xml_root_path":[""]}],"sessions_conns":["*internal"]},"filters":{"apiers_conns":[],"resources_conns":[],"stats_conns":[]},"freeswitch_agent":{"create_cdr":false,"empty_balance_ann_file":"","empty_balance_context":"","enabled":false,"event_socket_conns":[{"address":"127.0.0.1:8021","alias":"127.0.0.1:8021","password":"ClueCon","reconnects":5}],"extra_fields":"","low_balance_ann_file":"","max_wait_connection":"2s","sessions_conns":["*birpc_internal"],"subscribe_park":true},"general":{"connect_attempts":5,"connect_timeout":"1s","dbdata_encoding":"*msgpack","default_caching":"*reload","default_category":"call","default_request_type":"*rated","default_tenant":"cgrates.org","default_timezone":"Local","digest_equal":":","digest_separator":",","failed_posts_dir":"/var/spool/cgrates/failed_posts","failed_posts_ttl":"5s","locking_timeout":"0","log_level":6,"logger":"*syslog","max_parallel_conns":100,"node_id":"ENGINE1","poster_attempts":3,"reconnects":-1,"reply_timeout":"2s","rounding_decimals":5,"rsr_separator":";","tpexport_dir":"/var/spool/cgrates/tpe"},"http":{"auth_users":{},"client_opts":{"dialFallbackDelay":"300ms","dialKeepAlive":"30s","dialTimeout":"30s","disableCompression":false,"disableKeepAlives":false,"expectContinueTimeout":"0","forceAttemptHttp2":true,"idleConnTimeout":"90s","maxConnsPerHost":0,"maxIdleConns":100,"maxIdleConnsPerHost":2,"responseHeaderTimeout":"0","skipTlsVerify":false,"tlsHandshakeTimeout":"10s"},"freeswitch_cdrs_url":"/freeswitch_json","http_cdrs":"/cdr_http","json_rpc_url":"/jsonrpc","registrars_url":"/registrar","use_basic_auth":false,"ws_url":"/ws"},"http_agent":[],"kamailio_agent":{"create_cdr":false,"enabled":false,"evapi_conns":[{"address":"127.0.0.1:8448","alias":"","reconnects":5}],"sessions_conns":["*birpc_internal"],"timezone":""},"listen":{"http":"127.0.0.1:2080","http_tls":"127.0.0.1:2280","rpc_gob":"127.0.0.1:2013","rpc_gob_tls":"127.0.0.1:2023","rpc_json":"127.0.0.1:2012","rpc_json_tls":"127.0.0.1:2022"},"loader":{"caches_conns":["*localhost"],"data_path":"./","disable_reverse":false,"field_separator":",","gapi_credentials":".gapi/credentials.json","gapi_token":".gapi/token.json","scheduler_conns":["*localhost"],"tpid":""},"loaders":[{"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"Contexts","tag":"Contexts","type":"*variable","value":"~*req.2"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.3"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.4"},{"path":"AttributeFilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Path","tag":"Path","type":"*variable","value":"~*req.6"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.7"},{"path":"Value","tag":"Value","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.10"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Values","tag":"Values","type":"*variable","value":"~*req.4"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.5"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.9"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.10"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.6"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.7"},{"path":"MetricFilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.11"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.12"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.8"},{"path":"ActionIDs","tag":"ActionIDs","type":"*variable","value":"~*req.9"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.10"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.4"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.5"},{"path":"RouteID","tag":"RouteID","type":"*variable","value":"~*req.6"},{"path":"RouteFilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.7"},{"path":"RouteAccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.8"},{"path":"RouteRatingPlanIDs","tag":"RouteRatingPlanIDs","type":"*variable","value":"~*req.9"},{"path":"RouteResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.10"},{"path":"RouteStatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.11"},{"path":"RouteWeight","tag":"RouteWeight","type":"*variable","value":"~*req.12"},{"path":"RouteBlocker","tag":"RouteBlocker","type":"*variable","value":"~*req.13"},{"path":"RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.14"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.15"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.3"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.4"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.5"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.6"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Contexts","tag":"Contexts","type":"*variable","value":"~*req.2"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.3"},{"path":"ActivationInterval","tag":"ActivationInterval","type":"*variable","value":"~*req.4"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.5"},{"path":"StrategyParameters","tag":"StrategyParameters","type":"*variable","value":"~*req.6"},{"path":"ConnID","tag":"ConnID","type":"*variable","value":"~*req.7"},{"path":"ConnFilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.8"},{"path":"ConnWeight","tag":"ConnWeight","type":"*variable","value":"~*req.9"},{"path":"ConnBlocker","tag":"ConnBlocker","type":"*variable","value":"~*req.10"},{"path":"ConnParameters","tag":"ConnParameters","type":"*variable","value":"~*req.11"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.12"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.4"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"}],"dry_run":false,"enabled":false,"field_separator":",","id":"*default","lock_filename":".cgr.lck","run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}],"mailer":{"auth_password":"CGRateS.org","auth_user":"cgrates","from_address":"cgr-mailer@localhost.localdomain","server":"localhost"},"migrator":{"out_datadb_encoding":"msgpack","out_datadb_host":"127.0.0.1","out_datadb_name":"10","out_datadb_opts":{"redis_ca_certificate":"","redis_client_certificate":"","redis_client_key":"","redis_cluster":false,"redis_cluster_ondown_delay":"0","redis_cluster_sync":"5s","redis_sentinel":"","redis_tls":false},"out_datadb_password":"","out_datadb_port":"6379","out_datadb_type":"redis","out_datadb_user":"cgrates","out_stordb_host":"127.0.0.1","out_stordb_name":"cgrates","out_stordb_opts":{},"out_stordb_password":"","out_stordb_port":"3306","out_stordb_type":"mysql","out_stordb_user":"cgrates","users_filters":[]},"radius_agent":{"client_dictionaries":{"*default":"/usr/share/cgrates/radius/dict/"},"client_secrets":{"*default":"CGRateS.org"},"enabled":false,"listen_acct":"127.0.0.1:1813","listen_auth":"127.0.0.1:1812","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"]},"rals":{"balance_rating_subject":{"*any":"*zero1ns","*voice":"*zero1s"},"caches_conns":["*internal"],"dynaprepaid_actionplans":[],"enabled":false,"max_computed_usage":{"*any":"189h0m0s","*data":"107374182400","*mms":"10000","*sms":"10000","*voice":"72h0m0s"},"max_increments":1000000,"remove_expired":true,"rp_subject_prefix_matching":false,"stats_conns":[],"thresholds_conns":[]},"registrarc":{"dispatcher":{"enabled":false,"hosts":{},"refresh_interval":"5m0s","registrars_conns":[]},"rpc":{"enabled":false,"hosts":{},"refresh_interval":"5m0s","registrars_conns":[]}},"resources":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[],"thresholds_conns":[]},"routes":{"attributes_conns":[],"default_ratio":1,"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"rals_conns":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"rpc_conns":{"*bijson_localhost":{"conns":[{"address":"127.0.0.1:2014","transport":"*birpc_json"}],"poolSize":0,"strategy":"*first"},"*birpc_internal":{"conns":[{"address":"*birpc_internal","transport":""}],"poolSize":0,"strategy":"*first"},"*internal":{"conns":[{"address":"*internal","transport":""}],"poolSize":0,"strategy":"*first"},"*localhost":{"conns":[{"address":"127.0.0.1:2012","transport":"*json"}],"poolSize":0,"strategy":"*first"}},"schedulers":{"cdrs_conns":[],"enabled":false,"filters":[],"stats_conns":[],"thresholds_conns":[]},"sessions":{"alterable_fields":[],"attributes_conns":[],"cdrs_conns":[],"channel_sync_interval":"0","chargers_conns":[],"client_protocol":1,"debit_interval":"0","default_usage":{"*any":"3h0m0s","*data":"1048576","*sms":"1","*voice":"3h0m0s"},"enabled":false,"listen_bigob":"","listen_bijson":"127.0.0.1:2014","min_dur_low_balance":"0","rals_conns":[],"replication_conns":[],"resources_conns":[],"routes_conns":[],"scheduler_conns":[],"session_indexes":[],"session_ttl":"0","stats_conns":[],"stir":{"allowed_attest":["*any"],"default_attest":"A","payload_maxduration":"-1","privatekey_path":"","publickey_path":""},"store_session_costs":false,"terminate_attempts":5,"thresholds_conns":[]},"sip_agent":{"enabled":false,"listen":"127.0.0.1:5060","listen_net":"udp","request_processors":[],"retransmission_timer":1000000000,"sessions_conns":["*internal"],"timezone":""},"stats":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"store_interval":"","store_uncompressed_limit":0,"suffix_indexed_fields":[],"thresholds_conns":[]},"stor_db":{"db_host":"127.0.0.1","db_name":"cgrates","db_password":"","db_port":3306,"db_type":"*mysql","db_user":"cgrates","items":{"*cdrs":{"remote":false,"replicate":false},"*session_costs":{"remote":false,"replicate":false},"*tp_account_actions":{"remote":false,"replicate":false},"*tp_action_plans":{"remote":false,"replicate":false},"*tp_action_triggers":{"remote":false,"replicate":false},"*tp_actions":{"remote":false,"replicate":false},"*tp_attributes":{"remote":false,"replicate":false},"*tp_chargers":{"remote":false,"replicate":false},"*tp_destination_rates":{"remote":false,"replicate":false},"*tp_destinations":{"remote":false,"replicate":false},"*tp_dispatcher_hosts":{"remote":false,"replicate":false},"*tp_dispatcher_profiles":{"remote":false,"replicate":false},"*tp_filters":{"remote":false,"replicate":false},"*tp_rates":{"remote":false,"replicate":false},"*tp_rating_plans":{"remote":false,"replicate":false},"*tp_rating_profiles":{"remote":false,"replicate":false},"*tp_resources":{"remote":false,"replicate":false},"*tp_routes":{"remote":false,"replicate":false},"*tp_shared_groups":{"remote":false,"replicate":false},"*tp_stats":{"remote":false,"replicate":false},"*tp_thresholds":{"remote":false,"replicate":false},"*tp_timings":{"remote":false,"replicate":false},"*versions":{"remote":false,"replicate":false}},"opts":{"conn_max_lifetime":0,"max_idle_conns":10,"max_open_conns":100,"mysql_location":"Local","query_timeout":"10s","sslmode":"disable"},"prefix_indexed_fields":[],"remote_conns":null,"replication_conns":null,"string_indexed_fields":[]},"suretax":{"bill_to_number":"","business_unit":"","client_number":"","client_tracking":"~*req.CGRID","customer_number":"~*req.Subject","include_local_cost":false,"orig_number":"~*req.Subject","p2pplus4":"","p2pzipcode":"","plus4":"","regulatory_code":"03","response_group":"03","response_type":"D4","return_file_code":"0","sales_type_code":"R","tax_exemption_code_list":"","tax_included":"0","tax_situs_rule":"04","term_number":"~*req.Destination","timezone":"UTC","trans_type_code":"010101","unit_type":"00","units":"1","url":"","validation_key":"","zipcode":""},"templates":{"*asr":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"}],"*cca":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"path":"*rep.Result-Code","tag":"ResultCode","type":"*constant","value":"2001"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"},{"mandatory":true,"path":"*rep.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"mandatory":true,"path":"*rep.CC-Request-Type","tag":"CCRequestType","type":"*variable","value":"~*req.CC-Request-Type"},{"mandatory":true,"path":"*rep.CC-Request-Number","tag":"CCRequestNumber","type":"*variable","value":"~*req.CC-Request-Number"}],"*cdrLog":[{"mandatory":true,"path":"*cdr.ToR","tag":"ToR","type":"*variable","value":"~*req.BalanceType"},{"mandatory":true,"path":"*cdr.OriginHost","tag":"OriginHost","type":"*constant","value":"127.0.0.1"},{"mandatory":true,"path":"*cdr.RequestType","tag":"RequestType","type":"*constant","value":"*none"},{"mandatory":true,"path":"*cdr.Tenant","tag":"Tenant","type":"*variable","value":"~*req.Tenant"},{"mandatory":true,"path":"*cdr.Account","tag":"Account","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Subject","tag":"Subject","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Cost","tag":"Cost","type":"*variable","value":"~*req.Cost"},{"mandatory":true,"path":"*cdr.Source","tag":"Source","type":"*constant","value":"*cdrLog"},{"mandatory":true,"path":"*cdr.Usage","tag":"Usage","type":"*constant","value":"1"},{"mandatory":true,"path":"*cdr.RunID","tag":"RunID","type":"*variable","value":"~*req.ActionType"},{"mandatory":true,"path":"*cdr.SetupTime","tag":"SetupTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.AnswerTime","tag":"AnswerTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.PreRated","tag":"PreRated","type":"*constant","value":"true"}],"*err":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"}],"*errSip":[{"mandatory":true,"path":"*rep.Request","tag":"Request","type":"*constant","value":"SIP/2.0 500 Internal Server Error"}],"*rar":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"path":"*diamreq.Re-Auth-Request-Type","tag":"ReAuthRequestType","type":"*constant","value":"0"}]},"thresholds":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[]},"tls":{"ca_certificate":"","client_certificate":"","client_key":"","server_certificate":"","server_key":"","server_name":"","server_policy":4}}`
cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSON)
if err != nil {
t.Fatal(err)
@@ -5627,14 +5494,14 @@ func TestReloadSections(t *testing.T) {
subsystemsThatNeedDataDB := utils.NewStringSet([]string{SCHEDULER_JSN,
RALS_JSN, CDRS_JSN, SessionSJson, ATTRIBUTE_JSN,
ChargerSCfgJson, RESOURCES_JSON, STATS_JSON, THRESHOLDS_JSON,
- RouteSJson, LoaderJson, DispatcherSJson, RateSJson, ApierS})
+ RouteSJson, LoaderJson, DispatcherSJson, ApierS})
subsystemsThatNeedStorDB := utils.NewStringSet([]string{RALS_JSN, CDRS_JSN, ApierS})
cfgCgr := NewDefaultCGRConfig()
for _, section := range []string{RPCConnsJsonName, HTTP_JSN, SCHEDULER_JSN, RALS_JSN, CDRS_JSN, ERsJson,
SessionSJson, AsteriskAgentJSN, FreeSWITCHAgentJSN, KamailioAgentJSN, DA_JSN, RA_JSN, HttpAgentJson,
DNSAgentJson, ATTRIBUTE_JSN, ChargerSCfgJson, RESOURCES_JSON, STATS_JSON, THRESHOLDS_JSON, RouteSJson,
- LoaderJson, DispatcherSJson, ApierS, EEsJson, SIPAgentJson, RateSJson, RegistrarCJson, AnalyzerCfgJson} {
+ LoaderJson, DispatcherSJson, ApierS, EEsJson, SIPAgentJson, RegistrarCJson, AnalyzerCfgJson} {
for _, section := range sortedCfgSections {
cfgCgr.rldChans[section] = make(chan struct{}, 1)
}
@@ -5865,9 +5732,6 @@ func TestCGRConfigClone(t *testing.T) {
if !reflect.DeepEqual(cfg.eesCfg, rcv.eesCfg) {
t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(cfg.eesCfg), utils.ToJSON(rcv.eesCfg))
}
- if !reflect.DeepEqual(cfg.rateSCfg, rcv.rateSCfg) {
- t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(cfg.rateSCfg), utils.ToJSON(rcv.rateSCfg))
- }
if !reflect.DeepEqual(cfg.sipAgentCfg, rcv.sipAgentCfg) {
t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(cfg.sipAgentCfg), utils.ToJSON(rcv.sipAgentCfg))
}
@@ -5882,22 +5746,6 @@ func TestCGRConfigClone(t *testing.T) {
}
}
-func TestLoadAccountSCfgError(t *testing.T) {
- cfgJSONStr := `{
-"accounts": {
- "enabled": "not_bool",
- }
-}`
- expected := "json: cannot unmarshal string into Go struct field AccountSJsonCfg.Enabled of type bool"
- cfg := NewDefaultCGRConfig()
-
- if cgrCfgJSON, err := NewCgrJsonCfgFromBytes([]byte(cfgJSONStr)); err != nil {
- t.Error(err)
- } else if err := cfg.loadAccountSCfg(cgrCfgJSON); err == nil || err.Error() != expected {
- t.Errorf("Expected %+v, received %+v", expected, err)
- }
-}
-
func TestCGRConfigGetDP(t *testing.T) {
cfg := NewDefaultCGRConfig()
cfg.LockSections(HttpAgentJson, LoaderJson, ChargerSCfgJson)
diff --git a/config/libconfig_json.go b/config/libconfig_json.go
index a8306c653..1d0483b74 100644
--- a/config/libconfig_json.go
+++ b/config/libconfig_json.go
@@ -626,21 +626,6 @@ type STIRJsonCfg struct {
Privatekey_path *string
}
-type RateSJsonCfg struct {
- Enabled *bool
- Indexed_selects *bool
- String_indexed_fields *[]string
- Prefix_indexed_fields *[]string
- Suffix_indexed_fields *[]string
- Nested_fields *bool // applies when indexed fields is not defined
- Rate_indexed_selects *bool
- Rate_string_indexed_fields *[]string
- Rate_prefix_indexed_fields *[]string
- Rate_suffix_indexed_fields *[]string
- Rate_nested_fields *bool // applies when indexed fields is not defined
- Verbosity *int
-}
-
// SIPAgentJsonCfg
type SIPAgentJsonCfg struct {
Enabled *bool
@@ -669,18 +654,3 @@ type CoreSJsonCfg struct {
Caps_stats_interval *string
Shutdown_timeout *string
}
-
-// Account service config section
-type AccountSJsonCfg struct {
- Enabled *bool
- Indexed_selects *bool
- Attributes_conns *[]string
- Rates_conns *[]string
- Thresholds_conns *[]string
- String_indexed_fields *[]string
- Prefix_indexed_fields *[]string
- Suffix_indexed_fields *[]string
- Nested_fields *bool // applies when indexed fields is not defined
- Max_iterations *int
- Max_usage *string
-}
diff --git a/config/ratescfg.go b/config/ratescfg.go
deleted file mode 100644
index de9756d1c..000000000
--- a/config/ratescfg.go
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
-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
-*/
-
-package config
-
-import (
- "github.com/cgrates/cgrates/utils"
-)
-
-// RateSCfg the rates config section
-type RateSCfg struct {
- Enabled bool
- IndexedSelects bool
- StringIndexedFields *[]string
- PrefixIndexedFields *[]string
- SuffixIndexedFields *[]string
- NestedFields bool
- RateIndexedSelects bool
- RateStringIndexedFields *[]string
- RatePrefixIndexedFields *[]string
- RateSuffixIndexedFields *[]string
- RateNestedFields bool
- Verbosity int
-}
-
-func (rCfg *RateSCfg) loadFromJSONCfg(jsnCfg *RateSJsonCfg) (err error) {
- if jsnCfg == nil {
- return
- }
- if jsnCfg.Enabled != nil {
- rCfg.Enabled = *jsnCfg.Enabled
- }
- if jsnCfg.Indexed_selects != nil {
- rCfg.IndexedSelects = *jsnCfg.Indexed_selects
- }
- if jsnCfg.String_indexed_fields != nil {
- sif := make([]string, len(*jsnCfg.String_indexed_fields))
- for i, fID := range *jsnCfg.String_indexed_fields {
- sif[i] = fID
- }
- rCfg.StringIndexedFields = &sif
- }
- if jsnCfg.Prefix_indexed_fields != nil {
- pif := make([]string, len(*jsnCfg.Prefix_indexed_fields))
- for i, fID := range *jsnCfg.Prefix_indexed_fields {
- pif[i] = fID
- }
- rCfg.PrefixIndexedFields = &pif
- }
- if jsnCfg.Suffix_indexed_fields != nil {
- sif := make([]string, len(*jsnCfg.Suffix_indexed_fields))
- for i, fID := range *jsnCfg.Suffix_indexed_fields {
- sif[i] = fID
- }
- rCfg.SuffixIndexedFields = &sif
- }
- if jsnCfg.Nested_fields != nil {
- rCfg.NestedFields = *jsnCfg.Nested_fields
- }
-
- if jsnCfg.Rate_indexed_selects != nil {
- rCfg.RateIndexedSelects = *jsnCfg.Rate_indexed_selects
- }
- if jsnCfg.Rate_string_indexed_fields != nil {
- sif := make([]string, len(*jsnCfg.Rate_string_indexed_fields))
- for i, fID := range *jsnCfg.Rate_string_indexed_fields {
- sif[i] = fID
- }
- rCfg.RateStringIndexedFields = &sif
- }
- if jsnCfg.Rate_prefix_indexed_fields != nil {
- pif := make([]string, len(*jsnCfg.Rate_prefix_indexed_fields))
- for i, fID := range *jsnCfg.Rate_prefix_indexed_fields {
- pif[i] = fID
- }
- rCfg.RatePrefixIndexedFields = &pif
- }
- if jsnCfg.Rate_suffix_indexed_fields != nil {
- sif := make([]string, len(*jsnCfg.Rate_suffix_indexed_fields))
- for i, fID := range *jsnCfg.Rate_suffix_indexed_fields {
- sif[i] = fID
- }
- rCfg.RateSuffixIndexedFields = &sif
- }
- if jsnCfg.Rate_nested_fields != nil {
- rCfg.RateNestedFields = *jsnCfg.Rate_nested_fields
- }
- if jsnCfg.Verbosity != nil {
- rCfg.Verbosity = *jsnCfg.Verbosity
- }
- return
-}
-
-// AsMapInterface returns the config as a map[string]interface{}
-func (rCfg *RateSCfg) AsMapInterface() (initialMP map[string]interface{}) {
- initialMP = map[string]interface{}{
- utils.EnabledCfg: rCfg.Enabled,
- utils.IndexedSelectsCfg: rCfg.IndexedSelects,
- utils.NestedFieldsCfg: rCfg.NestedFields,
- utils.RateIndexedSelectsCfg: rCfg.RateIndexedSelects,
- utils.RateNestedFieldsCfg: rCfg.RateNestedFields,
- utils.Verbosity: rCfg.Verbosity,
- }
- if rCfg.StringIndexedFields != nil {
- stringIndexedFields := make([]string, len(*rCfg.StringIndexedFields))
- for i, item := range *rCfg.StringIndexedFields {
- stringIndexedFields[i] = item
- }
- initialMP[utils.StringIndexedFieldsCfg] = stringIndexedFields
- }
- if rCfg.PrefixIndexedFields != nil {
- prefixIndexedFields := make([]string, len(*rCfg.PrefixIndexedFields))
- for i, item := range *rCfg.PrefixIndexedFields {
- prefixIndexedFields[i] = item
- }
- initialMP[utils.PrefixIndexedFieldsCfg] = prefixIndexedFields
- }
- if rCfg.SuffixIndexedFields != nil {
- sufixIndexedFields := make([]string, len(*rCfg.SuffixIndexedFields))
- for i, item := range *rCfg.SuffixIndexedFields {
- sufixIndexedFields[i] = item
- }
- initialMP[utils.SuffixIndexedFieldsCfg] = sufixIndexedFields
- }
- if rCfg.RateStringIndexedFields != nil {
- rateStringIndexedFields := make([]string, len(*rCfg.RateStringIndexedFields))
- for i, item := range *rCfg.RateStringIndexedFields {
- rateStringIndexedFields[i] = item
- }
- initialMP[utils.RateStringIndexedFieldsCfg] = rateStringIndexedFields
- }
- if rCfg.RatePrefixIndexedFields != nil {
- ratePrefixIndexedFields := make([]string, len(*rCfg.RatePrefixIndexedFields))
- for i, item := range *rCfg.RatePrefixIndexedFields {
- ratePrefixIndexedFields[i] = item
- }
- initialMP[utils.RatePrefixIndexedFieldsCfg] = ratePrefixIndexedFields
- }
- if rCfg.RateSuffixIndexedFields != nil {
- rateSufixIndexedFields := make([]string, len(*rCfg.RateSuffixIndexedFields))
- for i, item := range *rCfg.RateSuffixIndexedFields {
- rateSufixIndexedFields[i] = item
- }
- initialMP[utils.RateSuffixIndexedFieldsCfg] = rateSufixIndexedFields
- }
- return
-}
-
-// Clone returns a deep copy of RateSCfg
-func (rCfg RateSCfg) Clone() (cln *RateSCfg) {
- cln = &RateSCfg{
- Enabled: rCfg.Enabled,
- IndexedSelects: rCfg.IndexedSelects,
- NestedFields: rCfg.NestedFields,
- RateIndexedSelects: rCfg.RateIndexedSelects,
- RateNestedFields: rCfg.RateNestedFields,
- Verbosity: rCfg.Verbosity,
- }
- if rCfg.StringIndexedFields != nil {
- idx := make([]string, len(*rCfg.StringIndexedFields))
- for i, dx := range *rCfg.StringIndexedFields {
- idx[i] = dx
- }
- cln.StringIndexedFields = &idx
- }
- if rCfg.PrefixIndexedFields != nil {
- idx := make([]string, len(*rCfg.PrefixIndexedFields))
- for i, dx := range *rCfg.PrefixIndexedFields {
- idx[i] = dx
- }
- cln.PrefixIndexedFields = &idx
- }
- if rCfg.SuffixIndexedFields != nil {
- idx := make([]string, len(*rCfg.SuffixIndexedFields))
- for i, dx := range *rCfg.SuffixIndexedFields {
- idx[i] = dx
- }
- cln.SuffixIndexedFields = &idx
- }
-
- if rCfg.RateStringIndexedFields != nil {
- idx := make([]string, len(*rCfg.RateStringIndexedFields))
- for i, dx := range *rCfg.RateStringIndexedFields {
- idx[i] = dx
- }
- cln.RateStringIndexedFields = &idx
- }
- if rCfg.RatePrefixIndexedFields != nil {
- idx := make([]string, len(*rCfg.RatePrefixIndexedFields))
- for i, dx := range *rCfg.RatePrefixIndexedFields {
- idx[i] = dx
- }
- cln.RatePrefixIndexedFields = &idx
- }
- if rCfg.RateSuffixIndexedFields != nil {
- idx := make([]string, len(*rCfg.RateSuffixIndexedFields))
- for i, dx := range *rCfg.RateSuffixIndexedFields {
- idx[i] = dx
- }
- cln.RateSuffixIndexedFields = &idx
- }
- return
-}
diff --git a/config/ratescfg_test.go b/config/ratescfg_test.go
deleted file mode 100644
index 05cb45e96..000000000
--- a/config/ratescfg_test.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
-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
-*/
-
-package config
-
-import (
- "reflect"
- "testing"
-
- "github.com/cgrates/cgrates/utils"
-)
-
-func TestRateSConfigloadFromJsonCfg(t *testing.T) {
- cfgJSON := &RateSJsonCfg{
- Enabled: utils.BoolPointer(true),
- Indexed_selects: utils.BoolPointer(true),
- String_indexed_fields: &[]string{"*req.index1"},
- Prefix_indexed_fields: &[]string{"*req.index1"},
- Suffix_indexed_fields: &[]string{"*req.index1"},
- Nested_fields: utils.BoolPointer(true),
- Rate_indexed_selects: utils.BoolPointer(true),
- Rate_string_indexed_fields: &[]string{"*req.index1"},
- Rate_prefix_indexed_fields: &[]string{"*req.index1"},
- Rate_suffix_indexed_fields: &[]string{"*req.index1"},
- Rate_nested_fields: utils.BoolPointer(true),
- Verbosity: utils.IntPointer(20),
- }
- expected := &RateSCfg{
- Enabled: true,
- IndexedSelects: true,
- StringIndexedFields: &[]string{"*req.index1"},
- PrefixIndexedFields: &[]string{"*req.index1"},
- SuffixIndexedFields: &[]string{"*req.index1"},
- NestedFields: true,
- RateIndexedSelects: true,
- RateStringIndexedFields: &[]string{"*req.index1"},
- RatePrefixIndexedFields: &[]string{"*req.index1"},
- RateSuffixIndexedFields: &[]string{"*req.index1"},
- RateNestedFields: true,
- Verbosity: 20,
- }
- jsonCfg := NewDefaultCGRConfig()
- if err = jsonCfg.rateSCfg.loadFromJSONCfg(cfgJSON); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, jsonCfg.rateSCfg) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(expected), utils.ToJSON(jsonCfg.rateSCfg))
- }
-}
-
-func TestRatesCfgAsMapInterface(t *testing.T) {
- cfgJSONStr := `{
- "rates": {}
-}`
- eMap := map[string]interface{}{
- utils.EnabledCfg: false,
- utils.IndexedSelectsCfg: true,
- utils.PrefixIndexedFieldsCfg: []string{},
- utils.SuffixIndexedFieldsCfg: []string{},
- utils.NestedFieldsCfg: false,
- utils.RateIndexedSelectsCfg: true,
- utils.RatePrefixIndexedFieldsCfg: []string{},
- utils.RateSuffixIndexedFieldsCfg: []string{},
- utils.RateNestedFieldsCfg: false,
- utils.Verbosity: 1000,
- }
- if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
- t.Error(err)
- } else if rcv := cgrCfg.rateSCfg.AsMapInterface(); !reflect.DeepEqual(rcv, eMap) {
- t.Errorf("Expected %+v \n, received %+v", eMap, rcv)
- }
-}
-
-func TestRatesCfgAsMapInterface1(t *testing.T) {
- cfgJSONStr := `{
- "rates": {
- "enabled": true,
- "indexed_selects": false,
- "string_indexed_fields": ["*req.index1"],
- "prefix_indexed_fields": ["*req.index1", "*req.index2"],
- "suffix_indexed_fields": ["*req.index1"],
- "nested_fields": true,
- "rate_indexed_selects": false,
- "rate_string_indexed_fields": ["*req.index1"],
- "rate_prefix_indexed_fields": ["*req.index1", "*req.index2"],
- "rate_suffix_indexed_fields": ["*req.index1", "*req.index2", "*req.index3"],
- "rate_nested_fields": true,
- },
-}`
- eMap := map[string]interface{}{
- utils.EnabledCfg: true,
- utils.IndexedSelectsCfg: false,
- utils.StringIndexedFieldsCfg: []string{"*req.index1"},
- utils.PrefixIndexedFieldsCfg: []string{"*req.index1", "*req.index2"},
- utils.SuffixIndexedFieldsCfg: []string{"*req.index1"},
- utils.NestedFieldsCfg: true,
- utils.RateIndexedSelectsCfg: false,
- utils.RateStringIndexedFieldsCfg: []string{"*req.index1"},
- utils.RatePrefixIndexedFieldsCfg: []string{"*req.index1", "*req.index2"},
- utils.RateSuffixIndexedFieldsCfg: []string{"*req.index1", "*req.index2", "*req.index3"},
- utils.RateNestedFieldsCfg: true,
- utils.Verbosity: 1000,
- }
- if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
- t.Error(err)
- } else if rcv := cgrCfg.rateSCfg.AsMapInterface(); !reflect.DeepEqual(rcv, eMap) {
- t.Errorf("Expected %+v \n, received %+v", eMap, rcv)
- }
-}
-
-func TestRateSCfgClone(t *testing.T) {
- sa := &RateSCfg{
- Enabled: true,
- IndexedSelects: true,
- StringIndexedFields: &[]string{"*req.index1"},
- PrefixIndexedFields: &[]string{"*req.index1"},
- SuffixIndexedFields: &[]string{"*req.index1"},
- NestedFields: true,
- RateIndexedSelects: true,
- RateStringIndexedFields: &[]string{"*req.index1"},
- RatePrefixIndexedFields: &[]string{"*req.index1"},
- RateSuffixIndexedFields: &[]string{"*req.index1"},
- RateNestedFields: true,
- Verbosity: 20,
- }
- rcv := sa.Clone()
- if !reflect.DeepEqual(sa, rcv) {
- t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(sa), utils.ToJSON(rcv))
- }
- (*rcv.StringIndexedFields)[0] = ""
- if (*sa.StringIndexedFields)[0] != "*req.index1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
- (*rcv.PrefixIndexedFields)[0] = ""
- if (*sa.PrefixIndexedFields)[0] != "*req.index1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
- (*rcv.SuffixIndexedFields)[0] = ""
- if (*sa.SuffixIndexedFields)[0] != "*req.index1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
-
- (*rcv.RateStringIndexedFields)[0] = ""
- if (*sa.RateStringIndexedFields)[0] != "*req.index1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
- (*rcv.RatePrefixIndexedFields)[0] = ""
- if (*sa.RatePrefixIndexedFields)[0] != "*req.index1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
- (*rcv.RateSuffixIndexedFields)[0] = ""
- if (*sa.RateSuffixIndexedFields)[0] != "*req.index1" {
- t.Errorf("Expected clone to not modify the cloned")
- }
-}
diff --git a/console/ping.go b/console/ping.go
index 79138a483..7e1142e68 100644
--- a/console/ping.go
+++ b/console/ping.go
@@ -81,10 +81,6 @@ func (self *CmdApierPing) RpcMethod() string {
return utils.APIerSv1Ping
case utils.EEsLow:
return utils.EeSv1Ping
- case utils.RateSLow:
- return utils.RateSv1Ping
- case utils.AccountSLow:
- return utils.AccountSv1Ping
default:
}
return self.rpcMethod
diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json
index ced2c185a..11fb4d785 100755
--- a/data/conf/cgrates/cgrates.json
+++ b/data/conf/cgrates/cgrates.json
@@ -44,9 +44,9 @@
// "rpc_conns": {
-// "*localhost": {
-// "conns": [{"address": "127.0.0.1:2012", "transport":"*json"}],
-// },
+// //"*localhost": {
+// //"conns": [{"address": "127.0.0.1:2012", "transport":"*json"}],
+// //},
// }, // rpc connections definitions
@@ -86,8 +86,6 @@
// "*charger_profiles": {"remote":false, "replicate":false},
// "*dispatcher_profiles":{"remote":false, "replicate":false},
// "*dispatcher_hosts":{"remote":false, "replicate":false},
-// "*rate_profiles":{"remote":false, "replicate":false},
-// "*action_profiles":{"remote":false, "replicate":false},
// "*load_ids":{"remote":false, "replicate":false},
// "*indexes":{"remote":false, "replicate":false},
// },
@@ -146,8 +144,6 @@
// "*versions": {"remote":false, "replicate":false},
// "*tp_dispatcher_profiles":{"remote":false, "replicate":false},
// "*tp_dispatcher_hosts":{"remote":false, "replicate":false},
-// "*tp_rate_profiles":{"remote":false, "replicate":false},
-// "*tp_action_profiles":{"remote":false, "replicate":false},
// },
// },
@@ -236,8 +232,6 @@
// "*charger_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control charger profile caching
// "*dispatcher_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control dispatcher profile caching
// "*dispatcher_hosts": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control dispatcher hosts caching
-// "*rate_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control rate profile caching
-// "*action_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control action profile caching
// "*resource_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control resource filter indexes caching
// "*stat_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control stat filter indexes caching
// "*threshold_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control threshold filter indexes caching
@@ -245,9 +239,6 @@
// "*attribute_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control attribute filter indexes caching
// "*charger_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control charger filter indexes caching
// "*dispatcher_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control dispatcher filter indexes caching
-// "*rate_profile_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control rate profile filter indexes caching
-// "*rate_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control rate filter indexes caching
-// "*action_profile_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control action profile filter indexes caching
// "*reverse_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control reverse filter indexes caching used only for set and remove filters
// "*dispatcher_routes": {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control dispatcher routes caching
// "*dispatcher_loads": {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control dispatcher load( in case of *ratio ConnParams is present)
@@ -291,8 +282,6 @@
// "*tp_chargers":{"limit": -1, "ttl": "", "static_ttl": false, "replicate": false},
// "*tp_dispatcher_profiles":{"limit": -1, "ttl": "", "static_ttl": false, "replicate": false},
// "*tp_dispatcher_hosts":{"limit": -1, "ttl": "", "static_ttl": false, "replicate": false},
-// "*tp_rate_profiles":{"limit": -1, "ttl": "", "static_ttl": false, "replicate": false},
-// "*tp_action_profiles":{"limit": -1, "ttl": "", "static_ttl": false, "replicate": false},
// },
// "replication_conns": [],
// },
@@ -778,52 +767,6 @@
// {"tag": "TLS", "path": "TLS", "type": "*variable", "value": "~*req.4"},
// ],
// },
-// {
-// "type": "*rate_profiles", // data source type
-// "file_name": "RateProfiles.csv", // file name in the tp_in_dir
-// "fields": [
-// {"tag": "Tenant", "path": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
-// {"tag": "ID", "path": "ID", "type": "*variable", "value": "~*req.1", "mandatory": true},
-// {"tag": "FilterIDs", "path": "FilterIDs", "type": "*variable", "value": "~*req.2"},
-// {"tag": "ActivationInterval", "path": "ActivationInterval", "type": "*variable", "value": "~*req.3"},
-// {"tag": "Weight", "path": "Weight", "type": "*variable", "value": "~*req.4"},
-// {"tag": "MinCost", "path": "MinCost", "type": "*variable", "value": "~*req.5"},
-// {"tag": "MaxCost", "path": "MaxCost", "type": "*variable", "value": "~*req.6"},
-// {"tag": "MaxCostStrategy", "path": "MaxCostStrategy", "type": "*variable", "value": "~*req.7"},
-// {"tag": "RateID", "path": "RateID", "type": "*variable", "value": "~*req.8"},
-// {"tag": "RateFilterIDs", "path": "RateFilterIDs", "type": "*variable", "value": "~*req.9"},
-// {"tag": "RateActivationTimes", "path": "RateActivationTimes", "type": "*variable", "value": "~*req.10"},
-// {"tag": "RateWeight", "path": "RateWeight", "type": "*variable", "value": "~*req.11"},
-// {"tag": "RateBlocker", "path": "RateBlocker", "type": "*variable", "value": "~*req.12"},
-// {"tag": "RateIntervalStart", "path": "RateIntervalStart", "type": "*variable", "value": "~*req.13"},
-// {"tag": "RateFixedFee", "path": "RateFixedFee", "type": "*variable", "value": "~*req.14"},
-// {"tag": "RateRecurrentFee", "path": "RateRecurrentFee", "type": "*variable", "value": "~*req.15"},
-// {"tag": "RateUnit", "path": "RateUnit", "type": "*variable", "value": "~*req.16"},
-// {"tag": "RateIncrement", "path": "RateIncrement", "type": "*variable", "value": "~*req.17"},
-// ],
-// },
-// {
-// "type": "*action_profiles", // data source type
-// "file_name": "ActionProfiles.csv", // file name in the tp_in_dir
-// "fields": [
-// {"tag": "Tenant", "path": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
-// {"tag": "ID", "path": "ID", "type": "*variable", "value": "~*req.1", "mandatory": true},
-// {"tag": "FilterIDs", "path": "FilterIDs", "type": "*variable", "value": "~*req.2"},
-// {"tag": "ActivationInterval", "path": "ActivationInterval", "type": "*variable", "value": "~*req.3"},
-// {"tag": "Weight", "path": "Weight", "type": "*variable", "value": "~*req.4"},
-// {"tag": "Schedule", "path": "Schedule", "type": "*variable", "value": "~*req.5"},
-// {"tag": "TargetType", "path": "TargetType", "type": "*variable", "value": "~*req.6"},
-// {"tag": "TargetIDs", "path": "TargetIDs", "type": "*variable", "value": "~*req.7"},
-// {"tag": "ActionID", "path": "ActionID", "type": "*variable", "value": "~*req.8"},
-// {"tag": "ActionFilterIDs", "path": "ActionFilterIDs", "type": "*variable", "value": "~*req.9"},
-// {"tag": "ActionBlocker", "path": "ActionBlocker", "type": "*variable", "value": "~*req.10"},
-// {"tag": "ActionTTL", "path": "ActionTTL", "type": "*variable", "value": "~*req.11"},
-// {"tag": "ActionType", "path": "ActionType", "type": "*variable", "value": "~*req.12"},
-// {"tag": "ActionOpts", "path": "ActionOpts", "type": "*variable", "value": "~*req.13"},
-// {"tag": "ActionPath", "path": "ActionPath", "type": "*variable", "value": "~*req.14"},
-// {"tag": "ActionValue", "path": "ActionValue", "type": "*variable", "value": "~*req.15"},
-// ],
-// },
// ],
// },
// ],
@@ -953,22 +896,6 @@
// },
-// "rates": {
-// "enabled": false,
-// "indexed_selects": true, // enable profile matching exclusively on indexes
-// //"string_indexed_fields": [], // query indexes based on these fields for faster processing
-// "prefix_indexed_fields": [], // query indexes based on these fields for faster processing
-// "suffix_indexed_fields": [], // query indexes based on these fields for faster processing
-// "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level)
-// "rate_indexed_selects": true, // enable profile matching exclusively on indexes
-// //"rate_string_indexed_fields": [], // query indexes based on these fields for faster processing
-// "rate_prefix_indexed_fields": [], // query indexes based on these fields for faster processing
-// "rate_suffix_indexed_fields": [], // query indexes based on these fields for faster processing
-// "rate_nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level)
-// "verbosity": 1000, // number of increment iterations allowed
-// },
-
-
// "sip_agent": { // SIP Agents, only used for redirections
// "enabled": false, // enables the SIP agent:
// "listen": "127.0.0.1:5060", // address where to listen for SIP requests
@@ -1084,35 +1011,4 @@
// },
-// "actions": { // ActionS config
-// "enabled": false, // starts attribute service:
-// "cdrs_conns": [], // connections to CDRs for CDR posting <""|*internal|$rpc_conns_id>
-// "ees_conns": [], // connections to Ees for exporting event <""|*internal|$rpc_conns_id>
-// "thresholds_conns": [], // connections to ThresholdS for *reset_threshold action <""|*internal|$rpc_conns_id>
-// "stats_conns": [], // connections to StatS for *reset_stat_queue action: <""|*internal|$rpc_conns_id>
-// "accounts_conns": [], // connections to AccountS for *topup/*topup_reset action: <""|*internal|$rpc_conns_id>
-// "tenants":[], // List of tenants to operate on
-// "indexed_selects": true, // enable profile matching exclusively on indexes
-// //"string_indexed_fields": [], // query indexes based on these fields for faster processing
-// "prefix_indexed_fields": [], // query indexes based on these fields for faster processing
-// "suffix_indexed_fields": [], // query indexes based on these fields for faster processing
-// "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level)
-// },
-
-
-// "accounts": { // AccountS config
-// "enabled": false, // starts service:
-// "indexed_selects": true, // enable profile matching exclusively on indexes
-// "attributes_conns": [], // connections to AttributeS for account/balance updates, empty to disable attributes functionality: <""|*internal|$rpc_conns_id>
-// "rates_conns": [], // connections to RatesS for account/balance updates, empty to disable rates functionality: <""|*internal|$rpc_conns_id>
-// "thresholds_conns": [], // connections to ThresholdS for account/balance updates, empty to disable thresholds functionality: <""|*internal|$rpc_conns_id>
-// //"string_indexed_fields": [], // query indexes based on these fields for faster processing
-// "prefix_indexed_fields": [], // query indexes based on these fields for faster processing
-// "suffix_indexed_fields": [], // query indexes based on these fields for faster processing
-// "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level)
-// "max_iterations": 1000, // maximum number of iterations
-// "max_usage": "72h", // maximum time of usage
-// },
-
-
}
diff --git a/data/conf/samples/accounts_internal/cgrates.json b/data/conf/samples/accounts_internal/cgrates.json
deleted file mode 100644
index 3afb376a7..000000000
--- a/data/conf/samples/accounts_internal/cgrates.json
+++ /dev/null
@@ -1,47 +0,0 @@
-{
-
-// CGRateS sample configuration file
-// Copyright (C) ITsysCOM GmbH
-//
-
-
-
-"data_db": {
- "db_type": "*internal",
-},
-
-
-"stor_db": {
- "db_type": "*internal",
-},
-
-
-"attributes": {
- "enabled": true,
-
-},
-
-
-"rates": {
- "enabled": true,
-},
-
-
-"rals": {
- "enabled": true,
-},
-
-
-"accounts": {
- "enabled": true,
- "attributes_conns": ["*localhost"],
- "rates_conns": ["*localhost"],
-},
-
-
-"apiers": {
- "enabled": true,
-},
-
-}
-
diff --git a/data/conf/samples/accounts_mysql/cgrates.json b/data/conf/samples/accounts_mysql/cgrates.json
deleted file mode 100644
index 61ead87fb..000000000
--- a/data/conf/samples/accounts_mysql/cgrates.json
+++ /dev/null
@@ -1,54 +0,0 @@
-{
-
-// CGRateS sample configuration file
-// Copyright (C) ITsysCOM GmbH
-//
-
-
-
-"data_db": {
- "db_type": "redis",
- "db_port": 6379,
- "db_name": "10",
-},
-
-
-"stor_db": {
- "db_password": "CGRateS.org",
-},
-
-
-"attributes": {
- "enabled": true,
-
-},
-
-
-"rates": {
- "enabled": true,
-},
-
-
-"schedulers": {
- "enabled": true,
-},
-
-
-"rals": {
- "enabled": true,
-},
-
-
-"accounts": {
- "enabled": true,
- "attributes_conns": ["*localhost"],
- "rates_conns": ["*internal"],
-},
-
-
-"apiers": {
- "enabled": true,
-},
-
-}
-
diff --git a/data/conf/samples/analyzers/cgrates.json b/data/conf/samples/analyzers/cgrates.json
index ec84db230..322a20cb0 100644
--- a/data/conf/samples/analyzers/cgrates.json
+++ b/data/conf/samples/analyzers/cgrates.json
@@ -114,10 +114,6 @@
},
-"rates": {
- "enabled": true
-},
-
"filters": {
"apiers_conns": ["*internal"],
diff --git a/data/conf/samples/caps_queue_bench/cgrates.json b/data/conf/samples/caps_queue_bench/cgrates.json
index a30533b6d..6bee0bcd4 100644
--- a/data/conf/samples/caps_queue_bench/cgrates.json
+++ b/data/conf/samples/caps_queue_bench/cgrates.json
@@ -117,10 +117,6 @@
},
-"rates": {
- "enabled": true
-},
-
"filters": {
"apiers_conns": ["*internal"],
},
diff --git a/data/conf/samples/dispatchers/all/cgrates.json b/data/conf/samples/dispatchers/all/cgrates.json
index 02cfa4a13..0fa582bc4 100644
--- a/data/conf/samples/dispatchers/all/cgrates.json
+++ b/data/conf/samples/dispatchers/all/cgrates.json
@@ -72,18 +72,6 @@
},
-"rates": {
- "enabled": true,
-},
-
-
-
-
-"accounts": {
- "enabled": true,
-},
-
-
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/dispatchers/all2/cgrates.json b/data/conf/samples/dispatchers/all2/cgrates.json
index fe8245501..6a2e871e2 100644
--- a/data/conf/samples/dispatchers/all2/cgrates.json
+++ b/data/conf/samples/dispatchers/all2/cgrates.json
@@ -66,19 +66,6 @@
"enabled": true,
},
-
-"rates": {
- "enabled": true,
-},
-
-
-
-
-"accounts": {
- "enabled": true,
-},
-
-
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/dispatchers/all2_mongo/cgrates.json b/data/conf/samples/dispatchers/all2_mongo/cgrates.json
index 92e4582fe..34ca0e53b 100644
--- a/data/conf/samples/dispatchers/all2_mongo/cgrates.json
+++ b/data/conf/samples/dispatchers/all2_mongo/cgrates.json
@@ -70,19 +70,6 @@
"enabled": true,
},
-
-"rates": {
- "enabled": true,
-},
-
-
-
-
-"accounts": {
- "enabled": true,
-},
-
-
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/dispatchers/all2_mysql/cgrates.json b/data/conf/samples/dispatchers/all2_mysql/cgrates.json
index de4a6a9bb..a123d6296 100644
--- a/data/conf/samples/dispatchers/all2_mysql/cgrates.json
+++ b/data/conf/samples/dispatchers/all2_mysql/cgrates.json
@@ -68,18 +68,6 @@
},
-"rates": {
- "enabled": true,
-},
-
-
-
-
-"accounts": {
- "enabled": true,
-},
-
-
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/dispatchers/all_mongo/cgrates.json b/data/conf/samples/dispatchers/all_mongo/cgrates.json
index 23672246e..9cd1b498a 100644
--- a/data/conf/samples/dispatchers/all_mongo/cgrates.json
+++ b/data/conf/samples/dispatchers/all_mongo/cgrates.json
@@ -74,19 +74,6 @@
"enabled": true,
},
-
-"rates": {
- "enabled": true,
-},
-
-
-
-
-"accounts": {
- "enabled": true,
-},
-
-
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/dispatchers/all_mysql/cgrates.json b/data/conf/samples/dispatchers/all_mysql/cgrates.json
index 9b5ee99aa..5a81c9f37 100644
--- a/data/conf/samples/dispatchers/all_mysql/cgrates.json
+++ b/data/conf/samples/dispatchers/all_mysql/cgrates.json
@@ -72,19 +72,6 @@
"enabled": true,
},
-
-"rates": {
- "enabled": true,
-},
-
-
-
-
-"accounts": {
- "enabled": true,
-},
-
-
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/hundred_rates/cgrates.json b/data/conf/samples/hundred_rates/cgrates.json
index 72a7e7b1a..e24849a95 100644
--- a/data/conf/samples/hundred_rates/cgrates.json
+++ b/data/conf/samples/hundred_rates/cgrates.json
@@ -14,16 +14,7 @@
"db_password": "CGRateS.org",
},
- // "caches":{
- // "partitions": {
- // "*destinations": {"limit": 10000, "ttl":"0s", "precache": true},
- // "*reverse_destinations": {"limit": 10000, "ttl":"0s", "precache": true},
- // "*rating_plans": {"limit": 10000, "ttl":"0s","precache": true},
- // "*rating_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
- // "*rate_profiles": {"limit": 10000, "ttl": "", "static_ttl": false, "precache": true, "replicate": false}, // control rate profile caching
- // },
- // },
"rals": {
"enabled": true,
@@ -38,10 +29,5 @@
"enabled": true,
},
- "rates": {
- "enabled": true,
- "rate_string_indexed_fields": ["*req.PrefixDestination"]
- },
-
-},
+}
diff --git a/data/conf/samples/rates/cgrates.json b/data/conf/samples/rates/cgrates.json
deleted file mode 100644
index c06fc0a9b..000000000
--- a/data/conf/samples/rates/cgrates.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
-// Sample CGRateS Configuration file for RateS
-//
-// Copyright (C) ITsysCOM GmbH
-
-"general": {
- "log_level": 7,
-},
-
-
-"rates": {
- "enabled": true,
-},
-
-
-}
diff --git a/data/conf/samples/registrarc/all2_mongo/cgrates.json b/data/conf/samples/registrarc/all2_mongo/cgrates.json
index afda81f15..46c15af50 100644
--- a/data/conf/samples/registrarc/all2_mongo/cgrates.json
+++ b/data/conf/samples/registrarc/all2_mongo/cgrates.json
@@ -74,12 +74,6 @@
"enabled": true,
},
-
-"rates": {
- "enabled": true,
-},
-
-
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/registrarc/all2_mysql/cgrates.json b/data/conf/samples/registrarc/all2_mysql/cgrates.json
index 128c8b029..1ce880fd9 100644
--- a/data/conf/samples/registrarc/all2_mysql/cgrates.json
+++ b/data/conf/samples/registrarc/all2_mysql/cgrates.json
@@ -73,11 +73,6 @@
},
- "rates": {
- "enabled": true,
- },
-
-
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/registrarc/all_mongo/cgrates.json b/data/conf/samples/registrarc/all_mongo/cgrates.json
index e0add73c0..874e0153f 100644
--- a/data/conf/samples/registrarc/all_mongo/cgrates.json
+++ b/data/conf/samples/registrarc/all_mongo/cgrates.json
@@ -79,11 +79,6 @@
},
-"rates": {
- "enabled": true,
-},
-
-
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/registrarc/all_mysql/cgrates.json b/data/conf/samples/registrarc/all_mysql/cgrates.json
index d2b5e0749..76fa0330b 100644
--- a/data/conf/samples/registrarc/all_mysql/cgrates.json
+++ b/data/conf/samples/registrarc/all_mysql/cgrates.json
@@ -77,11 +77,6 @@
},
-"rates": {
- "enabled": true,
-},
-
-
"cdrs": {
"enabled": true,
"chargers_conns":["*internal"],
diff --git a/data/conf/samples/registrarc/registrarc_rpc_mongo/cgrates.json b/data/conf/samples/registrarc/registrarc_rpc_mongo/cgrates.json
index d7f78dab1..dcc4e43dd 100644
--- a/data/conf/samples/registrarc/registrarc_rpc_mongo/cgrates.json
+++ b/data/conf/samples/registrarc/registrarc_rpc_mongo/cgrates.json
@@ -122,18 +122,6 @@
},
-"rates": {
- "enabled": true
-},
-
-
-
-
-"accounts": {
- "enabled": true,
-},
-
-
"filters": {
"apiers_conns": ["*internal"],
},
diff --git a/data/conf/samples/registrarc/registrarc_rpc_mysql/cgrates.json b/data/conf/samples/registrarc/registrarc_rpc_mysql/cgrates.json
index 423180adb..f84a27b16 100644
--- a/data/conf/samples/registrarc/registrarc_rpc_mysql/cgrates.json
+++ b/data/conf/samples/registrarc/registrarc_rpc_mysql/cgrates.json
@@ -118,19 +118,6 @@
"scheduler_conns": ["*internal"],
},
-
-"rates": {
- "enabled": true
-},
-
-
-
-
-"accounts": {
- "enabled": true,
-},
-
-
"filters": {
"apiers_conns": ["*internal"],
},
diff --git a/data/conf/samples/replication_cache/engine1/cgrates.json b/data/conf/samples/replication_cache/engine1/cgrates.json
index 962a62a13..466f666e1 100644
--- a/data/conf/samples/replication_cache/engine1/cgrates.json
+++ b/data/conf/samples/replication_cache/engine1/cgrates.json
@@ -52,11 +52,6 @@
},
-"rates": {
- "enabled": true
-},
-
-
"schedulers": {
"enabled": true
},
@@ -69,4 +64,4 @@
-},
+}
diff --git a/data/conf/samples/replication_cache/engine2/cgrates.json b/data/conf/samples/replication_cache/engine2/cgrates.json
index ddb912305..9121181d5 100644
--- a/data/conf/samples/replication_cache/engine2/cgrates.json
+++ b/data/conf/samples/replication_cache/engine2/cgrates.json
@@ -33,11 +33,6 @@
},
-"rates": {
- "enabled": true,
-},
-
-
"schedulers": {
"enabled": true,
},
diff --git a/data/conf/samples/tutinternal/cgrates.json b/data/conf/samples/tutinternal/cgrates.json
index e96318af1..d9bd56be8 100644
--- a/data/conf/samples/tutinternal/cgrates.json
+++ b/data/conf/samples/tutinternal/cgrates.json
@@ -105,18 +105,6 @@
},
-"rates": {
- "enabled": true
-},
-
-
-
-
-"accounts": {
- "enabled": true
-},
-
-
"filters": {
"apiers_conns": ["*internal"]
}
diff --git a/data/conf/samples/tutmongo/cgrates.json b/data/conf/samples/tutmongo/cgrates.json
index 25c17889f..83c57507f 100644
--- a/data/conf/samples/tutmongo/cgrates.json
+++ b/data/conf/samples/tutmongo/cgrates.json
@@ -120,16 +120,6 @@
},
-"rates": {
- "enabled": true
-},
-
-
-"accounts": {
- "enabled": true
-},
-
-
"filters": {
"apiers_conns": ["*internal"],
},
diff --git a/data/conf/samples/tutmongojson/cgrates.json b/data/conf/samples/tutmongojson/cgrates.json
index e47709162..7e1e4678a 100644
--- a/data/conf/samples/tutmongojson/cgrates.json
+++ b/data/conf/samples/tutmongojson/cgrates.json
@@ -116,17 +116,6 @@
},
- "rates": {
- "enabled": true
- },
-
-
-
- "accounts": {
- "enabled": true
- },
-
-
"filters": {
"apiers_conns": ["*internal"],
},
diff --git a/data/conf/samples/tutmysql/cgrates.json b/data/conf/samples/tutmysql/cgrates.json
index 48f4f51de..8db2e1ac1 100644
--- a/data/conf/samples/tutmysql/cgrates.json
+++ b/data/conf/samples/tutmysql/cgrates.json
@@ -112,16 +112,6 @@
},
-"rates": {
- "enabled": true
-},
-
-
-"accounts": {
- "enabled": true
-},
-
-
"filters": {
"apiers_conns": ["*internal"],
},
diff --git a/data/conf/samples/tutmysqljson/cgrates.json b/data/conf/samples/tutmysqljson/cgrates.json
index 6aa731592..339a65344 100644
--- a/data/conf/samples/tutmysqljson/cgrates.json
+++ b/data/conf/samples/tutmysqljson/cgrates.json
@@ -112,21 +112,6 @@
},
- "rates": {
- "enabled": true
- },
-
-
- "actions": {
- "enabled": true
- },
-
-
- "accounts": {
- "enabled": true
- },
-
-
"filters": {
"apiers_conns": ["*internal"],
},
diff --git a/data/tariffplans/dispatchers_gob/Attributes.csv b/data/tariffplans/dispatchers_gob/Attributes.csv
index fd82d6dac..b465425f1 100644
--- a/data/tariffplans/dispatchers_gob/Attributes.csv
+++ b/data/tariffplans/dispatchers_gob/Attributes.csv
@@ -20,7 +20,7 @@ cgrates.org,ATTR_API_PSE_AUTH,*auth,*string:~*req.ApiKey:pse12345,,,*req.APIMeth
cgrates.org,ATTR_API_CFG_AUTH,*auth,*string:~*req.ApiKey:cfg12345,,,*req.APIMethods,*constant,ConfigSv1.GetConfig&ConfigSv1.ReloadConfig,false,20
cgrates.org,ATTR_API_APIER_AUTH,*auth,*string:~*req.ApiKey:apier12345,,,*req.APIMethods,*constant,APIerSv1.GetAttributeProfile&APIerSv1.SetAttributeProfile,false,20
cgrates.org,ATTR_API_RALS_AUTH,*auth,*string:~*req.ApiKey:rals12345,,,*req.APIMethods,*constant,RALsV1.Ping&RALsV1.GetRatingPlansCost,false,20
-cgrates.org,ATTR_API_REPLICATOR_AUTH,*auth,*string:~*req.ApiKey:repl12345,,,*req.APIMethods,*constant,ReplicatorSv1.Ping&ReplicatorSv1.GetAccount&ReplicatorSv1.SetAccount&ReplicatorSv1.RemoveAccount&ReplicatorSv1.GetRouteProfile&ReplicatorSv1.SetRouteProfile&ReplicatorSv1.RemoveRouteProfile&ReplicatorSv1.GetAttributeProfile&ReplicatorSv1.SetAttributeProfile&ReplicatorSv1.RemoveAttributeProfile&ReplicatorSv1.SetChargerProfile&ReplicatorSv1.GetChargerProfile&ReplicatorSv1.RemoveChargerProfile&ReplicatorSv1.GetDispatcherProfile&ReplicatorSv1.SetDispatcherProfile&ReplicatorSv1.RemoveDispatcherProfile&ReplicatorSv1.GetDispatcherHost&ReplicatorSv1.SetDispatcherHost&ReplicatorSv1.RemoveDispatcherHost&ReplicatorSv1.GetFilter&ReplicatorSv1.SetFilter&ReplicatorSv1.RemoveFilter&ReplicatorSv1.GetThreshold&ReplicatorSv1.SetThreshold&ReplicatorSv1.RemoveThreshold&ReplicatorSv1.GetStatQueue&ReplicatorSv1.SetStatQueue&ReplicatorSv1.RemoveStatQueue&ReplicatorSv1.GetResource&ReplicatorSv1.SetResource&ReplicatorSv1.RemoveResource&ReplicatorSv1.GetResourceProfile&ReplicatorSv1.SetResourceProfile&ReplicatorSv1.RemoveResourceProfile&ReplicatorSv1.GetStatQueueProfile&ReplicatorSv1.SetStatQueueProfile&ReplicatorSv1.RemoveStatQueueProfile&ReplicatorSv1.GetThresholdProfile&ReplicatorSv1.SetThresholdProfile&ReplicatorSv1.RemoveThresholdProfile&ReplicatorSv1.GetTiming&ReplicatorSv1.SetTiming&ReplicatorSv1.RemoveTiming&ReplicatorSv1.GetActionTriggers&ReplicatorSv1.SetActionTriggers&ReplicatorSv1.RemoveActionTriggers&ReplicatorSv1.SetSharedGroup&ReplicatorSv1.GetSharedGroup&ReplicatorSv1.RemoveSharedGroup&ReplicatorSv1.SetActions&ReplicatorSv1.GetActions&ReplicatorSv1.RemoveActions&ReplicatorSv1.SetActionPlan&ReplicatorSv1.GetActionPlan&ReplicatorSv1.RemoveActionPlan&ReplicatorSv1.SetAccountActionPlans&ReplicatorSv1.GetAccountActionPlans&ReplicatorSv1.RemAccountActionPlans&ReplicatorSv1.SetRatingPlan&ReplicatorSv1.GetRatingPlan&ReplicatorSv1.RemoveRatingPlan&ReplicatorSv1.SetRatingProfile&ReplicatorSv1.GetRatingProfile&ReplicatorSv1.RemoveRatingProfile&ReplicatorSv1.SetDestination&ReplicatorSv1.GetDestination&ReplicatorSv1.RemoveDestination&ReplicatorSv1.SetLoadIDs&ReplicatorSv1.GetItemLoadIDs&ReplicatorSv1.SetRateProfile&ReplicatorSv1.GetRateProfile&ReplicatorSv1.RemoveRateProfile,false,20
+cgrates.org,ATTR_API_REPLICATOR_AUTH,*auth,*string:~*req.ApiKey:repl12345,,,*req.APIMethods,*constant,ReplicatorSv1.Ping&ReplicatorSv1.GetAccount&ReplicatorSv1.SetAccount&ReplicatorSv1.RemoveAccount&ReplicatorSv1.GetRouteProfile&ReplicatorSv1.SetRouteProfile&ReplicatorSv1.RemoveRouteProfile&ReplicatorSv1.GetAttributeProfile&ReplicatorSv1.SetAttributeProfile&ReplicatorSv1.RemoveAttributeProfile&ReplicatorSv1.SetChargerProfile&ReplicatorSv1.GetChargerProfile&ReplicatorSv1.RemoveChargerProfile&ReplicatorSv1.GetDispatcherProfile&ReplicatorSv1.SetDispatcherProfile&ReplicatorSv1.RemoveDispatcherProfile&ReplicatorSv1.GetDispatcherHost&ReplicatorSv1.SetDispatcherHost&ReplicatorSv1.RemoveDispatcherHost&ReplicatorSv1.GetFilter&ReplicatorSv1.SetFilter&ReplicatorSv1.RemoveFilter&ReplicatorSv1.GetThreshold&ReplicatorSv1.SetThreshold&ReplicatorSv1.RemoveThreshold&ReplicatorSv1.GetStatQueue&ReplicatorSv1.SetStatQueue&ReplicatorSv1.RemoveStatQueue&ReplicatorSv1.GetResource&ReplicatorSv1.SetResource&ReplicatorSv1.RemoveResource&ReplicatorSv1.GetResourceProfile&ReplicatorSv1.SetResourceProfile&ReplicatorSv1.RemoveResourceProfile&ReplicatorSv1.GetStatQueueProfile&ReplicatorSv1.SetStatQueueProfile&ReplicatorSv1.RemoveStatQueueProfile&ReplicatorSv1.GetThresholdProfile&ReplicatorSv1.SetThresholdProfile&ReplicatorSv1.RemoveThresholdProfile&ReplicatorSv1.GetTiming&ReplicatorSv1.SetTiming&ReplicatorSv1.RemoveTiming&ReplicatorSv1.GetActionTriggers&ReplicatorSv1.SetActionTriggers&ReplicatorSv1.RemoveActionTriggers&ReplicatorSv1.SetSharedGroup&ReplicatorSv1.GetSharedGroup&ReplicatorSv1.RemoveSharedGroup&ReplicatorSv1.SetActions&ReplicatorSv1.GetActions&ReplicatorSv1.RemoveActions&ReplicatorSv1.SetActionPlan&ReplicatorSv1.GetActionPlan&ReplicatorSv1.RemoveActionPlan&ReplicatorSv1.SetAccountActionPlans&ReplicatorSv1.GetAccountActionPlans&ReplicatorSv1.RemAccountActionPlans&ReplicatorSv1.SetRatingPlan&ReplicatorSv1.GetRatingPlan&ReplicatorSv1.RemoveRatingPlan&ReplicatorSv1.SetRatingProfile&ReplicatorSv1.GetRatingProfile&ReplicatorSv1.RemoveRatingProfile&ReplicatorSv1.SetDestination&ReplicatorSv1.GetDestination&ReplicatorSv1.RemoveDestination&ReplicatorSv1.SetLoadIDs&ReplicatorSv1.GetItemLoadIDs,false,20
cgrates.org,ATTR_API_CDRSV2,*auth,*string:~*req.ApiKey:cdrsv212345,,,*req.APIMethods,*constant,CDRsV2.ProcessEvent&CDRsV2.StoreSessionCost,false,20
cgrates.org,ATTR_API_RATES_AUTH,*auth,*string:~*req.ApiKey:rPrf12345,,,*req.APIMethods,*constant,RateSv1.Ping,false,20
cgrates.org,ATTR_API_CORE_AUTH,*auth,*string:~*req.ApiKey:core12345,,,*req.APIMethods,*constant,CoreSv1.Status&CoreSv1.Ping&CoreSv1.Sleep,false,20
diff --git a/data/tariffplans/oldaccvsnew/AccountProfiles.csv b/data/tariffplans/oldaccvsnew/AccountProfiles.csv
deleted file mode 100644
index 10c7efa30..000000000
--- a/data/tariffplans/oldaccvsnew/AccountProfiles.csv
+++ /dev/null
@@ -1,6 +0,0 @@
-#Tenant,ID,FilterIDs,ActivationInterval,Weights,Opts,BalanceID,BalanceFilterIDs,BalanceWeights,BalanceType,BalanceUnits,BalanceUnitFactors,BalanceOpts,BalanceCostIncrements,BalanceAttributeIDs,BalanceRateProfileIDs,ThresholdIDs
-cgrates.org,1001,*string:~*req.Account:1001,,,,VoiceBalance,,;10,*abstract,3600000000000,,,*string:~*req.ToR:*voice;1000000000;0;0,,,
-cgrates.org,1002,*string:~*req.Account:1002,,,,VoiceBalance,,;10,*abstract,3600000000000,,,*string:~*req.ToR:*voice;1000000000;;,,RP_ANY,
-cgrates.org,1002,,,,,MonetaryBalance,,;10,*concrete,100,,,,,,
-cgrates.org,1003,*string:~*req.Account:1003,,,,VoiceBalance,,;10,*abstract,3600000000000,,,*string:~*req.ToR:*voice;1000000000;;,,,
-cgrates.org,1003,,,,,MonetaryBalance,,;10,*concrete,100,,,,,,
diff --git a/data/tariffplans/oldaccvsnew/RateProfiles.csv b/data/tariffplans/oldaccvsnew/RateProfiles.csv
deleted file mode 100644
index 48b90d455..000000000
--- a/data/tariffplans/oldaccvsnew/RateProfiles.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tenant,ID,FilterIDs,ActivationInterval,Weight,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeight,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement
-cgrates.org,RP_ANY,,,,,,,RT_ANY,,,,,0s,0,0.2,60s,60s
-cgrates.org,RP_ANY,,,,,,,RT_ANY,,,,,60s,0,0.1,60s,1s
\ No newline at end of file
diff --git a/data/tariffplans/testit/AccountProfiles.csv b/data/tariffplans/testit/AccountProfiles.csv
deleted file mode 100644
index 287674eb0..000000000
--- a/data/tariffplans/testit/AccountProfiles.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tenant,ID,FilterIDs,ActivationInterval,Weights,Opts,BalanceID,BalanceFilterIDs,BalanceWeights,BalanceType,BalanceUnits,BalanceUnitFactors,BalanceOpts,BalanceCostIncrements,BalanceAttributeIDs,BalanceRateProfileIDs,ThresholdIDs
-cgrates.org,ACC_PRF_1,,,;20,,MonetaryBalance,,;10,*monetary,14,fltr1&fltr2;100;fltr3;200,,fltr1&fltr2;1.3;2.3;3.3,attr1;attr2,,*none
-cgrates.org,1001,,,,,VoiceBalance,,;10,*voice,3600000000000,,,,,,
\ No newline at end of file
diff --git a/data/tariffplans/testit/RateProfiles.csv b/data/tariffplans/testit/RateProfiles.csv
deleted file mode 100644
index 353008802..000000000
--- a/data/tariffplans/testit/RateProfiles.csv
+++ /dev/null
@@ -1,5 +0,0 @@
-#Tenant,ID,FilterIDs,ActivationInterval,Weights,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeights,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement
-cgrates.org,RT_SPECIAL_1002,*string:~*req.Account:1002,,;10,0,0,*free,RT_ALWAYS,,"* * * * *",;0,false,0s,,0.01,1m,1s
-cgrates.org,RT_RETAIL1,,,;0,0,0,*free,RT_ALWAYS,,"* * * * *",;0,false,0s,,0.4,1m,30s
-cgrates.org,RT_RETAIL1,,,,,,,RT_ALWAYS,,"* * * * *",;0,false,1m,,0.2,1m,10s
-
diff --git a/data/tariffplans/tutaccounts/AccountProfiles.csv b/data/tariffplans/tutaccounts/AccountProfiles.csv
deleted file mode 100644
index d1534754d..000000000
--- a/data/tariffplans/tutaccounts/AccountProfiles.csv
+++ /dev/null
@@ -1,5 +0,0 @@
-#Tenant,ID,FilterIDs,ActivationInterval,Weights,Opts,BalanceID,BalanceFilterIDs,BalanceWeights,BalanceType,BalanceUnits,BalanceUnitFactors,BalanceOpts,BalanceCostIncrements,BalanceAttributeIDs,BalanceRateProfileIDs,ThresholdIDs
-cgrates.org,1001,*string:~*req.Account:1001,,,,MonetaryBalance1,,;30,*concrete,5,,,*string:~*req.ToR:*voice;1000000000;0;0.01;*string:~*req.ToR:*data;1024;0;0.01,,,*none
-cgrates.org,1001,,,,,GenericBalance1,,;20,*abstract,3600000000000,*string:~*req.ToR:*data;1.024,,*string:~*req.ToR:*voice;1000000000;0;0.01;*string:~*req.ToR:*data;1024;0;0.01,,,
-cgrates.org,1001,,,,,MonetaryBalance2,,;10,*concrete,3,,,*string:~*req.ToR:*voice;1000000000;0;1,,,
-cgrates.org,1002,*string:~*req.Account:1002,,;10,,MonetaryBalance1,,,*concrete,10,,,*string:~*req.ToR:*voice;1000000000;0;0.01;;1;0;1,,,*none
diff --git a/data/tariffplans/tutrates/RateProfiles.csv b/data/tariffplans/tutrates/RateProfiles.csv
deleted file mode 100644
index 5cd0711df..000000000
--- a/data/tariffplans/tutrates/RateProfiles.csv
+++ /dev/null
@@ -1,5 +0,0 @@
-#Tenant,ID,FilterIDs,ActivationInterval,Weights,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeights,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement
-cgrates.org,RP1,*string:~*req.Subject:1001,,;0,0.1,0.6,*free,RT_WEEK,,"* * * * 1-5",;0,false,0s,,0.12,1m,1m
-cgrates.org,RP1,,,,,,,RT_WEEK,,,,,1m,,0.6,1m,1s
-cgrates.org,RP1,,,,,,,RT_WEEKEND,,"* * * * 0,6",;10,false,0s,,0.06,1m,1s
-cgrates.org,RP1,,,,,,,RT_CHRISTMAS,,* * 24 12 *,;30,false,0s,,0.06,1m,1s
\ No newline at end of file
diff --git a/engine/storage_csv.go b/engine/storage_csv.go
index 7fbd2d61d..71fca5e98 100644
--- a/engine/storage_csv.go
+++ b/engine/storage_csv.go
@@ -204,6 +204,7 @@ func NewGoogleCSVStorage(sep rune, spreadsheetID string) (*CSVStorage, error) {
getIfExist(utils.Chargers),
getIfExist(utils.DispatcherProfiles),
getIfExist(utils.DispatcherHosts),
+ )
c.generator = func() csvReaderCloser {
return &csvGoogle{
spreadsheetID: spreadsheetID,
diff --git a/general_tests/acntacts_test.go b/general_tests/acntacts_test.go
index 73abcbf8a..b1e032309 100644
--- a/general_tests/acntacts_test.go
+++ b/general_tests/acntacts_test.go
@@ -58,7 +58,7 @@ ENABLE_ACNT,*enable_account,,,,,,,,,,,,,false,false,10`
csvr, err := engine.NewTpReader(dbAcntActs.DataDB(), engine.NewStringCSVStorage(utils.CSVSep, destinations, timings,
rates, destinationRates, ratingPlans, ratingProfiles, sharedGroups,
actions, actionPlans, actionTriggers, accountActions,
- resLimits, stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, "", utils.EmptyString, utils.EmptyString), "", "", nil, nil, false)
+ resLimits, stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, ""), "", "", nil, nil, false)
if err != nil {
t.Error(err)
}
diff --git a/general_tests/auth_test.go b/general_tests/auth_test.go
index 9e400338b..0df896889 100644
--- a/general_tests/auth_test.go
+++ b/general_tests/auth_test.go
@@ -60,7 +60,7 @@ func TestAuthLoadCsvError(t *testing.T) {
chargerProfiles := ``
csvr, err := engine.NewTpReader(dbAuth.DataDB(), engine.NewStringCSVStorage(utils.CSVSep, destinations, timings, rates, destinationRates,
ratingPlans, ratingProfiles, sharedGroups, actions, actionPlans, actionTriggers, accountActions,
- resLimits, stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, "", utils.EmptyString, utils.EmptyString), "", "", nil, nil, false)
+ resLimits, stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, ""), "", "", nil, nil, false)
if err != nil {
t.Error(err)
}
@@ -94,7 +94,7 @@ cgrates.org,call,*any,2013-01-06T00:00:00Z,RP_ANY,`
chargerProfiles := ``
csvr, err := engine.NewTpReader(dbAuth.DataDB(), engine.NewStringCSVStorage(utils.CSVSep, destinations, timings, rates, destinationRates,
ratingPlans, ratingProfiles, sharedGroups, actions, actionPlans, actionTriggers, accountActions,
- resLimits, stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, "", utils.EmptyString, utils.EmptyString), "", "", nil, nil, false)
+ resLimits, stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, ""), "", "", nil, nil, false)
if err != nil {
t.Error(err)
}
diff --git a/general_tests/costs1_test.go b/general_tests/costs1_test.go
index 658c019e6..9a45b083a 100644
--- a/general_tests/costs1_test.go
+++ b/general_tests/costs1_test.go
@@ -59,7 +59,7 @@ cgrates.org,sms,*any,2012-01-01T00:00:00Z,RP_SMS1,`
utils.EmptyString, utils.EmptyString, utils.EmptyString,
utils.EmptyString, utils.EmptyString, utils.EmptyString,
utils.EmptyString, utils.EmptyString, utils.EmptyString,
- utils.EmptyString, utils.EmptyString, utils.EmptyString, utils.EmptyString),
+ utils.EmptyString, utils.EmptyString),
utils.EmptyString, utils.EmptyString, nil, nil, false)
if err != nil {
t.Error(err)
diff --git a/general_tests/datachrg1_test.go b/general_tests/datachrg1_test.go
index 7a62c0cac..dc246852d 100644
--- a/general_tests/datachrg1_test.go
+++ b/general_tests/datachrg1_test.go
@@ -47,7 +47,7 @@ RP_DATA1,DR_DATA_2,TM2,10`
utils.EmptyString, timings, rates, destinationRates, ratingPlans, ratingProfiles,
utils.EmptyString, utils.EmptyString, utils.EmptyString, utils.EmptyString, utils.EmptyString,
utils.EmptyString, utils.EmptyString, utils.EmptyString, utils.EmptyString, utils.EmptyString,
- utils.EmptyString, utils.EmptyString, utils.EmptyString, utils.EmptyString, utils.EmptyString, utils.EmptyString),
+ utils.EmptyString, utils.EmptyString, utils.EmptyString, utils.EmptyString),
utils.EmptyString, utils.EmptyString, nil, nil, false)
if err != nil {
t.Error(err)
diff --git a/general_tests/ddazmbl1_test.go b/general_tests/ddazmbl1_test.go
index b69b7bc27..00d1bec00 100644
--- a/general_tests/ddazmbl1_test.go
+++ b/general_tests/ddazmbl1_test.go
@@ -68,7 +68,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10`
destinationRates, ratingPlans, ratingProfiles,
sharedGroups, actions, actionPlans, actionTriggers, accountActions,
resLimits, stats, thresholds, filters, suppliers,
- attrProfiles, chargerProfiles, ``, "", utils.EmptyString, utils.EmptyString), "", "", nil, nil, false)
+ attrProfiles, chargerProfiles, ``, ""), "", "", nil, nil, false)
if err != nil {
t.Error(err)
}
diff --git a/general_tests/ddazmbl2_test.go b/general_tests/ddazmbl2_test.go
index da9d9fc9f..d068d1cc4 100644
--- a/general_tests/ddazmbl2_test.go
+++ b/general_tests/ddazmbl2_test.go
@@ -66,7 +66,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10`
csvr, err := engine.NewTpReader(dataDB2.DataDB(), engine.NewStringCSVStorage(utils.CSVSep, destinations, timings,
rates, destinationRates, ratingPlans, ratingProfiles, sharedGroups, actions, actionPlans,
actionTriggers, accountActions, resLimits,
- stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, "", utils.EmptyString, utils.EmptyString), "", "", nil, nil, false)
+ stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, ""), "", "", nil, nil, false)
if err != nil {
t.Error(err)
}
diff --git a/general_tests/ddazmbl3_test.go b/general_tests/ddazmbl3_test.go
index aa290102e..c3eee4caa 100644
--- a/general_tests/ddazmbl3_test.go
+++ b/general_tests/ddazmbl3_test.go
@@ -64,7 +64,7 @@ cgrates.org,call,discounted_minutes,2013-01-06T00:00:00Z,RP_UK_Mobile_BIG5_PKG,`
csvr, err := engine.NewTpReader(dataDB3.DataDB(), engine.NewStringCSVStorage(utils.CSVSep, destinations, timings, rates,
destinationRates, ratingPlans, ratingProfiles, sharedGroups, actions, actionPlans, actionTriggers,
accountActions, resLimits, stats,
- thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, "", utils.EmptyString, utils.EmptyString), "", "", nil, nil, false)
+ thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``, ""), "", "", nil, nil, false)
if err != nil {
t.Error(err)
}
diff --git a/general_tests/smschrg1_test.go b/general_tests/smschrg1_test.go
index 7b5369dfd..60fa47926 100644
--- a/general_tests/smschrg1_test.go
+++ b/general_tests/smschrg1_test.go
@@ -47,7 +47,7 @@ func TestSMSLoadCsvTpSmsChrg1(t *testing.T) {
utils.EmptyString, utils.EmptyString, utils.EmptyString, utils.EmptyString,
utils.EmptyString, utils.EmptyString, utils.EmptyString, utils.EmptyString,
utils.EmptyString, utils.EmptyString, utils.EmptyString, utils.EmptyString,
- utils.EmptyString, utils.EmptyString, utils.EmptyString, utils.EmptyString), utils.EmptyString,
+ utils.EmptyString, utils.EmptyString), utils.EmptyString,
utils.EmptyString, nil, nil, false)
if err != nil {
t.Error(err)
diff --git a/go.mod b/go.mod
index df84211f8..e4616450d 100644
--- a/go.mod
+++ b/go.mod
@@ -17,7 +17,6 @@ require (
github.com/cenkalti/rpc2 v0.0.0-20210220005819-4a29bc83afe1
github.com/cgrates/aringo v0.0.0-20201113143849-3b299e4e636d
github.com/cgrates/baningo v0.0.0-20201105145354-6e3173f6a91b
- github.com/cgrates/cron v0.0.0-20201022095836-3522d5b72c70
github.com/cgrates/fsock v0.0.0-20191107070144-e7a331109df7
github.com/cgrates/kamevapi v0.0.0-20191001125829-7dbc3ad58817
github.com/cgrates/ltcache v0.0.0-20181016092649-92fb7fa77cca
diff --git a/go.sum b/go.sum
index 911fd6202..1e87b17b4 100644
--- a/go.sum
+++ b/go.sum
@@ -86,8 +86,6 @@ github.com/cgrates/aringo v0.0.0-20201113143849-3b299e4e636d h1:1PLz/t3XZy5KF8EY
github.com/cgrates/aringo v0.0.0-20201113143849-3b299e4e636d/go.mod h1:mMAzSIjK11XfRMrOIa7DXYl64REdPldRCbAgzKB47XQ=
github.com/cgrates/baningo v0.0.0-20201105145354-6e3173f6a91b h1:9IX5Z3Tw7n2QrY7GLGGpqjjC/NVSJvQ7nxLkC2JP4vw=
github.com/cgrates/baningo v0.0.0-20201105145354-6e3173f6a91b/go.mod h1:3SwVROaS1Iml5lqEhj0gRhDRtmbBgypZpKcEkVTSleU=
-github.com/cgrates/cron v0.0.0-20201022095836-3522d5b72c70 h1:/O+Dr12jcizDiCoIG2oK6wyE1pNRVQc62Wz+TfPWDhU=
-github.com/cgrates/cron v0.0.0-20201022095836-3522d5b72c70/go.mod h1:I9cUDn/uzkakr0hmYTjXkQqf6wagg44L2p01gSYRRz0=
github.com/cgrates/fsock v0.0.0-20191107070144-e7a331109df7 h1:dxtBWRAr62vRRKkExmJZ0u1EbCw/y0vOkSfdFND5qXw=
github.com/cgrates/fsock v0.0.0-20191107070144-e7a331109df7/go.mod h1:uWcTZ01eKJdWcoYBhsEXKgSlO6Vv8wT9qcR5JeJovBs=
github.com/cgrates/kamevapi v0.0.0-20191001125829-7dbc3ad58817 h1:1Tdv6H/usqmkQVeQbd+x87L5xo6DFmbYpbI00qfrWGw=
diff --git a/migrator/migrator.go b/migrator/migrator.go
index 549a184c3..bd639d7f8 100644
--- a/migrator/migrator.go
+++ b/migrator/migrator.go
@@ -215,6 +215,9 @@ func (m *Migrator) Migrate(taskIDs []string) (err error, stats map[string]int) {
if err := m.migrateThresholds(); err != nil {
log.Print("ERROR: ", utils.MetaThresholds, " ", err)
}
+ if err := m.migrateRouteProfiles(); err != nil {
+ log.Print("ERROR: ", utils.MetaRoutes, " ", err)
+ }
if err := m.migrateAttributeProfile(); err != nil {
log.Print("ERROR: ", utils.MetaAttributes, " ", err)
}
diff --git a/migrator/migrator_datadb.go b/migrator/migrator_datadb.go
index 5c58ef843..a3ea977fc 100644
--- a/migrator/migrator_datadb.go
+++ b/migrator/migrator_datadb.go
@@ -83,6 +83,7 @@ type MigratorDataDB interface {
getV1ChargerProfile() (v1chrPrf *engine.ChargerProfile, err error)
getV1DispatcherProfile() (v1chrPrf *engine.DispatcherProfile, err error)
+ getV1RouteProfile() (v1chrPrf *engine.RouteProfile, err error)
getV3Stats() (v1st *engine.StatQueueProfile, err error)
getV3ThresholdProfile() (v2T *engine.ThresholdProfile, err error)
diff --git a/migrator/routes.go b/migrator/routes.go
index 1013c8327..82f79de52 100644
--- a/migrator/routes.go
+++ b/migrator/routes.go
@@ -19,6 +19,7 @@ along with this program. If not, see
package migrator
import (
+ "errors"
"fmt"
"strings"
@@ -136,6 +137,67 @@ func (m *Migrator) migrateCurrentRouteProfile() (err error) {
return
}
+func (m *Migrator) migrateRouteProfiles() (err error) {
+ var vrs engine.Versions
+ current := engine.CurrentDataDBVersions()
+ if vrs, err = m.getVersions(utils.ActionTriggers); err != nil {
+ return
+ }
+ routeVersion, has := vrs[utils.Routes]
+ if !has {
+ if vrs[utils.RQF] != current[utils.RQF] {
+ return fmt.Errorf("please migrate the filters before migrating the routes")
+ }
+ if err = m.migrateFromSupplierToRoute(); err != nil {
+ return
+ }
+ }
+ migrated := true
+ var v2 *engine.RouteProfile
+ for {
+ version := routeVersion
+ for {
+ switch version {
+ default:
+ return fmt.Errorf("Unsupported version %v", version)
+ case current[utils.Routes]:
+ migrated = false
+ if m.sameDataDB {
+ break
+ }
+ if err = m.migrateCurrentRouteProfile(); err != nil {
+ return err
+ }
+ case 1:
+ if v2, err = m.migrateV1ToV2Routes(); err != nil && err != utils.ErrNoMoreData {
+ return
+ } else if err == utils.ErrNoMoreData {
+ break
+ }
+ version = 2
+ }
+ if version == current[utils.Routes] || err == utils.ErrNoMoreData {
+ break
+ }
+ }
+ if err == utils.ErrNoMoreData || !migrated {
+ break
+ }
+ if !m.dryRun {
+ if err = m.dmIN.DataManager().SetRouteProfile(v2, true); err != nil {
+ return
+ }
+ }
+ m.stats[utils.Routes]++
+ }
+ // All done, update version wtih current one
+ if err = m.setVersions(utils.Routes); err != nil {
+ return
+ }
+
+ return m.ensureIndexesDataDB(engine.ColRts)
+}
+
func convertSupplierToRoute(spp *SupplierProfile) (route *engine.RouteProfile) {
route = &engine.RouteProfile{
Tenant: spp.Tenant,
@@ -162,3 +224,16 @@ func convertSupplierToRoute(spp *SupplierProfile) (route *engine.RouteProfile) {
}
return
}
+
+func (m *Migrator) migrateV1ToV2Routes() (v4Cpp *engine.RouteProfile, err error) {
+ v4Cpp, err = m.dmIN.getV1RouteProfile()
+ if err != nil {
+ return nil, err
+ } else if v4Cpp == nil {
+ return nil, errors.New("Dispatcher NIL")
+ }
+ if v4Cpp.FilterIDs, err = migrateInlineFilterV4(v4Cpp.FilterIDs); err != nil {
+ return nil, err
+ }
+ return
+}
diff --git a/migrator/storage_mongo_datadb.go b/migrator/storage_mongo_datadb.go
index d2da3456f..24054c9ec 100644
--- a/migrator/storage_mongo_datadb.go
+++ b/migrator/storage_mongo_datadb.go
@@ -852,3 +852,22 @@ func (v1ms *mongoMigrator) getV1DispatcherProfile() (v1dppPrf *engine.Dispatcher
}
return
}
+
+func (v1ms *mongoMigrator) getV1RouteProfile() (v1dppPrf *engine.RouteProfile, err error) {
+ if v1ms.cursor == nil {
+ v1ms.cursor, err = v1ms.mgoDB.DB().Collection(engine.ColRts).Find(v1ms.mgoDB.GetContext(), bson.D{})
+ if err != nil {
+ return nil, err
+ }
+ }
+ if !(*v1ms.cursor).Next(v1ms.mgoDB.GetContext()) {
+ (*v1ms.cursor).Close(v1ms.mgoDB.GetContext())
+ v1ms.cursor = nil
+ return nil, utils.ErrNoMoreData
+ }
+ v1dppPrf = new(engine.RouteProfile)
+ if err := (*v1ms.cursor).Decode(v1dppPrf); err != nil {
+ return nil, err
+ }
+ return
+}
diff --git a/services/datadb.go b/services/datadb.go
index 24d0f68d2..4057afc80 100644
--- a/services/datadb.go
+++ b/services/datadb.go
@@ -140,8 +140,7 @@ func (db *DataDBService) mandatoryDB() bool {
return db.cfg.RalsCfg().Enabled || db.cfg.SchedulerCfg().Enabled || db.cfg.ChargerSCfg().Enabled ||
db.cfg.AttributeSCfg().Enabled || db.cfg.ResourceSCfg().Enabled || db.cfg.StatSCfg().Enabled ||
db.cfg.ThresholdSCfg().Enabled || db.cfg.RouteSCfg().Enabled || db.cfg.DispatcherSCfg().Enabled ||
- db.cfg.LoaderCfg().Enabled() || db.cfg.ApierCfg().Enabled || db.cfg.RateSCfg().Enabled ||
- db.cfg.AccountSCfg().Enabled || db.cfg.AnalyzerSCfg().Enabled
+ db.cfg.LoaderCfg().Enabled() || db.cfg.ApierCfg().Enabled || db.cfg.AnalyzerSCfg().Enabled
}
// GetDM returns the DataManager
diff --git a/servmanager/servmanager.go b/servmanager/servmanager.go
index d7186f5da..740d9873b 100644
--- a/servmanager/servmanager.go
+++ b/servmanager/servmanager.go
@@ -239,8 +239,6 @@ func (srvMngr *ServiceManager) handleReload() {
go srvMngr.reloadService(utils.StorDB)
case <-srvMngr.GetConfig().GetReloadChan(config.EEsJson):
go srvMngr.reloadService(utils.EventExporterS)
- case <-srvMngr.GetConfig().GetReloadChan(config.RateSJson):
- go srvMngr.reloadService(utils.RateS)
case <-srvMngr.GetConfig().GetReloadChan(config.RPCConnsJsonName):
go srvMngr.connMgr.Reload()
case <-srvMngr.GetConfig().GetReloadChan(config.SIPAgentJson):
@@ -249,8 +247,6 @@ func (srvMngr *ServiceManager) handleReload() {
go srvMngr.reloadService(utils.RegistrarC)
case <-srvMngr.GetConfig().GetReloadChan(config.HTTP_JSN):
go srvMngr.reloadService(utils.GlobalVarS)
- case <-srvMngr.GetConfig().GetReloadChan(config.AccountSCfgJson):
- go srvMngr.reloadService(utils.AccountS)
case <-srvMngr.GetConfig().GetReloadChan(config.CoreSCfgJson):
go srvMngr.reloadService(utils.CoreS)
}
diff --git a/utils/accountprofile.go b/utils/accountprofile.go
deleted file mode 100644
index 98e5c0dd8..000000000
--- a/utils/accountprofile.go
+++ /dev/null
@@ -1,514 +0,0 @@
-/*
-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
-*/
-
-package utils
-
-import (
- "sort"
- "time"
-
- "github.com/ericlagergren/decimal"
-)
-
-// AccountProfile represents one Account on a Tenant
-type AccountProfile struct {
- Tenant string
- ID string // Account identificator, unique within the tenant
- FilterIDs []string
- ActivationInterval *ActivationInterval
- Weights DynamicWeights
- Opts map[string]interface{}
- Balances map[string]*Balance
- ThresholdIDs []string
-}
-
-// BalancesAltered detects altering of the Balances by comparing the Balance values with the ones from backup
-func (ap *AccountProfile) BalancesAltered(abb AccountBalancesBackup) (altred bool) {
- if len(ap.Balances) != len(abb) {
- return true
- }
- for blncID, blnc := range ap.Balances {
- if bkpVal, has := abb[blncID]; !has {
- return true
- } else if blnc.Units.Big.Cmp(bkpVal) != 0 {
- return true
- }
- }
- return
-}
-
-func (ap *AccountProfile) RestoreFromBackup(abb AccountBalancesBackup) {
- for blncID, val := range abb {
- ap.Balances[blncID].Units.Big = val
- }
-}
-
-// AccountBalancesBackup returns a backup of all balance values
-func (ap *AccountProfile) AccountBalancesBackup() (abb AccountBalancesBackup) {
- if ap.Balances != nil {
- abb = make(AccountBalancesBackup)
- for blncID, blnc := range ap.Balances {
- abb[blncID] = new(decimal.Big).Copy(blnc.Units.Big)
- }
- }
- return
-}
-
-// AccountBalanceBackups is used to create balance snapshots as backups
-type AccountBalancesBackup map[string]*decimal.Big
-
-// NewDefaultBalance returns a balance with default costIncrements
-func NewDefaultBalance(id string) *Balance {
- const torFltr = "*string:~*req.ToR:"
- return &Balance{
- ID: id,
- Type: MetaConcrete,
- Units: NewDecimal(0, 0),
- CostIncrements: []*CostIncrement{
- {
- FilterIDs: []string{torFltr + MetaVoice},
- Increment: NewDecimal(int64(time.Second), 0),
- RecurrentFee: NewDecimal(0, 0),
- },
- {
- FilterIDs: []string{torFltr + MetaData},
- Increment: NewDecimal(1024*1024, 0),
- RecurrentFee: NewDecimal(0, 0),
- },
- {
- FilterIDs: []string{torFltr + MetaSMS},
- Increment: NewDecimal(1, 0),
- RecurrentFee: NewDecimal(0, 0),
- },
- },
- }
-}
-
-// Balance represents one Balance inside an Account
-type Balance struct {
- ID string // Balance identificator, unique within an Account
- FilterIDs []string
- Weights DynamicWeights
- Type string
- Units *Decimal
- UnitFactors []*UnitFactor
- Opts map[string]interface{}
- CostIncrements []*CostIncrement
- AttributeIDs []string
-}
-
-// CostIncrement enforces cost calculation to specific balance increments
-type CostIncrement struct {
- FilterIDs []string
- Increment *Decimal
- FixedFee *Decimal
- RecurrentFee *Decimal
-}
-
-// Clone returns a copy of the CostIncrement
-func (cI *CostIncrement) Clone() (cIcln *CostIncrement) {
- cIcln = new(CostIncrement)
- if cI.FilterIDs != nil {
- cIcln.FilterIDs = make([]string, len(cI.FilterIDs))
- for i, fID := range cI.FilterIDs {
- cIcln.FilterIDs[i] = fID
- }
- }
- if cI.Increment != nil {
- cIcln.Increment = cI.Increment.Clone()
- }
- if cI.FixedFee != nil {
- cIcln.FixedFee = cI.FixedFee.Clone()
- }
- if cI.RecurrentFee != nil {
- cIcln.RecurrentFee = cI.RecurrentFee.Clone()
- }
- return
-}
-
-//Clone return a copy of the UnitFactor
-func (uF *UnitFactor) Clone() (untFct *UnitFactor) {
- untFct = new(UnitFactor)
- if uF.FilterIDs != nil {
- untFct.FilterIDs = make([]string, len(uF.FilterIDs))
- for i, value := range uF.FilterIDs {
- untFct.FilterIDs[i] = value
- }
- }
- if uF.Factor != nil {
- untFct.Factor = uF.Factor.Clone()
- }
- return
-}
-
-// UnitFactor is a multiplicator for the usage received
-type UnitFactor struct {
- FilterIDs []string
- Factor *Decimal
-}
-
-// Equals compares two UnitFactors
-func (uF *UnitFactor) Equals(nUf *UnitFactor) (eq bool) {
- if uF.FilterIDs == nil && nUf.FilterIDs != nil ||
- uF.FilterIDs != nil && nUf.FilterIDs == nil ||
- len(uF.FilterIDs) != len(nUf.FilterIDs) {
- return
- }
- for i := range uF.FilterIDs {
- if uF.FilterIDs[i] != nUf.FilterIDs[i] {
- return
- }
- }
- if uF.Factor == nil && nUf.Factor != nil ||
- uF.Factor != nil && nUf.Factor == nil {
- return
- }
- if uF.Factor == nil && nUf.Factor == nil {
- return true
- }
- return uF.Factor.Compare(nUf.Factor) == 0
-}
-
-// TenantID returns the combined Tenant:ID
-func (aP *AccountProfile) TenantID() string {
- return ConcatenatedKey(aP.Tenant, aP.ID)
-}
-
-// Clone returns a clone of the Account
-func (aP *AccountProfile) Clone() (acnt *AccountProfile) {
- acnt = &AccountProfile{
- Tenant: aP.Tenant,
- ID: aP.ID,
- ActivationInterval: aP.ActivationInterval.Clone(),
- Weights: aP.Weights.Clone(),
- }
- if aP.FilterIDs != nil {
- acnt.FilterIDs = make([]string, len(aP.FilterIDs))
- for i, value := range aP.FilterIDs {
- acnt.FilterIDs[i] = value
- }
- }
- if aP.Opts != nil {
- acnt.Opts = make(map[string]interface{})
- for key, value := range aP.Opts {
- acnt.Opts[key] = value
- }
- }
- if aP.Balances != nil {
- acnt.Balances = make(map[string]*Balance, len(aP.Balances))
- for i, value := range aP.Balances {
- acnt.Balances[i] = value.Clone()
- }
- }
- if aP.ThresholdIDs != nil {
- acnt.ThresholdIDs = make([]string, len(aP.ThresholdIDs))
- for i, value := range aP.ThresholdIDs {
- acnt.ThresholdIDs[i] = value
- }
- }
- return
-}
-
-//Clone returns a clone of the ActivationInterval
-func (aI *ActivationInterval) Clone() *ActivationInterval {
- if aI == nil {
- return nil
- }
- return &ActivationInterval{
- ActivationTime: aI.ActivationTime,
- ExpiryTime: aI.ExpiryTime,
- }
-}
-
-//Clone return a clone of the Balance
-func (bL *Balance) Clone() (blnc *Balance) {
- blnc = &Balance{
- ID: bL.ID,
- Weights: bL.Weights.Clone(),
- Type: bL.Type,
- }
- if bL.FilterIDs != nil {
- blnc.FilterIDs = make([]string, len(bL.FilterIDs))
- for i, value := range bL.FilterIDs {
- blnc.FilterIDs[i] = value
- }
- }
- if bL.Units != nil {
- blnc.Units = bL.Units.Clone()
- }
- if bL.UnitFactors != nil {
- blnc.UnitFactors = make([]*UnitFactor, len(bL.UnitFactors))
- for i, value := range bL.UnitFactors {
- blnc.UnitFactors[i] = value.Clone()
- }
- }
- if bL.Opts != nil {
- blnc.Opts = make(map[string]interface{})
- for key, value := range bL.Opts {
- blnc.Opts[key] = value
- }
- }
- if bL.CostIncrements != nil {
- blnc.CostIncrements = make([]*CostIncrement, len(bL.CostIncrements))
- for i, value := range bL.CostIncrements {
- blnc.CostIncrements[i] = value.Clone()
- }
- }
- if bL.AttributeIDs != nil {
- blnc.AttributeIDs = make([]string, len(bL.AttributeIDs))
- for i, value := range bL.AttributeIDs {
- blnc.AttributeIDs[i] = value
- }
- }
- return
-}
-
-// AccountProfileWithWeight attaches static weight to AccountProfile
-type AccountProfileWithWeight struct {
- *AccountProfile
- Weight float64
- LockID string
-}
-
-// AccountProfilesWithWeight is a sortable list of AccountProfileWithWeight
-type AccountProfilesWithWeight []*AccountProfileWithWeight
-
-// Sort is part of sort interface, sort based on Weight
-func (aps AccountProfilesWithWeight) Sort() {
- sort.Slice(aps, func(i, j int) bool { return aps[i].Weight > aps[j].Weight })
-}
-
-// AccountProfiles returns the list of AccountProfiles
-func (apWws AccountProfilesWithWeight) AccountProfiles() (aps []*AccountProfile) {
- if apWws != nil {
- aps = make([]*AccountProfile, len(apWws))
- for i, apWw := range apWws {
- aps[i] = apWw.AccountProfile
- }
- }
- return
-}
-
-// LockIDs returns the list of LockIDs
-func (apWws AccountProfilesWithWeight) LockIDs() (lkIDs []string) {
- if apWws != nil {
- lkIDs = make([]string, len(apWws))
- for i, apWw := range apWws {
- lkIDs[i] = apWw.LockID
- }
- }
- return
-}
-
-func (apWws AccountProfilesWithWeight) TenantIDs() (tntIDs []string) {
- if apWws != nil {
- tntIDs = make([]string, len(apWws))
- for i, apWw := range apWws {
- tntIDs[i] = apWw.AccountProfile.TenantID()
- }
- }
- return
-}
-
-// BalanceWithWeight attaches static Weight to Balance
-type BalanceWithWeight struct {
- *Balance
- Weight float64
-}
-
-// BalancesWithWeight is a sortable list of BalanceWithWeight
-type BalancesWithWeight []*BalanceWithWeight
-
-// Sort is part of sort interface, sort based on Weight
-func (blcs BalancesWithWeight) Sort() {
- sort.Slice(blcs, func(i, j int) bool { return blcs[i].Weight > blcs[j].Weight })
-}
-
-// Balances returns the list of Balances
-func (bWws BalancesWithWeight) Balances() (blncs []*Balance) {
- if bWws != nil {
- blncs = make([]*Balance, len(bWws))
- for i, bWw := range bWws {
- blncs[i] = bWw.Balance
- }
- }
- return
-}
-
-// APIAccountProfileWithOpts is used in API calls
-type APIAccountProfileWithOpts struct {
- *APIAccountProfile
- APIOpts map[string]interface{}
-}
-
-type AccountProfileWithAPIOpts struct {
- *AccountProfile
- APIOpts map[string]interface{}
-}
-
-// ArgsAccountForEvent arguments used for process event
-type ArgsAccountsForEvent struct {
- *CGREvent
- AccountIDs []string
-}
-
-type ReplyMaxUsage struct {
- AccountID string
- MaxUsage time.Duration
-}
-
-// APIAccountProfile represents one APIAccount on a Tenant
-type APIAccountProfile struct {
- Tenant string
- ID string
- FilterIDs []string
- ActivationInterval *ActivationInterval
- Weights string
- Opts map[string]interface{}
- Balances map[string]*APIBalance
- ThresholdIDs []string
-}
-
-// AsAccountProfile convert APIAccountProfile struct to AccountProfile struct
-func (ext *APIAccountProfile) AsAccountProfile() (profile *AccountProfile, err error) {
- profile = &AccountProfile{
- Tenant: ext.Tenant,
- ID: ext.ID,
- FilterIDs: ext.FilterIDs,
- ActivationInterval: ext.ActivationInterval,
- Opts: ext.Opts,
- ThresholdIDs: ext.ThresholdIDs,
- }
- if ext.Weights != EmptyString {
- if profile.Weights, err = NewDynamicWeightsFromString(ext.Weights, ";", "&"); err != nil {
- return nil, err
- }
- }
- if len(ext.Balances) != 0 {
- profile.Balances = make(map[string]*Balance, len(ext.Balances))
- for i, bal := range ext.Balances {
- if profile.Balances[i], err = bal.AsBalance(); err != nil {
- return nil, err
- }
- }
- }
- return
-}
-
-// APIBalance represents one APIBalance inside an APIAccount
-type APIBalance struct {
- ID string // Balance identificator, unique within an Account
- FilterIDs []string
- Weights string
- Type string
- Units float64
- UnitFactors []*APIUnitFactor
- Opts map[string]interface{}
- CostIncrements []*APICostIncrement
- AttributeIDs []string
-}
-
-// AsBalance convert APIBalance struct to Balance struct
-func (ext *APIBalance) AsBalance() (balance *Balance, err error) {
- balance = &Balance{
- ID: ext.ID,
- FilterIDs: ext.FilterIDs,
- Type: ext.Type,
- Units: NewDecimalFromFloat64(ext.Units),
- Opts: ext.Opts,
- AttributeIDs: ext.AttributeIDs,
- }
- if ext.Weights != EmptyString {
- if balance.Weights, err = NewDynamicWeightsFromString(ext.Weights, ";", "&"); err != nil {
- return nil, err
- }
- }
- if len(ext.UnitFactors) != 0 {
- balance.UnitFactors = make([]*UnitFactor, len(ext.UnitFactors))
- for i, uFct := range ext.UnitFactors {
- balance.UnitFactors[i] = uFct.AsUnitFactor()
- }
- }
- if len(ext.CostIncrements) != 0 {
- balance.CostIncrements = make([]*CostIncrement, len(ext.CostIncrements))
- for i, cIncr := range ext.CostIncrements {
- balance.CostIncrements[i] = cIncr.AsCostIncrement()
- }
- }
- return
-
-}
-
-// APICostIncrement represent one CostIncrement inside an APIBalance
-type APICostIncrement struct {
- FilterIDs []string
- Increment *float64
- FixedFee *float64
- RecurrentFee *float64
-}
-
-// AsCostIncrement convert APICostIncrement struct to CostIncrement struct
-func (ext *APICostIncrement) AsCostIncrement() (cIncr *CostIncrement) {
- cIncr = &CostIncrement{
- FilterIDs: ext.FilterIDs,
- }
- if ext.Increment != nil {
- cIncr.Increment = NewDecimalFromFloat64(*ext.Increment)
- }
- if ext.FixedFee != nil {
- cIncr.FixedFee = NewDecimalFromFloat64(*ext.FixedFee)
- }
- if ext.RecurrentFee != nil {
- cIncr.RecurrentFee = NewDecimalFromFloat64(*ext.RecurrentFee)
- }
- return
-}
-
-// APIUnitFactor represent one UnitFactor inside an APIBalance
-type APIUnitFactor struct {
- FilterIDs []string
- Factor float64
-}
-
-// AsUnitFactor convert APIUnitFactor struct to UnitFactor struct
-func (ext *APIUnitFactor) AsUnitFactor() *UnitFactor {
- return &UnitFactor{
- FilterIDs: ext.FilterIDs,
- Factor: NewDecimalFromFloat64(ext.Factor),
- }
-}
-
-type ArgsActSetBalance struct {
- Tenant string
- AccountID string
- Diktats []*BalDiktat
- Reset bool
- APIOpts map[string]interface{}
-}
-
-type BalDiktat struct {
- Path string
- Value string
-}
-
-type ArgsActRemoveBalances struct {
- Tenant string
- AccountID string
- BalanceIDs []string
- APIOpts map[string]interface{}
-}
diff --git a/utils/accountprofile_test.go b/utils/accountprofile_test.go
deleted file mode 100644
index 84de5b5b9..000000000
--- a/utils/accountprofile_test.go
+++ /dev/null
@@ -1,750 +0,0 @@
-/*
-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
-*/
-
-package utils
-
-import (
- "reflect"
- "testing"
- "time"
-
- "github.com/ericlagergren/decimal"
-)
-
-func TestCloneBalance(t *testing.T) {
- expBlc := &Balance{
- ID: "TEST_ID1",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Weights: DynamicWeights{
- {
- Weight: 1.1,
- },
- },
- Type: "*abstract",
- Opts: map[string]interface{}{
- "Destination": 10,
- },
- CostIncrements: []*CostIncrement{
- {
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Increment: &Decimal{decimal.New(1, 1)},
- FixedFee: &Decimal{decimal.New(75, 1)},
- RecurrentFee: &Decimal{decimal.New(20, 1)},
- },
- },
- AttributeIDs: []string{"attr1", "attr2"},
- UnitFactors: []*UnitFactor{
- {
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Factor: &Decimal{decimal.New(20, 2)},
- },
- },
- Units: &Decimal{decimal.New(125, 3)},
- }
- if rcv := expBlc.Clone(); !reflect.DeepEqual(rcv, expBlc) {
- t.Errorf("Expected %+v \n, received %+v", ToJSON(expBlc), ToJSON(rcv))
- }
-
- expBlc.Opts = nil
- if rcv := expBlc.Clone(); !reflect.DeepEqual(rcv, expBlc) {
- t.Errorf("Expected %+v \n, received %+v", ToJSON(expBlc), ToJSON(rcv))
- }
-}
-
-func TestCloneAccountProfile(t *testing.T) {
- actPrf := &AccountProfile{
- Tenant: "cgrates.org",
- ID: "Profile_id1",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- ActivationInterval: &ActivationInterval{
- ActivationTime: time.Date(2020, 7, 21, 10, 0, 0, 0, time.UTC),
- ExpiryTime: time.Date(2020, 7, 22, 10, 0, 0, 0, time.UTC),
- },
- Weights: DynamicWeights{
- {
- Weight: 2.4,
- },
- },
- Opts: map[string]interface{}{
- "Destination": 10,
- },
- Balances: map[string]*Balance{
- "VoiceBalance": {
- ID: "VoiceBalance",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Weights: DynamicWeights{
- {
- Weight: 1.1,
- },
- },
- Type: "*abstract",
- Opts: map[string]interface{}{
- "Destination": 10,
- },
- CostIncrements: []*CostIncrement{
- {
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Increment: &Decimal{decimal.New(1, 1)},
- FixedFee: &Decimal{decimal.New(75, 1)},
- RecurrentFee: &Decimal{decimal.New(20, 1)},
- },
- },
- AttributeIDs: []string{"attr1", "attr2"},
- UnitFactors: []*UnitFactor{
- {
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Factor: &Decimal{decimal.New(20, 2)},
- },
- },
- Units: &Decimal{decimal.New(125, 3)},
- },
- },
- ThresholdIDs: []string{"*none"},
- }
- if rcv := actPrf.Clone(); !reflect.DeepEqual(rcv, actPrf) {
- t.Errorf("Expected %+v, received %+v", ToJSON(actPrf), ToJSON(rcv))
- }
-
- actPrf.Opts = nil
- actPrf.ActivationInterval = nil
- if rcv := actPrf.Clone(); !reflect.DeepEqual(rcv, actPrf) {
- t.Errorf("Expected %+v \n, received %+v", ToJSON(actPrf), ToJSON(rcv))
- }
-}
-
-func TestTenantIDAccountProfile(t *testing.T) {
- actPrf := &AccountProfile{
- Tenant: "cgrates.org",
- ID: "test_ID1",
- }
- exp := "cgrates.org:test_ID1"
- if rcv := actPrf.TenantID(); rcv != exp {
- t.Errorf("Expected %+v, received %+v", exp, rcv)
- }
-}
-
-func TestAccountProfileAsAccountProfile(t *testing.T) {
- apiAccPrf := &APIAccountProfile{
- Tenant: "cgrates.org",
- ID: "test_ID1",
- Opts: map[string]interface{}{},
- Balances: map[string]*APIBalance{
- "VoiceBalance": {
- ID: "VoiceBalance",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Weights: ";1.2",
- Type: "*abstract",
- Opts: map[string]interface{}{
- "Destination": 10,
- },
- Units: 0,
- },
- },
- Weights: ";10",
- }
- expected := &AccountProfile{
- Tenant: "cgrates.org",
- ID: "test_ID1",
- Opts: map[string]interface{}{},
- Balances: map[string]*Balance{
- "VoiceBalance": {
- ID: "VoiceBalance",
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Weights: DynamicWeights{
- {
- Weight: 1.2,
- },
- },
- Type: "*abstract",
- Opts: map[string]interface{}{
- "Destination": 10,
- },
- Units: NewDecimal(0, 0),
- },
- },
- Weights: DynamicWeights{
- {
- Weight: 10,
- },
- },
- }
- if rcv, err := apiAccPrf.AsAccountProfile(); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expected %+v, received %+v", ToJSON(expected), ToJSON(rcv))
- }
-}
-
-func TestAsAccountProfileError(t *testing.T) {
- apiAccPrf := &APIAccountProfile{
- Tenant: "cgrates.org",
- ID: "test_ID1",
- Opts: map[string]interface{}{},
- Balances: map[string]*APIBalance{
- "MonetaryBalance": {
- Weights: ";10",
- },
- },
- Weights: "10",
- }
- expectedErr := "invalid DynamicWeight format for string <10>"
- if _, err := apiAccPrf.AsAccountProfile(); err == nil || err.Error() != expectedErr {
- t.Errorf("Expected %+v, received %+v", expectedErr, err)
- }
-
- apiAccPrf.Weights = ";10"
- apiAccPrf.Balances["MonetaryBalance"].Weights = "10"
- expectedErr = "invalid DynamicWeight format for string <10>"
- if _, err := apiAccPrf.AsAccountProfile(); err == nil || err.Error() != expectedErr {
- t.Errorf("Expected %+v, received %+v", expectedErr, err)
- }
-}
-
-func TestAPIBalanceAsBalance(t *testing.T) {
- blc := &APIBalance{
- ID: "VoiceBalance",
- CostIncrements: []*APICostIncrement{
- {
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Increment: Float64Pointer(1),
- FixedFee: Float64Pointer(10),
- RecurrentFee: Float64Pointer(35),
- },
- },
- Weights: ";10",
- UnitFactors: []*APIUnitFactor{
- {
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Factor: 20,
- },
- },
- }
- expected := &Balance{
- ID: "VoiceBalance",
- CostIncrements: []*CostIncrement{
- {
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Increment: NewDecimal(1, 0),
- FixedFee: NewDecimal(10, 0),
- RecurrentFee: NewDecimal(35, 0),
- },
- },
- Weights: DynamicWeights{
- {
- Weight: 10,
- },
- },
- UnitFactors: []*UnitFactor{
- {
- FilterIDs: []string{"*string:~*req.Account:1001"},
- Factor: NewDecimal(20, 0),
- },
- },
- Units: NewDecimal(0, 0),
- }
- if rcv, err := blc.AsBalance(); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcv, expected) {
- t.Errorf("Expected %+v \n, received %+v", ToJSON(expected), ToJSON(rcv))
- }
-
-}
-
-func TestAccountProfileBalancesAlteredCompareLength(t *testing.T) {
- actPrf := &AccountProfile{
- Balances: map[string]*Balance{
- "testString": {},
- "testString2": {},
- },
- }
-
- actBk := map[string]*decimal.Big{
- "testString": {},
- }
-
- result := actPrf.BalancesAltered(actBk)
- if result != true {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", true, result)
- }
-
-}
-
-func TestAccountProfileBalancesAlteredCheckKeys(t *testing.T) {
- actPrf := &AccountProfile{
- Balances: map[string]*Balance{
- "testString": {},
- },
- }
-
- actBk := map[string]*decimal.Big{
- "testString2": {},
- }
-
- result := actPrf.BalancesAltered(actBk)
- if result != true {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", true, result)
- }
-
-}
-
-func TestAccountProfileBalancesAlteredCompareValues(t *testing.T) {
- actPrf := &AccountProfile{
- Balances: map[string]*Balance{
- "testString": {
- Units: &Decimal{decimal.New(1, 1)},
- },
- },
- }
-
- actBk := map[string]*decimal.Big{
- "testString": {},
- }
-
- result := actPrf.BalancesAltered(actBk)
- if result != true {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", true, result)
- }
-
-}
-
-func TestAccountProfileBalancesAlteredFalse(t *testing.T) {
- actPrf := &AccountProfile{}
-
- actBk := AccountBalancesBackup{}
-
- result := actPrf.BalancesAltered(actBk)
- if result != false {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", false, result)
- }
-
-}
-
-func TestAPRestoreFromBackup(t *testing.T) {
- actPrf := &AccountProfile{
- Balances: map[string]*Balance{
- "testString": {
- Units: &Decimal{},
- },
- },
- }
-
- actBk := AccountBalancesBackup{
- "testString": decimal.New(1, 1),
- }
-
- actPrf.RestoreFromBackup(actBk)
- for key, value := range actBk {
- if actPrf.Balances[key].Units.Big != value {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", actPrf.Balances[key].Units.Big, value)
- }
- }
-}
-
-func TestAPAccountBalancesBackup(t *testing.T) {
- actPrf := &AccountProfile{
- Balances: map[string]*Balance{
- "testKey": {
- Units: &Decimal{decimal.New(1234, 3)},
- },
- },
- }
-
- actBk := actPrf.AccountBalancesBackup()
- for key, value := range actBk {
- if actPrf.Balances[key].Units.Big.Cmp(value) != 0 {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", actPrf.Balances[key].Units.Big, value)
- }
- }
-}
-
-func TestAPNewDefaultBalance(t *testing.T) {
-
- const torFltr = "*string:~*req.ToR:"
- id := "testID"
-
- expected := &Balance{
- ID: id,
- Type: MetaConcrete,
- Units: NewDecimal(0, 0),
- CostIncrements: []*CostIncrement{
- {
- FilterIDs: []string{torFltr + MetaVoice},
- Increment: NewDecimal(int64(time.Second), 0),
- RecurrentFee: NewDecimal(0, 0),
- },
- {
- FilterIDs: []string{torFltr + MetaData},
- Increment: NewDecimal(1024*1024, 0),
- RecurrentFee: NewDecimal(0, 0),
- },
- {
- FilterIDs: []string{torFltr + MetaSMS},
- Increment: NewDecimal(1, 0),
- RecurrentFee: NewDecimal(0, 0),
- },
- },
- }
-
- received := NewDefaultBalance(id)
-
- if !reflect.DeepEqual(received, expected) {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", expected, received)
- }
-}
-
-func TestAPApsSort(t *testing.T) {
-
- apS := AccountProfilesWithWeight{
- {
- Weight: 2,
- },
- {
- Weight: 1,
- },
- {
- Weight: 3,
- },
- }
- expected := AccountProfilesWithWeight{
- {
- Weight: 3,
- },
- {
- Weight: 2,
- },
- {
- Weight: 1,
- },
- }
-
- apS.Sort()
- if !reflect.DeepEqual(apS, expected) {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", ToJSON(expected), ToJSON(apS))
- }
-}
-
-func TestAPAccountProfiles(t *testing.T) {
-
- apS := AccountProfilesWithWeight{
- {
- AccountProfile: &AccountProfile{
- Tenant: "testTenant1",
- ID: "testID1",
- FilterIDs: []string{"testFID1", "testFID2"},
- ActivationInterval: &ActivationInterval{
- ActivationTime: time.Date(2020, time.April, 12, 0, 0, 0, 0, time.UTC),
- ExpiryTime: time.Date(2020, time.April, 12, 10, 0, 0, 0, time.UTC),
- },
- Weights: nil,
- Balances: map[string]*Balance{
- "testBalance1": {
- ID: "testBalance1",
- Type: MetaAbstract,
- Units: &Decimal{decimal.New(0, 0)},
- },
- },
- },
- Weight: 23,
- LockID: "testString1",
- },
- {
- AccountProfile: &AccountProfile{
- Tenant: "testTenant2",
- ID: "testID2",
- FilterIDs: []string{"testFID1", "testFID2"},
- ActivationInterval: &ActivationInterval{
- ActivationTime: time.Date(2020, time.April, 12, 0, 0, 0, 0, time.UTC),
- ExpiryTime: time.Date(2020, time.April, 12, 10, 0, 0, 0, time.UTC),
- },
- Weights: nil,
- Balances: map[string]*Balance{
- "testBalance2": {
- ID: "testBalance2",
- Type: MetaAbstract,
- Units: &Decimal{decimal.New(0, 0)},
- },
- },
- },
- Weight: 15,
- LockID: "testString2",
- },
- }
-
- expected := make([]*AccountProfile, 0)
- for i := range apS {
- expected = append(expected, apS[i].AccountProfile)
- }
- received := apS.AccountProfiles()
-
- if !reflect.DeepEqual(received, expected) {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", ToJSON(expected), ToJSON(received))
- }
-}
-
-func TestAPLockIDs(t *testing.T) {
- apS := AccountProfilesWithWeight{
- {
- AccountProfile: &AccountProfile{
- Tenant: "testTenant1",
- ID: "testID1",
- FilterIDs: []string{"testFID1", "testFID2"},
- ActivationInterval: &ActivationInterval{
- ActivationTime: time.Date(2020, time.April, 12, 0, 0, 0, 0, time.UTC),
- ExpiryTime: time.Date(2020, time.April, 12, 10, 0, 0, 0, time.UTC),
- },
- Weights: nil,
- Balances: map[string]*Balance{
- "testBalance1": {
- ID: "testBalance1",
- Type: MetaAbstract,
- Units: &Decimal{decimal.New(0, 0)},
- },
- },
- },
- Weight: 23,
- LockID: "testString1",
- },
- {
- AccountProfile: &AccountProfile{
- Tenant: "testTenant2",
- ID: "testID2",
- FilterIDs: []string{"testFID1", "testFID2"},
- ActivationInterval: &ActivationInterval{
- ActivationTime: time.Date(2020, time.April, 12, 0, 0, 0, 0, time.UTC),
- ExpiryTime: time.Date(2020, time.April, 12, 10, 0, 0, 0, time.UTC),
- },
- Weights: nil,
- Balances: map[string]*Balance{
- "testBalance2": {
- ID: "testBalance2",
- Type: MetaAbstract,
- Units: &Decimal{decimal.New(0, 0)},
- },
- },
- },
- Weight: 15,
- LockID: "testString2",
- },
- }
-
- expected := make([]string, 0)
- for i := range apS {
- expected = append(expected, apS[i].LockID)
- }
- received := apS.LockIDs()
-
- if !reflect.DeepEqual(received, expected) {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", expected, received)
- }
-}
-
-func TestAPTenantIDs(t *testing.T) {
- apS := AccountProfilesWithWeight{
- {
- AccountProfile: &AccountProfile{
- Tenant: "testTenant1",
- ID: "testID1",
- FilterIDs: []string{"testFID1", "testFID2"},
- ActivationInterval: &ActivationInterval{
- ActivationTime: time.Date(2020, time.April, 12, 0, 0, 0, 0, time.UTC),
- ExpiryTime: time.Date(2020, time.April, 12, 10, 0, 0, 0, time.UTC),
- },
- Weights: nil,
- Balances: map[string]*Balance{
- "testBalance1": {
- ID: "testBalance1",
- Type: MetaAbstract,
- Units: &Decimal{decimal.New(0, 0)},
- },
- },
- },
- Weight: 23,
- LockID: "testString1",
- },
- {
- AccountProfile: &AccountProfile{
- Tenant: "testTenant2",
- ID: "testID2",
- FilterIDs: []string{"testFID1", "testFID2"},
- ActivationInterval: &ActivationInterval{
- ActivationTime: time.Date(2020, time.April, 12, 0, 0, 0, 0, time.UTC),
- ExpiryTime: time.Date(2020, time.April, 12, 10, 0, 0, 0, time.UTC),
- },
- Weights: nil,
- Balances: map[string]*Balance{
- "testBalance2": {
- ID: "testBalance2",
- Type: MetaAbstract,
- Units: &Decimal{decimal.New(0, 0)},
- },
- },
- },
- Weight: 15,
- LockID: "testString2",
- },
- }
-
- expected := make([]string, 0)
- for _, val := range apS {
- id := val.AccountProfile.Tenant
- tenant := val.AccountProfile.ID
- expected = append(expected, ConcatenatedKey(id, tenant))
- }
- received := apS.TenantIDs()
-
- if !reflect.DeepEqual(received, expected) {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", expected, received)
- }
-}
-
-func TestAPBlcsSort(t *testing.T) {
-
- blncS := BalancesWithWeight{
- {
- Weight: 2,
- },
- {
- Weight: 1,
- },
- {
- Weight: 3,
- },
- }
- expected := BalancesWithWeight{
- {
- Weight: 3,
- },
- {
- Weight: 2,
- },
- {
- Weight: 1,
- },
- }
-
- blncS.Sort()
- if !reflect.DeepEqual(blncS, expected) {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", ToJSON(expected), ToJSON(blncS))
- }
-}
-
-func TestAPBalances(t *testing.T) {
- blncS := BalancesWithWeight{
- {
- Balance: &Balance{
- ID: "testID1",
- FilterIDs: []string{"testFID1", "testFID2"},
- Type: MetaAbstract,
- Units: &Decimal{decimal.New(1234, 3)},
- Weights: nil,
- UnitFactors: []*UnitFactor{
- {
- Factor: NewDecimal(1, 1),
- },
- },
- Opts: map[string]interface{}{
- MetaBalanceLimit: -1.0,
- },
- CostIncrements: []*CostIncrement{
- {
- Increment: NewDecimal(int64(time.Duration(time.Second)), 0),
- RecurrentFee: NewDecimal(0, 0),
- },
- },
- AttributeIDs: []string{"testString1"},
- },
- Weight: 23,
- },
- {
- Balance: &Balance{
- ID: "testID2",
- FilterIDs: []string{"testFID3", "testFID4"},
- Type: MetaAbstract,
- Units: &Decimal{decimal.New(1234, 3)},
- Weights: nil,
- UnitFactors: []*UnitFactor{
- {
- Factor: NewDecimal(1, 1),
- },
- },
- Opts: map[string]interface{}{
- MetaBalanceLimit: -1.0,
- },
- CostIncrements: []*CostIncrement{
- {
- Increment: NewDecimal(int64(time.Duration(time.Second)), 0),
- RecurrentFee: NewDecimal(0, 0),
- },
- },
- AttributeIDs: []string{"testString3"},
- },
- Weight: 23,
- },
- }
-
- expected := make([]*Balance, 0)
- for i := range blncS {
- expected = append(expected, blncS[i].Balance)
- }
- received := blncS.Balances()
-
- if !reflect.DeepEqual(received, expected) {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", ToJSON(expected), ToJSON(received))
- }
-}
-
-func TestEqualsUnitFactor(t *testing.T) {
- uf1 := &UnitFactor{
- FilterIDs: []string{"*string:~*req.Account:1003"},
- Factor: NewDecimal(10, 0),
- }
- uf2 := &UnitFactor{
- FilterIDs: []string{"*string:~*req.Account:1003"},
- Factor: NewDecimal(10, 0),
- }
- if !uf1.Equals(uf2) {
- t.Errorf("Unexpected equal result")
- }
-
- uf1.FilterIDs = []string{"*string:~*req.Account:1004"}
- if uf1.Equals(uf2) {
- t.Errorf("Unexpected equal result")
- }
- uf1.FilterIDs = nil
-
- if uf1.Equals(uf2) {
- t.Errorf("Unexpected equal result")
- }
- uf1.FilterIDs = []string{"*string:~*req.Account:1003"}
-
- uf1.Factor = NewDecimal(100, 0)
- if uf1.Equals(uf2) {
- t.Errorf("Unexpected equal result")
- }
-
- uf1.Factor = nil
- uf2.Factor = nil
- if !uf1.Equals(uf2) {
- t.Errorf("Unexpected equal result")
- }
-
- uf2.Factor = NewDecimal(10, 0)
- if uf1.Equals(uf2) {
- t.Errorf("Unexpected equal result")
- }
-}
diff --git a/utils/apitpdata.go b/utils/apitpdata.go
index f32ede6dc..95c9b8dd8 100644
--- a/utils/apitpdata.go
+++ b/utils/apitpdata.go
@@ -1321,7 +1321,6 @@ func NewAttrReloadCacheWithOpts() *AttrReloadCacheWithAPIOpts {
RouteFilterIndexIDs: nil,
ChargerFilterIndexIDs: nil,
DispatcherFilterIndexIDs: nil,
- RateFilterIndexIDs: nil,
FilterIndexIDs: nil,
},
}
diff --git a/utils/apitpdata_test.go b/utils/apitpdata_test.go
index 9ceaf2f6b..7de34e44d 100644
--- a/utils/apitpdata_test.go
+++ b/utils/apitpdata_test.go
@@ -22,8 +22,6 @@ import (
"strings"
"testing"
"time"
-
- "github.com/ericlagergren/decimal"
)
func TestTPDistinctIdsString(t *testing.T) {
@@ -1045,7 +1043,6 @@ func TestNewAttrReloadCacheWithOpts(t *testing.T) {
RouteFilterIndexIDs: nil,
ChargerFilterIndexIDs: nil,
DispatcherFilterIndexIDs: nil,
- RateFilterIndexIDs: nil,
FilterIndexIDs: nil,
},
}
@@ -1054,125 +1051,3 @@ func TestNewAttrReloadCacheWithOpts(t *testing.T) {
t.Errorf("Expected %+v \n, received %+v", eMap, newAttrReloadCache)
}
}
-
-func TestStartTimeNow(t *testing.T) {
- testCostEventStruct := &ArgsCostForEvent{
- RateProfileIDs: []string{"123", "456", "789"},
- CGREvent: &CGREvent{
- Tenant: "*req.CGRID",
- ID: "",
- Event: map[string]interface{}{},
- APIOpts: map[string]interface{}{},
- },
- }
- timpulet1 := time.Now()
- result, err := testCostEventStruct.StartTime("")
- timpulet2 := time.Now()
- if err != nil {
- t.Errorf("Expected , received <%+v>", err)
- }
- if result.Before(timpulet1) && result.After(timpulet2) {
- t.Errorf("Expected between <%+v> and <%+v>, received <%+v>", timpulet1, timpulet2, result)
- }
-}
-
-func TestStartTime(t *testing.T) {
- testCostEventStruct := &ArgsCostForEvent{
- RateProfileIDs: []string{"123", "456", "789"},
- CGREvent: &CGREvent{
- Tenant: "*req.CGRID",
- ID: "",
- Event: map[string]interface{}{},
- APIOpts: map[string]interface{}{"*ratesStartTime": "2018-01-07T17:00:10Z"},
- },
- }
- if result, err := testCostEventStruct.StartTime(""); err != nil {
- t.Errorf("Expected , received <%+v>", err)
- } else if !reflect.DeepEqual(result.String(), "2018-01-07 17:00:10 +0000 UTC") {
- t.Errorf("Expected <2018-01-07 17:00:10 +0000 UTC> , received <%+v>", result)
- }
-}
-
-func TestStartTimeError(t *testing.T) {
- testCostEventStruct := &ArgsCostForEvent{
- RateProfileIDs: []string{"123", "456", "789"},
- CGREvent: &CGREvent{
- Tenant: "*req.CGRID",
- ID: "",
- Event: map[string]interface{}{},
- APIOpts: map[string]interface{}{"*ratesStartTime": "start"},
- },
- }
- _, err := testCostEventStruct.StartTime("")
- if err == nil && err.Error() != "received , received <%+v>", err)
- }
-}
-
-func TestUsageMinute(t *testing.T) {
- testCostEventStruct := &ArgsCostForEvent{
- RateProfileIDs: []string{"123", "456", "789"},
- CGREvent: &CGREvent{
- Tenant: "*req.CGRID",
- ID: "",
- Event: map[string]interface{}{},
- APIOpts: map[string]interface{}{},
- },
- }
- if rcv, err := testCostEventStruct.Usage(); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(decimal.New(int64(time.Minute), 0), rcv) {
- t.Errorf("Expected %+v, received %+v", decimal.New(int64(time.Minute), 0), rcv)
- }
-}
-
-func TestUsageError(t *testing.T) {
- testCostEventStruct := &ArgsCostForEvent{
- RateProfileIDs: []string{"123", "456", "789"},
- CGREvent: &CGREvent{
- Tenant: "*req.CGRID",
- ID: "",
- Event: map[string]interface{}{},
- APIOpts: map[string]interface{}{"*ratesUsage": "start"},
- },
- }
- _, err := testCostEventStruct.Usage()
- if err == nil && err.Error() != "received , received <%+v>", err)
- }
-}
-
-func TestUsage(t *testing.T) {
- testCostEventStruct := &ArgsCostForEvent{
- RateProfileIDs: []string{"123", "456", "789"},
- CGREvent: &CGREvent{
- Tenant: "*req.CGRID",
- ID: "",
- Event: map[string]interface{}{},
- APIOpts: map[string]interface{}{"*ratesUsage": "2m10s"},
- },
- }
-
- if result, err := testCostEventStruct.Usage(); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(result.String(), "130000000000") {
- t.Errorf("Expected <130000000000> , received <%+v>", result.String())
- }
-}
-
-func TestATDUsage(t *testing.T) {
- args := &ArgsCostForEvent{
- CGREvent: &CGREvent{
- ID: "testID",
- Event: map[string]interface{}{
- Usage: true,
- },
- },
- }
-
- _, err := args.Usage()
- expected := "cannot convert field: true to time.Duration"
- if err == nil || err.Error() != expected {
- t.Errorf("\nExpected: <%+v>, \nReceived: <%+v>", expected, err.Error())
- }
-}
diff --git a/utils/consts.go b/utils/consts.go
index 673276699..8b8eb24d6 100644
--- a/utils/consts.go
+++ b/utils/consts.go
@@ -486,7 +486,6 @@ const (
MetaUCH = "*uch"
MetaGuardian = "*guardians"
MetaEEs = "*ees"
- MetaRateS = "*rates"
MetaContinue = "*continue"
MetaUp = "*up"
Migrator = "migrator"
@@ -871,7 +870,6 @@ const (
MetaYearly = "*yearly"
MetaDaily = "*daily"
MetaWeekly = "*weekly"
- RateS = "RateS"
Underline = "_"
MetaPartial = "*partial"
MetaBusy = "*busy"
@@ -1020,8 +1018,6 @@ const (
ReplicatorLow = "replicator"
ApierSLow = "apiers"
EEsLow = "ees"
- RateSLow = "rates"
- AccountSLow = "accounts"
)
// Actions
@@ -1504,23 +1500,6 @@ const (
RALsV1Ping = "RALsV1.Ping"
)
-const (
- RateSv1 = "RateSv1"
- RateSv1CostForEvent = "RateSv1.CostForEvent"
- RateSv1Ping = "RateSv1.Ping"
-)
-
-const (
- AccountSv1 = "AccountSv1"
- AccountSv1Ping = "AccountSv1.Ping"
- AccountSv1MaxAbstracts = "AccountSv1.MaxAbstracts"
- AccountSv1DebitAbstracts = "AccountSv1.DebitAbstracts"
- AccountSv1MaxConcretes = "AccountSv1.MaxConcretes"
- AccountSv1DebitConcretes = "AccountSv1.DebitConcretes"
- AccountSv1ActionSetBalance = "AccountSv1.ActionSetBalance"
- AccountSv1ActionRemoveBalance = "AccountSv1.ActionRemoveBalance"
-)
-
const (
CoreS = "CoreS"
CoreSv1 = "CoreSv1"