diff --git a/apier/v1/accountsv1_it_test.go b/apier/v1/accountsv1_it_test.go
deleted file mode 100644
index d0b09bf94..000000000
--- a/apier/v1/accountsv1_it_test.go
+++ /dev/null
@@ -1,1422 +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)
- }
-
- //set a rate profile to be used in case of debit
- apiRPrf := &utils.APIRateProfile{
- Tenant: "cgrates.org",
- ID: "RP_Test",
- Weights: ";10",
- Rates: map[string]*utils.APIRate{
- "RT_ALWAYS": {
- ID: "RT_ALWAYS",
- Weights: ";0",
- ActivationTimes: "* * * * *",
- IntervalRates: []*utils.APIIntervalRate{
- {
- IntervalStart: "0",
- RecurrentFee: utils.Float64Pointer(0.1),
- Increment: utils.Float64Pointer(1),
- Unit: utils.Float64Pointer(1),
- },
- },
- },
- },
- }
-
- if err := acntSRPC.Call(utils.APIerSv1SetRateProfile,
- &utils.APIRateProfileWithAPIOpts{
- APIRateProfile: apiRPrf,
- }, &reply); err != nil {
- t.Fatal(err)
- } else if reply != utils.OK {
- t.Errorf("Expecting: %+v, received: %+v", utils.OK, reply)
- }
-
- 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)
- }
-
- //set a rate profile to be used in case of debit
- apiRPrf := &utils.APIRateProfile{
- Tenant: "cgrates.org",
- ID: "RP_Test2",
- FilterIDs: []string{"*string:~*req.Account:ACC_WITH_RATES"},
- Weights: ";20",
- Rates: map[string]*utils.APIRate{
- "RT_ALWAYS": {
- ID: "RT_ALWAYS",
- Weights: ";0",
- ActivationTimes: "* * * * *",
- IntervalRates: []*utils.APIIntervalRate{
- {
- IntervalStart: "0",
- RecurrentFee: utils.Float64Pointer(0.5),
- Increment: utils.Float64Pointer(2),
- Unit: utils.Float64Pointer(2),
- },
- },
- },
- },
- }
-
- if err := acntSRPC.Call(utils.APIerSv1SetRateProfile,
- &utils.APIRateProfileWithAPIOpts{
- APIRateProfile: apiRPrf,
- }, &reply); err != nil {
- t.Fatal(err)
- } else if reply != utils.OK {
- t.Errorf("Expecting: %+v, received: %+v", utils.OK, reply)
- }
-
- 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),
- },
- },
- RateProfileIDs: []string{"RP_Test22"},
- },
- "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)
- }
-
- //set a rate profile to be used in case of debit
- apiRPrf := &utils.APIRateProfile{
- Tenant: "cgrates.org",
- ID: "RP_Test22",
- FilterIDs: []string{"*string:~*req.Account:ACC_WITH_RATES2"},
- Weights: ";20",
- Rates: map[string]*utils.APIRate{
- "RT_ALWAYS": {
- ID: "RT_ALWAYS",
- Weights: ";0",
- ActivationTimes: "* * * * *",
- IntervalRates: []*utils.APIIntervalRate{
- {
- IntervalStart: "0",
- RecurrentFee: utils.Float64Pointer(0.5),
- Increment: utils.Float64Pointer(2),
- Unit: utils.Float64Pointer(2),
- },
- },
- },
- },
- }
-
- if err := acntSRPC.Call(utils.APIerSv1SetRateProfile,
- &utils.APIRateProfileWithAPIOpts{
- APIRateProfile: apiRPrf,
- }, &reply); err != nil {
- t.Fatal(err)
- } else if reply != utils.OK {
- t.Errorf("Expecting: %+v, received: %+v", utils.OK, reply)
- }
-
- 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/filter_indexes_it_test.go b/apier/v1/filter_indexes_it_test.go
index 04218467d..864683832 100644
--- a/apier/v1/filter_indexes_it_test.go
+++ b/apier/v1/filter_indexes_it_test.go
@@ -72,13 +72,6 @@ var (
testV1FIdxSecondComputeRouteProfileIndexes,
testV1FIdxRemoveRouteProfile,
- testV1FIdxdxInitDataDb,
- testV1FISetAccountProfileIndexes,
- testV1FIComputeAccountProfileIndexes,
- testV1FISetSecondFilterForAccountProfile,
- testV1FIComputeIDsAccountProfileIndexes,
- testV1FIRemoveAccountProfile,
-
testV1FIdxdxInitDataDb,
testV1FISetActionProfileIndexes,
testV1FIComputeActionProfileIndexes,
@@ -1167,275 +1160,6 @@ func testV1FIdxRemoveRouteProfile(t *testing.T) {
}
}
-//AccountProfile
-func testV1FISetAccountProfileIndexes(t *testing.T) {
- var reply *utils.AccountProfile
- filter = &engine.FilterWithAPIOpts{
- Filter: &engine.Filter{
- Tenant: tenant,
- ID: "ACCPRF_FLTR",
- Rules: []*engine.FilterRule{
- {
- Type: utils.MetaString,
- Element: "~*req.Account",
- Values: []string{"1001", "1002"},
- },
- },
- },
- }
- var result string
- if err := tFIdxRpc.Call(utils.APIerSv1SetFilter, filter, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-
- //there is not an accPrf in database, so we will get NOT_FOUND
- if err := tFIdxRpc.Call(utils.APIerSv1GetAccountProfile,
- &utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: tenant, ID: "ACC_PRF"}},
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-
- //set in db an accPrf then we will get it without errors
- accPrf := &utils.APIAccountProfileWithOpts{
- APIAccountProfile: &utils.APIAccountProfile{
- Tenant: tenant,
- ID: "ACC_PRF",
- FilterIDs: []string{"*prefix:~*req.Destination:123", "ACCPRF_FLTR"},
- Balances: map[string]*utils.APIBalance{
- "ConcreteBalance": {
- ID: "ConcreteBalance",
- Type: utils.MetaConcrete,
- Units: 200,
- },
- },
- },
- }
- if err := tFIdxRpc.Call(utils.APIerSv1SetAccountProfile, accPrf, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Errorf("Unexpected reply returned")
- }
- newAccPrf, err := accPrf.AsAccountProfile()
- if err != nil {
- t.Error(err)
- }
- if err := tFIdxRpc.Call(utils.APIerSv1GetAccountProfile,
- &utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: tenant, ID: "ACC_PRF"}},
- &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(reply, newAccPrf) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(newAccPrf), utils.ToJSON(reply))
- }
-
- var indexes []string
- expectedIDx := []string{"*string:*req.Account:1001:ACC_PRF", "*string:*req.Account:1002:ACC_PRF", "*prefix:*req.Destination:123:ACC_PRF"}
- //trying to get indexes,
- if err := tFIdxRpc.Call(utils.APIerSv1GetFilterIndexes,
- &AttrGetFilterIndexes{ItemType: utils.MetaAccountProfiles, Tenant: tenant},
- &indexes); err != nil {
- t.Error(err)
- } else {
- sort.Strings(expectedIDx)
- sort.Strings(indexes)
- if !reflect.DeepEqual(indexes, expectedIDx) {
- t.Errorf("Expected %+v, received %+v", expectedIDx, indexes)
- }
- }
-}
-
-func testV1FIComputeAccountProfileIndexes(t *testing.T) {
- //remove indexes from db
- var result string
- if err := tFIdxRpc.Call(utils.APIerSv1RemoveFilterIndexes,
- &AttrRemFilterIndexes{ItemType: utils.MetaAccountProfiles, Tenant: tenant},
- &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-
- var indexes []string
- //nothing to get from db, as we removed them
- if err := tFIdxRpc.Call(utils.APIerSv1GetFilterIndexes,
- &AttrGetFilterIndexes{ItemType: utils.MetaAccountProfiles, Tenant: tenant},
- &indexes); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-
- //compute them, to put indexes again in db for the right subsystem
- if err := tFIdxRpc.Call(utils.APIerSv1ComputeFilterIndexes,
- &utils.ArgsComputeFilterIndexes{
- Tenant: tenant,
- AccountS: true,
- }, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-
- expectedIDx := []string{"*string:*req.Account:1001:ACC_PRF", "*string:*req.Account:1002:ACC_PRF", "*prefix:*req.Destination:123:ACC_PRF"}
- //as we compute them, next we will try to get them again from db
- if err := tFIdxRpc.Call(utils.APIerSv1GetFilterIndexes,
- &AttrGetFilterIndexes{ItemType: utils.MetaAccountProfiles, Tenant: tenant},
- &indexes); err != nil {
- t.Error(err)
- } else {
- sort.Strings(expectedIDx)
- sort.Strings(indexes)
- if !reflect.DeepEqual(indexes, expectedIDx) {
- t.Errorf("Expected %+v, received %+v", expectedIDx, indexes)
- }
- }
-}
-
-func testV1FISetSecondFilterForAccountProfile(t *testing.T) {
- //new filter
- filter = &engine.FilterWithAPIOpts{
- Filter: &engine.Filter{
- Tenant: tenant,
- ID: "ACCPRF_FLTR2",
- Rules: []*engine.FilterRule{
- {
- Type: utils.MetaString,
- Element: "~*req.CGRID",
- Values: []string{"Dan1"},
- },
- },
- },
- }
- var result string
- if err := tFIdxRpc.Call(utils.APIerSv1SetFilter, filter, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-
- //we will overwrite this AccPrf with our new filter
- accPrf := &utils.APIAccountProfileWithOpts{
- APIAccountProfile: &utils.APIAccountProfile{
- Tenant: tenant,
- ID: "ACC_PRF",
- FilterIDs: []string{"*prefix:~*req.Destination:123", "ACCPRF_FLTR", "ACCPRF_FLTR2"},
- Balances: map[string]*utils.APIBalance{
- "ConcreteBalance": {
- ID: "ConcreteBalance",
- Type: utils.MetaConcrete,
- Units: 200,
- },
- },
- },
- }
- if err := tFIdxRpc.Call(utils.APIerSv1SetAccountProfile, accPrf, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Errorf("Unexpected reply returned")
- }
- newAccPrf, err := accPrf.AsAccountProfile()
- if err != nil {
- t.Error(err)
- }
- var reply *utils.AccountProfile
- if err := tFIdxRpc.Call(utils.APIerSv1GetAccountProfile,
- &utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: tenant, ID: "ACC_PRF"}},
- &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(reply, newAccPrf) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(newAccPrf), utils.ToJSON(reply))
- }
-
- var indexes []string
- expectedIDx := []string{"*string:*req.Account:1001:ACC_PRF", "*string:*req.Account:1002:ACC_PRF",
- "*prefix:*req.Destination:123:ACC_PRF", "*string:*req.CGRID:Dan1:ACC_PRF"}
- //trying to get indexes, should be indexes for both filters:"ACCPRF_FLTR" and "ACCPRF_FLTR2"
- if err := tFIdxRpc.Call(utils.APIerSv1GetFilterIndexes,
- &AttrGetFilterIndexes{ItemType: utils.MetaAccountProfiles, Tenant: tenant},
- &indexes); err != nil {
- t.Error(err)
- } else {
- sort.Strings(expectedIDx)
- sort.Strings(indexes)
- if !reflect.DeepEqual(indexes, expectedIDx) {
- t.Errorf("Expected %+v, received %+v", expectedIDx, indexes)
- }
- }
-}
-
-func testV1FIComputeIDsAccountProfileIndexes(t *testing.T) {
- //remove indexes from db
- var result string
- if err := tFIdxRpc.Call(utils.APIerSv1RemoveFilterIndexes,
- &AttrRemFilterIndexes{ItemType: utils.MetaAccountProfiles, Tenant: tenant},
- &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-
- var indexes []string
- //nothing to get from db, as we removed them,
- if err := tFIdxRpc.Call(utils.APIerSv1GetFilterIndexes,
- &AttrGetFilterIndexes{ItemType: utils.MetaAccountProfiles, Tenant: tenant},
- &indexes); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-
- //compute them, to put indexes again in db for the right subsystem
- if err := tFIdxRpc.Call(utils.APIerSv1ComputeFilterIndexIDs,
- &utils.ArgsComputeFilterIndexIDs{
- Tenant: tenant,
- AccountProfileIDs: []string{"ACC_PRF"},
- }, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-
- expectedIDx := []string{"*string:*req.Account:1001:ACC_PRF", "*string:*req.Account:1002:ACC_PRF",
- "*prefix:*req.Destination:123:ACC_PRF", "*string:*req.CGRID:Dan1:ACC_PRF"}
- //as we compute them, next we will try to get them again from db
- if err := tFIdxRpc.Call(utils.APIerSv1GetFilterIndexes,
- &AttrGetFilterIndexes{ItemType: utils.MetaAccountProfiles, Tenant: tenant},
- &indexes); err != nil {
- t.Error(err)
- } else {
- sort.Strings(expectedIDx)
- sort.Strings(indexes)
- if !reflect.DeepEqual(indexes, expectedIDx) {
- t.Errorf("Expected %+v, received %+v", expectedIDx, indexes)
- }
- }
-}
-
-func testV1FIRemoveAccountProfile(t *testing.T) {
- //removing accPrf from db will delete the indexes from dB
- var result string
- if err := tFIdxRpc.Call(utils.APIerSv1RemoveAccountProfile,
- &utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: tenant, ID: "ACC_PRF"}},
- &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected result returned", result)
- }
-
- var reply *utils.AccountProfile
- //there is not an accPrf in database, so we will get NOT_FOUND
- if err := tFIdxRpc.Call(utils.APIerSv1GetAccountProfile,
- &utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: tenant, ID: "ACC_PRF"}},
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-
- var indexes []string
- //there are no indexes in db, as we removed actprf from db
- if err := tFIdxRpc.Call(utils.APIerSv1GetFilterIndexes,
- &AttrGetFilterIndexes{ItemType: utils.MetaAccountProfiles, Tenant: tenant},
- &indexes); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-}
-
//ActionProfile
func testV1FISetActionProfileIndexes(t *testing.T) {
//set a new filter in db
diff --git a/apier/v1/full_remote_it_test.go b/apier/v1/full_remote_it_test.go
index a61f5c688..77b82649f 100644
--- a/apier/v1/full_remote_it_test.go
+++ b/apier/v1/full_remote_it_test.go
@@ -58,7 +58,6 @@ var (
testFullRemoteITDispatcher,
testFullRemoteITRate,
testFullRemoteITAction,
- testFullRemoteITAccount,
testFullRemoteITKillEngine,
}
)
@@ -721,107 +720,6 @@ func testFullRemoteITAction(t *testing.T) {
}
}
-func testFullRemoteITAccount(t *testing.T) {
- // verify for not found in internal
- var reply *utils.AccountProfile
- if err := fullRemInternalRPC.Call(utils.APIerSv1GetAccountProfile,
- utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1001"}},
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Fatal(err)
- }
-
- apiAccPrf := &utils.APIAccountProfileWithOpts{
- APIAccountProfile: &utils.APIAccountProfile{
- Tenant: "cgrates.org",
- ID: "1001",
- Weights: ";20",
- Opts: map[string]interface{}{
- "TEST0": 2.,
- },
- Balances: map[string]*utils.APIBalance{
- "MonetaryBalance": {
- ID: "MonetaryBalance",
- Weights: ";10",
- Type: utils.MetaMonetary,
- Opts: map[string]interface{}{
- "TEST1": 5.,
- },
- CostIncrements: []*utils.APICostIncrement{
- {
- FilterIDs: []string{"fltr1", "fltr2"},
- Increment: utils.Float64Pointer(1.3),
- FixedFee: utils.Float64Pointer(2.3),
- RecurrentFee: utils.Float64Pointer(3.3),
- },
- },
- AttributeIDs: []string{"attr1", "attr2"},
- UnitFactors: []*utils.APIUnitFactor{
- {
- FilterIDs: []string{"fltr1", "fltr2"},
- Factor: 100,
- },
- {
- FilterIDs: []string{"fltr3"},
- Factor: 200,
- },
- },
- Units: 14,
- },
- "VoiceBalance": {
- ID: "VoiceBalance",
- Weights: ";10",
- Type: utils.MetaVoice,
- Opts: map[string]interface{}{},
- Units: 3600000000000,
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- },
- }
- var replySet string
-
- // add a threshold profile in engine1 and verify it internal
- if err := fullRemEngineOneRPC.Call(utils.APIerSv1SetAccountProfile, apiAccPrf, &replySet); err != nil {
- t.Error(err)
- } else if replySet != utils.OK {
- t.Error("Unexpected reply returned", replySet)
- }
-
- accPrf, err := apiAccPrf.AsAccountProfile()
- if err != nil {
- t.Error(err)
- }
-
- if err := fullRemInternalRPC.Call(utils.APIerSv1GetAccountProfile,
- utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1001"}},
- &reply); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(accPrf, reply) {
- t.Errorf("Expecting : %+v \n, received: %+v", utils.ToJSON(accPrf), utils.ToJSON(reply))
- }
-
- // update the threshold profile and verify it to be updated
- apiAccPrf.FilterIDs = []string{"*string:~*req.Account:1001", "*string:~*req.Destination:1002"}
- if err := fullRemEngineOneRPC.Call(utils.APIerSv1SetAccountProfile, apiAccPrf, &replySet); err != nil {
- t.Error(err)
- } else if replySet != utils.OK {
- t.Error("Unexpected reply returned", replySet)
- }
-
- accPrf, err = apiAccPrf.AsAccountProfile()
- if err != nil {
- t.Error(err)
- }
-
- if err := fullRemInternalRPC.Call(utils.APIerSv1GetAccountProfile,
- utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1001"}},
- &reply); err != nil {
- t.Fatal(err)
- } else if !reflect.DeepEqual(accPrf, reply) {
- t.Errorf("Expecting : %+v \n, received: %+v", utils.ToJSON(accPrf), utils.ToJSON(reply))
- }
-}
-
func testFullRemoteITKillEngine(t *testing.T) {
if err := engine.KillEngine(100); err != nil {
t.Error(err)
diff --git a/apier/v1/precache_it_test.go b/apier/v1/precache_it_test.go
index 41529f8dc..bb57f2bff 100644
--- a/apier/v1/precache_it_test.go
+++ b/apier/v1/precache_it_test.go
@@ -214,50 +214,47 @@ func testPrecacheGetCacheStatsAfterRestart(t *testing.T) {
Items: 10,
Groups: 1,
},
- utils.CacheThresholdProfiles: {Items: 7},
- utils.CacheThresholds: {Items: 7},
- utils.CacheTimings: {},
- utils.CacheDiameterMessages: {},
- utils.CacheClosedSessions: {},
- utils.CacheLoadIDs: {},
- utils.CacheRPCConnections: {},
- utils.CacheCDRIDs: {},
- utils.CacheRatingProfilesTmp: {},
- utils.CacheUCH: {},
- utils.CacheReverseFilterIndexes: {},
- utils.CacheAccounts: {},
- utils.CacheVersions: {},
- utils.CacheTBLTPTimings: {},
- utils.CacheTBLTPDestinations: {},
- utils.CacheTBLTPRates: {},
- utils.CacheTBLTPDestinationRates: {},
- utils.CacheTBLTPRatingPlans: {},
- utils.CacheTBLTPRatingProfiles: {},
- utils.CacheTBLTPSharedGroups: {},
- utils.CacheTBLTPActions: {},
- utils.CacheTBLTPActionPlans: {},
- utils.CacheTBLTPActionTriggers: {},
- utils.CacheTBLTPAccountActions: {},
- utils.CacheTBLTPResources: {},
- utils.CacheTBLTPStats: {},
- utils.CacheTBLTPThresholds: {},
- utils.CacheTBLTPFilters: {},
- utils.CacheSessionCostsTBL: {},
- utils.CacheCDRsTBL: {},
- utils.CacheTBLTPRoutes: {},
- utils.CacheTBLTPAttributes: {},
- utils.CacheTBLTPChargers: {},
- utils.CacheTBLTPDispatchers: {},
- utils.CacheTBLTPDispatcherHosts: {},
- utils.CacheTBLTPRateProfiles: {},
- utils.MetaAPIBan: {},
- utils.CacheActionProfiles: {},
- utils.CacheActionProfilesFilterIndexes: {},
- utils.CacheTBLTPActionProfiles: {},
- utils.CacheTBLTPAccountProfiles: {},
- utils.CacheAccountProfiles: {},
- utils.CacheAccountProfilesFilterIndexes: {},
- utils.CacheReplicationHosts: {},
+ utils.CacheThresholdProfiles: {Items: 7},
+ utils.CacheThresholds: {Items: 7},
+ utils.CacheTimings: {},
+ utils.CacheDiameterMessages: {},
+ utils.CacheClosedSessions: {},
+ utils.CacheLoadIDs: {},
+ utils.CacheRPCConnections: {},
+ utils.CacheCDRIDs: {},
+ utils.CacheRatingProfilesTmp: {},
+ utils.CacheUCH: {},
+ utils.CacheReverseFilterIndexes: {},
+ utils.CacheAccounts: {},
+ utils.CacheVersions: {},
+ utils.CacheTBLTPTimings: {},
+ utils.CacheTBLTPDestinations: {},
+ utils.CacheTBLTPRates: {},
+ utils.CacheTBLTPDestinationRates: {},
+ utils.CacheTBLTPRatingPlans: {},
+ utils.CacheTBLTPRatingProfiles: {},
+ utils.CacheTBLTPSharedGroups: {},
+ utils.CacheTBLTPActions: {},
+ utils.CacheTBLTPActionPlans: {},
+ utils.CacheTBLTPActionTriggers: {},
+ utils.CacheTBLTPAccountActions: {},
+ utils.CacheTBLTPResources: {},
+ utils.CacheTBLTPStats: {},
+ utils.CacheTBLTPThresholds: {},
+ utils.CacheTBLTPFilters: {},
+ utils.CacheSessionCostsTBL: {},
+ utils.CacheCDRsTBL: {},
+ utils.CacheTBLTPRoutes: {},
+ utils.CacheTBLTPAttributes: {},
+ utils.CacheTBLTPChargers: {},
+ utils.CacheTBLTPDispatchers: {},
+ utils.CacheTBLTPDispatcherHosts: {},
+ utils.CacheTBLTPRateProfiles: {},
+ utils.MetaAPIBan: {},
+ utils.CacheActionProfiles: {},
+ utils.CacheActionProfilesFilterIndexes: {},
+ utils.CacheTBLTPActionProfiles: {},
+ utils.CacheReplicationHosts: {},
}
if *apiBan {
(*expectedStats)[utils.MetaAPIBan] = <cache.CacheStats{Items: 254}
diff --git a/apier/v1/tpaccountprofiles_it_test.go b/apier/v1/tpaccountprofiles_it_test.go
deleted file mode 100644
index 3b8b39cc2..000000000
--- a/apier/v1/tpaccountprofiles_it_test.go
+++ /dev/null
@@ -1,233 +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"
- "testing"
-
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var (
- tpAcctPrfCfgPath string
- tpAcctPrfCfg *config.CGRConfig
- tpAcctPrfRPC *rpc.Client
- tpAcctPrf *utils.TPAccountProfile
- tpAcctPrfDelay int
- tpAcctPrfConfigDIR string //run tests for specific configuration
-)
-
-var sTestsTPAcctPrf = []func(t *testing.T){
- testTPAcctPrfInitCfg,
- testTPAcctPrfResetStorDb,
- testTPAcctPrfStartEngine,
- testTPAcctPrfRPCConn,
- testTPAcctPrfGetTPAcctPrfBeforeSet,
- testTPAcctPrfSetTPAcctPrf,
- testTPAcctPrfGetTPAcctPrfAfterSet,
- testTPAcctPrfGetTPAcctPrfIDs,
- testTPAcctPrfUpdateTPAcctBal,
- testTPAcctPrfGetTPAcctBalAfterUpdate,
- testTPAcctPrfRemTPAcctPrf,
- testTPAcctPrfGetTPAcctPrfAfterRemove,
- testTPAcctPrfKillEngine,
-}
-
-//Test start here
-func TestTPAcctPrfIT(t *testing.T) {
- switch *dbType {
- case utils.MetaInternal:
- tpAcctPrfConfigDIR = "tutinternal"
- case utils.MetaMySQL:
- tpAcctPrfConfigDIR = "tutmysql"
- case utils.MetaMongo:
- tpAcctPrfConfigDIR = "tutmongo"
- case utils.MetaPostgres:
- t.SkipNow()
- default:
- t.Fatal("Unknown Database type")
- }
- for _, stest := range sTestsTPAcctPrf {
- t.Run(tpAcctPrfConfigDIR, stest)
- }
-}
-
-func testTPAcctPrfInitCfg(t *testing.T) {
- var err error
- tpAcctPrfCfgPath = path.Join(*dataDir, "conf", "samples", tpAcctPrfConfigDIR)
- tpAcctPrfCfg, err = config.NewCGRConfigFromPath(tpAcctPrfCfgPath)
- if err != nil {
- t.Error(err)
- }
- tpAcctPrfDelay = 1000
-}
-
-// Wipe out the cdr database
-func testTPAcctPrfResetStorDb(t *testing.T) {
- if err := engine.InitStorDb(tpAcctPrfCfg); err != nil {
- t.Fatal(err)
- }
-}
-
-// Start CGR Engine
-func testTPAcctPrfStartEngine(t *testing.T) {
- if _, err := engine.StopStartEngine(tpAcctPrfCfgPath, tpAcctPrfDelay); err != nil {
- t.Fatal(err)
- }
-}
-
-// Connect rpc client to rater
-func testTPAcctPrfRPCConn(t *testing.T) {
- var err error
- tpAcctPrfRPC, err = jsonrpc.Dial(utils.TCP, tpAcctPrfCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
- if err != nil {
- t.Fatal(err)
- }
-}
-
-func testTPAcctPrfGetTPAcctPrfBeforeSet(t *testing.T) {
- var reply *utils.TPAccountProfile
- if err := tpAcctPrfRPC.Call(utils.APIerSv1GetTPAccountProfile,
- &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "1001"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-}
-
-func testTPAcctPrfSetTPAcctPrf(t *testing.T) {
- tpAcctPrf = &utils.TPAccountProfile{
- TPid: "TP1",
- Tenant: "cgrates.org",
- ID: "1001",
- Weights: ";20",
- Balances: map[string]*utils.TPAccountBalance{
- "MonetaryBalance": {
- ID: "MonetaryBalance",
- Weights: ";10",
- Type: utils.MetaMonetary,
- Units: 14,
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- }
- var result string
- if err := tpAcctPrfRPC.Call(utils.APIerSv1SetTPAccountProfile, tpAcctPrf, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-}
-
-func testTPAcctPrfGetTPAcctPrfAfterSet(t *testing.T) {
- var reply *utils.TPAccountProfile
- if err := tpAcctPrfRPC.Call(utils.APIerSv1GetTPAccountProfile,
- &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "1001"}, &reply); err != nil {
- t.Fatal(err)
- }
- if !reflect.DeepEqual(tpAcctPrf, reply) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(tpAcctPrf), utils.ToJSON(reply))
- }
-}
-
-func testTPAcctPrfGetTPAcctPrfIDs(t *testing.T) {
- var result []string
- expectedTPID := []string{"cgrates.org:1001"}
- if err := tpAcctPrfRPC.Call(utils.APIerSv1GetTPAccountProfileIDs,
- &AttrGetTPAccountProfileIDs{TPid: "TP1"}, &result); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expectedTPID, result) {
- t.Errorf("Expecting: %+v, received: %+v", expectedTPID, result)
- }
-}
-
-func testTPAcctPrfUpdateTPAcctBal(t *testing.T) {
- tpAcctPrf.Balances = map[string]*utils.TPAccountBalance{
- "MonetaryBalance2": {
- ID: "MonetaryBalance2",
- Weights: ";12",
- Type: utils.MetaMonetary,
- Units: 16,
- },
- }
- var result string
- if err := tpAcctPrfRPC.Call(utils.APIerSv1SetTPAccountProfile, tpAcctPrf, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-}
-
-func testTPAcctPrfGetTPAcctBalAfterUpdate(t *testing.T) {
- var reply *utils.TPAccountProfile
- revTPAcctPrf := &utils.TPAccountProfile{
- TPid: "TP1",
- Tenant: "cgrates.org",
- ID: "1001",
- Weights: ";20",
- Balances: map[string]*utils.TPAccountBalance{
- "MonetaryBalance2": {
- ID: "MonetaryBalance2",
- Weights: ";12",
- Type: utils.MetaMonetary,
- Units: 16,
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- }
- if err := tpAcctPrfRPC.Call(utils.APIerSv1GetTPAccountProfile,
- &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "1001"}, &reply); err != nil {
- t.Fatal(err)
- }
- if !reflect.DeepEqual(tpAcctPrf, reply) && !reflect.DeepEqual(revTPAcctPrf, reply) {
- t.Errorf("Expecting : %+v, \n received: %+v", utils.ToJSON(tpAcctPrf), utils.ToJSON(reply))
- }
-}
-
-func testTPAcctPrfRemTPAcctPrf(t *testing.T) {
- var resp string
- if err := tpAcctPrfRPC.Call(utils.APIerSv1RemoveTPAccountProfile,
- &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "1001"},
- &resp); err != nil {
- t.Error(err)
- } else if resp != utils.OK {
- t.Error("Unexpected reply returned", resp)
- }
-}
-
-func testTPAcctPrfGetTPAcctPrfAfterRemove(t *testing.T) {
- var reply *utils.TPAccountProfile
- if err := tpAcctPrfRPC.Call(utils.APIerSv1GetTPAccountProfile,
- &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "1001"},
- &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-}
-
-func testTPAcctPrfKillEngine(t *testing.T) {
- if err := engine.KillEngine(tpAcctPrfDelay); err != nil {
- t.Error(err)
- }
-}
diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json
index 67ac1166f..ced2c185a 100755
--- a/data/conf/cgrates/cgrates.json
+++ b/data/conf/cgrates/cgrates.json
@@ -88,7 +88,6 @@
// "*dispatcher_hosts":{"remote":false, "replicate":false},
// "*rate_profiles":{"remote":false, "replicate":false},
// "*action_profiles":{"remote":false, "replicate":false},
-// "*account_profiles":{"remote":false, "replicate":false},
// "*load_ids":{"remote":false, "replicate":false},
// "*indexes":{"remote":false, "replicate":false},
// },
@@ -149,7 +148,6 @@
// "*tp_dispatcher_hosts":{"remote":false, "replicate":false},
// "*tp_rate_profiles":{"remote":false, "replicate":false},
// "*tp_action_profiles":{"remote":false, "replicate":false},
-// "*tp_account_profiles":{"remote":false, "replicate":false},
// },
// },
@@ -240,7 +238,6 @@
// "*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
-// "*account_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control account 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
@@ -251,7 +248,6 @@
// "*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
-// "*account_profile_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control coount 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)
@@ -297,7 +293,6 @@
// "*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},
-// "*tp_account_profiles":{"limit": -1, "ttl": "", "static_ttl": false, "replicate": false},
// },
// "replication_conns": [],
// },
@@ -829,29 +824,6 @@
// {"tag": "ActionValue", "path": "ActionValue", "type": "*variable", "value": "~*req.15"},
// ],
// },
-// {
-// "type": "*account_profiles", // data source type
-// "file_name": "AccountProfiles.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": "BalanceID", "path": "BalanceID", "type": "*variable", "value": "~*req.5"},
-// {"tag": "BalanceFilterIDs", "path": "BalanceFilterIDs", "type": "*variable", "value": "~*req.6"},
-// {"tag": "BalanceWeight", "path": "BalanceWeight", "type": "*variable", "value": "~*req.7"},
-// {"tag": "BalanceBlocker", "path": "BalanceBlocker", "type": "*variable", "value": "~*req.8"},
-// {"tag": "BalanceType", "path": "BalanceType", "type": "*variable", "value": "~*req.9"},
-// {"tag": "BalanceOpts", "path": "BalanceOpts", "type": "*variable", "value": "~*req.10"},
-// {"tag": "BalanceCostIncrements", "path": "BalanceCostIncrements", "type": "*variable", "value": "~*req.11"},
-// {"tag": "BalanceAttributeIDs", "path": "BalanceAttributeIDs", "type": "*variable", "value": "~*req.12"},
-// {"tag": "BalanceRateProfileIDs", "path": "BalanceRateProfileIDs", "type": "*variable", "value": "~*req.13"},
-// {"tag": "BalanceUnitFactors", "path": "BalanceUnitFactors", "type": "*variable", "value": "~*req.14"},
-// {"tag": "BalanceUnits", "path": "BalanceUnits", "type": "*variable", "value": "~*req.15"},
-// {"tag": "ThresholdIDs", "path": "ThresholdIDs", "type": "*variable", "value": "~*req.16"},
-// ],
-// },
// ],
// },
// ],
diff --git a/data/conf/samples/filtered_replication/engine1_mongo/cgrates.json b/data/conf/samples/filtered_replication/engine1_mongo/cgrates.json
index 45180fc0e..959a25578 100644
--- a/data/conf/samples/filtered_replication/engine1_mongo/cgrates.json
+++ b/data/conf/samples/filtered_replication/engine1_mongo/cgrates.json
@@ -54,7 +54,6 @@
"*load_ids":{"remote":true,"replicate":false},
"*indexes":{"remote":true, "replicate":false},
"*action_profiles":{"remote":true,"replicate":false},
- "*account_profiles":{"remote":true,"replicate":false},
},
},
diff --git a/data/conf/samples/filtered_replication/engine1_redis/cgrates.json b/data/conf/samples/filtered_replication/engine1_redis/cgrates.json
index 3f95c6e19..8d9510477 100644
--- a/data/conf/samples/filtered_replication/engine1_redis/cgrates.json
+++ b/data/conf/samples/filtered_replication/engine1_redis/cgrates.json
@@ -53,7 +53,6 @@
"*load_ids":{"remote":true,"replicate":false},
"*indexes":{"remote":true, "replicate":false},
"*action_profiles":{"remote":true,"replicate":false},
- "*account_profiles":{"remote":true,"replicate":false},
},
},
diff --git a/data/conf/samples/filtered_replication/engine2_mongo/cgrates.json b/data/conf/samples/filtered_replication/engine2_mongo/cgrates.json
index 8393c3adf..a5ce68cd3 100644
--- a/data/conf/samples/filtered_replication/engine2_mongo/cgrates.json
+++ b/data/conf/samples/filtered_replication/engine2_mongo/cgrates.json
@@ -54,7 +54,6 @@
"*load_ids":{"remote":true,"replicate":false},
"*indexes":{"remote":true, "replicate":false},
"*action_profiles":{"remote":true,"replicate":false},
- "*account_profiles":{"remote":true,"replicate":false},
},
},
diff --git a/data/conf/samples/filtered_replication/engine2_redis/cgrates.json b/data/conf/samples/filtered_replication/engine2_redis/cgrates.json
index f9443cb57..f470b4063 100644
--- a/data/conf/samples/filtered_replication/engine2_redis/cgrates.json
+++ b/data/conf/samples/filtered_replication/engine2_redis/cgrates.json
@@ -54,7 +54,6 @@
"*load_ids":{"remote":true,"replicate":false},
"*indexes":{"remote":true, "replicate":false},
"*action_profiles":{"remote":true,"replicate":false},
- "*account_profiles":{"remote":true,"replicate":false},
},
},
diff --git a/data/conf/samples/filtered_replication/internal/cgrates.json b/data/conf/samples/filtered_replication/internal/cgrates.json
index e23ddd041..a787bb126 100644
--- a/data/conf/samples/filtered_replication/internal/cgrates.json
+++ b/data/conf/samples/filtered_replication/internal/cgrates.json
@@ -55,7 +55,6 @@
"*rate_profiles":{"remote":false,"replicate":true},
"*load_ids":{"remote":false,"replicate":true},
"*action_profiles":{"remote":false,"replicate":true},
- "*account_profiles":{"remote":false,"replicate":true},
},
},
diff --git a/data/conf/samples/full_remote/internal/cgrates.json b/data/conf/samples/full_remote/internal/cgrates.json
index 13ff7baa5..57ea613d3 100644
--- a/data/conf/samples/full_remote/internal/cgrates.json
+++ b/data/conf/samples/full_remote/internal/cgrates.json
@@ -45,7 +45,6 @@
"*dispatcher_hosts": {"limit":0 },
"*rate_profiles": {"limit":0 },
"*action_profiles": {"limit":0 },
- "*account_profiles": {"limit":0 },
"*resource_filter_indexes" : {"limit":0},
"*stat_filter_indexes" : {"limit":0},
"*threshold_filter_indexes" : {"limit":0},
@@ -56,7 +55,6 @@
"*rate_profile_filter_indexes" : {"limit":0},
"*rate_filter_indexes" : {"limit":0},
"*action_profile_filter_indexes" : {"limit":0},
- "*account_profile_filter_indexes" : {"limit":0},
"*reverse_filter_indexes" : {"limit":0},
"*dispatcher_routes": {"limit":0},
"*dispatcher_loads": {"limit":0},
@@ -94,7 +92,6 @@
"*dispatcher_profiles":{"remote":true,"replicate":false},
"*dispatcher_hosts":{"remote":true,"replicate":false},
"*rate_profiles":{"remote":true,"replicate":false},
- "*account_profiles":{"remote":true, "replicate":false},
"*load_ids":{"remote":true,"replicate":false},
"*indexes":{"remote":true, "replicate":false},
},
diff --git a/data/storage/mysql/create_tariffplan_tables.sql b/data/storage/mysql/create_tariffplan_tables.sql
index 7745c1622..f801942c9 100644
--- a/data/storage/mysql/create_tariffplan_tables.sql
+++ b/data/storage/mysql/create_tariffplan_tables.sql
@@ -535,35 +535,6 @@ CREATE TABLE tp_action_profiles (
`id`,`filter_ids`,`action_id` )
);
-
-DROP TABLE IF EXISTS tp_account_profiles;
-CREATE TABLE tp_account_profiles (
- `pk` int(11) NOT NULL AUTO_INCREMENT,
- `tpid` varchar(64) NOT NULL,
- `tenant` varchar(64) NOT NULL,
- `id` varchar(64) NOT NULL,
- `filter_ids` varchar(64) NOT NULL,
- `activation_interval` varchar(64) NOT NULL,
- `weights` varchar(64) NOT NULL,
- `opts` varchar(256) NOT NULL,
- `balance_id` varchar(64) NOT NULL,
- `balance_filter_ids` varchar(64) NOT NULL,
- `balance_weights` varchar(64) NOT NULL,
- `balance_type` varchar(64) NOT NULL,
- `balance_units` decimal(16,4) NOT NULL,
- `balance_unit_factors` varchar(64) NOT NULL,
- `balance_opts` varchar(256) NOT NULL,
- `balance_cost_increments` varchar(64) NOT NULL,
- `balance_attribute_ids` varchar(64) NOT NULL,
- `balance_rate_profile_ids` varchar(64) NOT NULL,
- `threshold_ids` varchar(64) NOT NULL,
- `created_at` TIMESTAMP,
- PRIMARY KEY (`pk`),
- KEY `tpid` (`tpid`),
- UNIQUE KEY `unique_tp_account_profiles` (`tpid`,`tenant`,
- `id`,`filter_ids`,`balance_id` )
-);
-
--
-- Table structure for table `versions`
--
diff --git a/data/storage/postgres/create_tariffplan_tables.sql b/data/storage/postgres/create_tariffplan_tables.sql
index 75c651c78..d823fc2ea 100644
--- a/data/storage/postgres/create_tariffplan_tables.sql
+++ b/data/storage/postgres/create_tariffplan_tables.sql
@@ -519,33 +519,6 @@ CREATE TABLE tp_action_profiles (
"filter_ids", "action_id");
-DROP TABLE IF EXISTS tp_account_profiles;
-CREATE TABLE tp_account_profiles (
- "pk" SERIAL PRIMARY KEY,
- "tpid" varchar(64) NOT NULL,
- "tenant" varchar(64) NOT NULL,
- "id" varchar(64) NOT NULL,
- "filter_ids" varchar(64) NOT NULL,
- "activation_interval" varchar(64) NOT NULL,
- "weights" varchar(64) NOT NULL,
- "opts" varchar(256) NOT NULL,
- "balance_id" varchar(64) NOT NULL,
- "balance_filter_ids" varchar(64) NOT NULL,
- "balance_weights" varchar(64) NOT NULL,
- "balance_type" varchar(64) NOT NULL,
- "balance_units" decimal(16,4) NOT NULL,
- "balance_unit_factors" varchar(64) NOT NULL,
- "balance_opts" varchar(256) NOT NULL,
- "balance_cost_increments" varchar(64) NOT NULL,
- "balance_attribute_ids" varchar(64) NOT NULL,
- "balance_rate_profile_ids" varchar(64) NOT NULL,
- "threshold_ids" varchar(64) NOT NULL,
- "created_at" TIMESTAMP WITH TIME ZONE
-);
- CREATE INDEX tp_account_profiles_ids ON tp_account_profiles (tpid);
- CREATE INDEX tp_account_profiles_unique ON tp_account_profiles ("tpid", "tenant", "id",
- "filter_ids", "balance_id");
-
--
-- Table structure for table `versions`
--
diff --git a/data/tariffplans/dispatchers/Attributes.csv b/data/tariffplans/dispatchers/Attributes.csv
index 549968fc8..1ba3aee50 100644
--- a/data/tariffplans/dispatchers/Attributes.csv
+++ b/data/tariffplans/dispatchers/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&ReplicatorSv1.SetAccountProfile&ReplicatorSv1.GetAccountProfile&ReplicatorSv1.RemoveAccountProfile&ReplicatorSv1.SetActionProfile&ReplicatorSv1.GetActionProfile&ReplicatorSv1.RemoveActionProfile,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&ReplicatorSv1.SetActionProfile&ReplicatorSv1.GetActionProfile&ReplicatorSv1.RemoveActionProfile,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&RateSv1.CostForEvent,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/dispatchers/caches_it_test.go b/dispatchers/caches_it_test.go
index 96d6f0958..e3d395696 100644
--- a/dispatchers/caches_it_test.go
+++ b/dispatchers/caches_it_test.go
@@ -166,58 +166,56 @@ func testDspChcLoadAfterFolder(t *testing.T) {
func testDspChcPrecacheStatus(t *testing.T) {
var reply map[string]string
expected := map[string]string{
- utils.CacheDestinations: utils.MetaReady,
- utils.CacheReverseDestinations: utils.MetaReady,
- utils.CacheRatingPlans: utils.MetaReady,
- utils.CacheRatingProfiles: utils.MetaReady,
- utils.CacheActions: utils.MetaReady,
- utils.CacheActionPlans: utils.MetaReady,
- utils.CacheAccountActionPlans: utils.MetaReady,
- utils.CacheActionTriggers: utils.MetaReady,
- utils.CacheSharedGroups: utils.MetaReady,
- utils.CacheResourceProfiles: utils.MetaReady,
- utils.CacheResources: utils.MetaReady,
- utils.CacheTimings: utils.MetaReady,
- utils.CacheStatQueueProfiles: utils.MetaReady,
- utils.CacheStatQueues: utils.MetaReady,
- utils.CacheThresholdProfiles: utils.MetaReady,
- utils.CacheThresholds: utils.MetaReady,
- utils.CacheFilters: utils.MetaReady,
- utils.CacheRouteProfiles: utils.MetaReady,
- utils.CacheAttributeProfiles: utils.MetaReady,
- utils.CacheChargerProfiles: utils.MetaReady,
- utils.CacheDispatcherProfiles: utils.MetaReady,
- utils.CacheDispatcherHosts: utils.MetaReady,
- utils.CacheDiameterMessages: utils.MetaReady,
- utils.CacheAttributeFilterIndexes: utils.MetaReady,
- utils.CacheResourceFilterIndexes: utils.MetaReady,
- utils.CacheStatFilterIndexes: utils.MetaReady,
- utils.CacheThresholdFilterIndexes: utils.MetaReady,
- utils.CacheRouteFilterIndexes: utils.MetaReady,
- utils.CacheChargerFilterIndexes: utils.MetaReady,
- utils.CacheDispatcherFilterIndexes: utils.MetaReady,
- utils.CacheRateProfilesFilterIndexes: utils.MetaReady,
- utils.CacheRateFilterIndexes: utils.MetaReady,
- utils.CacheRateProfiles: utils.MetaReady,
- utils.CacheLoadIDs: utils.MetaReady,
- utils.CacheCDRIDs: utils.MetaReady,
- utils.CacheClosedSessions: utils.MetaReady,
- utils.CacheDispatcherRoutes: utils.MetaReady,
- utils.CacheEventResources: utils.MetaReady,
- utils.CacheRPCConnections: utils.MetaReady,
- utils.CacheRPCResponses: utils.MetaReady,
- utils.CacheRatingProfilesTmp: utils.MetaReady,
- utils.CacheUCH: utils.MetaReady,
- utils.CacheSTIR: utils.MetaReady,
- utils.CacheDispatcherLoads: utils.MetaReady,
- utils.CacheDispatchers: utils.MetaReady,
- utils.CacheEventCharges: utils.MetaReady,
- utils.CacheReverseFilterIndexes: utils.MetaReady,
- utils.CacheCapsEvents: utils.MetaReady,
- utils.CacheActionProfiles: utils.MetaReady,
- utils.CacheActionProfilesFilterIndexes: utils.MetaReady,
- utils.CacheAccountProfilesFilterIndexes: utils.MetaReady,
- utils.CacheAccountProfiles: utils.MetaReady,
+ utils.CacheDestinations: utils.MetaReady,
+ utils.CacheReverseDestinations: utils.MetaReady,
+ utils.CacheRatingPlans: utils.MetaReady,
+ utils.CacheRatingProfiles: utils.MetaReady,
+ utils.CacheActions: utils.MetaReady,
+ utils.CacheActionPlans: utils.MetaReady,
+ utils.CacheAccountActionPlans: utils.MetaReady,
+ utils.CacheActionTriggers: utils.MetaReady,
+ utils.CacheSharedGroups: utils.MetaReady,
+ utils.CacheResourceProfiles: utils.MetaReady,
+ utils.CacheResources: utils.MetaReady,
+ utils.CacheTimings: utils.MetaReady,
+ utils.CacheStatQueueProfiles: utils.MetaReady,
+ utils.CacheStatQueues: utils.MetaReady,
+ utils.CacheThresholdProfiles: utils.MetaReady,
+ utils.CacheThresholds: utils.MetaReady,
+ utils.CacheFilters: utils.MetaReady,
+ utils.CacheRouteProfiles: utils.MetaReady,
+ utils.CacheAttributeProfiles: utils.MetaReady,
+ utils.CacheChargerProfiles: utils.MetaReady,
+ utils.CacheDispatcherProfiles: utils.MetaReady,
+ utils.CacheDispatcherHosts: utils.MetaReady,
+ utils.CacheDiameterMessages: utils.MetaReady,
+ utils.CacheAttributeFilterIndexes: utils.MetaReady,
+ utils.CacheResourceFilterIndexes: utils.MetaReady,
+ utils.CacheStatFilterIndexes: utils.MetaReady,
+ utils.CacheThresholdFilterIndexes: utils.MetaReady,
+ utils.CacheRouteFilterIndexes: utils.MetaReady,
+ utils.CacheChargerFilterIndexes: utils.MetaReady,
+ utils.CacheDispatcherFilterIndexes: utils.MetaReady,
+ utils.CacheRateProfilesFilterIndexes: utils.MetaReady,
+ utils.CacheRateFilterIndexes: utils.MetaReady,
+ utils.CacheRateProfiles: utils.MetaReady,
+ utils.CacheLoadIDs: utils.MetaReady,
+ utils.CacheCDRIDs: utils.MetaReady,
+ utils.CacheClosedSessions: utils.MetaReady,
+ utils.CacheDispatcherRoutes: utils.MetaReady,
+ utils.CacheEventResources: utils.MetaReady,
+ utils.CacheRPCConnections: utils.MetaReady,
+ utils.CacheRPCResponses: utils.MetaReady,
+ utils.CacheRatingProfilesTmp: utils.MetaReady,
+ utils.CacheUCH: utils.MetaReady,
+ utils.CacheSTIR: utils.MetaReady,
+ utils.CacheDispatcherLoads: utils.MetaReady,
+ utils.CacheDispatchers: utils.MetaReady,
+ utils.CacheEventCharges: utils.MetaReady,
+ utils.CacheReverseFilterIndexes: utils.MetaReady,
+ utils.CacheCapsEvents: utils.MetaReady,
+ utils.CacheActionProfiles: utils.MetaReady,
+ utils.CacheActionProfilesFilterIndexes: utils.MetaReady,
utils.CacheAccounts: utils.MetaReady,
utils.CacheVersions: utils.MetaReady,
@@ -246,7 +244,6 @@ func testDspChcPrecacheStatus(t *testing.T) {
utils.CacheTBLTPRateProfiles: utils.MetaReady,
utils.MetaAPIBan: utils.MetaReady,
utils.CacheTBLTPActionProfiles: utils.MetaReady,
- utils.CacheTBLTPAccountProfiles: utils.MetaReady,
utils.CacheReplicationHosts: utils.MetaReady,
}
diff --git a/dispatchers/replicator_it_test.go b/dispatchers/replicator_it_test.go
index 7daa7eba8..6a05ec5f4 100644
--- a/dispatchers/replicator_it_test.go
+++ b/dispatchers/replicator_it_test.go
@@ -54,7 +54,6 @@ var sTestsDspRpl = []func(t *testing.T){
testDspRplRatingProfile,
testDspRplDestination,
testDspRplRateProfile,
- testDspRplAccountProfile,
testDspRplActionProfile,
}
@@ -1557,65 +1556,6 @@ func testDspRplRateProfile(t *testing.T) {
t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
}
}
-func testDspRplAccountProfile(t *testing.T) {
- // Set RateProfile
- var replyStr string
- rPrf := &utils.AccountProfileWithAPIOpts{
- AccountProfile: &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "RP1",
- },
- APIOpts: map[string]interface{}{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(utils.ReplicatorSv1SetAccountProfile, rPrf, &replyStr); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.SetAccountProfile: ", err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
- // Get RateProfile
- var reply *utils.AccountProfile
- args := &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{
- Tenant: "cgrates.org",
- ID: "RP1",
- },
- APIOpts: map[string]interface{}{
- utils.OptsAPIKey: "repl12345",
- },
- }
- if err := dispEngine.RPC.Call(utils.ReplicatorSv1GetAccountProfile, args, &reply); err != nil {
- t.Error("Unexpected error when calling ReplicatorSv1.GetAccountProfile: ", err)
- } else if !reflect.DeepEqual(rPrf.AccountProfile, reply) {
- t.Errorf("Expecting: %+v, received: %+v, ", rPrf.AccountProfile, reply)
- }
- // Stop engine 1
- allEngine.stopEngine(t)
-
- // Get RateProfile
- if err := dispEngine.RPC.Call(utils.ReplicatorSv1GetAccountProfile, args, &reply); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
- // Start engine 1
- allEngine.startEngine(t)
-
- // Remove RateProfile
- if err := dispEngine.RPC.Call(utils.ReplicatorSv1RemoveAccountProfile, args, &replyStr); err != nil {
- t.Error(err)
- } else if replyStr != utils.OK {
- t.Error("Unexpected reply returned", replyStr)
- }
-
- // Get RateProfile
- if err := dispEngine.RPC.Call(utils.ReplicatorSv1GetAccountProfile, args, &reply); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Errorf("Expecting: %+v, received: %+v, ", utils.ErrNotFound, err)
- }
-
-}
func testDspRplActionProfile(t *testing.T) {
// Set RateProfile
diff --git a/engine/datadbmock.go b/engine/datadbmock.go
index 92941ecad..b31565a90 100644
--- a/engine/datadbmock.go
+++ b/engine/datadbmock.go
@@ -406,10 +406,6 @@ func (dbM *DataDBMock) RemoveActionProfileDrv(string, string) error {
return utils.ErrNotImplemented
}
-func (dbM *DataDBMock) RemoveAccountProfileDrv(string, string) error {
- return utils.ErrNotImplemented
-}
-
func (dbM *DataDBMock) SetVersions(vrs Versions, overwrite bool) (err error) {
return utils.ErrNotImplemented
}
diff --git a/engine/model_helpers.go b/engine/model_helpers.go
index f61af3602..95332534a 100644
--- a/engine/model_helpers.go
+++ b/engine/model_helpers.go
@@ -3414,195 +3414,3 @@ func ActionProfileToAPI(ap *ActionProfile) (tpAp *utils.TPActionProfile) {
}
return
}
-
-type AccountProfileMdls []*AccountProfileMdl
-
-// CSVHeader return the header for csv fields as a slice of string
-func (apm AccountProfileMdls) CSVHeader() (result []string) {
- return []string{"#" + utils.Tenant, utils.ID, utils.FilterIDs,
- utils.ActivationIntervalString, utils.Weight, utils.BalanceID,
- utils.BalanceFilterIDs, utils.BalanceWeight, utils.BalanceBlocker,
- utils.BalanceType, utils.BalanceOpts, utils.BalanceUnits, utils.ThresholdIDs,
- }
-}
-
-func (tps AccountProfileMdls) AsTPAccountProfile() (result []*utils.TPAccountProfile, err error) {
- filterIDsMap := make(map[string]utils.StringSet)
- thresholdIDsMap := make(map[string]utils.StringSet)
- actPrfMap := make(map[string]*utils.TPAccountProfile)
- for _, tp := range tps {
- tenID := (&utils.TenantID{Tenant: tp.Tenant, ID: tp.ID}).TenantID()
- aPrf, found := actPrfMap[tenID]
- if !found {
- aPrf = &utils.TPAccountProfile{
- TPid: tp.Tpid,
- Tenant: tp.Tenant,
- ID: tp.ID,
- Weights: tp.Weights,
- Balances: make(map[string]*utils.TPAccountBalance),
- }
- }
- if tp.FilterIDs != utils.EmptyString {
- if _, has := filterIDsMap[tenID]; !has {
- filterIDsMap[tenID] = make(utils.StringSet)
- }
- filterIDsMap[tenID].AddSlice(strings.Split(tp.FilterIDs, utils.InfieldSep))
- }
- if tp.ThresholdIDs != utils.EmptyString {
- if _, has := thresholdIDsMap[tenID]; !has {
- thresholdIDsMap[tenID] = make(utils.StringSet)
- }
- thresholdIDsMap[tenID].AddSlice(strings.Split(tp.ThresholdIDs, utils.InfieldSep))
- }
- if tp.ActivationInterval != utils.EmptyString {
- aPrf.ActivationInterval = new(utils.TPActivationInterval)
- aiSplt := strings.Split(tp.ActivationInterval, utils.InfieldSep)
- if len(aiSplt) == 2 {
- aPrf.ActivationInterval.ActivationTime = aiSplt[0]
- aPrf.ActivationInterval.ExpiryTime = aiSplt[1]
- } else if len(aiSplt) == 1 {
- aPrf.ActivationInterval.ActivationTime = aiSplt[0]
- }
- }
- if tp.BalanceID != utils.EmptyString {
- aPrf.Balances[tp.BalanceID] = &utils.TPAccountBalance{
- ID: tp.BalanceID,
- Weights: tp.BalanceWeights,
- Type: tp.BalanceType,
- Opts: tp.BalanceOpts,
- Units: tp.BalanceUnits,
- }
-
- if tp.BalanceFilterIDs != utils.EmptyString {
- aPrf.Balances[tp.BalanceID].FilterIDs = utils.NewStringSet(strings.Split(tp.BalanceFilterIDs, utils.InfieldSep)).AsSlice()
- }
- if tp.BalanceCostIncrements != utils.EmptyString {
- costIncrements := make([]*utils.TPBalanceCostIncrement, 0)
- sls := strings.Split(tp.BalanceCostIncrements, utils.InfieldSep)
- if len(sls)%4 != 0 {
- return nil, fmt.Errorf("invlid key: <%s> for BalanceCostIncrements", tp.BalanceCostIncrements)
- }
- for j := 0; j < len(sls); j = j + 4 {
- costIncrement, err := utils.NewTPBalanceCostIncrement(sls[j], sls[j+1], sls[j+2], sls[j+3])
- if err != nil {
- return nil, err
- }
- costIncrements = append(costIncrements, costIncrement)
- }
- aPrf.Balances[tp.BalanceID].CostIncrement = costIncrements
- }
- if tp.BalanceAttributeIDs != utils.EmptyString {
- // the order for attributes is important
- // also no duplicate check as we would
- // need to let the user execute the same
- // attribute twice if needed
- aPrf.Balances[tp.BalanceID].AttributeIDs = strings.Split(tp.BalanceAttributeIDs, utils.InfieldSep)
- }
- if tp.BalanceRateProfileIDs != utils.EmptyString {
- aPrf.Balances[tp.BalanceID].RateProfileIDs = utils.NewStringSet(strings.Split(tp.BalanceRateProfileIDs, utils.InfieldSep)).AsSlice()
- }
- if tp.BalanceUnitFactors != utils.EmptyString {
- unitFactors := make([]*utils.TPBalanceUnitFactor, 0)
- sls := strings.Split(tp.BalanceUnitFactors, utils.InfieldSep)
- if len(sls)%2 != 0 {
- return nil, fmt.Errorf("invlid key: <%s> for BalanceUnitFactors", tp.BalanceUnitFactors)
- }
-
- for j := 0; j < len(sls); j = j + 2 {
- unitFactor, err := utils.NewTPBalanceUnitFactor(sls[j], sls[j+1])
- if err != nil {
- return nil, err
- }
- unitFactors = append(unitFactors, unitFactor)
- }
- aPrf.Balances[tp.BalanceID].UnitFactors = unitFactors
- }
-
- }
- actPrfMap[tenID] = aPrf
- }
- result = make([]*utils.TPAccountProfile, len(actPrfMap))
- i := 0
- for tntID, th := range actPrfMap {
- result[i] = th
- result[i].FilterIDs = filterIDsMap[tntID].AsSlice()
- result[i].ThresholdIDs = thresholdIDsMap[tntID].AsSlice()
- i++
- }
- return
-}
-
-func APItoModelTPAccountProfile(tPrf *utils.TPAccountProfile) (mdls AccountProfileMdls) {
- if len(tPrf.Balances) == 0 {
- return
- }
- i := 0
- for _, balance := range tPrf.Balances {
- mdl := &AccountProfileMdl{
- Tenant: tPrf.Tenant,
- Tpid: tPrf.TPid,
- ID: tPrf.ID,
- }
- if i == 0 {
- for i, val := range tPrf.FilterIDs {
- if i != 0 {
- mdl.FilterIDs += utils.InfieldSep
- }
- mdl.FilterIDs += val
- }
- for i, val := range tPrf.ThresholdIDs {
- if i != 0 {
- mdl.ThresholdIDs += utils.InfieldSep
- }
- mdl.ThresholdIDs += val
- }
- if tPrf.ActivationInterval != nil {
- if tPrf.ActivationInterval.ActivationTime != utils.EmptyString {
- mdl.ActivationInterval = tPrf.ActivationInterval.ActivationTime
- }
- if tPrf.ActivationInterval.ExpiryTime != utils.EmptyString {
- mdl.ActivationInterval += utils.InfieldSep + tPrf.ActivationInterval.ExpiryTime
- }
- }
- mdl.Weights = tPrf.Weights
- }
- mdl.BalanceID = balance.ID
- for i, val := range balance.FilterIDs {
- if i != 0 {
- mdl.BalanceFilterIDs += utils.InfieldSep
- }
- mdl.BalanceFilterIDs += val
- }
- mdl.BalanceWeights = balance.Weights
- mdl.BalanceType = balance.Type
- mdl.BalanceOpts = balance.Opts
- for i, costIncr := range balance.CostIncrement {
- if i != 0 {
- mdl.BalanceCostIncrements += utils.InfieldSep
- }
- mdl.BalanceCostIncrements += costIncr.AsString()
- }
- for i, attrID := range balance.AttributeIDs {
- if i != 0 {
- mdl.BalanceAttributeIDs += utils.InfieldSep
- }
- mdl.BalanceAttributeIDs += attrID
- }
- for i, ratePrfID := range balance.RateProfileIDs {
- if i != 0 {
- mdl.BalanceRateProfileIDs += utils.InfieldSep
- }
- mdl.BalanceRateProfileIDs += ratePrfID
- }
- for i, unitFactor := range balance.UnitFactors {
- if i != 0 {
- mdl.BalanceUnitFactors += utils.InfieldSep
- }
- mdl.BalanceUnitFactors += unitFactor.AsString()
- }
- mdl.BalanceUnits = balance.Units
- mdls = append(mdls, mdl)
- i++
- }
- return
-}
diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go
index c18bbaa94..335de7efe 100644
--- a/engine/model_helpers_test.go
+++ b/engine/model_helpers_test.go
@@ -6949,206 +6949,6 @@ func TestModelHelpersCSVLoadErrorBool(t *testing.T) {
}
}
-func TestAccountProfileMdlsCSVHeader(t *testing.T) {
- testStruct := AccountProfileMdls{{
- Tpid: "TEST_TPID",
- Tenant: "cgrates.org",
- ID: "ResGroup1",
- FilterIDs: "FLTR_RES_GR1",
- ActivationInterval: "2014-07-29T15:00:00Z",
- Weights: "10.0",
- ThresholdIDs: "WARN_RES1;WARN_RES1",
- },
- }
- exp := []string{"#" + utils.Tenant, utils.ID, utils.FilterIDs,
- utils.ActivationIntervalString, utils.Weight, utils.BalanceID,
- utils.BalanceFilterIDs, utils.BalanceWeight, utils.BalanceBlocker,
- utils.BalanceType, utils.BalanceOpts, utils.BalanceUnits, utils.ThresholdIDs}
- result := testStruct.CSVHeader()
- if !reflect.DeepEqual(exp, result) {
- t.Errorf("Expecting: %+v,\nreceived: %+v", utils.ToJSON(exp), utils.ToJSON(result))
- }
-}
-
-func TestAccountProfileMdlsAsTPAccountProfile(t *testing.T) {
- testStruct := AccountProfileMdls{{
- PK: 0,
- Tpid: "TEST_TPID",
- Tenant: "cgrates.org",
- ID: "ResGroup1",
- FilterIDs: "FLTR_RES_GR1",
- ActivationInterval: "2014-07-24T15:00:00Z;2014-07-25T15:00:00Z",
- Weights: "10.0",
- BalanceID: "VoiceBalance",
- BalanceFilterIDs: "FLTR_RES_GR2",
- BalanceWeights: "10",
- BalanceRateProfileIDs: "rt1;rt2",
- BalanceType: utils.MetaVoice,
- BalanceUnits: 3600000000000,
- ThresholdIDs: "WARN_RES1",
- },
- }
- exp := []*utils.TPAccountProfile{
- {
- TPid: "TEST_TPID",
- Tenant: "cgrates.org",
- ID: "ResGroup1",
- FilterIDs: []string{"FLTR_RES_GR1"},
- ActivationInterval: &utils.TPActivationInterval{
- ActivationTime: "2014-07-24T15:00:00Z",
- ExpiryTime: "2014-07-25T15:00:00Z",
- },
- Weights: "10.0",
- Balances: map[string]*utils.TPAccountBalance{
- "VoiceBalance": {
- ID: "VoiceBalance",
- FilterIDs: []string{"FLTR_RES_GR2"},
- Weights: "10",
- Type: utils.MetaVoice,
- RateProfileIDs: []string{"rt1", "rt2"},
- Units: 3600000000000,
- },
- },
- ThresholdIDs: []string{"WARN_RES1"},
- },
- }
- result, err := testStruct.AsTPAccountProfile()
- if err != nil {
- t.Fatal(err)
- }
- sort.Strings(exp[0].Balances["VoiceBalance"].RateProfileIDs)
- sort.Strings(result[0].Balances["VoiceBalance"].RateProfileIDs)
- if !reflect.DeepEqual(exp, result) {
- t.Errorf("Expecting: %+v,\nreceived: %+v", utils.ToJSON(exp), utils.ToJSON(result))
- }
-}
-
-func TestAccountProfileMdlsAsTPAccountProfileCase2(t *testing.T) {
- testStruct := AccountProfileMdls{{
- PK: 0,
- Tpid: "TEST_TPID",
- Tenant: "cgrates.org",
- ID: "ResGroup1",
- FilterIDs: "FLTR_RES_GR1",
- ActivationInterval: "2014-07-24T15:00:00Z",
- Weights: "10.0",
- BalanceID: "VoiceBalance",
- BalanceFilterIDs: "FLTR_RES_GR2",
- BalanceWeights: "10",
- BalanceType: utils.MetaVoice,
- BalanceUnits: 3600000000000,
- ThresholdIDs: "WARN_RES1",
- },
- }
- exp := []*utils.TPAccountProfile{
- {
- TPid: "TEST_TPID",
- Tenant: "cgrates.org",
- ID: "ResGroup1",
- FilterIDs: []string{"FLTR_RES_GR1"},
- ActivationInterval: &utils.TPActivationInterval{
- ActivationTime: "2014-07-24T15:00:00Z",
- },
- Weights: "10.0",
- Balances: map[string]*utils.TPAccountBalance{
- "VoiceBalance": {
- ID: "VoiceBalance",
- FilterIDs: []string{"FLTR_RES_GR2"},
- Weights: "10",
- Type: utils.MetaVoice,
- Units: 3600000000000,
- },
- },
- ThresholdIDs: []string{"WARN_RES1"},
- },
- }
- result, err := testStruct.AsTPAccountProfile()
- if err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(exp, result) {
- t.Errorf("Expecting: %+v,\nreceived: %+v", utils.ToJSON(exp), utils.ToJSON(result))
- }
-}
-
-func TestAccountProfileMdlsAsTPAccountProfileError(t *testing.T) {
- testStruct := AccountProfileMdls{
- {
- PK: 0,
- Tpid: "TEST_TPID",
- Tenant: "cgrates.org",
- ID: "ResGroup1",
- BalanceID: "VoiceBalance",
- BalanceCostIncrements: "AN;INVALID;COST;INCREMENT;VALUE",
- },
- }
- expectedErr := "invlid key: for BalanceCostIncrements"
- if _, err := testStruct.AsTPAccountProfile(); err == nil || err.Error() != expectedErr {
- t.Errorf("Expected %+v, received %+v", expectedErr, err)
- }
-
- testStruct[0].BalanceCostIncrements = ";20;not_float;10"
- expectedErr = "strconv.ParseFloat: parsing \"not_float\": invalid syntax"
- if _, err := testStruct.AsTPAccountProfile(); err == nil || err.Error() != expectedErr {
- t.Errorf("Expected %+v, received %+v", expectedErr, err)
- }
-
- testStruct[0].BalanceCostIncrements = utils.EmptyString
- testStruct[0].BalanceUnitFactors = "NOT;A;VALUE"
- expectedErr = "invlid key: for BalanceUnitFactors"
- if _, err := testStruct.AsTPAccountProfile(); err == nil || err.Error() != expectedErr {
- t.Errorf("Expected %+v, received %+v", expectedErr, err)
- }
-
- testStruct[0].BalanceUnitFactors = ";float"
- expectedErr = "strconv.ParseFloat: parsing \"float\": invalid syntax"
- if _, err := testStruct.AsTPAccountProfile(); err == nil || err.Error() != expectedErr {
- t.Errorf("Expected %+v, received %+v", expectedErr, err)
- }
-}
-
-func TestAPItoModelTPAccountProfile(t *testing.T) {
- testStruct := &utils.TPAccountProfile{
- TPid: "TEST_TPID",
- Tenant: "cgrates.org",
- ID: "ResGroup1",
- FilterIDs: []string{"FLTR_RES_GR1"},
- ActivationInterval: &utils.TPActivationInterval{
- ActivationTime: "2014-07-24T15:00:00Z",
- ExpiryTime: "2014-07-25T15:00:00Z",
- },
- Weights: "10.0",
- Balances: map[string]*utils.TPAccountBalance{
- "VoiceBalance": {
- ID: "VoiceBalance",
- FilterIDs: []string{"FLTR_RES_GR2"},
- Weights: "10",
- Type: utils.MetaVoice,
- Units: 3600000000000,
- CostIncrement: []*utils.TPBalanceCostIncrement{},
- },
- },
- ThresholdIDs: []string{"WARN_RES1"},
- }
- exp := AccountProfileMdls{{
- Tpid: "TEST_TPID",
- Tenant: "cgrates.org",
- ID: "ResGroup1",
- FilterIDs: "FLTR_RES_GR1",
- ActivationInterval: "2014-07-24T15:00:00Z;2014-07-25T15:00:00Z",
- Weights: "10.0",
- BalanceID: "VoiceBalance",
- BalanceFilterIDs: "FLTR_RES_GR2",
- BalanceWeights: "10",
- BalanceType: utils.MetaVoice,
- BalanceUnits: 3600000000000,
- ThresholdIDs: "WARN_RES1",
- }}
- result := APItoModelTPAccountProfile(testStruct)
- if !reflect.DeepEqual(exp, result) {
- t.Errorf("Expecting: %+v,\nreceived: %+v", utils.ToJSON(exp), utils.ToJSON(result))
- }
-}
-
func TestModelHelpersActionProfileToAPICase2(t *testing.T) {
testStruct := &utils.TPActionProfile{
Tenant: "cgrates.org",
diff --git a/engine/models.go b/engine/models.go
index 8e7f0cbbd..6bf406dcf 100644
--- a/engine/models.go
+++ b/engine/models.go
@@ -565,26 +565,3 @@ type ActionProfileMdl struct {
func (ActionProfileMdl) TableName() string {
return utils.TBLTPActionProfiles
}
-
-type AccountProfileMdl struct {
- PK uint `gorm:"primary_key"`
- Tpid string
- Tenant string `index:"0" re:""`
- ID string `index:"1" re:""`
- FilterIDs string `index:"2" re:""`
- ActivationInterval string `index:"3" re:""`
- Weights string `index:"4" re:""`
- Opts string `index:"5" re:""`
- BalanceID string `index:"6" re:""`
- BalanceFilterIDs string `index:"7" re:""`
- BalanceWeights string `index:"8" re:""`
- BalanceType string `index:"9" re:""`
- BalanceUnits float64 `index:"10" re:"\d+\.?\d*"`
- BalanceUnitFactors string `index:"11" re:""`
- BalanceOpts string `index:"12" re:""`
- BalanceCostIncrements string `index:"13" re:""`
- BalanceAttributeIDs string `index:"14" re:""`
- BalanceRateProfileIDs string `index:"15" re:""`
- ThresholdIDs string `index:"16" re:""`
- CreatedAt time.Time
-}
diff --git a/engine/storage_csv.go b/engine/storage_csv.go
index 218c4913a..b4ab4d3c7 100644
--- a/engine/storage_csv.go
+++ b/engine/storage_csv.go
@@ -66,7 +66,6 @@ type CSVStorage struct {
dispatcherHostsFn []string
rateProfilesFn []string
actionProfilesFn []string
- accountProfilesFn []string
}
// NewCSVStorage creates a CSV storege that takes the data from the paths specified
@@ -688,18 +687,6 @@ func (csvs *CSVStorage) GetTPActionProfiles(tpid, tenant, id string) ([]*utils.T
return tpDPPs.AsTPActionProfile(), nil
}
-func (csvs *CSVStorage) GetTPAccountProfiles(tpid, tenant, id string) ([]*utils.TPAccountProfile, error) {
- var tpDPPs AccountProfileMdls
- if err := csvs.proccesData(AccountProfileMdl{}, csvs.accountProfilesFn, func(tp interface{}) {
- dpp := tp.(AccountProfileMdl)
- dpp.Tpid = tpid
- tpDPPs = append(tpDPPs, &dpp)
- }); err != nil {
- return nil, err
- }
- return tpDPPs.AsTPAccountProfile()
-}
-
func (csvs *CSVStorage) GetTpIds(colName string) ([]string, error) {
return nil, utils.ErrNotImplemented
}
diff --git a/engine/storage_sql.go b/engine/storage_sql.go
index dca147c56..cc8e6729d 100644
--- a/engine/storage_sql.go
+++ b/engine/storage_sql.go
@@ -772,29 +772,6 @@ func (sqls *SQLStorage) SetTPActionProfiles(tpAps []*utils.TPActionProfile) erro
tx.Commit()
return nil
}
-
-func (sqls *SQLStorage) SetTPAccountProfiles(tpAps []*utils.TPAccountProfile) error {
- if len(tpAps) == 0 {
- return nil
- }
- tx := sqls.db.Begin()
- for _, tpAp := range tpAps {
- // Remove previous
- if err := tx.Where(&AccountProfileMdl{Tpid: tpAp.TPid, Tenant: tpAp.Tenant, ID: tpAp.ID}).Delete(AccountProfileMdl{}).Error; err != nil {
- tx.Rollback()
- return err
- }
- for _, mst := range APItoModelTPAccountProfile(tpAp) {
- if err := tx.Create(&mst).Error; err != nil {
- tx.Rollback()
- return err
- }
- }
- }
- tx.Commit()
- return nil
-}
-
func (sqls *SQLStorage) SetSMCost(smc *SMCost) error {
if smc.CostDetails == nil {
return nil
@@ -1657,27 +1634,6 @@ func (sqls *SQLStorage) GetTPActionProfiles(tpid, tenant, id string) ([]*utils.T
return arls, nil
}
-func (sqls *SQLStorage) GetTPAccountProfiles(tpid, tenant, id string) ([]*utils.TPAccountProfile, error) {
- var dpps AccountProfileMdls
- q := sqls.db.Where("tpid = ?", tpid)
- if len(id) != 0 {
- q = q.Where("id = ?", id)
- }
- if len(tenant) != 0 {
- q = q.Where("tenant = ?", tenant)
- }
- if err := q.Find(&dpps).Error; err != nil {
- return nil, err
- }
- arls, err := dpps.AsTPAccountProfile()
- if err != nil {
- return nil, err
- } else if len(arls) == 0 {
- return arls, utils.ErrNotFound
- }
- return arls, nil
-}
-
// GetVersions returns slice of all versions or a specific version if tag is specified
func (sqls *SQLStorage) GetVersions(itm string) (vrs Versions, err error) {
q := sqls.db.Model(&TBLVersion{})
diff --git a/engine/tpreader.go b/engine/tpreader.go
index 06505c55b..6bd27db28 100644
--- a/engine/tpreader.go
+++ b/engine/tpreader.go
@@ -58,7 +58,6 @@ type TpReader struct {
dispatcherHosts map[utils.TenantID]*utils.TPDispatcherHost
rateProfiles map[utils.TenantID]*utils.TPRateProfile
actionProfiles map[utils.TenantID]*utils.TPActionProfile
- accountProfiles map[utils.TenantID]*utils.TPAccountProfile
resources []*utils.TenantID // IDs of resources which need creation based on resourceProfiles
statQueues []*utils.TenantID // IDs of statQueues which need creation based on statQueueProfiles
thresholds []*utils.TenantID // IDs of thresholds which need creation based on thresholdProfiles
@@ -109,7 +108,6 @@ func (tpr *TpReader) Init() {
tpr.dispatcherHosts = make(map[utils.TenantID]*utils.TPDispatcherHost)
tpr.rateProfiles = make(map[utils.TenantID]*utils.TPRateProfile)
tpr.actionProfiles = make(map[utils.TenantID]*utils.TPActionProfile)
- tpr.accountProfiles = make(map[utils.TenantID]*utils.TPAccountProfile)
tpr.filters = make(map[utils.TenantID]*utils.TPFilterProfile)
tpr.acntActionPlans = make(map[string][]string)
}
diff --git a/engine/z_filterindexer_it_test.go b/engine/z_filterindexer_it_test.go
index b7229bce5..94c83ff63 100644
--- a/engine/z_filterindexer_it_test.go
+++ b/engine/z_filterindexer_it_test.go
@@ -54,7 +54,6 @@ var sTests = []func(t *testing.T){
testITTestStoreFilterIndexesWithTransID,
testITFlush,
testITIsDBEmpty,
- testITAccountProfileIndexes,
testITFlush,
testITIsDBEmpty,
testITResourceProfileIndexes,
@@ -984,218 +983,6 @@ func testITTestStoreFilterIndexesWithTransID(t *testing.T) {
}
}
-func testITAccountProfileIndexes(t *testing.T) {
- fltr1 := &Filter{
- Tenant: "cgrates.org",
- ID: "FIRST",
- Rules: []*FilterRule{
- {
- Type: utils.MetaString,
- Element: "~*req.Destination",
- Values: []string{"DEST1", "DEST2", "~DynamicValue"},
- },
- },
- }
- if err := dataManager.SetFilter(fltr1, true); err != nil {
- t.Error(err)
- }
-
- accPrf1 := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "test_ID1",
- FilterIDs: []string{"FIRST", "*string:~*req.Account:DAN"},
- Balances: map[string]*utils.Balance{
- "VoiceBalance": {
- ID: "VoiceBalance",
- Type: utils.MetaAbstract,
- Units: utils.NewDecimal(100, 0),
- },
- },
- }
- accPrf2 := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "test_ID2",
- FilterIDs: []string{"FIRST"},
- Balances: map[string]*utils.Balance{
- "ConcreteBalance": {
- ID: "ConcreteBalance",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(200, 0),
- },
- },
- }
-
- if err := dataManager.SetAccountProfile(accPrf1, true); err != nil {
- t.Error(err)
- } else if err := dataManager.SetAccountProfile(accPrf2, true); err != nil {
- t.Error(err)
- }
-
- eIdxes := map[string]utils.StringSet{
- "*string:*req.Account:DAN": {
- "test_ID1": struct{}{},
- },
- "*string:*req.Destination:DEST1": {
- "test_ID1": struct{}{},
- "test_ID2": struct{}{},
- },
- "*string:*req.Destination:DEST2": {
- "test_ID1": struct{}{},
- "test_ID2": struct{}{},
- },
- }
- if rcvIDx, err := dataManager.GetIndexes(utils.CacheAccountProfilesFilterIndexes,
- "cgrates.org", utils.EmptyString, false, false); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcvIDx, eIdxes) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(eIdxes), utils.ToJSON(rcvIDx))
- }
-
- //add another filter for matching
- fltr2 := &Filter{
- Tenant: "cgrates.org",
- ID: "SECOND",
- Rules: []*FilterRule{
- {
- Type: utils.MetaString,
- Element: "dan",
- Values: []string{"DEST3", "~*req.Accounts", "~*req.Owner"},
- },
- },
- }
- if err := dataManager.SetFilter(fltr2, true); err != nil {
- t.Error(err)
- }
-
- accPrf3 := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "test_ID3",
- FilterIDs: []string{"SECOND", "*string:~*req.Account:DAN"},
- Balances: map[string]*utils.Balance{
- "ConcreteBalance": {
- ID: "ConcreteBalance",
- Type: utils.MetaConcrete,
- Units: utils.NewDecimal(200, 0),
- },
- },
- }
- if err := dataManager.SetAccountProfile(accPrf3, true); err != nil {
- t.Error(err)
- }
-
- eIdxes = map[string]utils.StringSet{
- "*string:*req.Accounts:dan": {
- "test_ID3": struct{}{},
- },
- "*string:*req.Owner:dan": {
- "test_ID3": struct{}{},
- },
- "*string:*req.Account:DAN": {
- "test_ID1": struct{}{},
- "test_ID3": struct{}{},
- },
- "*string:*req.Destination:DEST1": {
- "test_ID1": struct{}{},
- "test_ID2": struct{}{},
- },
- "*string:*req.Destination:DEST2": {
- "test_ID1": struct{}{},
- "test_ID2": struct{}{},
- },
- }
- if rcvIDx, err := dataManager.GetIndexes(utils.CacheAccountProfilesFilterIndexes,
- "cgrates.org", utils.EmptyString, false, false); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcvIDx, eIdxes) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(eIdxes), utils.ToJSON(rcvIDx))
- }
-
- eIdxes = map[string]utils.StringSet{
- "*string:*req.Destination:DEST1": {
- "test_ID1": struct{}{},
- "test_ID2": struct{}{},
- },
- }
- if rcvIDx, err := dataManager.GetIndexes(utils.CacheAccountProfilesFilterIndexes,
- "cgrates.org", "*string:*req.Destination:DEST1", false, false); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcvIDx, eIdxes) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(eIdxes), utils.ToJSON(rcvIDx))
- }
-
- //here we will update the filters
- fltr1 = &Filter{
- Tenant: "cgrates.org",
- ID: "FIRST",
- Rules: []*FilterRule{{Type: utils.MetaString, Element: "~*req.Destination", Values: []string{"DEST5"}}},
- }
- fltr2 = &Filter{
- Tenant: "cgrates.org",
- ID: "SECOND",
- Rules: []*FilterRule{{Type: utils.MetaString, Element: "DEST4", Values: []string{"~*req.CGRID"}}},
- }
- if err := dataManager.SetFilter(fltr1, true); err != nil {
- t.Error(err)
- } else if err := dataManager.SetFilter(fltr2, true); err != nil {
- t.Error(err)
- }
-
- eIdxes = map[string]utils.StringSet{
- "*string:*req.Destination:DEST5": {
- "test_ID1": struct{}{},
- "test_ID2": struct{}{},
- },
- "*string:*req.CGRID:DEST4": {
- "test_ID3": struct{}{},
- },
- "*string:*req.Account:DAN": {
- "test_ID1": struct{}{},
- "test_ID3": struct{}{},
- },
- }
- if rcvIDx, err := dataManager.GetIndexes(utils.CacheAccountProfilesFilterIndexes,
- "cgrates.org", utils.EmptyString, false, false); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcvIDx, eIdxes) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(eIdxes), utils.ToJSON(rcvIDx))
- }
-
- // here we will get the reverse indexing
- eIdxes = map[string]utils.StringSet{
- utils.CacheAccountProfilesFilterIndexes: {
- "test_ID1": struct{}{},
- "test_ID2": struct{}{},
- },
- }
- if rcvIDx, err := dataManager.GetIndexes(utils.CacheReverseFilterIndexes,
- "cgrates.org:FIRST", utils.EmptyString, false, false); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcvIDx, eIdxes) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(eIdxes), utils.ToJSON(rcvIDx))
- }
-
- eIdxes = map[string]utils.StringSet{
- utils.CacheAccountProfilesFilterIndexes: {
- "test_ID3": struct{}{},
- },
- }
- if rcvIDx, err := dataManager.GetIndexes(utils.CacheReverseFilterIndexes,
- "cgrates.org:SECOND", utils.EmptyString, false, false); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcvIDx, eIdxes) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(eIdxes), utils.ToJSON(rcvIDx))
- }
-
- //invalid tnt:context or index key
- eIdxes = nil
- if rcvIDx, err := dataManager.GetIndexes(utils.CacheAccountProfilesFilterIndexes,
- "cgrates.org", "*string:*req.Destination:DEST6", false, false); err == nil || err != utils.ErrNotFound {
- t.Errorf("Expected %+v, received %+v", utils.ErrNotFound, err)
- } else if !reflect.DeepEqual(rcvIDx, eIdxes) {
- t.Errorf("Expected %+v, received %+v", utils.ToJSON(eIdxes), utils.ToJSON(rcvIDx))
- }
-}
-
func testITResourceProfileIndexes(t *testing.T) {
fltr1 := &Filter{
Tenant: "cgrates.org",
diff --git a/engine/z_onstor_it_test.go b/engine/z_onstor_it_test.go
index b0011e867..102b3d8e4 100644
--- a/engine/z_onstor_it_test.go
+++ b/engine/z_onstor_it_test.go
@@ -26,8 +26,6 @@ import (
"testing"
"time"
- "github.com/ericlagergren/decimal"
-
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/utils"
)
@@ -79,7 +77,6 @@ var (
testOnStorITDispatcherProfile,
testOnStorITRateProfile,
testOnStorITActionProfile,
- testOnStorITAccountProfile,
//testOnStorITCacheActionTriggers,
//testOnStorITCRUDActionTriggers,
}
@@ -2313,79 +2310,3 @@ func testOnStorITActionProfile(t *testing.T) {
t.Error(err)
}
}
-
-func testOnStorITAccountProfile(t *testing.T) {
- acctPrf := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "RP1",
- FilterIDs: []string{"test_filterId"},
- ActivationInterval: &utils.ActivationInterval{
- ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
- ExpiryTime: time.Date(2014, 7, 15, 14, 25, 0, 0, time.UTC),
- },
- Weights: utils.DynamicWeights{
- {
- Weight: 2,
- },
- },
- Balances: map[string]*utils.Balance{
- "VoiceBalance": {
- ID: "VoiceBalance",
- FilterIDs: []string{"FLTR_RES_GR2"},
- Weights: utils.DynamicWeights{
- {
- Weight: 10,
- },
- },
- Type: utils.MetaVoice,
- Units: &utils.Decimal{
- Big: new(decimal.Big).SetUint64(10),
- },
- Opts: map[string]interface{}{
- "key1": "val1",
- },
- }},
- ThresholdIDs: []string{"test_thrs"},
- }
-
- //empty in database
- if _, err := onStor.GetAccountProfile("cgrates.org", "RP1"); err != utils.ErrNotFound {
- t.Error(err)
- }
-
- //get from database
- if err := onStor.SetAccountProfile(acctPrf, false); err != nil {
- t.Error(err)
- }
- if rcv, err := onStor.GetAccountProfile("cgrates.org", "RP1"); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcv, acctPrf) {
- t.Errorf("Expecting: %v, received: %v", acctPrf, rcv)
- }
-
- //craft akeysFromPrefix
- expectedKey := []string{"anp_cgrates.org:RP1"}
- if rcv, err := onStor.DataDB().GetKeysForPrefix(utils.AccountProfilePrefix); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expectedKey, rcv) {
- t.Errorf("Expecting: %v, received: %v", expectedKey, rcv)
- }
-
- //updateFilters
- acctPrf.FilterIDs = []string{"*prefix:~*req.Destination:10"}
- if err := onStor.SetAccountProfile(acctPrf, false); err != nil {
- t.Error(err)
- } else if rcv, err := onStor.GetAccountProfile("cgrates.org", "RP1"); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(acctPrf, rcv) {
- t.Errorf("Expecting: %v, received: %v", acctPrf, rcv)
- }
-
- //remove from database
- if err := onStor.RemoveAccountProfile("cgrates.org", "RP1",
- utils.NonTransactional, false); err != nil {
- t.Error(err)
- } else if _, err := onStor.GetAccountProfile("cgrates.org", "RP1"); err != utils.ErrNotFound {
- t.Error(err)
- }
-}
diff --git a/engine/z_stordb_it_test.go b/engine/z_stordb_it_test.go
index f22652d4d..5bee9037d 100644
--- a/engine/z_stordb_it_test.go
+++ b/engine/z_stordb_it_test.go
@@ -44,7 +44,6 @@ var sTestsStorDBit = []func(t *testing.T){
testStorDBitFlush,
testStorDBitIsDBEmpty,
testStorDBitCRUDVersions,
- testStorDBitCRUDTPAccountProfiles,
testStorDBitCRUDTPActionProfiles,
testStorDBitCRUDTPDispatcherProfiles,
testStorDBitCRUDTPDispatcherHosts,
@@ -149,82 +148,6 @@ func testStorDBitIsDBEmpty(t *testing.T) {
}
}
-func testStorDBitCRUDTPAccountProfiles(t *testing.T) {
- //READ
- if _, err := storDB.GetTPAccountProfiles("sub_ID1", utils.EmptyString, "TEST_ID1"); err != utils.ErrNotFound {
- t.Error(err)
- }
-
- //WRITE
- var actPrf = []*utils.TPAccountProfile{
- {
- TPid: testTPID,
- Tenant: "cgrates.org",
- ID: "1001",
- Weights: ";20",
- Balances: map[string]*utils.TPAccountBalance{
- "MonetaryBalance": {
- ID: "MonetaryBalance",
- Weights: ";10",
- Type: utils.MetaMonetary,
- CostIncrement: []*utils.TPBalanceCostIncrement{
- {
- FilterIDs: []string{"fltr1", "fltr2"},
- Increment: utils.Float64Pointer(1.3),
- FixedFee: utils.Float64Pointer(2.3),
- RecurrentFee: utils.Float64Pointer(3.3),
- },
- },
- AttributeIDs: []string{"attr1", "attr2"},
- UnitFactors: []*utils.TPBalanceUnitFactor{
- {
- FilterIDs: []string{"fltr1", "fltr2"},
- Factor: 100,
- },
- {
- FilterIDs: []string{"fltr3"},
- Factor: 200,
- },
- },
- Units: 14,
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- },
- }
- if err := storDB.SetTPAccountProfiles(actPrf); err != nil {
- t.Error(err)
- }
-
- //READ
- rcv, err := storDB.GetTPAccountProfiles(actPrf[0].TPid, utils.EmptyString, utils.EmptyString)
- if err != nil {
- t.Error(err)
- }
- sort.Strings(rcv[0].Balances["MonetaryBalance"].AttributeIDs)
- if !(reflect.DeepEqual(rcv[0], actPrf[0])) {
- t.Errorf("Expecting:\n%+v\nReceived:\n%+v\n", utils.ToJSON(actPrf[0]), utils.ToJSON(rcv[0]))
- }
-
- //UPDATE AND READ
- actPrf[0].FilterIDs = []string{"*string:~*req.Account:1007"}
- if err := storDB.SetTPAccountProfiles(actPrf); err != nil {
- t.Error(err)
- } else if rcv, err := storDB.GetTPAccountProfiles(actPrf[0].TPid,
- utils.EmptyString, utils.EmptyString); err != nil {
- t.Error(err)
- } else if !(reflect.DeepEqual(rcv[0], actPrf[0])) {
- t.Errorf("Expecting:\n%+v\nReceived:\n%+v\n", utils.ToJSON(actPrf[0]), utils.ToJSON(rcv[0]))
- }
-
- //REMOVE AND READ
- if err := storDB.RemTpData(utils.EmptyString, actPrf[0].TPid, nil); err != nil {
- t.Error(err)
- } else if _, err := storDB.GetTPActionProfiles(actPrf[0].TPid, utils.EmptyString, utils.EmptyString); err != utils.ErrNotFound {
- t.Error(err)
- }
-}
-
func testStorDBitCRUDTPActionProfiles(t *testing.T) {
//READ
if _, err := storDB.GetTPActionProfiles("sub_ID1", utils.EmptyString, "TEST_ID1"); err != utils.ErrNotFound {
diff --git a/general_tests/accountactions_it_test.go b/general_tests/accountactions_it_test.go
index 44ce228d2..6ad3e6588 100644
--- a/general_tests/accountactions_it_test.go
+++ b/general_tests/accountactions_it_test.go
@@ -49,10 +49,8 @@ var (
testAccActionsExecuteAction,
testAccActionsSetActionProfile,
testAccActionsExecuteAction2,
- testAccActionsGetAccountAfterActions,
testAccActionsSetActionProfile2,
testAccActionsExecuteAction3,
- testAccActionsGetAccountAfterRemActions,
testAccActionsKillEngine,
}
)
@@ -237,48 +235,6 @@ func testAccActionsExecuteAction2(t *testing.T) {
}
}
-func testAccActionsGetAccountAfterActions(t *testing.T) {
- accPrf := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "1001",
- Balances: map[string]*utils.Balance{
- "MONETARY": {
- ID: "MONETARY",
- Weights: utils.DynamicWeights{{}},
- Type: utils.MetaConcrete,
- Units: utils.NewDecimalFromFloat64(1048576),
- CostIncrements: []*utils.CostIncrement{{
- FilterIDs: []string{"*string:~*req.ToR:*data"},
- Increment: utils.NewDecimalFromFloat64(1024),
- FixedFee: utils.NewDecimalFromFloat64(0),
- RecurrentFee: utils.NewDecimalFromFloat64(0.01),
- }},
- },
- "VOICE": {
- ID: "VOICE",
- FilterIDs: []string{"*string:~*req.ToR:*voice"},
- Weights: utils.DynamicWeights{{Weight: 2}},
- Type: utils.MetaAbstract,
- Units: utils.NewDecimalFromFloat64(2 * 10800000000000),
- CostIncrements: []*utils.CostIncrement{{
- FilterIDs: []string{"*string:~*req.ToR:*voice"},
- Increment: utils.NewDecimalFromFloat64(1000000000),
- FixedFee: utils.NewDecimalFromFloat64(0),
- RecurrentFee: utils.NewDecimalFromFloat64(0.01),
- }},
- },
- },
- ThresholdIDs: []string{utils.MetaNone},
- }
- var result *utils.AccountProfile
- if err := accSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1001"}}, &result); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(accPrf, result) {
- t.Errorf("Expecting : %s, received: %s", utils.ToJSON(accPrf), utils.ToJSON(result))
- }
-}
-
func testAccActionsSetActionProfile2(t *testing.T) {
actPrf := &engine.ActionProfileWithAPIOpts{
ActionProfile: &engine.ActionProfile{
@@ -337,22 +293,6 @@ func testAccActionsExecuteAction3(t *testing.T) {
}
}
-func testAccActionsGetAccountAfterRemActions(t *testing.T) {
- accPrf := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "1001",
- Balances: map[string]*utils.Balance{},
- ThresholdIDs: []string{utils.MetaNone},
- }
- var result *utils.AccountProfile
- if err := accSRPC.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "1001"}}, &result); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(accPrf, result) {
- t.Errorf("Expecting : %s, received: %s", utils.ToJSON(accPrf), utils.ToJSON(result))
- }
-}
-
func testAccActionsKillEngine(t *testing.T) {
if err := engine.KillEngine(100); err != nil {
t.Error(err)
diff --git a/general_tests/export_it_test.go b/general_tests/export_it_test.go
index 2f3100f49..dce1b0da2 100644
--- a/general_tests/export_it_test.go
+++ b/general_tests/export_it_test.go
@@ -61,7 +61,6 @@ var (
testExpVerifyRoutes,
testExpVerifyRateProfiles,
testExpVerifyActionProfiles,
- testExpVerifyAccountProfiles,
testExpCleanFiles,
testExpStopCgrEngine,
}
@@ -509,66 +508,6 @@ func testExpVerifyActionProfiles(t *testing.T) {
}
}
-func testExpVerifyAccountProfiles(t *testing.T) {
- var reply *utils.AccountProfile
- acctPrf := &utils.AccountProfile{
- Tenant: "cgrates.org",
- ID: "ACC_PRF_1",
- FilterIDs: []string{},
- Weights: utils.DynamicWeights{
- {
- Weight: 20,
- },
- },
- Balances: map[string]*utils.Balance{
- "MonetaryBalance": {
- ID: "MonetaryBalance",
- Weights: utils.DynamicWeights{
- {
- Weight: 10,
- },
- },
- Type: "*monetary",
- CostIncrements: []*utils.CostIncrement{
- {
- FilterIDs: []string{"fltr1", "fltr2"},
- Increment: utils.NewDecimal(13, 1),
- FixedFee: utils.NewDecimal(23, 1),
- RecurrentFee: utils.NewDecimal(33, 1),
- },
- },
- AttributeIDs: []string{"attr1", "attr2"},
- UnitFactors: []*utils.UnitFactor{
- {
- FilterIDs: []string{"fltr1", "fltr2"},
- Factor: utils.NewDecimal(100, 0),
- },
- {
- FilterIDs: []string{"fltr3"},
- Factor: utils.NewDecimal(200, 0),
- },
- },
- Units: utils.NewDecimal(14, 0),
- },
- },
- ThresholdIDs: []string{"*none"},
- }
- sort.Strings(acctPrf.Balances["MonetaryBalance"].CostIncrements[0].FilterIDs)
- sort.Strings(acctPrf.Balances["MonetaryBalance"].UnitFactors[0].FilterIDs)
- sort.Strings(acctPrf.Balances["MonetaryBalance"].AttributeIDs)
- if err := expRpc.Call(utils.APIerSv1GetAccountProfile, &utils.TenantIDWithAPIOpts{
- TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ACC_PRF_1"}}, &reply); err != nil {
- t.Fatal(err)
- } else {
- sort.Strings(acctPrf.Balances["MonetaryBalance"].CostIncrements[0].FilterIDs)
- sort.Strings(acctPrf.Balances["MonetaryBalance"].UnitFactors[0].FilterIDs)
- sort.Strings(acctPrf.Balances["MonetaryBalance"].AttributeIDs)
- if !reflect.DeepEqual(acctPrf, reply) {
- t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(acctPrf), utils.ToJSON(reply))
- }
- }
-}
-
func testExpCleanFiles(t *testing.T) {
if err := os.RemoveAll("/tmp/tp/"); err != nil {
t.Error(err)
diff --git a/general_tests/filtered_replication_it_test.go b/general_tests/filtered_replication_it_test.go
index 785dd3ade..5dea677b9 100644
--- a/general_tests/filtered_replication_it_test.go
+++ b/general_tests/filtered_replication_it_test.go
@@ -66,7 +66,6 @@ var (
testFltrRplDispatcherHost,
testFltrRplRateProfile,
testFltrRplActionProfile,
- testFltrRplAccountProfile,
testFltrRplAccount,
testFltrRplDestination,
@@ -1584,127 +1583,6 @@ func testFltrRplActionProfile(t *testing.T) {
}
}
-func testFltrRplAccountProfile(t *testing.T) {
- acID := "ATTR1"
- acPrf := &utils.APIAccountProfileWithOpts{
- APIAccountProfile: &utils.APIAccountProfile{
- Tenant: "cgrates.org",
- ID: acID,
- FilterIDs: []string{"*string:~*req.Account:dan"},
- Weights: ";10",
- Balances: map[string]*utils.APIBalance{
- "Balance1": {
- 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},
- },
- }
- expPrf, err := acPrf.AsAccountProfile()
- if err != nil {
- t.Fatal(err)
- }
- var result string
- var replyPrfl *utils.AccountProfile
- var rplyIDs []string
- // empty
- if err := fltrRplEngine1RPC.Call(utils.APIerSv1GetAccountProfileIDs, &utils.PaginatorWithTenant{}, &rplyIDs); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Fatalf("Unexpected error: %v", err)
- }
- if err := fltrRplEngine2RPC.Call(utils.APIerSv1GetAccountProfileIDs, &utils.PaginatorWithTenant{}, &rplyIDs); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Fatalf("Unexpected error: %v", err)
- }
-
- if err := fltrRplInternalRPC.Call(utils.APIerSv1SetAccountProfile, acPrf, &result); err != nil {
- t.Fatal(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
- if err := fltrRplInternalRPC.Call(utils.APIerSv1GetAccountProfile,
- utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: acID}}, &replyPrfl); err != nil {
- t.Fatal(err)
- }
- if !reflect.DeepEqual(expPrf, replyPrfl) {
- t.Errorf("Expecting : %s, received: %s", utils.ToJSON(expPrf), utils.ToJSON(replyPrfl))
- }
- replyPrfl = nil
-
- if err := fltrRplEngine1RPC.Call(utils.APIerSv1GetAccountProfileIDs, &utils.PaginatorWithTenant{}, &rplyIDs); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Fatalf("Unexpected error: %v", err)
- }
- if err := fltrRplEngine2RPC.Call(utils.APIerSv1GetAccountProfileIDs, &utils.PaginatorWithTenant{}, &rplyIDs); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Fatalf("Unexpected error: %v", err)
- }
-
- if err := fltrRplEngine1RPC.Call(utils.APIerSv1GetAccountProfile,
- utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: acID}}, &replyPrfl); err != nil {
- t.Fatal(err)
- }
- if !reflect.DeepEqual(expPrf, replyPrfl) {
- t.Errorf("Expecting : %s, received: %s", utils.ToJSON(expPrf), utils.ToJSON(replyPrfl))
- }
- replyPrfl = nil
- acPrf.Weights = ";15"
- if expPrf, err = acPrf.AsAccountProfile(); err != nil {
- t.Fatal(err)
- }
- if err := fltrRplInternalRPC.Call(utils.APIerSv1SetAccountProfile, acPrf, &result); err != nil {
- t.Fatal(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
- if err := fltrRplInternalRPC.Call(utils.APIerSv1GetAccountProfile,
- utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: acID}}, &replyPrfl); err != nil {
- t.Fatal(err)
- }
- if !reflect.DeepEqual(expPrf, replyPrfl) {
- t.Errorf("Expecting : %s, received: %s", utils.ToJSON(expPrf), utils.ToJSON(replyPrfl))
- }
- replyPrfl = nil
-
- // use replicator to see if the attribute was changed in the DB
- if err := fltrRplEngine1RPC.Call(utils.ReplicatorSv1GetAccountProfile,
- utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: acID}}, &replyPrfl); err != nil {
- t.Fatal(err)
- }
- if !reflect.DeepEqual(expPrf, replyPrfl) {
- t.Errorf("Expecting : %s, received: %s", utils.ToJSON(expPrf), utils.ToJSON(replyPrfl))
- }
-
- if err := fltrRplEngine2RPC.Call(utils.APIerSv1GetAccountProfileIDs, &utils.PaginatorWithTenant{}, &rplyIDs); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Fatalf("Unexpected error: %v", err)
- }
-
- if err := fltrRplInternalRPC.Call(utils.APIerSv1RemoveAccountProfile,
- utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: acID}}, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
- if err := fltrRplEngine1RPC.Call(utils.APIerSv1GetAccountProfileIDs, &utils.PaginatorWithTenant{}, &rplyIDs); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Fatalf("Unexpected error: %v", err)
- }
- if err := fltrRplEngine2RPC.Call(utils.APIerSv1GetAccountProfileIDs, &utils.PaginatorWithTenant{}, &rplyIDs); err == nil ||
- err.Error() != utils.ErrNotFound.Error() {
- t.Fatalf("Unexpected error: %v", err)
- }
-}
-
func testFltrRplAccount(t *testing.T) {
acID := "ATTR1"
attrPrf := &v2.AttrSetAccount{Tenant: "cgrates.org", Account: acID, ExtraOptions: map[string]bool{utils.Disabled: true}}
diff --git a/services/datadb_it_test.go b/services/datadb_it_test.go
index a5b96824d..237b9c7ae 100644
--- a/services/datadb_it_test.go
+++ b/services/datadb_it_test.go
@@ -182,9 +182,6 @@ func TestDataDBReload(t *testing.T) {
utils.MetaActionProfiles: {
Replicate: false,
Remote: false},
- utils.MetaAccountProfiles: {
- Replicate: false,
- Remote: false},
},
}
if !reflect.DeepEqual(oldcfg, db.oldDBCfg) {
diff --git a/utils/apitpdata.go b/utils/apitpdata.go
index 0852ab00b..79c56abff 100755
--- a/utils/apitpdata.go
+++ b/utils/apitpdata.go
@@ -21,7 +21,6 @@ package utils
import (
"fmt"
"sort"
- "strconv"
"strings"
"time"
@@ -933,18 +932,17 @@ func (attr *ArgRSv1ResourceUsage) Clone() *ArgRSv1ResourceUsage {
}
type ArgsComputeFilterIndexIDs struct {
- Tenant string
- Context string
- AttributeIDs []string
- ResourceIDs []string
- StatIDs []string
- RouteIDs []string
- ThresholdIDs []string
- ChargerIDs []string
- DispatcherIDs []string
- RateProfileIDs []string
- AccountProfileIDs []string
- ActionProfileIDs []string
+ Tenant string
+ Context string
+ AttributeIDs []string
+ ResourceIDs []string
+ StatIDs []string
+ RouteIDs []string
+ ThresholdIDs []string
+ ChargerIDs []string
+ DispatcherIDs []string
+ RateProfileIDs []string
+ ActionProfileIDs []string
}
type ArgsComputeFilterIndexes struct {
@@ -1553,108 +1551,6 @@ type TPAPDiktat struct {
Value string
}
-type TPAccountProfile struct {
- TPid string
- Tenant string
- ID string
- FilterIDs []string
- ActivationInterval *TPActivationInterval
- Weights string
- Balances map[string]*TPAccountBalance
- ThresholdIDs []string
-}
-
-type TPAccountBalance struct {
- ID string
- FilterIDs []string
- Weights string
- Blocker bool
- Type string
- Opts string
- CostIncrement []*TPBalanceCostIncrement
- AttributeIDs []string
- RateProfileIDs []string
- UnitFactors []*TPBalanceUnitFactor
- Units float64
-}
-
-func NewTPBalanceCostIncrement(filtersStr, incrementStr, fixedFeeStr, recurrentFeeStr string) (costIncrement *TPBalanceCostIncrement, err error) {
- costIncrement = &TPBalanceCostIncrement{
- FilterIDs: strings.Split(filtersStr, ANDSep),
- }
- if incrementStr != EmptyString {
- incr, err := strconv.ParseFloat(incrementStr, 64)
- if err != nil {
- return nil, err
- }
- costIncrement.Increment = Float64Pointer(incr)
- }
- if fixedFeeStr != EmptyString {
- fixedFee, err := strconv.ParseFloat(fixedFeeStr, 64)
- if err != nil {
- return nil, err
- }
- costIncrement.FixedFee = Float64Pointer(fixedFee)
- }
- if recurrentFeeStr != EmptyString {
- recFee, err := strconv.ParseFloat(recurrentFeeStr, 64)
- if err != nil {
- return nil, err
- }
- costIncrement.RecurrentFee = Float64Pointer(recFee)
- }
- return
-}
-
-type TPBalanceCostIncrement struct {
- FilterIDs []string
- Increment *float64
- FixedFee *float64
- RecurrentFee *float64
-}
-
-func (costIncr *TPBalanceCostIncrement) AsString() (s string) {
- if len(costIncr.FilterIDs) != 0 {
- s = s + strings.Join(costIncr.FilterIDs, ANDSep)
- }
- s = s + InfieldSep
- if costIncr.Increment != nil {
- s = s + strconv.FormatFloat(*costIncr.Increment, 'f', -1, 64)
- }
- s = s + InfieldSep
- if costIncr.FixedFee != nil {
- s = s + strconv.FormatFloat(*costIncr.FixedFee, 'f', -1, 64)
- }
- s = s + InfieldSep
- if costIncr.RecurrentFee != nil {
- s = s + strconv.FormatFloat(*costIncr.RecurrentFee, 'f', -1, 64)
- }
- return
-}
-
-func NewTPBalanceUnitFactor(filtersStr, factorStr string) (unitFactor *TPBalanceUnitFactor, err error) {
- unitFactor = &TPBalanceUnitFactor{
- FilterIDs: strings.Split(filtersStr, ANDSep),
- }
- if unitFactor.Factor, err = strconv.ParseFloat(factorStr, 64); err != nil {
- return
- }
- return
-}
-
-type TPBalanceUnitFactor struct {
- FilterIDs []string
- Factor float64
-}
-
-func (unitFactor *TPBalanceUnitFactor) AsString() (s string) {
- if len(unitFactor.FilterIDs) != 0 {
- s = s + strings.Join(unitFactor.FilterIDs, ANDSep)
- }
- s = s + InfieldSep + strconv.FormatFloat(unitFactor.Factor, 'f', -1, 64)
- return
-}
-
// ArgActionSv1ScheduleActions is used in ActionSv1 methods
type ArgActionSv1ScheduleActions struct {
*CGREvent
diff --git a/utils/apitpdata_test.go b/utils/apitpdata_test.go
index 1ec45df56..f9a90c667 100644
--- a/utils/apitpdata_test.go
+++ b/utils/apitpdata_test.go
@@ -1162,84 +1162,6 @@ func TestUsage(t *testing.T) {
}
}
-func TestNewTPBalanceCostIncrement(t *testing.T) {
- incrementStr := "20"
- fixedFeeStr := "10"
- recurentFeeStr := "0.4"
- filterStr := "*string:*Account:1001"
- expected := &TPBalanceCostIncrement{
- FilterIDs: []string{"*string:*Account:1001"},
- Increment: Float64Pointer(20),
- FixedFee: Float64Pointer(10),
- RecurrentFee: Float64Pointer(0.4),
- }
- if rcv, err := NewTPBalanceCostIncrement(filterStr, incrementStr, fixedFeeStr, recurentFeeStr); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(rcv, expected) {
- t.Errorf("Expected %+v, received %+v", expected, rcv)
- }
-}
-
-func TestNewTPBalanceCostIncrementErrors(t *testing.T) {
- invalidStr := "not_float64"
- expectedErr := "strconv.ParseFloat: parsing \"not_float64\": invalid syntax"
- if _, err := NewTPBalanceCostIncrement(EmptyString, invalidStr, EmptyString, EmptyString); err == nil || err.Error() != expectedErr {
- t.Errorf("Expected %+v, received %+v", expectedErr, err)
- }
- if _, err := NewTPBalanceCostIncrement(EmptyString, EmptyString, invalidStr, EmptyString); err == nil || err.Error() != expectedErr {
- t.Errorf("Expected %+v, received %+v", expectedErr, err)
- }
- if _, err := NewTPBalanceCostIncrement(EmptyString, EmptyString, EmptyString, invalidStr); err == nil || err.Error() != expectedErr {
- t.Errorf("Expected %+v, received %+v", expectedErr, err)
- }
-}
-
-func TestTPBalanceCostIncrementAsString(t *testing.T) {
- costIncr := &TPBalanceCostIncrement{
- FilterIDs: []string{"*string:*Account:1001"},
- Increment: Float64Pointer(20),
- FixedFee: Float64Pointer(10),
- RecurrentFee: Float64Pointer(0.4),
- }
- expected := "*string:*Account:1001;20;10;0.4"
- if rcv := costIncr.AsString(); expected != rcv {
- t.Errorf("Expected %+v, received %+v", expected, rcv)
- }
-}
-
-func TestNewBalanceUnitFactor(t *testing.T) {
- factorStr := "1.7"
- filterStr := "*string:*Account:1001"
- expected := &TPBalanceUnitFactor{
- FilterIDs: []string{"*string:*Account:1001"},
- Factor: 1.7,
- }
- if rcv, err := NewTPBalanceUnitFactor(filterStr, factorStr); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expected, rcv) {
- t.Errorf("Expected %+v, received %+v", expected, rcv)
- }
-}
-
-func TestNewBalanceUnitFactorError(t *testing.T) {
- invalidStr := "not_float64"
- expectedErr := "strconv.ParseFloat: parsing \"not_float64\": invalid syntax"
- if _, err := NewTPBalanceUnitFactor(EmptyString, invalidStr); err == nil || err.Error() != expectedErr {
- t.Errorf("Expected %+v, received %+v", expectedErr, err)
- }
-}
-
-func TestBalanceUnitFactor(t *testing.T) {
- unitFctr := &TPBalanceUnitFactor{
- FilterIDs: []string{"*string:*Account:1001"},
- Factor: 1.7,
- }
- expected := "*string:*Account:1001;1.7"
- if rcv := unitFctr.AsString(); expected != rcv {
- t.Errorf("Expected %+v, received %+v", expected, rcv)
- }
-}
-
func TestATDUsage(t *testing.T) {
args := &ArgsCostForEvent{
CGREvent: &CGREvent{