From 25e37dda2ddc52b6a9c2fb38f7bcc20dd067f384 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Wed, 11 Dec 2019 17:47:17 +0200 Subject: [PATCH] Updated initSession and tests --- apier/v1/sessionsv1_it_test.go | 12 +++++++----- general_tests/rpccaching_it_test.go | 2 +- sessions/sessions.go | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apier/v1/sessionsv1_it_test.go b/apier/v1/sessionsv1_it_test.go index f0cbf3f3d..5d74eac8c 100644 --- a/apier/v1/sessionsv1_it_test.go +++ b/apier/v1/sessionsv1_it_test.go @@ -52,7 +52,6 @@ var ( testSSv1ItAuth, testSSv1ItAuthWithDigest, testSSv1ItInitiateSession, - testSSv1ItInitiateSessionWithDigest, testSSv1ItUpdateSession, testSSv1ItTerminateSession, testSSv1ItProcessCDR, @@ -61,6 +60,9 @@ var ( testSSv1ItForceUpdateSession, testSSv1ItDynamicDebit, testSSv1ItDeactivateSessions, + + testSSv1ItInitiateSessionWithDigest, // no need for session terminate because is the last test + testSSv1ItStopCgrEngine, } ) @@ -388,7 +390,7 @@ func testSSv1ItInitiateSessionWithDigest(t *testing.T) { Event: map[string]interface{}{ utils.Tenant: "cgrates.org", utils.ToR: utils.VOICE, - utils.OriginID: "TestSSv1It1", + utils.OriginID: "TestSSv1It2", utils.RequestType: sSV1RequestType, utils.Account: "1001", utils.Subject: "ANY2CNT", @@ -525,7 +527,7 @@ func testSSv1ItTerminateSession(t *testing.T) { aSessions := make([]*sessions.ExternalSession, 0) if err := sSv1BiRpc.Call(utils.SessionSv1GetActiveSessions, nil, &aSessions); err == nil || err.Error() != utils.ErrNotFound.Error() { - t.Error(err) + t.Errorf("Expected error %s received error %v and reply %s", utils.ErrNotFound, err, utils.ToJSON(aSessions)) } } @@ -719,7 +721,7 @@ func testSSv1ItForceUpdateSession(t *testing.T) { } var acnt *engine.Account attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"} - eAcntVal := 9.399500 + eAcntVal := 9.55 if err := sSApierRpc.Call(utils.ApierV2GetAccount, attrs, &acnt); err != nil { t.Error(err) } else if acnt.BalanceMap[utils.MONETARY].GetTotalValue() != eAcntVal { @@ -790,7 +792,7 @@ func testSSv1ItForceUpdateSession(t *testing.T) { t.Errorf("wrong active ssesions: %s", utils.ToJSON(aSessions)) } - eAcntVal = 9.249500 + eAcntVal = 9.4 if err := sSApierRpc.Call(utils.ApierV2GetAccount, attrs, &acnt); err != nil { t.Error(err) } else if acnt.BalanceMap[utils.MONETARY].GetTotalValue() != eAcntVal { diff --git a/general_tests/rpccaching_it_test.go b/general_tests/rpccaching_it_test.go index 634a7a904..c3ab7762f 100644 --- a/general_tests/rpccaching_it_test.go +++ b/general_tests/rpccaching_it_test.go @@ -355,7 +355,7 @@ func testRPCMethodsInitSession(t *testing.T) { time.Sleep(1*time.Second + 500*time.Millisecond) if err := rpcRpc.Call(utils.SessionSv1InitiateSession, - args, &rply); err == nil || err.Error() != "RALS_ERROR:ACCOUNT_DISABLED" { + args, &rply); err == nil || !(err.Error() == "RALS_ERROR:ACCOUNT_DISABLED" || err.Error() == utils.NewErrRALs(utils.ErrExists).Error()) { // ErrExist -> initSession twice t.Error("Unexpected error returned", err) } diff --git a/sessions/sessions.go b/sessions/sessions.go index 872f77eb3..feb199f83 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -1398,7 +1398,7 @@ func (sS *SessionS) initSession(tnt string, evStart engine.MapEvent, clntConnID DebitInterval: dbtItval, ArgDispatcher: argDisp, } - if sS.isIndexed(s, true) { // check if already exists + if sS.isIndexed(s, false) { // check if already exists return nil, utils.ErrExists } if err = sS.forkSession(s); err != nil {