mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 13:19:53 +05:00
Updated cache reload
This commit is contained in:
committed by
Dan Christian Bogos
parent
b5db408648
commit
4cb76bb3d9
@@ -22,17 +22,22 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/cgrates/birpc"
|
||||
"github.com/cgrates/birpc/context"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"os/exec"
|
||||
"path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/birpc"
|
||||
"github.com/cgrates/birpc/context"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -143,7 +148,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
|
||||
if err := cgrLdrBIRPC.Call(context.Background(), utils.AdminSv1GetAttributeProfile,
|
||||
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_ACNT_1001"}},
|
||||
&replyAttr); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Expected %+q, received %+q", utils.ErrNotFound.Error(), err.Error())
|
||||
t.Errorf("Expected %+q, received %v", utils.ErrNotFound.Error(), err)
|
||||
}
|
||||
|
||||
//filtersPrf
|
||||
@@ -151,7 +156,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
|
||||
if err := cgrLdrBIRPC.Call(context.Background(), utils.AdminSv1GetFilter,
|
||||
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_1"}},
|
||||
&replyFltr); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Expected %+q, received %+q", utils.ErrNotFound.Error(), err.Error())
|
||||
t.Errorf("Expected %+q, received %v", utils.ErrNotFound.Error(), err)
|
||||
}
|
||||
|
||||
//ratesPrf
|
||||
@@ -167,13 +172,13 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
|
||||
if err := cgrLdrBIRPC.Call(context.Background(), utils.AdminSv1GetResourceProfile,
|
||||
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "RES_ACNT_1001"}},
|
||||
&replyResPrf); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Expected %+q, received %+q", utils.ErrNotFound.Error(), err.Error())
|
||||
t.Errorf("Expected %+q, received %v", utils.ErrNotFound.Error(), err)
|
||||
}
|
||||
var replyRes *engine.Resource
|
||||
if err := cgrLdrBIRPC.Call(context.Background(), utils.ResourceSv1GetResource,
|
||||
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "RES_ACNT_1001"}},
|
||||
&replyRes); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Expected %+q, received %+q", utils.ErrNotFound.Error(), err.Error())
|
||||
t.Errorf("Expected %+q, received %v", utils.ErrNotFound.Error(), err)
|
||||
}
|
||||
|
||||
// routesPrf
|
||||
@@ -181,7 +186,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
|
||||
if err := cgrLdrBIRPC.Call(context.Background(), utils.AdminSv1GetRouteProfile,
|
||||
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ROUTE_ACNT_1001"}},
|
||||
&replyRts); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Expected %+q, received %+q", utils.ErrNotFound.Error(), err.Error())
|
||||
t.Errorf("Expected %+q, received %v", utils.ErrNotFound.Error(), err)
|
||||
}
|
||||
|
||||
// statsPrf
|
||||
@@ -189,7 +194,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
|
||||
if err := cgrLdrBIRPC.Call(context.Background(), utils.AdminSv1GetStatQueueProfile,
|
||||
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "Stat_1"}},
|
||||
&replySts); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Expected %+q, received %+q", utils.ErrNotFound.Error(), err.Error())
|
||||
t.Errorf("Expected %+q, received %v", utils.ErrNotFound.Error(), err)
|
||||
}
|
||||
|
||||
// statQueue
|
||||
@@ -197,7 +202,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
|
||||
if err := cgrLdrBIRPC.Call(context.Background(), utils.StatSv1GetStatQueue,
|
||||
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "Stat_1"}},
|
||||
&replyStQue); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Expected %+q, received %+q", utils.ErrNotFound.Error(), err.Error())
|
||||
t.Errorf("Expected %+q, received %v", utils.ErrNotFound.Error(), err)
|
||||
}
|
||||
|
||||
// thresholdPrf
|
||||
@@ -205,7 +210,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
|
||||
if err := cgrLdrBIRPC.Call(context.Background(), utils.AdminSv1GetThresholdProfile,
|
||||
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "THD_ACNT_1"}},
|
||||
&replyThdPrf); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Expected %+q, received %+q", utils.ErrNotFound.Error(), err.Error())
|
||||
t.Errorf("Expected %+q, received %v", utils.ErrNotFound.Error(), err)
|
||||
}
|
||||
|
||||
// threshold
|
||||
@@ -213,8 +218,17 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
|
||||
if err := cgrLdrBIRPC.Call(context.Background(), utils.ThresholdSv1GetThreshold,
|
||||
&utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "THD_ACNT_1"}},
|
||||
&rplyThd); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Expected %+q, received %+q", utils.ErrNotFound.Error(), err.Error())
|
||||
t.Errorf("Expected %+q, received %v", utils.ErrNotFound.Error(), err)
|
||||
}
|
||||
|
||||
//chargers
|
||||
var replyChrgr *engine.ChargerProfile
|
||||
if err := cgrLdrBIRPC.Call(context.Background(), utils.APIerSv1GetChargerProfile,
|
||||
&utils.TenantID{Tenant: "cgrates.org", ID: "Raw"},
|
||||
&replyChrgr); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Expected %+v, received %v", utils.ErrNotFound.Error(), err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func testCgrLdrLoadData(t *testing.T) {
|
||||
|
||||
@@ -282,10 +282,11 @@ func (dm *DataManager) CacheDataFromDB(ctx *context.Context, prfx string, ids []
|
||||
err.Error(),
|
||||
fmt.Sprintf("error <%s> querying DataManager for category: <%s>, dataID: <%s>", err.Error(), prfx, dataID))
|
||||
}
|
||||
if err = Cache.Remove(ctx, utils.CachePrefixToInstance[prfx], dataID,
|
||||
cacheCommit(utils.NonTransactional), utils.NonTransactional); err != nil {
|
||||
return
|
||||
}
|
||||
err = nil
|
||||
// if err = Cache.Remove(ctx, utils.CachePrefixToInstance[prfx], dataID,
|
||||
// cacheCommit(utils.NonTransactional), utils.NonTransactional); err != nil {
|
||||
// return
|
||||
// }
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
@@ -170,7 +170,7 @@ func TestHealthIndexThreshold(t *testing.T) {
|
||||
|
||||
exp := &FilterIHReply{
|
||||
MissingIndexes: map[string][]string{
|
||||
"cgrates.org:*string:*opts.ID:1002": {"TestHealthIndexThreshold"},
|
||||
"cgrates.org:*string:*opts.ID:1002": {"TestHealthIndexThreshold"},
|
||||
"cgrates.org:*string:*opts.*eventType:AccountUpdate": {"TestHealthIndexThreshold"},
|
||||
},
|
||||
BrokenIndexes: map[string][]string{},
|
||||
@@ -203,7 +203,7 @@ func TestHealthIndexThreshold(t *testing.T) {
|
||||
exp = &FilterIHReply{
|
||||
MissingObjects: []string{"cgrates.org:InexistingThreshold"},
|
||||
MissingIndexes: map[string][]string{
|
||||
"cgrates.org:*string:*opts.ID:1002": {"TestHealthIndexThreshold"},
|
||||
"cgrates.org:*string:*opts.ID:1002": {"TestHealthIndexThreshold"},
|
||||
"cgrates.org:*string:*opts.*eventType:AccountUpdate": {"TestHealthIndexThreshold"},
|
||||
},
|
||||
BrokenIndexes: map[string][]string{
|
||||
@@ -238,7 +238,7 @@ func TestHealthIndexThreshold(t *testing.T) {
|
||||
exp = &FilterIHReply{
|
||||
MissingObjects: []string{"cgrates.org:InexistingThreshold"},
|
||||
MissingIndexes: map[string][]string{
|
||||
"cgrates.org:*string:*opts.ID:1002": {"TestHealthIndexThreshold"},
|
||||
"cgrates.org:*string:*opts.ID:1002": {"TestHealthIndexThreshold"},
|
||||
"cgrates.org:*string:*opts.*eventType:AccountUpdate": {"TestHealthIndexThreshold"},
|
||||
},
|
||||
BrokenIndexes: map[string][]string{
|
||||
|
||||
@@ -285,15 +285,15 @@ func (eEc *ExtEventCharges) Equals(exCh *ExtEventCharges) (eq bool) {
|
||||
|
||||
// Equals returns the equality between two EventCharges
|
||||
func (eC *EventCharges) Equals(evCh *EventCharges) (eq bool) {
|
||||
if eC == nil && evCh == nil {
|
||||
return true
|
||||
if eC == nil && evCh == nil {
|
||||
return true
|
||||
}
|
||||
if (eC == nil && evCh != nil ||
|
||||
eC != nil && evCh == nil) ||
|
||||
(eC.Abstracts == nil && evCh.Abstracts != nil ||
|
||||
eC.Abstracts != nil && evCh.Abstracts == nil ||
|
||||
(eC.Abstracts != nil && evCh.Abstracts != nil &&
|
||||
eC.Abstracts.Compare(evCh.Abstracts) != 0)) ||
|
||||
eC.Abstracts != nil && evCh.Abstracts == nil ||
|
||||
(eC.Abstracts != nil && evCh.Abstracts != nil &&
|
||||
eC.Abstracts.Compare(evCh.Abstracts) != 0)) ||
|
||||
(eC.Concretes == nil && evCh.Concretes != nil ||
|
||||
eC.Concretes != nil && evCh.Concretes == nil ||
|
||||
(eC.Concretes != nil && evCh.Concretes != nil &&
|
||||
|
||||
Reference in New Issue
Block a user