From 517bf7964bb703dee31201054c3b5eb37c0e6cf9 Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 3 Apr 2014 16:36:03 +0200 Subject: [PATCH 1/2] action enable/disable_user -> enable/disable_account, cgr-tester to use test data compatible with fs_json tutorial --- cmd/cgr-tester/cgr-tester.go | 8 ++++---- data/tester/cgr-tester.py | 8 ++++---- engine/action.go | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/cgr-tester/cgr-tester.go b/cmd/cgr-tester/cgr-tester.go index 2c032f907..76a816e82 100644 --- a/cmd/cgr-tester/cgr-tester.go +++ b/cmd/cgr-tester/cgr-tester.go @@ -53,9 +53,9 @@ var ( dbdata_encoding = flag.String("dbdata_encoding", cgrConfig.DBDataEncoding, "The encoding used to store object data in strings.") raterAddress = flag.String("rater_address", "", "Rater address for remote tests. Empty for internal rater.") tor = flag.String("tor", "call", "The type of record to use in queries.") - tenant = flag.String("tenant", "call", "The type of record to use in queries.") + tenant = flag.String("tenant", "cgrates.org", "The type of record to use in queries.") subject = flag.String("subject", "1001", "The rating subject to use in queries.") - destination = flag.String("destination", "+4986517174963", "The destination to use in queries.") + destination = flag.String("destination", "1002", "The destination to use in queries.") nilDuration = time.Duration(0) ) @@ -150,8 +150,8 @@ func main() { defer pprof.StopCPUProfile() } cd := &engine.CallDescriptor{ - TimeStart: time.Date(2013, time.December, 13, 22, 30, 0, 0, time.UTC), - TimeEnd: time.Date(2013, time.December, 13, 22, 31, 0, 0, time.UTC), + TimeStart: time.Date(2014, time.December, 11, 55, 30, 0, 0, time.UTC), + TimeEnd: time.Date(2014, time.December, 11, 55, 31, 0, 0, time.UTC), CallDuration: 60 * time.Second, Direction: "*out", TOR: *tor, diff --git a/data/tester/cgr-tester.py b/data/tester/cgr-tester.py index 8993fa4d9..dbb99029d 100644 --- a/data/tester/cgr-tester.py +++ b/data/tester/cgr-tester.py @@ -47,9 +47,9 @@ cd = {"Direction":"*out", "TOR":"call", "Tenant": "cgrates.org", "Subject": "1001", - "Destination": "+49", - "TimeStart": "2013-08-07T17:30:00Z", - "TimeEnd": "2013-08-07T18:30:00Z", + "Destination": "1002", + "TimeStart": "2014-04-03T11:12:23.190554134+02:00", + "TimeEnd": "2014-04-03T11:13:23.190554134+02:00", "CallDuration": 60000000000, } @@ -60,7 +60,7 @@ cd = {"Direction":"*out", start_time = time.time() i = 0 -runs = 1e5 +runs = 5e5 result = "" for i in range(int(runs) + 1): result = rpc.call("Responder.GetCost", cd) diff --git a/engine/action.go b/engine/action.go index c0dc08373..3667e1f49 100644 --- a/engine/action.go +++ b/engine/action.go @@ -58,8 +58,8 @@ const ( DEBIT = "*debit" RESET_COUNTER = "*reset_counter" RESET_COUNTERS = "*reset_counters" - ENABLE_USER = "*enable_user" - DISABLE_USER = "*disable_user" + ENABLE_ACCOUNT = "*enable_account" + DISABLE_ACCOUNT = "*disable_account" CALL_URL = "*call_url" CALL_URL_ASYNC = "*call_url_async" MAIL_ASYNC = "*mail_async" @@ -90,9 +90,9 @@ func getActionFunc(typ string) (actionTypeFunc, bool) { return resetCounterAction, true case RESET_COUNTERS: return resetCountersAction, true - case ENABLE_USER: + case ENABLE_ACCOUNT: return enableUserAction, true - case DISABLE_USER: + case DISABLE_ACCOUNT: return disableUserAction, true case CALL_URL: return callUrl, true From 71f296d65630b1ac793bfc6fbfcda6355f51f71c Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Fri, 4 Apr 2014 16:51:02 +0300 Subject: [PATCH 2/2] test for DigiDaz regression --- engine/calldesc_test.go | 30 ++++++++++++++++++++++++++---- engine/loader_csv_test.go | 6 +++--- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/engine/calldesc_test.go b/engine/calldesc_test.go index df4b3a303..1c3e52254 100644 --- a/engine/calldesc_test.go +++ b/engine/calldesc_test.go @@ -575,7 +575,7 @@ func TestMaxDebitZeroDefinedRate(t *testing.T) { cd1 := &CallDescriptor{ Direction: "*out", TOR: "call", - Tenant: "cgrates.directvoip.co.uk", + Tenant: "cgrates.org", Subject: "12345", Account: "12345", Destination: "447956", @@ -603,7 +603,7 @@ func TestMaxDebitZeroDefinedRateOnlyMinutes(t *testing.T) { cd1 := &CallDescriptor{ Direction: "*out", TOR: "call", - Tenant: "cgrates.directvoip.co.uk", + Tenant: "cgrates.org", Subject: "12345", Account: "12345", Destination: "447956", @@ -613,7 +613,7 @@ func TestMaxDebitZeroDefinedRateOnlyMinutes(t *testing.T) { CallDuration: 0} cc, err := cd1.MaxDebit() if err != nil { - t.Error("Error maxdebiting: ", err) + t.Fatal("Error maxdebiting: ", err) } if cc.GetDuration() != 40*time.Second { t.Error("Error obtaining max debit duration: ", cc.GetDuration()) @@ -623,7 +623,29 @@ func TestMaxDebitZeroDefinedRateOnlyMinutes(t *testing.T) { } } -/*********************************** BENCHMARKS ***************************************/ +func TestMaxDebitConsumesMinutes(t *testing.T) { + ap, _ := accountingStorage.GetActionTimings("TOPUP10_AT") + for _, at := range ap { + at.Execute() + } + cd1 := &CallDescriptor{ + Direction: "*out", + TOR: "call", + Tenant: "cgrates.org", + Subject: "12345", + Account: "12345", + Destination: "447956", + TimeStart: time.Date(2014, 3, 4, 6, 0, 0, 0, time.UTC), + TimeEnd: time.Date(2014, 3, 4, 6, 0, 5, 0, time.UTC), + LoopIndex: 0, + CallDuration: 0} + cd1.MaxDebit() + if cd1.account.BalanceMap[MINUTES+OUTBOUND][0].Value != 20 { + t.Error("Error using minutes: ", cd1.account.BalanceMap[MINUTES+OUTBOUND][0].Value) + } +} + +/*************** BENCHMARKS ********************/ func BenchmarkStorageGetting(b *testing.B) { b.StopTimer() t1 := time.Date(2012, time.February, 2, 17, 30, 0, 0, time.UTC) diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 46e51ecf4..a708a671b 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -118,8 +118,8 @@ vdf,0,*out,fallback1,2013-11-18T13:45:00Z,G,fallback2 vdf,0,*out,fallback1,2013-11-18T13:46:00Z,G,fallback2 vdf,0,*out,fallback1,2013-11-18T13:47:00Z,G,fallback2 vdf,0,*out,fallback2,2013-11-18T13:45:00Z,R,rif -cgrates.directvoip.co.uk,call,*out,*any,2013-01-06T00:00:00Z,RP_UK, -cgrates.directvoip.co.uk,call,*out,discounted_minutes,2013-01-06T00:00:00Z,RP_UK_Mobile_BIG5_PKG, +cgrates.org,call,*out,*any,2013-01-06T00:00:00Z,RP_UK, +cgrates.org,call,*out,discounted_minutes,2013-01-06T00:00:00Z,RP_UK_Mobile_BIG5_PKG, ` sharedGroups = ` SG1,*any,*lowest, @@ -157,7 +157,7 @@ STANDARD_TRIGGERS,*monetary,*out,*max_counter,5,FS_USERS,LOG_WARNING,10 ` accountActions = ` vdf,minitsboy;a1;a2,*out,MORE_MINUTES,STANDARD_TRIGGER -cgrates.directvoip.co.uk,12345,*out,TOPUP10_AT,STANDARD_TRIGGERS +cgrates.org,12345,*out,TOPUP10_AT,STANDARD_TRIGGERS vdf,empty0,*out,TOPUP_SHARED0_AT, vdf,empty10,*out,TOPUP_SHARED10_AT, vdf,emptyX,*out,TOPUP_EMPTY_AT,