From 8c8238b4444ed090973e857f340e6feb3f31123b Mon Sep 17 00:00:00 2001 From: Tripon Alexandru-Ionut Date: Thu, 6 Jun 2019 17:01:41 +0300 Subject: [PATCH] Updated call tests --- agents/kamagent.go | 2 +- calls_test.sh | 6 ++-- .../kamevapi/cgrates/etc/cgrates/cgrates.json | 3 ++ engine/mapevent.go | 2 +- general_tests/tutorial_calls_test.go | 34 +++++++++++-------- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/agents/kamagent.go b/agents/kamagent.go index 8d0b824da..010250d13 100644 --- a/agents/kamagent.go +++ b/agents/kamagent.go @@ -329,7 +329,7 @@ func (ka *KamailioAgent) V1DisconnectSession(args utils.AttrDisconnectSession, r KamHashEntry, hEntry, KamHashID, hID)) return } - connIdx, err := utils.IfaceAsInt64(connIdxIface) + connIdx, err := utils.IfaceAsTInt64(connIdxIface) if err != nil { return err } diff --git a/calls_test.sh b/calls_test.sh index de29a5836..746f6d779 100755 --- a/calls_test.sh +++ b/calls_test.sh @@ -1,9 +1,9 @@ #! /usr/bin/env sh -./local_test.sh +# ./local_test.sh lcl=$? -echo 'go test github.com/cgrates/cgrates/general_tests -calls' -go test github.com/cgrates/cgrates/general_tests -calls +echo 'go test github.com/cgrates/cgrates/general_tests -tags=call' +go test github.com/cgrates/cgrates/general_tests -tags=call -timeout=10h gnr=$? exit $gen && $gnr \ No newline at end of file diff --git a/data/tutorials/kamevapi/cgrates/etc/cgrates/cgrates.json b/data/tutorials/kamevapi/cgrates/etc/cgrates/cgrates.json index aa62c7b37..f15bac3b7 100644 --- a/data/tutorials/kamevapi/cgrates/etc/cgrates/cgrates.json +++ b/data/tutorials/kamevapi/cgrates/etc/cgrates/cgrates.json @@ -78,6 +78,9 @@ "thresholds_conns": [ {"address": "127.0.0.1:2012", "transport": "*json"}, ], + "chargers_conns": [ + {"address": "127.0.0.1:2012", "transport": "*json"}, + ], "store_session_costs": true, "debit_interval": "5s", "channel_sync_interval":"5m", diff --git a/engine/mapevent.go b/engine/mapevent.go index 8ac141452..c329a880b 100644 --- a/engine/mapevent.go +++ b/engine/mapevent.go @@ -86,7 +86,7 @@ func (me MapEvent) GetInt64(fldName string) (out int64, err error) { if !has { return 0, utils.ErrNotFound } - return utils.IfaceAsInt64(fldIface) + return utils.IfaceAsTInt64(fldIface) } func (me MapEvent) GetStringIgnoreErrors(fldName string) (out string) { diff --git a/general_tests/tutorial_calls_test.go b/general_tests/tutorial_calls_test.go index 269a36924..fc3e55907 100755 --- a/general_tests/tutorial_calls_test.go +++ b/general_tests/tutorial_calls_test.go @@ -307,7 +307,8 @@ func testCallStatMetricsBefore(t *testing.T) { func testCallCheckResourceBeforeAllocation(t *testing.T) { var rs *engine.Resources args := &utils.ArgRSv1ResourceUsage{ - CGREvent: utils.CGREvent{ + UsageID: "OriginID", + CGREvent: &utils.CGREvent{ Tenant: "cgrates.org", ID: "ResourceEvent", Event: map[string]interface{}{ @@ -316,9 +317,9 @@ func testCallCheckResourceBeforeAllocation(t *testing.T) { utils.Destination: "1002"}, }} if err := tutorialCallsRpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &rs); err != nil { - t.Error(err) + t.Fatal(err) } else if len(*rs) != 1 { - t.Errorf("Resources: %+v", utils.ToJSON(rs)) + t.Fatalf("Resources: %+v", utils.ToJSON(rs)) } for _, r := range *rs { if r.ID == "ResGroup1" && @@ -450,7 +451,8 @@ func testCallCall1003To1001SecondTime(t *testing.T) { func testCallCheckResourceAllocation(t *testing.T) { var rs *engine.Resources args := &utils.ArgRSv1ResourceUsage{ - CGREvent: utils.CGREvent{ + UsageID: "OriginID1", + CGREvent: &utils.CGREvent{ Tenant: "cgrates.org", ID: "ResourceAllocation", Event: map[string]interface{}{ @@ -459,9 +461,9 @@ func testCallCheckResourceAllocation(t *testing.T) { utils.Destination: "1002"}, }} if err := tutorialCallsRpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &rs); err != nil { - t.Error(err) + t.Fatal(err) } else if len(*rs) != 1 { - t.Errorf("Resources: %+v", utils.ToJSON(rs)) + t.Fatalf("Resources: %+v", utils.ToJSON(rs)) } for _, r := range *rs { if r.ID == "ResGroup1" && len(r.Usages) != 3 { @@ -637,7 +639,8 @@ func testCallStatMetrics(t *testing.T) { func testCallCheckResourceRelease(t *testing.T) { var rs *engine.Resources args := &utils.ArgRSv1ResourceUsage{ - CGREvent: utils.CGREvent{ + UsageID: "OriginID2", + CGREvent: &utils.CGREvent{ Tenant: "cgrates.org", ID: "ResourceRelease", Event: map[string]interface{}{ @@ -646,9 +649,9 @@ func testCallCheckResourceRelease(t *testing.T) { utils.Destination: "1002"}, }} if err := tutorialCallsRpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &rs); err != nil { - t.Error(err) + t.Fatal(err) } else if len(*rs) != 1 { - t.Errorf("Resources: %+v", rs) + t.Fatalf("Resources: %+v", rs) } for _, r := range *rs { if r.ID == "ResGroup1" && len(r.Usages) != 0 { @@ -711,7 +714,8 @@ func testCallSyncSessions(t *testing.T) { //check if resource was allocated for 2 calls(1001->1002;1001->1003) var rs *engine.Resources args := &utils.ArgRSv1ResourceUsage{ - CGREvent: utils.CGREvent{ + UsageID: "OriginID3", + CGREvent: &utils.CGREvent{ Tenant: "cgrates.org", ID: "AllocateResource", Event: map[string]interface{}{ @@ -720,9 +724,9 @@ func testCallSyncSessions(t *testing.T) { utils.Destination: "1002"}, }} if err := tutorialCallsRpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &rs); err != nil { - t.Error(err) + t.Fatal(err) } else if len(*rs) != 1 { - t.Errorf("Resources: %+v", utils.ToJSON(rs)) + t.Fatalf("Resources: %+v", utils.ToJSON(rs)) } for _, r := range *rs { if r.ID == "ResGroup1" && len(r.Usages) != 2 { @@ -777,7 +781,7 @@ func testCallSyncSessions(t *testing.T) { if err := tutorialCallsRpc.Call(utils.ApierV2GetCDRs, req, &rplCdrs); err != nil { t.Error("Unexpected error: ", err.Error()) } else if len(rplCdrs) != numberOfCDR { // cdr from sync session + cdr from before - t.Error("Unexpected number of CDRs returned: ", len(rplCdrs)) + t.Fatal("Unexpected number of CDRs returned: ", len(rplCdrs)) } else if time1, err := utils.ParseDurationWithSecs(rplCdrs[0].Usage); err != nil { t.Error(err) } else if time1 > time.Duration(15*time.Second) { @@ -797,9 +801,9 @@ func testCallSyncSessions(t *testing.T) { //check if resource was released var rsAfter *engine.Resources if err := tutorialCallsRpc.Call(utils.ResourceSv1GetResourcesForEvent, args, &rsAfter); err != nil { - t.Error(err) + t.Fatal(err) } else if len(*rsAfter) != 1 { - t.Errorf("Resources: %+v", rsAfter) + t.Fatalf("Resources: %+v", rsAfter) } for _, r := range *rsAfter { if r.ID == "ResGroup1" && len(r.Usages) != 0 {