diff --git a/config/datadbcfg.go b/config/datadbcfg.go index 049c0577e..f4dad7ee4 100644 --- a/config/datadbcfg.go +++ b/config/datadbcfg.go @@ -100,7 +100,6 @@ func (dbcfg *DataDbCfg) loadFromJsonCfg(jsnDbCfg *DbJsonCfg) (err error) { } } if jsnDbCfg.Items != nil { - dbcfg.Items = make(map[string]*ItemOpt) for kJsn, vJsn := range *jsnDbCfg.Items { val, has := dbcfg.Items[kJsn] if val == nil || !has { diff --git a/config/datadbcfg_test.go b/config/datadbcfg_test.go index 3d9c4a638..2c2084c32 100644 --- a/config/datadbcfg_test.go +++ b/config/datadbcfg_test.go @@ -398,6 +398,7 @@ func TestDataDbCfgloadFromJsonCfgItems(t *testing.T) { func TestDataDbCfgAsMapInterface(t *testing.T) { var dbcfg DataDbCfg + dbcfg.Items = make(map[string]*ItemOpt) cfgJSONStr := `{ "data_db": { "db_type": "*redis", diff --git a/engine/datamanager.go b/engine/datamanager.go index e36fc05df..5e3123d19 100644 --- a/engine/datamanager.go +++ b/engine/datamanager.go @@ -197,6 +197,9 @@ func (dm *DataManager) CacheDataFromDB(prfx string, ids []string, mustBeCached b utils.UnsupportedCachePrefix, fmt.Sprintf("prefix <%s> is not a supported cache prefix", prfx)) } + if dm.cacheCfg[utils.CachePrefixToInstance[prfx]].Limit == 0 { + return + } if ids == nil { keyIDs, err := dm.DataDB().GetKeysForPrefix(prfx) if err != nil { diff --git a/engine/loader_it_test.go b/engine/loader_it_test.go index 03b20f891..71be7d643 100644 --- a/engine/loader_it_test.go +++ b/engine/loader_it_test.go @@ -92,7 +92,7 @@ func testLoaderITInitDataDB(t *testing.T) { if err != nil { t.Fatal("Error on dataDb connection: ", err.Error()) } - dataDbCsv = NewDataManager(dbConn, nil, nil) + dataDbCsv = NewDataManager(dbConn, lCfg.CacheCfg(), nil) if err = dbConn.Flush(utils.EmptyString); err != nil { t.Fatal("Error when flushing datadb") } diff --git a/engine/onstor_it_test.go b/engine/onstor_it_test.go index ee6c28f05..33d022612 100644 --- a/engine/onstor_it_test.go +++ b/engine/onstor_it_test.go @@ -143,6 +143,9 @@ func testOnStorITIsDBEmpty(t *testing.T) { } func testOnStorITCacheDestinations(t *testing.T) { + if onStor.dataDB.GetStorageType() == utils.INTERNAL { + t.SkipNow() + } if err := onStor.CacheDataFromDB("INVALID", nil, false); err == nil || err.Error() != utils.UnsupportedCachePrefix { t.Error(err) } @@ -163,6 +166,7 @@ func testOnStorITCacheDestinations(t *testing.T) { if err := onStor.CacheDataFromDB(utils.DESTINATION_PREFIX, []string{dst.Id}, false); err != nil { t.Error(err) } + if itm, hasIt := Cache.Get(utils.CacheDestinations, dst.Id); !hasIt { t.Error("Did not cache") } else if !reflect.DeepEqual(dst, itm.(*Destination)) { @@ -171,6 +175,9 @@ func testOnStorITCacheDestinations(t *testing.T) { } func testOnStorITCacheReverseDestinations(t *testing.T) { + if onStor.dataDB.GetStorageType() == utils.INTERNAL { + t.SkipNow() + } dst := &Destination{Id: "TEST_CACHE", Prefixes: []string{"+491", "+492", "+493"}} if err := onStor.SetReverseDestination(dst, utils.NonTransactional); err != nil { t.Error(err) @@ -193,6 +200,9 @@ func testOnStorITCacheReverseDestinations(t *testing.T) { } func testOnStorITCacheActionPlan(t *testing.T) { + if onStor.dataDB.GetStorageType() == utils.INTERNAL { + t.SkipNow() + } ap := &ActionPlan{ Id: "MORE_MINUTES", AccountIDs: utils.StringMap{"vdf:minitsboy": true}, @@ -256,6 +266,9 @@ func testOnStorITCacheActionPlan(t *testing.T) { } func testOnStorITCacheAccountActionPlans(t *testing.T) { + if onStor.dataDB.GetStorageType() == utils.INTERNAL { + t.SkipNow() + } acntID := utils.ConcatenatedKey("cgrates.org", "1001") aAPs := []string{"PACKAGE_10_SHARED_A_5", "USE_SHARED_A", "apl_PACKAGE_1001"} if err := onStor.SetAccountActionPlans(acntID, aAPs, true); err != nil { diff --git a/engine/resources_test.go b/engine/resources_test.go index a3fc0dd1d..eb0bdbef0 100644 --- a/engine/resources_test.go +++ b/engine/resources_test.go @@ -324,6 +324,9 @@ func TestResourceAllocateResource(t *testing.T) { // TestRSCacheSetGet assurace the presence of private params in cached resource func TestRSCacheSetGet(t *testing.T) { + if *dbType == utils.MetaInternal { + t.SkipNow() + } r := &Resource{ Tenant: "cgrates.org", ID: "RL", @@ -719,6 +722,9 @@ func TestResourceIDs(t *testing.T) { } func TestResourceCaching(t *testing.T) { + if *dbType == utils.MetaInternal { + t.SkipNow() + } //clear the cache Cache.Clear(nil) // start fresh with new dataManager diff --git a/packages/debian/changelog b/packages/debian/changelog index f0d80c651..93f5369d9 100644 --- a/packages/debian/changelog +++ b/packages/debian/changelog @@ -24,6 +24,8 @@ cgrates (0.10.1~dev) UNRELEASED; urgency=medium * [AgentRequest] Improved NavigableMap * [AgentRequest] FieldAsInterface return Data instead of NMItem * [SupplierS] Allow multiple suppliers with the same ID + * [Engine] Skip caching is limit is 0 + * [CacheS] Avoid long recaching -- Alexandru Tripon Wed, 19 Feb 2020 15:22:59 +0200