mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 21:29:52 +05:00
Update tests with CacheLoadIDs
This commit is contained in:
committed by
Dan Christian Bogos
parent
57489d90aa
commit
827503ce60
@@ -372,6 +372,11 @@ func (self *ApierV1) SetRatingProfile(attrs utils.AttrSetRatingProfile, reply *s
|
||||
if err := self.DataManager.SetRatingProfile(rpfl, utils.NonTransactional); err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
//generate a loadID for RatingProfile and store it in database
|
||||
loadIDs := map[string]string{utils.CacheRatingProfiles: utils.UUIDSha1Prefix()}
|
||||
if err := self.DataManager.SetLoadIDs(loadIDs); err != nil {
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*reply = OK
|
||||
return nil
|
||||
}
|
||||
@@ -467,6 +472,11 @@ func (self *ApierV1) SetActions(attrs V1AttrSetActions, reply *string) (err erro
|
||||
if err := self.DataManager.SetActions(attrs.ActionsId, storeActions, utils.NonTransactional); err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
//generate a loadID for RatingProfile and store it in database
|
||||
loadIDs := map[string]string{utils.CacheActions: utils.UUIDSha1Prefix()}
|
||||
if err := self.DataManager.SetLoadIDs(loadIDs); err != nil {
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*reply = OK
|
||||
return nil
|
||||
}
|
||||
@@ -596,6 +606,11 @@ func (self *ApierV1) SetActionPlan(attrs AttrSetActionPlan, reply *string) (err
|
||||
}
|
||||
sched.Reload()
|
||||
}
|
||||
//generate a loadID for RatingProfile and store it in database
|
||||
loadIDs := map[string]string{utils.CacheActionPlans: utils.UUIDSha1Prefix()}
|
||||
if err := self.DataManager.SetLoadIDs(loadIDs); err != nil {
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*reply = OK
|
||||
return nil
|
||||
}
|
||||
@@ -773,6 +788,11 @@ func (self *ApierV1) RemoveRatingProfile(attr AttrRemoveRatingProfile, reply *st
|
||||
*reply = err.Error()
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
//generate a loadID for RatingProfile and store it in database
|
||||
loadIDs := map[string]string{utils.CacheRatingProfiles: utils.UUIDSha1Prefix()}
|
||||
if err := self.DataManager.SetLoadIDs(loadIDs); err != nil {
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*reply = utils.OK
|
||||
return nil
|
||||
}
|
||||
@@ -859,6 +879,11 @@ func (self *ApierV1) RemoveActions(attr AttrRemoveActions, reply *string) error
|
||||
return err
|
||||
}
|
||||
}
|
||||
//generate a loadID for RatingProfile and store it in database
|
||||
loadIDs := map[string]string{utils.CacheActions: utils.UUIDSha1Prefix()}
|
||||
if err := self.DataManager.SetLoadIDs(loadIDs); err != nil {
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*reply = utils.OK
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -838,6 +838,7 @@ func TestApierReloadCache(t *testing.T) {
|
||||
expectedStats[utils.CacheRatingProfiles].Items = 2
|
||||
expectedStats[utils.CacheRatingPlans].Items = 1
|
||||
expectedStats[utils.CacheReverseDestinations].Items = 10
|
||||
expectedStats[utils.CacheLoadIDs].Items = 20
|
||||
if err := rater.Call("CacheSv1.GetCacheStats", nil, &rcvStats); err != nil {
|
||||
t.Error("Got error on CacheSv1.GetCacheStats: ", err.Error())
|
||||
} else if !reflect.DeepEqual(expectedStats, rcvStats) {
|
||||
@@ -1307,10 +1308,11 @@ func TestApierResetDataAfterLoadFromFolder(t *testing.T) {
|
||||
expStats[utils.CacheActionPlans].Items = 7
|
||||
expStats[utils.CacheActions].Items = 6
|
||||
expStats[utils.CacheDestinations].Items = 3
|
||||
expStats[utils.CacheLoadIDs].Items = 17
|
||||
if err := rater.Call("CacheSv1.GetCacheStats", nil, &rcvStats); err != nil {
|
||||
t.Error("Got error on CacheSv1.GetCacheStats: ", err.Error())
|
||||
} else if !reflect.DeepEqual(expStats, rcvStats) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats))
|
||||
t.Errorf("Expecting: %+v,\n received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats))
|
||||
}
|
||||
reply := ""
|
||||
// Simple test that command is executed without errors
|
||||
@@ -1333,6 +1335,7 @@ func TestApierResetDataAfterLoadFromFolder(t *testing.T) {
|
||||
expStats[utils.CacheSupplierProfiles].Items = 2
|
||||
expStats[utils.CacheThresholdProfiles].Items = 1
|
||||
expStats[utils.CacheThresholds].Items = 1
|
||||
expStats[utils.CacheLoadIDs].Items = 20
|
||||
|
||||
if err := rater.Call("CacheSv1.GetCacheStats", nil, &rcvStats); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -129,6 +129,7 @@ func testCacheSAfterLoadFromFolder(t *testing.T) {
|
||||
expStats[utils.CacheActionPlans].Items = 7
|
||||
expStats[utils.CacheActions].Items = 6
|
||||
expStats[utils.CacheDestinations].Items = 3
|
||||
expStats[utils.CacheLoadIDs].Items = 17
|
||||
if err := chcRPC.Call(utils.CacheSv1GetCacheStats, nil, &rcvStats); err != nil {
|
||||
t.Error("Got error on CacheSv1.GetCacheStats: ", err.Error())
|
||||
} else if !reflect.DeepEqual(expStats, rcvStats) {
|
||||
|
||||
@@ -287,6 +287,10 @@ func testPrecacheGetCacheStatsAfterRestart(t *testing.T) {
|
||||
Items: 0,
|
||||
Groups: 0,
|
||||
},
|
||||
utils.CacheLoadIDs: {
|
||||
Items: 0,
|
||||
Groups: 0,
|
||||
},
|
||||
}
|
||||
if err := precacheRPC.Call(utils.CacheSv1GetCacheStats, cacheIDs, &reply); err != nil {
|
||||
t.Error(err.Error())
|
||||
|
||||
@@ -96,7 +96,8 @@ func (self *ApierV1) GetTPAccountActionLoadIds(attrs AttrGetTPAccountActionIds,
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
if ids, err := self.StorDb.GetTpTableIds(attrs.TPid, utils.TBLTPAccountActions, utils.TPDistinctIds{"loadid"}, nil, &attrs.Paginator); err != nil {
|
||||
if ids, err := self.StorDb.GetTpTableIds(attrs.TPid, utils.TBLTPAccountActions,
|
||||
utils.TPDistinctIds{"loadid"}, nil, &attrs.Paginator); err != nil {
|
||||
if err.Error() != utils.ErrNotFound.Error() {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
@@ -112,7 +113,8 @@ func (self *ApierV1) GetTPAccountActionIds(attrs AttrGetTPAccountActionIds, repl
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
if ids, err := self.StorDb.GetTpTableIds(attrs.TPid, utils.TBLTPAccountActions, utils.TPDistinctIds{"loadid", "tenant", "account"}, nil, &attrs.Paginator); err != nil {
|
||||
if ids, err := self.StorDb.GetTpTableIds(attrs.TPid, utils.TBLTPAccountActions,
|
||||
utils.TPDistinctIds{"loadid", "tenant", "account"}, nil, &attrs.Paginator); err != nil {
|
||||
if err.Error() != utils.ErrNotFound.Error() {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
@@ -132,7 +134,8 @@ func (self *ApierV1) RemTPAccountActions(attrs AttrGetTPAccountActions, reply *s
|
||||
if err := aa.SetAccountActionId(attrs.AccountActionsId); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := self.StorDb.RemTpData(utils.TBLTPAccountActions, aa.Tpid, map[string]string{"loadid": aa.Loadid, "tenant": aa.Tenant, "account": aa.Account}); err != nil {
|
||||
if err := self.StorDb.RemTpData(utils.TBLTPAccountActions, aa.Tpid,
|
||||
map[string]string{"loadid": aa.Loadid, "tenant": aa.Tenant, "account": aa.Account}); err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
} else {
|
||||
*reply = utils.OK
|
||||
|
||||
@@ -121,7 +121,8 @@ func testTPAccActionsRpcConn(t *testing.T) {
|
||||
func testTPAccActionsGetTPAccActionBeforeSet(t *testing.T) {
|
||||
var reply *utils.TPAccountActions
|
||||
if err := tpAccActionsRPC.Call("ApierV1.GetTPAccountActions",
|
||||
&AttrGetTPAccountActions{TPid: "TPAcc", AccountActionsId: tpAccActionID}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
&AttrGetTPAccountActions{TPid: "TPAcc", AccountActionsId: tpAccActionID}, &reply); err == nil ||
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -224,7 +225,8 @@ func testTPAccActionsRemTPAccAction(t *testing.T) {
|
||||
func testTPAccActionsGetTPAccActionAfterRemove(t *testing.T) {
|
||||
var reply *utils.TPAccountActions
|
||||
if err := tpAccActionsRPC.Call("ApierV1.GetTPAccountActions",
|
||||
&AttrGetTPAccountActions{TPid: "TPAcc", AccountActionsId: tpAccActionID}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
&AttrGetTPAccountActions{TPid: "TPAcc", AccountActionsId: tpAccActionID}, &reply); err == nil ||
|
||||
err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +131,7 @@ func testTPAlsPrfSetTPAlsPrf(t *testing.T) {
|
||||
&utils.TPAttribute{
|
||||
FieldName: "FL1",
|
||||
Substitute: "Al1",
|
||||
FilterIDs: []string{},
|
||||
},
|
||||
},
|
||||
Weight: 20,
|
||||
@@ -149,7 +150,7 @@ func testTPAlsPrfGetTPAlsPrfAfterSet(t *testing.T) {
|
||||
&utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "Attr1"}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(tpAlsPrf, reply) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", tpAlsPrf, reply)
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(tpAlsPrf), utils.ToJSON(reply))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,10 +170,12 @@ func testTPAlsPrfUpdateTPAlsPrf(t *testing.T) {
|
||||
&utils.TPAttribute{
|
||||
FieldName: "FL1",
|
||||
Substitute: "Al1",
|
||||
FilterIDs: []string{},
|
||||
},
|
||||
&utils.TPAttribute{
|
||||
FieldName: "FL2",
|
||||
Substitute: "Al2",
|
||||
FilterIDs: []string{},
|
||||
},
|
||||
}
|
||||
var result string
|
||||
@@ -199,10 +202,12 @@ func testTPAlsPrfGetTPAlsPrfAfterUpdate(t *testing.T) {
|
||||
&utils.TPAttribute{
|
||||
FieldName: "FL2",
|
||||
Substitute: "Al2",
|
||||
FilterIDs: []string{},
|
||||
},
|
||||
&utils.TPAttribute{
|
||||
FieldName: "FL1",
|
||||
Substitute: "Al1",
|
||||
FilterIDs: []string{},
|
||||
},
|
||||
},
|
||||
Weight: 20,
|
||||
|
||||
@@ -1504,7 +1504,8 @@ func TestDfApierCfg(t *testing.T) {
|
||||
eCfg := &ApierJsonCfg{
|
||||
Caches_conns: &[]*HaPoolJsonCfg{
|
||||
{
|
||||
Address: utils.StringPointer(utils.MetaInternal),
|
||||
Address: utils.StringPointer("127.0.0.1:2012"),
|
||||
Transport: utils.StringPointer(utils.MetaJSONrpc),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1711,7 +1711,10 @@ func TestNewCGRConfigFromPathNotFound(t *testing.T) {
|
||||
func TestCgrCfgJSONDefaultApierCfg(t *testing.T) {
|
||||
aCfg := &ApierCfg{
|
||||
CachesConns: []*HaPoolConfig{
|
||||
{Address: utils.MetaInternal},
|
||||
{
|
||||
Address: "127.0.0.1:2012",
|
||||
Transport: utils.MetaJSONrpc,
|
||||
},
|
||||
},
|
||||
}
|
||||
if !reflect.DeepEqual(cgrCfg.apier, aCfg) {
|
||||
|
||||
@@ -58,5 +58,11 @@
|
||||
"enabled": true, // starts User service: <true|false>.
|
||||
},
|
||||
|
||||
"apier": {
|
||||
"caches_conns":[ // connections to CacheS for reloads
|
||||
{"address": "127.0.0.1:3012", "transport": "*json"},
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -47,4 +47,10 @@
|
||||
],
|
||||
},
|
||||
|
||||
"apier": {
|
||||
"caches_conns":[ // connections to CacheS for reloads
|
||||
{"address": "127.0.0.1:22012", "transport": "*json"},
|
||||
],
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ func testDspChcLoadAfterFolder(t *testing.T) {
|
||||
expStats[utils.CacheActionPlans].Items = 1
|
||||
expStats[utils.CacheActions].Items = 1
|
||||
expStats[utils.CacheDestinations].Items = 4
|
||||
expStats[utils.CacheLoadIDs].Items = 17
|
||||
args := AttrCacheIDsWithApiKey{
|
||||
DispatcherResource: DispatcherResource{
|
||||
APIKey: "chc12345",
|
||||
@@ -124,7 +125,7 @@ func testDspChcLoadAfterFolder(t *testing.T) {
|
||||
expStats[utils.CacheSupplierProfiles].Items = 3
|
||||
expStats[utils.CacheThresholdProfiles].Items = 2
|
||||
expStats[utils.CacheThresholds].Items = 2
|
||||
|
||||
expStats[utils.CacheLoadIDs].Items = 20
|
||||
if err := dispEngine.RCP.Call(utils.CacheSv1GetCacheStats, &args, &rcvStats); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expStats, rcvStats) {
|
||||
@@ -166,6 +167,7 @@ func testDspChcPrecacheStatus(t *testing.T) {
|
||||
utils.CacheSupplierFilterIndexes: utils.MetaReady,
|
||||
utils.CacheChargerFilterIndexes: utils.MetaReady,
|
||||
utils.CacheDispatcherFilterIndexes: utils.MetaReady,
|
||||
utils.CacheLoadIDs: utils.MetaReady,
|
||||
}
|
||||
|
||||
if err := dispEngine.RCP.Call(utils.CacheSv1PrecacheStatus, AttrCacheIDsWithApiKey{
|
||||
|
||||
@@ -123,6 +123,7 @@ func TestTutSMGCacheStats(t *testing.T) {
|
||||
expectedStats[utils.CacheAttributeProfiles].Items = 1
|
||||
expectedStats[utils.MetaDefault].Items = 1
|
||||
expectedStats[utils.CacheActionTriggers].Items = 1
|
||||
expectedStats[utils.CacheLoadIDs].Items = 20
|
||||
if err := tutSMGRpc.Call("CacheSv1.GetCacheStats", nil, &rcvStats); err != nil {
|
||||
t.Error("Got error on CacheSv1.GetCacheStats: ", err.Error())
|
||||
} else if !reflect.DeepEqual(expectedStats, rcvStats) {
|
||||
|
||||
Reference in New Issue
Block a user