From 83d9c67a7717f12cd293c117dca140c86284863c Mon Sep 17 00:00:00 2001 From: andronache Date: Tue, 16 Mar 2021 09:12:23 +0200 Subject: [PATCH] Removed cache from multiple structs and replaced it with opts --- agents/diam_it_test.go | 4 +- apier/v1/accountsv1_it_test.go | 15 +- apier/v1/actions.go | 5 - apier/v1/actions_it_test.go | 30 ++- apier/v1/apier_it_test.go | 2 +- apier/v1/chargers.go | 6 - apier/v1/chargers_it_test.go | 16 +- apier/v1/cost_bench_it_test.go | 66 ++++--- apier/v1/dispatcher.go | 12 -- apier/v1/dispatcher_it_test.go | 12 +- apier/v1/ees_it_test.go | 2 +- apier/v1/filter_indexes_it_test.go | 174 ++++++++---------- apier/v1/filterindexecache_it_test.go | 6 +- apier/v1/full_remote_it_test.go | 86 +++++---- apier/v1/rateprofiles.go | 5 - apier/v1/rateprofiles_it_test.go | 145 +++++++-------- apier/v1/remote_it_test.go | 54 +++--- apier/v1/replicate_it_test.go | 12 +- apier/v1/routes.go | 7 +- apier/v1/routes_it_test.go | 12 +- apier/v1/stats_it_test.go | 4 +- apier/v1/thresholds.go | 2 +- apier/v1/thresholds_it_test.go | 16 +- apier/v2/cdrs_it_test.go | 20 +- apier/v2/cdrs_offline_it_test.go | 4 +- console/routes_profile_set.go | 6 +- console/thresholds_profile_set.go | 6 +- engine/thresholds.go | 7 - engine/z_actions_it_test.go | 6 +- ers/filefwv_it_test.go | 2 +- ers/filejson_it_test.go | 6 +- ers/flatstore_it_test.go | 2 +- ers/partial_csv_it_test.go | 2 +- general_tests/a1_it_test.go | 2 +- general_tests/accountactions_it_test.go | 161 ++++++++-------- general_tests/accounts_it_test.go | 2 +- general_tests/cacherpl_it_test.go | 4 +- general_tests/cdrs_exp_it_test.go | 2 +- general_tests/cdrs_it_test.go | 2 +- general_tests/cdrs_processevent_it_test.go | 2 +- general_tests/export_it_test.go | 2 +- general_tests/filtered_replication_it_test.go | 62 +++---- general_tests/filters_it_test.go | 14 +- general_tests/gocs_it_test.go | 2 +- general_tests/route_it_test.go | 8 +- general_tests/rpccaching_it_test.go | 4 +- general_tests/twoengines_it_test.go | 10 +- 47 files changed, 479 insertions(+), 552 deletions(-) diff --git a/agents/diam_it_test.go b/agents/diam_it_test.go index c5d2eaee8..53ce5cede 100644 --- a/agents/diam_it_test.go +++ b/agents/diam_it_test.go @@ -1454,7 +1454,7 @@ func testDiamItEmulateTerminate(t *testing.T) { } var result string //add the second charger - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.com", ID: "CustomCharger", @@ -1470,7 +1470,7 @@ func testDiamItEmulateTerminate(t *testing.T) { t.Error("Unexpected reply returned", result) } //add the second charger - chargerProfile2 := &v1.ChargerWithCache{ + chargerProfile2 := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.com", ID: "Default", diff --git a/apier/v1/accountsv1_it_test.go b/apier/v1/accountsv1_it_test.go index 34e66ea2e..42ad480a0 100644 --- a/apier/v1/accountsv1_it_test.go +++ b/apier/v1/accountsv1_it_test.go @@ -803,9 +803,8 @@ func testAccountSv1DebitWithAttributeSandRateS(t *testing.T) { } if err := acntSRPC.Call(utils.APIerSv1SetRateProfile, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: apiRPrf}, + &engine.APIRateProfileWithOpts{ + APIRateProfile: apiRPrf, }, &reply); err != nil { t.Fatal(err) } else if reply != utils.OK { @@ -901,9 +900,8 @@ func testAccountSv1DebitWithRateS(t *testing.T) { } if err := acntSRPC.Call(utils.APIerSv1SetRateProfile, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: apiRPrf}, + &engine.APIRateProfileWithOpts{ + APIRateProfile: apiRPrf, }, &reply); err != nil { t.Fatal(err) } else if reply != utils.OK { @@ -1006,9 +1004,8 @@ func testAccountSv1DebitWithRateS2(t *testing.T) { } if err := acntSRPC.Call(utils.APIerSv1SetRateProfile, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: apiRPrf}, + &engine.APIRateProfileWithOpts{ + APIRateProfile: apiRPrf, }, &reply); err != nil { t.Fatal(err) } else if reply != utils.OK { diff --git a/apier/v1/actions.go b/apier/v1/actions.go index 29ca412d4..51d84217e 100644 --- a/apier/v1/actions.go +++ b/apier/v1/actions.go @@ -88,11 +88,6 @@ func (apierSv1 *APIerSv1) GetActionProfileIDsCount(args *utils.TenantWithOpts, r return } -type ActionProfileWithCache struct { - *engine.ActionProfileWithOpts - Cache *string -} - //SetActionProfile add/update a new Action Profile func (apierSv1 *APIerSv1) SetActionProfile(ap *engine.ActionProfileWithOpts, reply *string) error { if missing := utils.MissingStructFields(ap.ActionProfile, []string{utils.ID, utils.Actions}); len(missing) != 0 { diff --git a/apier/v1/actions_it_test.go b/apier/v1/actions_it_test.go index c0e845c22..40357bac0 100644 --- a/apier/v1/actions_it_test.go +++ b/apier/v1/actions_it_test.go @@ -36,7 +36,7 @@ var ( actPrfCfgPath string actPrfCfg *config.CGRConfig actSRPC *rpc.Client - actPrf *ActionProfileWithCache + actPrf *engine.ActionProfileWithOpts actPrfConfigDIR string //run tests for specific configuration sTestsActPrf = []func(t *testing.T){ @@ -216,24 +216,22 @@ func testActionSPing(t *testing.T) { } func testActionSSettActionProfile(t *testing.T) { - actPrf = &ActionProfileWithCache{ - ActionProfileWithOpts: &engine.ActionProfileWithOpts{ - ActionProfile: &engine.ActionProfile{ - Tenant: "tenant_test", - ID: "id_test", - Actions: []*engine.APAction{ - { - ID: "test_action_id", - Diktats: []*engine.APDiktat{{}}, - }, - { - ID: "test_action_id2", - Diktats: []*engine.APDiktat{{}}, - }, + actPrf = &engine.ActionProfileWithOpts{ + ActionProfile: &engine.ActionProfile{ + Tenant: "tenant_test", + ID: "id_test", + Actions: []*engine.APAction{ + { + ID: "test_action_id", + Diktats: []*engine.APDiktat{{}}, + }, + { + ID: "test_action_id2", + Diktats: []*engine.APDiktat{{}}, }, }, - Opts: map[string]interface{}{}, }, + Opts: map[string]interface{}{}, } var result string expErr := utils.ErrNotFound.Error() diff --git a/apier/v1/apier_it_test.go b/apier/v1/apier_it_test.go index bfb3021ca..a1c736f21 100644 --- a/apier/v1/apier_it_test.go +++ b/apier/v1/apier_it_test.go @@ -1681,7 +1681,7 @@ func testApierResetDataAfterLoadFromFolder(t *testing.T) { func testApierSetChargerS(t *testing.T) { //add a default charger - chargerProfile := &ChargerWithCache{ + chargerProfile := &ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "Default", diff --git a/apier/v1/chargers.go b/apier/v1/chargers.go index fbf449343..c8951deda 100644 --- a/apier/v1/chargers.go +++ b/apier/v1/chargers.go @@ -64,12 +64,6 @@ func (apierSv1 *APIerSv1) GetChargerProfileIDs(args *utils.PaginatorWithTenant, return nil } -type ChargerWithCache struct { - *engine.ChargerProfile - Cache *string - Opts map[string]interface{} -} - type ChargerWithOpts struct { *engine.ChargerProfile Opts map[string]interface{} diff --git a/apier/v1/chargers_it_test.go b/apier/v1/chargers_it_test.go index 6be58d8dc..a8fd1309a 100755 --- a/apier/v1/chargers_it_test.go +++ b/apier/v1/chargers_it_test.go @@ -37,7 +37,7 @@ var ( chargerCfgPath string chargerCfg *config.CGRConfig chargerRPC *rpc.Client - chargerProfile *ChargerWithCache + chargerProfile *ChargerWithOpts chargerConfigDIR string //run tests for specific configuration chargerEvent = []*utils.CGREvent{ @@ -149,7 +149,7 @@ func testChargerSRPCConn(t *testing.T) { } func testChargerSLoadAddCharger(t *testing.T) { - chargerProfile := &ChargerWithCache{ + chargerProfile := &ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "Charger1", @@ -169,7 +169,7 @@ func testChargerSLoadAddCharger(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - chargerProfile = &ChargerWithCache{ + chargerProfile = &ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "Charger2", @@ -189,7 +189,7 @@ func testChargerSLoadAddCharger(t *testing.T) { t.Error("Unexpected reply returned", result) } - chargerProfile = &ChargerWithCache{ + chargerProfile = &ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "ChargerNotMatching", @@ -367,7 +367,7 @@ func testChargerSProcessEvent(t *testing.T) { } func testChargerSSetChargerProfile(t *testing.T) { - chargerProfile = &ChargerWithCache{ + chargerProfile = &ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "ApierTest", @@ -478,7 +478,7 @@ func testChargerSPing(t *testing.T) { func testChargerSProcessWithNotFoundAttribute(t *testing.T) { var result string - chargerProfile = &ChargerWithCache{ + chargerProfile = &ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "ChargerWithoutAttribute", @@ -540,7 +540,7 @@ func testChargerSKillEngine(t *testing.T) { } func testChargerSProccessEventWithProcceSRunS(t *testing.T) { - chargerProfile = &ChargerWithCache{ + chargerProfile = &ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "ApierTest", @@ -604,7 +604,7 @@ func testChargerSProccessEventWithProcceSRunS(t *testing.T) { } func testChargerSSetChargerProfileWithoutTenant(t *testing.T) { - chargerProfile = &ChargerWithCache{ + chargerProfile = &ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ ID: "randomID", FilterIDs: []string{"*string:~*req.Account:1010"}, diff --git a/apier/v1/cost_bench_it_test.go b/apier/v1/cost_bench_it_test.go index d629a9a15..e11fbb386 100644 --- a/apier/v1/cost_bench_it_test.go +++ b/apier/v1/cost_bench_it_test.go @@ -95,31 +95,29 @@ func testCostBenchLoadFromFolder2(b *testing.B) { } func testCostBenchSetRateProfile(b *testing.B) { - rPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: &engine.APIRateProfile{ - ID: "DefaultRate", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - Weights: ";10", - Rates: map[string]*engine.APIRate{ - "RATE1": &engine.APIRate{ - ID: "RATE1", - Weights: ";0", - ActivationTimes: "* * * * *", - IntervalRates: []*engine.APIIntervalRate{ - { - IntervalStart: "0", - FixedFee: utils.Float64Pointer(0.4), - RecurrentFee: utils.Float64Pointer(0.2), - Unit: utils.Float64Pointer(60000000000), - Increment: utils.Float64Pointer(60000000000), - }, - { - IntervalStart: "1m", - RecurrentFee: utils.Float64Pointer(0.1), - Unit: utils.Float64Pointer(60000000000), - Increment: utils.Float64Pointer(1000000000), - }, + rPrf := &engine.APIRateProfileWithOpts{ + APIRateProfile: &engine.APIRateProfile{ + ID: "DefaultRate", + FilterIDs: []string{"*string:~*req.Subject:1001"}, + Weights: ";10", + Rates: map[string]*engine.APIRate{ + "RATE1": &engine.APIRate{ + ID: "RATE1", + Weights: ";0", + ActivationTimes: "* * * * *", + IntervalRates: []*engine.APIIntervalRate{ + { + IntervalStart: "0", + FixedFee: utils.Float64Pointer(0.4), + RecurrentFee: utils.Float64Pointer(0.2), + Unit: utils.Float64Pointer(60000000000), + Increment: utils.Float64Pointer(60000000000), + }, + { + IntervalStart: "1m", + RecurrentFee: utils.Float64Pointer(0.1), + Unit: utils.Float64Pointer(60000000000), + Increment: utils.Float64Pointer(1000000000), }, }, }, @@ -165,16 +163,14 @@ func testCostBenchSetRateProfile2(b *testing.B) { Increment: utils.Float64Pointer(1000000000), }}, } - rPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: &engine.APIRateProfile{ - ID: "RateChristmas", - FilterIDs: []string{"*string:~*req.Subject:1010"}, - Weights: ";50", - Rates: map[string]*engine.APIRate{ - "RATE1": rate1, - "RATE_CHRISTMAS": rtChristmas, - }, + rPrf := &engine.APIRateProfileWithOpts{ + APIRateProfile: &engine.APIRateProfile{ + ID: "RateChristmas", + FilterIDs: []string{"*string:~*req.Subject:1010"}, + Weights: ";50", + Rates: map[string]*engine.APIRate{ + "RATE1": rate1, + "RATE_CHRISTMAS": rtChristmas, }, }, } diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index d89ba13b5..249dafa6f 100755 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -68,12 +68,6 @@ func (apierSv1 *APIerSv1) GetDispatcherProfileIDs(tenantArg *utils.PaginatorWith return nil } -type DispatcherWithCache struct { - *engine.DispatcherProfile - Cache *string - Opts map[string]interface{} -} - type DispatcherWithOpts struct { *engine.DispatcherProfile Opts map[string]interface{} @@ -168,12 +162,6 @@ func (apierSv1 *APIerSv1) GetDispatcherHostIDs(tenantArg *utils.PaginatorWithTen return nil } -type DispatcherHostWithCache struct { - *engine.DispatcherHost - Cache *string - Opts map[string]interface{} -} - //SetDispatcherHost add/update a new Dispatcher Host func (apierSv1 *APIerSv1) SetDispatcherHost(args *engine.DispatcherHostWithOpts, reply *string) error { if missing := utils.MissingStructFields(args.DispatcherHost, []string{utils.ID}); len(missing) != 0 { diff --git a/apier/v1/dispatcher_it_test.go b/apier/v1/dispatcher_it_test.go index bede78c1b..b76129ba8 100644 --- a/apier/v1/dispatcher_it_test.go +++ b/apier/v1/dispatcher_it_test.go @@ -37,8 +37,8 @@ var ( dispatcherCfgPath string dispatcherCfg *config.CGRConfig dispatcherRPC *rpc.Client - dispatcherProfile *DispatcherWithCache - dispatcherHost *DispatcherHostWithCache + dispatcherProfile *DispatcherWithOpts + dispatcherHost *engine.DispatcherHostWithOpts dispatcherConfigDIR string //run tests for specific configuration sTestsDispatcher = []func(t *testing.T){ @@ -129,7 +129,7 @@ func testDispatcherSRPCConn(t *testing.T) { func testDispatcherSSetDispatcherProfile(t *testing.T) { var reply string - dispatcherProfile = &DispatcherWithCache{ + dispatcherProfile = &DispatcherWithOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "Dsp1", @@ -262,7 +262,7 @@ func testDispatcherSSetDispatcherHost(t *testing.T) { t.Error(err) } - dispatcherHost = &DispatcherHostWithCache{ + dispatcherHost = &engine.DispatcherHostWithOpts{ DispatcherHost: &engine.DispatcherHost{ Tenant: "cgrates.org", RemoteHost: &config.RemoteHost{ @@ -375,7 +375,7 @@ func testDispatcherSKillEngine(t *testing.T) { } func testDispatcherSSetDispatcherProfileWithoutTenant(t *testing.T) { - dispatcherProfile = &DispatcherWithCache{ + dispatcherProfile = &DispatcherWithOpts{ DispatcherProfile: &engine.DispatcherProfile{ ID: "Dsp1", FilterIDs: []string{"*string:~*req.Account:1001"}, @@ -418,7 +418,7 @@ func testDispatcherSRemDispatcherProfileWithoutTenant(t *testing.T) { } func testDispatcherSSetDispatcherHostWithoutTenant(t *testing.T) { - dispatcherHost = &DispatcherHostWithCache{ + dispatcherHost = &engine.DispatcherHostWithOpts{ DispatcherHost: &engine.DispatcherHost{ RemoteHost: &config.RemoteHost{ ID: "DspHst7", diff --git a/apier/v1/ees_it_test.go b/apier/v1/ees_it_test.go index 109f9609b..49ab0a90a 100644 --- a/apier/v1/ees_it_test.go +++ b/apier/v1/ees_it_test.go @@ -125,7 +125,7 @@ func testEEsRPCConn(t *testing.T) { func testEEsAddCDRs(t *testing.T) { //add a default charger - chargerProfile := &ChargerWithCache{ + chargerProfile := &ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "Default", diff --git a/apier/v1/filter_indexes_it_test.go b/apier/v1/filter_indexes_it_test.go index e84f201f8..73455c3c3 100644 --- a/apier/v1/filter_indexes_it_test.go +++ b/apier/v1/filter_indexes_it_test.go @@ -208,7 +208,7 @@ func testV1FIdxSetThresholdProfile(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl = &engine.ThresholdWithCache{ + tPrfl = &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: tenant, ID: "TEST_PROFILE1", @@ -304,7 +304,7 @@ func testV1FIdxSetSecondThresholdProfile(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl = &engine.ThresholdWithCache{ + tPrfl = &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: tenant, ID: "TEST_PROFILE2", @@ -947,7 +947,7 @@ func testV1FIdxSetRouteProfileIndexes(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - rPrf := &RouteWithCache{ + rPrf := &RouteWithOpts{ RouteProfile: &engine.RouteProfile{ Tenant: tenant, ID: "TEST_PROFILE1", @@ -1045,7 +1045,7 @@ func testV1FIdxSetSecondRouteProfileIndexes(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - rPrf := &RouteWithCache{ + rPrf := &RouteWithOpts{ RouteProfile: &engine.RouteProfile{ Tenant: tenant, ID: "TEST_PROFILE2", @@ -1460,23 +1460,21 @@ func testV1FISetActionProfileIndexes(t *testing.T) { } //set an actPrf in db, so we will get it without any problems - actPrf := &ActionProfileWithCache{ - ActionProfileWithOpts: &engine.ActionProfileWithOpts{ - ActionProfile: &engine.ActionProfile{ - Tenant: tenant, - ID: "ACT_PRF", - FilterIDs: []string{"*prefix:~*req.Account:1001|1002", "ACTION_FLTR"}, - Schedule: "* * * * *", - Actions: []*engine.APAction{ - { - ID: "TOPUP", - FilterIDs: []string{}, - Type: utils.MetaLog, - Diktats: []*engine.APDiktat{{ - Path: "~*balance.TestBalance.Value", - Value: "10", - }}, - }, + actPrf := &engine.ActionProfileWithOpts{ + ActionProfile: &engine.ActionProfile{ + Tenant: tenant, + ID: "ACT_PRF", + FilterIDs: []string{"*prefix:~*req.Account:1001|1002", "ACTION_FLTR"}, + Schedule: "* * * * *", + Actions: []*engine.APAction{ + { + ID: "TOPUP", + FilterIDs: []string{}, + Type: utils.MetaLog, + Diktats: []*engine.APDiktat{{ + Path: "~*balance.TestBalance.Value", + Value: "10", + }}, }, }, }, @@ -1619,18 +1617,16 @@ func testVF1SetSecondActionProfile(t *testing.T) { } //set the second actPrf in db with our filter - actPrf := &ActionProfileWithCache{ - ActionProfileWithOpts: &engine.ActionProfileWithOpts{ - ActionProfile: &engine.ActionProfile{ - Tenant: tenant, - ID: "ACT_PRF2", - FilterIDs: []string{"ACTION_FLTR2"}, - Actions: []*engine.APAction{ - { - ID: "TORESET", - FilterIDs: []string{}, - Type: utils.MetaLog, - }, + actPrf := &engine.ActionProfileWithOpts{ + ActionProfile: &engine.ActionProfile{ + Tenant: tenant, + ID: "ACT_PRF2", + FilterIDs: []string{"ACTION_FLTR2"}, + Actions: []*engine.APAction{ + { + ID: "TORESET", + FilterIDs: []string{}, + Type: utils.MetaLog, }, }, }, @@ -1814,24 +1810,22 @@ func testV1FISetRateProfileRatesIndexes(t *testing.T) { } //set in db a ratePrf with double populated rates with our filter - ratePrfRates := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: &engine.APIRateProfile{ - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: []string{"*string:~*req.Usage:10m"}, - MaxCostStrategy: "*free", - Rates: map[string]*engine.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - FilterIDs: []string{"RATE_FLTR1", "*suffix:~*req.Account:1009"}, - ActivationTimes: "* * * * 1-5", - }, - "RT_MONTH": { - ID: "RT_MONTH", - FilterIDs: []string{"RATE_FLTR1"}, - ActivationTimes: "* * * * *", - }, + ratePrfRates := &engine.APIRateProfileWithOpts{ + APIRateProfile: &engine.APIRateProfile{ + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: []string{"*string:~*req.Usage:10m"}, + MaxCostStrategy: "*free", + Rates: map[string]*engine.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + FilterIDs: []string{"RATE_FLTR1", "*suffix:~*req.Account:1009"}, + ActivationTimes: "* * * * 1-5", + }, + "RT_MONTH": { + ID: "RT_MONTH", + FilterIDs: []string{"RATE_FLTR1"}, + ActivationTimes: "* * * * *", }, }, }, @@ -1994,19 +1988,17 @@ func testV1FISetSecondRateProfileRate(t *testing.T) { } //append a new rate in the same rate profile - ratePrfRates := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: &engine.APIRateProfile{ - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: []string{"*string:~*req.Usage:10m"}, - MaxCostStrategy: "*free", - Rates: map[string]*engine.APIRate{ - "RT_YEAR": { - ID: "RT_YEAR", - FilterIDs: []string{"RTPRF_FLTR3"}, - ActivationTimes: "* * * * *", - }, + ratePrfRates := &engine.APIRateProfileWithOpts{ + APIRateProfile: &engine.APIRateProfile{ + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: []string{"*string:~*req.Usage:10m"}, + MaxCostStrategy: "*free", + Rates: map[string]*engine.APIRate{ + "RT_YEAR": { + ID: "RT_YEAR", + FilterIDs: []string{"RTPRF_FLTR3"}, + ActivationTimes: "* * * * *", }, }, }, @@ -2243,19 +2235,17 @@ func testV1FISetRateProfileIndexes(t *testing.T) { t.Error(err) } //set in db a ratePrf with with our filterS - ratePrfRates := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: &engine.APIRateProfile{ - Tenant: "cgrates.org", - ID: "RP2", - FilterIDs: []string{"*string:~*req.Usage:10m", "RATEFLTR_FLTR1"}, - MaxCostStrategy: "*free", - Rates: map[string]*engine.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - FilterIDs: []string{"*suffix:~*req.Account:1009"}, - ActivationTimes: "* * * * 1-5", - }, + ratePrfRates := &engine.APIRateProfileWithOpts{ + APIRateProfile: &engine.APIRateProfile{ + Tenant: "cgrates.org", + ID: "RP2", + FilterIDs: []string{"*string:~*req.Usage:10m", "RATEFLTR_FLTR1"}, + MaxCostStrategy: "*free", + Rates: map[string]*engine.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + FilterIDs: []string{"*suffix:~*req.Account:1009"}, + ActivationTimes: "* * * * 1-5", }, }, }, @@ -2420,19 +2410,17 @@ func testV1FISetSecondRateProfile(t *testing.T) { } //another rate profile - ratePrfRates := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: &engine.APIRateProfile{ - Tenant: "cgrates.org", - ID: "RP3", - FilterIDs: []string{"RTPRF_FLTR6"}, - MaxCostStrategy: "*free", - Rates: map[string]*engine.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - FilterIDs: []string{"*suffix:~*req.Account:1019"}, - ActivationTimes: "* * * * 1-5", - }, + ratePrfRates := &engine.APIRateProfileWithOpts{ + APIRateProfile: &engine.APIRateProfile{ + Tenant: "cgrates.org", + ID: "RP3", + FilterIDs: []string{"RTPRF_FLTR6"}, + MaxCostStrategy: "*free", + Rates: map[string]*engine.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + FilterIDs: []string{"*suffix:~*req.Account:1019"}, + ActivationTimes: "* * * * 1-5", }, }, }, @@ -3053,7 +3041,7 @@ func testV1FIdxGetFilterIndexes4(t *testing.T) { func testV1FIdxSetDispatcherProfile(t *testing.T) { var reply string //add a dispatcherProfile for 2 subsystems and verify if the index was created for both - dispatcherProfile = &DispatcherWithCache{ + dispatcherProfile = &DispatcherWithOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "DSP_Test1", @@ -3196,7 +3184,7 @@ func testV1FIdxSetDispatcherProfile2(t *testing.T) { var reply string //add a new dispatcherProfile with empty filterIDs //should create an index of type *none:*any:*any for *attributes subsystem - dispatcherProfile = &DispatcherWithCache{ + dispatcherProfile = &DispatcherWithOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "DSP_Test2", @@ -3215,7 +3203,7 @@ func testV1FIdxSetDispatcherProfile2(t *testing.T) { //add a new dispatcherProfile with empty filterIDs //should create an index of type *none:*any:*any for *sessions subsystem - dispatcherProfile2 := DispatcherWithCache{ + dispatcherProfile2 := DispatcherWithOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "DSP_Test3", diff --git a/apier/v1/filterindexecache_it_test.go b/apier/v1/filterindexecache_it_test.go index 1d4c9290d..32771ddf6 100644 --- a/apier/v1/filterindexecache_it_test.go +++ b/apier/v1/filterindexecache_it_test.go @@ -190,7 +190,7 @@ func testV1FIdxCaSetThresholdProfile(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - tPrfl = &engine.ThresholdWithCache{ + tPrfl = &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TEST_PROFILE1", @@ -295,7 +295,7 @@ func testV1FIdxCaUpdateThresholdProfile(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - tPrfl = &engine.ThresholdWithCache{ + tPrfl = &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TEST_PROFILE1", @@ -402,7 +402,7 @@ func testV1FIdxCaUpdateThresholdProfileFromTP(t *testing.T) { } reply.FilterIDs = []string{"TestFilter3"} - if err := tFIdxCaRpc.Call(utils.APIerSv1SetThresholdProfile, &engine.ThresholdWithCache{ThresholdProfile: reply}, &result); err != nil { + if err := tFIdxCaRpc.Call(utils.APIerSv1SetThresholdProfile, &engine.ThresholdProfileWithOpts{ThresholdProfile: reply}, &result); err != nil { t.Error(err) } else if result != utils.OK { t.Error("Unexpected reply returned", result) diff --git a/apier/v1/full_remote_it_test.go b/apier/v1/full_remote_it_test.go index 82d6f8624..07b0b25b5 100644 --- a/apier/v1/full_remote_it_test.go +++ b/apier/v1/full_remote_it_test.go @@ -259,7 +259,7 @@ func testFullRemoteITThreshold(t *testing.T) { } var replySet string - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", @@ -546,7 +546,7 @@ func testFullRemoteITDispatcher(t *testing.T) { } var replySet string - dispatcherProfile = &DispatcherWithCache{ + dispatcherProfile = &DispatcherWithOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "Dsp1", @@ -596,30 +596,28 @@ func testFullRemoteITRate(t *testing.T) { } var replySet string - apiRPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: &engine.APIRateProfile{ - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - Weights: ";0", - MaxCostStrategy: "*free", - Rates: map[string]*engine.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - Weights: ";0", - ActivationTimes: "* * * * 1-5", - }, - "RT_WEEKEND": { - ID: "RT_WEEKEND", - Weights: ";10", - ActivationTimes: "* * * * 0,6", - }, - "RT_CHRISTMAS": { - ID: "RT_CHRISTMAS", - Weights: ";30", - ActivationTimes: "* * 24 12 *", - }, + apiRPrf := &engine.APIRateProfileWithOpts{ + APIRateProfile: &engine.APIRateProfile{ + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: []string{"*string:~*req.Subject:1001"}, + Weights: ";0", + MaxCostStrategy: "*free", + Rates: map[string]*engine.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + Weights: ";0", + ActivationTimes: "* * * * 1-5", + }, + "RT_WEEKEND": { + ID: "RT_WEEKEND", + Weights: ";10", + ActivationTimes: "* * * * 0,6", + }, + "RT_CHRISTMAS": { + ID: "RT_CHRISTMAS", + Weights: ";30", + ActivationTimes: "* * 24 12 *", }, }, }, @@ -676,24 +674,22 @@ func testFullRemoteITAction(t *testing.T) { } var replySet string - actPrf = &ActionProfileWithCache{ - ActionProfileWithOpts: &engine.ActionProfileWithOpts{ - ActionProfile: &engine.ActionProfile{ - Tenant: "cgrates.org", - ID: "ACT_1", - Actions: []*engine.APAction{ - { - ID: "test_action_id", - Diktats: []*engine.APDiktat{{}}, - }, - { - ID: "test_action_id2", - Diktats: []*engine.APDiktat{{}}, - }, + actPrf = &engine.ActionProfileWithOpts{ + ActionProfile: &engine.ActionProfile{ + Tenant: "cgrates.org", + ID: "ACT_1", + Actions: []*engine.APAction{ + { + ID: "test_action_id", + Diktats: []*engine.APDiktat{{}}, + }, + { + ID: "test_action_id2", + Diktats: []*engine.APDiktat{{}}, }, }, - Opts: map[string]interface{}{}, }, + Opts: map[string]interface{}{}, } // add a threshold profile in engine1 and verify it internal if err := fullRemEngineOneRPC.Call(utils.APIerSv1SetActionProfile, actPrf, &replySet); err != nil { @@ -706,8 +702,8 @@ func testFullRemoteITAction(t *testing.T) { utils.TenantIDWithOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ACT_1"}}, &reply); err != nil { t.Fatal(err) - } else if !reflect.DeepEqual(actPrf.ActionProfileWithOpts.ActionProfile, reply) { - t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(actPrf.ActionProfileWithOpts.ActionProfile), utils.ToJSON(reply)) + } else if !reflect.DeepEqual(actPrf.ActionProfile, reply) { + t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(actPrf.ActionProfile), utils.ToJSON(reply)) } // update the threshold profile and verify it to be updated actPrf.FilterIDs = []string{"*string:~*req.Account:1001", "*string:~*req.Destination:1002"} @@ -720,8 +716,8 @@ func testFullRemoteITAction(t *testing.T) { utils.TenantIDWithOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ACT_1"}}, &reply); err != nil { t.Fatal(err) - } else if !reflect.DeepEqual(actPrf.ActionProfileWithOpts.ActionProfile, reply) { - t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(actPrf.ActionProfileWithOpts.ActionProfile), utils.ToJSON(reply)) + } else if !reflect.DeepEqual(actPrf.ActionProfile, reply) { + t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(actPrf.ActionProfile), utils.ToJSON(reply)) } } diff --git a/apier/v1/rateprofiles.go b/apier/v1/rateprofiles.go index fc567fb3d..95ba73a1d 100644 --- a/apier/v1/rateprofiles.go +++ b/apier/v1/rateprofiles.go @@ -88,11 +88,6 @@ func (apierSv1 *APIerSv1) GetRateProfileIDsCount(args *utils.TenantWithOpts, rep return } -type APIRateProfileWithCache struct { - *engine.APIRateProfileWithOpts - Cache *string -} - //SetRateProfile add/update a new Rate Profile func (apierSv1 *APIerSv1) SetRateProfile(ext *engine.APIRateProfileWithOpts, reply *string) error { if missing := utils.MissingStructFields(ext.APIRateProfile, []string{utils.ID, utils.Rates}); len(missing) != 0 { diff --git a/apier/v1/rateprofiles_it_test.go b/apier/v1/rateprofiles_it_test.go index 1494946cb..4b2f03728 100644 --- a/apier/v1/rateprofiles_it_test.go +++ b/apier/v1/rateprofiles_it_test.go @@ -297,17 +297,15 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { var reply string expErr := "SERVER_ERROR: broken reference to filter: *wrong:inline for item with ID: cgrates.org:RP1" if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfile, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: apiRPrf}, + &engine.APIRateProfileWithOpts{ + APIRateProfile: apiRPrf, }, &reply); err == nil || err.Error() != expErr { t.Fatalf("Expected error: %q, received: %v", expErr, err) } apiRPrf.FilterIDs = []string{"*string:~*req.Subject:1001"} if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfile, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: apiRPrf}, + &engine.APIRateProfileWithOpts{ + APIRateProfile: apiRPrf, }, &reply); err != nil { t.Fatal(err) } else if reply != utils.OK { @@ -357,18 +355,16 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { apiRPrfRates.Rates["RT_WEEK"].FilterIDs = []string{"*wrong:inline"} expErr = "SERVER_ERROR: broken reference to filter: *wrong:inline for rate with ID: RT_WEEK" if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfileRates, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: apiRPrfRates}, + &engine.APIRateProfileWithOpts{ + APIRateProfile: apiRPrfRates, }, &reply); err == nil || err.Error() != expErr { t.Fatalf("Expected error: %q, received: %v", expErr, err) } apiRPrfRates.Rates["RT_WEEK"].FilterIDs = nil if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfileRates, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: apiRPrfRates}, + &engine.APIRateProfileWithOpts{ + APIRateProfile: apiRPrfRates, }, &reply); err != nil { t.Fatal(err) } else if reply != utils.OK { @@ -488,9 +484,8 @@ func testV1RatePrfRemoveRateProfileRates(t *testing.T) { } var reply string if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfile, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: apiRPrf}, + &engine.APIRateProfileWithOpts{ + APIRateProfile: apiRPrf, }, &reply); err != nil { t.Fatal(err) } else if reply != utils.OK { @@ -638,22 +633,20 @@ func testV1RateGetRemoveRateProfileWithoutTenant(t *testing.T) { if *encoding == utils.MetaGOB { rateProfile.Rates["RT_WEEK"].FilterIDs = nil } - apiRPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: &engine.APIRateProfile{ - ID: "RPWithoutTenant", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - Weights: ";0", - MaxCostStrategy: "*free", - Rates: map[string]*engine.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - Weights: ";0", - ActivationTimes: "* * * * 1-5", - IntervalRates: []*engine.APIIntervalRate{ - { - IntervalStart: "0", - }, + apiRPrf := &engine.APIRateProfileWithOpts{ + APIRateProfile: &engine.APIRateProfile{ + ID: "RPWithoutTenant", + FilterIDs: []string{"*string:~*req.Subject:1001"}, + Weights: ";0", + MaxCostStrategy: "*free", + Rates: map[string]*engine.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + Weights: ";0", + ActivationTimes: "* * * * 1-5", + IntervalRates: []*engine.APIIntervalRate{ + { + IntervalStart: "0", }, }, }, @@ -771,29 +764,27 @@ func testV1RatePrfGetRateProfileRatesWithoutTenant(t *testing.T) { }, }, } - apiRPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: &engine.APIRateProfile{ - ID: "SpecialRate", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - Weights: ";0", - MaxCostStrategy: "*free", - Rates: map[string]*engine.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - Weights: ";0", - ActivationTimes: "* * * * 1-5", - }, - "RT_WEEKEND": { - ID: "RT_WEEKEND", - Weights: ";10", - ActivationTimes: "* * * * 0,6", - }, - "RT_CHRISTMAS": { - ID: "RT_CHRISTMAS", - Weights: ";30", - ActivationTimes: "* * 24 12 *", - }, + apiRPrf := &engine.APIRateProfileWithOpts{ + APIRateProfile: &engine.APIRateProfile{ + ID: "SpecialRate", + FilterIDs: []string{"*string:~*req.Subject:1001"}, + Weights: ";0", + MaxCostStrategy: "*free", + Rates: map[string]*engine.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + Weights: ";0", + ActivationTimes: "* * * * 1-5", + }, + "RT_WEEKEND": { + ID: "RT_WEEKEND", + Weights: ";10", + ActivationTimes: "* * * * 0,6", + }, + "RT_CHRISTMAS": { + ID: "RT_CHRISTMAS", + Weights: ";30", + ActivationTimes: "* * 24 12 *", }, }, }, @@ -863,30 +854,28 @@ func testV1RateCostForEventWithDefault(t *testing.T) { }, }, } - rPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: &engine.APIRateProfile{ - ID: "DefaultRate", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - Weights: ";10", - Rates: map[string]*engine.APIRate{ - "RATE1": &engine.APIRate{ - ID: "RATE1", - Weights: ";0", - ActivationTimes: "* * * * *", - IntervalRates: []*engine.APIIntervalRate{ - { - IntervalStart: "0", - RecurrentFee: utils.Float64Pointer(0.12), - Unit: utils.Float64Pointer(60000000000), - Increment: utils.Float64Pointer(60000000000), - }, - { - IntervalStart: "1m", - RecurrentFee: utils.Float64Pointer(0.06), - Unit: utils.Float64Pointer(60000000000), - Increment: utils.Float64Pointer(1000000000), - }, + rPrf := &engine.APIRateProfileWithOpts{ + APIRateProfile: &engine.APIRateProfile{ + ID: "DefaultRate", + FilterIDs: []string{"*string:~*req.Subject:1001"}, + Weights: ";10", + Rates: map[string]*engine.APIRate{ + "RATE1": &engine.APIRate{ + ID: "RATE1", + Weights: ";0", + ActivationTimes: "* * * * *", + IntervalRates: []*engine.APIIntervalRate{ + { + IntervalStart: "0", + RecurrentFee: utils.Float64Pointer(0.12), + Unit: utils.Float64Pointer(60000000000), + Increment: utils.Float64Pointer(60000000000), + }, + { + IntervalStart: "1m", + RecurrentFee: utils.Float64Pointer(0.06), + Unit: utils.Float64Pointer(60000000000), + Increment: utils.Float64Pointer(1000000000), }, }, }, diff --git a/apier/v1/remote_it_test.go b/apier/v1/remote_it_test.go index cc8fa3d08..f5c767c92 100644 --- a/apier/v1/remote_it_test.go +++ b/apier/v1/remote_it_test.go @@ -274,7 +274,7 @@ func testInternalRemoteITGetThreshold(t *testing.T) { func testInternalRemoteITGetThresholdProfile(t *testing.T) { var reply *engine.ThresholdProfile - tPrfl = &engine.ThresholdWithCache{ + tPrfl = &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_ACNT_1001", @@ -599,7 +599,7 @@ func testInternalRemoteITGetDispatcherProfile(t *testing.T) { t.Error(err) } - dispatcherProfile = &DispatcherWithCache{ + dispatcherProfile = &DispatcherWithOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "Dsp1", @@ -635,7 +635,7 @@ func testInternalRemoteITGetDispatcherHost(t *testing.T) { t.Error(err) } - dispatcherHost = &DispatcherHostWithCache{ + dispatcherHost = &engine.DispatcherHostWithOpts{ DispatcherHost: &engine.DispatcherHost{ Tenant: "cgrates.org", RemoteHost: &config.RemoteHost{ @@ -711,30 +711,28 @@ func testInternalRemoteITGetRateProfile(t *testing.T) { }, }, } - apiRPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: &engine.APIRateProfile{ - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - Weights: ";0", - MaxCostStrategy: "*free", - Rates: map[string]*engine.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - Weights: ";0", - ActivationTimes: "* * * * 1-5", - }, - "RT_WEEKEND": { - ID: "RT_WEEKEND", - Weights: ";10", - ActivationTimes: "* * * * 0,6", - }, - "RT_CHRISTMAS": { - ID: "RT_CHRISTMAS", - Weights: ";30", - ActivationTimes: "* * 24 12 *", - }, + apiRPrf := &engine.APIRateProfileWithOpts{ + APIRateProfile: &engine.APIRateProfile{ + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: []string{"*string:~*req.Subject:1001"}, + Weights: ";0", + MaxCostStrategy: "*free", + Rates: map[string]*engine.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + Weights: ";0", + ActivationTimes: "* * * * 1-5", + }, + "RT_WEEKEND": { + ID: "RT_WEEKEND", + Weights: ";10", + ActivationTimes: "* * * * 0,6", + }, + "RT_CHRISTMAS": { + ID: "RT_CHRISTMAS", + Weights: ";30", + ActivationTimes: "* * 24 12 *", }, }, }, @@ -791,7 +789,7 @@ func testInternalReplicationSetThreshold(t *testing.T) { expectedIDX, utils.ToJSON(indexes)) } - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Replication", diff --git a/apier/v1/replicate_it_test.go b/apier/v1/replicate_it_test.go index e8fc996af..4bcb773e8 100644 --- a/apier/v1/replicate_it_test.go +++ b/apier/v1/replicate_it_test.go @@ -347,7 +347,7 @@ func testInternalReplicateITRouteProfile(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - rPrf := &RouteWithCache{ + rPrf := &RouteWithOpts{ RouteProfile: &engine.RouteProfile{ Tenant: "cgrates.org", ID: "TEST_PROFILE1", @@ -501,7 +501,7 @@ func testInternalReplicateITDispatcherProfile(t *testing.T) { t.Error(err) } // set - dispatcherProfile = &DispatcherWithCache{ + dispatcherProfile = &DispatcherWithOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "Dsp1", @@ -568,7 +568,7 @@ func testInternalReplicateITChargerProfile(t *testing.T) { t.Error(err) } // set - chargerProfile = &ChargerWithCache{ + chargerProfile = &ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "ApierTest", @@ -634,7 +634,7 @@ func testInternalReplicateITDispatcherHost(t *testing.T) { &reply); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - dispatcherHost = &DispatcherHostWithCache{ + dispatcherHost = &engine.DispatcherHostWithOpts{ DispatcherHost: &engine.DispatcherHost{ Tenant: "cgrates.org", RemoteHost: &config.RemoteHost{ @@ -1002,7 +1002,7 @@ func testInternalReplicateITThresholdProfile(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - tPrfl = &engine.ThresholdWithCache{ + tPrfl = &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: tenant, ID: "TEST_PROFILE1", @@ -1231,7 +1231,7 @@ func testInternalReplicateITThreshold(t *testing.T) { } else if reply != utils.OK { t.Errorf("Calling APIerSv2.SetActions received: %s", reply) } - tPrfl := engine.ThresholdWithCache{ + tPrfl := engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: tenant, ID: "THD_Test", diff --git a/apier/v1/routes.go b/apier/v1/routes.go index 2db0e2556..e50609159 100644 --- a/apier/v1/routes.go +++ b/apier/v1/routes.go @@ -64,14 +64,13 @@ func (apierSv1 *APIerSv1) GetRouteProfileIDs(args *utils.PaginatorWithTenant, sp return nil } -type RouteWithCache struct { +type RouteWithOpts struct { *engine.RouteProfile - Cache *string - Opts map[string]interface{} + Opts map[string]interface{} } //SetRouteProfile add a new Route configuration -func (apierSv1 *APIerSv1) SetRouteProfile(args *RouteWithCache, reply *string) error { +func (apierSv1 *APIerSv1) SetRouteProfile(args *RouteWithOpts, reply *string) error { if missing := utils.MissingStructFields(args.RouteProfile, []string{utils.ID}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } diff --git a/apier/v1/routes_it_test.go b/apier/v1/routes_it_test.go index 121c353bf..be95c264c 100644 --- a/apier/v1/routes_it_test.go +++ b/apier/v1/routes_it_test.go @@ -36,7 +36,7 @@ var ( routeSv1CfgPath string routeSv1Cfg *config.CGRConfig routeSv1Rpc *rpc.Client - routePrf *RouteWithCache + routePrf *RouteWithOpts routeSv1ConfDIR string //run tests for specific configuration sTestsRouteSV1 = []func(t *testing.T){ @@ -839,7 +839,7 @@ func testV1RouteGetRouteWithoutFilter(t *testing.T) { } func testV1RouteSetRouteProfiles(t *testing.T) { - routePrf = &RouteWithCache{ + routePrf = &RouteWithOpts{ RouteProfile: &engine.RouteProfile{ Tenant: "cgrates.org", ID: "TEST_PROFILE1", @@ -1101,7 +1101,7 @@ func testV1RoutesOneRouteWithoutDestination(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - routePrf = &RouteWithCache{ + routePrf = &RouteWithOpts{ RouteProfile: &engine.RouteProfile{ Tenant: "cgrates.org", ID: "ROUTE_DESTINATION", @@ -1175,7 +1175,7 @@ func testV1RouteMultipleRouteSameID(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - routePrf = &RouteWithCache{ + routePrf = &RouteWithOpts{ RouteProfile: &engine.RouteProfile{ Tenant: "cgrates.org", ID: "MULTIPLE_ROUTES", @@ -1283,7 +1283,7 @@ func testV1RouteMultipleRouteSameID(t *testing.T) { } func testV1RouteAccountWithRatingPlan(t *testing.T) { - routePrf = &RouteWithCache{ + routePrf = &RouteWithOpts{ RouteProfile: &engine.RouteProfile{ Tenant: "cgrates.org", ID: "RouteWithAccAndRP", @@ -1563,7 +1563,7 @@ func testV1RouteStopEngine(t *testing.T) { } func testV1RouteSetRouteProfilesWithoutTenant(t *testing.T) { - routePrf = &RouteWithCache{ + routePrf = &RouteWithOpts{ RouteProfile: &engine.RouteProfile{ Tenant: "cgrates.org", ID: "TEST_PROFILE10", diff --git a/apier/v1/stats_it_test.go b/apier/v1/stats_it_test.go index a3ed64a1d..c06026181 100644 --- a/apier/v1/stats_it_test.go +++ b/apier/v1/stats_it_test.go @@ -853,7 +853,7 @@ func testV1STSProcessStatWithThreshold(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - thSts := &engine.ThresholdWithCache{ + thSts := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Stat", @@ -1160,7 +1160,7 @@ func testV1STSProcessStatWithThreshold2(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - thSts := &engine.ThresholdWithCache{ + thSts := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Stat2", diff --git a/apier/v1/thresholds.go b/apier/v1/thresholds.go index cec6c0972..77e3f7721 100644 --- a/apier/v1/thresholds.go +++ b/apier/v1/thresholds.go @@ -124,7 +124,7 @@ func (apierSv1 *APIerSv1) GetThresholdProfileIDsCount(args *utils.TenantWithOpts } // SetThresholdProfile alters/creates a ThresholdProfile -func (apierSv1 *APIerSv1) SetThresholdProfile(args *engine.ThresholdWithCache, reply *string) error { +func (apierSv1 *APIerSv1) SetThresholdProfile(args *engine.ThresholdProfileWithOpts, reply *string) error { if missing := utils.MissingStructFields(args.ThresholdProfile, []string{utils.ID}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } diff --git a/apier/v1/thresholds_it_test.go b/apier/v1/thresholds_it_test.go index 56c17b5e4..03e1b3344 100644 --- a/apier/v1/thresholds_it_test.go +++ b/apier/v1/thresholds_it_test.go @@ -36,7 +36,7 @@ var ( tSv1CfgPath string tSv1Cfg *config.CGRConfig tSv1Rpc *rpc.Client - tPrfl *engine.ThresholdWithCache + tPrfl *engine.ThresholdProfileWithOpts tSv1ConfDIR string //run tests for specific configuration tEvs = []*engine.ThresholdsArgsProcessEvent{ @@ -421,7 +421,7 @@ func testV1TSGetThresholdsAfterRestart(t *testing.T) { func testV1TSSetThresholdProfileBrokenReference(t *testing.T) { var reply *engine.ThresholdProfile var result string - tPrfl = &engine.ThresholdWithCache{ + tPrfl = &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", @@ -472,7 +472,7 @@ func testV1TSSetThresholdProfile(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl = &engine.ThresholdWithCache{ + tPrfl = &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", @@ -551,7 +551,7 @@ func testV1TSMaxHits(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl = &engine.ThresholdWithCache{ + tPrfl = &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH3", @@ -656,7 +656,7 @@ func testV1TSUpdateSnooze(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - customTh := &engine.ThresholdWithCache{ + customTh := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH4", @@ -703,7 +703,7 @@ func testV1TSUpdateSnooze(t *testing.T) { t.Errorf("expecting: %+v, received: %+v", tNow.Add(10*time.Minute), td.Snooze) } - customTh2 := &engine.ThresholdWithCache{ + customTh2 := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH4", @@ -737,7 +737,7 @@ func testV1TSStopEngine(t *testing.T) { } func testV1TSGetThresholdProfileWithoutTenant(t *testing.T) { - tPrfl = &engine.ThresholdWithCache{ + tPrfl = &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ ID: "randomID", FilterIDs: []string{"*string:~*req.Account:1001"}, @@ -846,7 +846,7 @@ func testV1TSGetThresholdsWithoutTenant(t *testing.T) { func testV1TSProcessAccountUpdateEvent(t *testing.T) { var result string - thAcntUpdate := &engine.ThresholdWithCache{ + thAcntUpdate := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_ACNT_UPDATE_EV", diff --git a/apier/v2/cdrs_it_test.go b/apier/v2/cdrs_it_test.go index 6bc60f6a8..8a1372f0e 100644 --- a/apier/v2/cdrs_it_test.go +++ b/apier/v2/cdrs_it_test.go @@ -463,7 +463,7 @@ func testV2CDRsDifferentTenants(t *testing.T) { t.Errorf("Expecting : %+v, received: %+v", alsPrf.AttributeProfile, reply) } //add a charger - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "CustomTenant", ID: "CustomCharger", @@ -475,7 +475,9 @@ func testV2CDRsDifferentTenants(t *testing.T) { AttributeIDs: []string{"*none"}, Weight: 20, }, - Cache: utils.StringPointer(utils.MetaReload), + Opts: map[string]interface{}{ + utils.CacheOpt: utils.MetaReload, + }, } if err := cdrsRpc.Call(utils.APIerSv1SetChargerProfile, chargerProfile, &result); err != nil { t.Error(err) @@ -728,7 +730,7 @@ func testV2CDRsSetThreshold(t *testing.T) { } else if reply != utils.OK { t.Errorf("Calling APIerSv2.SetActions received: %s", reply) } - tPrfl := engine.ThresholdWithCache{ + tPrfl := engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", @@ -858,7 +860,7 @@ func testV2CDRsRerate(t *testing.T) { t.Error("Reply: ", reply) } //add a charger - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "Default", @@ -869,7 +871,9 @@ func testV2CDRsRerate(t *testing.T) { AttributeIDs: []string{"*none"}, Weight: 20, }, - Cache: utils.StringPointer(utils.MetaReload), + Opts: map[string]interface{}{ + utils.CacheOpt: utils.MetaReload, + }, } if err := cdrsRpc.Call(utils.APIerSv1SetChargerProfile, chargerProfile, &reply); err != nil { t.Error(err) @@ -1022,7 +1026,7 @@ func testV2CDRsDuplicateCDRs(t *testing.T) { t.Error("Reply: ", reply) } //add a charger - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "Default", @@ -1033,7 +1037,9 @@ func testV2CDRsDuplicateCDRs(t *testing.T) { AttributeIDs: []string{"*none"}, Weight: 20, }, - Cache: utils.StringPointer(utils.MetaReload), + Opts: map[string]interface{}{ + utils.CacheOpt: utils.MetaReload, + }, } if err := cdrsRpc.Call(utils.APIerSv1SetChargerProfile, chargerProfile, &reply); err != nil { t.Error(err) diff --git a/apier/v2/cdrs_offline_it_test.go b/apier/v2/cdrs_offline_it_test.go index 8f3eb3ef7..ce2f53c6e 100644 --- a/apier/v2/cdrs_offline_it_test.go +++ b/apier/v2/cdrs_offline_it_test.go @@ -160,7 +160,7 @@ func testV2CDRsOfflineBalanceUpdate(t *testing.T) { t.Error(err) } //create a threshold that match out account - tPrfl := engine.ThresholdWithCache{ + tPrfl := engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", @@ -274,7 +274,7 @@ func testV2CDRsOfflineExpiryBalance(t *testing.T) { t.Error(err) } //create a threshold that match out account - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test2", diff --git a/console/routes_profile_set.go b/console/routes_profile_set.go index e1d6705ee..03123b5a9 100644 --- a/console/routes_profile_set.go +++ b/console/routes_profile_set.go @@ -28,7 +28,7 @@ func init() { c := &CmdSetRoute{ name: "routes_profile_set", rpcMethod: utils.APIerSv1SetRouteProfile, - rpcParams: &v1.RouteWithCache{}, + rpcParams: &v1.RouteWithOpts{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -37,7 +37,7 @@ func init() { type CmdSetRoute struct { name string rpcMethod string - rpcParams *v1.RouteWithCache + rpcParams *v1.RouteWithOpts *CommandExecuter } @@ -51,7 +51,7 @@ func (self *CmdSetRoute) RpcMethod() string { func (self *CmdSetRoute) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &v1.RouteWithCache{ + self.rpcParams = &v1.RouteWithOpts{ RouteProfile: new(engine.RouteProfile), Opts: map[string]interface{}{}, } diff --git a/console/thresholds_profile_set.go b/console/thresholds_profile_set.go index c751864c7..31cd9a407 100644 --- a/console/thresholds_profile_set.go +++ b/console/thresholds_profile_set.go @@ -27,7 +27,7 @@ func init() { c := &CmdSetThreshold{ name: "thresholds_profile_set", rpcMethod: utils.APIerSv1SetThresholdProfile, - rpcParams: &engine.ThresholdWithCache{}, + rpcParams: &engine.ThresholdProfileWithOpts{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -37,7 +37,7 @@ func init() { type CmdSetThreshold struct { name string rpcMethod string - rpcParams *engine.ThresholdWithCache + rpcParams *engine.ThresholdProfileWithOpts *CommandExecuter } @@ -51,7 +51,7 @@ func (self *CmdSetThreshold) RpcMethod() string { func (self *CmdSetThreshold) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &engine.ThresholdWithCache{ + self.rpcParams = &engine.ThresholdProfileWithOpts{ ThresholdProfile: new(engine.ThresholdProfile), Opts: map[string]interface{}{}, } diff --git a/engine/thresholds.go b/engine/thresholds.go index 74530d6ea..1a6b12d42 100644 --- a/engine/thresholds.go +++ b/engine/thresholds.go @@ -29,13 +29,6 @@ import ( "github.com/cgrates/cgrates/utils" ) -// ThresholdWithCache used in api to determine how to reload cache -type ThresholdWithCache struct { - *ThresholdProfile - Cache *string - Opts map[string]interface{} -} - // ThresholdProfileWithOpts is used in replicatorV1 for dispatcher type ThresholdProfileWithOpts struct { *ThresholdProfile diff --git a/engine/z_actions_it_test.go b/engine/z_actions_it_test.go index 36d05db45..1456cd1b4 100644 --- a/engine/z_actions_it_test.go +++ b/engine/z_actions_it_test.go @@ -339,7 +339,7 @@ func testActionsitThresholdCDrLog(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl := ThresholdWithCache{ + tPrfl := ThresholdProfileWithOpts{ ThresholdProfile: &ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", @@ -558,7 +558,7 @@ func testActionsitThresholdCgrRpcAction(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl := &ThresholdWithCache{ + tPrfl := &ThresholdProfileWithOpts{ ThresholdProfile: &ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_CGRRPC", @@ -623,7 +623,7 @@ func testActionsitThresholdPostEvent(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl := &ThresholdWithCache{ + tPrfl := &ThresholdProfileWithOpts{ ThresholdProfile: &ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_PostEvent", diff --git a/ers/filefwv_it_test.go b/ers/filefwv_it_test.go index 93e56f4cc..dbf41db27 100644 --- a/ers/filefwv_it_test.go +++ b/ers/filefwv_it_test.go @@ -114,7 +114,7 @@ func testFWVITRpcConn(t *testing.T) { func testFWVITLoadTPFromFolder(t *testing.T) { //add a default charger - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "Default", diff --git a/ers/filejson_it_test.go b/ers/filejson_it_test.go index 3eb61981b..608903415 100644 --- a/ers/filejson_it_test.go +++ b/ers/filejson_it_test.go @@ -130,7 +130,7 @@ func testJSONRpcConn(t *testing.T) { func testJSONAddData(t *testing.T) { var reply string //add a charger - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "Default", @@ -141,7 +141,9 @@ func testJSONAddData(t *testing.T) { AttributeIDs: []string{"*none"}, Weight: 20, }, - Cache: utils.StringPointer(utils.MetaReload), + Opts: map[string]interface{}{ + utils.CacheOpt: utils.MetaReload, + }, } if err := jsonRPC.Call(utils.APIerSv1SetChargerProfile, chargerProfile, &reply); err != nil { t.Error(err) diff --git a/ers/flatstore_it_test.go b/ers/flatstore_it_test.go index 870bb6eb0..b62affd2f 100644 --- a/ers/flatstore_it_test.go +++ b/ers/flatstore_it_test.go @@ -132,7 +132,7 @@ func testFlatstoreITRpcConn(t *testing.T) { func testFlatstoreITLoadTPFromFolder(t *testing.T) { //add a default charger - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "Default", diff --git a/ers/partial_csv_it_test.go b/ers/partial_csv_it_test.go index ceae1a4e0..a7b52b78c 100644 --- a/ers/partial_csv_it_test.go +++ b/ers/partial_csv_it_test.go @@ -129,7 +129,7 @@ func testPartITRpcConn(t *testing.T) { func testPartITLoadTPFromFolder(t *testing.T) { //add a default charger - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "Default", diff --git a/general_tests/a1_it_test.go b/general_tests/a1_it_test.go index 1ea320ce5..3d8acab4d 100644 --- a/general_tests/a1_it_test.go +++ b/general_tests/a1_it_test.go @@ -137,7 +137,7 @@ func testA1itLoadTPFromFolder(t *testing.T) { } //add a default charger - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "Default", diff --git a/general_tests/accountactions_it_test.go b/general_tests/accountactions_it_test.go index 051efd47b..6bd61323f 100644 --- a/general_tests/accountactions_it_test.go +++ b/general_tests/accountactions_it_test.go @@ -28,7 +28,6 @@ import ( "testing" "time" - v1 "github.com/cgrates/cgrates/apier/v1" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -115,74 +114,72 @@ func testAccActionsRPCConn(t *testing.T) { } func testAccActionsSetActionProfile(t *testing.T) { - actPrf := &v1.ActionProfileWithCache{ - ActionProfileWithOpts: &engine.ActionProfileWithOpts{ - ActionProfile: &engine.ActionProfile{ - Tenant: "cgrates.org", - ID: "CREATE_ACC", - FilterIDs: []string{"*string:~*req.Account:1001"}, - Weight: 0, - Targets: map[string]utils.StringSet{utils.MetaAccounts: {"1001": {}}}, - Schedule: utils.MetaASAP, - Actions: []*engine.APAction{ - { - ID: "SET_NEW_BAL", - FilterIDs: []string{"*exists:*opts.BAL_NEW:"}, - Type: utils.MetaSetBalance, - Diktats: []*engine.APDiktat{ - { - Path: "*account.ThresholdIDs", - Value: utils.MetaNone, - }, - { - Path: "*balance.MONETARY.Type", - Value: utils.MetaConcrete, - }, - { - Path: "*balance.MONETARY.Units", - Value: "1048576", - }, - { - Path: "*balance.MONETARY.Weights", - Value: "`;0`", - }, - { - Path: "*balance.MONETARY.CostIncrements", - Value: "`*string:~*req.ToR:*data;1024;0;0.01`", - }, + actPrf := &engine.ActionProfileWithOpts{ + ActionProfile: &engine.ActionProfile{ + Tenant: "cgrates.org", + ID: "CREATE_ACC", + FilterIDs: []string{"*string:~*req.Account:1001"}, + Weight: 0, + Targets: map[string]utils.StringSet{utils.MetaAccounts: {"1001": {}}}, + Schedule: utils.MetaASAP, + Actions: []*engine.APAction{ + { + ID: "SET_NEW_BAL", + FilterIDs: []string{"*exists:*opts.BAL_NEW:"}, + Type: utils.MetaSetBalance, + Diktats: []*engine.APDiktat{ + { + Path: "*account.ThresholdIDs", + Value: utils.MetaNone, + }, + { + Path: "*balance.MONETARY.Type", + Value: utils.MetaConcrete, + }, + { + Path: "*balance.MONETARY.Units", + Value: "1048576", + }, + { + Path: "*balance.MONETARY.Weights", + Value: "`;0`", + }, + { + Path: "*balance.MONETARY.CostIncrements", + Value: "`*string:~*req.ToR:*data;1024;0;0.01`", }, }, - { - ID: "SET_ADD_BAL", - FilterIDs: []string{"*exists:*opts.BAL_ADD:"}, - Type: utils.MetaAddBalance, - Diktats: []*engine.APDiktat{ - { - Path: "*balance.VOICE.Type", - Value: utils.MetaAbstract, - }, - { - Path: "*balance.VOICE.Units", - Value: strconv.FormatInt((3 * time.Hour).Nanoseconds(), 10), - }, - { - Path: "*balance.VOICE.FilterIDs", - Value: "`*string:~*req.ToR:*voice`", - }, - { - Path: "*balance.VOICE.Weights", - Value: "`;2`", - }, - { - Path: "*balance.VOICE.CostIncrements", - Value: "`*string:~*req.ToR:*voice;1000000000;0;0.01`", - }, + }, + { + ID: "SET_ADD_BAL", + FilterIDs: []string{"*exists:*opts.BAL_ADD:"}, + Type: utils.MetaAddBalance, + Diktats: []*engine.APDiktat{ + { + Path: "*balance.VOICE.Type", + Value: utils.MetaAbstract, + }, + { + Path: "*balance.VOICE.Units", + Value: strconv.FormatInt((3 * time.Hour).Nanoseconds(), 10), + }, + { + Path: "*balance.VOICE.FilterIDs", + Value: "`*string:~*req.ToR:*voice`", + }, + { + Path: "*balance.VOICE.Weights", + Value: "`;2`", + }, + { + Path: "*balance.VOICE.CostIncrements", + Value: "`*string:~*req.ToR:*voice;1000000000;0;0.01`", }, }, }, }, - Opts: map[string]interface{}{}, }, + Opts: map[string]interface{}{}, } var reply string if err := accSRPC.Call(utils.APIerSv1SetActionProfile, actPrf, &reply); err != nil { @@ -283,32 +280,30 @@ func testAccActionsGetAccountAfterActions(t *testing.T) { } func testAccActionsSetActionProfile2(t *testing.T) { - actPrf := &v1.ActionProfileWithCache{ - ActionProfileWithOpts: &engine.ActionProfileWithOpts{ - ActionProfile: &engine.ActionProfile{ - Tenant: "cgrates.org", - ID: "REM_ACC", - FilterIDs: []string{"*string:~*req.Account:1001"}, - Weight: 0, - Targets: map[string]utils.StringSet{utils.MetaAccounts: {"1001": {}}}, - Schedule: utils.MetaASAP, - Actions: []*engine.APAction{ - { - ID: "REM_BAL", - Type: utils.MetaRemBalance, - Diktats: []*engine.APDiktat{ - { - Path: "MONETARY", - }, - { - Path: "VOICE", - }, + actPrf := &engine.ActionProfileWithOpts{ + ActionProfile: &engine.ActionProfile{ + Tenant: "cgrates.org", + ID: "REM_ACC", + FilterIDs: []string{"*string:~*req.Account:1001"}, + Weight: 0, + Targets: map[string]utils.StringSet{utils.MetaAccounts: {"1001": {}}}, + Schedule: utils.MetaASAP, + Actions: []*engine.APAction{ + { + ID: "REM_BAL", + Type: utils.MetaRemBalance, + Diktats: []*engine.APDiktat{ + { + Path: "MONETARY", + }, + { + Path: "VOICE", }, }, }, }, - Opts: map[string]interface{}{}, }, + Opts: map[string]interface{}{}, } var reply string if err := accSRPC.Call(utils.APIerSv1SetActionProfile, actPrf, &reply); err != nil { diff --git a/general_tests/accounts_it_test.go b/general_tests/accounts_it_test.go index 7ae11b14c..0071b13ba 100644 --- a/general_tests/accounts_it_test.go +++ b/general_tests/accounts_it_test.go @@ -249,7 +249,7 @@ func testV1AccSendToThreshold(t *testing.T) { t.Errorf("Calling APIerSv2.SetActions received: %s", reply) } - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_AccDisableAndLog", diff --git a/general_tests/cacherpl_it_test.go b/general_tests/cacherpl_it_test.go index dbe00e32a..d8cb48829 100644 --- a/general_tests/cacherpl_it_test.go +++ b/general_tests/cacherpl_it_test.go @@ -229,7 +229,7 @@ func testCacheRplAddData(t *testing.T) { t.Errorf("cgr-loader failed: ") } - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "DefaultCharger", @@ -288,7 +288,7 @@ func testCacheRplAAAddData(t *testing.T) { t.Errorf("cgr-loader failed: ") } - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "DefaultCharger", diff --git a/general_tests/cdrs_exp_it_test.go b/general_tests/cdrs_exp_it_test.go index 9e1ac24dc..f2f91a776 100644 --- a/general_tests/cdrs_exp_it_test.go +++ b/general_tests/cdrs_exp_it_test.go @@ -222,7 +222,7 @@ func testCDRsExpInitRPC(t *testing.T) { func testCDRsExpLoadAddCharger(t *testing.T) { // //add a default charger - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "*raw", diff --git a/general_tests/cdrs_it_test.go b/general_tests/cdrs_it_test.go index c6b52407d..9f14332be 100644 --- a/general_tests/cdrs_it_test.go +++ b/general_tests/cdrs_it_test.go @@ -526,7 +526,7 @@ func testV2CDRsSetThresholdProfile(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_PoccessCDR", diff --git a/general_tests/cdrs_processevent_it_test.go b/general_tests/cdrs_processevent_it_test.go index 30a8232d1..1d48179c4 100644 --- a/general_tests/cdrs_processevent_it_test.go +++ b/general_tests/cdrs_processevent_it_test.go @@ -450,7 +450,7 @@ func testV1CDRsProcessEventThreshold(t *testing.T) { } else if reply != utils.OK { t.Errorf("Calling APIerSv2.SetActions received: %s", reply) } - tPrfl := engine.ThresholdWithCache{ + tPrfl := engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", diff --git a/general_tests/export_it_test.go b/general_tests/export_it_test.go index b0cd0b748..c44454359 100644 --- a/general_tests/export_it_test.go +++ b/general_tests/export_it_test.go @@ -211,7 +211,7 @@ func testExpVerifyFilters(t *testing.T) { } func testExpVerifyThresholds(t *testing.T) { - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_ACNT_1001", diff --git a/general_tests/filtered_replication_it_test.go b/general_tests/filtered_replication_it_test.go index bfa9e2811..0d652e452 100644 --- a/general_tests/filtered_replication_it_test.go +++ b/general_tests/filtered_replication_it_test.go @@ -375,7 +375,7 @@ func testFltrRplFilters(t *testing.T) { func testFltrRplThresholdProfile(t *testing.T) { thID := "TH1" - thPrfl := &engine.ThresholdWithCache{ + thPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: thID, @@ -925,7 +925,7 @@ func testFltrRplResourceProfile(t *testing.T) { func testFltrRplRouteProfile(t *testing.T) { rpID := "RT1" - rpPrf := &v1.RouteWithCache{ + rpPrf := &v1.RouteWithOpts{ RouteProfile: &engine.RouteProfile{ Tenant: "cgrates.org", ID: rpID, @@ -1041,7 +1041,7 @@ func testFltrRplRouteProfile(t *testing.T) { func testFltrRplChargerProfile(t *testing.T) { chID := "CH1" - chPrf := &v1.ChargerWithCache{ + chPrf := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: chID, @@ -1142,7 +1142,7 @@ func testFltrRplChargerProfile(t *testing.T) { func testFltrRplDispatcherProfile(t *testing.T) { dspID := "DSP1" - dspPrf := &v1.DispatcherWithCache{ + dspPrf := &v1.DispatcherWithOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: dspID, @@ -1242,7 +1242,7 @@ func testFltrRplDispatcherProfile(t *testing.T) { func testFltrRplDispatcherHost(t *testing.T) { dspID := "DSH1" - dspPrf := &v1.DispatcherHostWithCache{ + dspPrf := &engine.DispatcherHostWithOpts{ DispatcherHost: &engine.DispatcherHost{ Tenant: "cgrates.org", RemoteHost: &config.RemoteHost{ @@ -1342,23 +1342,21 @@ func testFltrRplDispatcherHost(t *testing.T) { func testFltrRplRateProfile(t *testing.T) { rpID := "RP1" - rpPrf := &v1.APIRateProfileWithCache{ - APIRateProfileWithOpts: &engine.APIRateProfileWithOpts{ - APIRateProfile: &engine.APIRateProfile{ - Tenant: "cgrates.org", - ID: rpID, - FilterIDs: []string{"*string:~*req.Account:dan"}, - Weights: ";0", - MaxCostStrategy: "*free", - Rates: map[string]*engine.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - Weights: ";0", - ActivationTimes: "* * * * 1-5", - IntervalRates: []*engine.APIIntervalRate{ - { - IntervalStart: "0", - }, + rpPrf := &engine.APIRateProfileWithOpts{ + APIRateProfile: &engine.APIRateProfile{ + Tenant: "cgrates.org", + ID: rpID, + FilterIDs: []string{"*string:~*req.Account:dan"}, + Weights: ";0", + MaxCostStrategy: "*free", + Rates: map[string]*engine.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + Weights: ";0", + ActivationTimes: "* * * * 1-5", + IntervalRates: []*engine.APIIntervalRate{ + { + IntervalStart: "0", }, }, }, @@ -1484,19 +1482,17 @@ func testFltrRplRateProfile(t *testing.T) { func testFltrRplActionProfile(t *testing.T) { acID := "ATTR1" - acPrf := &v1.ActionProfileWithCache{ - ActionProfileWithOpts: &engine.ActionProfileWithOpts{ - ActionProfile: &engine.ActionProfile{ - Tenant: "cgrates.org", - ID: acID, - Actions: []*engine.APAction{ - { - ID: "test_action_id", - Diktats: []*engine.APDiktat{{}}, - }, + acPrf := &engine.ActionProfileWithOpts{ + ActionProfile: &engine.ActionProfile{ + Tenant: "cgrates.org", + ID: acID, + Actions: []*engine.APAction{ + { + ID: "test_action_id", + Diktats: []*engine.APDiktat{{}}, }, - Weight: 10, }, + Weight: 10, }, } var result string diff --git a/general_tests/filters_it_test.go b/general_tests/filters_it_test.go index 62995fe16..b66813941 100644 --- a/general_tests/filters_it_test.go +++ b/general_tests/filters_it_test.go @@ -293,7 +293,7 @@ func testV1FltrPopulateThreshold(t *testing.T) { } //Add a threshold with filter from above and an inline filter for Account 1010 - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_Stats1", @@ -367,7 +367,7 @@ func testV1FltrGetThresholdForEvent2(t *testing.T) { } //update the threshold with new filter - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_Stats1", @@ -470,7 +470,7 @@ func testV1FltrPopulateResources(t *testing.T) { t.Error("Unexpected reply returned", result) } - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_ResTest", @@ -742,7 +742,7 @@ func testV1FltrAccounts(t *testing.T) { t.Errorf("Calling APIerSv2.SetActions received: %s", result) } //Add a threshold with filter from above and an inline filter for Account 1010 - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_Account", @@ -830,7 +830,7 @@ func testV1FltrAccountsExistsDynamicaly(t *testing.T) { t.Error("Got error on APIerSv2.SetActions: ", err.Error()) } //Add a threshold with filter from above and an inline filter for Account 1010 - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_AccountDinamic", @@ -893,7 +893,7 @@ func testV1FltrChargerSuffix(t *testing.T) { } else if reply != utils.OK { t.Error("Reply: ", reply) } - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "IntraCharger", @@ -910,7 +910,7 @@ func testV1FltrChargerSuffix(t *testing.T) { t.Error("Unexpected reply returned", result) } - chargerProfile2 := &v1.ChargerWithCache{ + chargerProfile2 := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "InterCharger", diff --git a/general_tests/gocs_it_test.go b/general_tests/gocs_it_test.go index 4352f68ff..792bb683d 100644 --- a/general_tests/gocs_it_test.go +++ b/general_tests/gocs_it_test.go @@ -135,7 +135,7 @@ func testGOCSApierRpcConn(t *testing.T) { } func testGOCSLoadData(t *testing.T) { - chargerProfile := &v1.ChargerWithCache{ + chargerProfile := &v1.ChargerWithOpts{ ChargerProfile: &engine.ChargerProfile{ Tenant: "cgrates.org", ID: "DEFAULT", diff --git a/general_tests/route_it_test.go b/general_tests/route_it_test.go index 1e1ccadb0..c9e51ff6d 100644 --- a/general_tests/route_it_test.go +++ b/general_tests/route_it_test.go @@ -37,7 +37,7 @@ var ( splSv1CfgPath string splSv1Cfg *config.CGRConfig splSv1Rpc *rpc.Client - splPrf *v1.RouteWithCache + splPrf *v1.RouteWithOpts splSv1ConfDIR string //run tests for specific configuration sTestsSupplierSV1 = []func(t *testing.T){ @@ -133,7 +133,7 @@ func testV1SplSSetSupplierProfilesWithoutRatingPlanIDs(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - splPrf = &v1.RouteWithCache{ + splPrf = &v1.RouteWithOpts{ RouteProfile: &engine.RouteProfile{ Tenant: "cgrates.org", ID: "TEST_PROFILE2", @@ -197,7 +197,7 @@ func testV1SplSAddNewSplPrf(t *testing.T) { t.Error(err) } //create a new Supplier Profile to test *reas and *reds sorting strategy - splPrf = &v1.RouteWithCache{ + splPrf = &v1.RouteWithOpts{ RouteProfile: &engine.RouteProfile{ Tenant: "cgrates.org", ID: "ROUTE_ResourceTest", @@ -473,7 +473,7 @@ func testV1SplSAddNewSplPrf2(t *testing.T) { t.Error(err) } //create a new Supplier Profile to test *reas and *reds sorting strategy - splPrf = &v1.RouteWithCache{ + splPrf = &v1.RouteWithOpts{ RouteProfile: &engine.RouteProfile{ Tenant: "cgrates.org", ID: "ROUTE_ResourceDescendent", diff --git a/general_tests/rpccaching_it_test.go b/general_tests/rpccaching_it_test.go index 511ac7355..d738fb5de 100644 --- a/general_tests/rpccaching_it_test.go +++ b/general_tests/rpccaching_it_test.go @@ -163,7 +163,7 @@ func testRPCMethodsAddData(t *testing.T) { } //Add a thresholdProfile to disable account - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_AccDisableAndLog", @@ -180,7 +180,7 @@ func testRPCMethodsAddData(t *testing.T) { t.Error("Unexpected reply returned", reply) } //Add a thresholdProfile to enable account - tPrfl2 := &engine.ThresholdWithCache{ + tPrfl2 := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_AccEnableAndLog", diff --git a/general_tests/twoengines_it_test.go b/general_tests/twoengines_it_test.go index 5d75cebc9..95dacd00c 100644 --- a/general_tests/twoengines_it_test.go +++ b/general_tests/twoengines_it_test.go @@ -145,7 +145,7 @@ func testTwoEnginesSetThreshold(t *testing.T) { t.Error(err) } var result string - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_TwoEnginesTest", @@ -205,7 +205,7 @@ func testTwoEnginesCheckCacheAfterSet(t *testing.T) { t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys) } // after we verify the cache make sure it was set correctly there - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_TwoEnginesTest", @@ -230,7 +230,7 @@ func testTwoEnginesCheckCacheAfterSet(t *testing.T) { func testTwoEnginesUpdateThreshold(t *testing.T) { var rplTh *engine.ThresholdProfile var result string - tPrfl := &engine.ThresholdWithCache{ + tPrfl := &engine.ThresholdProfileWithOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_TwoEnginesTest", @@ -242,7 +242,9 @@ func testTwoEnginesUpdateThreshold(t *testing.T) { ActionIDs: []string{"ACT_1.1"}, Async: true, }, - Cache: utils.StringPointer(utils.MetaReload), + Opts: map[string]interface{}{ + utils.CacheOpt: utils.MetaReload, + }, } if err := engineOneRpc.Call(utils.APIerSv1SetThresholdProfile, tPrfl, &result); err != nil { t.Error(err)