From fad736e5a65dc242440059afeba614ced48fb397 Mon Sep 17 00:00:00 2001 From: andronache98 Date: Thu, 10 Feb 2022 14:53:51 +0200 Subject: [PATCH] Changed Weights from float64 to DynamicWeights for Resources and Chargers --- agents/diam_it_test.go | 10 +- apis/chargers_it_test.go | 120 ++- apis/chargers_test.go | 84 +- apis/filter_indexes_it_test.go | 52 +- apis/filters_test.go | 10 +- apis/loaders_it_test.go | 30 +- apis/resources_it_test.go | 70 +- apis/resources_test.go | 26 +- cmd/cgr-loader/cgr-loader_remove_it_test.go | 11 +- config/config_defaults.go | 4 +- config/config_json_test.go | 8 +- config/config_test.go | 14 +- config/loaderscfg_test.go | 16 +- .../scripts/create_tariffplan_tables.sql | 4 +- .../mysql/create_tariffplan_tables.sql | 4 +- .../postgres/create_tariffplan_tables.sql | 4 +- data/tariffplans/hundredrates/Chargers.csv | 4 +- data/tariffplans/loadRateTest/Chargers.csv | 8 +- data/tariffplans/loadRateTest/Resources.csv | 4 +- data/tariffplans/oldaccvsnew/Chargers.csv | 4 +- data/tariffplans/oldtutorial/Chargers.csv | 4 +- data/tariffplans/oldtutorial/Resources.csv | 8 +- data/tariffplans/precache/Resources.csv | 8 +- .../routes1/Chargers.csv | 6 +- data/tariffplans/testData/Chargers.csv | 4 +- data/tariffplans/testit/Chargers.csv | 8 +- data/tariffplans/testit/Resources.csv | 4 +- data/tariffplans/testtp/Resources.csv | 8 +- data/tariffplans/tp1cnt/Chargers.csv | 4 +- .../tp_destination_with_any/Chargers.csv | 4 +- .../tariffplans/tut_sip_redirect/Chargers.csv | 10 +- data/tariffplans/tutorial/Chargers.csv | 6 +- data/tariffplans/tutorial/Resources.csv | 4 +- data/tariffplans/tutorial2/Chargers.csv | 6 +- data/tariffplans/tutroutes/Chargers.csv | 4 +- data/tariffplans/tutroutes/Resources.csv | 6 +- dispatchers/chargers_it_test.go | 36 +- engine/chargers.go | 15 +- engine/chargers_test.go | 62 +- engine/libchargers.go | 15 +- engine/libchargers_test.go | 66 +- engine/libstats.go | 5 - engine/libtest.go | 10 +- engine/loader_csv_test.go | 6 +- engine/model_helpers.go | 43 +- engine/model_helpers_test.go | 119 +-- engine/models.go | 32 +- engine/resources.go | 24 +- engine/tpreader_test.go | 2 +- engine/z_filterindexer_it_test.go | 12 +- engine/z_filterindexer_test.go | 6 +- engine/z_libindex_health_test.go | 60 +- engine/z_onstor_it_test.go | 15 +- engine/z_resources_test.go | 743 ++++++++++++------ engine/z_stordb_it_test.go | 20 +- general_tests/attributes_it_test.go | 7 +- general_tests/export_it_test.go | 19 +- .../session_graceful_shutdown_it_test.go | 12 +- migrator/chargers_it_test.go | 12 +- migrator/resource_it_test.go | 15 +- migrator/tp_resources_it_test.go | 2 +- utils/apitpdata.go | 4 +- 62 files changed, 1322 insertions(+), 621 deletions(-) diff --git a/agents/diam_it_test.go b/agents/diam_it_test.go index 912ff3e4e..06e107b7b 100644 --- a/agents/diam_it_test.go +++ b/agents/diam_it_test.go @@ -1476,7 +1476,10 @@ func testDiamItEmulateTerminate(t *testing.T) { ID: "CustomCharger", RunID: "CustomCharger", AttributeIDs: []string{"*constant:*req.Category:custom_charger"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }}, }, } @@ -1492,7 +1495,10 @@ func testDiamItEmulateTerminate(t *testing.T) { ID: "Default", RunID: "*default", AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }}, }, } diff --git a/apis/chargers_it_test.go b/apis/chargers_it_test.go index f5ab51f99..0c8afb556 100644 --- a/apis/chargers_it_test.go +++ b/apis/chargers_it_test.go @@ -155,7 +155,11 @@ func testChgrsSetGetChargerProfile(t *testing.T) { ID: "TEST_CHARGERS_IT_TEST", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -172,7 +176,11 @@ func testChgrsSetGetChargerProfile(t *testing.T) { ID: "TEST_CHARGERS_IT_TEST", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } var result *engine.ChargerProfile if err := chgrsSRPC.Call(context.Background(), utils.AdminSv1GetChargerProfile, @@ -211,7 +219,11 @@ func testChgrsGetChargerProfiles(t *testing.T) { ID: "TEST_CHARGERS_IT_TEST", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, } if err := chgrsSRPC.Call(context.Background(), utils.AdminSv1GetChargerProfiles, @@ -239,7 +251,11 @@ func testChgrsSetGetChargerProfile2(t *testing.T) { ID: "TEST_CHARGERS_IT_TEST2", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -256,7 +272,11 @@ func testChgrsSetGetChargerProfile2(t *testing.T) { ID: "TEST_CHARGERS_IT_TEST2", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } var result *engine.ChargerProfile if err := chgrsSRPC.Call(context.Background(), utils.AdminSv1GetChargerProfile, @@ -295,14 +315,22 @@ func testChgrsGetChargerProfiles2(t *testing.T) { ID: "TEST_CHARGERS_IT_TEST", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, { Tenant: "cgrates.org", ID: "TEST_CHARGERS_IT_TEST2", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, } if err := chgrsSRPC.Call(context.Background(), utils.AdminSv1GetChargerProfiles, @@ -335,7 +363,11 @@ func testChgrsSetGetChargerProfile3(t *testing.T) { ID: "TEST_CHARGERS_IT_TEST3", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -352,7 +384,11 @@ func testChgrsSetGetChargerProfile3(t *testing.T) { ID: "TEST_CHARGERS_IT_TEST3", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } var result *engine.ChargerProfile if err := chgrsSRPC.Call(context.Background(), utils.AdminSv1GetChargerProfile, @@ -391,21 +427,33 @@ func testChgrsGetChargerProfiles3(t *testing.T) { ID: "TEST_CHARGERS_IT_TEST", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, { Tenant: "cgrates.org", ID: "TEST_CHARGERS_IT_TEST2", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, { Tenant: "cgrates.org", ID: "TEST_CHARGERS_IT_TEST3", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, } if err := chgrsSRPC.Call(context.Background(), utils.AdminSv1GetChargerProfiles, @@ -468,14 +516,22 @@ func testChgrsGetChargerProfilesAfterRemove(t *testing.T) { ID: "TEST_CHARGERS_IT_TEST", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, { Tenant: "cgrates.org", ID: "TEST_CHARGERS_IT_TEST2", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, } if err := chgrsSRPC.Call(context.Background(), utils.AdminSv1GetChargerProfiles, @@ -568,7 +624,11 @@ func testChgrsGetChargerProfilesWithPrefix(t *testing.T) { ID: "aTEST_CHARGERS_IT_TEST", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -585,7 +645,11 @@ func testChgrsGetChargerProfilesWithPrefix(t *testing.T) { ID: "aTEST_CHARGERS_IT_TEST", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } var result *engine.ChargerProfile if err := chgrsSRPC.Call(context.Background(), utils.AdminSv1GetChargerProfile, @@ -607,7 +671,11 @@ func testChgrsGetChargerProfilesWithPrefix(t *testing.T) { ID: "aTEST_CHARGERS_IT_TEST", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, } if err := chgrsSRPC.Call(context.Background(), utils.AdminSv1GetChargerProfiles, @@ -629,7 +697,11 @@ func testChgrsSetGetChargerProfileEvent(t *testing.T) { ID: "TEST_CHARGERS_IT_TEST", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -646,7 +718,11 @@ func testChgrsSetGetChargerProfileEvent(t *testing.T) { ID: "TEST_CHARGERS_IT_TEST", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } var result *engine.ChargerProfile if err := chgrsSRPC.Call(context.Background(), utils.AdminSv1GetChargerProfile, @@ -667,7 +743,11 @@ func testChgrsGetChargersForEvent(t *testing.T) { ID: "TEST_CHARGERS_IT_TEST", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, } cgrEv := &utils.CGREvent{ diff --git a/apis/chargers_test.go b/apis/chargers_test.go index d635282f1..4a64f21c2 100644 --- a/apis/chargers_test.go +++ b/apis/chargers_test.go @@ -44,7 +44,11 @@ func TestChargerSSetGetChargerProfile(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -75,7 +79,11 @@ func TestChargerSSetGetChargerProfile(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } if !reflect.DeepEqual(getRply, expectedGet) { t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.ToJSON(expectedGet), utils.ToJSON(getRply)) @@ -97,7 +105,11 @@ func TestChargerSSetGetChargerProfileErrMissingID(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -138,7 +150,11 @@ func TestChargerSSetGetChargerProfileErrNotFound(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -179,7 +195,11 @@ func TestChargerSSetChargerProfileErrMissingID(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -210,7 +230,11 @@ func TestChargerSDmSetChargerProfileErr(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -256,7 +280,11 @@ func TestChargerSSetChargerProfileSetLoadIDsErr(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -309,7 +337,11 @@ func TestChargerSSetChargerProfileCallCacheErr(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -339,7 +371,11 @@ func TestChargerSSetGetChargerProfileIDs(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -370,7 +406,11 @@ func TestChargerSSetGetChargerProfileIDs(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -457,7 +497,11 @@ func TestChargerSSetGetRmvGetChargerProfile(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -487,7 +531,11 @@ func TestChargerSSetGetRmvGetChargerProfile(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } if !reflect.DeepEqual(getRply, expectedGet) { t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.ToJSON(expectedGet), utils.ToJSON(getRply)) @@ -538,7 +586,11 @@ func TestChargerSSetGetRmvGetChargerProfileNoTenant(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -568,7 +620,11 @@ func TestChargerSSetGetRmvGetChargerProfileNoTenant(t *testing.T) { RunID: utils.MetaDefault, FilterIDs: []string{"*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } if !reflect.DeepEqual(getRply, expectedGet) { t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.ToJSON(expectedGet), utils.ToJSON(getRply)) diff --git a/apis/filter_indexes_it_test.go b/apis/filter_indexes_it_test.go index aaf2844a6..44bfe9a65 100644 --- a/apis/filter_indexes_it_test.go +++ b/apis/filter_indexes_it_test.go @@ -1802,7 +1802,11 @@ func testV1FIdxSetChargerSProfileWithFltr(t *testing.T) { FilterIDs: []string{"fltr_for_attr", "*string:~*req.Account:1001"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -1895,7 +1899,11 @@ func testV1FIdxSetChargerProfileMoreFltrsMoreIndexing(t *testing.T) { "*string:~*req.Account:1001", "fltr_for_attr3", "fltr_for_attr2"}, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, APIOpts: nil, } @@ -1995,7 +2003,11 @@ func testV1FIdxChargerMoreProfileForFilters(t *testing.T) { RunID: "NEW_ID", FilterIDs: []string{"*string:~*req.Account:1001", "fltr_for_attr3", "fltr_for_attr2"}, - Weight: 40, + Weights: utils.DynamicWeights{ + { + Weight: 40, + }, + }, }, APIOpts: nil, } @@ -2005,7 +2017,11 @@ func testV1FIdxChargerMoreProfileForFilters(t *testing.T) { RunID: "NEW_ID2", FilterIDs: []string{"*string:~*req.Account:1001", "fltr_for_attr"}, - Weight: 40, + Weights: utils.DynamicWeights{ + { + Weight: 40, + }, + }, }, APIOpts: nil, } @@ -3328,9 +3344,12 @@ func testV1FIdxSetResourceSProfileWithFltr(t *testing.T) { ID: "RESOURCE1", FilterIDs: []string{"*string:~*req.Account:1001", "fltr_for_attr"}, - UsageTTL: time.Second, - Limit: 1, - Weight: 10, + UsageTTL: time.Second, + Limit: 1, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, ThresholdIDs: []string{"TH1"}, }, } @@ -3422,9 +3441,12 @@ func testV1FIdxSetResourceSMoreFltrsMoreIndexing(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001", "fltr_for_attr", "fltr_for_attr3", "fltr_for_attr2"}, - UsageTTL: time.Second, - Limit: 1, - Weight: 10, + UsageTTL: time.Second, + Limit: 1, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, ThresholdIDs: []string{"TH1"}, }, } @@ -3526,7 +3548,10 @@ func testV1FIdxResourceSMoreProfilesForFltrs(t *testing.T) { "fltr_for_attr3", "fltr_for_attr2"}, UsageTTL: time.Second, Limit: 8, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }}, }, } resPrfl2 := &engine.ResourceProfileWithAPIOpts{ @@ -3537,7 +3562,10 @@ func testV1FIdxResourceSMoreProfilesForFltrs(t *testing.T) { "fltr_for_attr"}, UsageTTL: time.Second, Limit: 4, - Weight: 150, + Weights: utils.DynamicWeights{ + { + Weight: 150, + }}, }, } var reply string diff --git a/apis/filters_test.go b/apis/filters_test.go index 06a1f6878..f0eb68236 100644 --- a/apis/filters_test.go +++ b/apis/filters_test.go @@ -857,7 +857,10 @@ func TestFiltersSetFilterReloadCache(t *testing.T) { ResourceProfile: &engine.ResourceProfile{ ID: "RES_ID", FilterIDs: []string{"FLTR_ID"}, - Weight: 10, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, }, APIOpts: map[string]interface{}{ utils.MetaCache: utils.MetaNone, @@ -1026,7 +1029,10 @@ func TestFiltersSetFilterClearCache(t *testing.T) { ResourceProfile: &engine.ResourceProfile{ ID: "RES_ID", FilterIDs: []string{"FLTR_ID"}, - Weight: 10, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, }, APIOpts: map[string]interface{}{ utils.MetaCache: utils.MetaNone, diff --git a/apis/loaders_it_test.go b/apis/loaders_it_test.go index cd7b848b5..39424b262 100644 --- a/apis/loaders_it_test.go +++ b/apis/loaders_it_test.go @@ -653,7 +653,11 @@ func testLoadersGetChargerProfiles(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, RunID: "*rated", AttributeIDs: []string{"ATTR_1001_SIMPLEAUTH"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, { Tenant: "cgrates.org", @@ -661,7 +665,11 @@ func testLoadersGetChargerProfiles(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1002"}, RunID: "*rated", AttributeIDs: []string{"ATTR_1002_SIMPLEAUTH"}, - Weight: 15, + Weights: utils.DynamicWeights{ + { + Weight: 15, + }, + }, }, } var chrgs []*engine.ChargerProfile @@ -975,10 +983,13 @@ func testLoadersGetResourceProfiles(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, UsageTTL: time.Second, AllocationMessage: "call", - Weight: 10, - Limit: 2, - Blocker: true, - Stored: true, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 2, + Blocker: true, + Stored: true, }, { Tenant: "cgrates.org", @@ -988,8 +999,11 @@ func testLoadersGetResourceProfiles(t *testing.T) { AllocationMessage: "premium_call", Blocker: true, Stored: true, - Weight: 10, - Limit: 2, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 2, }, } var rsPrfs []*engine.ResourceProfile diff --git a/apis/resources_it_test.go b/apis/resources_it_test.go index 6f5d212ed..2014d3dd7 100644 --- a/apis/resources_it_test.go +++ b/apis/resources_it_test.go @@ -180,8 +180,11 @@ func testResourceSSetResourceProfiles(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, Limit: 10, AllocationMessage: "Approved", - Weight: 20, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }}, + ThresholdIDs: []string{utils.MetaNone}, }, } @@ -200,8 +203,11 @@ func testResourceSSetResourceProfiles(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, Limit: 10, AllocationMessage: "Approved", - Weight: 10, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + ThresholdIDs: []string{utils.MetaNone}, }, } @@ -227,8 +233,11 @@ func testResourceSGetResourceAfterSet(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, Limit: 10, AllocationMessage: "Approved", - Weight: 20, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }}, + ThresholdIDs: []string{utils.MetaNone}, } if err := rsRPC.Call(context.Background(), utils.ResourceSv1GetResource, @@ -264,8 +273,11 @@ func testResourceSGetResourceAfterSet(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, Limit: 10, AllocationMessage: "Approved", - Weight: 10, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + ThresholdIDs: []string{utils.MetaNone}, } if err := rsRPC.Call(context.Background(), utils.ResourceSv1GetResource, @@ -305,8 +317,11 @@ func testResourceSGetResourceWithConfigAfterSet(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, Limit: 10, AllocationMessage: "Approved", - Weight: 10, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + ThresholdIDs: []string{utils.MetaNone}, }, } @@ -347,8 +362,11 @@ func testResourceSGetResourceProfiles(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, Limit: 10, AllocationMessage: "Approved", - Weight: 20, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }}, + ThresholdIDs: []string{utils.MetaNone}, }, { Tenant: "cgrates.org", @@ -356,8 +374,11 @@ func testResourceSGetResourceProfiles(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, Limit: 10, AllocationMessage: "Approved", - Weight: 10, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + ThresholdIDs: []string{utils.MetaNone}, }, } if err := rsRPC.Call(context.Background(), utils.AdminSv1GetResourceProfiles, @@ -735,8 +756,11 @@ func testResourceSGetResourceProfilesWithPrefix(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, Limit: 10, AllocationMessage: "Approved", - Weight: 20, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }}, + ThresholdIDs: []string{utils.MetaNone}, }, } @@ -755,8 +779,11 @@ func testResourceSGetResourceProfilesWithPrefix(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, Limit: 10, AllocationMessage: "Approved", - Weight: 10, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + ThresholdIDs: []string{utils.MetaNone}, }, } @@ -778,8 +805,11 @@ func testResourceSGetResourceProfilesWithPrefix(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, Limit: 10, AllocationMessage: "Approved", - Weight: 20, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }}, + ThresholdIDs: []string{utils.MetaNone}, }, } if err := rsRPC.Call(context.Background(), utils.AdminSv1GetResourceProfiles, diff --git a/apis/resources_test.go b/apis/resources_test.go index 0693470f2..928f83594 100644 --- a/apis/resources_test.go +++ b/apis/resources_test.go @@ -53,7 +53,10 @@ func TestResourcesSetGetRemResourceProfile(t *testing.T) { ID: "RES_1", AllocationMessage: "Approved", Limit: 5, - Weight: 10, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, }, } if err := adms.SetResourceProfile(context.Background(), resPrf, &reply); err != nil { @@ -228,10 +231,13 @@ func TestResourcesRemoveResourceProfileCheckErrors(t *testing.T) { resPrf := &engine.ResourceProfileWithAPIOpts{ ResourceProfile: &engine.ResourceProfile{ - ID: "TestResourcesRemoveResourceProfileCheckErrors", - Tenant: "cgrates.org", - Limit: 5, - Weight: 10, + ID: "TestResourcesRemoveResourceProfileCheckErrors", + Tenant: "cgrates.org", + Limit: 5, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, AllocationMessage: "Approved", }, } @@ -499,7 +505,10 @@ func TestResourcesGetResource(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, Limit: 5, AllocationMessage: "Approved", - Weight: 10, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, }, } @@ -604,7 +613,10 @@ func TestResourcesAuthorizeAllocateReleaseResource(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, Limit: 5, AllocationMessage: "Approved", - Weight: 10, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, }, } diff --git a/cmd/cgr-loader/cgr-loader_remove_it_test.go b/cmd/cgr-loader/cgr-loader_remove_it_test.go index ee846af07..e503f7419 100644 --- a/cmd/cgr-loader/cgr-loader_remove_it_test.go +++ b/cmd/cgr-loader/cgr-loader_remove_it_test.go @@ -507,10 +507,13 @@ func testCgrLdrGetRateProfileAfterLoad(t *testing.T) { func testCgrLdrGetResourceProfileAfterLoad(t *testing.T) { expREsPrf := &engine.ResourceProfile{ - Tenant: utils.CGRateSorg, - ID: "RES_ACNT_1001", - FilterIDs: []string{"FLTR_ACCOUNT_1001"}, - Weight: 10, + Tenant: utils.CGRateSorg, + ID: "RES_ACNT_1001", + FilterIDs: []string{"FLTR_ACCOUNT_1001"}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, UsageTTL: time.Hour, Limit: 1, ThresholdIDs: []string{}, diff --git a/config/config_defaults.go b/config/config_defaults.go index e4a650b9f..391ee0b6e 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -1255,7 +1255,7 @@ const CGRATES_CFG_JSON = ` {"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": "Weight", "path": "Weight", "type": "*variable", "value": "~*req.3"}, + {"tag": "Weights", "path": "Weights", "type": "*variable", "value": "~*req.3"}, {"tag": "TTL", "path": "UsageTTL", "type": "*variable", "value": "~*req.4"}, {"tag": "Limit", "path": "Limit", "type": "*variable", "value": "~*req.5"}, {"tag": "AllocationMessage", "path": "AllocationMessage", "type": "*variable", "value": "~*req.6"}, @@ -1326,7 +1326,7 @@ const CGRATES_CFG_JSON = ` {"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": "Weight", "path": "Weight", "type": "*variable", "value": "~*req.3"}, + {"tag": "Weights", "path": "Weights", "type": "*variable", "value": "~*req.3"}, {"tag": "RunID", "path": "RunID", "type": "*variable", "value": "~*req.4"}, {"tag": "AttributeIDs", "path": "AttributeIDs", "type": "*variable", "value": "~*req.5"}, ], diff --git a/config/config_json_test.go b/config/config_json_test.go index a9a5c604f..2362d98d4 100644 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -1247,8 +1247,8 @@ func TestDfLoaderJsonCfg(t *testing.T) { Path: utils.StringPointer("FilterIDs"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.2")}, - {Tag: utils.StringPointer("Weight"), - Path: utils.StringPointer("Weight"), + {Tag: utils.StringPointer("Weights"), + Path: utils.StringPointer("Weights"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.3")}, {Tag: utils.StringPointer("TTL"), @@ -1469,8 +1469,8 @@ func TestDfLoaderJsonCfg(t *testing.T) { Path: utils.StringPointer("FilterIDs"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.2")}, - {Tag: utils.StringPointer("Weight"), - Path: utils.StringPointer("Weight"), + {Tag: utils.StringPointer("Weights"), + Path: utils.StringPointer("Weights"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~*req.3")}, {Tag: utils.StringPointer("RunID"), diff --git a/config/config_test.go b/config/config_test.go index 2e6d84e5e..a11563c98 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -9,7 +9,7 @@ the Free Software Foundation, either version 3 of the License, or 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 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PU:3474RPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License @@ -2729,8 +2729,8 @@ func TestCgrLoaderCfgITDefaults(t *testing.T) { Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.2", utils.InfieldSep), Layout: time.RFC3339}, - {Tag: "Weight", - Path: "Weight", + {Tag: "Weights", + Path: "Weights", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.3", utils.InfieldSep), Layout: time.RFC3339}, @@ -2999,8 +2999,8 @@ func TestCgrLoaderCfgITDefaults(t *testing.T) { Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.2", utils.InfieldSep), Layout: time.RFC3339}, - {Tag: "Weight", - Path: "Weight", + {Tag: "Weights", + Path: "Weights", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.3", utils.InfieldSep), Layout: time.RFC3339}, @@ -5364,7 +5364,7 @@ func TestV1GetConfigAsJSONDispatcherH(t *testing.T) { func TestV1GetConfigAsJSONLoaders(t *testing.T) { var reply string - expected := `{"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.4"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.5"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.6"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.7"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.8"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.7"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.4"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.5"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.6"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.7"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.12"},{"path":"Routes.Blocker","tag":"RouteBlocker","type":"*variable","value":"~*req.13"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.14"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.4"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.5"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.4"},{"path":"StrategyParams","tag":"StrategyParameters","type":"*variable","value":"~*req.5"},{"new_branch":true,"path":"Hosts.ID","tag":"ConnID","type":"*variable","value":"~*req.6"},{"path":"Hosts.FilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.7"},{"path":"Hosts.Weight","tag":"ConnWeight","type":"*variable","value":"~*req.8"},{"path":"Hosts.Blocker","tag":"ConnBlocker","type":"*variable","value":"~*req.9"},{"path":"Hosts.Params","tag":"ConnParameters","type":"*variable","value":"~*req.10"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"ConnectAttempts","tag":"ConnectAttempts","type":"*variable","value":"~*req.4"},{"path":"Reconnects","tag":"Reconnects","type":"*variable","value":"~*req.5"},{"path":"ConnectTimeout","tag":"ConnectTimeout","type":"*variable","value":"~*req.6"},{"path":"ReplyTimeout","tag":"ReplyTimeout","type":"*variable","value":"~*req.7"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.8"},{"path":"ClientKey","tag":"ClientKey","type":"*variable","value":"~*req.9"},{"path":"ClientCertificate","tag":"ClientCertificate","type":"*variable","value":"~*req.10"},{"path":"CaCertificate","tag":"CaCertificate","type":"*variable","value":"~*req.11"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.4"},{"path":"Targets[\u003c~*req.5\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Blocker","tag":"ActionBlocker","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Actions[\u003c~*req.7\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.4"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.14"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.15"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}]}` + expected := `{"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.4"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.5"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.6"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.7"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.8"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.7"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.4"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.5"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.6"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.7"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.12"},{"path":"Routes.Blocker","tag":"RouteBlocker","type":"*variable","value":"~*req.13"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.14"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.4"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.5"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.4"},{"path":"StrategyParams","tag":"StrategyParameters","type":"*variable","value":"~*req.5"},{"new_branch":true,"path":"Hosts.ID","tag":"ConnID","type":"*variable","value":"~*req.6"},{"path":"Hosts.FilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.7"},{"path":"Hosts.Weight","tag":"ConnWeight","type":"*variable","value":"~*req.8"},{"path":"Hosts.Blocker","tag":"ConnBlocker","type":"*variable","value":"~*req.9"},{"path":"Hosts.Params","tag":"ConnParameters","type":"*variable","value":"~*req.10"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"ConnectAttempts","tag":"ConnectAttempts","type":"*variable","value":"~*req.4"},{"path":"Reconnects","tag":"Reconnects","type":"*variable","value":"~*req.5"},{"path":"ConnectTimeout","tag":"ConnectTimeout","type":"*variable","value":"~*req.6"},{"path":"ReplyTimeout","tag":"ReplyTimeout","type":"*variable","value":"~*req.7"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.8"},{"path":"ClientKey","tag":"ClientKey","type":"*variable","value":"~*req.9"},{"path":"ClientCertificate","tag":"ClientCertificate","type":"*variable","value":"~*req.10"},{"path":"CaCertificate","tag":"CaCertificate","type":"*variable","value":"~*req.11"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.4"},{"path":"Targets[\u003c~*req.5\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Blocker","tag":"ActionBlocker","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Actions[\u003c~*req.7\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.4"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.14"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.15"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}]}` cgrCfg := NewDefaultCGRConfig() if err := cgrCfg.V1GetConfigAsJSON(context.Background(), &SectionWithAPIOpts{Sections: []string{LoaderSJSON}}, &reply); err != nil { t.Error(err) @@ -5581,7 +5581,7 @@ func TestV1GetConfigAsJSONAllConfig(t *testing.T) { } }` var reply string - expected := `{"accounts":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"max_iterations":1000,"max_usage":"259200000000000","nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[],"*usage":[]},"prefix_indexed_fields":[],"rates_conns":[],"suffix_indexed_fields":[],"thresholds_conns":[]},"actions":{"accounts_conns":[],"cdrs_conns":[],"dynaprepaid_actionprofile":[],"ees_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[]},"prefix_indexed_fields":[],"stats_conns":[],"suffix_indexed_fields":[],"tenants":[],"thresholds_conns":[]},"admins":{"actions_conns":[],"attributes_conns":[],"caches_conns":["*internal"],"ees_conns":[],"enabled":false},"analyzers":{"cleanup_interval":"1h0m0s","db_path":"/var/spool/cgrates/analyzers","enabled":false,"index_type":"*scorch","ttl":"24h0m0s"},"apiban":{"enabled":false,"keys":[]},"asterisk_agent":{"asterisk_conns":[{"address":"127.0.0.1:8088","alias":"","connect_attempts":3,"password":"CGRateS.org","reconnects":5,"user":"cgrates"}],"create_cdr":false,"enabled":false,"sessions_conns":["*birpc_internal"]},"attributes":{"accounts_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*processRuns":[],"*profileIDs":[],"*profileIgnoreFilters":[],"*profileRuns":[]},"prefix_indexed_fields":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_loads":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*event_charges":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"replication_conns":[]},"cdrs":{"accounts_conns":[],"actions_conns":[],"attributes_conns":[],"chargers_conns":[],"ees_conns":[],"enabled":false,"extra_fields":[],"online_cdr_exports":null,"opts":{"*accountS":[],"*attributeS":[],"*chargerS":[],"*eeS":[],"*rateS":[],"*statS":[],"*thresholdS":[]},"rates_conns":[],"session_cost_retries":5,"stats_conns":[],"store_cdrs":true,"thresholds_conns":[]},"chargers":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"config_db":{"db_host":"","db_name":"","db_password":"","db_port":0,"db_type":"*internal","db_user":"","opts":{"mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisSentinel":"","redisTLS":false}},"configs":{"enabled":false,"root_dir":"/var/spool/cgrates/configs","url":"/configs/"},"cores":{"caps":0,"caps_stats_interval":"0","caps_strategy":"*busy","ees_conns":[],"shutdown_timeout":"1s"},"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*account_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*actions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*stat_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false},"diameter_agent":{"asr_template":"","concurrent_requests":-1,"dictionaries_path":"/usr/share/cgrates/diameter/dict/","enabled":false,"forced_disconnect":"*none","listen":"127.0.0.1:3868","listen_net":"tcp","origin_host":"CGR-DA","origin_realm":"cgrates.org","product_name":"CGRateS","rar_template":"","request_processors":[],"sessions_conns":["*birpc_internal"],"synced_conn_requests":false,"vendor_id":0},"dispatchers":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"dns_agent":{"enabled":false,"listen":"127.0.0.1:2053","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"],"timezone":""},"ees":{"attributes_conns":[],"cache":{"*fileCSV":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"enabled":false,"exporters":[{"attempts":1,"attribute_context":"","attribute_ids":[],"concurrent_requests":0,"export_path":"/var/spool/cgrates/ees","failed_posts_dir":"/var/spool/cgrates/failed_posts","fields":[],"filters":[],"flags":[],"id":"*default","opts":{},"synchronous":false,"timezone":"","type":"*none"}]},"ers":{"enabled":false,"partial_cache_ttl":"1s","readers":[{"cache_dump_fields":[],"concurrent_requests":1024,"fields":[{"mandatory":true,"path":"*cgreq.ToR","tag":"ToR","type":"*variable","value":"~*req.2"},{"mandatory":true,"path":"*cgreq.OriginID","tag":"OriginID","type":"*variable","value":"~*req.3"},{"mandatory":true,"path":"*cgreq.RequestType","tag":"RequestType","type":"*variable","value":"~*req.4"},{"mandatory":true,"path":"*cgreq.Tenant","tag":"Tenant","type":"*variable","value":"~*req.6"},{"mandatory":true,"path":"*cgreq.Category","tag":"Category","type":"*variable","value":"~*req.7"},{"mandatory":true,"path":"*cgreq.Account","tag":"Account","type":"*variable","value":"~*req.8"},{"mandatory":true,"path":"*cgreq.Subject","tag":"Subject","type":"*variable","value":"~*req.9"},{"mandatory":true,"path":"*cgreq.Destination","tag":"Destination","type":"*variable","value":"~*req.10"},{"mandatory":true,"path":"*cgreq.SetupTime","tag":"SetupTime","type":"*variable","value":"~*req.11"},{"mandatory":true,"path":"*cgreq.AnswerTime","tag":"AnswerTime","type":"*variable","value":"~*req.12"},{"mandatory":true,"path":"*cgreq.Usage","tag":"Usage","type":"*variable","value":"~*req.13"}],"filters":[],"flags":[],"id":"*default","opts":{"csvFieldSeparator":",","csvHeaderDefineChar":":","csvRowLength":0,"natsSubject":"cgrates_cdrs","partialCacheAction":"*none","partialOrderField":"~*req.AnswerTime","xmlRootPath":""},"partial_commit_fields":[],"processed_path":"/var/spool/cgrates/ers/out","run_delay":"0","source_path":"/var/spool/cgrates/ers/in","tenant":"","timezone":"","type":"*none"}],"sessions_conns":["*internal"]},"filters":{"accounts_conns":[],"resources_conns":[],"stats_conns":[]},"freeswitch_agent":{"create_cdr":false,"empty_balance_ann_file":"","empty_balance_context":"","enabled":false,"event_socket_conns":[{"address":"127.0.0.1:8021","alias":"127.0.0.1:8021","password":"ClueCon","reconnects":5}],"extra_fields":[],"low_balance_ann_file":"","max_wait_connection":"2s","sessions_conns":["*birpc_internal"],"subscribe_park":true},"general":{"connect_attempts":5,"connect_timeout":"1s","dbdata_encoding":"*msgpack","decimal_max_scale":0,"decimal_min_scale":0,"decimal_precision":0,"decimal_rounding_mode":"*toNearestEven","default_caching":"*reload","default_category":"call","default_request_type":"*rated","default_tenant":"cgrates.org","default_timezone":"Local","digest_equal":":","digest_separator":",","failed_posts_dir":"/var/spool/cgrates/failed_posts","failed_posts_ttl":"5s","locking_timeout":"0","log_level":6,"logger":"*syslog","max_parallel_conns":100,"node_id":"ENGINE1","poster_attempts":3,"reconnects":-1,"reply_timeout":"2s","rounding_decimals":5,"rsr_separator":";","tpexport_dir":"/var/spool/cgrates/tpe"},"http":{"auth_users":{},"client_opts":{"dialFallbackDelay":"300ms","dialKeepAlive":"30s","dialTimeout":"30s","disableCompression":false,"disableKeepAlives":false,"expectContinueTimeout":"0s","forceAttemptHttp2":true,"idleConnTimeout":"1m30s","maxConnsPerHost":0,"maxIdleConns":100,"maxIdleConnsPerHost":2,"responseHeaderTimeout":"0s","skipTLSVerification":false,"tlsHandshakeTimeout":"10s"},"freeswitch_cdrs_url":"/freeswitch_json","http_cdrs":"/cdr_http","json_rpc_url":"/jsonrpc","prometheus_url":"/prometheus","registrars_url":"/registrar","use_basic_auth":false,"ws_url":"/ws"},"http_agent":[],"kamailio_agent":{"create_cdr":false,"enabled":false,"evapi_conns":[{"address":"127.0.0.1:8448","alias":"","reconnects":5}],"sessions_conns":["*birpc_internal"],"timezone":""},"listen":{"http":"127.0.0.1:2080","http_tls":"127.0.0.1:2280","rpc_gob":"127.0.0.1:2013","rpc_gob_tls":"127.0.0.1:2023","rpc_json":"127.0.0.1:2012","rpc_json_tls":"127.0.0.1:2022"},"loader":{"actions_conns":["*localhost"],"caches_conns":["*localhost"],"data_path":"./","disable_reverse":false,"field_separator":",","gapi_credentials":".gapi/credentials.json","gapi_token":".gapi/token.json","tpid":""},"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.4"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.5"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.6"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.7"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.8"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.7"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.4"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.5"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.6"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.7"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.12"},{"path":"Routes.Blocker","tag":"RouteBlocker","type":"*variable","value":"~*req.13"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.14"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.4"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.5"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.4"},{"path":"StrategyParams","tag":"StrategyParameters","type":"*variable","value":"~*req.5"},{"new_branch":true,"path":"Hosts.ID","tag":"ConnID","type":"*variable","value":"~*req.6"},{"path":"Hosts.FilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.7"},{"path":"Hosts.Weight","tag":"ConnWeight","type":"*variable","value":"~*req.8"},{"path":"Hosts.Blocker","tag":"ConnBlocker","type":"*variable","value":"~*req.9"},{"path":"Hosts.Params","tag":"ConnParameters","type":"*variable","value":"~*req.10"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"ConnectAttempts","tag":"ConnectAttempts","type":"*variable","value":"~*req.4"},{"path":"Reconnects","tag":"Reconnects","type":"*variable","value":"~*req.5"},{"path":"ConnectTimeout","tag":"ConnectTimeout","type":"*variable","value":"~*req.6"},{"path":"ReplyTimeout","tag":"ReplyTimeout","type":"*variable","value":"~*req.7"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.8"},{"path":"ClientKey","tag":"ClientKey","type":"*variable","value":"~*req.9"},{"path":"ClientCertificate","tag":"ClientCertificate","type":"*variable","value":"~*req.10"},{"path":"CaCertificate","tag":"CaCertificate","type":"*variable","value":"~*req.11"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.4"},{"path":"Targets[\u003c~*req.5\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Blocker","tag":"ActionBlocker","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Actions[\u003c~*req.7\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.4"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.14"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.15"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}],"migrator":{"out_datadb_encoding":"msgpack","out_datadb_host":"127.0.0.1","out_datadb_name":"10","out_datadb_opts":{"mongoQueryTimeout":"0s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"out_datadb_password":"","out_datadb_port":"6379","out_datadb_type":"redis","out_datadb_user":"cgrates","out_stordb_host":"127.0.0.1","out_stordb_name":"cgrates","out_stordb_opts":{"mongoQueryTimeout":"0s","mysqlLocation":"","sqlConnMaxLifetime":"0s","sqlMaxIdleConns":0,"sqlMaxOpenConns":0,"sslMode":""},"out_stordb_password":"","out_stordb_port":"3306","out_stordb_type":"mysql","out_stordb_user":"cgrates","users_filters":null},"radius_agent":{"client_dictionaries":{"*default":"/usr/share/cgrates/radius/dict/"},"client_secrets":{"*default":"CGRateS.org"},"enabled":false,"listen_acct":"127.0.0.1:1813","listen_auth":"127.0.0.1:1812","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"]},"rates":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*intervalStart":[],"*profileIDs":[],"*profileIgnoreFilters":[],"*startTime":[],"*usage":[]},"prefix_indexed_fields":[],"rate_exists_indexed_fields":[],"rate_indexed_selects":true,"rate_nested_fields":false,"rate_notexists_indexed_fields":[],"rate_prefix_indexed_fields":[],"rate_suffix_indexed_fields":[],"suffix_indexed_fields":[],"verbosity":1000},"registrarc":{"dispatchers":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]},"rpc":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]}},"resources":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*units":[],"*usageID":[],"*usageTTL":[]},"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[],"thresholds_conns":[]},"routes":{"accounts_conns":[],"attributes_conns":[],"default_ratio":1,"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*context":[],"*ignoreErrors":[],"*limit":[],"*maxCost":[],"*maxItems":[],"*offset":[],"*profileCount":[],"*usage":[]},"prefix_indexed_fields":[],"rates_conns":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"rpc_conns":{"*bijson_localhost":{"conns":[{"address":"127.0.0.1:2014","transport":"*birpc_json"}],"poolSize":0,"strategy":"*first"},"*birpc_internal":{"conns":[{"address":"*birpc_internal","transport":""}],"poolSize":0,"strategy":"*first"},"*internal":{"conns":[{"address":"*internal","transport":""}],"poolSize":0,"strategy":"*first"},"*localhost":{"conns":[{"address":"127.0.0.1:2012","transport":"*json"}],"poolSize":0,"strategy":"*first"}},"sessions":{"accounts_conns":[],"actions_conns":[],"alterable_fields":[],"attributes_conns":[],"cdrs_conns":[],"channel_sync_interval":"0","chargers_conns":[],"client_protocol":1,"default_usage":{"*any":"3h0m0s","*data":"1048576","*sms":"1","*voice":"3h0m0s"},"enabled":false,"listen_bigob":"","listen_bijson":"127.0.0.1:2014","min_dur_low_balance":"0","opts":{"*accountS":[],"*attributeS":[],"*attributesDerivedReply":[],"*blockerError":[],"*cdrS":[],"*cdrsDerivedReply":[],"*chargeable":[],"*chargerS":[],"*debitInterval":[],"*forceDuration":[],"*initiate":[],"*maxUsage":[],"*message":[],"*resourceS":[],"*resourcesAllocate":[],"*resourcesAuthorize":[],"*resourcesDerivedReply":[],"*resourcesRelease":[],"*routeS":[],"*routesDerivedReply":[],"*statS":[],"*statsDerivedReply":[],"*terminate":[],"*thresholdS":[],"*thresholdsDerivedReply":[],"*ttl":[],"*ttlLastUsage":[],"*ttlLastUsed":[],"*ttlMaxDelay":[],"*ttlUsage":[],"*update":[]},"rates_conns":[],"replication_conns":[],"resources_conns":[],"routes_conns":[],"session_indexes":[],"stats_conns":[],"stir":{"allowed_attest":["*any"],"default_attest":"A","payload_maxduration":"-1","privatekey_path":"","publickey_path":""},"store_session_costs":false,"terminate_attempts":5,"thresholds_conns":[]},"sip_agent":{"enabled":false,"listen":"127.0.0.1:5060","listen_net":"udp","request_processors":[],"retransmission_timer":"1s","sessions_conns":["*internal"],"timezone":""},"stats":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[],"*prometheusStatIDs":[],"*roundingDecimals":[]},"prefix_indexed_fields":[],"store_interval":"","store_uncompressed_limit":0,"suffix_indexed_fields":[],"thresholds_conns":[]},"stor_db":{"db_host":"127.0.0.1","db_name":"cgrates","db_password":"","db_port":3306,"db_type":"*mysql","db_user":"cgrates","items":{"*cdrs":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*session_costs":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_attributes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_chargers":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_dispatcher_hosts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_dispatcher_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_routes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_stats":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoQueryTimeout":"10s","mysqlDSNParams":{},"mysqlLocation":"Local","sqlConnMaxLifetime":"0s","sqlMaxIdleConns":10,"sqlMaxOpenConns":100,"sslMode":"disable"},"prefix_indexed_fields":[],"remote_conns":null,"replication_conns":null,"string_indexed_fields":[]},"suretax":{"bill_to_number":"","business_unit":"","client_number":"","client_tracking":"~*opts.*originID","customer_number":"~*req.Subject","include_local_cost":false,"orig_number":"~*req.Subject","p2pplus4":"","p2pzipcode":"","plus4":"","regulatory_code":"03","response_group":"03","response_type":"D4","return_file_code":"0","sales_type_code":"R","tax_exemption_code_list":"","tax_included":"0","tax_situs_rule":"04","term_number":"~*req.Destination","timezone":"UTC","trans_type_code":"010101","unit_type":"00","units":"1","url":"","validation_key":"","zipcode":""},"templates":{"*asr":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"}],"*cca":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"path":"*rep.Result-Code","tag":"ResultCode","type":"*constant","value":"2001"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"},{"mandatory":true,"path":"*rep.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"mandatory":true,"path":"*rep.CC-Request-Type","tag":"CCRequestType","type":"*variable","value":"~*req.CC-Request-Type"},{"mandatory":true,"path":"*rep.CC-Request-Number","tag":"CCRequestNumber","type":"*variable","value":"~*req.CC-Request-Number"}],"*cdrLog":[{"mandatory":true,"path":"*cdr.ToR","tag":"ToR","type":"*variable","value":"~*req.BalanceType"},{"mandatory":true,"path":"*cdr.OriginHost","tag":"OriginHost","type":"*constant","value":"127.0.0.1"},{"mandatory":true,"path":"*cdr.RequestType","tag":"RequestType","type":"*constant","value":"*none"},{"mandatory":true,"path":"*cdr.Tenant","tag":"Tenant","type":"*variable","value":"~*req.Tenant"},{"mandatory":true,"path":"*cdr.Account","tag":"Account","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Subject","tag":"Subject","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Cost","tag":"Cost","type":"*variable","value":"~*req.Cost"},{"mandatory":true,"path":"*cdr.Source","tag":"Source","type":"*constant","value":"*cdrLog"},{"mandatory":true,"path":"*cdr.Usage","tag":"Usage","type":"*constant","value":"1"},{"mandatory":true,"path":"*cdr.RunID","tag":"RunID","type":"*variable","value":"~*req.ActionType"},{"mandatory":true,"path":"*cdr.SetupTime","tag":"SetupTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.AnswerTime","tag":"AnswerTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.PreRated","tag":"PreRated","type":"*constant","value":"true"}],"*err":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"}],"*errSip":[{"mandatory":true,"path":"*rep.Request","tag":"Request","type":"*constant","value":"SIP/2.0 500 Internal Server Error"}],"*rar":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"path":"*diamreq.Re-Auth-Request-Type","tag":"ReAuthRequestType","type":"*constant","value":"0"}]},"thresholds":{"actions_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[]},"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[]},"tls":{"ca_certificate":"","client_certificate":"","client_key":"","server_certificate":"","server_key":"","server_name":"","server_policy":4}}` + expected := `{"accounts":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"max_iterations":1000,"max_usage":"259200000000000","nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[],"*usage":[]},"prefix_indexed_fields":[],"rates_conns":[],"suffix_indexed_fields":[],"thresholds_conns":[]},"actions":{"accounts_conns":[],"cdrs_conns":[],"dynaprepaid_actionprofile":[],"ees_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[]},"prefix_indexed_fields":[],"stats_conns":[],"suffix_indexed_fields":[],"tenants":[],"thresholds_conns":[]},"admins":{"actions_conns":[],"attributes_conns":[],"caches_conns":["*internal"],"ees_conns":[],"enabled":false},"analyzers":{"cleanup_interval":"1h0m0s","db_path":"/var/spool/cgrates/analyzers","enabled":false,"index_type":"*scorch","ttl":"24h0m0s"},"apiban":{"enabled":false,"keys":[]},"asterisk_agent":{"asterisk_conns":[{"address":"127.0.0.1:8088","alias":"","connect_attempts":3,"password":"CGRateS.org","reconnects":5,"user":"cgrates"}],"create_cdr":false,"enabled":false,"sessions_conns":["*birpc_internal"]},"attributes":{"accounts_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*processRuns":[],"*profileIDs":[],"*profileIgnoreFilters":[],"*profileRuns":[]},"prefix_indexed_fields":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_loads":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*event_charges":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"replication_conns":[]},"cdrs":{"accounts_conns":[],"actions_conns":[],"attributes_conns":[],"chargers_conns":[],"ees_conns":[],"enabled":false,"extra_fields":[],"online_cdr_exports":null,"opts":{"*accountS":[],"*attributeS":[],"*chargerS":[],"*eeS":[],"*rateS":[],"*statS":[],"*thresholdS":[]},"rates_conns":[],"session_cost_retries":5,"stats_conns":[],"store_cdrs":true,"thresholds_conns":[]},"chargers":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"config_db":{"db_host":"","db_name":"","db_password":"","db_port":0,"db_type":"*internal","db_user":"","opts":{"mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisSentinel":"","redisTLS":false}},"configs":{"enabled":false,"root_dir":"/var/spool/cgrates/configs","url":"/configs/"},"cores":{"caps":0,"caps_stats_interval":"0","caps_strategy":"*busy","ees_conns":[],"shutdown_timeout":"1s"},"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*account_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*actions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*stat_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false},"diameter_agent":{"asr_template":"","concurrent_requests":-1,"dictionaries_path":"/usr/share/cgrates/diameter/dict/","enabled":false,"forced_disconnect":"*none","listen":"127.0.0.1:3868","listen_net":"tcp","origin_host":"CGR-DA","origin_realm":"cgrates.org","product_name":"CGRateS","rar_template":"","request_processors":[],"sessions_conns":["*birpc_internal"],"synced_conn_requests":false,"vendor_id":0},"dispatchers":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"dns_agent":{"enabled":false,"listen":"127.0.0.1:2053","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"],"timezone":""},"ees":{"attributes_conns":[],"cache":{"*fileCSV":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"enabled":false,"exporters":[{"attempts":1,"attribute_context":"","attribute_ids":[],"concurrent_requests":0,"export_path":"/var/spool/cgrates/ees","failed_posts_dir":"/var/spool/cgrates/failed_posts","fields":[],"filters":[],"flags":[],"id":"*default","opts":{},"synchronous":false,"timezone":"","type":"*none"}]},"ers":{"enabled":false,"partial_cache_ttl":"1s","readers":[{"cache_dump_fields":[],"concurrent_requests":1024,"fields":[{"mandatory":true,"path":"*cgreq.ToR","tag":"ToR","type":"*variable","value":"~*req.2"},{"mandatory":true,"path":"*cgreq.OriginID","tag":"OriginID","type":"*variable","value":"~*req.3"},{"mandatory":true,"path":"*cgreq.RequestType","tag":"RequestType","type":"*variable","value":"~*req.4"},{"mandatory":true,"path":"*cgreq.Tenant","tag":"Tenant","type":"*variable","value":"~*req.6"},{"mandatory":true,"path":"*cgreq.Category","tag":"Category","type":"*variable","value":"~*req.7"},{"mandatory":true,"path":"*cgreq.Account","tag":"Account","type":"*variable","value":"~*req.8"},{"mandatory":true,"path":"*cgreq.Subject","tag":"Subject","type":"*variable","value":"~*req.9"},{"mandatory":true,"path":"*cgreq.Destination","tag":"Destination","type":"*variable","value":"~*req.10"},{"mandatory":true,"path":"*cgreq.SetupTime","tag":"SetupTime","type":"*variable","value":"~*req.11"},{"mandatory":true,"path":"*cgreq.AnswerTime","tag":"AnswerTime","type":"*variable","value":"~*req.12"},{"mandatory":true,"path":"*cgreq.Usage","tag":"Usage","type":"*variable","value":"~*req.13"}],"filters":[],"flags":[],"id":"*default","opts":{"csvFieldSeparator":",","csvHeaderDefineChar":":","csvRowLength":0,"natsSubject":"cgrates_cdrs","partialCacheAction":"*none","partialOrderField":"~*req.AnswerTime","xmlRootPath":""},"partial_commit_fields":[],"processed_path":"/var/spool/cgrates/ers/out","run_delay":"0","source_path":"/var/spool/cgrates/ers/in","tenant":"","timezone":"","type":"*none"}],"sessions_conns":["*internal"]},"filters":{"accounts_conns":[],"resources_conns":[],"stats_conns":[]},"freeswitch_agent":{"create_cdr":false,"empty_balance_ann_file":"","empty_balance_context":"","enabled":false,"event_socket_conns":[{"address":"127.0.0.1:8021","alias":"127.0.0.1:8021","password":"ClueCon","reconnects":5}],"extra_fields":[],"low_balance_ann_file":"","max_wait_connection":"2s","sessions_conns":["*birpc_internal"],"subscribe_park":true},"general":{"connect_attempts":5,"connect_timeout":"1s","dbdata_encoding":"*msgpack","decimal_max_scale":0,"decimal_min_scale":0,"decimal_precision":0,"decimal_rounding_mode":"*toNearestEven","default_caching":"*reload","default_category":"call","default_request_type":"*rated","default_tenant":"cgrates.org","default_timezone":"Local","digest_equal":":","digest_separator":",","failed_posts_dir":"/var/spool/cgrates/failed_posts","failed_posts_ttl":"5s","locking_timeout":"0","log_level":6,"logger":"*syslog","max_parallel_conns":100,"node_id":"ENGINE1","poster_attempts":3,"reconnects":-1,"reply_timeout":"2s","rounding_decimals":5,"rsr_separator":";","tpexport_dir":"/var/spool/cgrates/tpe"},"http":{"auth_users":{},"client_opts":{"dialFallbackDelay":"300ms","dialKeepAlive":"30s","dialTimeout":"30s","disableCompression":false,"disableKeepAlives":false,"expectContinueTimeout":"0s","forceAttemptHttp2":true,"idleConnTimeout":"1m30s","maxConnsPerHost":0,"maxIdleConns":100,"maxIdleConnsPerHost":2,"responseHeaderTimeout":"0s","skipTLSVerification":false,"tlsHandshakeTimeout":"10s"},"freeswitch_cdrs_url":"/freeswitch_json","http_cdrs":"/cdr_http","json_rpc_url":"/jsonrpc","prometheus_url":"/prometheus","registrars_url":"/registrar","use_basic_auth":false,"ws_url":"/ws"},"http_agent":[],"kamailio_agent":{"create_cdr":false,"enabled":false,"evapi_conns":[{"address":"127.0.0.1:8448","alias":"","reconnects":5}],"sessions_conns":["*birpc_internal"],"timezone":""},"listen":{"http":"127.0.0.1:2080","http_tls":"127.0.0.1:2280","rpc_gob":"127.0.0.1:2013","rpc_gob_tls":"127.0.0.1:2023","rpc_json":"127.0.0.1:2012","rpc_json_tls":"127.0.0.1:2022"},"loader":{"actions_conns":["*localhost"],"caches_conns":["*localhost"],"data_path":"./","disable_reverse":false,"field_separator":",","gapi_credentials":".gapi/credentials.json","gapi_token":".gapi/token.json","tpid":""},"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"new_branch":true,"path":"Rules.Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Rules.Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Rules.Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"new_branch":true,"path":"Attributes.FilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.4"},{"path":"Attributes.Path","tag":"Path","type":"*variable","value":"~*req.5"},{"path":"Attributes.Type","tag":"Type","type":"*variable","value":"~*req.6"},{"path":"Attributes.Value","tag":"Value","type":"*variable","value":"~*req.7"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.8"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.6"},{"new_branch":true,"path":"Metrics.MetricID","tag":"MetricIDs","type":"*variable","value":"~*req.7"},{"path":"Metrics.FilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.4"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.5"},{"new_branch":true,"path":"Routes.ID","tag":"RouteID","type":"*variable","value":"~*req.6"},{"path":"Routes.FilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.7"},{"path":"Routes.AccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.8"},{"path":"Routes.RateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.9"},{"path":"Routes.ResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.10"},{"path":"Routes.StatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.11"},{"path":"Routes.Weights","tag":"RouteWeights","type":"*variable","value":"~*req.12"},{"path":"Routes.Blocker","tag":"RouteBlocker","type":"*variable","value":"~*req.13"},{"path":"Routes.RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.14"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.4"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.5"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.4"},{"path":"StrategyParams","tag":"StrategyParameters","type":"*variable","value":"~*req.5"},{"new_branch":true,"path":"Hosts.ID","tag":"ConnID","type":"*variable","value":"~*req.6"},{"path":"Hosts.FilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.7"},{"path":"Hosts.Weight","tag":"ConnWeight","type":"*variable","value":"~*req.8"},{"path":"Hosts.Blocker","tag":"ConnBlocker","type":"*variable","value":"~*req.9"},{"path":"Hosts.Params","tag":"ConnParameters","type":"*variable","value":"~*req.10"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"ConnectAttempts","tag":"ConnectAttempts","type":"*variable","value":"~*req.4"},{"path":"Reconnects","tag":"Reconnects","type":"*variable","value":"~*req.5"},{"path":"ConnectTimeout","tag":"ConnectTimeout","type":"*variable","value":"~*req.6"},{"path":"ReplyTimeout","tag":"ReplyTimeout","type":"*variable","value":"~*req.7"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.8"},{"path":"ClientKey","tag":"ClientKey","type":"*variable","value":"~*req.9"},{"path":"ClientCertificate","tag":"ClientCertificate","type":"*variable","value":"~*req.10"},{"path":"CaCertificate","tag":"CaCertificate","type":"*variable","value":"~*req.11"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].FilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].ActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Weights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].Blocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Rates[\u003c~*req.7\u003e].IntervalRates.IntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.FixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.RecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Unit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"filters":["*notempty:~*req.7:"],"path":"Rates[\u003c~*req.7\u003e].IntervalRates.Increment","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.4"},{"path":"Targets[\u003c~*req.5\u003e]","tag":"TargetIDs","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].FilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Blocker","tag":"ActionBlocker","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].TTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Type","tag":"ActionType","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Opts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.7:"],"new_branch":true,"path":"Actions[\u003c~*req.7\u003e].Diktats.Path","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.7:"],"path":"Actions[\u003c~*req.7\u003e].Diktats.Value","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.4"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].FilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.6"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Weights","tag":"BalanceWeights","type":"*variable","value":"~*req.7"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Type","tag":"BalanceType","type":"*variable","value":"~*req.8"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Units","tag":"BalanceUnits","type":"*variable","value":"~*req.9"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].UnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.10"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].Opts","tag":"BalanceOpts","type":"*variable","value":"~*req.11"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].CostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.12"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].AttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.13"},{"filters":["*notempty:~*req.5:"],"path":"Balances[\u003c~*req.5\u003e].RateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.14"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.15"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}],"migrator":{"out_datadb_encoding":"msgpack","out_datadb_host":"127.0.0.1","out_datadb_name":"10","out_datadb_opts":{"mongoQueryTimeout":"0s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"out_datadb_password":"","out_datadb_port":"6379","out_datadb_type":"redis","out_datadb_user":"cgrates","out_stordb_host":"127.0.0.1","out_stordb_name":"cgrates","out_stordb_opts":{"mongoQueryTimeout":"0s","mysqlLocation":"","sqlConnMaxLifetime":"0s","sqlMaxIdleConns":0,"sqlMaxOpenConns":0,"sslMode":""},"out_stordb_password":"","out_stordb_port":"3306","out_stordb_type":"mysql","out_stordb_user":"cgrates","users_filters":null},"radius_agent":{"client_dictionaries":{"*default":"/usr/share/cgrates/radius/dict/"},"client_secrets":{"*default":"CGRateS.org"},"enabled":false,"listen_acct":"127.0.0.1:1813","listen_auth":"127.0.0.1:1812","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"]},"rates":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*intervalStart":[],"*profileIDs":[],"*profileIgnoreFilters":[],"*startTime":[],"*usage":[]},"prefix_indexed_fields":[],"rate_exists_indexed_fields":[],"rate_indexed_selects":true,"rate_nested_fields":false,"rate_notexists_indexed_fields":[],"rate_prefix_indexed_fields":[],"rate_suffix_indexed_fields":[],"suffix_indexed_fields":[],"verbosity":1000},"registrarc":{"dispatchers":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]},"rpc":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]}},"resources":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*units":[],"*usageID":[],"*usageTTL":[]},"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[],"thresholds_conns":[]},"routes":{"accounts_conns":[],"attributes_conns":[],"default_ratio":1,"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*context":[],"*ignoreErrors":[],"*limit":[],"*maxCost":[],"*maxItems":[],"*offset":[],"*profileCount":[],"*usage":[]},"prefix_indexed_fields":[],"rates_conns":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"rpc_conns":{"*bijson_localhost":{"conns":[{"address":"127.0.0.1:2014","transport":"*birpc_json"}],"poolSize":0,"strategy":"*first"},"*birpc_internal":{"conns":[{"address":"*birpc_internal","transport":""}],"poolSize":0,"strategy":"*first"},"*internal":{"conns":[{"address":"*internal","transport":""}],"poolSize":0,"strategy":"*first"},"*localhost":{"conns":[{"address":"127.0.0.1:2012","transport":"*json"}],"poolSize":0,"strategy":"*first"}},"sessions":{"accounts_conns":[],"actions_conns":[],"alterable_fields":[],"attributes_conns":[],"cdrs_conns":[],"channel_sync_interval":"0","chargers_conns":[],"client_protocol":1,"default_usage":{"*any":"3h0m0s","*data":"1048576","*sms":"1","*voice":"3h0m0s"},"enabled":false,"listen_bigob":"","listen_bijson":"127.0.0.1:2014","min_dur_low_balance":"0","opts":{"*accountS":[],"*attributeS":[],"*attributesDerivedReply":[],"*blockerError":[],"*cdrS":[],"*cdrsDerivedReply":[],"*chargeable":[],"*chargerS":[],"*debitInterval":[],"*forceDuration":[],"*initiate":[],"*maxUsage":[],"*message":[],"*resourceS":[],"*resourcesAllocate":[],"*resourcesAuthorize":[],"*resourcesDerivedReply":[],"*resourcesRelease":[],"*routeS":[],"*routesDerivedReply":[],"*statS":[],"*statsDerivedReply":[],"*terminate":[],"*thresholdS":[],"*thresholdsDerivedReply":[],"*ttl":[],"*ttlLastUsage":[],"*ttlLastUsed":[],"*ttlMaxDelay":[],"*ttlUsage":[],"*update":[]},"rates_conns":[],"replication_conns":[],"resources_conns":[],"routes_conns":[],"session_indexes":[],"stats_conns":[],"stir":{"allowed_attest":["*any"],"default_attest":"A","payload_maxduration":"-1","privatekey_path":"","publickey_path":""},"store_session_costs":false,"terminate_attempts":5,"thresholds_conns":[]},"sip_agent":{"enabled":false,"listen":"127.0.0.1:5060","listen_net":"udp","request_processors":[],"retransmission_timer":"1s","sessions_conns":["*internal"],"timezone":""},"stats":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[],"*prometheusStatIDs":[],"*roundingDecimals":[]},"prefix_indexed_fields":[],"store_interval":"","store_uncompressed_limit":0,"suffix_indexed_fields":[],"thresholds_conns":[]},"stor_db":{"db_host":"127.0.0.1","db_name":"cgrates","db_password":"","db_port":3306,"db_type":"*mysql","db_user":"cgrates","items":{"*cdrs":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*session_costs":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_attributes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_chargers":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_dispatcher_hosts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_dispatcher_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_routes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_stats":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoQueryTimeout":"10s","mysqlDSNParams":{},"mysqlLocation":"Local","sqlConnMaxLifetime":"0s","sqlMaxIdleConns":10,"sqlMaxOpenConns":100,"sslMode":"disable"},"prefix_indexed_fields":[],"remote_conns":null,"replication_conns":null,"string_indexed_fields":[]},"suretax":{"bill_to_number":"","business_unit":"","client_number":"","client_tracking":"~*opts.*originID","customer_number":"~*req.Subject","include_local_cost":false,"orig_number":"~*req.Subject","p2pplus4":"","p2pzipcode":"","plus4":"","regulatory_code":"03","response_group":"03","response_type":"D4","return_file_code":"0","sales_type_code":"R","tax_exemption_code_list":"","tax_included":"0","tax_situs_rule":"04","term_number":"~*req.Destination","timezone":"UTC","trans_type_code":"010101","unit_type":"00","units":"1","url":"","validation_key":"","zipcode":""},"templates":{"*asr":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"}],"*cca":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"path":"*rep.Result-Code","tag":"ResultCode","type":"*constant","value":"2001"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"},{"mandatory":true,"path":"*rep.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"mandatory":true,"path":"*rep.CC-Request-Type","tag":"CCRequestType","type":"*variable","value":"~*req.CC-Request-Type"},{"mandatory":true,"path":"*rep.CC-Request-Number","tag":"CCRequestNumber","type":"*variable","value":"~*req.CC-Request-Number"}],"*cdrLog":[{"mandatory":true,"path":"*cdr.ToR","tag":"ToR","type":"*variable","value":"~*req.BalanceType"},{"mandatory":true,"path":"*cdr.OriginHost","tag":"OriginHost","type":"*constant","value":"127.0.0.1"},{"mandatory":true,"path":"*cdr.RequestType","tag":"RequestType","type":"*constant","value":"*none"},{"mandatory":true,"path":"*cdr.Tenant","tag":"Tenant","type":"*variable","value":"~*req.Tenant"},{"mandatory":true,"path":"*cdr.Account","tag":"Account","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Subject","tag":"Subject","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Cost","tag":"Cost","type":"*variable","value":"~*req.Cost"},{"mandatory":true,"path":"*cdr.Source","tag":"Source","type":"*constant","value":"*cdrLog"},{"mandatory":true,"path":"*cdr.Usage","tag":"Usage","type":"*constant","value":"1"},{"mandatory":true,"path":"*cdr.RunID","tag":"RunID","type":"*variable","value":"~*req.ActionType"},{"mandatory":true,"path":"*cdr.SetupTime","tag":"SetupTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.AnswerTime","tag":"AnswerTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.PreRated","tag":"PreRated","type":"*constant","value":"true"}],"*err":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"}],"*errSip":[{"mandatory":true,"path":"*rep.Request","tag":"Request","type":"*constant","value":"SIP/2.0 500 Internal Server Error"}],"*rar":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"path":"*diamreq.Re-Auth-Request-Type","tag":"ReAuthRequestType","type":"*constant","value":"0"}]},"thresholds":{"actions_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[]},"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[]},"tls":{"ca_certificate":"","client_certificate":"","client_key":"","server_certificate":"","server_key":"","server_name":"","server_policy":4}}` cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSON) if err != nil { t.Fatal(err) diff --git a/config/loaderscfg_test.go b/config/loaderscfg_test.go index 66c9f2c62..b32d62d96 100644 --- a/config/loaderscfg_test.go +++ b/config/loaderscfg_test.go @@ -153,8 +153,8 @@ func TestLoaderSCfgloadFromJsonCfgCase1(t *testing.T) { Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.2", utils.InfieldSep), Layout: time.RFC3339}, - {Tag: "Weight", - Path: "Weight", + {Tag: "Weights", + Path: "Weights", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.3", utils.InfieldSep), Layout: time.RFC3339}, @@ -427,8 +427,8 @@ func TestLoaderSCfgloadFromJsonCfgCase1(t *testing.T) { Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.2", utils.InfieldSep), Layout: time.RFC3339}, - {Tag: "Weight", - Path: "Weight", + {Tag: "Weights", + Path: "Weights", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~*req.3", utils.InfieldSep), Layout: time.RFC3339}, @@ -1218,8 +1218,8 @@ func TestLoaderCfgAsMapInterfaceCase1(t *testing.T) { utils.ValueCfg: "~*req.2", }, { - utils.TagCfg: "Weight", - utils.PathCfg: "Weight", + utils.TagCfg: "Weights", + utils.PathCfg: "Weights", utils.TypeCfg: "*variable", utils.ValueCfg: "~*req.3", }, @@ -1538,8 +1538,8 @@ func TestLoaderCfgAsMapInterfaceCase1(t *testing.T) { utils.ValueCfg: "~*req.2", }, { - utils.TagCfg: "Weight", - utils.PathCfg: "Weight", + utils.TagCfg: "Weights", + utils.PathCfg: "Weights", utils.TypeCfg: "*variable", utils.ValueCfg: "~*req.3", }, diff --git a/data/storage/docker_mysql/scripts/create_tariffplan_tables.sql b/data/storage/docker_mysql/scripts/create_tariffplan_tables.sql index ac9aa3889..0d73dd370 100644 --- a/data/storage/docker_mysql/scripts/create_tariffplan_tables.sql +++ b/data/storage/docker_mysql/scripts/create_tariffplan_tables.sql @@ -16,7 +16,7 @@ CREATE TABLE tp_resources ( `allocation_message` varchar(64) NOT NULL, `blocker` BOOLEAN NOT NULL, `stored` BOOLEAN NOT NULL, - `weight` decimal(8,2) NOT NULL, + `weights` varchar(64) NOT NULL, `threshold_ids` varchar(64) NOT NULL, `created_at` TIMESTAMP, PRIMARY KEY (`pk`), @@ -168,7 +168,7 @@ CREATE TABLE tp_chargers ( `activation_interval` varchar(64) NOT NULL, `run_id` varchar(64) NOT NULL, `attribute_ids` varchar(64) NOT NULL, - `weight` decimal(8,2) NOT NULL, + `weights` varchar(64) NOT NULL, `created_at` TIMESTAMP, PRIMARY KEY (`pk`), KEY `tpid` (`tpid`), diff --git a/data/storage/mysql/create_tariffplan_tables.sql b/data/storage/mysql/create_tariffplan_tables.sql index 279141080..1a8b4c9d4 100644 --- a/data/storage/mysql/create_tariffplan_tables.sql +++ b/data/storage/mysql/create_tariffplan_tables.sql @@ -16,7 +16,7 @@ CREATE TABLE tp_resources ( `allocation_message` varchar(64) NOT NULL, `blocker` BOOLEAN NOT NULL, `stored` BOOLEAN NOT NULL, - `weight` decimal(8,2) NOT NULL, + `weights` varchar(32) NOT NULL, `threshold_ids` varchar(64) NOT NULL, `created_at` TIMESTAMP, PRIMARY KEY (`pk`), @@ -169,7 +169,7 @@ CREATE TABLE tp_chargers ( `activation_interval` varchar(64) NOT NULL, `run_id` varchar(64) NOT NULL, `attribute_ids` varchar(64) NOT NULL, - `weight` decimal(8,2) NOT NULL, + `weights` varchar(64) NOT NULL, `created_at` TIMESTAMP, PRIMARY KEY (`pk`), KEY `tpid` (`tpid`), diff --git a/data/storage/postgres/create_tariffplan_tables.sql b/data/storage/postgres/create_tariffplan_tables.sql index 50c16d8f7..129139a3e 100644 --- a/data/storage/postgres/create_tariffplan_tables.sql +++ b/data/storage/postgres/create_tariffplan_tables.sql @@ -16,7 +16,7 @@ CREATE TABLE tp_resources ( "allocation_message" varchar(64) NOT NULL, "blocker" BOOLEAN NOT NULL, "stored" BOOLEAN NOT NULL, - "weight" NUMERIC(8,2) NOT NULL, + "weights" varchar(32) NOT NULL, "threshold_ids" varchar(64) NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE ); @@ -162,7 +162,7 @@ CREATE INDEX tp_routes_unique ON tp_routes ("tpid", "tenant", "id", "activation_interval" varchar(64) NOT NULL, "run_id" varchar(64) NOT NULL, "attribute_ids" varchar(64) NOT NULL, - "weight" decimal(8,2) NOT NULL, + "weights" varchar(64) NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE ); CREATE INDEX tp_chargers_ids ON tp_chargers (tpid); diff --git a/data/tariffplans/hundredrates/Chargers.csv b/data/tariffplans/hundredrates/Chargers.csv index a6cfd005a..65a4d073c 100644 --- a/data/tariffplans/hundredrates/Chargers.csv +++ b/data/tariffplans/hundredrates/Chargers.csv @@ -1,2 +1,2 @@ -#Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs -cgrates.org,DEFAULT,,0,*default,*none \ No newline at end of file +#Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs +cgrates.org,DEFAULT,,;0,*default,*none \ No newline at end of file diff --git a/data/tariffplans/loadRateTest/Chargers.csv b/data/tariffplans/loadRateTest/Chargers.csv index 7c08b7062..e1b37ae7f 100644 --- a/data/tariffplans/loadRateTest/Chargers.csv +++ b/data/tariffplans/loadRateTest/Chargers.csv @@ -1,4 +1,4 @@ -#Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs -cgrates.org,Raw,,20,raw,*constant:*req.RequestType:*none -cgrates.org,CustomerCharges,,20,CustomerCharges,*none -cgrates.org,SupplierCharges,,10,SupplierCharges,ATTR_SUPPLIER1 \ No newline at end of file +#Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs +cgrates.org,Raw,,;20,raw,*constant:*req.RequestType:*none +cgrates.org,CustomerCharges,,;20,CustomerCharges,*none +cgrates.org,SupplierCharges,,;10,SupplierCharges,ATTR_SUPPLIER1 \ No newline at end of file diff --git a/data/tariffplans/loadRateTest/Resources.csv b/data/tariffplans/loadRateTest/Resources.csv index 9e0d98984..77062d1cf 100644 --- a/data/tariffplans/loadRateTest/Resources.csv +++ b/data/tariffplans/loadRateTest/Resources.csv @@ -1,2 +1,2 @@ -#Tenant[0],Id[1],FilterIDs[2],Weight[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] -cgrates.org,RES_ACNT_1001,FLTR_ACCOUNT_1001,10,1h,1,,false,false, +#Tenant[0],Id[1],FilterIDs[2],Weights[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] +cgrates.org,RES_ACNT_1001,FLTR_ACCOUNT_1001,;10,1h,1,,false,false, diff --git a/data/tariffplans/oldaccvsnew/Chargers.csv b/data/tariffplans/oldaccvsnew/Chargers.csv index a6cfd005a..65a4d073c 100644 --- a/data/tariffplans/oldaccvsnew/Chargers.csv +++ b/data/tariffplans/oldaccvsnew/Chargers.csv @@ -1,2 +1,2 @@ -#Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs -cgrates.org,DEFAULT,,0,*default,*none \ No newline at end of file +#Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs +cgrates.org,DEFAULT,,;0,*default,*none \ No newline at end of file diff --git a/data/tariffplans/oldtutorial/Chargers.csv b/data/tariffplans/oldtutorial/Chargers.csv index a6cfd005a..65a4d073c 100644 --- a/data/tariffplans/oldtutorial/Chargers.csv +++ b/data/tariffplans/oldtutorial/Chargers.csv @@ -1,2 +1,2 @@ -#Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs -cgrates.org,DEFAULT,,0,*default,*none \ No newline at end of file +#Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs +cgrates.org,DEFAULT,,;0,*default,*none \ No newline at end of file diff --git a/data/tariffplans/oldtutorial/Resources.csv b/data/tariffplans/oldtutorial/Resources.csv index 59c2e3a7e..57b782137 100644 --- a/data/tariffplans/oldtutorial/Resources.csv +++ b/data/tariffplans/oldtutorial/Resources.csv @@ -1,4 +1,4 @@ -#Tenant[0],Id[1],FilterIDs[2],Weight[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] -cgrates.org,ResGroup1,FLTR_1,20,1s,7,,false,false,*none -cgrates.org,ResGroup2,FLTR_DST_FS,10,3600s,8,SPECIAL_1002,false,true,*none -cgrates.org,ResGroup3,FLTR_RES_GR3,20,*unlimited,3,,true,false,*none +#Tenant[0],Id[1],FilterIDs[2],Weights[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] +cgrates.org,ResGroup1,FLTR_1,;20,1s,7,,false,false,*none +cgrates.org,ResGroup2,FLTR_DST_FS,;10,3600s,8,SPECIAL_1002,false,true,*none +cgrates.org,ResGroup3,FLTR_RES_GR3,;20,*unlimited,3,,true,false,*none diff --git a/data/tariffplans/precache/Resources.csv b/data/tariffplans/precache/Resources.csv index 6d174aab3..6e017bac7 100644 --- a/data/tariffplans/precache/Resources.csv +++ b/data/tariffplans/precache/Resources.csv @@ -1,4 +1,4 @@ -#Tenant[0],Id[1],FilterIDs[2],Weight[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] -cgrates.org,ResGroup1,FLTR_1,20,1s,7,,false,false, -cgrates.org,ResGroup2,FLTR_DST_FS,10,3600s,8,SPECIAL_1002,false,true, -cgrates.org,ResGroup3,FLTR_RES_GR3,20,*unlimited,3,,true,false, +#Tenant[0],Id[1],FilterIDs[2],Weights[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] +cgrates.org,ResGroup1,FLTR_1,;20,1s,7,,false,false, +cgrates.org,ResGroup2,FLTR_DST_FS,;10,3600s,8,SPECIAL_1002,false,true, +cgrates.org,ResGroup3,FLTR_RES_GR3,;20,*unlimited,3,,true,false, diff --git a/data/tariffplans/sessions_discount_volume/routes1/Chargers.csv b/data/tariffplans/sessions_discount_volume/routes1/Chargers.csv index 2d139af27..428d7ed78 100644 --- a/data/tariffplans/sessions_discount_volume/routes1/Chargers.csv +++ b/data/tariffplans/sessions_discount_volume/routes1/Chargers.csv @@ -1,4 +1,4 @@ -#Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs +#Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs -cgrates.org,CHRG_CUSTOMER,,0,customers,*none -cgrates.org,CHRG_SUPPLIER,,0,suppliers,*none +cgrates.org,CHRG_CUSTOMER,,;0,customers,*none +cgrates.org,CHRG_SUPPLIER,,;0,suppliers,*none diff --git a/data/tariffplans/testData/Chargers.csv b/data/tariffplans/testData/Chargers.csv index a6cfd005a..65a4d073c 100644 --- a/data/tariffplans/testData/Chargers.csv +++ b/data/tariffplans/testData/Chargers.csv @@ -1,2 +1,2 @@ -#Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs -cgrates.org,DEFAULT,,0,*default,*none \ No newline at end of file +#Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs +cgrates.org,DEFAULT,,;0,*default,*none \ No newline at end of file diff --git a/data/tariffplans/testit/Chargers.csv b/data/tariffplans/testit/Chargers.csv index 7c08b7062..e1b37ae7f 100644 --- a/data/tariffplans/testit/Chargers.csv +++ b/data/tariffplans/testit/Chargers.csv @@ -1,4 +1,4 @@ -#Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs -cgrates.org,Raw,,20,raw,*constant:*req.RequestType:*none -cgrates.org,CustomerCharges,,20,CustomerCharges,*none -cgrates.org,SupplierCharges,,10,SupplierCharges,ATTR_SUPPLIER1 \ No newline at end of file +#Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs +cgrates.org,Raw,,;20,raw,*constant:*req.RequestType:*none +cgrates.org,CustomerCharges,,;20,CustomerCharges,*none +cgrates.org,SupplierCharges,,;10,SupplierCharges,ATTR_SUPPLIER1 \ No newline at end of file diff --git a/data/tariffplans/testit/Resources.csv b/data/tariffplans/testit/Resources.csv index 9e0d98984..77062d1cf 100644 --- a/data/tariffplans/testit/Resources.csv +++ b/data/tariffplans/testit/Resources.csv @@ -1,2 +1,2 @@ -#Tenant[0],Id[1],FilterIDs[2],Weight[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] -cgrates.org,RES_ACNT_1001,FLTR_ACCOUNT_1001,10,1h,1,,false,false, +#Tenant[0],Id[1],FilterIDs[2],Weights[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] +cgrates.org,RES_ACNT_1001,FLTR_ACCOUNT_1001,;10,1h,1,,false,false, diff --git a/data/tariffplans/testtp/Resources.csv b/data/tariffplans/testtp/Resources.csv index a38ee4cdf..2e4f9c9e0 100755 --- a/data/tariffplans/testtp/Resources.csv +++ b/data/tariffplans/testtp/Resources.csv @@ -1,4 +1,4 @@ -#Tenant[0],Id[1],FilterIDs[2],Weight[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] -cgrates.org,ResGroup1,FLTR_1,20,1s,7,,false,false, -cgrates.org,ResGroup2,FLTR_DST_FS,10,3600s,8,SPECIAL_1002,false,true, -cgrates.org,ResGroup3,FLTR_RES_GR3,20,0s,1,,true,false, +#Tenant[0],Id[1],FilterIDs[2],Weights[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] +cgrates.org,ResGroup1,FLTR_1,;20,1s,7,,false,false, +cgrates.org,ResGroup2,FLTR_DST_FS,;10,3600s,8,SPECIAL_1002,false,true, +cgrates.org,ResGroup3,FLTR_RES_GR3,;20,0s,1,,true,false, diff --git a/data/tariffplans/tp1cnt/Chargers.csv b/data/tariffplans/tp1cnt/Chargers.csv index a6cfd005a..65a4d073c 100644 --- a/data/tariffplans/tp1cnt/Chargers.csv +++ b/data/tariffplans/tp1cnt/Chargers.csv @@ -1,2 +1,2 @@ -#Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs -cgrates.org,DEFAULT,,0,*default,*none \ No newline at end of file +#Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs +cgrates.org,DEFAULT,,;0,*default,*none \ No newline at end of file diff --git a/data/tariffplans/tp_destination_with_any/Chargers.csv b/data/tariffplans/tp_destination_with_any/Chargers.csv index a6cfd005a..65a4d073c 100644 --- a/data/tariffplans/tp_destination_with_any/Chargers.csv +++ b/data/tariffplans/tp_destination_with_any/Chargers.csv @@ -1,2 +1,2 @@ -#Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs -cgrates.org,DEFAULT,,0,*default,*none \ No newline at end of file +#Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs +cgrates.org,DEFAULT,,;0,*default,*none \ No newline at end of file diff --git a/data/tariffplans/tut_sip_redirect/Chargers.csv b/data/tariffplans/tut_sip_redirect/Chargers.csv index 6b4190af6..0ab868bc8 100644 --- a/data/tariffplans/tut_sip_redirect/Chargers.csv +++ b/data/tariffplans/tut_sip_redirect/Chargers.csv @@ -1,5 +1,5 @@ -#Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs -cgrates.org,DEFAULT,,0,*default,*none -cgrates.org,route1,,0,route1,*constant:*req.RequestType:*none;*constant:*req.Destination:1003 -cgrates.org,route2,,0,route2,*constant:*req.RequestType:*none;*constant:*req.Destination:1004 -cgrates.org,route3,,0,route3,*constant:*req.RequestType:*none;*constant:*req.Destination:1005 \ No newline at end of file +#Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs +cgrates.org,DEFAULT,,;0,*default,*none +cgrates.org,route1,,;0,route1,*constant:*req.RequestType:*none;*constant:*req.Destination:1003 +cgrates.org,route2,,;0,route2,*constant:*req.RequestType:*none;*constant:*req.Destination:1004 +cgrates.org,route3,,;0,route3,*constant:*req.RequestType:*none;*constant:*req.Destination:1005 \ No newline at end of file diff --git a/data/tariffplans/tutorial/Chargers.csv b/data/tariffplans/tutorial/Chargers.csv index a5a03bb11..af599fabb 100644 --- a/data/tariffplans/tutorial/Chargers.csv +++ b/data/tariffplans/tutorial/Chargers.csv @@ -1,3 +1,3 @@ -#Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs -cgrates.org,DEFAULT,,0,*default,*none -cgrates.org,Raw,,0,*raw,*constant:*req.RequestType:*none \ No newline at end of file +#Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs +cgrates.org,DEFAULT,,;0,*default,*none +cgrates.org,Raw,,;0,*raw,*constant:*req.RequestType:*none \ No newline at end of file diff --git a/data/tariffplans/tutorial/Resources.csv b/data/tariffplans/tutorial/Resources.csv index c4ec3b9c1..6c1a966b3 100644 --- a/data/tariffplans/tutorial/Resources.csv +++ b/data/tariffplans/tutorial/Resources.csv @@ -1,2 +1,2 @@ -#Tenant[0],Id[1],FilterIDs[2],Weight[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] -cgrates.org,ResGroup1,FLTR_RES,10,-1,7,,false,true,*none \ No newline at end of file +#Tenant[0],Id[1],FilterIDs[2],Weights[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] +cgrates.org,ResGroup1,FLTR_RES,;10,-1,7,,false,true,*none \ No newline at end of file diff --git a/data/tariffplans/tutorial2/Chargers.csv b/data/tariffplans/tutorial2/Chargers.csv index f95c29a92..9e1a053d9 100644 --- a/data/tariffplans/tutorial2/Chargers.csv +++ b/data/tariffplans/tutorial2/Chargers.csv @@ -1,8 +1,8 @@ -# Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs +# Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs # CGR_DEFAULT is the default charger for events -cgrates.org,CGR_DEFAULT,,0,*default,*none +cgrates.org,CGR_DEFAULT,,;0,*default,*none # CGR_RESELLER1 creates an additional CDR for calculating reseller costs # uses ATTR_CRG_RESELLER1 to replace Category and RequestType in events -cgrates.org,CRG_RESELLER1,,1,reseller1,ATTR_CRG_RESELLER1 +cgrates.org,CRG_RESELLER1,,;1,reseller1,ATTR_CRG_RESELLER1 diff --git a/data/tariffplans/tutroutes/Chargers.csv b/data/tariffplans/tutroutes/Chargers.csv index 56cb4b261..6c184b294 100644 --- a/data/tariffplans/tutroutes/Chargers.csv +++ b/data/tariffplans/tutroutes/Chargers.csv @@ -1,3 +1,3 @@ -# Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs +# Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs -cgrates.org,CGR_DEFAULT,,0,*default,*none +cgrates.org,CGR_DEFAULT,,;0,*default,*none diff --git a/data/tariffplans/tutroutes/Resources.csv b/data/tariffplans/tutroutes/Resources.csv index e3108e4ce..4bdaba12c 100644 --- a/data/tariffplans/tutroutes/Resources.csv +++ b/data/tariffplans/tutroutes/Resources.csv @@ -1,3 +1,3 @@ -#Tenant[0],Id[1],FilterIDs[2],Weight[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] -cgrates.org,RES_GRP1,*string:~*req.Account:1001|1002|1003,0,-1,10,,,,*none -cgrates.org,RES_GRP2,*string:~*req.Account:1004,0,-1,10,,,,*none \ No newline at end of file +#Tenant[0],Id[1],FilterIDs[2],Weights[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],ThresholdIDs[9] +cgrates.org,RES_GRP1,*string:~*req.Account:1001|1002|1003,;0,-1,10,,,,*none +cgrates.org,RES_GRP2,*string:~*req.Account:1004,;0,-1,10,,,,*none \ No newline at end of file diff --git a/dispatchers/chargers_it_test.go b/dispatchers/chargers_it_test.go index 513538322..1b21ecbf4 100644 --- a/dispatchers/chargers_it_test.go +++ b/dispatchers/chargers_it_test.go @@ -121,7 +121,11 @@ func testDspCppGetChtgFailover(t *testing.T) { FilterIDs: []string{}, RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 0, + Weights: utils.DynamicWeights{ + { + Weight: 0, + }, + }, }, } if *encoding == utils.MetaGOB { @@ -143,7 +147,11 @@ func testDspCppGetChtgFailover(t *testing.T) { FilterIDs: []string{}, RunID: utils.MetaRaw, AttributeIDs: []string{"*constant:*req.RequestType:*none"}, - Weight: 0, + Weights: utils.DynamicWeights{ + { + Weight: 0, + }, + }, }, ) if *encoding == utils.MetaGOB { @@ -219,7 +227,11 @@ func testDspCppTestAuthKey2(t *testing.T) { FilterIDs: []string{}, RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 0, + Weights: utils.DynamicWeights{ + { + Weight: 0, + }, + }, }, &engine.ChargerProfile{ Tenant: "cgrates.org", @@ -227,7 +239,11 @@ func testDspCppTestAuthKey2(t *testing.T) { FilterIDs: []string{}, RunID: utils.MetaRaw, AttributeIDs: []string{"*constant:*req.RequestType:*none"}, - Weight: 0, + Weights: utils.DynamicWeights{ + { + Weight: 0, + }, + }, }, } if *encoding == utils.MetaGOB { @@ -266,7 +282,11 @@ func testDspCppGetChtgRoundRobin(t *testing.T) { FilterIDs: []string{}, RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 0, + Weights: utils.DynamicWeights{ + { + Weight: 0, + }, + }, }, } if *encoding == utils.MetaGOB { @@ -288,7 +308,11 @@ func testDspCppGetChtgRoundRobin(t *testing.T) { FilterIDs: []string{}, RunID: utils.MetaRaw, AttributeIDs: []string{"*constant:*req.RequestType:*none"}, - Weight: 0, + Weights: utils.DynamicWeights{ + { + Weight: 0, + }, + }, }, ) if *encoding == utils.MetaGOB { diff --git a/engine/chargers.go b/engine/chargers.go index ee7548d4c..0d26be0f2 100644 --- a/engine/chargers.go +++ b/engine/chargers.go @@ -65,7 +65,6 @@ func (cS *ChargerS) matchingChargerProfilesForEvent(ctx *context.Context, tnt st if err != nil { return nil, err } - matchingCPs := make(map[string]*ChargerProfile) for cpID := range cpIDs { cP, err := cS.dm.GetChargerProfile(ctx, tnt, cpID, true, true, utils.NonTransactional) if err != nil { @@ -80,17 +79,15 @@ func (cS *ChargerS) matchingChargerProfilesForEvent(ctx *context.Context, tnt st } else if !pass { continue } - matchingCPs[cpID] = cP + if cP.weight, err = WeightFromDynamics(ctx, cP.Weights, cS.fltrS, tnt, evNm); err != nil { + return nil, err + } + cPs = append(cPs, cP) } - if len(matchingCPs) == 0 { + if len(cPs) == 0 { return nil, utils.ErrNotFound } - cPs = make(ChargerProfiles, len(matchingCPs)) - i := 0 - for _, cP := range matchingCPs { - cPs[i] = cP - i++ - } + cPs.Sort() return } diff --git a/engine/chargers_test.go b/engine/chargers_test.go index 8b60fb758..ad205c8a1 100644 --- a/engine/chargers_test.go +++ b/engine/chargers_test.go @@ -41,7 +41,12 @@ func TestChargerSetChargerProfiles(t *testing.T) { FilterIDs: []string{"FLTR_CP_1", "FLTR_CP_4", "*string:~*opts.*subsys:*chargers", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"}, RunID: "TestRunID", AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, + weight: 20, }, &ChargerProfile{ Tenant: "cgrates.org", @@ -49,7 +54,12 @@ func TestChargerSetChargerProfiles(t *testing.T) { FilterIDs: []string{"FLTR_CP_2", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR_1"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, + weight: 20, }, &ChargerProfile{ Tenant: "cgrates.org", @@ -57,7 +67,12 @@ func TestChargerSetChargerProfiles(t *testing.T) { FilterIDs: []string{"FLTR_CP_3", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR_1"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, + weight: 20, }, } cfg := config.NewDefaultCGRConfig() @@ -147,7 +162,11 @@ func TestChargerMatchingChargerProfilesForEvent(t *testing.T) { FilterIDs: []string{"FLTR_CP_1", "FLTR_CP_4", "*string:~*opts.*subsys:*chargers", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"}, RunID: "TestRunID", AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, &ChargerProfile{ Tenant: "cgrates.org", @@ -155,7 +174,11 @@ func TestChargerMatchingChargerProfilesForEvent(t *testing.T) { FilterIDs: []string{"FLTR_CP_2", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR_1"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, &ChargerProfile{ Tenant: "cgrates.org", @@ -163,7 +186,11 @@ func TestChargerMatchingChargerProfilesForEvent(t *testing.T) { FilterIDs: []string{"FLTR_CP_3", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR_1"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, } chargerEvents := []*utils.CGREvent{ @@ -305,7 +332,12 @@ func TestChargerProcessEvent(t *testing.T) { FilterIDs: []string{"FLTR_CP_1", "FLTR_CP_4", "*string:~*opts.*subsys:*chargers", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"}, RunID: "TestRunID", AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, + weight: 20, }, &ChargerProfile{ Tenant: "cgrates.org", @@ -313,7 +345,12 @@ func TestChargerProcessEvent(t *testing.T) { FilterIDs: []string{"FLTR_CP_2", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR_1"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, + weight: 20, }, &ChargerProfile{ Tenant: "cgrates.org", @@ -321,7 +358,12 @@ func TestChargerProcessEvent(t *testing.T) { FilterIDs: []string{"FLTR_CP_3", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR_1"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, + weight: 20, }, } chargerEvents := []*utils.CGREvent{ @@ -429,7 +471,7 @@ func TestChargerProcessEvent(t *testing.T) { true, false, utils.NonTransactional); err != nil { t.Errorf("Error: %+v", err) } else if !reflect.DeepEqual(cp, tempCp) { - t.Errorf("Expecting: %+v, received: %+v", cp, tempCp) + t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(cp), utils.ToJSON(tempCp)) } } diff --git a/engine/libchargers.go b/engine/libchargers.go index 0e7069eeb..6cdae2813 100644 --- a/engine/libchargers.go +++ b/engine/libchargers.go @@ -31,7 +31,8 @@ type ChargerProfile struct { FilterIDs []string RunID string AttributeIDs []string // perform data aliasing based on these Attributes - Weight float64 + Weights utils.DynamicWeights + weight float64 } // ChargerProfileWithAPIOpts is used in replicatorV1 for dispatcher @@ -49,7 +50,7 @@ type ChargerProfiles []*ChargerProfile // Sort is part of sort interface, sort based on Weight func (cps ChargerProfiles) Sort() { - sort.Slice(cps, func(i, j int) bool { return cps[i].Weight > cps[j].Weight }) + sort.Slice(cps, func(i, j int) bool { return cps[i].weight > cps[j].weight }) } func (cp *ChargerProfile) Set(path []string, val interface{}, newBranch bool, _ string) (err error) { @@ -73,9 +74,9 @@ func (cp *ChargerProfile) Set(path []string, val interface{}, newBranch bool, _ var valA []string valA, err = utils.IfaceAsStringSlice(val) cp.AttributeIDs = append(cp.AttributeIDs, valA...) - case utils.Weight: + case utils.Weights: if val != utils.EmptyString { - cp.Weight, err = utils.IfaceAsFloat64(val) + cp.Weights, err = utils.NewDynamicWeightsFromString(utils.IfaceAsString(val), utils.InfieldSep, utils.ANDSep) } } return @@ -94,9 +95,7 @@ func (cp *ChargerProfile) Merge(v2 interface{}) { } cp.FilterIDs = append(cp.FilterIDs, vi.FilterIDs...) cp.AttributeIDs = append(cp.AttributeIDs, vi.AttributeIDs...) - if vi.Weight != 0 { - cp.Weight = vi.Weight - } + cp.Weights = append(cp.Weights, vi.Weights...) } func (cp *ChargerProfile) String() string { return utils.ToJSON(cp) } @@ -134,7 +133,7 @@ func (cp *ChargerProfile) FieldAsInterface(fldPath []string) (_ interface{}, err case utils.FilterIDs: return cp.FilterIDs, nil case utils.Weight: - return cp.Weight, nil + return cp.Weights, nil case utils.AttributeIDs: return cp.AttributeIDs, nil case utils.RunID: diff --git a/engine/libchargers_test.go b/engine/libchargers_test.go index e8d52b86a..9ec4c7c8f 100644 --- a/engine/libchargers_test.go +++ b/engine/libchargers_test.go @@ -28,10 +28,14 @@ import ( func TestChargerProfileSet(t *testing.T) { cp := ChargerProfile{} exp := ChargerProfile{ - Tenant: "cgrates.org", - ID: "ID", - FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, - Weight: 10, + Tenant: "cgrates.org", + ID: "ID", + FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }, + }, RunID: utils.MetaDefault, AttributeIDs: []string{"attr1"}, } @@ -54,7 +58,7 @@ func TestChargerProfileSet(t *testing.T) { if err := cp.Set([]string{utils.FilterIDs}, "fltr1;*string:~*req.Account:1001", false, utils.EmptyString); err != nil { t.Error(err) } - if err := cp.Set([]string{utils.Weight}, 10, false, utils.EmptyString); err != nil { + if err := cp.Set([]string{utils.Weights}, ";10", false, utils.EmptyString); err != nil { t.Error(err) } if err := cp.Set([]string{utils.RunID}, utils.MetaDefault, false, utils.EmptyString); err != nil { @@ -70,8 +74,18 @@ func TestChargerProfileSet(t *testing.T) { } func TestChargerProfilesSort(t *testing.T) { - cp := ChargerProfiles{{}, {Weight: 10}} - exp := ChargerProfiles{{Weight: 10}, {}} + cp := ChargerProfiles{{}, {Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, + weight: 20}} + exp := ChargerProfiles{{Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, + weight: 20}, {}} cp.Sort() if !reflect.DeepEqual(exp, cp) { t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(cp)) @@ -80,10 +94,14 @@ func TestChargerProfilesSort(t *testing.T) { func TestChargerProfileAsInterface(t *testing.T) { cp := ChargerProfile{ - Tenant: "cgrates.org", - ID: "ID", - FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, - Weight: 10, + Tenant: "cgrates.org", + ID: "ID", + FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }, + }, RunID: utils.MetaDefault, AttributeIDs: []string{"attr1"}, } @@ -118,7 +136,7 @@ func TestChargerProfileAsInterface(t *testing.T) { } if val, err := cp.FieldAsInterface([]string{utils.Weight}); err != nil { t.Fatal(err) - } else if exp := cp.Weight; !reflect.DeepEqual(exp, val) { + } else if exp := cp.Weights; !reflect.DeepEqual(exp, val) { t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val)) } if val, err := cp.FieldAsInterface([]string{utils.RunID}); err != nil { @@ -154,18 +172,26 @@ func TestChargerProfileAsInterface(t *testing.T) { func TestChargerProfileMerge(t *testing.T) { dp := &ChargerProfile{} exp := &ChargerProfile{ - Tenant: "cgrates.org", - ID: "ID", - FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, - Weight: 10, + Tenant: "cgrates.org", + ID: "ID", + FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }, + }, RunID: utils.MetaDefault, AttributeIDs: []string{"attr1"}, } if dp.Merge(&ChargerProfile{ - Tenant: "cgrates.org", - ID: "ID", - FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, - Weight: 10, + Tenant: "cgrates.org", + ID: "ID", + FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }, + }, RunID: utils.MetaDefault, AttributeIDs: []string{"attr1"}, }); !reflect.DeepEqual(exp, dp) { diff --git a/engine/libstats.go b/engine/libstats.go index 550d3a1b4..f0e4ea993 100644 --- a/engine/libstats.go +++ b/engine/libstats.go @@ -50,11 +50,6 @@ type StatQueueProfile struct { lkID string // holds the reference towards guardian lock key } -type statprfWithWeight struct { - *StatQueueProfile - weight float64 -} - // StatQueueProfileWithAPIOpts is used in replicatorV1 for dispatcher type StatQueueProfileWithAPIOpts struct { *StatQueueProfile diff --git a/engine/libtest.go b/engine/libtest.go index b2dc19aba..77785c4af 100644 --- a/engine/libtest.go +++ b/engine/libtest.go @@ -86,9 +86,9 @@ TOPUP_RST_GNR_1000,*topup_reset,"{""*voice"": 60.0,""*data"":1024.0,""*sms"":1.0 ` ResourcesCSVContent = ` -#Tenant[0],Id[1],FilterIDs[2],Weight[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],Thresholds[9] -cgrates.org,ResGroup21,*string:~*req.Account:1001,10,1s,2,call,true,true, -cgrates.org,ResGroup22,*string:~*req.Account:dan,10,3600s,2,premium_call,true,true, +#Tenant[0],Id[1],FilterIDs[2],Weights[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],Thresholds[9] +cgrates.org,ResGroup21,*string:~*req.Account:1001,;10,1s,2,call,true,true, +cgrates.org,ResGroup22,*string:~*req.Account:dan,;10,3600s,2,premium_call,true,true, ` StatsCSVContent = ` #Tenant[0],Id[1],FilterIDs[2],Weights[3],QueueLength[4],TTL[5],MinItems[6],Metrics[7],MetricFilterIDs[8],Stored[9],Blocker[10],ThresholdIDs[11] @@ -126,8 +126,8 @@ cgrates.org,ALS1,*string:~*req.Account:1001;*string:~*opts.*context:con1,;20,*st cgrates.org,ALS1,*string:~*opts.*context:con2|con3,;20,,*req.Field2,*variable,Sub2,true ` ChargersCSVContent = ` -#Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs -cgrates.org,Charger1,*string:~*req.Account:1001,20,*rated,ATTR_1001_SIMPLEAUTH +#Tenant,ID,FilterIDs,Weights,RunID,AttributeIDs +cgrates.org,Charger1,*string:~*req.Account:1001,;20,*rated,ATTR_1001_SIMPLEAUTH ` DispatcherCSVContent = ` #Tenant,ID,FilterIDs,Weight,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 582bed064..0120110d1 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -94,7 +94,7 @@ func TestLoadResourceProfiles(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, UsageTTL: "1s", AllocationMessage: "call", - Weight: 10, + Weights: ";10", Limit: "2", Blocker: true, Stored: true, @@ -108,7 +108,7 @@ func TestLoadResourceProfiles(t *testing.T) { AllocationMessage: "premium_call", Blocker: true, Stored: true, - Weight: 10, + Weights: ";10", Limit: "2", }, } @@ -441,7 +441,7 @@ func TestLoadChargerProfiles(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, RunID: "*rated", AttributeIDs: []string{"ATTR_1001_SIMPLEAUTH"}, - Weight: 20, + Weights: ";20", }, } cppKey := utils.TenantID{Tenant: "cgrates.org", ID: "Charger1"} diff --git a/engine/model_helpers.go b/engine/model_helpers.go index fad006ce3..3b277fb8d 100644 --- a/engine/model_helpers.go +++ b/engine/model_helpers.go @@ -173,8 +173,8 @@ func (tps ResourceMdls) AsTPResources() (result []*utils.TPResourceProfile) { if tp.UsageTTL != utils.EmptyString { rl.UsageTTL = tp.UsageTTL } - if tp.Weight != 0 { - rl.Weight = tp.Weight + if tp.Weights != "" { + rl.Weights = tp.Weights } if tp.Limit != utils.EmptyString { rl.Limit = tp.Limit @@ -222,7 +222,7 @@ func APItoModelResource(rl *utils.TPResourceProfile) (mdls ResourceMdls) { Blocker: rl.Blocker, Stored: rl.Stored, UsageTTL: rl.UsageTTL, - Weight: rl.Weight, + Weights: rl.Weights, Limit: rl.Limit, AllocationMessage: rl.AllocationMessage, } @@ -244,7 +244,7 @@ func APItoModelResource(rl *utils.TPResourceProfile) (mdls ResourceMdls) { } if i == 0 { mdl.UsageTTL = rl.UsageTTL - mdl.Weight = rl.Weight + mdl.Weights = rl.Weights mdl.Limit = rl.Limit mdl.AllocationMessage = rl.AllocationMessage for i, val := range rl.ThresholdIDs { @@ -264,13 +264,18 @@ func APItoResource(tpRL *utils.TPResourceProfile, timezone string) (rp *Resource rp = &ResourceProfile{ Tenant: tpRL.Tenant, ID: tpRL.ID, - Weight: tpRL.Weight, Blocker: tpRL.Blocker, Stored: tpRL.Stored, AllocationMessage: tpRL.AllocationMessage, ThresholdIDs: make([]string, len(tpRL.ThresholdIDs)), FilterIDs: make([]string, len(tpRL.FilterIDs)), } + if tpRL.Weights != utils.EmptyString { + rp.Weights, err = utils.NewDynamicWeightsFromString(tpRL.Weights, utils.InfieldSep, utils.ANDSep) + if err != nil { + return + } + } if tpRL.UsageTTL != utils.EmptyString { if rp.UsageTTL, err = utils.ParseDurationWithNanosecs(tpRL.UsageTTL); err != nil { return nil, err @@ -299,7 +304,7 @@ func ResourceProfileToAPI(rp *ResourceProfile) (tpRL *utils.TPResourceProfile) { AllocationMessage: rp.AllocationMessage, Blocker: rp.Blocker, Stored: rp.Stored, - Weight: rp.Weight, + Weights: rp.Weights.String(utils.InfieldSep, utils.ANDSep), ThresholdIDs: make([]string, len(rp.ThresholdIDs)), } if rp.UsageTTL != time.Duration(0) { @@ -1218,8 +1223,8 @@ func (tps ChargerMdls) AsTPChargers() (result []*utils.TPChargerProfile) { ID: tp.ID, } } - if tp.Weight != 0 { - tpCPP.Weight = tp.Weight + if tp.Weights != "" { + tpCPP.Weights = tp.Weights } if tp.FilterIDs != utils.EmptyString { if _, has := filterMap[tntID]; !has { @@ -1279,11 +1284,11 @@ func APItoModelTPCharger(tpCPP *utils.TPChargerProfile) (mdls ChargerMdls) { } if min == 0 { mdl := &ChargerMdl{ - Tenant: tpCPP.Tenant, - Tpid: tpCPP.TPid, - ID: tpCPP.ID, - Weight: tpCPP.Weight, - RunID: tpCPP.RunID, + Tenant: tpCPP.Tenant, + Tpid: tpCPP.TPid, + ID: tpCPP.ID, + Weights: tpCPP.Weights, + RunID: tpCPP.RunID, } if isFilter && len(tpCPP.AttributeIDs) > 0 { mdl.AttributeIDs = tpCPP.AttributeIDs[0] @@ -1300,7 +1305,7 @@ func APItoModelTPCharger(tpCPP *utils.TPChargerProfile) (mdls ChargerMdls) { ID: tpCPP.ID, } if i == 0 { - mdl.Weight = tpCPP.Weight + mdl.Weights = tpCPP.Weights mdl.RunID = tpCPP.RunID } mdl.AttributeIDs = tpCPP.AttributeIDs[i] @@ -1339,11 +1344,17 @@ func APItoChargerProfile(tpCPP *utils.TPChargerProfile, timezone string) (cpp *C cpp = &ChargerProfile{ Tenant: tpCPP.Tenant, ID: tpCPP.ID, - Weight: tpCPP.Weight, RunID: tpCPP.RunID, FilterIDs: make([]string, len(tpCPP.FilterIDs)), AttributeIDs: make([]string, len(tpCPP.AttributeIDs)), } + if tpCPP.Weights != utils.EmptyString { + var err error + cpp.Weights, err = utils.NewDynamicWeightsFromString(tpCPP.Weights, utils.InfieldSep, utils.ANDSep) + if err != nil { + return + } + } for i, fli := range tpCPP.FilterIDs { cpp.FilterIDs[i] = fli } @@ -1360,7 +1371,7 @@ func ChargerProfileToAPI(chargerPrf *ChargerProfile) (tpCharger *utils.TPCharger FilterIDs: make([]string, len(chargerPrf.FilterIDs)), RunID: chargerPrf.RunID, AttributeIDs: make([]string, len(chargerPrf.AttributeIDs)), - Weight: chargerPrf.Weight, + Weights: chargerPrf.Weights.String(utils.InfieldSep, utils.ANDSep), } for i, fli := range chargerPrf.FilterIDs { tpCharger.FilterIDs[i] = fli diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go index 30de7cde9..1234afd5b 100644 --- a/engine/model_helpers_test.go +++ b/engine/model_helpers_test.go @@ -38,7 +38,7 @@ func TestTpResourcesAsTpResources(t *testing.T) { FilterIDs: "FLTR_RES_GR1;*ai:~*req.AnswerTime:2014-07-29T15:00:00Z", Stored: false, Blocker: false, - Weight: 10.0, + Weights: ";10", Limit: "45", ThresholdIDs: "WARN_RES1;WARN_RES1"}, { @@ -54,7 +54,7 @@ func TestTpResourcesAsTpResources(t *testing.T) { FilterIDs: "FLTR_RES_GR2;*ai:~*req.AnswerTime:2014-07-29T15:00:00Z", Stored: false, Blocker: false, - Weight: 10.0, + Weights: ";10", Limit: "20"}, } eTPs := []*utils.TPResourceProfile{ @@ -65,7 +65,7 @@ func TestTpResourcesAsTpResources(t *testing.T) { FilterIDs: []string{"FLTR_RES_GR1", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z"}, Stored: tps[0].Stored, Blocker: tps[0].Blocker, - Weight: tps[0].Weight, + Weights: tps[0].Weights, Limit: tps[0].Limit, ThresholdIDs: []string{"WARN_RES1", "WARN3"}, }, @@ -76,7 +76,7 @@ func TestTpResourcesAsTpResources(t *testing.T) { FilterIDs: []string{"FLTR_RES_GR2", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z"}, Stored: tps[2].Stored, Blocker: tps[2].Blocker, - Weight: tps[2].Weight, + Weights: tps[2].Weights, Limit: tps[2].Limit, }, } @@ -94,7 +94,7 @@ func TestAPItoResource(t *testing.T) { FilterIDs: []string{"FLTR_RES_GR_1", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z"}, Stored: false, Blocker: false, - Weight: 10, + Weights: ";10", Limit: "2", ThresholdIDs: []string{"TRes1"}, AllocationMessage: "asd", @@ -104,12 +104,14 @@ func TestAPItoResource(t *testing.T) { ID: tpRL.ID, Stored: tpRL.Stored, Blocker: tpRL.Blocker, - Weight: tpRL.Weight, FilterIDs: []string{"FLTR_RES_GR_1", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z"}, ThresholdIDs: []string{"TRes1"}, AllocationMessage: tpRL.AllocationMessage, Limit: 2, } + if tpRL.Weights != utils.EmptyString { + eRL.Weights, err = utils.NewDynamicWeightsFromString(utils.IfaceAsString(tpRL.Weights), utils.InfieldSep, utils.ANDSep) + } if rl, err := APItoResource(tpRL, "UTC"); err != nil { t.Error(err) } else if !reflect.DeepEqual(eRL, rl) { @@ -122,15 +124,18 @@ func TestResourceProfileToAPI(t *testing.T) { Tenant: "cgrates.org", ID: "ResGroup1", FilterIDs: []string{"FLTR_RES_GR_1", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z"}, - Weight: 10, + Weights: ";10", Limit: "2", ThresholdIDs: []string{"TRes1"}, AllocationMessage: "asd", } rp := &ResourceProfile{ - Tenant: "cgrates.org", - ID: "ResGroup1", - Weight: 10, + Tenant: "cgrates.org", + ID: "ResGroup1", + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, FilterIDs: []string{"FLTR_RES_GR_1", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z"}, ThresholdIDs: []string{"TRes1"}, AllocationMessage: "asd", @@ -148,7 +153,7 @@ func TestAPItoModelResource(t *testing.T) { TPid: testTPID, ID: "ResGroup1", FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-29T15:00:00Z"}, - Weight: 10, + Weights: ";10", Limit: "2", ThresholdIDs: []string{"TRes1"}, AllocationMessage: "test", @@ -158,7 +163,7 @@ func TestAPItoModelResource(t *testing.T) { Tenant: "cgrates.org", ID: "ResGroup1", FilterIDs: "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z", - Weight: 10.0, + Weights: ";10", Limit: "2", ThresholdIDs: "TRes1", AllocationMessage: "test", @@ -1348,7 +1353,7 @@ func TestAPItoChargerProfile(t *testing.T) { FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR1", "ATTR2"}, - Weight: 20, + Weights: ";20", } expected := &ChargerProfile{ @@ -1357,7 +1362,11 @@ func TestAPItoChargerProfile(t *testing.T) { FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR1", "ATTR2"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } if rcv := APItoChargerProfile(tpCPP, "UTC"); !reflect.DeepEqual(expected, rcv) { t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rcv)) @@ -1371,7 +1380,7 @@ func TestChargerProfileToAPI(t *testing.T) { FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z|2014-07-15T14:36:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR1", "ATTR2"}, - Weight: 20, + Weights: ";20", } chargerPrf := &ChargerProfile{ @@ -1380,7 +1389,11 @@ func TestChargerProfileToAPI(t *testing.T) { FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z|2014-07-15T14:36:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR1", "ATTR2"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } if rcv := ChargerProfileToAPI(chargerPrf); err != nil { t.Error(err) @@ -1398,7 +1411,7 @@ func TestAPItoModelTPCharger(t *testing.T) { FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z|2014-07-15T14:35:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR1", "ATTR2"}, - Weight: 20, + Weights: ";20", } expected := ChargerMdls{ &ChargerMdl{ @@ -1408,7 +1421,7 @@ func TestAPItoModelTPCharger(t *testing.T) { FilterIDs: "FLTR_ACNT_dan", RunID: "*rated", AttributeIDs: "ATTR1", - Weight: 20, + Weights: ";20", }, &ChargerMdl{ Tpid: "TP1", @@ -1440,7 +1453,7 @@ func TestAPItoModelTPCharger2(t *testing.T) { FilterIDs: []string{"FLTR_ACNT_dan", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z|2014-07-15T14:35:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR1", "ATTR2"}, - Weight: 20, + Weights: ";20", } expected := ChargerMdls{ &ChargerMdl{ @@ -1450,7 +1463,7 @@ func TestAPItoModelTPCharger2(t *testing.T) { FilterIDs: "FLTR_ACNT_dan", RunID: "*rated", AttributeIDs: "ATTR1", - Weight: 20, + Weights: ";20", }, &ChargerMdl{ Tpid: "TP1", @@ -1475,7 +1488,7 @@ func TestAPItoModelTPCharger3(t *testing.T) { FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR1"}, - Weight: 20, + Weights: ";20", } expected := ChargerMdls{ &ChargerMdl{ @@ -1485,7 +1498,7 @@ func TestAPItoModelTPCharger3(t *testing.T) { FilterIDs: "FLTR_ACNT_dan", RunID: "*rated", AttributeIDs: "ATTR1", - Weight: 20, + Weights: ";20", }, &ChargerMdl{ Tpid: "TP1", @@ -1514,7 +1527,7 @@ func TestAPItoModelTPCharger4(t *testing.T) { ID: "Charger1", FilterIDs: []string{"FLTR_ACNT_dan", "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z|2014-07-15T14:35:00Z"}, RunID: "*rated", - Weight: 20, + Weights: ";20", } expected := ChargerMdls{ &ChargerMdl{ @@ -1523,7 +1536,7 @@ func TestAPItoModelTPCharger4(t *testing.T) { ID: "Charger1", FilterIDs: "FLTR_ACNT_dan", RunID: "*rated", - Weight: 20, + Weights: ";20", }, &ChargerMdl{ Tpid: "TP1", @@ -1531,7 +1544,7 @@ func TestAPItoModelTPCharger4(t *testing.T) { ID: "Charger1", FilterIDs: "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z|2014-07-15T14:35:00Z", RunID: "", - Weight: 0, + Weights: "", }, } rcv := APItoModelTPCharger(tpCharger) @@ -1549,7 +1562,7 @@ func TestAPItoModelTPCharger5(t *testing.T) { FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR1"}, - Weight: 20, + Weights: ";20", } expected := ChargerMdls{ &ChargerMdl{ @@ -1559,7 +1572,7 @@ func TestAPItoModelTPCharger5(t *testing.T) { RunID: "*rated", AttributeIDs: "ATTR1", FilterIDs: "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", - Weight: 20, + Weights: ";20", }, } rcv := APItoModelTPCharger(tpCharger) @@ -1576,7 +1589,7 @@ func TestAPItoModelTPCharger6(t *testing.T) { ID: "Charger1", RunID: "*rated", FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z"}, - Weight: 20, + Weights: ";20", } expected := ChargerMdls{ &ChargerMdl{ @@ -1585,7 +1598,7 @@ func TestAPItoModelTPCharger6(t *testing.T) { ID: "Charger1", RunID: "*rated", FilterIDs: "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", - Weight: 20, + Weights: ";20", }, } rcv := APItoModelTPCharger(tpCharger) @@ -1603,7 +1616,7 @@ func TestModelAsTPChargers(t *testing.T) { FilterIDs: "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z;FLTR_ACNT_dan;FLTR_DST_DE", RunID: "*rated", AttributeIDs: "ATTR1", - Weight: 20, + Weights: ";20", }, } expected := &utils.TPChargerProfile{ @@ -1613,7 +1626,7 @@ func TestModelAsTPChargers(t *testing.T) { FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", "FLTR_ACNT_dan", "FLTR_DST_DE"}, RunID: "*rated", AttributeIDs: []string{"ATTR1"}, - Weight: 20, + Weights: ";20", } expected2 := &utils.TPChargerProfile{ TPid: "TP1", @@ -1622,7 +1635,7 @@ func TestModelAsTPChargers(t *testing.T) { FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", "FLTR_DST_DE", "FLTR_ACNT_dan"}, RunID: "*rated", AttributeIDs: []string{"ATTR1"}, - Weight: 20, + Weights: ";20", } rcv := models.AsTPChargers() sort.Strings(rcv[0].FilterIDs) @@ -1640,7 +1653,7 @@ func TestModelAsTPChargers2(t *testing.T) { FilterIDs: "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z;FLTR_ACNT_dan;FLTR_DST_DE", RunID: "*rated", AttributeIDs: "*constant:*req.RequestType:*rated;*constant:*req.Category:call;ATTR1;*constant:*req.Category:call", - Weight: 20, + Weights: ";20", }, } expected := &utils.TPChargerProfile{ @@ -1650,7 +1663,7 @@ func TestModelAsTPChargers2(t *testing.T) { FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z", "FLTR_ACNT_dan", "FLTR_DST_DE"}, RunID: "*rated", AttributeIDs: []string{"*constant:*req.RequestType:*rated;*constant:*req.Category:call", "ATTR1", "*constant:*req.Category:call"}, - Weight: 20, + Weights: ";20", } rcv := models.AsTPChargers() sort.Strings(rcv[0].FilterIDs) @@ -1668,7 +1681,7 @@ func TestModelAsTPChargers3(t *testing.T) { FilterIDs: "*ai:~*req.AnswerTime:2014-07-14T14:35:00Z|2014-07-15T14:35:00Z;FLTR_ACNT_dan;FLTR_DST_DE", RunID: "*rated", AttributeIDs: "*constant:*req.RequestType:*rated;*constant:*req.Category:call;ATTR1;*constant:*req.Category:call&<~*req.OriginID;_suf>", - Weight: 20, + Weights: ";20", }, } expected := &utils.TPChargerProfile{ @@ -1678,7 +1691,7 @@ func TestModelAsTPChargers3(t *testing.T) { FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:35:00Z|2014-07-15T14:35:00Z", "FLTR_ACNT_dan", "FLTR_DST_DE"}, RunID: "*rated", AttributeIDs: []string{"*constant:*req.RequestType:*rated;*constant:*req.Category:call", "ATTR1", "*constant:*req.Category:call&<~*req.OriginID;_suf>"}, - Weight: 20, + Weights: ";20", } rcv := models.AsTPChargers() sort.Strings(rcv[0].FilterIDs) @@ -3177,7 +3190,7 @@ func TestAPItoModelResourceCase2(t *testing.T) { ID: "ResGroup1", FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-29T15:00:00Z|2015-07-29T15:00:00Z"}, UsageTTL: "Test_TTL", - Weight: 10, + Weights: ";10", Limit: "2", ThresholdIDs: []string{"TRes1", "TRes2"}, AllocationMessage: "test", @@ -3189,7 +3202,7 @@ func TestAPItoModelResourceCase2(t *testing.T) { ID: "ResGroup1", FilterIDs: "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z|2015-07-29T15:00:00Z", UsageTTL: "Test_TTL", - Weight: 10, + Weights: ";10", Limit: "2", ThresholdIDs: "TRes1;TRes2", AllocationMessage: "test", @@ -3208,7 +3221,7 @@ func TestAPItoModelResourceCase3(t *testing.T) { ID: "ResGroup1", FilterIDs: []string{"FilterID1", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z|2015-07-29T15:00:00Z"}, UsageTTL: "Test_TTL", - Weight: 10, + Weights: ";10", Limit: "2", ThresholdIDs: []string{"TRes1", "TRes2"}, AllocationMessage: "test", @@ -3220,7 +3233,7 @@ func TestAPItoModelResourceCase3(t *testing.T) { ID: "ResGroup1", FilterIDs: "FilterID1", UsageTTL: "Test_TTL", - Weight: 10, + Weights: ";10", Limit: "2", ThresholdIDs: "TRes1;TRes2", AllocationMessage: "test", @@ -3231,7 +3244,7 @@ func TestAPItoModelResourceCase3(t *testing.T) { ID: "ResGroup1", FilterIDs: "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z|2015-07-29T15:00:00Z", UsageTTL: "", - Weight: 0, + Weights: "", Limit: "", ThresholdIDs: "", AllocationMessage: "", @@ -3494,7 +3507,11 @@ func TestChargerProfileToAPILastCase(t *testing.T) { FilterIDs: []string{"*string:~*opts.*subsys:*chargers", "FLTR_CP_1", "FLTR_CP_4", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"}, RunID: "TestRunID", AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } expStruct := &utils.TPChargerProfile{ @@ -3503,7 +3520,7 @@ func TestChargerProfileToAPILastCase(t *testing.T) { FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-14T14:25:00Z", "*string:~*opts.*subsys:*chargers", "FLTR_CP_1", "FLTR_CP_4"}, AttributeIDs: []string{"*none"}, RunID: "TestRunID", - Weight: 20, + Weights: ";20", } result := ChargerProfileToAPI(testStruct) @@ -3636,7 +3653,7 @@ func ModelHelpersTestStatMdlsCSVHeader(t *testing.T) { FilterIDs: "FLTR_RES_GR1;*ai:~*req.AnswerTime:2014-07-29T15:00:00Z", Stored: false, Blocker: false, - Weight: 10.0, + Weights: ";10", Limit: "45", ThresholdIDs: "WARN_RES1;WARN_RES1", }, @@ -4432,8 +4449,12 @@ func TestModelHelpersResourceProfileToAPICase2(t *testing.T) { AllocationMessage: "", Blocker: false, Stored: false, - Weight: 0, - ThresholdIDs: []string{"test_threshold_id"}, + Weights: utils.DynamicWeights{ + { + Weight: 0, + }, + }, + ThresholdIDs: []string{"test_threshold_id"}, } expStruct := &utils.TPResourceProfile{ TPid: "", @@ -4445,7 +4466,7 @@ func TestModelHelpersResourceProfileToAPICase2(t *testing.T) { AllocationMessage: "", Blocker: false, Stored: false, - Weight: 0, + Weights: ";0", ThresholdIDs: []string{"test_threshold_id"}, } result := ResourceProfileToAPI(testStruct) @@ -4465,7 +4486,7 @@ func TestModelHelpersAPItoResourceError1(t *testing.T) { AllocationMessage: "", Blocker: false, Stored: false, - Weight: 0, + Weights: ";0", ThresholdIDs: nil, } _, err := APItoResource(testStruct, "") @@ -4485,7 +4506,7 @@ func TestModelHelpersAPItoResourceError3(t *testing.T) { AllocationMessage: "", Blocker: false, Stored: false, - Weight: 0, + Weights: ";0", ThresholdIDs: nil, } _, err := APItoResource(testStruct, "") diff --git a/engine/models.go b/engine/models.go index 5035373ae..42f420182 100644 --- a/engine/models.go +++ b/engine/models.go @@ -30,16 +30,16 @@ import ( type ResourceMdl struct { PK uint `gorm:"primary_key"` Tpid string - Tenant string `index:"0" re:""` - ID string `index:"1" re:""` - FilterIDs string `index:"2" re:""` - Weight float64 `index:"3" re:"\d+\.?\d*"` - UsageTTL string `index:"4" re:""` - Limit string `index:"5" re:""` - AllocationMessage string `index:"6" re:""` - Blocker bool `index:"7" re:""` - Stored bool `index:"8" re:""` - ThresholdIDs string `index:"9" re:""` + Tenant string `index:"0" re:""` + ID string `index:"1" re:""` + FilterIDs string `index:"2" re:""` + Weights string `index:"3" re:"\d+\.?\d*"` + UsageTTL string `index:"4" re:""` + Limit string `index:"5" re:""` + AllocationMessage string `index:"6" re:""` + Blocker bool `index:"7" re:""` + Stored bool `index:"8" re:""` + ThresholdIDs string `index:"9" re:""` CreatedAt time.Time } @@ -237,12 +237,12 @@ func (AttributeMdl) TableName() string { type ChargerMdl struct { PK uint `gorm:"primary_key"` Tpid string - Tenant string `index:"0" re:""` - ID string `index:"1" re:""` - FilterIDs string `index:"2" re:""` - Weight float64 `index:"3" re:"\d+\.?\d*"` - RunID string `index:"4" re:""` - AttributeIDs string `index:"5" re:""` + Tenant string `index:"0" re:""` + ID string `index:"1" re:""` + FilterIDs string `index:"2" re:""` + Weights string `index:"3" re:"\d+\.?\d*"` + RunID string `index:"4" re:""` + AttributeIDs string `index:"5" re:""` CreatedAt time.Time } diff --git a/engine/resources.go b/engine/resources.go index ae0b0d7e5..1a4952190 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -42,14 +42,15 @@ type ResourceProfile struct { ID string // identifier of this resource FilterIDs []string UsageTTL time.Duration // auto-expire the usage after this duration - Limit float64 // limit value + Limit float64 // limixt value AllocationMessage string // message returned by the winning resource on allocation Blocker bool // blocker flag to stop processing on filters matched Stored bool - Weight float64 // Weight to sort the resources - ThresholdIDs []string // Thresholds to check after changing Limit + Weights utils.DynamicWeights // Weight to sort the resources + ThresholdIDs []string // Thresholds to check after changing Limit lkID string // holds the reference towards guardian lock key + } // ResourceProfileWithAPIOpts is used in replicatorV1 for dispatcher @@ -130,6 +131,7 @@ type Resource struct { tUsage *float64 // sum of all usages dirty *bool // the usages were modified, needs save, *bool so we only save if enabled in config rPrf *ResourceProfile // for ordering purposes + weight float64 } // resourceLockKey returns the ID used to lock a resource with guardian @@ -274,7 +276,7 @@ type Resources []*Resource // Sort sorts based on Weight func (rs Resources) Sort() { - sort.Slice(rs, func(i, j int) bool { return rs[i].rPrf.Weight > rs[j].rPrf.Weight }) + sort.Slice(rs, func(i, j int) bool { return rs[i].weight > rs[j].weight }) } // unlock will unlock resources part of this slice @@ -644,6 +646,10 @@ func (rS *ResourceS) matchingResourcesForEvent(ctx *context.Context, tnt string, r.ttl = utils.DurationPointer(rPrf.UsageTTL) } r.rPrf = rPrf + if r.weight, err = WeightFromDynamics(ctx, rPrf.Weights, + rS.fltrS, tnt, evNm); err != nil { + return + } rs = append(rs, r) } @@ -1051,9 +1057,9 @@ func (rp *ResourceProfile) Set(path []string, val interface{}, _ bool, _ string) rp.Blocker, err = utils.IfaceAsBool(val) case utils.Stored: rp.Stored, err = utils.IfaceAsBool(val) - case utils.Weight: + case utils.Weights: if val != utils.EmptyString { - rp.Weight, err = utils.IfaceAsFloat64(val) + rp.Weights, err = utils.NewDynamicWeightsFromString(utils.IfaceAsString(val), utils.InfieldSep, utils.ANDSep) } case utils.ThresholdIDs: var valA []string @@ -1088,9 +1094,7 @@ func (rp *ResourceProfile) Merge(v2 interface{}) { if vi.Stored { rp.Stored = vi.Stored } - if vi.Weight != 0 { - rp.Weight = vi.Weight - } + rp.Weights = append(rp.Weights, vi.Weights...) } func (rp *ResourceProfile) String() string { return utils.ToJSON(rp) } @@ -1138,7 +1142,7 @@ func (rp *ResourceProfile) FieldAsInterface(fldPath []string) (_ interface{}, er case utils.Stored: return rp.Stored, nil case utils.Weight: - return rp.Weight, nil + return rp.Weights, nil case utils.ThresholdIDs: return rp.ThresholdIDs, nil } diff --git a/engine/tpreader_test.go b/engine/tpreader_test.go index b224156f4..2708b9f60 100644 --- a/engine/tpreader_test.go +++ b/engine/tpreader_test.go @@ -408,7 +408,7 @@ func TestTPReaderGetLoadedIdsResourceProfiles(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z"}, UsageTTL: "1s", AllocationMessage: "call", - Weight: 10, + Weights: ";10", Limit: "2", Blocker: true, Stored: true, diff --git a/engine/z_filterindexer_it_test.go b/engine/z_filterindexer_it_test.go index 0d12604fc..376a79baf 100644 --- a/engine/z_filterindexer_it_test.go +++ b/engine/z_filterindexer_it_test.go @@ -1399,13 +1399,21 @@ func testITChargerProfileIndexes(t *testing.T) { Tenant: "cgrates.org", ID: "CHARGER_PRF1", FilterIDs: []string{"CHARGER_FLTR"}, - Weight: 10, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }, + }, } chrgr2 := &ChargerProfile{ Tenant: "cgrates.org", ID: "CHARGER_PRF2", FilterIDs: []string{"CHARGER_FLTR", "*string:~*req.Usage:~*req.Debited"}, - Weight: 10, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }, + }, } if err := dataManager.SetChargerProfile(context.Background(), chrgr1, true); err != nil { t.Error(err) diff --git a/engine/z_filterindexer_test.go b/engine/z_filterindexer_test.go index b0a807cd2..69b21d9cb 100644 --- a/engine/z_filterindexer_test.go +++ b/engine/z_filterindexer_test.go @@ -164,7 +164,11 @@ func TestFilterIndexesCheckingDynamicPathToNotIndexLibphNmbr(t *testing.T) { }, RunID: "RAW", AttributeIDs: []string{"attr_1"}, - Weight: 10, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }, + }, } if err := dm.SetChargerProfile(context.Background(), cghPfr, true); err != nil { diff --git a/engine/z_libindex_health_test.go b/engine/z_libindex_health_test.go index fe80d0ddc..08e8f3bba 100644 --- a/engine/z_libindex_health_test.go +++ b/engine/z_libindex_health_test.go @@ -279,7 +279,11 @@ func TestHealthIndexCharger(t *testing.T) { "*suffix:BrokenFilter:Invalid"}, // invalid (2 static types) RunID: "raw", AttributeIDs: []string{"*constant:*req.RequestType:*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } if err := dm.SetChargerProfile(context.Background(), chPrf, false); err != nil { t.Error(err) @@ -350,7 +354,11 @@ func TestHealthIndexCharger(t *testing.T) { "FLTR_1_DOES_NOT_EXIST_CHRGR"}, RunID: "raw", AttributeIDs: []string{"*constant:*req.RequestType:*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } if err := dm.SetChargerProfile(context.Background(), chPrf, false); err != nil { t.Error(err) @@ -400,7 +408,10 @@ func TestHealthIndexResources(t *testing.T) { AllocationMessage: "MessageAllocation", Blocker: true, Stored: true, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }}, } if err := dm.SetResourceProfile(context.Background(), rsPrf, false); err != nil { t.Error(err) @@ -476,7 +487,10 @@ func TestHealthIndexResources(t *testing.T) { AllocationMessage: "MessageAllocation", Blocker: true, Stored: true, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }}, } if err := dm.SetResourceProfile(context.Background(), rsPrf, false); err != nil { t.Error(err) @@ -1013,7 +1027,11 @@ func TestIndexHealthMultipleProfiles(t *testing.T) { "*suffix:BrokenFilter:Invalid"}, RunID: "raw", AttributeIDs: []string{"*constant:*req.RequestType:*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } chPrf2 := &ChargerProfile{ Tenant: "cgrates.org", @@ -1025,8 +1043,12 @@ func TestIndexHealthMultipleProfiles(t *testing.T) { "*string:~*req.Account:1234", "FLTR_1_NOT_EXIST2", }, - RunID: "*default", - Weight: 10, + RunID: "*default", + Weights: utils.DynamicWeights{ + { + Weight: 10, + }, + }, } chPrf3 := &ChargerProfile{ Tenant: "cgrates.org", @@ -1039,7 +1061,11 @@ func TestIndexHealthMultipleProfiles(t *testing.T) { }, AttributeIDs: []string{"Attr1"}, RunID: "*attribute", - Weight: 0, + Weights: utils.DynamicWeights{ + { + Weight: 0, + }, + }, } if err := dm.SetChargerProfile(context.Background(), chPrf1, false); err != nil { t.Error(err) @@ -1102,7 +1128,11 @@ func TestIndexHealthReverseChecking(t *testing.T) { }, RunID: "raw", AttributeIDs: []string{"*constant:*req.RequestType:*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } if err := dm.SetChargerProfile(context.Background(), chPrf1, false); err != nil { t.Error(err) @@ -1273,7 +1303,11 @@ func TestIndexHealthMissingReverseIndexes(t *testing.T) { }, RunID: "raw", AttributeIDs: []string{"*constant:*req.RequestType:*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } if err := dm.SetChargerProfile(context.Background(), chPrf1, false); err != nil { t.Error(err) @@ -1330,7 +1364,11 @@ func TestIndexHealthMissingReverseIndexes(t *testing.T) { }, RunID: "raw", AttributeIDs: []string{"*constant:*req.RequestType:*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } // now we set the charger with indexing and check the reverse indexes health if err := dm.SetChargerProfile(context.Background(), chPrf1, false); err != nil { diff --git a/engine/z_onstor_it_test.go b/engine/z_onstor_it_test.go index 0fbc05e66..5c32a0ecc 100644 --- a/engine/z_onstor_it_test.go +++ b/engine/z_onstor_it_test.go @@ -130,9 +130,12 @@ func testOnStorITIsDBEmpty(t *testing.T) { func testOnStorITResourceProfile(t *testing.T) { rL := &ResourceProfile{ - Tenant: "cgrates.org", - ID: "RL_TEST2", - Weight: 10, + Tenant: "cgrates.org", + ID: "RL_TEST2", + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, Limit: 1, ThresholdIDs: []string{"TEST_ACTIONS"}, @@ -923,7 +926,11 @@ func testOnStorITChargerProfile(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z"}, RunID: "*rated", AttributeIDs: []string{"ATTR_1"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } if _, rcvErr := onStor.GetChargerProfile(context.Background(), "cgrates.org", "CPP_1", true, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound { diff --git a/engine/z_resources_test.go b/engine/z_resources_test.go index 7620a93c0..c0e967b37 100644 --- a/engine/z_resources_test.go +++ b/engine/z_resources_test.go @@ -274,10 +274,13 @@ func TestResourceRecordUsage(t *testing.T) { Tenant: "cgrates.org", ID: "RL1", rPrf: &ResourceProfile{ - Tenant: "cgrates.org", - ID: "RL1", - FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, - Weight: 100, + Tenant: "cgrates.org", + ID: "RL1", + FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, + Weights: utils.DynamicWeights{ + { + Weight: 100, + }}, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, @@ -328,10 +331,13 @@ func TestResourceRemoveExpiredUnits(t *testing.T) { Tenant: "cgrates.org", ID: "RL1", rPrf: &ResourceProfile{ - Tenant: "cgrates.org", - ID: "RL1", - FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, - Weight: 100, + Tenant: "cgrates.org", + ID: "RL1", + FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, + Weights: utils.DynamicWeights{ + { + Weight: 100, + }}, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, @@ -397,10 +403,13 @@ func TestResourceUsedUnits(t *testing.T) { Tenant: "cgrates.org", ID: "RL1", rPrf: &ResourceProfile{ - Tenant: "cgrates.org", - ID: "RL1", - FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, - Weight: 100, + Tenant: "cgrates.org", + ID: "RL1", + FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, + Weights: utils.DynamicWeights{ + { + Weight: 100, + }}, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, @@ -460,10 +469,13 @@ func TestResourceSort(t *testing.T) { Tenant: "cgrates.org", ID: "RL1", rPrf: &ResourceProfile{ - Tenant: "cgrates.org", - ID: "RL1", - FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, - Weight: 100, + Tenant: "cgrates.org", + ID: "RL1", + FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, + Weights: utils.DynamicWeights{ + { + Weight: 100, + }}, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, @@ -475,6 +487,7 @@ func TestResourceSort(t *testing.T) { }, TTLIdx: []string{ru1.ID}, tUsage: utils.Float64Pointer(2), + weight: 100, } if err := r1.recordUsage(ru2); err != nil { @@ -494,9 +507,12 @@ func TestResourceSort(t *testing.T) { Tenant: "cgrates.org", ID: "RL2", rPrf: &ResourceProfile{ - ID: "RL2", - FilterIDs: []string{"FLTR_RES_RL2", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, - Weight: 50, + ID: "RL2", + FilterIDs: []string{"FLTR_RES_RL2", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, + Weights: utils.DynamicWeights{ + { + Weight: 50, + }}, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, UsageTTL: time.Millisecond, @@ -506,6 +522,7 @@ func TestResourceSort(t *testing.T) { ru2.ID: ru2, }, tUsage: utils.Float64Pointer(2), + weight: 50, } rs = Resources{r2, r1} @@ -539,10 +556,13 @@ func TestResourceClearUsage(t *testing.T) { Tenant: "cgrates.org", ID: "RL1", rPrf: &ResourceProfile{ - Tenant: "cgrates.org", - ID: "RL1", - FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, - Weight: 100, + Tenant: "cgrates.org", + ID: "RL1", + FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, + Weights: utils.DynamicWeights{ + { + Weight: 100, + }}, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, @@ -554,6 +574,7 @@ func TestResourceClearUsage(t *testing.T) { }, TTLIdx: []string{ru1.ID}, tUsage: utils.Float64Pointer(2), + weight: 100, } if err := r1.recordUsage(ru2); err != nil { @@ -573,9 +594,12 @@ func TestResourceClearUsage(t *testing.T) { Tenant: "cgrates.org", ID: "RL2", rPrf: &ResourceProfile{ - ID: "RL2", - FilterIDs: []string{"FLTR_RES_RL2", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, - Weight: 50, + ID: "RL2", + FilterIDs: []string{"FLTR_RES_RL2", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, + Weights: utils.DynamicWeights{ + { + Weight: 50, + }}, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, UsageTTL: time.Millisecond, @@ -585,6 +609,7 @@ func TestResourceClearUsage(t *testing.T) { ru2.ID: ru2, }, tUsage: utils.Float64Pointer(2), + weight: 50, } rs := Resources{r2, r1} @@ -635,10 +660,13 @@ func TestResourceRecordUsages(t *testing.T) { Tenant: "cgrates.org", ID: "RL1", rPrf: &ResourceProfile{ - Tenant: "cgrates.org", - ID: "RL1", - FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, - Weight: 100, + Tenant: "cgrates.org", + ID: "RL1", + FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, + Weights: utils.DynamicWeights{ + { + Weight: 100, + }}, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, @@ -650,6 +678,7 @@ func TestResourceRecordUsages(t *testing.T) { }, TTLIdx: []string{ru1.ID}, tUsage: utils.Float64Pointer(2), + weight: 100, } if err := r1.recordUsage(ru2); err != nil { @@ -669,9 +698,12 @@ func TestResourceRecordUsages(t *testing.T) { Tenant: "cgrates.org", ID: "RL2", rPrf: &ResourceProfile{ - ID: "RL2", - FilterIDs: []string{"FLTR_RES_RL2", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, - Weight: 50, + ID: "RL2", + FilterIDs: []string{"FLTR_RES_RL2", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, + Weights: utils.DynamicWeights{ + { + Weight: 50, + }}, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, UsageTTL: time.Millisecond, @@ -681,6 +713,7 @@ func TestResourceRecordUsages(t *testing.T) { ru2.ID: ru2, }, tUsage: utils.Float64Pointer(2), + weight: 50, } rs := Resources{r2, r1} @@ -723,10 +756,13 @@ func TestResourceAllocateResource(t *testing.T) { Tenant: "cgrates.org", ID: "RL1", rPrf: &ResourceProfile{ - Tenant: "cgrates.org", - ID: "RL1", - FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, - Weight: 100, + Tenant: "cgrates.org", + ID: "RL1", + FilterIDs: []string{"FLTR_RES_RL1", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, + Weights: utils.DynamicWeights{ + { + Weight: 100, + }}, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, @@ -738,6 +774,7 @@ func TestResourceAllocateResource(t *testing.T) { }, TTLIdx: []string{ru1.ID}, tUsage: utils.Float64Pointer(2), + weight: 100, } if err := r1.recordUsage(ru2); err != nil { @@ -757,9 +794,12 @@ func TestResourceAllocateResource(t *testing.T) { Tenant: "cgrates.org", ID: "RL2", rPrf: &ResourceProfile{ - ID: "RL2", - FilterIDs: []string{"FLTR_RES_RL2", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, - Weight: 50, + ID: "RL2", + FilterIDs: []string{"FLTR_RES_RL2", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, + Weights: utils.DynamicWeights{ + { + Weight: 50, + }}, Limit: 2, ThresholdIDs: []string{"TEST_ACTIONS"}, UsageTTL: time.Millisecond, @@ -769,6 +809,7 @@ func TestResourceAllocateResource(t *testing.T) { ru2.ID: ru2, }, tUsage: utils.Float64Pointer(2), + weight: 50, } rs := Resources{r2, r1} @@ -835,10 +876,13 @@ func TestRSCacheSetGet(t *testing.T) { ID: "RL", FilterIDs: []string{"FLTR_RES_RL", "*ai:~*req.AnswerTime:2014-07-03T13:43:00Z|2014-07-03T13:44:00Z"}, AllocationMessage: "ALLOC_RL", - Weight: 50, - Limit: 2, - ThresholdIDs: []string{"TEST_ACTIONS"}, - UsageTTL: time.Millisecond, + Weights: utils.DynamicWeights{ + { + Weight: 50, + }}, + Limit: 2, + ThresholdIDs: []string{"TEST_ACTIONS"}, + UsageTTL: time.Millisecond, }, Usages: map[string]*ResourceUsage{ "RU2": { @@ -979,8 +1023,11 @@ func TestResourceAddResourceProfile(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -989,8 +1036,11 @@ func TestResourceAddResourceProfile(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -999,8 +1049,11 @@ func TestResourceAddResourceProfile(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, } resourceTest := Resources{ @@ -1127,8 +1180,11 @@ func TestResourceMatchingResourcesForEvent(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -1137,8 +1193,11 @@ func TestResourceMatchingResourcesForEvent(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -1147,8 +1206,11 @@ func TestResourceMatchingResourcesForEvent(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, } resourceTest := Resources{ @@ -1269,8 +1331,11 @@ func TestResourceUsageTTLCase1(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -1279,8 +1344,11 @@ func TestResourceUsageTTLCase1(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -1289,8 +1357,11 @@ func TestResourceUsageTTLCase1(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, } resourceTest := Resources{ @@ -1466,8 +1537,11 @@ func TestResourceUsageTTLCase2(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -1476,8 +1550,11 @@ func TestResourceUsageTTLCase2(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -1486,8 +1563,11 @@ func TestResourceUsageTTLCase2(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, } resourceTest := Resources{ @@ -1660,8 +1740,11 @@ func TestResourceUsageTTLCase3(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -1670,8 +1753,11 @@ func TestResourceUsageTTLCase3(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -1680,8 +1766,11 @@ func TestResourceUsageTTLCase3(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, } resourceTest := Resources{ @@ -1855,8 +1944,11 @@ func TestResourceUsageTTLCase4(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -1865,8 +1957,11 @@ func TestResourceUsageTTLCase4(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -1875,8 +1970,11 @@ func TestResourceUsageTTLCase4(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, } resourceTest := Resources{ @@ -2050,8 +2148,11 @@ func TestResourceResIDsMp(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -2060,8 +2161,11 @@ func TestResourceResIDsMp(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -2070,8 +2174,11 @@ func TestResourceResIDsMp(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, } resourceTest := Resources{ @@ -2192,8 +2299,11 @@ func TestResourceMatchWithIndexFalse(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -2202,8 +2312,11 @@ func TestResourceMatchWithIndexFalse(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, { Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, @@ -2212,8 +2325,11 @@ func TestResourceMatchWithIndexFalse(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{""}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{""}, }, } resourceTest := Resources{ @@ -2347,8 +2463,11 @@ func TestResourceCaching(t *testing.T) { UsageTTL: -1, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{utils.MetaNone}, } if err := Cache.Set(context.TODO(), utils.CacheResourceProfiles, "cgrates.org:ResourceProfileCached", @@ -2650,10 +2769,13 @@ func TestResourcesRecordUsageClearErr(t *testing.T) { func TestResourceAllocateResourceOtherDB(t *testing.T) { rProf := &ResourceProfile{ - Tenant: "cgrates.org", - ID: "RL_DB", - FilterIDs: []string{"*string:~*opts.Resource:RL_DB"}, - Weight: 100, + Tenant: "cgrates.org", + ID: "RL_DB", + FilterIDs: []string{"*string:~*opts.Resource:RL_DB"}, + Weights: utils.DynamicWeights{ + { + Weight: 100, + }}, Limit: 2, ThresholdIDs: []string{utils.MetaNone}, UsageTTL: -time.Nanosecond, @@ -3347,9 +3469,12 @@ func TestResourcesV1ResourcesForEventOK(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -3366,6 +3491,7 @@ func TestResourcesV1ResourcesForEventOK(t *testing.T) { tUsage: utils.Float64Pointer(10), ttl: utils.DurationPointer(time.Minute), TTLIdx: []string{}, + weight: 10, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) if err != nil { @@ -3405,6 +3531,7 @@ func TestResourcesV1ResourcesForEventOK(t *testing.T) { tUsage: utils.Float64Pointer(10), ttl: utils.DurationPointer(72 * time.Hour), TTLIdx: []string{}, + weight: 10, }, } var reply Resources @@ -3426,9 +3553,12 @@ func TestResourcesV1ResourcesForEventNotFound(t *testing.T) { ID: "RES1", FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -3482,9 +3612,12 @@ func TestResourcesV1ResourcesForEventMissingParameters(t *testing.T) { ID: "RES1", FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -3583,9 +3716,12 @@ func TestResourcesV1ResourcesForEventCacheReplyExists(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -3678,9 +3814,12 @@ func TestResourcesV1ResourcesForEventCacheReplySet(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -3697,6 +3836,7 @@ func TestResourcesV1ResourcesForEventCacheReplySet(t *testing.T) { tUsage: utils.Float64Pointer(10), ttl: utils.DurationPointer(time.Minute), TTLIdx: []string{}, + weight: 10, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) if err != nil { @@ -3736,6 +3876,7 @@ func TestResourcesV1ResourcesForEventCacheReplySet(t *testing.T) { tUsage: utils.Float64Pointer(10), ttl: utils.DurationPointer(72 * time.Hour), TTLIdx: []string{}, + weight: 10, }, } var reply Resources @@ -3774,9 +3915,12 @@ func TestResourcesV1GetResourceOK(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -3851,9 +3995,12 @@ func TestResourcesV1GetResourceNotFound(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -3910,9 +4057,12 @@ func TestResourcesV1GetResourceMissingParameters(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -3968,9 +4118,12 @@ func TestResourcesV1GetResourceWithConfigOK(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -4048,9 +4201,12 @@ func TestResourcesV1GetResourceWithConfigNilrPrfOK(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) if err != nil { @@ -4131,9 +4287,12 @@ func TestResourcesV1GetResourceWithConfigNilrPrfProfileNotFound(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) if err != nil { @@ -4192,9 +4351,12 @@ func TestResourcesV1GetResourceWithConfigResourceNotFound(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -4249,9 +4411,12 @@ func TestResourcesV1GetResourceWithConfigMissingParameters(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -4305,9 +4470,12 @@ func TestResourcesV1AuthorizeResourcesOK(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -4356,9 +4524,12 @@ func TestResourcesV1AuthorizeResourcesNotAuthorized(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 0, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 0, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -4407,9 +4578,12 @@ func TestResourcesV1AuthorizeResourcesNoMatch(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -4458,9 +4632,12 @@ func TestResourcesV1AuthorizeResourcesNilCGREvent(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -4498,9 +4675,12 @@ func TestResourcesV1AuthorizeResourcesMissingUsageID(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -4550,9 +4730,12 @@ func TestResourcesV1AuthorizeResourcesCacheReplyExists(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -4631,9 +4814,12 @@ func TestResourcesV1AuthorizeResourcesCacheReplySet(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: -1, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: -1, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -4712,9 +4898,12 @@ func TestResourcesV1AllocateResourcesOK(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -4763,9 +4952,12 @@ func TestResourcesV1AllocateResourcesNoMatch(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -4813,9 +5005,12 @@ func TestResourcesV1AllocateResourcesMissingParameters(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -4903,9 +5098,12 @@ func TestResourcesV1AllocateResourcesCacheReplyExists(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: -1, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: -1, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -4984,9 +5182,12 @@ func TestResourcesV1AllocateResourcesCacheReplySet(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: -1, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: -1, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -5065,9 +5266,12 @@ func TestResourcesV1AllocateResourcesResAllocErr(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "", - Weight: 10, - Limit: -1, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: -1, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) if err != nil { @@ -5116,9 +5320,12 @@ func TestResourcesV1AllocateResourcesProcessThErr(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaThresholds)}, AllocationMessage: "Approved", - Weight: 10, - Limit: -1, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: -1, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -5198,9 +5405,12 @@ func TestResourcesV1ReleaseResourcesOK(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -5254,9 +5464,12 @@ func TestResourcesV1ReleaseResourcesUsageNotFound(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: 0, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: 0, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -5322,9 +5535,12 @@ func TestResourcesV1ReleaseResourcesNoMatch(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -5372,9 +5588,12 @@ func TestResourcesV1ReleaseResourcesMissingParameters(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -5462,9 +5681,12 @@ func TestResourcesV1ReleaseResourcesCacheReplyExists(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: -1, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: -1, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -5543,9 +5765,12 @@ func TestResourcesV1ReleaseResourcesCacheReplySet(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: -1, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: -1, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -5637,9 +5862,12 @@ func TestResourcesV1ReleaseResourcesProcessThErr(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaThresholds)}, AllocationMessage: "Approved", - Weight: 10, - Limit: -1, - UsageTTL: time.Minute, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: -1, + UsageTTL: time.Minute, } rs := &Resource{ rPrf: rsPrf, @@ -5722,10 +5950,13 @@ func TestResourcesStoreResourceError(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, - Stored: true, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, + Stored: true, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -5819,8 +6050,11 @@ func TestResourceMatchingResourcesForEventLocks(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{utils.MetaNone}, } dm.SetResourceProfile(context.Background(), rPrf, true) prfs = append(prfs, rPrf) @@ -5869,8 +6103,11 @@ func TestResourceMatchingResourcesForEventLocks2(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{utils.MetaNone}, } dm.SetResourceProfile(context.Background(), rPrf, true) prfs = append(prfs, rPrf) @@ -5883,8 +6120,11 @@ func TestResourceMatchingResourcesForEventLocks2(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{utils.MetaNone}, } err = db.SetResourceProfileDrv(context.Background(), rPrf) if err != nil { @@ -5934,9 +6174,12 @@ func TestResourceMatchingResourcesForEventLocksBlocker(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: float64(10 - i), - Blocker: i == 4, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: float64(10 - i), + }}, + Blocker: i == 4, + ThresholdIDs: []string{utils.MetaNone}, } dm.SetResourceProfile(context.Background(), rPrf, true) prfs = append(prfs, rPrf) @@ -5989,8 +6232,11 @@ func TestResourceMatchingResourcesForEventLocks3(t *testing.T) { UsageTTL: 10 * time.Second, Limit: 10.00, AllocationMessage: "AllocationMessage", - Weight: 20.00, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 20.00, + }}, + ThresholdIDs: []string{utils.MetaNone}, } Cache.Set(context.Background(), utils.CacheResources, rPrf.TenantID(), &Resource{ Tenant: rPrf.Tenant, @@ -6032,8 +6278,11 @@ func TestResourcesLockUnlockResourceProfiles(t *testing.T) { ID: "RES1", Limit: 10, AllocationMessage: "Approved", - Weight: 10, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + ThresholdIDs: []string{utils.MetaNone}, } //lock profile with empty lkID parameter @@ -6332,10 +6581,13 @@ func TestResourcesMatchingResourcesForEventFinalCacheSetErr(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, ThresholdIDs: []string{utils.MetaNone}, AllocationMessage: "Approved", - Weight: 10, - Limit: 10, - UsageTTL: time.Minute, - Stored: true, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, + Limit: 10, + UsageTTL: time.Minute, + Stored: true, } err := dm.SetResourceProfile(context.Background(), rsPrf, true) @@ -6359,6 +6611,7 @@ func TestResourcesMatchingResourcesForEventFinalCacheSetErr(t *testing.T) { Usages: make(map[string]*ResourceUsage), ttl: utils.DurationPointer(10 * time.Second), dirty: utils.BoolPointer(false), + weight: 10, } if rcv, err := rS.matchingResourcesForEvent(context.Background(), "cgrates.org", ev, ev.ID, @@ -6745,10 +6998,13 @@ func TestResourcesV1ReleaseResourcesErrRetrieveUsageTTL(t *testing.T) { func TestResourceProfileSet(t *testing.T) { cp := ResourceProfile{} exp := ResourceProfile{ - Tenant: "cgrates.org", - ID: "ID", - FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, - Weight: 10, + Tenant: "cgrates.org", + ID: "ID", + FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, UsageTTL: 10, Limit: 10, AllocationMessage: "new", @@ -6775,7 +7031,7 @@ func TestResourceProfileSet(t *testing.T) { if err := cp.Set([]string{utils.FilterIDs}, "fltr1;*string:~*req.Account:1001", false, utils.EmptyString); err != nil { t.Error(err) } - if err := cp.Set([]string{utils.Weight}, 10, false, utils.EmptyString); err != nil { + if err := cp.Set([]string{utils.Weights}, ";10", false, utils.EmptyString); err != nil { t.Error(err) } if err := cp.Set([]string{utils.UsageTTL}, 10, false, utils.EmptyString); err != nil { @@ -6804,10 +7060,13 @@ func TestResourceProfileSet(t *testing.T) { func TestResourceProfileAsInterface(t *testing.T) { rp := ResourceProfile{ - Tenant: "cgrates.org", - ID: "ID", - FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, - Weight: 10, + Tenant: "cgrates.org", + ID: "ID", + FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, UsageTTL: 10, Limit: 10, AllocationMessage: "new", @@ -6846,7 +7105,7 @@ func TestResourceProfileAsInterface(t *testing.T) { } if val, err := rp.FieldAsInterface([]string{utils.Weight}); err != nil { t.Fatal(err) - } else if exp := rp.Weight; !reflect.DeepEqual(exp, val) { + } else if exp := rp.Weights; !reflect.DeepEqual(exp, val) { t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(val)) } if val, err := rp.FieldAsInterface([]string{utils.ThresholdIDs}); err != nil { @@ -6903,10 +7162,13 @@ func TestResourceProfileAsInterface(t *testing.T) { func TestResourceProfileMerge(t *testing.T) { dp := &ResourceProfile{} exp := &ResourceProfile{ - Tenant: "cgrates.org", - ID: "ID", - FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, - Weight: 10, + Tenant: "cgrates.org", + ID: "ID", + FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, UsageTTL: 10, Limit: 10, AllocationMessage: "new", @@ -6915,10 +7177,13 @@ func TestResourceProfileMerge(t *testing.T) { ThresholdIDs: []string{"TH1"}, } if dp.Merge(&ResourceProfile{ - Tenant: "cgrates.org", - ID: "ID", - FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, - Weight: 10, + Tenant: "cgrates.org", + ID: "ID", + FilterIDs: []string{"fltr1", "*string:~*req.Account:1001"}, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, UsageTTL: 10, Limit: 10, AllocationMessage: "new", diff --git a/engine/z_stordb_it_test.go b/engine/z_stordb_it_test.go index 26b82a59c..c1253badd 100644 --- a/engine/z_stordb_it_test.go +++ b/engine/z_stordb_it_test.go @@ -823,7 +823,7 @@ func testStorDBitCRUDTPChargers(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1002"}, AttributeIDs: make([]string, 0), RunID: utils.MetaDefault, - Weight: 20, + Weights: ";20", }, { TPid: "TP_id", @@ -832,7 +832,7 @@ func testStorDBitCRUDTPChargers(t *testing.T) { FilterIDs: []string{"*string:~*req.Destination:10"}, AttributeIDs: make([]string, 0), RunID: utils.MetaDefault, - Weight: 10, + Weights: ";10", }, } if err := storDB.SetTPChargers(tpChargers); err != nil { @@ -882,7 +882,7 @@ func testStorDBitCRUDTpResources(t *testing.T) { { TPid: "testTPid", ID: "testTag1", - Weight: 0.0, + Weights: ";0", Limit: "test", ThresholdIDs: []string{"1x", "2x"}, FilterIDs: []string{"FILTR_RES_1"}, @@ -892,7 +892,7 @@ func testStorDBitCRUDTpResources(t *testing.T) { { TPid: "testTPid", ID: "testTag2", - Weight: 0.0, + Weights: ";0", Limit: "test", ThresholdIDs: []string{"1x", "2x"}, FilterIDs: []string{"FLTR_RES_2"}, @@ -913,8 +913,8 @@ func testStorDBitCRUDTpResources(t *testing.T) { if !(reflect.DeepEqual(snd[0].ID, rcv[0].ID) || reflect.DeepEqual(snd[0].ID, rcv[1].ID)) { t.Errorf("Expecting: %+v, received: %+v || %+v", snd[0].ID, rcv[0].ID, rcv[1].ID) } - if !(reflect.DeepEqual(snd[0].Weight, rcv[0].Weight) || reflect.DeepEqual(snd[0].Weight, rcv[1].Weight)) { - t.Errorf("Expecting: %+v, received: %+v || %+v", snd[0].Weight, rcv[0].Weight, rcv[1].Weight) + if !(reflect.DeepEqual(snd[0].Weights, rcv[0].Weights) || reflect.DeepEqual(snd[0].Weights, rcv[1].Weights)) { + t.Errorf("Expecting: %+v, received: %+v || %+v", snd[0].Weights, rcv[0].Weights, rcv[1].Weights) } if !(reflect.DeepEqual(snd[0].Limit, rcv[0].Limit) || reflect.DeepEqual(snd[0].Limit, rcv[1].Limit)) { t.Errorf("Expecting: %+v, received: %+v || %+v", snd[0].Limit, rcv[0].Limit, rcv[1].Limit) @@ -926,8 +926,8 @@ func testStorDBitCRUDTpResources(t *testing.T) { } } // UPDATE - snd[0].Weight = 2.1 - snd[1].Weight = 2.1 + snd[0].Weights = ";2.1" + snd[1].Weights = ";2.1" if err := storDB.SetTPResources(snd); err != nil { t.Error(err) } @@ -941,8 +941,8 @@ func testStorDBitCRUDTpResources(t *testing.T) { if !(reflect.DeepEqual(snd[0].ID, rcv[0].ID) || reflect.DeepEqual(snd[0].ID, rcv[1].ID)) { t.Errorf("Expecting: %+v, received: %+v || %+v", snd[0].ID, rcv[0].ID, rcv[1].ID) } - if !(reflect.DeepEqual(snd[0].Weight, rcv[0].Weight) || reflect.DeepEqual(snd[0].Weight, rcv[1].Weight)) { - t.Errorf("Expecting: %+v, received: %+v || %+v", snd[0].Weight, rcv[0].Weight, rcv[1].Weight) + if !(reflect.DeepEqual(snd[0].Weights, rcv[0].Weights) || reflect.DeepEqual(snd[0].Weights, rcv[1].Weights)) { + t.Errorf("Expecting: %+v, received: %+v || %+v", snd[0].Weights, rcv[0].Weights, rcv[1].Weights) } if !(reflect.DeepEqual(snd[0].Limit, rcv[0].Limit) || reflect.DeepEqual(snd[0].Limit, rcv[1].Limit)) { t.Errorf("Expecting: %+v, received: %+v || %+v", snd[0].Limit, rcv[0].Limit, rcv[1].Limit) diff --git a/general_tests/attributes_it_test.go b/general_tests/attributes_it_test.go index a36b72f26..743a5d289 100644 --- a/general_tests/attributes_it_test.go +++ b/general_tests/attributes_it_test.go @@ -524,8 +524,11 @@ func testAttributeSProcessEventWithResource(t *testing.T) { Limit: 10, AllocationMessage: "MessageAllocation", Stored: true, - Weight: 20, - ThresholdIDs: []string{utils.MetaNone}, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }}, + ThresholdIDs: []string{utils.MetaNone}, } var result string diff --git a/general_tests/export_it_test.go b/general_tests/export_it_test.go index 1f5a915ef..dbfedffd1 100644 --- a/general_tests/export_it_test.go +++ b/general_tests/export_it_test.go @@ -254,14 +254,17 @@ func testExpVerifyThresholds(t *testing.T) { func testExpVerifyResources(t *testing.T) { rPrf := &engine.ResourceProfile{ - Tenant: "cgrates.org", - ID: "RES_ACNT_1001", - FilterIDs: []string{"FLTR_ACCOUNT_1001"}, - UsageTTL: time.Hour, - Limit: 1, - Blocker: false, - Stored: false, - Weight: 10, + Tenant: "cgrates.org", + ID: "RES_ACNT_1001", + FilterIDs: []string{"FLTR_ACCOUNT_1001"}, + UsageTTL: time.Hour, + Limit: 1, + Blocker: false, + Stored: false, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, ThresholdIDs: []string{}, } if *encoding == utils.MetaGOB { diff --git a/general_tests/session_graceful_shutdown_it_test.go b/general_tests/session_graceful_shutdown_it_test.go index 19789f4c8..f488b6a9c 100644 --- a/general_tests/session_graceful_shutdown_it_test.go +++ b/general_tests/session_graceful_shutdown_it_test.go @@ -145,7 +145,11 @@ func testSessionSRplcApierSetChargerS(t *testing.T) { ID: "Default", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, } var result1 string @@ -161,7 +165,11 @@ func testSessionSRplcApierSetChargerS(t *testing.T) { ID: "Default", RunID: utils.MetaDefault, AttributeIDs: []string{"*none"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, }, } var result2 string diff --git a/migrator/chargers_it_test.go b/migrator/chargers_it_test.go index dc0d3a4f8..8e86eed71 100644 --- a/migrator/chargers_it_test.go +++ b/migrator/chargers_it_test.go @@ -185,14 +185,22 @@ func testChrgITMigrateAndMove(t *testing.T) { ID: "CHRG_1", FilterIDs: []string{"*string:Accont:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z|2014-07-14T14:25:00Z"}, AttributeIDs: []string{"ATTR_1"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } chrgPrf2 := &engine.ChargerProfile{ Tenant: "cgrates.com", ID: "CHRG_1", FilterIDs: []string{"*string:Accont:1001", "*ai:~*req.AnswerTime:2014-07-14T14:25:00Z|2014-07-14T14:25:00Z"}, AttributeIDs: []string{"ATTR_1"}, - Weight: 20, + Weights: utils.DynamicWeights{ + { + Weight: 20, + }, + }, } switch chrgAction { case utils.Migrate: // for the momment only one version of chargers exists diff --git a/migrator/resource_it_test.go b/migrator/resource_it_test.go index 9ffa34f01..ec97aa8a4 100644 --- a/migrator/resource_it_test.go +++ b/migrator/resource_it_test.go @@ -181,12 +181,15 @@ func testResITFlush(t *testing.T) { func testResITMigrateAndMove(t *testing.T) { resPrfl := &engine.ResourceProfile{ - Tenant: "cgrates.org", - ID: "RES1", - FilterIDs: []string{"*string:~*req.Account:1001"}, - UsageTTL: time.Second, - Limit: 1, - Weight: 10, + Tenant: "cgrates.org", + ID: "RES1", + FilterIDs: []string{"*string:~*req.Account:1001"}, + UsageTTL: time.Second, + Limit: 1, + Weights: utils.DynamicWeights{ + { + Weight: 10, + }}, ThresholdIDs: []string{"TH1"}, } switch resAction { diff --git a/migrator/tp_resources_it_test.go b/migrator/tp_resources_it_test.go index 173f75256..c47945982 100644 --- a/migrator/tp_resources_it_test.go +++ b/migrator/tp_resources_it_test.go @@ -119,7 +119,7 @@ func testTpResITPopulate(t *testing.T) { AllocationMessage: "", Blocker: true, Stored: true, - Weight: 20, + Weights: ";20", ThresholdIDs: []string{"ValOne", "ValTwo"}, }, } diff --git a/utils/apitpdata.go b/utils/apitpdata.go index e0974f60e..a179ae4c8 100644 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -148,7 +148,7 @@ type TPResourceProfile struct { AllocationMessage string Blocker bool // blocker flag to stop processing on filters matched Stored bool - Weight float64 // Weight to sort the ResourceLimits + Weights string // Weight to sort the ResourceLimits ThresholdIDs []string // Thresholds to check after changing Limit } @@ -331,7 +331,7 @@ type TPChargerProfile struct { FilterIDs []string RunID string AttributeIDs []string - Weight float64 + Weights string } type TPTntID struct {