From 0caf4123d1e8a34ca35975c6bddd8eaed7c4b1b4 Mon Sep 17 00:00:00 2001 From: porosnicuadrian Date: Thu, 17 Mar 2022 15:32:47 +0200 Subject: [PATCH] TPe tests --- apis/cache_it_test.go | 6 +++--- apis/tpes_it_test.go | 12 +++++++++--- data/conf/samples/tutinternal/cgrates.json | 7 ------- data/conf/samples/tutmongo/cgrates.json | 14 -------------- tpes/tpes.go | 5 +++-- 5 files changed, 15 insertions(+), 29 deletions(-) diff --git a/apis/cache_it_test.go b/apis/cache_it_test.go index fb5033678..ff4dc15c7 100644 --- a/apis/cache_it_test.go +++ b/apis/cache_it_test.go @@ -216,7 +216,7 @@ func testCacheSHasItemAttributeProfile(t *testing.T) { t.Errorf("Unexpected reply result") } - //also cannot take any itemIDs + // also cannot take any itemIDs argsIds := &utils.ArgsGetCacheItemIDsWithAPIOpts{ ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{ CacheID: utils.CacheAttributeProfiles, @@ -264,7 +264,7 @@ func testCacheSHasItemAttributeProfile(t *testing.T) { ItemID: "cgrates.org:TEST_ATTRIBUTES_IT_TEST", }, } - //Getting an profile from db will set it in cache + // Getting an profile from db will set it in cache if err := chcRPC.Call(context.Background(), utils.CacheSv1HasItem, args, &reply); err != nil { t.Error(err) @@ -382,7 +382,7 @@ func testCacheSRemoveItemsAndReloadCache(t *testing.T) { t.Errorf("Unexpected reply return") } - //as we removed the items, we cannot take it from cache + // as we removed the items, we cannot take it from cache if err := chcRPC.Call(context.Background(), utils.CacheSv1GetItemIDs, argsIds, &result); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Errorf("Expected %+v, received %+v", utils.ErrNotFound, result) diff --git a/apis/tpes_it_test.go b/apis/tpes_it_test.go index 7d605cfbe..a0bf3cacc 100644 --- a/apis/tpes_it_test.go +++ b/apis/tpes_it_test.go @@ -65,6 +65,11 @@ var ( testTPeSExportTariffPlanAllTariffPlan, // export again after we will flush the database testTPeSInitDataDb, + testTPeSKillEngine, + + testTPeSInitCfg, + testTPeSStartEngine, + testTPeSRPCConn, testTPeSExportAfterFlush, testTPeSKillEngine, } @@ -159,6 +164,7 @@ func testTPeSSetAttributeProfile(t *testing.T) { } else if reply != utils.OK { t.Error(err) } + attrPrf1 := &engine.APIAttributeProfileWithAPIOpts{ APIAttributeProfile: &engine.APIAttributeProfile{ Tenant: utils.CGRateSorg, @@ -1089,7 +1095,7 @@ func testTPeSExportTariffPlanHalfTariffPlan(t *testing.T) { }, utils.DispatcherProfilesCsv: { {"#Tenant", "ID", "FilterIDs", "Weight", "Strategy", "StrategyParameters", "ConnID", "ConnFilterIDs", "ConnWeight", "ConnBlocker", "ConnParameters"}, - {"cgrates.org", "Dsp1", "*string:~*req.Account:1001;*ai:~*req.AnswerTime:2014-07-14T14:25:00Z", "20", "*first", "false", "C1", "", "10", "false", "*ratio:2;192.168.54.203"}, + {"cgrates.org", "Dsp1", "*string:~*req.Account:1001;*ai:~*req.AnswerTime:2014-07-14T14:25:00Z", "20", "*first", "false", "C1", "", "10", "false", "192.168.54.203"}, }, } expected[utils.RatesCsv] = csvRply[utils.RatesCsv] @@ -1223,7 +1229,7 @@ func testTPeSExportTariffPlanAllTariffPlan(t *testing.T) { }, utils.DispatcherProfilesCsv: { {"#Tenant", "ID", "FilterIDs", "Weight", "Strategy", "StrategyParameters", "ConnID", "ConnFilterIDs", "ConnWeight", "ConnBlocker", "ConnParameters"}, - {"cgrates.org", "Dsp1", "*string:~*req.Account:1001;*ai:~*req.AnswerTime:2014-07-14T14:25:00Z", "20", "*first", "false", "C1", "", "10", "false", "*ratio:2;192.168.54.203"}, + {"cgrates.org", "Dsp1", "*string:~*req.Account:1001;*ai:~*req.AnswerTime:2014-07-14T14:25:00Z", "20", "*first", "false", "C1", "", "10", "false", "192.168.54.203"}, {"cgrates.org", "Dsp2", "*string:~*opts.EventType:LoadDispatcher", "10", "*weight", "", "Conn2", "*suffix:~*opts.*answerTime:45T", "0", "false", "*ratio:1"}, }, } @@ -1297,7 +1303,7 @@ func testTPeSExportAfterFlush(t *testing.T) { } // empty exporters, nothing in database to export if len(csvRply) != 0 { - t.Errorf("Unexpected length, expected to be 0, no exports were nedeed and got zip containing: %v", utils.ToJSON(csvRply)) + t.Errorf("Unexpected length, expected to be 0, no exports were nedeed and got zip containing: \n %v", utils.ToJSON(csvRply)) } } diff --git a/data/conf/samples/tutinternal/cgrates.json b/data/conf/samples/tutinternal/cgrates.json index 4eb0fe2e1..e0cd7e08d 100644 --- a/data/conf/samples/tutinternal/cgrates.json +++ b/data/conf/samples/tutinternal/cgrates.json @@ -20,13 +20,6 @@ "db_type": "*internal" }, - -"schedulers": { - "enabled": true, - "cdrs_conns": ["*internal"], - "stats_conns": ["*localhost"] -}, - "cdrs": { "enabled": true, "chargers_conns":["*internal"] diff --git a/data/conf/samples/tutmongo/cgrates.json b/data/conf/samples/tutmongo/cgrates.json index 880b0c247..00247a215 100644 --- a/data/conf/samples/tutmongo/cgrates.json +++ b/data/conf/samples/tutmongo/cgrates.json @@ -21,20 +21,6 @@ "db_port": 27017, }, -"rals": { - "enabled": true, - "thresholds_conns": ["*internal"], - "max_increments":3000000, -}, - - -"schedulers": { - "enabled": true, - "cdrs_conns": ["*internal"], - "stats_conns": ["*localhost"], -}, - - "cdrs": { "enabled": true, "chargers_conns":["*internal"], diff --git a/tpes/tpes.go b/tpes/tpes.go index 69e498de5..b9c35ae17 100644 --- a/tpes/tpes.go +++ b/tpes/tpes.go @@ -119,9 +119,10 @@ func (tpE *TPeS) V1ExportTariffPlan(ctx *context.Context, args *ArgsExportTP, re var itemIDs []string if itemIDs, err = getTariffPlansKeys(ctx, tpE.dm, args.Tenant, subsystem); err != nil { return + } else if len(itemIDs) != 0 { + // the map e.g. : *filters: {"ATTR_1", "ATTR_1"} + args.ExportItems[subsystem] = itemIDs } - // the map e.g. : *filters: {"ATTR_1", "ATTR_1"} - args.ExportItems[subsystem] = itemIDs } } else { // else export just the wanted IDs