From 8a42c224dde0d9c41bc6bd6d6745115d82f879bf Mon Sep 17 00:00:00 2001 From: TeoV Date: Tue, 19 Dec 2017 17:35:36 +0200 Subject: [PATCH] Update methods for FilterIndexer --- engine/attributes_test.go | 104 ++++++++++++++++----------------- engine/datamanager.go | 14 ++--- engine/filterindexer.go | 8 +-- engine/onstor_it_test.go | 6 +- engine/storage_interface.go | 4 +- engine/storage_map.go | 6 +- engine/storage_mongo_datadb.go | 54 +++++++---------- engine/storage_redis.go | 4 +- engine/suppliers_test.go | 2 +- engine/tp_reader.go | 10 ++-- migrator/migrator_it_test.go | 13 +++-- 11 files changed, 104 insertions(+), 121 deletions(-) diff --git a/engine/attributes_test.go b/engine/attributes_test.go index e467e711c..4e20693bd 100644 --- a/engine/attributes_test.go +++ b/engine/attributes_test.go @@ -1,4 +1,3 @@ - /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments Copyright (C) ITsysCOM GmbH @@ -23,14 +22,14 @@ import ( "testing" "time" - "github.com/cgrates/cgrates/utils" "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/utils" ) var ( - atrPs AttributeProfiles - srv AttributeService - dmAtr *DataManager + atrPs AttributeProfiles + srv AttributeService + dmAtr *DataManager ) var sTestsAttributes = []func(t *testing.T){ @@ -38,13 +37,14 @@ var sTestsAttributes = []func(t *testing.T){ testAttributeMatchingAttributeProfilesForEvent, testAttributeProfileForEvent, testAttributeProcessEvent, - } +} func TestAttributes(t *testing.T) { for _, stest := range sTestsAttributes { t.Run("Test Suppliers", stest) } } + //.matchingAttributeProfilesForEvent //.attributeProfileForEvent //.processEvent @@ -55,7 +55,7 @@ func testPopulateAttrService(t *testing.T) { second := 1 * time.Second data, _ := NewMapStorage() dmAtr = NewDataManager(data) - context :=utils.MetaRating + context := utils.MetaRating attrMap := make(map[string]map[string]*Attribute) attrMap["FL1"] = make(map[string]*Attribute) attrMap["FL1"]["In1"] = &Attribute{ @@ -65,33 +65,33 @@ func testPopulateAttrService(t *testing.T) { Append: true, } - atrPs= AttributeProfiles{ - &AttributeProfile{ - Tenant: "cgrates.org", - ID: "attributeprofile1", - Context: context, - FilterIDs: []string{"filter1"}, - ActivationInterval: &utils.ActivationInterval{ + atrPs = AttributeProfiles{ + &AttributeProfile{ + Tenant: "cgrates.org", + ID: "attributeprofile1", + Context: context, + FilterIDs: []string{"filter1"}, + ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC).Local(), ExpiryTime: time.Now().Add(time.Duration(20 * time.Minute)).Local(), }, - Attributes: attrMap, - Weight: 20, + Attributes: attrMap, + Weight: 20, }, - &AttributeProfile{ - Tenant: "cgrates.org", - ID: "attributeprofile2", - Context: context, - FilterIDs: []string{"filter2"}, - ActivationInterval: &utils.ActivationInterval{ + &AttributeProfile{ + Tenant: "cgrates.org", + ID: "attributeprofile2", + Context: context, + FilterIDs: []string{"filter2"}, + ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC).Local(), ExpiryTime: time.Now().Add(time.Duration(20 * time.Minute)).Local(), }, - Attributes: attrMap, - Weight: 20, + Attributes: attrMap, + Weight: 20, }, } - + x, err := NewRequestFilter(MetaString, "attributeprofile1", []string{"Attribute"}) if err != nil { t.Errorf("Error: %+v", err) @@ -117,8 +117,8 @@ func testPopulateAttrService(t *testing.T) { filter2 := &Filter{Tenant: config.CgrConfig().DefaultTenant, ID: "filter2", RequestFilters: filters2} dmAtr.SetFilter(filter1) dmAtr.SetFilter(filter2) - srv= AttributeService{ - dm:dmAtr, + srv = AttributeService{ + dm: dmAtr, filterS: &FilterS{dm: dmAtr}, indexedFields: []string{"attributeprofile1", "attributeprofile2"}, } @@ -130,83 +130,83 @@ func testPopulateAttrService(t *testing.T) { ev["PddInterval"] = "1s" ev["Weight"] = "20.0" sev = &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "attribute_event", - Context:&context, - Event: ev, + Tenant: "cgrates.org", + ID: "attribute_event", + Context: &context, + Event: ev, } for _, atr := range atrPs { - dmAtr.SetAttributeProfile(atr) + dmAtr.SetAttributeProfile(atr) } prefix := utils.ConcatenatedKey(sev.Tenant, *sev.Context) - ref := NewReqFilterIndexer(dmAtr, utils.AttributeProfilePrefix,prefix) + ref := NewReqFilterIndexer(dmAtr, utils.AttributeProfilePrefix, prefix) ref.IndexFilters("attributeprofile1", filter1) ref.IndexFilters("attributeprofile2", filter2) - err = ref.StoreIndexes(true) + err = ref.StoreIndexes() if err != nil { t.Errorf("Error: %+v", err) } } func testAttributeMatchingAttributeProfilesForEvent(t *testing.T) { - atrpl,err:=srv.matchingAttributeProfilesForEvent(sev) + atrpl, err := srv.matchingAttributeProfilesForEvent(sev) if err != nil { t.Errorf("Error: %+v", err) } - if !reflect.DeepEqual(atrPs[0], atrpl[0])&&!reflect.DeepEqual(atrPs[0], atrpl[1]) { + if !reflect.DeepEqual(atrPs[0], atrpl[0]) && !reflect.DeepEqual(atrPs[0], atrpl[1]) { t.Errorf("Expecting: %+v, received: %+v", atrPs[0], atrpl[0]) - } else if !reflect.DeepEqual(atrPs[1], atrpl[1])&&!reflect.DeepEqual(atrPs[1], atrpl[0]) { + } else if !reflect.DeepEqual(atrPs[1], atrpl[1]) && !reflect.DeepEqual(atrPs[1], atrpl[0]) { t.Errorf("Expecting: %+v, received: %+v", atrPs[1], atrpl[1]) } } func testAttributeProfileForEvent(t *testing.T) { - context:=utils.MetaRating + context := utils.MetaRating ev := make(map[string]interface{}) ev["attributeprofile1"] = "Attribute" ev["UsageInterval"] = "1s" ev["Weight"] = "9.0" sev = &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "attribute_event", + Tenant: "cgrates.org", + ID: "attribute_event", Context: &context, - Event: ev, + Event: ev, } - atrpl,err:=srv.attributeProfileForEvent(sev) + atrpl, err := srv.attributeProfileForEvent(sev) if err != nil { t.Errorf("Error: %+v", err) } - if !reflect.DeepEqual(atrPs[0], atrpl)&&!reflect.DeepEqual(atrPs[1], atrpl) { + if !reflect.DeepEqual(atrPs[0], atrpl) && !reflect.DeepEqual(atrPs[1], atrpl) { t.Errorf("Expecting: %+v, received: %+v", atrPs[0], atrpl) } } func testAttributeProcessEvent(t *testing.T) { -context:=utils.MetaRating + context := utils.MetaRating ev := make(map[string]interface{}) ev["attributeprofile1"] = "Attribute" ev["UsageInterval"] = "1s" ev["Weight"] = "9.0" sev = &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "attribute_event", + Tenant: "cgrates.org", + ID: "attribute_event", Context: &context, - Event: ev, + Event: ev, } eRply := &AttrSProcessEventReply{ MatchedProfile: "attributeprofile1", - CGREvent: sev, + CGREvent: sev, } - atrpl,err:=srv.processEvent(sev) + atrpl, err := srv.processEvent(sev) if err != nil { t.Errorf("Error: %+v", err) } if !reflect.DeepEqual(eRply.MatchedProfile, atrpl.MatchedProfile) { t.Errorf("Expecting: %+v, received: %+v", eRply.MatchedProfile, atrpl.MatchedProfile) - }else if !reflect.DeepEqual(eRply.AlteredFields, atrpl.AlteredFields) { + } else if !reflect.DeepEqual(eRply.AlteredFields, atrpl.AlteredFields) { t.Errorf("Expecting: %+v, received: %+v", eRply.AlteredFields, atrpl.AlteredFields) - }else if !reflect.DeepEqual(eRply.CGREvent, atrpl.CGREvent) { + } else if !reflect.DeepEqual(eRply.CGREvent, atrpl.CGREvent) { t.Errorf("Expecting: %+v, received: %+v", eRply.CGREvent, atrpl.CGREvent) } -} \ No newline at end of file +} diff --git a/engine/datamanager.go b/engine/datamanager.go index 22a2f7f1b..54b53c278 100644 --- a/engine/datamanager.go +++ b/engine/datamanager.go @@ -403,7 +403,7 @@ func (dm *DataManager) SetThresholdProfile(th *ThresholdProfile, withIndex bool) GetDBIndexKey(thdsIndexers.itemType, thdsIndexers.dbKeySuffix, true), fldNameVal); rcvErr != nil { if rcvErr.Error() == utils.ErrNotFound.Error() { - if err = thdsIndexers.StoreIndexes(false); err != nil { + if err = thdsIndexers.StoreIndexes(); err != nil { return } } else { @@ -414,12 +414,12 @@ func (dm *DataManager) SetThresholdProfile(th *ThresholdProfile, withIndex bool) th.Tenant).RemoveItemFromIndex(th.ID); err != nil { return } - if err = thdsIndexers.StoreIndexes(false); err != nil { + if err = thdsIndexers.StoreIndexes(); err != nil { return } } } - if err = thdsIndexers.StoreIndexes(false); err != nil { + if err = thdsIndexers.StoreIndexes(); err != nil { return } } @@ -891,8 +891,8 @@ func (dm *DataManager) GetFilterIndexes(dbKey string, fldNameVal map[string]stri return dm.DataDB().GetFilterIndexesDrv(dbKey, fldNameVal) } -func (dm *DataManager) SetFilterIndexes(dbKey string, indexes map[string]map[string]utils.StringMap, update bool) (err error) { - return dm.DataDB().SetFilterIndexesDrv(dbKey, indexes, update) +func (dm *DataManager) SetFilterIndexes(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) { + return dm.DataDB().SetFilterIndexesDrv(dbKey, indexes) } func (dm *DataManager) RemoveFilterIndexes(dbKey string) (err error) { @@ -903,8 +903,8 @@ func (dm *DataManager) GetFilterReverseIndexes(dbKey string, fldNameVal map[stri return dm.DataDB().GetFilterReverseIndexesDrv(dbKey, fldNameVal) } -func (dm *DataManager) SetFilterReverseIndexes(dbKey string, indexes map[string]map[string]utils.StringMap, update bool) (err error) { - return dm.DataDB().SetFilterReverseIndexesDrv(dbKey, indexes, update) +func (dm *DataManager) SetFilterReverseIndexes(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) { + return dm.DataDB().SetFilterReverseIndexesDrv(dbKey, indexes) } func (dm *DataManager) RemoveFilterReverseIndexes(dbKey, itemID string) (err error) { diff --git a/engine/filterindexer.go b/engine/filterindexer.go index f74a9cfcd..b151258ff 100644 --- a/engine/filterindexer.go +++ b/engine/filterindexer.go @@ -138,15 +138,15 @@ func (rfi *ReqFilterIndexer) IndexTPFilter(tpFltr *utils.TPFilterProfile, itemID } // StoreIndexes handles storing the indexes to dataDB -func (rfi *ReqFilterIndexer) StoreIndexes(update bool) (err error) { +func (rfi *ReqFilterIndexer) StoreIndexes() (err error) { if err = rfi.dm.SetFilterIndexes( GetDBIndexKey(rfi.itemType, rfi.dbKeySuffix, false), - rfi.indexes, update); err != nil { + rfi.indexes); err != nil { return } return rfi.dm.SetFilterReverseIndexes( GetDBIndexKey(rfi.itemType, rfi.dbKeySuffix, true), - rfi.reveseIndex, update) + rfi.reveseIndex) } //Populate the ReqFilterIndexer.reveseIndex for specifil itemID @@ -207,7 +207,7 @@ func (rfi *ReqFilterIndexer) RemoveItemFromIndex(itemID string) (err error) { } } } - if err = rfi.StoreIndexes(true); err != nil { + if err = rfi.StoreIndexes(); err != nil { return } if err = rfi.dm.RemoveFilterReverseIndexes( diff --git a/engine/onstor_it_test.go b/engine/onstor_it_test.go index 8d92459f5..ac1e418ea 100644 --- a/engine/onstor_it_test.go +++ b/engine/onstor_it_test.go @@ -229,8 +229,7 @@ func testOnStorITSetFilterIndexes(t *testing.T) { }, } if err := onStor.SetFilterIndexes( - GetDBIndexKey(utils.ResourceProfilesPrefix, "cgrates.org", false), - idxes, false); err != nil { + GetDBIndexKey(utils.ResourceProfilesPrefix, "cgrates.org", false), idxes); err != nil { t.Error(err) } } @@ -304,8 +303,7 @@ func testOnStorITGetFilterIndexes(t *testing.T) { // t.Errorf("Expecting: %+v, received: %+v", eIdxes, idxes) } if err := onStor.SetFilterIndexes( - GetDBIndexKey(utils.ResourceProfilesPrefix, "cgrates.org", false), - eIdxes, false); err != nil { + GetDBIndexKey(utils.ResourceProfilesPrefix, "cgrates.org", false), eIdxes); err != nil { t.Error(err) } } diff --git a/engine/storage_interface.go b/engine/storage_interface.go index a023f00c4..31e38287e 100755 --- a/engine/storage_interface.go +++ b/engine/storage_interface.go @@ -118,10 +118,10 @@ type DataDB interface { GetLoadHistory(int, bool, string) ([]*utils.LoadInstance, error) AddLoadHistory(*utils.LoadInstance, int, string) error GetFilterIndexesDrv(dbKey string, fldNameVal map[string]string) (indexes map[string]map[string]utils.StringMap, err error) - SetFilterIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap, update bool) (err error) + SetFilterIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) RemoveFilterIndexesDrv(id string) (err error) GetFilterReverseIndexesDrv(dbKey string, fldNameVal map[string]string) (indexes map[string]map[string]utils.StringMap, err error) - SetFilterReverseIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap, update bool) (err error) + SetFilterReverseIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) RemoveFilterReverseIndexesDrv(dbKey, itemID string) (err error) MatchFilterIndexDrv(dbKey, fieldName, fieldVal string) (itemIDs utils.StringMap, err error) GetStatQueueProfileDrv(tenant string, ID string) (sq *StatQueueProfile, err error) diff --git a/engine/storage_map.go b/engine/storage_map.go index fcdfe2e15..625a7705a 100755 --- a/engine/storage_map.go +++ b/engine/storage_map.go @@ -22,7 +22,6 @@ import ( "bytes" "compress/zlib" "errors" - "fmt" "io/ioutil" "strings" "sync" @@ -1289,7 +1288,7 @@ func (ms *MapStorage) GetFilterIndexesDrv(dbKey string, return } -func (ms *MapStorage) SetFilterIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap, update bool) (err error) { +func (ms *MapStorage) SetFilterIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) { ms.mu.Lock() defer ms.mu.Unlock() result, err := ms.ms.Marshal(indexes) @@ -1341,7 +1340,7 @@ func (ms *MapStorage) GetFilterReverseIndexesDrv(dbKey string, return } -func (ms *MapStorage) SetFilterReverseIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap, update bool) (err error) { +func (ms *MapStorage) SetFilterReverseIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) { ms.mu.Lock() defer ms.mu.Unlock() result, err := ms.ms.Marshal(indexes) @@ -1546,7 +1545,6 @@ func (ms *MapStorage) SetFilterDrv(r *Filter) (err error) { if err != nil { return err } - fmt.Printf("Setsfilter with Tenant:%+v ID:%+v \n", r.Tenant, r.ID) ms.dict[utils.FilterPrefix+utils.ConcatenatedKey(r.Tenant, r.ID)] = result return } diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go index d5232e500..ce93114b8 100755 --- a/engine/storage_mongo_datadb.go +++ b/engine/storage_mongo_datadb.go @@ -1963,28 +1963,21 @@ func (ms *MongoStorage) GetFilterIndexesDrv(dbKey string, return result.Value, nil } -func (ms *MongoStorage) SetFilterIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap, update bool) (err error) { +func (ms *MongoStorage) SetFilterIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) { session, col := ms.conn(colRFI) defer session.Close() - if update { - for k, v := range indexes { - for k2, v2 := range v { - findParam2 := fmt.Sprintf("value.%s.%s", k, k2) - if len(v2) != 0 { - for k3 := range v2 { - err = col.Update(bson.M{"key": dbKey}, bson.M{"$set": bson.M{findParam2: bson.M{k3: true}}}) - } - } else { - err = col.Update(bson.M{"key": dbKey}, bson.M{"$unset": bson.M{findParam2: 1}}) - } + for k, v := range indexes { + for k2, v2 := range v { + findParam2 := fmt.Sprintf("value.%s.%s", k, k2) + if len(v2) == 0 { + err = col.Update(bson.M{"key": dbKey}, bson.M{"$unset": bson.M{findParam2: 1}}) } } - } else { - _, err = col.Upsert(bson.M{"key": dbKey}, &struct { - Key string - Value map[string]map[string]utils.StringMap - }{dbKey, indexes}) } + _, err = col.Upsert(bson.M{"key": dbKey}, &struct { + Key string + Value map[string]map[string]utils.StringMap + }{dbKey, indexes}) return } @@ -2031,28 +2024,21 @@ func (ms *MongoStorage) GetFilterReverseIndexesDrv(dbKey string, return result.Value, nil } -func (ms *MongoStorage) SetFilterReverseIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap, update bool) (err error) { +func (ms *MongoStorage) SetFilterReverseIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) { session, col := ms.conn(colRFI) defer session.Close() - if update { - for k, v := range indexes { - for k2, v2 := range v { - findParam2 := fmt.Sprintf("value.%s.%s", k, k2) - if len(v2) != 0 { - for k3 := range v2 { - err = col.Update(bson.M{"key": dbKey}, bson.M{"$set": bson.M{findParam2: bson.M{k3: true}}}) - } - } else { - err = col.Update(bson.M{"key": dbKey}, bson.M{"$unset": bson.M{findParam2: 1}}) - } + for k, v := range indexes { + for k2, v2 := range v { + findParam2 := fmt.Sprintf("value.%s.%s", k, k2) + if len(v2) == 0 { + err = col.Update(bson.M{"key": dbKey}, bson.M{"$unset": bson.M{findParam2: 1}}) } } - } else { - _, err = col.Upsert(bson.M{"key": dbKey}, &struct { - Key string - Value map[string]map[string]utils.StringMap - }{dbKey, indexes}) } + _, err = col.Upsert(bson.M{"key": dbKey}, &struct { + Key string + Value map[string]map[string]utils.StringMap + }{dbKey, indexes}) return } diff --git a/engine/storage_redis.go b/engine/storage_redis.go index 20cdfec06..9a477cd59 100755 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -1412,7 +1412,7 @@ func (rs *RedisStorage) GetFilterIndexesDrv(dbKey string, return } -func (rs *RedisStorage) SetFilterIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap, update bool) (err error) { +func (rs *RedisStorage) SetFilterIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) { mp := make(map[string]string) for fldName, fldValMp := range indexes { for fldVal, strMp := range fldValMp { @@ -1484,7 +1484,7 @@ func (rs *RedisStorage) GetFilterReverseIndexesDrv(dbKey string, return } -func (rs *RedisStorage) SetFilterReverseIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap, update bool) (err error) { +func (rs *RedisStorage) SetFilterReverseIndexesDrv(dbKey string, indexes map[string]map[string]utils.StringMap) (err error) { mp := make(map[string]string) for fldName, fldValMp := range indexes { for _, strMp := range fldValMp { diff --git a/engine/suppliers_test.go b/engine/suppliers_test.go index a3aaaf9b1..3c6991200 100644 --- a/engine/suppliers_test.go +++ b/engine/suppliers_test.go @@ -275,7 +275,7 @@ func TestSuppliersPopulateSupplierService(t *testing.T) { ref := NewReqFilterIndexer(dmspl, utils.SupplierProfilePrefix, "cgrates.org") ref.IndexFilters("supplierprofile1", filter3) ref.IndexFilters("supplierprofile2", filter4) - err = ref.StoreIndexes(false) + err = ref.StoreIndexes() if err != nil { t.Errorf("Error: %+v", err) } diff --git a/engine/tp_reader.go b/engine/tp_reader.go index d1236a141..128946858 100755 --- a/engine/tp_reader.go +++ b/engine/tp_reader.go @@ -2335,7 +2335,7 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("Indexing resource profiles") } for tenant, fltrIdxer := range tpr.resIndexers { - if err := fltrIdxer.StoreIndexes(false); err != nil { + if err := fltrIdxer.StoreIndexes(); err != nil { return err } if verbose { @@ -2350,7 +2350,7 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("StatQueue filter indexes:") } for tenant, fltrIdxer := range tpr.sqpIndexers { - if err := fltrIdxer.StoreIndexes(false); err != nil { + if err := fltrIdxer.StoreIndexes(); err != nil { return err } if verbose { @@ -2365,7 +2365,7 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("Threshold filter indexes:") } for tenant, fltrIdxer := range tpr.thdsIndexers { - if err := fltrIdxer.StoreIndexes(false); err != nil { + if err := fltrIdxer.StoreIndexes(); err != nil { return err } if verbose { @@ -2380,7 +2380,7 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("Indexing Supplier Profiles") } for tenant, fltrIdxer := range tpr.sppIndexers { - if err := fltrIdxer.StoreIndexes(false); err != nil { + if err := fltrIdxer.StoreIndexes(); err != nil { return err } if verbose { @@ -2395,7 +2395,7 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err log.Print("Indexing Attribute Profiles") } for tntCntx, fltrIdxer := range tpr.attrIndexers { - if err := fltrIdxer.StoreIndexes(false); err != nil { + if err := fltrIdxer.StoreIndexes(); err != nil { return err } if verbose { diff --git a/migrator/migrator_it_test.go b/migrator/migrator_it_test.go index ed53dde25..bbe006db8 100644 --- a/migrator/migrator_it_test.go +++ b/migrator/migrator_it_test.go @@ -1147,6 +1147,7 @@ func testMigratorThreshold(t *testing.T) { thp := &engine.ThresholdProfile{ ID: threshold.ID, Tenant: config.CgrConfig().DefaultTenant, + FilterIDs: []string{filter.ID}, Blocker: false, Weight: threshold.Weight, ActivationInterval: &utils.ActivationInterval{threshold.ExpirationDate, threshold.ActivationDate}, @@ -1162,7 +1163,7 @@ func testMigratorThreshold(t *testing.T) { if err := mig.dmIN.SetFilter(filter); err != nil { t.Error("Error when setting Filter ", err.Error()) } - if err := mig.dmIN.SetThresholdProfile(thp); err != nil { + if err := mig.dmIN.SetThresholdProfile(thp, true); err != nil { t.Error("Error when setting threshold ", err.Error()) } if err := mig.dmIN.SetThreshold(th); err != nil { @@ -1200,7 +1201,7 @@ func testMigratorThreshold(t *testing.T) { if err := mig.dmIN.SetFilter(filter); err != nil { t.Error("Error when setting Filter ", err.Error()) } - if err := mig.dmIN.SetThresholdProfile(thp); err != nil { + if err := mig.dmIN.SetThresholdProfile(thp, true); err != nil { t.Error("Error when setting Threshold ", err.Error()) } if err := mig.dmIN.SetThreshold(th); err != nil { @@ -1238,7 +1239,7 @@ func testMigratorThreshold(t *testing.T) { if err := mig.dmIN.SetFilter(filter); err != nil { t.Error("Error when setting Filter ", err.Error()) } - if err := mig.dmIN.SetThresholdProfile(thp); err != nil { + if err := mig.dmIN.SetThresholdProfile(thp, true); err != nil { t.Error("Error when setting Threshold ", err.Error()) } if err := mig.dmIN.SetThreshold(th); err != nil { @@ -2619,11 +2620,11 @@ func testMigratorTpFilter(t *testing.T) { } if !reflect.DeepEqual(tpFilter[0].TPid, result[0].TPid) { t.Errorf("Expecting: %+v, received: %+v", tpFilter[0].TPid, result[0].TPid) - }else if !reflect.DeepEqual(tpFilter[0].ID, result[0].ID) { + } else if !reflect.DeepEqual(tpFilter[0].ID, result[0].ID) { t.Errorf("Expecting: %+v, received: %+v", tpFilter[0].ID, result[0].ID) - }else if !reflect.DeepEqual(tpFilter[0].Filters, result[0].Filters) { + } else if !reflect.DeepEqual(tpFilter[0].Filters, result[0].Filters) { t.Errorf("Expecting: %+v, received: %+v", tpFilter[0].Filters, result[0].Filters) - }else if !reflect.DeepEqual(tpFilter[0].ActivationInterval, result[0].ActivationInterval) { + } else if !reflect.DeepEqual(tpFilter[0].ActivationInterval, result[0].ActivationInterval) { t.Errorf("Expecting: %+v, received: %+v", tpFilter[0].ActivationInterval, result[0].ActivationInterval) } }