mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Remove Storage.UpdateReverseAlias, various onstor integration tests fixes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) //<nil>
|
||||
// }
|
||||
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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user