Added fixes to apier/v1

This commit is contained in:
Trial97
2018-11-06 18:34:51 +02:00
committed by Dan Christian Bogos
parent f8a21a541c
commit a5d4d12032
3 changed files with 27 additions and 6 deletions

View File

@@ -759,11 +759,19 @@ func TestApierSetRatingProfile(t *testing.T) {
} else if cc.Cost != 0 {
t.Errorf("Calling Responder.GetCost got callcost: %v", cc.Cost)
}
expectedStats = &utils.CacheStats{ReverseDestinations: 10, RatingPlans: 1, RatingProfiles: 1, Actions: 1, ActionPlans: 1, AccountActionPlans: 1}
expectedStats = &utils.CacheStats{
ReverseDestinations: 10,
RatingPlans: 1,
RatingProfiles: 1,
Actions: 1,
ActionPlans: 1,
AccountActionPlans: 1,
Aliases: 6,
}
if err := rater.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil {
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
} else if !reflect.DeepEqual(expectedStats, rcvStats) {
t.Errorf("Calling ApierV1.GetCacheStats expected: %+v, received: %+v", expectedStats, rcvStats)
t.Errorf("Calling ApierV1.GetCacheStats expected: %+v, received: %+v", utils.ToJSON(expectedStats), utils.ToJSON(rcvStats))
}
}
@@ -819,11 +827,19 @@ func TestApierReloadCache(t *testing.T) {
}
var rcvStats *utils.CacheStats
var args utils.AttrCacheStats
expectedStats := &utils.CacheStats{ReverseDestinations: 10, RatingPlans: 1, RatingProfiles: 1, Actions: 1, ActionPlans: 1, AccountActionPlans: 1}
expectedStats := &utils.CacheStats{
ReverseDestinations: 10,
RatingPlans: 1,
RatingProfiles: 1, // when it fails here is 2 is needed to investigate more
Actions: 1,
ActionPlans: 1,
AccountActionPlans: 1,
Aliases: 6,
}
if err := rater.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil {
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
} else if !reflect.DeepEqual(expectedStats, rcvStats) {
t.Errorf("Calling ApierV1.GetCacheStats expected: %+v, received: %+v", expectedStats, rcvStats)
t.Errorf("Calling ApierV1.GetCacheStats expected: %+v, received: %+v", utils.ToJSON(expectedStats), utils.ToJSON(rcvStats))
}
}
@@ -1292,7 +1308,7 @@ func TestApierResetDataAfterLoadFromFolder(t *testing.T) {
if err := rater.Call("ApierV1.GetCacheStats", utils.AttrCacheStats{}, &rcvStats); err != nil {
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
} else if !reflect.DeepEqual(expStats, rcvStats) {
t.Errorf("Expecting: %+v, received: %+v", expStats, rcvStats)
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expStats), utils.ToJSON(rcvStats))
}
reply := ""
// Simple test that command is executed without errors

View File

@@ -47,6 +47,7 @@ func (ssv1 *SessionSv1) Handlers() map[string]interface{} {
utils.SessionSv1GetActiveSessions: ssv1.BiRPCV1GetActiveSessions,
utils.SessionSv1GetPassiveSessions: ssv1.BiRPCV1GetPassiveSessions,
utils.SessionSv1RegisterInternalBiJSONConn: ssv1.BiRPCv1RegisterInternalBiJSONConn,
utils.SessionSv1Ping: ssv1.BiRPCPing,
}
}
@@ -151,6 +152,10 @@ func (ssv1 *SessionSv1) BiRPCv1RegisterInternalBiJSONConn(clnt *rpc2.Client, arg
return ssv1.SMG.BiRPCv1RegisterInternalBiJSONConn(clnt, args, rply)
}
func (ssv1 *SessionSv1) BiRPCPing(clnt *rpc2.Client, ign string, reply *string) error {
return ssv1.Ping(ign, reply)
}
func (ssv1 *SessionSv1) Ping(ign string, reply *string) error {
*reply = utils.Pong
return nil

View File

@@ -106,7 +106,7 @@ func TestSSv1ItRpcConn(t *testing.T) {
dummyClnt.Close() // close so we don't get EOF error when disconnecting server
}
func TestV1STSSessionPing(t *testing.T) {
func TestSSv1ItPing(t *testing.T) {
var resp string
if err := sSv1BiRpc.Call(utils.SessionSv1Ping, "", &resp); err != nil {
t.Error(err)