Updated cache reload

This commit is contained in:
Trial97
2021-07-29 10:08:04 +03:00
committed by Dan Christian Bogos
parent 43cc17328f
commit 922eb77caf
5 changed files with 24 additions and 22 deletions

View File

@@ -23,9 +23,6 @@ package main
import (
"bytes"
"errors"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
"net/rpc"
"net/rpc/jsonrpc"
"os/exec"
@@ -34,6 +31,10 @@ import (
"sort"
"testing"
"time"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
var (
@@ -126,7 +127,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
if err := cgrLdrRPC.Call(utils.APIerSv1GetAttributeProfile,
&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
@@ -134,7 +135,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
if err := cgrLdrRPC.Call(utils.APIerSv1GetFilter,
&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)
}
// resourcesPrf
@@ -142,7 +143,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
if err := cgrLdrRPC.Call(utils.APIerSv1GetResourceProfile,
&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)
}
// resource
@@ -150,7 +151,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
if err := cgrLdrRPC.Call(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
@@ -158,7 +159,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
if err := cgrLdrRPC.Call(utils.APIerSv1GetRouteProfile,
&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
@@ -166,7 +167,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
if err := cgrLdrRPC.Call(utils.APIerSv1GetStatQueueProfile,
&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
@@ -174,7 +175,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
if err := cgrLdrRPC.Call(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
@@ -182,7 +183,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
if err := cgrLdrRPC.Call(utils.APIerSv1GetThresholdProfile,
&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
@@ -190,7 +191,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
if err := cgrLdrRPC.Call(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
@@ -198,7 +199,7 @@ func testCgrLdrGetSubsystemsNotLoadedLoad(t *testing.T) {
if err := cgrLdrRPC.Call(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.Error())
t.Errorf("Expected %+v, received %v", utils.ErrNotFound.Error(), err)
}
}

View File

@@ -57,7 +57,7 @@ type CoreService struct {
shdWg *sync.WaitGroup
stopMemPrf chan struct{}
shdChan *utils.SyncedChan
fileMEM string
fileMEM string
fileCPU io.Closer
fileMx sync.Mutex
}

View File

@@ -40,7 +40,7 @@ func TestNewCoreService(t *testing.T) {
shdChan := utils.NewSyncedChan()
stopMemPrf := make(chan struct{})
expected := &CoreService{
fileMEM: "/tmp",
fileMEM: "/tmp",
shdWg: shdWg,
shdChan: shdChan,
stopMemPrf: stopMemPrf,
@@ -48,7 +48,7 @@ func TestNewCoreService(t *testing.T) {
CapsStats: sts,
}
rcv := NewCoreService(cfgDflt, caps, nil,"/tmp", stopchan, shdWg, stopMemPrf, shdChan)
rcv := NewCoreService(cfgDflt, caps, nil, "/tmp", stopchan, shdWg, stopMemPrf, shdChan)
if !reflect.DeepEqual(expected, rcv) {
t.Errorf("Expected %+v, received %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
@@ -63,7 +63,7 @@ func TestCoreServiceStatus(t *testing.T) {
caps := engine.NewCaps(1, utils.MetaBusy)
stopChan := make(chan struct{}, 1)
cores := NewCoreService(cfgDflt, caps, nil,"/tmp", stopChan, nil, nil, nil)
cores := NewCoreService(cfgDflt, caps, nil, "/tmp", stopChan, nil, nil, nil)
args := &utils.TenantWithAPIOpts{
Tenant: "cgrates.org",
APIOpts: map[string]interface{}{},

View File

@@ -271,10 +271,11 @@ func (dm *DataManager) CacheDataFromDB(prfx string, ids []string, mustBeCached b
err.Error(),
fmt.Sprintf("error <%s> querying DataManager for category: <%s>, dataID: <%s>", err.Error(), prfx, dataID))
}
if err = Cache.Remove(utils.CachePrefixToInstance[prfx], dataID,
cacheCommit(utils.NonTransactional), utils.NonTransactional); err != nil {
return
}
err = nil
// if err = Cache.Remove(utils.CachePrefixToInstance[prfx], dataID,
// cacheCommit(utils.NonTransactional), utils.NonTransactional); err != nil {
// return
// }
}
}
return

View File

@@ -3205,4 +3205,4 @@ func TestBiRPCv1ProcessEventNoTenant(t *testing.T) {
if err := ss.BiRPCv1ProcessEvent(nil, args, reply); err != nil {
t.Error(err)
}
}
}