From eadd0cbb790650474543318badfaed3071d38cbf Mon Sep 17 00:00:00 2001 From: DanB Date: Mon, 28 Dec 2015 13:37:43 +0100 Subject: [PATCH] CDR and related TOR -> ToR field --- agents/dmtagent_it_test.go | 10 ++--- apier/v1/apier_local_test.go | 2 +- apier/v1/auth.go | 4 +- apier/v1/cdrstatsv1_local_test.go | 8 ++-- apier/v1/debit.go | 4 +- apier/v2/cdrs_mongo_local_test.go | 14 +++--- apier/v2/cdrs_mysql_local_test.go | 16 +++---- apier/v2/cdrs_psql_local_test.go | 16 +++---- cdrc/csv.go | 2 +- cdrc/csv_test.go | 8 ++-- cdrc/fwv.go | 2 +- cdre/cdrexporter.go | 22 ++++----- cdre/cdrexporter_test.go | 14 +++--- cdre/csv_test.go | 4 +- cdre/fixedwidth_test.go | 8 ++-- config/cfg_data.json | 2 +- config/cfg_data2.json | 2 +- config/config_defaults.go | 6 +-- engine/actions_local_test.go | 2 +- engine/actions_test.go | 2 +- engine/cdr.go | 28 ++++++------ engine/cdr_local_test.go | 2 +- engine/cdr_test.go | 44 +++++++++--------- engine/cdrs.go | 4 +- engine/cdrstats.go | 2 +- engine/cgrcdr.go | 2 +- engine/cgrcdr_test.go | 4 +- engine/fscdr.go | 2 +- engine/fscdr_test.go | 2 +- engine/responder_test.go | 4 +- engine/stats_test.go | 4 +- engine/storage_cdrs_it_test.go | 4 +- engine/storage_mongo_tp.go | 2 +- engine/storage_sql.go | 14 +++--- engine/suretax_test.go | 2 +- engine/users_test.go | 54 +++++++++++------------ general_tests/auth_test.go | 8 ++-- general_tests/cdrs_replication_it_test.go | 4 +- general_tests/fsevcorelate_test.go | 4 +- general_tests/suretax_it_test.go | 2 +- general_tests/tutorial_local_test.go | 32 +++++++------- sessionmanager/fsevent.go | 2 +- sessionmanager/fsevent_test.go | 2 +- sessionmanager/kamevent.go | 2 +- sessionmanager/osipsevent.go | 2 +- sessionmanager/osipsevent_test.go | 4 +- sessionmanager/smg_event.go | 2 +- sessionmanager/smg_event_test.go | 2 +- utils/apitpdata.go | 16 +++---- utils/consts.go | 2 +- 50 files changed, 203 insertions(+), 203 deletions(-) diff --git a/agents/dmtagent_it_test.go b/agents/dmtagent_it_test.go index f3f5dc3a1..2e6d8f707 100644 --- a/agents/dmtagent_it_test.go +++ b/agents/dmtagent_it_test.go @@ -143,7 +143,7 @@ func TestDmtAgentCCRAsSMGenericEvent(t *testing.T) { eSMGE := sessionmanager.SMGenericEvent{"EventName": DIAMETER_CCR, "OriginID": "routinga;1442095190;1476802709", "Account": "*users", "AnswerTime": "2015-11-23 12:22:24 +0000 UTC", "Category": "call", "Destination": "4986517174964", "Direction": "*out", "RequestType": "*users", "SetupTime": "2015-11-23 12:22:24 +0000 UTC", - "Subject": "*users", "SubscriberId": "4986517174963", "TOR": "*voice", "Tenant": "*users", "Usage": "300"} + "Subject": "*users", "SubscriberId": "4986517174963", "ToR": "*voice", "Tenant": "*users", "Usage": "300"} if smge, err := ccr.AsSMGenericEvent(cfgDefaults.DiameterAgentCfg().RequestProcessors[0].CCRFields); err != nil { t.Error(err) } else if !reflect.DeepEqual(eSMGE, smge) { @@ -186,7 +186,7 @@ func TestDmtAgentSendCCRInit(t *testing.T) { if err != nil { t.Fatal(err) } - cdr := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, + cdr := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1004", Supplier: "SUPPL1", SetupTime: time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2015, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, @@ -225,7 +225,7 @@ func TestDmtAgentSendCCRUpdate(t *testing.T) { if !*testIntegration { return } - cdr := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, + cdr := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1004", Supplier: "SUPPL1", SetupTime: time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2015, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, @@ -264,7 +264,7 @@ func TestDmtAgentSendCCRUpdate2(t *testing.T) { if !*testIntegration { return } - cdr := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, + cdr := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1004", Supplier: "SUPPL1", SetupTime: time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2015, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, @@ -302,7 +302,7 @@ func TestDmtAgentSendCCRTerminate(t *testing.T) { if !*testIntegration { return } - cdr := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, + cdr := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1004", Supplier: "SUPPL1", SetupTime: time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2015, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, diff --git a/apier/v1/apier_local_test.go b/apier/v1/apier_local_test.go index 36f1add3c..36b4fc86e 100644 --- a/apier/v1/apier_local_test.go +++ b/apier/v1/apier_local_test.go @@ -1424,7 +1424,7 @@ func TestApierLocalProcessCdr(t *testing.T) { return } var reply string - cdr := engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + cdr := engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, diff --git a/apier/v1/auth.go b/apier/v1/auth.go index 7e2503a8c..f462a14d7 100644 --- a/apier/v1/auth.go +++ b/apier/v1/auth.go @@ -32,8 +32,8 @@ func (self *ApierV1) GetMaxUsage(usageRecord engine.UsageRecord, maxUsage *float if err != nil { return utils.NewErrServerError(err) } - if usageRecord.TOR == "" { - usageRecord.TOR = utils.VOICE + if usageRecord.ToR == "" { + usageRecord.ToR = utils.VOICE } if usageRecord.RequestType == "" { usageRecord.RequestType = self.Config.DefaultReqType diff --git a/apier/v1/cdrstatsv1_local_test.go b/apier/v1/cdrstatsv1_local_test.go index 5c414d745..b9a2b7354 100644 --- a/apier/v1/cdrstatsv1_local_test.go +++ b/apier/v1/cdrstatsv1_local_test.go @@ -112,28 +112,28 @@ func TestCDRStatsLclPostCdrs(t *testing.T) { } httpClient := new(http.Client) storedCdrs := []*engine.CDR{ - &engine.CDR{CGRID: utils.Sha1("dsafdsafa", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("dsafdsafa", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "+4986517174963", SetupTime: time.Now(), AnswerTime: time.Now(), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, }, - &engine.CDR{CGRID: utils.Sha1("dsafdsafb", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("dsafdsafb", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "+4986517174963", SetupTime: time.Now(), AnswerTime: time.Now(), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(5) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, }, - &engine.CDR{CGRID: utils.Sha1("dsafdsafc", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("dsafdsafc", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "+4986517174963", SetupTime: time.Now(), AnswerTime: time.Now(), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(30) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, }, - &engine.CDR{CGRID: utils.Sha1("dsafdsafd", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("dsafdsafd", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "+4986517174963", SetupTime: time.Now(), AnswerTime: time.Time{}, diff --git a/apier/v1/debit.go b/apier/v1/debit.go index f0faf509c..bd9f53209 100644 --- a/apier/v1/debit.go +++ b/apier/v1/debit.go @@ -32,8 +32,8 @@ func (self *ApierV1) DebitUsage(usageRecord engine.UsageRecord, reply *string) e *reply = err.Error() return err } - if usageRecord.TOR == "" { - usageRecord.TOR = utils.VOICE + if usageRecord.ToR == "" { + usageRecord.ToR = utils.VOICE } if usageRecord.RequestType == "" { usageRecord.RequestType = self.Config.DefaultReqType diff --git a/apier/v2/cdrs_mongo_local_test.go b/apier/v2/cdrs_mongo_local_test.go index fee37b538..8cc7fd7b2 100644 --- a/apier/v2/cdrs_mongo_local_test.go +++ b/apier/v2/cdrs_mongo_local_test.go @@ -74,7 +74,7 @@ func TestV2CdrsMongoInjectUnratedCdr(t *testing.T) { return } strCdr1 := &engine.CDR{CGRID: utils.Sha1("bbb1", time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC).String()), - TOR: utils.VOICE, OriginID: "bbb1", OriginHost: "192.168.1.1", Source: "UNKNOWN", RequestType: utils.META_RATED, + ToR: utils.VOICE, OriginID: "bbb1", OriginHost: "192.168.1.1", Source: "UNKNOWN", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2013, 12, 7, 8, 42, 26, 0, time.UTC), Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, @@ -112,20 +112,20 @@ func TestV2CdrsMongoProcessCdr(t *testing.T) { } var reply string cdrs := []*engine.CDR{ - &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, Rated: true, }, - &engine.CDR{CGRID: utils.Sha1("abcdeftg", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("abcdeftg", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1002", Subject: "1002", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, }, - &engine.CDR{CGRID: utils.Sha1("aererfddf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("aererfddf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, @@ -214,17 +214,17 @@ func TestV2CdrsMongoProcessPrepaidCdr(t *testing.T) { } var reply string cdrs := []*engine.CDR{ - &engine.CDR{CGRID: utils.Sha1("dsafdsaf2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("dsafdsaf2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_PREPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, Rated: true, }, - &engine.CDR{CGRID: utils.Sha1("abcdeftg2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("abcdeftg2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_PREPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1002", Subject: "1002", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, }, - &engine.CDR{CGRID: utils.Sha1("aererfddf2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("aererfddf2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_PREPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, diff --git a/apier/v2/cdrs_mysql_local_test.go b/apier/v2/cdrs_mysql_local_test.go index 1e7d6465b..bbbed922e 100644 --- a/apier/v2/cdrs_mysql_local_test.go +++ b/apier/v2/cdrs_mysql_local_test.go @@ -80,7 +80,7 @@ func TestV2CDRsMySQLInjectUnratedCdr(t *testing.T) { return } strCdr1 := &engine.CDR{CGRID: utils.Sha1("bbb1", time.Date(2015, 11, 21, 10, 47, 24, 0, time.UTC).String()), RunID: utils.MetaRaw, - TOR: utils.VOICE, OriginID: "bbb1", OriginHost: "192.168.1.1", Source: "TestV2CDRsMySQLInjectUnratedCdr", RequestType: utils.META_RATED, + ToR: utils.VOICE, OriginID: "bbb1", OriginHost: "192.168.1.1", Source: "TestV2CDRsMySQLInjectUnratedCdr", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2015, 11, 21, 10, 47, 24, 0, time.UTC), AnswerTime: time.Date(2015, 11, 21, 10, 47, 26, 0, time.UTC), Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, @@ -117,7 +117,7 @@ func TestV2CDRsMySQLProcessCdrRated(t *testing.T) { } cdr := &engine.CDR{ CGRID: utils.Sha1("dsafdsaf", time.Date(2015, 12, 13, 18, 15, 26, 0, time.UTC).String()), RunID: utils.DEFAULT_RUNID, - OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "TestV2CDRsMySQLProcessCdrRated", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2015, 12, 13, 18, 15, 26, 0, time.UTC), AnswerTime: time.Date(2015, 12, 13, 18, 15, 26, 0, time.UTC), @@ -138,7 +138,7 @@ func TestV2CDRsMySQLProcessCdrRaw(t *testing.T) { } cdr := &engine.CDR{ CGRID: utils.Sha1("abcdeftg", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, RunID: utils.MetaRaw, - TOR: utils.VOICE, OriginID: "abcdeftg", + ToR: utils.VOICE, OriginID: "abcdeftg", OriginHost: "192.168.1.1", Source: "TestV2CDRsMySQLProcessCdrRaw", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1002", Subject: "1002", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), @@ -214,17 +214,17 @@ func TestV2CDRsMySQLProcessPrepaidCdr(t *testing.T) { } var reply string cdrs := []*engine.CDR{ - &engine.CDR{CGRID: utils.Sha1("dsafdsaf2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("dsafdsaf2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "TestV2CDRsMySQLProcessPrepaidCdr1", RequestType: utils.META_PREPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, Rated: true, }, - &engine.CDR{CGRID: utils.Sha1("abcdeftg2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("abcdeftg2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "TestV2CDRsMySQLProcessPrepaidCdr2", RequestType: utils.META_PREPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1002", Subject: "1002", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, }, - &engine.CDR{CGRID: utils.Sha1("aererfddf2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("aererfddf2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "TestV2CDRsMySQLProcessPrepaidCdr3", RequestType: utils.META_PREPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, @@ -314,7 +314,7 @@ func TestV2CDRsMySQLProcessRatedExternalCdrBenchmark(t *testing.T) { if !*testLocal { return } - cdr := &engine.ExternalCDR{TOR: utils.VOICE, + cdr := &engine.ExternalCDR{ToR: utils.VOICE, OriginID: "benchratedcdr", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1001", Supplier: "SUPPL1", SetupTime: "2014-08-04T13:00:00Z", AnswerTime: "2014-08-04T13:00:07Z", @@ -363,7 +363,7 @@ func TestV2CDRsMySQLProcessPostpaidExternalCdrBenchmark(t *testing.T) { if !*testLocal { return } - cdr := &engine.ExternalCDR{TOR: utils.VOICE, + cdr := &engine.ExternalCDR{ToR: utils.VOICE, OriginID: "benchpostpaidcdr", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_POSTPAID, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", Supplier: "SUPPL1", SetupTime: "2014-08-04T13:00:00Z", AnswerTime: "2014-08-04T13:00:07Z", diff --git a/apier/v2/cdrs_psql_local_test.go b/apier/v2/cdrs_psql_local_test.go index a70fdc16b..03d387c01 100644 --- a/apier/v2/cdrs_psql_local_test.go +++ b/apier/v2/cdrs_psql_local_test.go @@ -77,7 +77,7 @@ func TestV2CDRsPSQLInjectUnratedCdr(t *testing.T) { return } strCdr1 := &engine.CDR{CGRID: utils.Sha1("bbb1", time.Date(2015, 11, 21, 10, 47, 24, 0, time.UTC).String()), RunID: utils.MetaRaw, - TOR: utils.VOICE, OriginID: "bbb1", OriginHost: "192.168.1.1", Source: "TestV2CDRsPSQLInjectUnratedCdr", RequestType: utils.META_RATED, + ToR: utils.VOICE, OriginID: "bbb1", OriginHost: "192.168.1.1", Source: "TestV2CDRsPSQLInjectUnratedCdr", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2015, 11, 21, 10, 47, 24, 0, time.UTC), AnswerTime: time.Date(2015, 11, 21, 10, 47, 26, 0, time.UTC), Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, @@ -114,7 +114,7 @@ func TestV2CDRsPSQLProcessCdrRated(t *testing.T) { } cdr := &engine.CDR{ CGRID: utils.Sha1("dsafdsaf", time.Date(2015, 12, 13, 18, 15, 26, 0, time.UTC).String()), RunID: utils.DEFAULT_RUNID, - OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "TestV2CDRsPSQLProcessCdrRated", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2015, 12, 13, 18, 15, 26, 0, time.UTC), AnswerTime: time.Date(2015, 12, 13, 18, 15, 26, 0, time.UTC), @@ -135,7 +135,7 @@ func TestV2CDRsPSQLProcessCdrRaw(t *testing.T) { } cdr := &engine.CDR{ CGRID: utils.Sha1("abcdeftg", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, RunID: utils.MetaRaw, - TOR: utils.VOICE, OriginID: "abcdeftg", + ToR: utils.VOICE, OriginID: "abcdeftg", OriginHost: "192.168.1.1", Source: "TestV2CDRsPSQLProcessCdrRaw", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1002", Subject: "1002", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), @@ -211,17 +211,17 @@ func TestV2CDRsPSQLProcessPrepaidCdr(t *testing.T) { } var reply string cdrs := []*engine.CDR{ - &engine.CDR{CGRID: utils.Sha1("dsafdsaf2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("dsafdsaf2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "TestV2CDRsPSQLProcessPrepaidCdr1", RequestType: utils.META_PREPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, Rated: true, }, - &engine.CDR{CGRID: utils.Sha1("abcdeftg2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("abcdeftg2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "TestV2CDRsPSQLProcessPrepaidCdr2", RequestType: utils.META_PREPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1002", Subject: "1002", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, }, - &engine.CDR{CGRID: utils.Sha1("aererfddf2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + &engine.CDR{CGRID: utils.Sha1("aererfddf2", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "TestV2CDRsPSQLProcessPrepaidCdr3", RequestType: utils.META_PREPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, @@ -311,7 +311,7 @@ func TestV2CDRsPSQLProcessRatedExternalCdrBenchmark(t *testing.T) { if !*testLocal { return } - cdr := &engine.ExternalCDR{TOR: utils.VOICE, + cdr := &engine.ExternalCDR{ToR: utils.VOICE, OriginID: "benchratedcdr", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1001", Supplier: "SUPPL1", SetupTime: "2014-08-04T13:00:00Z", AnswerTime: "2014-08-04T13:00:07Z", @@ -360,7 +360,7 @@ func TestV2CDRsPSQLProcessPostpaidExternalCdrBenchmark(t *testing.T) { if !*testLocal { return } - cdr := &engine.ExternalCDR{TOR: utils.VOICE, + cdr := &engine.ExternalCDR{ToR: utils.VOICE, OriginID: "benchpostpaidcdr", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_POSTPAID, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", Supplier: "SUPPL1", SetupTime: "2014-08-04T13:00:00Z", AnswerTime: "2014-08-04T13:00:07Z", diff --git a/cdrc/csv.go b/cdrc/csv.go index 1d668e17a..c6daaaee0 100644 --- a/cdrc/csv.go +++ b/cdrc/csv.go @@ -314,7 +314,7 @@ func (self *CsvRecordsProcessor) recordToStoredCdr(record []string, cdrcId strin } } storedCdr.CGRID = utils.Sha1(storedCdr.OriginID, storedCdr.SetupTime.UTC().String()) - if storedCdr.TOR == utils.DATA && self.cdrcCfgs[cdrcId].DataUsageMultiplyFactor != 0 { + if storedCdr.ToR == utils.DATA && self.cdrcCfgs[cdrcId].DataUsageMultiplyFactor != 0 { storedCdr.Usage = time.Duration(float64(storedCdr.Usage.Nanoseconds()) * self.cdrcCfgs[cdrcId].DataUsageMultiplyFactor) } for _, httpFieldCfg := range lazyHttpFields { // Lazy process the http fields diff --git a/cdrc/csv_test.go b/cdrc/csv_test.go index f741e991a..066f564db 100644 --- a/cdrc/csv_test.go +++ b/cdrc/csv_test.go @@ -50,7 +50,7 @@ func TestCsvRecordForkCdr(t *testing.T) { } expectedCdr := &engine.CDR{ CGRID: utils.Sha1(cdrRow[3], time.Date(2013, 2, 3, 19, 50, 0, 0, time.UTC).String()), - TOR: cdrRow[2], + ToR: cdrRow[2], OriginID: cdrRow[3], OriginHost: "0.0.0.0", // Got it over internal interface Source: "TEST_CDRC", @@ -90,7 +90,7 @@ func TestCsvDataMultiplyFactor(t *testing.T) { var sTime time.Time expectedCdr := &engine.CDR{ CGRID: utils.Sha1("", sTime.String()), - TOR: cdrRow[0], + ToR: cdrRow[0], OriginHost: "0.0.0.0", Source: "TEST_CDRC", Usage: time.Duration(1) * time.Second, @@ -103,7 +103,7 @@ func TestCsvDataMultiplyFactor(t *testing.T) { csvProcessor.cdrcCfgs["*default"].DataUsageMultiplyFactor = 1024 expectedCdr = &engine.CDR{ CGRID: utils.Sha1("", sTime.String()), - TOR: cdrRow[0], + ToR: cdrRow[0], OriginHost: "0.0.0.0", Source: "TEST_CDRC", Usage: time.Duration(1024) * time.Second, @@ -116,7 +116,7 @@ func TestCsvDataMultiplyFactor(t *testing.T) { cdrRow = []string{"*voice", "1"} expectedCdr = &engine.CDR{ CGRID: utils.Sha1("", sTime.String()), - TOR: cdrRow[0], + ToR: cdrRow[0], OriginHost: "0.0.0.0", Source: "TEST_CDRC", Usage: time.Duration(1) * time.Second, diff --git a/cdrc/fwv.go b/cdrc/fwv.go index 1b65415ff..b1fffe60d 100644 --- a/cdrc/fwv.go +++ b/cdrc/fwv.go @@ -205,7 +205,7 @@ func (self *FwvRecordsProcessor) recordToStoredCdr(record string, cfgKey string) if storedCdr.CGRID == "" && storedCdr.OriginID != "" && cfgKey != "*header" { storedCdr.CGRID = utils.Sha1(storedCdr.OriginID, storedCdr.SetupTime.UTC().String()) } - if storedCdr.TOR == utils.DATA && duMultiplyFactor != 0 { + if storedCdr.ToR == utils.DATA && duMultiplyFactor != 0 { storedCdr.Usage = time.Duration(float64(storedCdr.Usage.Nanoseconds()) * duMultiplyFactor) } for _, httpFieldCfg := range lazyHttpFields { // Lazy process the http fields diff --git a/cdre/cdrexporter.go b/cdre/cdrexporter.go index d789b5ba0..00fbe67d9 100644 --- a/cdre/cdrexporter.go +++ b/cdre/cdrexporter.go @@ -229,16 +229,16 @@ func (cdre *CdrExporter) metaHandler(tag, arg string) (string, error) { case META_NRCDRS: return strconv.Itoa(cdre.numberOfRecords), nil case META_DURCDRS: - emulatedCdr := &engine.CDR{TOR: utils.VOICE, Usage: cdre.totalDuration} + emulatedCdr := &engine.CDR{ToR: utils.VOICE, Usage: cdre.totalDuration} return emulatedCdr.FormatUsage(arg), nil case META_SMSUSAGE: - emulatedCdr := &engine.CDR{TOR: utils.SMS, Usage: cdre.totalSmsUsage} + emulatedCdr := &engine.CDR{ToR: utils.SMS, Usage: cdre.totalSmsUsage} return emulatedCdr.FormatUsage(arg), nil case META_GENERICUSAGE: - emulatedCdr := &engine.CDR{TOR: utils.GENERIC, Usage: cdre.totalGenericUsage} + emulatedCdr := &engine.CDR{ToR: utils.GENERIC, Usage: cdre.totalGenericUsage} return emulatedCdr.FormatUsage(arg), nil case META_DATAUSAGE: - emulatedCdr := &engine.CDR{TOR: utils.DATA, Usage: cdre.totalDataUsage} + emulatedCdr := &engine.CDR{ToR: utils.DATA, Usage: cdre.totalDataUsage} return emulatedCdr.FormatUsage(arg), nil case META_COSTCDRS: return strconv.FormatFloat(utils.Round(cdre.totalCost, cdre.roundDecimals, utils.ROUNDING_MIDDLE), 'f', -1, 64), nil @@ -318,11 +318,11 @@ func (cdre *CdrExporter) processCdr(cdr *engine.CDR) error { cdr.ExtraFields = make(map[string]string) } // Cost multiply - if cdre.dataUsageMultiplyFactor != 0.0 && cdr.TOR == utils.DATA { + if cdre.dataUsageMultiplyFactor != 0.0 && cdr.ToR == utils.DATA { cdr.UsageMultiply(cdre.dataUsageMultiplyFactor, cdre.cgrPrecision) - } else if cdre.smsUsageMultiplyFactor != 0 && cdr.TOR == utils.SMS { + } else if cdre.smsUsageMultiplyFactor != 0 && cdr.ToR == utils.SMS { cdr.UsageMultiply(cdre.smsUsageMultiplyFactor, cdre.cgrPrecision) - } else if cdre.genericUsageMultiplyFactor != 0 && cdr.TOR == utils.GENERIC { + } else if cdre.genericUsageMultiplyFactor != 0 && cdr.ToR == utils.GENERIC { cdr.UsageMultiply(cdre.genericUsageMultiplyFactor, cdre.cgrPrecision) } if cdre.costMultiplyFactor != 0.0 { @@ -386,16 +386,16 @@ func (cdre *CdrExporter) processCdr(cdr *engine.CDR) error { cdre.lastCdrATime = cdr.AnswerTime } cdre.numberOfRecords += 1 - if cdr.TOR == utils.VOICE { // Only count duration for non data cdrs + if cdr.ToR == utils.VOICE { // Only count duration for non data cdrs cdre.totalDuration += cdr.Usage } - if cdr.TOR == utils.SMS { // Count usage for SMS + if cdr.ToR == utils.SMS { // Count usage for SMS cdre.totalSmsUsage += cdr.Usage } - if cdr.TOR == utils.GENERIC { // Count usage for GENERIC + if cdr.ToR == utils.GENERIC { // Count usage for GENERIC cdre.totalGenericUsage += cdr.Usage } - if cdr.TOR == utils.DATA { // Count usage for DATA + if cdr.ToR == utils.DATA { // Count usage for DATA cdre.totalDataUsage += cdr.Usage } if cdr.Cost != -1 { diff --git a/cdre/cdrexporter_test.go b/cdre/cdrexporter_test.go index cbb7a4bb3..0960c8b8f 100644 --- a/cdre/cdrexporter_test.go +++ b/cdre/cdrexporter_test.go @@ -30,23 +30,23 @@ import ( func TestCdreGetCombimedCdrFieldVal(t *testing.T) { cfg, _ := config.NewDefaultCGRConfig() cdrs := []*engine.CDR{ - &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", + &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Unix(1383813745, 0).UTC(), AnswerTime: time.Unix(1383813746, 0).UTC(), Usage: time.Duration(10) * time.Second, RunID: "RUN_RTL", Cost: 1.01}, - &engine.CDR{CGRID: utils.Sha1("dsafdsaf2", time.Unix(1383813745, 0).UTC().String()), TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", + &engine.CDR{CGRID: utils.Sha1("dsafdsaf2", time.Unix(1383813745, 0).UTC().String()), ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Unix(1383813745, 0).UTC(), AnswerTime: time.Unix(1383813746, 0).UTC(), Usage: time.Duration(10) * time.Second, RunID: "CUSTOMER1", Cost: 2.01}, - &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", + &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Unix(1383813745, 0).UTC(), AnswerTime: time.Unix(1383813746, 0).UTC(), Usage: time.Duration(10) * time.Second, RunID: "CUSTOMER1", Cost: 3.01}, - &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", + &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Unix(1383813745, 0).UTC(), AnswerTime: time.Unix(1383813746, 0).UTC(), Usage: time.Duration(10) * time.Second, RunID: utils.DEFAULT_RUNID, Cost: 4.01}, - &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", + &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1000", Subject: "1001", Destination: "1002", SetupTime: time.Unix(1383813745, 0).UTC(), AnswerTime: time.Unix(1383813746, 0).UTC(), Usage: time.Duration(10) * time.Second, RunID: "RETAIL1", Cost: 5.01}, @@ -76,7 +76,7 @@ func TestCdreGetCombimedCdrFieldVal(t *testing.T) { func TestGetDateTimeFieldVal(t *testing.T) { cdreTst := new(CdrExporter) - cdrTst := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", + cdrTst := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Unix(1383813745, 0).UTC(), AnswerTime: time.Unix(1383813746, 0).UTC(), Usage: time.Duration(10) * time.Second, RunID: utils.DEFAULT_RUNID, Cost: 1.01, @@ -105,7 +105,7 @@ func TestGetDateTimeFieldVal(t *testing.T) { func TestCdreCdrFieldValue(t *testing.T) { cdre := new(CdrExporter) - cdr := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", + cdr := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Unix(1383813745, 0).UTC(), AnswerTime: time.Unix(1383813746, 0).UTC(), Usage: time.Duration(10) * time.Second, RunID: utils.DEFAULT_RUNID, Cost: 1.01} diff --git a/cdre/csv_test.go b/cdre/csv_test.go index a6361fc4f..0990c7a80 100644 --- a/cdre/csv_test.go +++ b/cdre/csv_test.go @@ -34,7 +34,7 @@ func TestCsvCdrWriter(t *testing.T) { writer := &bytes.Buffer{} cfg, _ := config.NewDefaultCGRConfig() storedCdr1 := &engine.CDR{ - CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", + CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Unix(1383813745, 0).UTC(), AnswerTime: time.Unix(1383813746, 0).UTC(), Usage: time.Duration(10) * time.Second, RunID: utils.DEFAULT_RUNID, @@ -62,7 +62,7 @@ func TestCsvCdrWriter(t *testing.T) { func TestAlternativeFieldSeparator(t *testing.T) { writer := &bytes.Buffer{} cfg, _ := config.NewDefaultCGRConfig() - storedCdr1 := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", + storedCdr1 := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Unix(1383813745, 0).UTC(), AnswerTime: time.Unix(1383813746, 0).UTC(), Usage: time.Duration(10) * time.Second, RunID: utils.DEFAULT_RUNID, diff --git a/cdre/fixedwidth_test.go b/cdre/fixedwidth_test.go index 58e3c3842..ffdd1f747 100644 --- a/cdre/fixedwidth_test.go +++ b/cdre/fixedwidth_test.go @@ -119,7 +119,7 @@ func TestWriteCdr(t *testing.T) { TrailerFields: trailerCfgFlds, } cdr := &engine.CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), - TOR: utils.VOICE, OrderID: 1, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", + ToR: utils.VOICE, OrderID: 1, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), @@ -177,7 +177,7 @@ func TestWriteCdrs(t *testing.T) { TrailerFields: trailerCfgFlds, } cdr1 := &engine.CDR{CGRID: utils.Sha1("aaa1", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), - TOR: utils.VOICE, OrderID: 2, OriginID: "aaa1", OriginHost: "192.168.1.1", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", + ToR: utils.VOICE, OrderID: 2, OriginID: "aaa1", OriginHost: "192.168.1.1", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1010", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), @@ -185,7 +185,7 @@ func TestWriteCdrs(t *testing.T) { ExtraFields: map[string]string{"productnumber": "12341", "fieldextr2": "valextr2"}, } cdr2 := &engine.CDR{CGRID: utils.Sha1("aaa2", time.Date(2013, 11, 7, 7, 42, 20, 0, time.UTC).String()), - TOR: utils.VOICE, OrderID: 4, OriginID: "aaa2", OriginHost: "192.168.1.2", RequestType: utils.META_PREPAID, Direction: "*out", Tenant: "cgrates.org", + ToR: utils.VOICE, OrderID: 4, OriginID: "aaa2", OriginHost: "192.168.1.2", RequestType: utils.META_PREPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1002", Subject: "1002", Destination: "1011", SetupTime: time.Date(2013, 11, 7, 7, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 7, 42, 26, 0, time.UTC), @@ -194,7 +194,7 @@ func TestWriteCdrs(t *testing.T) { } cdr3 := &engine.CDR{} cdr4 := &engine.CDR{CGRID: utils.Sha1("aaa3", time.Date(2013, 11, 7, 9, 42, 18, 0, time.UTC).String()), - TOR: utils.VOICE, OrderID: 3, OriginID: "aaa4", OriginHost: "192.168.1.4", RequestType: utils.META_POSTPAID, Direction: "*out", Tenant: "cgrates.org", + ToR: utils.VOICE, OrderID: 3, OriginID: "aaa4", OriginHost: "192.168.1.4", RequestType: utils.META_POSTPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1004", Subject: "1004", Destination: "1013", SetupTime: time.Date(2013, 11, 7, 9, 42, 18, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 9, 42, 26, 0, time.UTC), diff --git a/config/cfg_data.json b/config/cfg_data.json index a6acc1ee6..77f20a7da 100644 --- a/config/cfg_data.json +++ b/config/cfg_data.json @@ -33,7 +33,7 @@ "run_delay": 1, "cdr_source_id": "csv2", // free form field, tag identifying the source of the CDRs within CDRS database "content_fields":[ // import template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value - {"field_id": "TOR", "value": "~7:s/^(voice|data|sms|generic)$/*$1/"}, + {"field_id": "ToR", "value": "~7:s/^(voice|data|sms|generic)$/*$1/"}, {"field_id": "AnswerTime", "value": "1"}, {"field_id": "Usage", "value": "~9:s/^(\\d+)$/${1}s/"}, ], diff --git a/config/cfg_data2.json b/config/cfg_data2.json index 822dd1f09..67b846168 100644 --- a/config/cfg_data2.json +++ b/config/cfg_data2.json @@ -8,7 +8,7 @@ "data_usage_multiply_factor": 0.000976563, "cdr_source_id": "csv2", // free form field, tag identifying the source of the CDRs within CDRS database "content_fields":[ // import template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value - {"field_id": "TOR", "value": "~7:s/^(voice|data|sms|generic)$/*$1/"}, + {"field_id": "ToR", "value": "~7:s/^(voice|data|sms|generic)$/*$1/"}, {"field_id": "AnswerTime", "value": "2"}, ], }, diff --git a/config/config_defaults.go b/config/config_defaults.go index f37f4f5ec..845ad4141 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -142,7 +142,7 @@ const CGRATES_CFG_JSON = ` "content_fields": [ // template of the exported content fields {"tag": "CGRID", "field_id": "CGRID", "type": "*composed", "value": "CGRID"}, {"tag":"RunID", "field_id": "RunID", "type": "*composed", "value": "RunID"}, - {"tag":"TOR", "field_id": "TOR", "type": "*composed", "value": "TOR"}, + {"tag":"TOR", "field_id": "ToR", "type": "*composed", "value": "ToR"}, {"tag":"OriginID", "field_id": "OriginID", "type": "*composed", "value": "OriginID"}, {"tag":"RequestType", "field_id": "RequestType", "type": "*composed", "value": "RequestType"}, {"tag":"Direction", "field_id": "Direction", "type": "*composed", "value": "Direction"}, @@ -181,7 +181,7 @@ const CGRATES_CFG_JSON = ` "partial_record_cache": "10s", // duration to cache partial records when not pairing "header_fields": [], // template of the import header fields "content_fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value - {"tag": "TOR", "field_id": "TOR", "type": "*composed", "value": "2", "mandatory": true}, + {"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "2", "mandatory": true}, {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "3", "mandatory": true}, {"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "4", "mandatory": true}, {"tag": "Direction", "field_id": "Direction", "type": "*composed", "value": "5", "mandatory": true}, @@ -278,7 +278,7 @@ const CGRATES_CFG_JSON = ` "request_filter": "Subscription-Id>Subscription-Id-Type(0)", // filter requests processed by this processor "continue_on_success": false, // continue to the next template if executed "ccr_fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value - {"tag": "TOR", "field_id": "TOR", "type": "*composed", "value": "^*voice", "mandatory": true}, + {"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "^*voice", "mandatory": true}, {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "Session-Id", "mandatory": true}, {"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "^*users", "mandatory": true}, {"tag": "Direction", "field_id": "Direction", "type": "*composed", "value": "^*out", "mandatory": true}, diff --git a/engine/actions_local_test.go b/engine/actions_local_test.go index 936cc4e0a..c5d30e126 100644 --- a/engine/actions_local_test.go +++ b/engine/actions_local_test.go @@ -113,7 +113,7 @@ func TestActionsLocalSetCdrlogActions(t *testing.T) { t.Error("Unexpected error: ", err.Error()) } else if len(rcvedCdrs) != 1 { t.Error("Unexpected number of CDRs returned: ", len(rcvedCdrs)) - } else if rcvedCdrs[0].TOR != utils.MONETARY || + } else if rcvedCdrs[0].ToR != utils.MONETARY || rcvedCdrs[0].OriginHost != "127.0.0.1" || rcvedCdrs[0].Source != CDRLOG || rcvedCdrs[0].RequestType != utils.META_PREPAID || diff --git a/engine/actions_test.go b/engine/actions_test.go index aacc0a003..2b3f7614c 100644 --- a/engine/actions_test.go +++ b/engine/actions_test.go @@ -1212,7 +1212,7 @@ func TestActionCdrLogParamsWithOverload(t *testing.T) { acnt := &Account{Id: "cgrates.org:dan2904"} cdrlog := &Action{ ActionType: CDRLOG, - ExtraParameters: `{"Subject":"^rif","Destination":"^1234","TOR":"~action_tag:s/^at(.)$/0$1/","AccountId":"~account_id:s/^\\*(.*)$/$1/"}`, + ExtraParameters: `{"Subject":"^rif","Destination":"^1234","ToR":"~action_tag:s/^at(.)$/0$1/","AccountId":"~account_id:s/^\\*(.*)$/$1/"}`, } err := cdrLogAction(acnt, nil, cdrlog, Actions{ &Action{ diff --git a/engine/cdr.go b/engine/cdr.go index 5fdd28d8d..ca0893832 100644 --- a/engine/cdr.go +++ b/engine/cdr.go @@ -33,7 +33,7 @@ import ( func NewCDRFromExternalCDR(extCdr *ExternalCDR, timezone string) (*CDR, error) { var err error - cdr := &CDR{CGRID: extCdr.CGRID, RunID: extCdr.RunID, OrderID: extCdr.OrderID, TOR: extCdr.TOR, OriginID: extCdr.OriginID, OriginHost: extCdr.OriginHost, + cdr := &CDR{CGRID: extCdr.CGRID, RunID: extCdr.RunID, OrderID: extCdr.OrderID, ToR: extCdr.ToR, OriginID: extCdr.OriginID, OriginHost: extCdr.OriginHost, Source: extCdr.Source, RequestType: extCdr.RequestType, Direction: extCdr.Direction, Tenant: extCdr.Tenant, Category: extCdr.Category, Account: extCdr.Account, Subject: extCdr.Subject, Destination: extCdr.Destination, Supplier: extCdr.Supplier, DisconnectCause: extCdr.DisconnectCause, CostSource: extCdr.CostSource, Cost: extCdr.Cost, Rated: extCdr.Rated} @@ -67,7 +67,7 @@ func NewCDRFromExternalCDR(extCdr *ExternalCDR, timezone string) (*CDR, error) { } func NewCDRWithDefaults(cfg *config.CGRConfig) *CDR { - return &CDR{TOR: utils.VOICE, RequestType: cfg.DefaultReqType, Direction: utils.OUT, Tenant: cfg.DefaultTenant, Category: cfg.DefaultCategory, + return &CDR{ToR: utils.VOICE, RequestType: cfg.DefaultReqType, Direction: utils.OUT, Tenant: cfg.DefaultTenant, Category: cfg.DefaultCategory, ExtraFields: make(map[string]string), Cost: -1} } @@ -78,7 +78,7 @@ type CDR struct { OriginHost string // represents the IP address of the host generating the CDR (automatically populated by the server) Source string // formally identifies the source of the CDR (free form field) OriginID string // represents the unique accounting id given by the telecom switch generating the CDR - TOR string // type of record, meta-field, should map to one of the TORs hardcoded inside the server <*voice|*data|*sms|*generic> + ToR string // type of record, meta-field, should map to one of the TORs hardcoded inside the server <*voice|*data|*sms|*generic> RequestType string // matching the supported request types by the **CGRateS**, accepted values are hardcoded in the server . Direction string // matching the supported direction identifiers of the CGRateS <*out> Tenant string // tenant whom this record belongs @@ -126,7 +126,7 @@ func (cdr *CDR) FormatCost(shiftDecimals, roundDecimals int) string { // Formats usage on export func (cdr *CDR) FormatUsage(layout string) string { - if utils.IsSliceMember([]string{utils.DATA, utils.SMS, utils.GENERIC}, cdr.TOR) { + if utils.IsSliceMember([]string{utils.DATA, utils.SMS, utils.GENERIC}, cdr.ToR) { return strconv.FormatFloat(utils.Round(cdr.Usage.Seconds(), 0, utils.ROUNDING_MIDDLE), 'f', -1, 64) } switch layout { @@ -146,7 +146,7 @@ func (cdr *CDR) FieldAsString(rsrFld *utils.RSRField) string { case utils.ORDERID: return rsrFld.ParseValue(strconv.FormatInt(cdr.OrderID, 10)) case utils.TOR: - return rsrFld.ParseValue(cdr.TOR) + return rsrFld.ParseValue(cdr.ToR) case utils.ACCID: return rsrFld.ParseValue(cdr.OriginID) case utils.CDRHOST: @@ -197,7 +197,7 @@ func (cdr *CDR) ParseFieldValue(fieldId, fieldVal, timezone string) error { var err error switch fieldId { case utils.TOR: - cdr.TOR += fieldVal + cdr.ToR += fieldVal case utils.ACCID: cdr.OriginID += fieldVal case utils.REQTYPE: @@ -291,7 +291,7 @@ func (cdr *CDR) AsHttpForm() url.Values { for fld, val := range cdr.ExtraFields { v.Set(fld, val) } - v.Set(utils.TOR, cdr.TOR) + v.Set(utils.TOR, cdr.ToR) v.Set(utils.ACCID, cdr.OriginID) v.Set(utils.CDRHOST, cdr.OriginHost) v.Set(utils.CDRSOURCE, cdr.Source) @@ -411,7 +411,7 @@ func (cdr *CDR) ForkCdr(runId string, RequestTypeFld, directionFld, tenantFld, c var err error frkStorCdr := new(CDR) frkStorCdr.CGRID = cdr.CGRID - frkStorCdr.TOR = cdr.TOR + frkStorCdr.ToR = cdr.ToR frkStorCdr.RunID = runId frkStorCdr.Cost = -1.0 // Default for non-rated CDR frkStorCdr.OriginID = cdr.OriginID @@ -442,7 +442,7 @@ func (cdr *CDR) ForkCdr(runId string, RequestTypeFld, directionFld, tenantFld, c return nil, utils.NewErrMandatoryIeMissing(utils.SUBJECT, subjectFld.Id) } frkStorCdr.Destination = cdr.FieldAsString(destFld) - if primaryMandatory && len(frkStorCdr.Destination) == 0 && frkStorCdr.TOR == utils.VOICE { + if primaryMandatory && len(frkStorCdr.Destination) == 0 && frkStorCdr.ToR == utils.VOICE { return nil, utils.NewErrMandatoryIeMissing(utils.DESTINATION, destFld.Id) } sTimeStr := cdr.FieldAsString(setupTimeFld) @@ -497,7 +497,7 @@ func (cdr *CDR) AsExternalCDR() *ExternalCDR { OriginHost: cdr.OriginHost, Source: cdr.Source, OriginID: cdr.OriginID, - TOR: cdr.TOR, + ToR: cdr.ToR, RequestType: cdr.RequestType, Direction: cdr.Direction, Tenant: cdr.Tenant, @@ -705,7 +705,7 @@ type ExternalCDR struct { OriginHost string Source string OriginID string - TOR string + ToR string RequestType string Direction string Tenant string @@ -729,7 +729,7 @@ type ExternalCDR struct { // Used when authorizing requests from outside, eg ApierV1.GetMaxUsage type UsageRecord struct { - TOR string + ToR string RequestType string Direction string Tenant string @@ -745,7 +745,7 @@ type UsageRecord struct { func (self *UsageRecord) AsStoredCdr(timezone string) (*CDR, error) { var err error - cdr := &CDR{TOR: self.TOR, RequestType: self.RequestType, Direction: self.Direction, Tenant: self.Tenant, Category: self.Category, + cdr := &CDR{ToR: self.ToR, RequestType: self.RequestType, Direction: self.Direction, Tenant: self.Tenant, Category: self.Category, Account: self.Account, Subject: self.Subject, Destination: self.Destination} if cdr.SetupTime, err = utils.ParseTimeDetectLayout(self.SetupTime, timezone); err != nil { return nil, err @@ -768,7 +768,7 @@ func (self *UsageRecord) AsStoredCdr(timezone string) (*CDR, error) { func (self *UsageRecord) AsCallDescriptor(timezone string) (*CallDescriptor, error) { var err error cd := &CallDescriptor{ - TOR: self.TOR, + TOR: self.ToR, Direction: self.Direction, Tenant: self.Tenant, Category: self.Category, diff --git a/engine/cdr_local_test.go b/engine/cdr_local_test.go index c17fe1dfa..823e8f6d5 100644 --- a/engine/cdr_local_test.go +++ b/engine/cdr_local_test.go @@ -34,7 +34,7 @@ func TestHttpJsonPost(t *testing.T) { if !*testLocal { return } - cdrOut := &ExternalCDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + cdrOut := &ExternalCDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "account1", Subject: "tgooiscs0014", Destination: "1002", diff --git a/engine/cdr_test.go b/engine/cdr_test.go index 3c92ae000..4aabc0df1 100644 --- a/engine/cdr_test.go +++ b/engine/cdr_test.go @@ -33,13 +33,13 @@ func TestCDRInterfaces(t *testing.T) { } func TestNewCDRFromExternalCDR(t *testing.T) { - extCdr := &ExternalCDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, + extCdr := &ExternalCDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", Supplier: "SUPPL1", SetupTime: "2013-11-07T08:42:20Z", AnswerTime: "2013-11-07T08:42:26Z", RunID: utils.DEFAULT_RUNID, Usage: "0.00000001", PDD: "7.0", ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, Rated: true, } - eStorCdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, + eStorCdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", Supplier: "SUPPL1", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, @@ -53,7 +53,7 @@ func TestNewCDRFromExternalCDR(t *testing.T) { } func TestCDRClone(t *testing.T) { - storCdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, + storCdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", Supplier: "SUPPL1", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, @@ -65,7 +65,7 @@ func TestCDRClone(t *testing.T) { } func TestFieldAsString(t *testing.T) { - cdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + cdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, @@ -122,7 +122,7 @@ func TestFieldAsString(t *testing.T) { } func TestFieldsAsString(t *testing.T) { - cdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + cdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, @@ -136,7 +136,7 @@ func TestFieldsAsString(t *testing.T) { } func TestPassesFieldFilter(t *testing.T) { - cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, @@ -165,7 +165,7 @@ func TestPassesFieldFilter(t *testing.T) { if pass, _ := cdr.PassesFieldFilter(acntPrefxFltr); pass { t.Error("Passing filter") } - torFltr, _ := utils.NewRSRField(`^TOR::*voice/`) + torFltr, _ := utils.NewRSRField(`^ToR::*voice/`) if pass, _ := cdr.PassesFieldFilter(torFltr); !pass { t.Error("Not passing filter") } @@ -281,7 +281,7 @@ func TestFormatUsage(t *testing.T) { if cdr.FormatUsage("default") != "10" { t.Error("Wrong usage format: ", cdr.FormatUsage("default")) } - cdr = CDR{TOR: utils.DATA, Usage: time.Duration(1640113000000000)} + cdr = CDR{ToR: utils.DATA, Usage: time.Duration(1640113000000000)} if cdr.FormatUsage("default") != "1640113" { t.Error("Wrong usage format: ", cdr.FormatUsage("default")) } @@ -296,7 +296,7 @@ func TestFormatUsage(t *testing.T) { } func TestCDRAsHttpForm(t *testing.T) { - storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, @@ -358,7 +358,7 @@ func TestCDRAsHttpForm(t *testing.T) { } func TestCDRForkCdr(t *testing.T) { - storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, + storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), PDD: time.Duration(200) * time.Millisecond, @@ -373,7 +373,7 @@ func TestCDRForkCdr(t *testing.T) { if err != nil { t.Error("Unexpected error received", err) } - expctSplRatedCdr := &CDR{CGRID: storCdr.CGRID, TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, + expctSplRatedCdr := &CDR{CGRID: storCdr.CGRID, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), PDD: time.Duration(200) * time.Millisecond, AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), Usage: time.Duration(10) * time.Second, Supplier: "suppl1", ExtraFields: map[string]string{"field_extr1": "val_extr1", "field_extr2": "valextr2"}, @@ -384,7 +384,7 @@ func TestCDRForkCdr(t *testing.T) { } func TestCDRForkCdrStaticVals(t *testing.T) { - storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, @@ -409,7 +409,7 @@ func TestCDRForkCdrStaticVals(t *testing.T) { if err != nil { t.Error("Unexpected error received", err) } - expctRatedCdr2 := &CDR{CGRID: storCdr.CGRID, TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_POSTPAID, + expctRatedCdr2 := &CDR{CGRID: storCdr.CGRID, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_POSTPAID, Direction: "*in", Tenant: "cgrates.com", Category: "premium_call", Account: "first_account", Subject: "first_subject", Destination: "1002", SetupTime: time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2013, 12, 7, 8, 42, 26, 0, time.UTC), Usage: time.Duration(12) * time.Second, PDD: time.Duration(3) * time.Second, @@ -429,14 +429,14 @@ func TestCDRForkCdrStaticVals(t *testing.T) { } func TestCDRForkCdrFromMetaDefaults(t *testing.T) { - storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, PDD: time.Duration(4) * time.Second, Supplier: "SUPPL3", ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, } - expctCdr := &CDR{CGRID: storCdr.CGRID, TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, + expctCdr := &CDR{CGRID: storCdr.CGRID, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), Usage: time.Duration(10) * time.Second, PDD: time.Duration(4) * time.Second, Supplier: "SUPPL3", Cost: 1.01, @@ -463,13 +463,13 @@ func TestCDRForkCdrFromMetaDefaults(t *testing.T) { } func TestCDRAsExternalCDR(t *testing.T) { - storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, + storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10), PDD: time.Duration(7) * time.Second, Supplier: "SUPPL1", ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01} - expectOutCdr := &ExternalCDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, + expectOutCdr := &ExternalCDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: "2013-11-07T08:42:20Z", AnswerTime: "2013-11-07T08:42:26Z", RunID: utils.DEFAULT_RUNID, @@ -481,7 +481,7 @@ func TestCDRAsExternalCDR(t *testing.T) { } func TestCDREventFields(t *testing.T) { - cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "dan", Subject: "dans", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 27, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, Supplier: "suppl1", @@ -547,11 +547,11 @@ func TestCDREventFields(t *testing.T) { } func TesUsageReqAsCDR(t *testing.T) { - setupReq := &UsageRecord{TOR: utils.VOICE, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", + setupReq := &UsageRecord{ToR: utils.VOICE, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: "2013-11-07T08:42:20Z", AnswerTime: "2013-11-07T08:42:26Z", Usage: "0.00000001", } - eStorCdr := &CDR{TOR: utils.VOICE, RequestType: utils.META_RATED, Direction: "*out", + eStorCdr := &CDR{ToR: utils.VOICE, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), Usage: time.Duration(10)} if CDR, err := setupReq.AsStoredCdr(""); err != nil { @@ -562,11 +562,11 @@ func TesUsageReqAsCDR(t *testing.T) { } func TestUsageReqAsCD(t *testing.T) { - req := &UsageRecord{TOR: utils.VOICE, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", + req := &UsageRecord{ToR: utils.VOICE, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: "2013-11-07T08:42:20Z", AnswerTime: "2013-11-07T08:42:26Z", Usage: "0.00000001", } - eCD := &CallDescriptor{TOR: req.TOR, Direction: req.Direction, + eCD := &CallDescriptor{TOR: req.ToR, Direction: req.Direction, Tenant: req.Tenant, Category: req.Category, Account: req.Account, Subject: req.Subject, Destination: req.Destination, TimeStart: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), TimeEnd: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).Add(time.Duration(10))} if cd, err := req.AsCallDescriptor(""); err != nil { diff --git a/engine/cdrs.go b/engine/cdrs.go index b1db25c4d..4b1a62e7d 100644 --- a/engine/cdrs.go +++ b/engine/cdrs.go @@ -135,7 +135,7 @@ func (self *CdrServer) RateCDRs(cgrIds, runIds, tors, cdrHosts, cdrSources, Requ } else if rerateRated { costStart = utils.Float64Pointer(0.0) } - cdrs, _, err := self.cdrDb.GetCDRs(&utils.CDRsFilter{CGRIDs: cgrIds, RunIDs: runIds, TORs: tors, Sources: cdrSources, + cdrs, _, err := self.cdrDb.GetCDRs(&utils.CDRsFilter{CGRIDs: cgrIds, RunIDs: runIds, ToRs: tors, Sources: cdrSources, RequestTypes: RequestTypes, Directions: directions, Tenants: tenants, Categories: categories, Accounts: accounts, Subjects: subjects, DestinationPrefixes: destPrefixes, OrderIDStart: orderIdStart, OrderIDEnd: orderIdEnd, AnswerTimeStart: &timeStart, AnswerTimeEnd: &timeEnd, @@ -355,7 +355,7 @@ func (self *CdrServer) getCostFromRater(cdr *CDR) (*CallCost, error) { timeStart = cdr.SetupTime } cd := &CallDescriptor{ - TOR: cdr.TOR, + TOR: cdr.ToR, Direction: cdr.Direction, Tenant: cdr.Tenant, Category: cdr.Category, diff --git a/engine/cdrstats.go b/engine/cdrstats.go index 9f6253cd5..94d17cf51 100644 --- a/engine/cdrstats.go +++ b/engine/cdrstats.go @@ -94,7 +94,7 @@ func (cs *CdrStats) AcceptCdr(cdr *CDR) bool { return false } } - if len(cs.TOR) > 0 && !utils.IsSliceMember(cs.TOR, cdr.TOR) { + if len(cs.TOR) > 0 && !utils.IsSliceMember(cs.TOR, cdr.ToR) { return false } if len(cs.CdrHost) > 0 && !utils.IsSliceMember(cs.CdrHost, cdr.OriginHost) { diff --git a/engine/cgrcdr.go b/engine/cgrcdr.go index 035537ad7..7121070dc 100644 --- a/engine/cgrcdr.go +++ b/engine/cgrcdr.go @@ -61,7 +61,7 @@ func (cgrCdr CgrCdr) getExtraFields() map[string]string { func (cgrCdr CgrCdr) AsStoredCdr(timezone string) *CDR { storCdr := new(CDR) storCdr.CGRID = cgrCdr.getCGRID(timezone) - storCdr.TOR = cgrCdr[utils.TOR] + storCdr.ToR = cgrCdr[utils.TOR] storCdr.OriginID = cgrCdr[utils.ACCID] storCdr.OriginHost = cgrCdr[utils.CDRHOST] storCdr.Source = cgrCdr[utils.CDRSOURCE] diff --git a/engine/cgrcdr_test.go b/engine/cgrcdr_test.go index 35ddb2d73..82648affe 100644 --- a/engine/cgrcdr_test.go +++ b/engine/cgrcdr_test.go @@ -40,7 +40,7 @@ func TestCgrCdrAsCDR(t *testing.T) { utils.ACCOUNT: "1001", utils.SUBJECT: "1001", utils.DESTINATION: "1002", utils.SETUP_TIME: "2013-11-07T08:42:20Z", utils.ANSWER_TIME: "2013-11-07T08:42:26Z", utils.USAGE: "10", utils.SUPPLIER: "SUPPL1", "field_extr1": "val_extr1", "fieldextr2": "valextr2"} setupTime, _ := utils.ParseTimeDetectLayout(cgrCdr[utils.SETUP_TIME], "") - expctRtCdr := &CDR{CGRID: utils.Sha1(cgrCdr[utils.ACCID], setupTime.String()), TOR: utils.VOICE, OriginID: cgrCdr[utils.ACCID], OriginHost: cgrCdr[utils.CDRHOST], + expctRtCdr := &CDR{CGRID: utils.Sha1(cgrCdr[utils.ACCID], setupTime.String()), ToR: utils.VOICE, OriginID: cgrCdr[utils.ACCID], OriginHost: cgrCdr[utils.CDRHOST], Source: cgrCdr[utils.CDRSOURCE], RequestType: cgrCdr[utils.REQTYPE], Direction: cgrCdr[utils.DIRECTION], Tenant: cgrCdr[utils.TENANT], Category: cgrCdr[utils.CATEGORY], Account: cgrCdr[utils.ACCOUNT], Subject: cgrCdr[utils.SUBJECT], @@ -60,7 +60,7 @@ func TestReplicatedCgrCdrAsCDR(t *testing.T) { utils.ACCOUNT: "1001", utils.SUBJECT: "1001", utils.DESTINATION: "1002", utils.SETUP_TIME: "2013-11-07T08:42:20Z", utils.PDD: "0.200", utils.ANSWER_TIME: "2013-11-07T08:42:26Z", utils.USAGE: "10", utils.SUPPLIER: "SUPPL1", utils.DISCONNECT_CAUSE: "NORMAL_CLEARING", utils.COST: "0.12", utils.RATED: "true", "field_extr1": "val_extr1", "fieldextr2": "valextr2"} expctRtCdr := &CDR{CGRID: cgrCdr[utils.CGRID], - TOR: cgrCdr[utils.TOR], + ToR: cgrCdr[utils.TOR], OriginID: cgrCdr[utils.ACCID], OriginHost: cgrCdr[utils.CDRHOST], Source: cgrCdr[utils.CDRSOURCE], diff --git a/engine/fscdr.go b/engine/fscdr.go index 21226a190..8ab7ad753 100644 --- a/engine/fscdr.go +++ b/engine/fscdr.go @@ -121,7 +121,7 @@ func (fsCdr FSCdr) searchExtraField(field string, body map[string]interface{}) ( func (fsCdr FSCdr) AsStoredCdr(timezone string) *CDR { storCdr := new(CDR) storCdr.CGRID = fsCdr.getCGRID(timezone) - storCdr.TOR = utils.VOICE + storCdr.ToR = utils.VOICE storCdr.OriginID = fsCdr.vars[FS_UUID] storCdr.OriginHost = fsCdr.vars[FS_IP] storCdr.Source = FS_CDR_SOURCE diff --git a/engine/fscdr_test.go b/engine/fscdr_test.go index 52551cbd6..bdd7ffa50 100644 --- a/engine/fscdr_test.go +++ b/engine/fscdr_test.go @@ -55,7 +55,7 @@ func TestCDRFields(t *testing.T) { } setupTime, _ := utils.ParseTimeDetectLayout("1436280728", "") answerTime, _ := utils.ParseTimeDetectLayout("1436280728", "") - expctCDR := &CDR{CGRID: "164b0422fdc6a5117031b427439482c6a4f90e41", TOR: utils.VOICE, OriginID: "e3133bf7-dcde-4daf-9663-9a79ffcef5ad", + expctCDR := &CDR{CGRID: "164b0422fdc6a5117031b427439482c6a4f90e41", ToR: utils.VOICE, OriginID: "e3133bf7-dcde-4daf-9663-9a79ffcef5ad", OriginHost: "127.0.0.1", Source: "freeswitch_json", Direction: utils.OUT, Category: "call", RequestType: utils.META_PREPAID, Tenant: "cgrates.org", Account: "1001", Subject: "1001", Destination: "1003", SetupTime: setupTime, PDD: time.Duration(28) * time.Millisecond, AnswerTime: answerTime, Usage: time.Duration(66) * time.Second, Supplier: "supplier1", DisconnectCause: "NORMAL_CLEARING", ExtraFields: map[string]string{"sip_user_agent": "PJSUA v2.3 Linux-3.2.0.4/x86_64/glibc-2.13"}, Cost: -1} diff --git a/engine/responder_test.go b/engine/responder_test.go index 3011d79bf..526652491 100644 --- a/engine/responder_test.go +++ b/engine/responder_test.go @@ -56,7 +56,7 @@ func TestResponderGetDerivedChargers(t *testing.T) { func TestResponderGetDerivedMaxSessionTime(t *testing.T) { testTenant := "vdf" - cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: testTenant, Category: "call", Account: "dan", Subject: "dan", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, @@ -122,7 +122,7 @@ func TestResponderGetDerivedMaxSessionTime(t *testing.T) { func TestResponderGetSessionRuns(t *testing.T) { testTenant := "vdf" - cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf", + cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_PREPAID, Direction: "*out", Tenant: testTenant, Category: "call", Account: "dan2", Subject: "dan2", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), PDD: 3 * time.Second, AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), Supplier: "suppl1", diff --git a/engine/stats_test.go b/engine/stats_test.go index f291b9f87..def739f13 100644 --- a/engine/stats_test.go +++ b/engine/stats_test.go @@ -56,7 +56,7 @@ func TestStatsValue(t *testing.T) { func TestStatsSimplifyCDR(t *testing.T) { cdr := &CDR{ - TOR: "tor", + ToR: "tor", OriginID: "accid", OriginHost: "cdrhost", Source: "cdrsource", @@ -85,7 +85,7 @@ func TestStatsSimplifyCDR(t *testing.T) { func TestAcceptCdr(t *testing.T) { sq := NewStatsQueue(nil) cdr := &CDR{ - TOR: "tor", + ToR: "tor", OriginID: "accid", OriginHost: "cdrhost", Source: "cdrsource", diff --git a/engine/storage_cdrs_it_test.go b/engine/storage_cdrs_it_test.go index 8f295664c..deb117fd8 100644 --- a/engine/storage_cdrs_it_test.go +++ b/engine/storage_cdrs_it_test.go @@ -88,7 +88,7 @@ func testSetCDR(cdrStorage CdrStorage) error { OriginHost: "127.0.0.1", Source: "testSetCDRs", OriginID: "testevent1", - TOR: utils.VOICE, + ToR: utils.VOICE, RequestType: utils.META_PREPAID, Direction: utils.OUT, Tenant: "cgrates.org", @@ -119,7 +119,7 @@ func testSetCDR(cdrStorage CdrStorage) error { OriginHost: "127.0.0.1", Source: "testSetCDRs", OriginID: "testevent1", - TOR: utils.VOICE, + ToR: utils.VOICE, RequestType: utils.META_PREPAID, Direction: utils.OUT, Tenant: "cgrates.org", diff --git a/engine/storage_mongo_tp.go b/engine/storage_mongo_tp.go index e0674f177..55364ad7f 100644 --- a/engine/storage_mongo_tp.go +++ b/engine/storage_mongo_tp.go @@ -758,7 +758,7 @@ func (ms *MongoStorage) GetCDRs(qryFltr *utils.CDRsFilter) ([]*CDR, int64, error filters := bson.M{ "cgrid": bson.M{"$in": qryFltr.CGRIDs, "$nin": qryFltr.NotCGRIDs}, "mediationrunid": bson.M{"$in": qryFltr.RunIDs, "$nin": qryFltr.NotRunIDs}, - "tor": bson.M{"$in": qryFltr.TORs, "$nin": qryFltr.NotTORs}, + "tor": bson.M{"$in": qryFltr.ToRs, "$nin": qryFltr.NotToRs}, "cdrhost": bson.M{"$in": qryFltr.OriginHosts, "$nin": qryFltr.NotOriginHosts}, "cdrsource": bson.M{"$in": qryFltr.Sources, "$nin": qryFltr.NotSources}, "reqtype": bson.M{"$in": qryFltr.RequestTypes, "$nin": qryFltr.NotRequestTypes}, diff --git a/engine/storage_sql.go b/engine/storage_sql.go index b953d66e1..886a2f941 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -628,7 +628,7 @@ func (self *SQLStorage) SetCDR(cdr *CDR, allowUpdate bool) error { OriginHost: cdr.OriginHost, Source: cdr.Source, OriginID: cdr.OriginID, - Tor: cdr.TOR, + Tor: cdr.ToR, RequestType: cdr.RequestType, Direction: cdr.Direction, Tenant: cdr.Tenant, @@ -660,7 +660,7 @@ func (self *SQLStorage) SetCDR(cdr *CDR, allowUpdate bool) error { OriginHost: cdr.OriginHost, Source: cdr.Source, OriginID: cdr.OriginID, - Tor: cdr.TOR, + Tor: cdr.ToR, RequestType: cdr.RequestType, Direction: cdr.Direction, Tenant: cdr.Tenant, @@ -714,11 +714,11 @@ func (self *SQLStorage) GetCDRs(qryFltr *utils.CDRsFilter) ([]*CDR, int64, error if len(qryFltr.NotRunIDs) != 0 { q = q.Where("run_id not in (?)", qryFltr.NotRunIDs) } - if len(qryFltr.TORs) != 0 { - q = q.Where("tor in (?)", qryFltr.TORs) + if len(qryFltr.ToRs) != 0 { + q = q.Where("tor in (?)", qryFltr.ToRs) } - if len(qryFltr.NotTORs) != 0 { - q = q.Where("tor not in (?)", qryFltr.NotTORs) + if len(qryFltr.NotToRs) != 0 { + q = q.Where("tor not in (?)", qryFltr.NotToRs) } if len(qryFltr.OriginHosts) != 0 { q = q.Where("origin_host in (?)", qryFltr.OriginHosts) @@ -932,7 +932,7 @@ func (self *SQLStorage) GetCDRs(qryFltr *utils.CDRsFilter) ([]*CDR, int64, error OriginHost: result.OriginHost, Source: result.Source, OriginID: result.OriginID, - TOR: result.Tor, + ToR: result.Tor, RequestType: result.RequestType, Direction: result.Direction, Tenant: result.Tenant, diff --git a/engine/suretax_test.go b/engine/suretax_test.go index 0f92f7f2a..8e9fce485 100644 --- a/engine/suretax_test.go +++ b/engine/suretax_test.go @@ -30,7 +30,7 @@ import ( func TestNewSureTaxRequest(t *testing.T) { CGRID := utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()) - cdr := &CDR{CGRID: CGRID, OrderID: 123, TOR: utils.VOICE, + cdr := &CDR{CGRID: CGRID, OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", Supplier: "SUPPL1", SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID, diff --git a/engine/users_test.go b/engine/users_test.go index 26e0bcd35..e21a926dd 100644 --- a/engine/users_test.go +++ b/engine/users_test.go @@ -582,16 +582,16 @@ func TestUsersAddUpdateRemoveIndexes(t *testing.T) { func TestUsersUsageRecordGetLoadUserProfile(t *testing.T) { userService = &UserMap{ table: map[string]map[string]string{ - "test:user": map[string]string{"TOR": "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"}, - ":user": map[string]string{"TOR": "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"}, - "test:": map[string]string{"TOR": "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"}, - "test1:user1": map[string]string{"TOR": "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13"}, + "test:user": map[string]string{utils.TOR: "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"}, + ":user": map[string]string{utils.TOR: "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"}, + "test:": map[string]string{utils.TOR: "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"}, + "test1:user1": map[string]string{utils.TOR: "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13"}, }, index: make(map[string]map[string]bool), } ur := &UsageRecord{ - TOR: utils.USERS, + ToR: utils.USERS, RequestType: utils.USERS, Direction: "*out", Tenant: "", @@ -609,7 +609,7 @@ func TestUsersUsageRecordGetLoadUserProfile(t *testing.T) { t.Error("Error loading user profile: ", err) } expected := &UsageRecord{ - TOR: "04", + ToR: "04", RequestType: "4", Direction: "*out", Tenant: "", @@ -629,16 +629,16 @@ func TestUsersUsageRecordGetLoadUserProfile(t *testing.T) { func TestUsersExternalCDRGetLoadUserProfileExtraFields(t *testing.T) { userService = &UserMap{ table: map[string]map[string]string{ - "test:user": map[string]string{"TOR": "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"}, - ":user": map[string]string{"TOR": "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"}, - "test:": map[string]string{"TOR": "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"}, - "test1:user1": map[string]string{"TOR": "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13", "Test": "1"}, + "test:user": map[string]string{utils.TOR: "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"}, + ":user": map[string]string{utils.TOR: "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"}, + "test:": map[string]string{utils.TOR: "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"}, + "test1:user1": map[string]string{utils.TOR: "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13", "Test": "1"}, }, index: make(map[string]map[string]bool), } ur := &ExternalCDR{ - TOR: utils.USERS, + ToR: utils.USERS, RequestType: utils.USERS, Direction: "*out", Tenant: "", @@ -659,7 +659,7 @@ func TestUsersExternalCDRGetLoadUserProfileExtraFields(t *testing.T) { t.Error("Error loading user profile: ", err) } expected := &ExternalCDR{ - TOR: "04", + ToR: "04", RequestType: "4", Direction: "*out", Tenant: "", @@ -682,16 +682,16 @@ func TestUsersExternalCDRGetLoadUserProfileExtraFields(t *testing.T) { func TestUsersExternalCDRGetLoadUserProfileExtraFieldsNotFound(t *testing.T) { userService = &UserMap{ table: map[string]map[string]string{ - "test:user": map[string]string{"TOR": "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"}, - ":user": map[string]string{"TOR": "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"}, - "test:": map[string]string{"TOR": "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"}, - "test1:user1": map[string]string{"TOR": "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13", "Test": "2"}, + "test:user": map[string]string{utils.TOR: "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"}, + ":user": map[string]string{utils.TOR: "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"}, + "test:": map[string]string{utils.TOR: "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"}, + "test1:user1": map[string]string{utils.TOR: "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13", "Test": "2"}, }, index: make(map[string]map[string]bool), } ur := &ExternalCDR{ - TOR: utils.USERS, + ToR: utils.USERS, RequestType: utils.USERS, Direction: "*out", Tenant: "", @@ -716,16 +716,16 @@ func TestUsersExternalCDRGetLoadUserProfileExtraFieldsNotFound(t *testing.T) { func TestUsersExternalCDRGetLoadUserProfileExtraFieldsSet(t *testing.T) { userService = &UserMap{ table: map[string]map[string]string{ - "test:user": map[string]string{"TOR": "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"}, - ":user": map[string]string{"TOR": "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"}, - "test:": map[string]string{"TOR": "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"}, - "test1:user1": map[string]string{"TOR": "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13", "Test": "1", "Best": "BestValue"}, + "test:user": map[string]string{utils.TOR: "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"}, + ":user": map[string]string{utils.TOR: "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"}, + "test:": map[string]string{utils.TOR: "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"}, + "test1:user1": map[string]string{utils.TOR: "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13", "Test": "1", "Best": "BestValue"}, }, index: make(map[string]map[string]bool), } ur := &ExternalCDR{ - TOR: utils.USERS, + ToR: utils.USERS, RequestType: utils.USERS, Direction: "*out", Tenant: "", @@ -747,7 +747,7 @@ func TestUsersExternalCDRGetLoadUserProfileExtraFieldsSet(t *testing.T) { t.Error("Error loading user profile: ", err) } expected := &ExternalCDR{ - TOR: "04", + ToR: "04", RequestType: "4", Direction: "*out", Tenant: "", @@ -772,7 +772,7 @@ func TestUsersCallDescLoadUserProfile(t *testing.T) { userService = &UserMap{ table: map[string]map[string]string{ "cgrates.org:dan": map[string]string{"RequestType": "*prepaid", "Category": "call1", "Account": "dan", "Subject": "dan", "Cli": "+4986517174963"}, - "cgrates.org:danvoice": map[string]string{"TOR": "*voice", "RequestType": "*prepaid", "Category": "call1", "Account": "dan", "Subject": "0723"}, + "cgrates.org:danvoice": map[string]string{utils.TOR: "*voice", "RequestType": "*prepaid", "Category": "call1", "Account": "dan", "Subject": "0723"}, "cgrates:rif": map[string]string{"RequestType": "*postpaid", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726"}, }, index: make(map[string]map[string]bool), @@ -813,14 +813,14 @@ func TestUsersCDRLoadUserProfile(t *testing.T) { userService = &UserMap{ table: map[string]map[string]string{ "cgrates.org:dan": map[string]string{"RequestType": "*prepaid", "Category": "call1", "Account": "dan", "Subject": "dan", "Cli": "+4986517174963"}, - "cgrates.org:danvoice": map[string]string{"TOR": "*voice", "RequestType": "*prepaid", "Category": "call1", "Account": "dan", "Subject": "0723"}, + "cgrates.org:danvoice": map[string]string{utils.TOR: "*voice", "RequestType": "*prepaid", "Category": "call1", "Account": "dan", "Subject": "0723"}, "cgrates:rif": map[string]string{"RequestType": "*postpaid", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726"}, }, index: make(map[string]map[string]bool), } startTime := time.Now() cdr := &CDR{ - TOR: "*sms", + ToR: "*sms", RequestType: utils.USERS, Tenant: utils.USERS, Category: utils.USERS, @@ -833,7 +833,7 @@ func TestUsersCDRLoadUserProfile(t *testing.T) { ExtraFields: map[string]string{"Cli": "+4986517174963"}, } expected := &CDR{ - TOR: "*sms", + ToR: "*sms", RequestType: "*prepaid", Tenant: "cgrates.org", Category: "call1", diff --git a/general_tests/auth_test.go b/general_tests/auth_test.go index 26d686735..b9069716e 100644 --- a/general_tests/auth_test.go +++ b/general_tests/auth_test.go @@ -93,7 +93,7 @@ RP_ANY,DR_ANY_1CNT,*any,10` } func TestAuthPostpaidNoAcnt(t *testing.T) { - cdr := &engine.CDR{TOR: utils.VOICE, RequestType: utils.META_POSTPAID, Direction: "*out", Tenant: "cgrates.org", + cdr := &engine.CDR{ToR: utils.VOICE, RequestType: utils.META_POSTPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "nonexistent", Subject: "testauthpostpaid1", Destination: "4986517174963", SetupTime: time.Date(2015, 8, 27, 11, 26, 0, 0, time.UTC)} var maxSessionTime float64 @@ -104,7 +104,7 @@ func TestAuthPostpaidNoAcnt(t *testing.T) { func TestAuthPostpaidNoDestination(t *testing.T) { // Test subject which does not have destination attached - cdr := &engine.CDR{TOR: utils.VOICE, RequestType: utils.META_POSTPAID, Direction: "*out", Tenant: "cgrates.org", + cdr := &engine.CDR{ToR: utils.VOICE, RequestType: utils.META_POSTPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "testauthpostpaid1", Subject: "testauthpostpaid1", Destination: "441231234", SetupTime: time.Date(2015, 8, 27, 11, 26, 0, 0, time.UTC)} var maxSessionTime float64 @@ -115,7 +115,7 @@ func TestAuthPostpaidNoDestination(t *testing.T) { func TestAuthPostpaidFallbackDest(t *testing.T) { // Test subject which has fallback for destination - cdr := &engine.CDR{TOR: utils.VOICE, RequestType: utils.META_POSTPAID, Direction: "*out", Tenant: "cgrates.org", + cdr := &engine.CDR{ToR: utils.VOICE, RequestType: utils.META_POSTPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "testauthpostpaid1", Subject: "testauthpostpaid2", Destination: "441231234", SetupTime: time.Date(2015, 8, 27, 11, 26, 0, 0, time.UTC)} var maxSessionTime float64 @@ -128,7 +128,7 @@ func TestAuthPostpaidFallbackDest(t *testing.T) { func TestAuthPostpaidWithDestination(t *testing.T) { // Test subject which does not have destination attached - cdr := &engine.CDR{TOR: utils.VOICE, RequestType: utils.META_POSTPAID, Direction: "*out", Tenant: "cgrates.org", + cdr := &engine.CDR{ToR: utils.VOICE, RequestType: utils.META_POSTPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "testauthpostpaid1", Subject: "testauthpostpaid1", Destination: "4986517174963", SetupTime: time.Date(2015, 8, 27, 11, 26, 0, 0, time.UTC)} var maxSessionTime float64 diff --git a/general_tests/cdrs_replication_it_test.go b/general_tests/cdrs_replication_it_test.go index 92a046679..66a682f7a 100644 --- a/general_tests/cdrs_replication_it_test.go +++ b/general_tests/cdrs_replication_it_test.go @@ -91,7 +91,7 @@ func TestCdrsHttpCdrReplication(t *testing.T) { t.Fatal("Could not connect to rater: ", err.Error()) } testCdr1 := &engine.CDR{CGRID: utils.Sha1("httpjsonrpc1", time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC).String()), - TOR: utils.VOICE, OriginID: "httpjsonrpc1", OriginHost: "192.168.1.1", Source: "UNKNOWN", RequestType: utils.META_PSEUDOPREPAID, + ToR: utils.VOICE, OriginID: "httpjsonrpc1", OriginHost: "192.168.1.1", Source: "UNKNOWN", RequestType: utils.META_PSEUDOPREPAID, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2013, 12, 7, 8, 42, 26, 0, time.UTC), Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, @@ -118,7 +118,7 @@ func TestCdrsHttpCdrReplication(t *testing.T) { rcvAnswerTime, _ := utils.ParseTimeDetectLayout(rcvedCdrs[0].AnswerTime, "") //rcvUsage, _ := utils.ParseDurationWithSecs(rcvedCdrs[0].Usage) if rcvedCdrs[0].CGRID != testCdr1.CGRID || - rcvedCdrs[0].TOR != testCdr1.TOR || + rcvedCdrs[0].ToR != testCdr1.ToR || rcvedCdrs[0].OriginHost != testCdr1.OriginHost || rcvedCdrs[0].Source != testCdr1.Source || rcvedCdrs[0].RequestType != testCdr1.RequestType || diff --git a/general_tests/fsevcorelate_test.go b/general_tests/fsevcorelate_test.go index e41989fc8..898be1012 100644 --- a/general_tests/fsevcorelate_test.go +++ b/general_tests/fsevcorelate_test.go @@ -561,8 +561,8 @@ func TestEvCdrCorelate(t *testing.T) { if evStoredCdr.CGRID != jsnStoredCdr.CGRID { t.Errorf("evStoredCdr.CGRID: %s, jsnStoredCdr.CGRID: %s", evStoredCdr.CGRID, jsnStoredCdr.CGRID) } - if evStoredCdr.TOR != jsnStoredCdr.TOR { - t.Errorf("evStoredCdr.TOR: %s, jsnStoredCdr.TOR: %s", evStoredCdr.TOR, jsnStoredCdr.TOR) + if evStoredCdr.ToR != jsnStoredCdr.ToR { + t.Errorf("evStoredCdr.ToR: %s, jsnStoredCdr.ToR: %s", evStoredCdr.ToR, jsnStoredCdr.ToR) } if evStoredCdr.OriginID != jsnStoredCdr.OriginID { t.Errorf("evStoredCdr.OriginID: %s, jsnStoredCdr.OriginID: %s", evStoredCdr.OriginID, jsnStoredCdr.OriginID) diff --git a/general_tests/suretax_it_test.go b/general_tests/suretax_it_test.go index 6358d8a59..43d9575c9 100644 --- a/general_tests/suretax_it_test.go +++ b/general_tests/suretax_it_test.go @@ -133,7 +133,7 @@ func TestSTIProcessExternalCdr(t *testing.T) { if !*testSureTax { return } - cdr := &engine.ExternalCDR{TOR: utils.VOICE, + cdr := &engine.ExternalCDR{ToR: utils.VOICE, OriginID: "teststicdr1", OriginHost: "192.168.1.1", Source: "STI_TEST", RequestType: utils.META_RATED, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "+14082342500", Destination: "+16268412300", Supplier: "SUPPL1", SetupTime: "2015-10-18T13:00:00Z", AnswerTime: "2015-10-18T13:00:00Z", diff --git a/general_tests/tutorial_local_test.go b/general_tests/tutorial_local_test.go index d5c389c2f..865915188 100644 --- a/general_tests/tutorial_local_test.go +++ b/general_tests/tutorial_local_test.go @@ -418,7 +418,7 @@ func TestTutLocalDerivedMaxSessionTime(t *testing.T) { tStart := time.Date(2014, 8, 4, 13, 0, 0, 0, time.UTC) ev := engine.CDR{ CGRID: utils.Sha1("testevent1", tStart.String()), - TOR: utils.VOICE, + ToR: utils.VOICE, OriginID: "testevent1", OriginHost: "127.0.0.1", RequestType: utils.META_PREPAID, @@ -447,7 +447,7 @@ func TestTutLocalMaxUsage(t *testing.T) { if !*testLocal { return } - setupReq := &engine.UsageRecord{TOR: utils.VOICE, RequestType: utils.META_PREPAID, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", + setupReq := &engine.UsageRecord{ToR: utils.VOICE, RequestType: utils.META_PREPAID, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1001", SetupTime: "2014-08-04T13:00:00Z", Usage: "1", } @@ -457,7 +457,7 @@ func TestTutLocalMaxUsage(t *testing.T) { } else if maxTime != 1 { t.Errorf("Calling ApierV2.MaxUsage got maxTime: %f", maxTime) } - setupReq = &engine.UsageRecord{TOR: utils.VOICE, RequestType: utils.META_RATED, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", + setupReq = &engine.UsageRecord{ToR: utils.VOICE, RequestType: utils.META_RATED, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "test_max_usage", Destination: "1001", SetupTime: "2014-08-04T13:00:00Z", } @@ -473,7 +473,7 @@ func TestTutLocalDebitUsage(t *testing.T) { if !*testLocal { return } - setupReq := &engine.UsageRecord{TOR: utils.VOICE, RequestType: utils.META_PREPAID, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", + setupReq := &engine.UsageRecord{ToR: utils.VOICE, RequestType: utils.META_PREPAID, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1001", AnswerTime: "2014-08-04T13:00:00Z", Usage: "1", } @@ -490,7 +490,7 @@ func TestTutLocalProcessExternalCdr(t *testing.T) { if !*testLocal { return } - cdr := &engine.ExternalCDR{TOR: utils.VOICE, + cdr := &engine.ExternalCDR{ToR: utils.VOICE, OriginID: "testextcdr1", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1001", Supplier: "SUPPL1", SetupTime: "2014-08-04T13:00:00Z", AnswerTime: "2014-08-04T13:00:07Z", @@ -509,7 +509,7 @@ func TestTutLocalProcessExternalCdrUP(t *testing.T) { if !*testLocal { return } - cdr := &engine.ExternalCDR{TOR: utils.VOICE, + cdr := &engine.ExternalCDR{ToR: utils.VOICE, OriginID: "testextcdr2", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, Direction: utils.OUT, RequestType: utils.USERS, Tenant: utils.USERS, Account: utils.USERS, Destination: "1001", Supplier: "SUPPL1", SetupTime: "2014-08-04T13:00:00Z", AnswerTime: "2014-08-04T13:00:07Z", @@ -524,7 +524,7 @@ func TestTutLocalProcessExternalCdrUP(t *testing.T) { } time.Sleep(time.Duration(*waitRater) * time.Millisecond) eCdr := &engine.ExternalCDR{CGRID: "63a8d2bfeca2cfb790826c3ec461696d6574cfde", OrderID: 2, - TOR: utils.VOICE, + ToR: utils.VOICE, OriginID: "testextcdr2", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "1004", Subject: "1004", Destination: "1001", Supplier: "SUPPL1", SetupTime: time.Date(2014, 8, 4, 13, 0, 0, 0, time.UTC).Local().Format(time.RFC3339), AnswerTime: time.Date(2014, 8, 4, 13, 0, 7, 0, time.UTC).Local().Format(time.RFC3339), @@ -541,7 +541,7 @@ func TestTutLocalProcessExternalCdrUP(t *testing.T) { if cdrs[0].CGRID != eCdr.CGRID { t.Errorf("Unexpected CGRID for CDR: %+v", cdrs[0]) } - if cdrs[0].TOR != eCdr.TOR { + if cdrs[0].ToR != eCdr.ToR { t.Errorf("Unexpected TOR for CDR: %+v", cdrs[0]) } if cdrs[0].Source != eCdr.Source { @@ -590,7 +590,7 @@ func TestTutLocalCostErrors(t *testing.T) { if !*testLocal { return } - cdr := &engine.ExternalCDR{TOR: utils.VOICE, + cdr := &engine.ExternalCDR{ToR: utils.VOICE, OriginID: "testtutlocal_1", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: utils.OUT, Tenant: "cgrates.org", Category: "fake", Account: "2001", Subject: "2001", Destination: "1001", Supplier: "SUPPL1", SetupTime: "2014-08-04T13:00:00Z", AnswerTime: "2014-08-04T13:00:07Z", @@ -617,7 +617,7 @@ func TestTutLocalCostErrors(t *testing.T) { t.Errorf("Unexpected Cost for Cdr received: %+v", cdrs[0]) } } - cdr2 := &engine.ExternalCDR{TOR: utils.VOICE, + cdr2 := &engine.ExternalCDR{ToR: utils.VOICE, OriginID: "testtutlocal_2", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_POSTPAID, Direction: utils.OUT, Tenant: "cgrates.org", Category: "fake", Account: "2002", Subject: "2002", Destination: "1001", Supplier: "SUPPL1", SetupTime: "2014-08-04T13:00:00Z", AnswerTime: "2014-08-04T13:00:07Z", @@ -642,7 +642,7 @@ func TestTutLocalCostErrors(t *testing.T) { t.Errorf("Unexpected Cost for Cdr received: %+v", cdrs[0]) } } - cdr3 := &engine.ExternalCDR{TOR: utils.VOICE, + cdr3 := &engine.ExternalCDR{ToR: utils.VOICE, OriginID: "testtutlocal_3", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_POSTPAID, Direction: utils.OUT, Tenant: "cgrates.org", Category: "fake", Account: "1001", Subject: "1001", Destination: "2002", Supplier: "SUPPL1", SetupTime: "2014-08-04T13:00:00Z", AnswerTime: "2014-08-04T13:00:07Z", @@ -822,13 +822,13 @@ func TestTutLocalLcrQos(t *testing.T) { } // Post some CDRs to influence stats testCdr1 := &engine.CDR{CGRID: utils.Sha1("testcdr1", time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC).String()), - TOR: utils.VOICE, OriginID: "testcdr1", OriginHost: "192.168.1.1", Source: "TEST_QOS_LCR", RequestType: utils.META_RATED, + ToR: utils.VOICE, OriginID: "testcdr1", OriginHost: "192.168.1.1", Source: "TEST_QOS_LCR", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2014, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2014, 12, 7, 8, 42, 26, 0, time.UTC), Usage: time.Duration(2) * time.Minute, Supplier: "suppl1", ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}} testCdr2 := &engine.CDR{CGRID: utils.Sha1("testcdr2", time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC).String()), - TOR: utils.VOICE, OriginID: "testcdr2", OriginHost: "192.168.1.1", Source: "TEST_QOS_LCR", RequestType: utils.META_RATED, + ToR: utils.VOICE, OriginID: "testcdr2", OriginHost: "192.168.1.1", Source: "TEST_QOS_LCR", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1002", Subject: "1002", Destination: "1003", SetupTime: time.Date(2014, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2014, 12, 7, 8, 42, 26, 0, time.UTC), Usage: time.Duration(90) * time.Second, Supplier: "suppl2", @@ -860,7 +860,7 @@ func TestTutLocalLcrQos(t *testing.T) { // t.Errorf("Expecting: %+v, %+v, received: %+v, %+v", eStLcr.SupplierCosts[0], eStLcr.SupplierCosts[1], lcr.SupplierCosts[0], lcr.SupplierCosts[1]) } testCdr3 := &engine.CDR{CGRID: utils.Sha1("testcdr3", time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC).String()), - TOR: utils.VOICE, OriginID: "testcdr3", OriginHost: "192.168.1.1", Source: "TEST_QOS_LCR", RequestType: utils.META_RATED, + ToR: utils.VOICE, OriginID: "testcdr3", OriginHost: "192.168.1.1", Source: "TEST_QOS_LCR", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1004", SetupTime: time.Date(2014, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2014, 12, 7, 8, 42, 26, 0, time.UTC), Usage: time.Duration(180) * time.Second, Supplier: "suppl2"} @@ -924,7 +924,7 @@ func TestTutLocalLcrQosThreshold(t *testing.T) { // t.Errorf("Expecting: %+v, %+v received: %+v, %+v", eLcr.SupplierCosts[0], eLcr.SupplierCosts[1], lcr.SupplierCosts[0], lcr.SupplierCosts[1]) } testCdr4 := &engine.CDR{CGRID: utils.Sha1("testcdr4", time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC).String()), - TOR: utils.VOICE, OriginID: "testcdr4", OriginHost: "192.168.1.1", Source: "TEST_QOS_LCR", RequestType: utils.META_RATED, + ToR: utils.VOICE, OriginID: "testcdr4", OriginHost: "192.168.1.1", Source: "TEST_QOS_LCR", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1004", SetupTime: time.Date(2014, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2014, 12, 7, 8, 42, 26, 0, time.UTC), Usage: time.Duration(60) * time.Second, Supplier: "suppl2"} @@ -987,7 +987,7 @@ func TestTutLocalLcrQosThreshold(t *testing.T) { // t.Errorf("Expecting: %+v, received: %+v", eLcr.SupplierCosts[1], lcr.SupplierCosts[1]) } testCdr5 := &engine.CDR{CGRID: utils.Sha1("testcdr5", time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC).String()), - TOR: utils.VOICE, OriginID: "testcdr5", OriginHost: "192.168.1.1", Source: "TEST_QOS_LCR", RequestType: utils.META_RATED, + ToR: utils.VOICE, OriginID: "testcdr5", OriginHost: "192.168.1.1", Source: "TEST_QOS_LCR", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1003", Subject: "1003", Destination: "1004", SetupTime: time.Date(2014, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2014, 12, 7, 8, 42, 26, 0, time.UTC), Usage: time.Duration(1) * time.Second, Supplier: "suppl2"} diff --git a/sessionmanager/fsevent.go b/sessionmanager/fsevent.go index 065b83671..8634be250 100644 --- a/sessionmanager/fsevent.go +++ b/sessionmanager/fsevent.go @@ -340,7 +340,7 @@ func (fsev FSEvent) PassesFieldFilter(fieldFilter *utils.RSRField) (bool, string func (fsev FSEvent) AsStoredCdr(timezone string) *engine.CDR { storCdr := new(engine.CDR) storCdr.CGRID = fsev.GetCgrId(timezone) - storCdr.TOR = utils.VOICE + storCdr.ToR = utils.VOICE storCdr.OriginID = fsev.GetUUID() storCdr.OriginHost = fsev.GetOriginatorIP(utils.META_DEFAULT) storCdr.Source = "FS_" + fsev.GetName() diff --git a/sessionmanager/fsevent_test.go b/sessionmanager/fsevent_test.go index 439cd5382..3dbb6c7e7 100644 --- a/sessionmanager/fsevent_test.go +++ b/sessionmanager/fsevent_test.go @@ -634,7 +634,7 @@ func TestFsEvAsStoredCdr(t *testing.T) { setupTime, _ := utils.ParseTimeDetectLayout("1436280728", "") aTime, _ := utils.ParseTimeDetectLayout("1436280728", "") eStoredCdr := &engine.CDR{CGRID: "164b0422fdc6a5117031b427439482c6a4f90e41", - TOR: utils.VOICE, OriginID: "e3133bf7-dcde-4daf-9663-9a79ffcef5ad", OriginHost: "10.0.3.15", Source: "FS_CHANNEL_HANGUP_COMPLETE", RequestType: utils.META_PREPAID, + ToR: utils.VOICE, OriginID: "e3133bf7-dcde-4daf-9663-9a79ffcef5ad", OriginHost: "10.0.3.15", Source: "FS_CHANNEL_HANGUP_COMPLETE", RequestType: utils.META_PREPAID, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1003", SetupTime: setupTime, AnswerTime: aTime, Usage: time.Duration(66) * time.Second, PDD: time.Duration(28) * time.Millisecond, Supplier: "supplier1", diff --git a/sessionmanager/kamevent.go b/sessionmanager/kamevent.go index 301a5cac5..422498c0f 100644 --- a/sessionmanager/kamevent.go +++ b/sessionmanager/kamevent.go @@ -319,7 +319,7 @@ func (kev KamEvent) PassesFieldFilter(*utils.RSRField) (bool, string) { func (kev KamEvent) AsStoredCdr(timezone string) *engine.CDR { storCdr := new(engine.CDR) storCdr.CGRID = kev.GetCgrId(timezone) - storCdr.TOR = utils.VOICE + storCdr.ToR = utils.VOICE storCdr.OriginID = kev.GetUUID() storCdr.OriginHost = kev.GetOriginatorIP(utils.META_DEFAULT) storCdr.Source = kev.GetCdrSource() diff --git a/sessionmanager/osipsevent.go b/sessionmanager/osipsevent.go index 7b003bc09..cbb5052f9 100644 --- a/sessionmanager/osipsevent.go +++ b/sessionmanager/osipsevent.go @@ -267,7 +267,7 @@ func (osipsev *OsipsEvent) DialogId() string { func (osipsEv *OsipsEvent) AsStoredCdr(timezone string) *engine.CDR { storCdr := new(engine.CDR) storCdr.CGRID = osipsEv.GetCgrId(timezone) - storCdr.TOR = utils.VOICE + storCdr.ToR = utils.VOICE storCdr.OriginID = osipsEv.GetUUID() storCdr.OriginHost = osipsEv.GetOriginatorIP(utils.META_DEFAULT) storCdr.Source = "OSIPS_" + osipsEv.GetName() diff --git a/sessionmanager/osipsevent_test.go b/sessionmanager/osipsevent_test.go index 6c9d90706..ac8c2b665 100644 --- a/sessionmanager/osipsevent_test.go +++ b/sessionmanager/osipsevent_test.go @@ -144,7 +144,7 @@ func TestOsipsEventAsStoredCdr(t *testing.T) { setupTime, _ := utils.ParseTimeDetectLayout("1406370492", "") answerTime, _ := utils.ParseTimeDetectLayout("1406370499", "") eStoredCdr := &engine.CDR{CGRID: utils.Sha1("ODVkMDI2Mzc2MDY5N2EzODhjNTAzNTdlODhiZjRlYWQ", setupTime.UTC().String()), - TOR: utils.VOICE, OriginID: "ODVkMDI2Mzc2MDY5N2EzODhjNTAzNTdlODhiZjRlYWQ", OriginHost: "172.16.254.77", Source: "OSIPS_E_ACC_CDR", + ToR: utils.VOICE, OriginID: "ODVkMDI2Mzc2MDY5N2EzODhjNTAzNTdlODhiZjRlYWQ", OriginHost: "172.16.254.77", Source: "OSIPS_E_ACC_CDR", RequestType: utils.META_PREPAID, Direction: utils.OUT, Tenant: "itsyscom.com", Category: "call", Account: "dan", Subject: "dan", Destination: "+4986517174963", SetupTime: setupTime, AnswerTime: answerTime, @@ -163,7 +163,7 @@ func TestOsipsAccMissedToStoredCdr(t *testing.T) { "duration": "", "dialog_id": "3547:277000822", "extra1": "val1", "extra2": "val2"}, OriginatorAddress: addr, }} eStoredCdr := &engine.CDR{CGRID: utils.Sha1("27b1e6679ad0109b5d756e42bb4c9c28@0:0:0:0:0:0:0:0", setupTime.UTC().String()), - TOR: utils.VOICE, OriginID: "27b1e6679ad0109b5d756e42bb4c9c28@0:0:0:0:0:0:0:0", OriginHost: "172.16.254.77", Source: "OSIPS_E_ACC_MISSED_EVENT", + ToR: utils.VOICE, OriginID: "27b1e6679ad0109b5d756e42bb4c9c28@0:0:0:0:0:0:0:0", OriginHost: "172.16.254.77", Source: "OSIPS_E_ACC_MISSED_EVENT", RequestType: utils.META_PSEUDOPREPAID, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Supplier: "supplier1", DisconnectCause: "404", Destination: "1002", SetupTime: setupTime, AnswerTime: setupTime, Usage: time.Duration(0), ExtraFields: map[string]string{"extra1": "val1", "extra2": "val2"}, Cost: -1} diff --git a/sessionmanager/smg_event.go b/sessionmanager/smg_event.go index 38b46beb4..c775c45a1 100644 --- a/sessionmanager/smg_event.go +++ b/sessionmanager/smg_event.go @@ -302,7 +302,7 @@ func (self SMGenericEvent) PassesFieldFilter(*utils.RSRField) (bool, string) { func (self SMGenericEvent) AsStoredCdr(cfg *config.CGRConfig, timezone string) *engine.CDR { storCdr := engine.NewCDRWithDefaults(cfg) storCdr.CGRID = self.GetCgrId(timezone) - storCdr.TOR = utils.FirstNonEmpty(self.GetTOR(utils.META_DEFAULT), storCdr.TOR) // Keep default if none in the event + storCdr.ToR = utils.FirstNonEmpty(self.GetTOR(utils.META_DEFAULT), storCdr.ToR) // Keep default if none in the event storCdr.OriginID = self.GetUUID() storCdr.OriginHost = self.GetOriginatorIP(utils.META_DEFAULT) storCdr.Source = self.GetCdrSource() diff --git a/sessionmanager/smg_event_test.go b/sessionmanager/smg_event_test.go index 981cc58af..a52503560 100644 --- a/sessionmanager/smg_event_test.go +++ b/sessionmanager/smg_event_test.go @@ -148,7 +148,7 @@ func TestSMGenericEventAsStoredCdr(t *testing.T) { smGev["Extra1"] = "Value1" smGev["Extra2"] = 5 eStoredCdr := &engine.CDR{CGRID: "0711eaa78e53937f1593dabc08c83ea04a915f2e", - TOR: utils.VOICE, OriginID: "12345", OriginHost: "10.0.3.15", Source: "SMG_TEST_EVENT", RequestType: utils.META_PREPAID, + ToR: utils.VOICE, OriginID: "12345", OriginHost: "10.0.3.15", Source: "SMG_TEST_EVENT", RequestType: utils.META_PREPAID, Direction: utils.OUT, Tenant: "cgrates.org", Category: "call", Account: "account1", Subject: "subject1", Destination: "+4986517174963", SetupTime: time.Date(2015, 11, 9, 14, 21, 24, 0, time.UTC), AnswerTime: time.Date(2015, 11, 9, 14, 22, 2, 0, time.UTC), Usage: time.Duration(83) * time.Second, PDD: time.Duration(300) * time.Millisecond, Supplier: "supplier1", DisconnectCause: "NORMAL_DISCONNECT", diff --git a/utils/apitpdata.go b/utils/apitpdata.go index 153c44a06..6d5206e05 100644 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -626,7 +626,7 @@ func (self *AttrExpFileCdrs) AsCDRsFilter(timezone string) (*CDRsFilter, error) cdrFltr := &CDRsFilter{ CGRIDs: self.CgrIds, RunIDs: self.MediationRunIds, - TORs: self.TORs, + ToRs: self.TORs, OriginHosts: self.CdrHosts, Sources: self.CdrSources, RequestTypes: self.ReqTypes, @@ -700,7 +700,7 @@ func (self *AttrGetCdrs) AsCDRsFilter(timezone string) (*CDRsFilter, error) { cdrFltr := &CDRsFilter{ CGRIDs: self.CgrIds, RunIDs: self.MediationRunIds, - TORs: self.TORs, + ToRs: self.TORs, OriginHosts: self.CdrHosts, Sources: self.CdrSources, RequestTypes: self.ReqTypes, @@ -839,8 +839,8 @@ type CDRsFilter struct { NotOriginHosts []string // Filter out specific cdr hosts Sources []string // If provided, it will filter cdrsource NotSources []string // Filter out specific CDR sources - TORs []string // If provided, filter on TypeOfRecord - NotTORs []string // Filter specific TORs out + ToRs []string // If provided, filter on TypeOfRecord + NotToRs []string // Filter specific TORs out RequestTypes []string // If provided, it will fiter reqtype NotRequestTypes []string // Filter out specific request types Directions []string // If provided, it will fiter direction @@ -896,8 +896,8 @@ type RPCCDRsFilter struct { NotOriginHosts []string // Filter out specific cdr hosts Sources []string // If provided, it will filter cdrsource NotSources []string // Filter out specific CDR sources - TORs []string // If provided, filter on TypeOfRecord - NotTORs []string // Filter specific TORs out + ToRs []string // If provided, filter on TypeOfRecord + NotToRs []string // Filter specific TORs out RequestTypes []string // If provided, it will fiter reqtype NotRequestTypes []string // Filter out specific request types Directions []string // If provided, it will fiter direction @@ -945,8 +945,8 @@ func (self *RPCCDRsFilter) AsCDRsFilter(timezone string) (*CDRsFilter, error) { NotCGRIDs: self.NotCGRIDs, RunIDs: self.RunIDs, NotRunIDs: self.NotRunIDs, - TORs: self.TORs, - NotTORs: self.NotTORs, + ToRs: self.ToRs, + NotToRs: self.NotToRs, OriginHosts: self.OriginHosts, NotOriginHosts: self.NotOriginHosts, Sources: self.Sources, diff --git a/utils/consts.go b/utils/consts.go index 78e07a985..0bda133a3 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -104,7 +104,7 @@ const ( MSGPACK = "msgpack" CSV_LOAD = "CSVLOAD" CGRID = "CGRID" - TOR = "TOR" + TOR = "ToR" ORDERID = "OrderID" ACCID = "OriginID" CDRSOURCE = "Source"