From 65345437536e6dc9a5b02d8fcae3a1c26e874bcb Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 4 May 2020 17:05:17 +0300 Subject: [PATCH] Updated integration tests --- apier/v1/apier_it_test.go | 7 +++++++ engine/loader_it_test.go | 14 ++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/apier/v1/apier_it_test.go b/apier/v1/apier_it_test.go index 9c1db994e..534437d62 100644 --- a/apier/v1/apier_it_test.go +++ b/apier/v1/apier_it_test.go @@ -822,6 +822,8 @@ func testApierLoadAccountActions(t *testing.T) { expectedStats[utils.CacheAccountActionPlans].Items = 1 expectedStats[utils.CacheActionPlans].Items = 1 expectedStats[utils.CacheActions].Items = 1 + expectedStats[utils.CacheLoadIDs].Items = 20 + expectedStats[utils.CacheRPCConnections].Items = 1 if err := rater.Call(utils.CacheSv1GetCacheStats, new(utils.AttrCacheIDsWithArgDispatcher), &rcvStats); err != nil { t.Error("Got error on CacheSv1.GetCacheStats: ", err.Error()) } else if !reflect.DeepEqual(expectedStats, rcvStats) { @@ -857,6 +859,8 @@ func testApierSetRatingProfile(t *testing.T) { expectedStats[utils.CacheActionPlans].Items = 1 expectedStats[utils.CacheActions].Items = 1 expectedStats[utils.CacheRatingProfiles].Items = 1 + expectedStats[utils.CacheLoadIDs].Items = 20 + expectedStats[utils.CacheRPCConnections].Items = 1 if err := rater.Call(utils.CacheSv1GetCacheStats, new(utils.AttrCacheIDsWithArgDispatcher), &rcvStats); err != nil { t.Error("Got error on CacheSv1.GetCacheStats: ", err.Error()) } else if !reflect.DeepEqual(expectedStats, rcvStats) { @@ -891,6 +895,8 @@ func testApierSetRatingProfile(t *testing.T) { } expectedStats[utils.CacheRatingPlans].Items = 1 expectedStats[utils.CacheReverseDestinations].Items = 10 + expectedStats[utils.CacheLoadIDs].Items = 20 + expectedStats[utils.CacheRPCConnections].Items = 1 if err := rater.Call(utils.CacheSv1GetCacheStats, new(utils.AttrCacheIDsWithArgDispatcher), &rcvStats); err != nil { t.Error("Got error on CacheSv1.GetCacheStats: ", err.Error()) } else if !reflect.DeepEqual(expectedStats, rcvStats) { @@ -964,6 +970,7 @@ func testApierReloadCache(t *testing.T) { expectedStats[utils.CacheRatingPlans].Items = 1 expectedStats[utils.CacheReverseDestinations].Items = 10 expectedStats[utils.CacheLoadIDs].Items = 20 + expectedStats[utils.CacheRPCConnections].Items = 1 if err := rater.Call(utils.CacheSv1GetCacheStats, new(utils.AttrCacheIDsWithArgDispatcher), &rcvStats); err != nil { t.Error("Got error on CacheSv1.GetCacheStats: ", err.Error()) } else if !reflect.DeepEqual(expectedStats, rcvStats) { diff --git a/engine/loader_it_test.go b/engine/loader_it_test.go index f6c2d0f79..03b20f891 100644 --- a/engine/loader_it_test.go +++ b/engine/loader_it_test.go @@ -27,6 +27,7 @@ import ( "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/utils" + "github.com/cgrates/rpcclient" ) var ( @@ -95,6 +96,11 @@ func testLoaderITInitDataDB(t *testing.T) { if err = dbConn.Flush(utils.EmptyString); err != nil { t.Fatal("Error when flushing datadb") } + cacheChan := make(chan rpcclient.ClientConnector, 1) + cacheChan <- NewCacheS(lCfg, dataDbCsv) + connMgr = NewConnManager(lCfg, map[string]chan rpcclient.ClientConnector{ + utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches): cacheChan, + }) } // Create/reset storage tariff plan tables, used as database connectin establishment also @@ -130,7 +136,7 @@ func testLoaderITRemoveLoad(t *testing.T) { } }*/ loader, err = NewTpReader(dataDbCsv.DataDB(), NewFileCSVStorage(utils.CSV_SEP, - path.Join(*dataDir, "tariffplans", *tpCsvScenario), false), "", "", nil, nil) + path.Join(*dataDir, "tariffplans", *tpCsvScenario), false), "", "", []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches)}, nil) if err != nil { t.Error(err) } @@ -207,7 +213,7 @@ func testLoaderITLoadFromCSV(t *testing.T) { t.Error("Failed validating data: ", err.Error()) } }*/ - loader, err = NewTpReader(dataDbCsv.DataDB(), NewFileCSVStorage(utils.CSV_SEP, path.Join(*dataDir, "tariffplans", *tpCsvScenario), false), "", "", nil, nil) + loader, err = NewTpReader(dataDbCsv.DataDB(), NewFileCSVStorage(utils.CSV_SEP, path.Join(*dataDir, "tariffplans", *tpCsvScenario), false), "", "", []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches)}, nil) if err != nil { t.Error(err) } @@ -510,7 +516,7 @@ func testLoaderITImportToStorDb(t *testing.T) { // Loads data from storDb into dataDb func testLoaderITLoadFromStorDb(t *testing.T) { - loader, _ := NewTpReader(dataDbCsv.DataDB(), storDb, utils.TEST_SQL, "", nil, nil) + loader, _ := NewTpReader(dataDbCsv.DataDB(), storDb, utils.TEST_SQL, "", []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches)}, nil) if err := loader.LoadDestinations(); err != nil && err.Error() != utils.NotFoundCaps { t.Error("Failed loading destinations: ", err.Error()) } @@ -544,7 +550,7 @@ func testLoaderITLoadFromStorDb(t *testing.T) { } func testLoaderITLoadIndividualProfiles(t *testing.T) { - loader, _ := NewTpReader(dataDbCsv.DataDB(), storDb, utils.TEST_SQL, "", nil, nil) + loader, _ := NewTpReader(dataDbCsv.DataDB(), storDb, utils.TEST_SQL, "", []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches)}, nil) // Load ratingPlans. This will also set destination keys if rps, err := storDb.GetTPRatingPlans(utils.TEST_SQL, "", nil); err != nil { t.Fatal("Could not retrieve rating plans")