diff --git a/engine/aliases.go b/engine/aliases.go index 96529aec9..d7ea5205c 100644 --- a/engine/aliases.go +++ b/engine/aliases.go @@ -245,11 +245,6 @@ func (am *AliasHandler) SetAlias(attr *AttrAddAlias, reply *string) (err error) if err = am.accountingDb.CacheDataFromDB(utils.REVERSE_ALIASES_PREFIX, attr.Alias.ReverseAliasIDs(), true); err != nil { return } - //FIXME: optimize by creating better update reverse alias - /*err := am.accountingDb.UpdateReverseAlias(oldAlias, oldAlias) - if err != nil { - return err - }*/ } *reply = utils.OK diff --git a/engine/onstor_it_test.go b/engine/onstor_it_test.go index 81866fb66..0d3c190e1 100644 --- a/engine/onstor_it_test.go +++ b/engine/onstor_it_test.go @@ -1396,16 +1396,16 @@ func testOnStorITCRUDReverseAlias(t *testing.T) { Direction: "*out", Tenant: "itsyscom.com", Category: "call", - Account: "dan", - Subject: "dan", + Account: "testOnStorITCRUDReverseAlias", + Subject: "testOnStorITCRUDReverseAlias", Context: "*rating", Values: AliasValues{ &AliasValue{ DestinationId: "EU", Pairs: AliasPairs{ "Account": map[string]string{ - "dan": "dan1", - "rif": "rif1", + "dan": "testOnStorITCRUDReverseAlias1", + "rif": "testOnStorITCRUDReverseAlias2", }, "Calling": map[string]string{ "11234": "2234", @@ -1416,47 +1416,16 @@ func testOnStorITCRUDReverseAlias(t *testing.T) { &AliasValue{ DestinationId: "US", - Pairs: AliasPairs{"Account": map[string]string{"dan": "dan2"}}, - Weight: 20, - }, - }, - } - als2 := &Alias{ - Direction: "*out", - Tenant: "cgrates.org", - Category: "call", - Account: "dan", - Subject: "dan", - Context: "*rating", - Values: AliasValues{ - &AliasValue{ - DestinationId: "EU_LANDLINE", - Pairs: AliasPairs{ - "Subject": map[string]string{ - "dan": "dan1", - "rif": "rif1", - }, - "Cli": map[string]string{ - "0723": "0724", - }, - }, - Weight: 10, - }, - - &AliasValue{ - DestinationId: "GLOBAL1", - Pairs: AliasPairs{"Subject": map[string]string{"dan": "dan2"}}, + Pairs: AliasPairs{"Account": map[string]string{"dan": "testOnStorITCRUDReverseAlias3"}}, Weight: 20, }, }, } rvAlsID := strings.Join([]string{als.Values[1].Pairs["Account"]["dan"], "Account", als.Context}, "") exp := strings.Join([]string{als.Direction, ":", als.Tenant, ":", als.Category, ":", als.Account, ":", als.Subject, ":", als.Context, ":", als.Values[1].DestinationId}, "") - // rvAlsID2 := strings.Join([]string{als2.Values[1].Pairs["Account"]["dan"], "Account", als2.Context}, "") - // exp2 := strings.Join([]string{als2.Direction, ":", als2.Tenant, ":", als2.Category, ":", als2.Account, ":", als2.Subject, ":", als2.Context, ":", als2.Values[1].DestinationId}, "") - //FixMe if _, rcvErr := onStor.GetReverseAlias(rvAlsID, true, utils.NonTransactional); rcvErr != utils.ErrNotFound { - // t.Error(rcvErr) // - // } + if _, rcvErr := onStor.GetReverseAlias(rvAlsID, true, utils.NonTransactional); rcvErr != utils.ErrNotFound { + t.Error(rcvErr) + } if err := onStor.SetReverseAlias(als, utils.NonTransactional); err != nil { t.Error(err) } @@ -1465,14 +1434,6 @@ func testOnStorITCRUDReverseAlias(t *testing.T) { } else if !reflect.DeepEqual(exp, rcv[0]) { t.Errorf("Expecting: %v, received: %v", exp, rcv[0]) } - if err := onStor.UpdateReverseAlias(als, als2, utils.NonTransactional); err != nil { - t.Error(err) - } - //FixMe if rcv, err := onStor.GetReverseAlias(rvAlsID2, true, utils.NonTransactional); err != nil { - // t.Error(err) //NOT_FOUND - // } else if !reflect.DeepEqual(exp2, rcv) { - // t.Errorf("Expecting: %v, received: %v", exp2, rcv) - // } } func testOnStorITCRUDResourceLimit(t *testing.T) { diff --git a/engine/storage_interface.go b/engine/storage_interface.go index 0a290e49e..482b76072 100644 --- a/engine/storage_interface.go +++ b/engine/storage_interface.go @@ -101,7 +101,6 @@ type AccountingStorage interface { RemoveAlias(string, string) error SetReverseAlias(*Alias, string) error GetReverseAlias(string, bool, string) ([]string, error) - UpdateReverseAlias(*Alias, *Alias, string) error GetResourceLimit(string, bool, string) (*ResourceLimit, error) SetResourceLimit(*ResourceLimit, string) error RemoveResourceLimit(string, string) error @@ -173,7 +172,6 @@ type DataDB interface { RemoveAlias(string, string) error SetReverseAlias(*Alias, string) error GetReverseAlias(string, bool, string) ([]string, error) - UpdateReverseAlias(*Alias, *Alias, string) error GetResourceLimit(string, bool, string) (*ResourceLimit, error) SetResourceLimit(*ResourceLimit, string) error RemoveResourceLimit(string, string) error diff --git a/engine/storage_map.go b/engine/storage_map.go index daa2d0887..5138f2cfe 100644 --- a/engine/storage_map.go +++ b/engine/storage_map.go @@ -894,10 +894,6 @@ func (ms *MapStorage) RemoveAlias(key string, transactionID string) error { return nil } -func (ms *MapStorage) UpdateReverseAlias(oldAl, newAl *Alias, transactionID string) error { - return nil -} - func (ms *MapStorage) GetLoadHistory(limitItems int, skipCache bool, transactionID string) ([]*utils.LoadInstance, error) { ms.mu.RLock() defer ms.mu.RUnlock() diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go index 2c271a3e8..e65f58799 100644 --- a/engine/storage_mongo_datadb.go +++ b/engine/storage_mongo_datadb.go @@ -1364,10 +1364,6 @@ func (ms *MongoStorage) RemoveAlias(key, transactionID string) (err error) { return } -func (ms *MongoStorage) UpdateReverseAlias(oldAl, newAl *Alias, transactionID string) error { - return nil -} - // Limit will only retrieve the last n items out of history, newest first func (ms *MongoStorage) GetLoadHistory(limit int, skipCache bool, transactionID string) (loadInsts []*utils.LoadInstance, err error) { if limit == 0 { diff --git a/engine/storage_redis.go b/engine/storage_redis.go index 6ef04ada1..9ee96ec88 100644 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -926,13 +926,8 @@ func (rs *RedisStorage) GetReverseAlias(reverseID string, skipCache bool, transa } } if ids, err = rs.Cmd("SMEMBERS", key).List(); err != nil { - if err.Error() == "wrong type" { // did not find the destination - cache.Set(key, nil, cacheCommit(transactionID), transactionID) - err = utils.ErrNotFound - } return - } - if len(ids) == 0 { + } else if len(ids) == 0 { cache.Set(key, nil, cacheCommit(transactionID), transactionID) err = utils.ErrNotFound return @@ -990,13 +985,6 @@ func (rs *RedisStorage) RemoveAlias(id string, transactionID string) (err error) return } -func (rs *RedisStorage) UpdateReverseAlias(oldAl, newAl *Alias, transactionID string) error { - // FIXME: thi can be optimized - cache.RemPrefixKey(utils.REVERSE_ALIASES_PREFIX, cacheCommit(transactionID), transactionID) - rs.SetReverseAlias(newAl, transactionID) - return nil -} - // Limit will only retrieve the last n items out of history, newest first func (rs *RedisStorage) GetLoadHistory(limit int, skipCache bool, transactionID string) ([]*utils.LoadInstance, error) { if limit == 0 {