From 1b371419db859a4e49d6b65832b51cb22b351652 Mon Sep 17 00:00:00 2001 From: TeoV Date: Wed, 14 Nov 2018 10:41:27 -0500 Subject: [PATCH] Update call test for freeswitch and kamailio --- agents/asterisk_event.go | 1 + data/tariffplans/tutorial/Filters.csv | 2 +- .../asterisk/etc/asterisk/pjsip.conf | 1 + general_tests/tutorial_calls_test.go | 25 ++++--------------- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/agents/asterisk_event.go b/agents/asterisk_event.go index fa52c14b8..d385c7747 100644 --- a/agents/asterisk_event.go +++ b/agents/asterisk_event.go @@ -245,6 +245,7 @@ func (smaEv *SMAsteriskEvent) AsMapStringInterface() (mp map[string]interface{}) for extraKey, extraVal := range smaEv.ExtraParameters() { // Append extraParameters mp[extraKey] = extraVal } + mp[utils.Source] = utils.KamailioAgent return } diff --git a/data/tariffplans/tutorial/Filters.csv b/data/tariffplans/tutorial/Filters.csv index 3b62ee7ef..143bd00b7 100644 --- a/data/tariffplans/tutorial/Filters.csv +++ b/data/tariffplans/tutorial/Filters.csv @@ -4,7 +4,7 @@ cgrates.org,FLTR_DST_FS,*string,Account,1001,2014-07-29T15:00:00Z cgrates.org,FLTR_DST_FS,*destinations,Destination,DST_FS, cgrates.org,FLTR_ACNT_1001_1002,*string,Account,1001;1002,2014-07-29T15:00:00Z cgrates.org,FLTR_ACNT_1001_1002,*string,RunID,*default, -cgrates.org,FLTR_ACNT_1001_1003,*string,Destination,1001;1002, +cgrates.org,FLTR_ACNT_1001_1002,*string,Destination,1001;1002;1003, cgrates.org,FLTR_ACNT_1001,*string,Account,1001,2014-07-29T15:00:00Z cgrates.org,FLTR_ACNT_1002,*string,Account,1002,2014-07-29T15:00:00Z cgrates.org,FLTR_ACNT_1003,*string,Account,1003,2014-07-29T15:00:00Z diff --git a/data/tutorials/asterisk_ari/asterisk/etc/asterisk/pjsip.conf b/data/tutorials/asterisk_ari/asterisk/etc/asterisk/pjsip.conf index 4db5b566c..a545acda4 100755 --- a/data/tutorials/asterisk_ari/asterisk/etc/asterisk/pjsip.conf +++ b/data/tutorials/asterisk_ari/asterisk/etc/asterisk/pjsip.conf @@ -36,6 +36,7 @@ auth = 1002 [1002] type = aor max_contacts = 5 +qualify_frequency = 0 [1002] type=auth diff --git a/general_tests/tutorial_calls_test.go b/general_tests/tutorial_calls_test.go index 7e3443da5..9c524b319 100755 --- a/general_tests/tutorial_calls_test.go +++ b/general_tests/tutorial_calls_test.go @@ -77,7 +77,7 @@ var sTestsCalls = []func(t *testing.T){ testCallCheckResourceRelease, testCallCheckThreshold1001After, testCallCheckThreshold1002After, - //testCallSyncSessions, + testCallSyncSessions, testCallStopPjsuaListener, testCallStopCgrEngine, testCallStopFS, @@ -424,11 +424,6 @@ func testCallCall1001To1003(t *testing.T) { } } -// 1001 -> 1002 67s -// 1002 -> 1001 65s -// 1001 -> 1003 12s -// here we have 3 units of resource allocation - // Call from 1003 (prepaid) to 1001 for 20 seconds func testCallCall1003To1001(t *testing.T) { if err := engine.PjsuaCallUri( @@ -439,11 +434,6 @@ func testCallCall1003To1001(t *testing.T) { // after this call from 1001 to 1003 and call from 1003 to 1001 should be done } -// 1001 -> 1002 45s -// 1002 -> 1001 43s -// 1003 -> 1001 20s -// 1 unit was release and 1 units was accolated (now we have 3 units allocated ) - // Call from 1003 (prepaid) to 1001 for 15 seconds func testCallCall1003To1001SecondTime(t *testing.T) { time.Sleep(22 * time.Second) @@ -455,11 +445,6 @@ func testCallCall1003To1001SecondTime(t *testing.T) { time.Sleep(time.Second) } -// 1001 -> 1002 22s -// 1002 -> 1001 20s -// 1003 -> 1001 15s (new call) -// 3 units allocated - // Check if the resource was Allocated func testCallCheckResourceAllocation(t *testing.T) { var rs *engine.Resources @@ -483,7 +468,7 @@ func testCallCheckResourceAllocation(t *testing.T) { } } // Allow calls to finish before start querying the results - time.Sleep(time.Duration(30) * time.Second) + time.Sleep(time.Duration(50) * time.Second) } // Make sure account was debited properly @@ -699,7 +684,7 @@ func testCallSyncSessions(t *testing.T) { t.Errorf("Resources: %+v", utils.ToJSON(rs)) } for _, r := range *rs { - if r.ID == "ResGroup1" && (len(r.Usages) != 2 || len(r.TTLIdx) != 2) { + if r.ID == "ResGroup1" && len(r.Usages) != 2 { t.Errorf("Unexpected resource: %+v", utils.ToJSON(r)) } } @@ -727,7 +712,7 @@ func testCallSyncSessions(t *testing.T) { // activeSessions shouldn't be active if err := tutorialCallsRpc.Call(utils.SessionSv1GetActiveSessions, - &map[string]string{}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() { + &map[string]string{}, &reply); err != nil && err.Error() != utils.ErrNotFound.Error() { t.Error("Got error on SessionSv1.GetActiveSessions: ", err) } @@ -741,7 +726,7 @@ func testCallSyncSessions(t *testing.T) { sourceForCDR = utils.KamailioAgent numberOfCDR = 3 case utils.Asterisk: - sourceForCDR = "" + sourceForCDR = utils.AsteriskAgent numberOfCDR = 3 } // verify cdr