mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 18:46:24 +05:00
Merge branch 'master' of https://github.com/cgrates/cgrates
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -38,7 +40,6 @@ import (
|
||||
"github.com/fiorix/go-diameter/diam/dict"
|
||||
)
|
||||
|
||||
var testIntegration = flag.Bool("integration", false, "Perform the tests in integration mode, not by default.") // This flag will be passed here via "go test -local" args
|
||||
var waitRater = flag.Int("wait_rater", 100, "Number of miliseconds to wait for rater to start and cache")
|
||||
var dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
|
||||
var interations = flag.Int("iterations", 1, "Number of iterations to do for dry run simulation")
|
||||
@@ -48,13 +49,10 @@ var daCfgPath string
|
||||
var daCfg *config.CGRConfig
|
||||
var apierRpc *rpc.Client
|
||||
var dmtClient *DiameterClient
|
||||
var err error
|
||||
|
||||
var rplyTimeout time.Duration
|
||||
|
||||
func TestDmtAgentInitCfg(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
daCfgPath = path.Join(*dataDir, "conf", "samples", "dmtagent")
|
||||
// Init config first
|
||||
var err error
|
||||
@@ -69,9 +67,6 @@ func TestDmtAgentInitCfg(t *testing.T) {
|
||||
|
||||
// Remove data in both rating and accounting db
|
||||
func TestDmtAgentResetDataDb(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.InitDataDb(daCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -79,9 +74,6 @@ func TestDmtAgentResetDataDb(t *testing.T) {
|
||||
|
||||
// Wipe out the cdr database
|
||||
func TestDmtAgentResetStorDb(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.InitStorDb(daCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -89,18 +81,12 @@ func TestDmtAgentResetStorDb(t *testing.T) {
|
||||
|
||||
// Start CGR Engine
|
||||
func TestDmtAgentStartEngine(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if _, err := engine.StopStartEngine(daCfgPath, 4000); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDmtAgentCCRAsSMGenericEvent(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
cfgDefaults, _ := config.NewDefaultCGRConfig()
|
||||
loadDictionaries(cfgDefaults.DiameterAgentCfg().DictionariesDir, "UNIT_TEST")
|
||||
time.Sleep(time.Duration(*waitRater) * time.Millisecond)
|
||||
@@ -160,9 +146,6 @@ func TestDmtAgentCCRAsSMGenericEvent(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDmtAgentPopulateCCTotalOctets(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
daRP := &config.DARequestProcessor{CCAFields: []*config.CfgCdrField{
|
||||
&config.CfgCdrField{Tag: "GrantedUnit", FieldFilter: utils.ParseRSRFieldsMustCompile("CGRError(^$)", utils.INFIELD_SEP),
|
||||
FieldId: "Multiple-Services-Credit-Control>Granted-Service-Unit>CC-Time", Type: utils.META_COMPOSED, Value: utils.ParseRSRFieldsMustCompile("CGRMaxUsage", utils.INFIELD_SEP), Mandatory: true},
|
||||
@@ -193,9 +176,6 @@ func TestDmtAgentPopulateCCTotalOctets(t *testing.T) {
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestDmtAgentApierRpcConn(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
apierRpc, err = jsonrpc.Dial("tcp", daCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
@@ -205,9 +185,6 @@ func TestDmtAgentApierRpcConn(t *testing.T) {
|
||||
|
||||
// Load the tariff plan, creating accounts and their balances
|
||||
func TestDmtAgentTPFromFolder(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutorial")}
|
||||
var loadInst utils.LoadInstance
|
||||
if err := apierRpc.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &loadInst); err != nil {
|
||||
@@ -217,9 +194,6 @@ func TestDmtAgentTPFromFolder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConnectDiameterClient(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
dmtClient, err = NewDiameterClient(daCfg.DiameterAgentCfg().Listen, "UNIT_TEST", daCfg.DiameterAgentCfg().OriginRealm,
|
||||
daCfg.DiameterAgentCfg().VendorId, daCfg.DiameterAgentCfg().ProductName, utils.DIAMETER_FIRMWARE_REVISION, daCfg.DiameterAgentCfg().DictionariesDir)
|
||||
if err != nil {
|
||||
@@ -229,9 +203,6 @@ func TestConnectDiameterClient(t *testing.T) {
|
||||
|
||||
// cgr-console 'cost Category="call" Tenant="cgrates.org" Subject="1001" Destination="1004" TimeStart="2015-11-07T08:42:26Z" TimeEnd="2015-11-07T08:47:26Z"'
|
||||
func TestDmtAgentSendCCRInit(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
cdr := &engine.CDR{CGRID: utils.Sha1("testccr1", time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE,
|
||||
OriginID: "testccr1", 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",
|
||||
@@ -273,9 +244,6 @@ func TestDmtAgentSendCCRInit(t *testing.T) {
|
||||
|
||||
// cgr-console 'cost Category="call" Tenant="cgrates.org" Subject="1001" Destination="1004" TimeStart="2015-11-07T08:42:26Z" TimeEnd="2015-11-07T08:52:26Z"'
|
||||
func TestDmtAgentSendCCRUpdate(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
cdr := &engine.CDR{CGRID: utils.Sha1("testccr1", time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE,
|
||||
OriginID: "testccr1", 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",
|
||||
@@ -312,9 +280,6 @@ func TestDmtAgentSendCCRUpdate(t *testing.T) {
|
||||
|
||||
// cgr-console 'cost Category="call" Tenant="cgrates.org" Subject="1001" Destination="1004" TimeStart="2015-11-07T08:42:26Z" TimeEnd="2015-11-07T08:57:26Z"'
|
||||
func TestDmtAgentSendCCRUpdate2(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
cdr := &engine.CDR{CGRID: utils.Sha1("testccr1", time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE,
|
||||
OriginID: "testccr1", 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",
|
||||
@@ -350,9 +315,6 @@ func TestDmtAgentSendCCRUpdate2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDmtAgentSendCCRTerminate(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
cdr := &engine.CDR{CGRID: utils.Sha1("testccr1", time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE,
|
||||
OriginID: "testccr1", 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",
|
||||
@@ -391,9 +353,6 @@ func TestDmtAgentSendCCRTerminate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDmtAgentSendCCRSMS(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
ccr := diam.NewRequest(diam.CreditControl, 4, nil)
|
||||
ccr.NewAVP(avp.SessionID, avp.Mbit, 0, datatype.UTF8String("testccr2"))
|
||||
ccr.NewAVP(avp.OriginHost, avp.Mbit, 0, datatype.DiameterIdentity("CGR-DA"))
|
||||
@@ -484,9 +443,6 @@ func TestDmtAgentSendCCRSMS(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDmtAgentSendCCRSMSWrongAccount(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
ccr := diam.NewRequest(diam.CreditControl, 4, nil)
|
||||
ccr.NewAVP(avp.SessionID, avp.Mbit, 0, datatype.UTF8String("testccr3"))
|
||||
ccr.NewAVP(avp.OriginHost, avp.Mbit, 0, datatype.DiameterIdentity("CGR-DA"))
|
||||
@@ -553,9 +509,6 @@ func TestDmtAgentSendCCRSMSWrongAccount(t *testing.T) {
|
||||
|
||||
// cgr-console 'cost Category="call" Tenant="cgrates.org" Subject="1001" Destination="1004" TimeStart="2015-11-07T08:42:26Z" TimeEnd="2015-11-07T08:47:26Z"'
|
||||
func TestDmtAgentSendCCRInitWrongAccount(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
cdr := &engine.CDR{CGRID: utils.Sha1("testccr4", time.Date(2015, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE,
|
||||
OriginID: "testccr4", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out",
|
||||
Tenant: "cgrates.org", Category: "call", Account: "non_existent", Subject: "non_existent", Destination: "1004", Supplier: "SUPPL1",
|
||||
@@ -586,9 +539,6 @@ func TestDmtAgentSendCCRInitWrongAccount(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDmtAgentSendCCRSimpaEvent(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
ccr := diam.NewRequest(diam.CreditControl, 4, nil)
|
||||
ccr.NewAVP(avp.SessionID, avp.Mbit, 0, datatype.UTF8String("testccr5"))
|
||||
ccr.NewAVP(avp.OriginHost, avp.Mbit, 0, datatype.DiameterIdentity("CGR-DA"))
|
||||
@@ -661,9 +611,6 @@ func TestDmtAgentSendCCRSimpaEvent(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDmtAgentCdrs(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var cdrs []*engine.ExternalCDR
|
||||
req := utils.RPCCDRsFilter{RunIDs: []string{utils.META_DEFAULT}, ToRs: []string{utils.VOICE}}
|
||||
if err := apierRpc.Call("ApierV2.GetCdrs", req, &cdrs); err != nil {
|
||||
@@ -681,9 +628,6 @@ func TestDmtAgentCdrs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDmtAgentSendDataGrpInit(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
ccr := diam.NewRequest(diam.CreditControl, 4, nil)
|
||||
ccr.NewAVP(avp.SessionID, avp.Mbit, 0, datatype.UTF8String("testdatagrp"))
|
||||
ccr.NewAVP(avp.OriginHost, avp.Mbit, 0, datatype.DiameterIdentity("CGR-DA"))
|
||||
@@ -749,9 +693,6 @@ func TestDmtAgentSendDataGrpInit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDmtAgentSendDataGrpUpdate(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
ccr := diam.NewRequest(diam.CreditControl, 4, nil)
|
||||
ccr.NewAVP(avp.SessionID, avp.Mbit, 0, datatype.UTF8String("testdatagrp"))
|
||||
ccr.NewAVP(avp.OriginHost, avp.Mbit, 0, datatype.DiameterIdentity("CGR-DA"))
|
||||
@@ -843,9 +784,6 @@ func TestDmtAgentSendDataGrpUpdate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDmtAgentSendDataGrpTerminate(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
ccr := diam.NewRequest(diam.CreditControl, 4, nil)
|
||||
ccr.NewAVP(avp.SessionID, avp.Mbit, 0, datatype.UTF8String("testdatagrp"))
|
||||
ccr.NewAVP(avp.OriginHost, avp.Mbit, 0, datatype.DiameterIdentity("CGR-DA"))
|
||||
@@ -923,9 +861,6 @@ func TestDmtAgentSendDataGrpTerminate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDmtAgentSendDataGrpCDRs(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var cdrs []*engine.ExternalCDR
|
||||
req := utils.RPCCDRsFilter{CGRIDs: []string{utils.Sha1("testdatagrp")}}
|
||||
if err := apierRpc.Call("ApierV2.GetCdrs", req, &cdrs); err != nil {
|
||||
@@ -937,9 +872,6 @@ func TestDmtAgentSendDataGrpCDRs(t *testing.T) {
|
||||
|
||||
/*
|
||||
func TestDmtAgentDryRun1(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
ccr := diam.NewRequest(diam.CreditControl, 4, nil)
|
||||
ccr.NewAVP(avp.SessionID, avp.Mbit, 0, datatype.UTF8String("cgrates;1451911932;00082"))
|
||||
ccr.NewAVP(avp.OriginHost, avp.Mbit, 0, datatype.DiameterIdentity("CGR-DA"))
|
||||
@@ -971,9 +903,6 @@ func TestDmtAgentDryRun1(t *testing.T) {
|
||||
*/
|
||||
|
||||
func TestDmtAgentDryRun1(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
ccr := diam.NewRequest(diam.CreditControl, 4, nil)
|
||||
ccr.NewAVP(avp.SessionID, avp.Mbit, 0, datatype.UTF8String("cgrates;1451911932;00082"))
|
||||
ccr.NewAVP(avp.OriginHost, avp.Mbit, 0, datatype.DiameterIdentity("CGR-DA"))
|
||||
@@ -1049,9 +978,6 @@ func TestDmtAgentDryRun1(t *testing.T) {
|
||||
|
||||
/*
|
||||
func TestDmtAgentLoadCER(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
m := diam.NewRequest(diam.CapabilitiesExchange, 4, dict.Default)
|
||||
m.NewAVP(avp.OriginHost, avp.Mbit, 0, datatype.DiameterIdentity("CGR-DA"))
|
||||
m.NewAVP(avp.OriginRealm, avp.Mbit, 0, datatype.DiameterIdentity("cgrates.org"))
|
||||
@@ -1073,9 +999,6 @@ func TestDmtAgentLoadCER(t *testing.T) {
|
||||
*/
|
||||
|
||||
func TestDmtAgentStopEngine(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.KillEngine(*waitRater); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -31,9 +33,6 @@ import (
|
||||
var cgrRater1Cmd, cgrSmg1Cmd *exec.Cmd
|
||||
|
||||
func TestHaPoolInitCfg(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
daCfgPath = path.Join(*dataDir, "conf", "samples", "hapool", "cgrrater1")
|
||||
// Init config first
|
||||
var err error
|
||||
@@ -57,9 +56,6 @@ func TestHaPoolResetStorDb(t *testing.T) {
|
||||
|
||||
// Start CGR Engine
|
||||
func TestHaPoolStartEngine(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
engine.KillEngine(*waitRater) // just to make sure
|
||||
var err error
|
||||
cgrRater1 := path.Join(*dataDir, "conf", "samples", "hapool", "cgrrater1")
|
||||
|
||||
@@ -35,6 +35,8 @@ import (
|
||||
"github.com/fiorix/go-diameter/diam/dict"
|
||||
)
|
||||
|
||||
var err error
|
||||
|
||||
func TestDisectUsageForCCR(t *testing.T) {
|
||||
if reqType, reqNr, reqCCTime, usedCCTime := disectUsageForCCR(time.Duration(0)*time.Second, time.Duration(300)*time.Second, false); reqType != 1 || reqNr != 0 || reqCCTime != 300 || usedCCTime != 0 {
|
||||
t.Error(reqType, reqNr, reqCCTime, usedCCTime)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -58,15 +60,11 @@ var cfgPath string
|
||||
var cfg *config.CGRConfig
|
||||
var rater *rpc.Client
|
||||
|
||||
var testLocal = flag.Bool("local", false, "Perform the tests only on local test environment, not by default.") // This flag will be passed here via "go test -local" args
|
||||
var dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
|
||||
var storDbType = flag.String("stordb_type", "mysql", "The type of the storDb database <mysql>")
|
||||
var waitRater = flag.Int("wait_rater", 500, "Number of miliseconds to wait for rater to start and cache")
|
||||
|
||||
func TestApierLoadConfig(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
cfgPath = path.Join(*dataDir, "conf", "samples", "apier")
|
||||
if cfg, err = config.NewCGRConfigFromFolder(cfgPath); err != nil {
|
||||
@@ -75,9 +73,6 @@ func TestApierLoadConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierCreateDirs(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
for _, pathDir := range []string{cfg.CdreProfiles[utils.META_DEFAULT].ExportDirectory, "/var/log/cgrates/cdrc/in", "/var/log/cgrates/cdrc/out", cfg.HistoryDir} {
|
||||
|
||||
if err := os.RemoveAll(pathDir); err != nil {
|
||||
@@ -90,9 +85,6 @@ func TestApierCreateDirs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierInitDataDb(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
if err := engine.InitDataDb(cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -100,9 +92,6 @@ func TestApierInitDataDb(t *testing.T) {
|
||||
|
||||
// Empty tables before using them
|
||||
func TestApierInitStorDb(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
if err := engine.InitStorDb(cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -110,9 +99,6 @@ func TestApierInitStorDb(t *testing.T) {
|
||||
|
||||
// Finds cgr-engine executable and starts it with default configuration
|
||||
func TestApierStartEngine(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
enginePath, err := exec.LookPath("cgr-engine")
|
||||
if err != nil {
|
||||
t.Fatal("Cannot find cgr-engine executable")
|
||||
@@ -129,9 +115,7 @@ func TestApierStartEngine(t *testing.T) {
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestApierRpcConn(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
rater, err = jsonrpc.Dial("tcp", cfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
@@ -141,9 +125,6 @@ func TestApierRpcConn(t *testing.T) {
|
||||
|
||||
// Test here TPTiming APIs
|
||||
func TestApierTPTiming(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
// ALWAYS,*any,*any,*any,*any,00:00:00
|
||||
tmAlways := &utils.ApierTPTiming{TPid: utils.TEST_SQL,
|
||||
TimingId: "ALWAYS",
|
||||
@@ -209,9 +190,6 @@ func TestApierTPTiming(t *testing.T) {
|
||||
|
||||
// Test here TPTiming APIs
|
||||
func TestApierTPDestination(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
dstDe := &utils.V1TPDestination{TPid: utils.TEST_SQL, DestinationId: "GERMANY", Prefixes: []string{"+49"}}
|
||||
dstDeMobile := &utils.V1TPDestination{TPid: utils.TEST_SQL, DestinationId: "GERMANY_MOBILE", Prefixes: []string{"+4915", "+4916", "+4917"}}
|
||||
@@ -263,9 +241,6 @@ func TestApierTPDestination(t *testing.T) {
|
||||
|
||||
// Test here TPRate APIs
|
||||
func TestApierTPRate(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
rt := &utils.TPRate{TPid: utils.TEST_SQL, RateId: "RT_FS_USERS", RateSlots: []*utils.RateSlot{
|
||||
&utils.RateSlot{ConnectFee: 0, Rate: 0, RateUnit: "60s", RateIncrement: "60s", GroupIntervalStart: "0s"},
|
||||
@@ -317,9 +292,6 @@ func TestApierTPRate(t *testing.T) {
|
||||
|
||||
// Test here TPDestinationRate APIs
|
||||
func TestApierTPDestinationRate(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
dr := &utils.TPDestinationRate{TPid: utils.TEST_SQL, DestinationRateId: "DR_FREESWITCH_USERS", DestinationRates: []*utils.DestinationRate{
|
||||
&utils.DestinationRate{DestinationId: "FS_USERS", RateId: "RT_FS_USERS", RoundingMethod: "*up", RoundingDecimals: 2},
|
||||
@@ -374,9 +346,6 @@ func TestApierTPDestinationRate(t *testing.T) {
|
||||
|
||||
// Test here TPRatingPlan APIs
|
||||
func TestApierTPRatingPlan(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
rp := &utils.TPRatingPlan{TPid: utils.TEST_SQL, RatingPlanId: "RETAIL1", RatingPlanBindings: []*utils.TPRatingPlanBinding{
|
||||
&utils.TPRatingPlanBinding{DestinationRatesId: "DR_FREESWITCH_USERS", TimingId: "ALWAYS", Weight: 10},
|
||||
@@ -428,9 +397,6 @@ func TestApierTPRatingPlan(t *testing.T) {
|
||||
|
||||
// Test here TPRatingPlan APIs
|
||||
func TestApierTPRatingProfile(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
rpf := &utils.TPRatingProfile{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", Category: "call", Direction: "*out", Subject: "*any",
|
||||
RatingPlanActivations: []*utils.TPRatingActivation{
|
||||
@@ -482,9 +448,6 @@ func TestApierTPRatingProfile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierTPActions(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
act := &utils.TPActions{TPid: utils.TEST_SQL, ActionsId: "PREPAID_10", Actions: []*utils.TPAction{
|
||||
&utils.TPAction{Identifier: "*topup_reset", BalanceType: "*monetary", Directions: "*out", Units: "10", ExpiryTime: "*unlimited",
|
||||
@@ -542,9 +505,6 @@ func TestApierTPActions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierTPActionPlan(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
at := &utils.TPActionPlan{TPid: utils.TEST_SQL, ActionPlanId: "PREPAID_10", ActionPlan: []*utils.TPActionTiming{
|
||||
&utils.TPActionTiming{ActionsId: "PREPAID_10", TimingId: "ASAP", Weight: 10},
|
||||
@@ -595,9 +555,6 @@ func TestApierTPActionPlan(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierTPActionTriggers(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
at := &utils.TPActionTriggers{TPid: utils.TEST_SQL, ActionTriggersId: "STANDARD_TRIGGERS", ActionTriggers: []*utils.TPActionTrigger{
|
||||
&utils.TPActionTrigger{Id: "STANDARD_TRIGGERS", UniqueID: "MYFIRSTTRIGGER", BalanceType: "*monetary", BalanceDirections: "*out", ThresholdType: "*min_balance", ThresholdValue: 2, ActionsId: "LOG_BALANCE", Weight: 10},
|
||||
@@ -650,9 +607,6 @@ func TestApierTPActionTriggers(t *testing.T) {
|
||||
|
||||
// Test here TPAccountActions APIs
|
||||
func TestApierTPAccountActions(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
aa1 := &utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org",
|
||||
Account: "1001", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"}
|
||||
@@ -711,9 +665,6 @@ func TestApierTPAccountActions(t *testing.T) {
|
||||
|
||||
// Test here LoadRatingPlan
|
||||
func TestApierLoadRatingPlan(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
if err := rater.Call("ApierV1.LoadRatingPlan", AttrLoadRatingPlan{TPid: utils.TEST_SQL, RatingPlanId: "RETAIL1"}, &reply); err != nil {
|
||||
t.Error("Got error on ApierV1.LoadRatingPlan: ", err.Error())
|
||||
@@ -724,9 +675,6 @@ func TestApierLoadRatingPlan(t *testing.T) {
|
||||
|
||||
// Test here SetRatingProfile
|
||||
func TestApierSetRatingProfile(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
rpa := &utils.TPRatingActivation{ActivationTime: "2012-01-01T00:00:00Z", RatingPlanId: "RETAIL1", FallbackSubjects: "dan2"}
|
||||
rpf := &AttrSetRatingProfile{Tenant: "cgrates.org", Category: "call", Direction: "*out", Subject: "dan", RatingPlanActivations: []*utils.TPRatingActivation{rpa}}
|
||||
@@ -765,9 +713,6 @@ func TestApierSetRatingProfile(t *testing.T) {
|
||||
|
||||
// Test here LoadRatingProfile
|
||||
func TestApierLoadRatingProfile(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
rpf := &utils.TPRatingProfile{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", Category: "call", Direction: "*out", Subject: "*any"}
|
||||
if err := rater.Call("ApierV1.LoadRatingProfile", rpf, &reply); err != nil {
|
||||
@@ -779,9 +724,6 @@ func TestApierLoadRatingProfile(t *testing.T) {
|
||||
|
||||
// Test here LoadAccountActions
|
||||
func TestApierLoadAccountActions(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
aa1 := &utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", Account: "1001"}
|
||||
if err := rater.Call("ApierV1.LoadAccountActions", aa1, &reply); err != nil {
|
||||
@@ -793,9 +735,6 @@ func TestApierLoadAccountActions(t *testing.T) {
|
||||
|
||||
// Test here ReloadScheduler
|
||||
func TestApierReloadScheduler(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
// Simple test that command is executed without errors
|
||||
if err := rater.Call("ApierV1.ReloadScheduler", reply, &reply); err != nil {
|
||||
@@ -807,9 +746,6 @@ func TestApierReloadScheduler(t *testing.T) {
|
||||
|
||||
// Test here ReloadCache
|
||||
func TestApierReloadCache(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
arc := new(utils.AttrReloadCache)
|
||||
// Simple test that command is executed without errors
|
||||
@@ -821,9 +757,6 @@ func TestApierReloadCache(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierGetCacheStats(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var rcvStats *utils.CacheStats
|
||||
var args utils.AttrCacheStats
|
||||
err := rater.Call("ApierV1.GetCacheStats", args, &rcvStats)
|
||||
@@ -837,9 +770,6 @@ func TestApierGetCacheStats(t *testing.T) {
|
||||
|
||||
// Test here GetDestination
|
||||
func TestApierGetDestination(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := new(engine.Destination)
|
||||
dstId := "GERMANY_MOBILE"
|
||||
expectedReply := &engine.Destination{Id: dstId, Prefixes: []string{"+4915", "+4916", "+4917"}}
|
||||
@@ -852,9 +782,6 @@ func TestApierGetDestination(t *testing.T) {
|
||||
|
||||
// Test here GetRatingPlan
|
||||
func TestApierGetRatingPlan(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := new(engine.RatingPlan)
|
||||
rplnId := "RETAIL1"
|
||||
if err := rater.Call("ApierV1.GetRatingPlan", rplnId, reply); err != nil {
|
||||
@@ -881,9 +808,6 @@ func TestApierGetRatingPlan(t *testing.T) {
|
||||
|
||||
// Test here AddBalance
|
||||
func TestApierAddBalance(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
attrs := &AttrAddBalance{Tenant: "cgrates.org", Account: "1001", BalanceType: "*monetary", Value: 1.5}
|
||||
if err := rater.Call("ApierV1.AddBalance", attrs, &reply); err != nil {
|
||||
@@ -932,9 +856,6 @@ func TestApierAddBalance(t *testing.T) {
|
||||
|
||||
// Test here ExecuteAction
|
||||
func TestApierExecuteAction(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
// Add balance to a previously known account
|
||||
attrs := utils.AttrExecuteAction{Tenant: "cgrates.org", Account: "dan2", ActionsId: "PREPAID_10"}
|
||||
@@ -952,9 +873,6 @@ func TestApierExecuteAction(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierSetActions(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
act1 := &V1TPAction{Identifier: engine.TOPUP_RESET, BalanceType: utils.MONETARY, Directions: utils.OUT, Units: 75.0, ExpiryTime: engine.UNLIMITED, Weight: 20.0}
|
||||
attrs1 := &V1AttrSetActions{ActionsId: "ACTS_1", Actions: []*V1TPAction{act1}}
|
||||
reply1 := ""
|
||||
@@ -970,9 +888,6 @@ func TestApierSetActions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierGetActions(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
expectActs := []*utils.TPAction{
|
||||
&utils.TPAction{Identifier: engine.TOPUP_RESET, BalanceType: utils.MONETARY, Directions: utils.OUT, Units: "75", BalanceWeight: "0", BalanceBlocker: "false", BalanceDisabled: "false", ExpiryTime: engine.UNLIMITED, Weight: 20.0}}
|
||||
|
||||
@@ -985,9 +900,6 @@ func TestApierGetActions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierSetActionPlan(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
atm1 := &AttrActionPlan{ActionsId: "ACTS_1", MonthDays: "1", Time: "00:00:00", Weight: 20.0}
|
||||
atms1 := &AttrSetActionPlan{Id: "ATMS_1", ActionPlan: []*AttrActionPlan{atm1}}
|
||||
reply1 := ""
|
||||
@@ -1004,9 +916,6 @@ func TestApierSetActionPlan(t *testing.T) {
|
||||
|
||||
// Test here AddTriggeredAction
|
||||
func TestApierAddTriggeredAction(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var reply string
|
||||
attrs := &AttrAddBalance{Tenant: "cgrates.org", Account: "dan32", BalanceType: "*monetary", Value: 1.5}
|
||||
if err := rater.Call("ApierV1.AddBalance", attrs, &reply); err != nil {
|
||||
@@ -1034,9 +943,6 @@ func TestApierAddTriggeredAction(t *testing.T) {
|
||||
|
||||
// Test here GetAccountActionTriggers
|
||||
func TestApierGetAccountActionTriggers(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var reply engine.ActionTriggers
|
||||
req := AttrAcntAction{Tenant: "cgrates.org", Account: "dan32"}
|
||||
if err := rater.Call("ApierV1.GetAccountActionTriggers", req, &reply); err != nil {
|
||||
@@ -1047,9 +953,6 @@ func TestApierGetAccountActionTriggers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierAddTriggeredAction2(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
// Add balance to a previously known account
|
||||
attrs := &AttrAddAccountActionTriggers{ActionTriggerIDs: &[]string{"STANDARD_TRIGGERS"}, Tenant: "cgrates.org", Account: "dan2"}
|
||||
@@ -1070,9 +973,6 @@ func TestApierAddTriggeredAction2(t *testing.T) {
|
||||
|
||||
// Test here GetAccountActionTriggers
|
||||
func TestApierGetAccountActionTriggers2(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var reply engine.ActionTriggers
|
||||
req := AttrAcntAction{Tenant: "cgrates.org", Account: "dan2"}
|
||||
if err := rater.Call("ApierV1.GetAccountActionTriggers", req, &reply); err != nil {
|
||||
@@ -1084,9 +984,6 @@ func TestApierGetAccountActionTriggers2(t *testing.T) {
|
||||
|
||||
// Test here SetAccountActionTriggers
|
||||
func TestApierSetAccountActionTriggers(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
// Test first get so we can steal the id which we need to remove
|
||||
var reply engine.ActionTriggers
|
||||
req := AttrAcntAction{Tenant: "cgrates.org", Account: "dan2"}
|
||||
@@ -1119,9 +1016,6 @@ func TestApierSetAccountActionTriggers(t *testing.T) {
|
||||
|
||||
// Test here RemAccountActionTriggers
|
||||
func TestApierRemAccountActionTriggers(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
// Test first get so we can steal the id which we need to remove
|
||||
var reply engine.ActionTriggers
|
||||
req := AttrAcntAction{Tenant: "cgrates.org", Account: "dan2"}
|
||||
@@ -1154,9 +1048,6 @@ func TestApierRemAccountActionTriggers(t *testing.T) {
|
||||
|
||||
// Test here SetAccount
|
||||
func TestApierSetAccount(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
attrs := &utils.AttrSetAccount{Tenant: "cgrates.org", Account: "dan7", ActionPlanId: "ATMS_1", ReloadScheduler: true}
|
||||
if err := rater.Call("ApierV1.SetAccount", attrs, &reply); err != nil {
|
||||
@@ -1176,9 +1067,6 @@ func TestApierSetAccount(t *testing.T) {
|
||||
|
||||
// Test here GetAccountActionTimings
|
||||
func TestApierGetAccountActionPlan(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var reply []*AccountActionTiming
|
||||
req := AttrAcntAction{Tenant: "cgrates.org", Account: "dan7"}
|
||||
if err := rater.Call("ApierV1.GetAccountActionPlan", req, &reply); err != nil {
|
||||
@@ -1194,9 +1082,6 @@ func TestApierGetAccountActionPlan(t *testing.T) {
|
||||
|
||||
// Test here RemoveActionTiming
|
||||
func TestApierRemUniqueIDActionTiming(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var rmReply string
|
||||
rmReq := AttrRemActionTiming{ActionPlanId: "ATMS_1", Tenant: "cgrates.org", Account: "dan4"}
|
||||
if err := rater.Call("ApierV1.RemActionTiming", rmReq, &rmReply); err != nil {
|
||||
@@ -1215,9 +1100,6 @@ func TestApierRemUniqueIDActionTiming(t *testing.T) {
|
||||
|
||||
// Test here GetAccount
|
||||
func TestApierGetAccount(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var reply *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}
|
||||
if err := rater.Call("ApierV2.GetAccount", attrs, &reply); err != nil {
|
||||
@@ -1254,9 +1136,6 @@ func TestApierGetAccount(t *testing.T) {
|
||||
|
||||
// Start with initial balance, top-up to test max_balance
|
||||
func TestApierTriggersExecute(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
attrs := &utils.AttrSetAccount{Tenant: "cgrates.org", Account: "dan8", ReloadScheduler: true}
|
||||
if err := rater.Call("ApierV1.SetAccount", attrs, &reply); err != nil {
|
||||
@@ -1274,9 +1153,6 @@ func TestApierTriggersExecute(t *testing.T) {
|
||||
|
||||
// Start fresh before loading from folder
|
||||
func TestApierResetDataBeforeLoadFromFolder(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
TestApierInitDataDb(t)
|
||||
reply := ""
|
||||
arc := new(utils.AttrReloadCache)
|
||||
@@ -1299,9 +1175,6 @@ func TestApierResetDataBeforeLoadFromFolder(t *testing.T) {
|
||||
|
||||
// Test here LoadTariffPlanFromFolder
|
||||
func TestApierLoadTariffPlanFromFolder(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: ""}
|
||||
if err := rater.Call("ApierV1.LoadTariffPlanFromFolder", attrs, &reply); err == nil || !strings.HasPrefix(err.Error(), utils.ErrMandatoryIeMissing.Error()) {
|
||||
@@ -1322,9 +1195,6 @@ func TestApierLoadTariffPlanFromFolder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierResetDataAfterLoadFromFolder(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
arc := new(utils.AttrReloadCache)
|
||||
// Simple test that command is executed without errors
|
||||
@@ -1351,9 +1221,6 @@ func TestApierResetDataAfterLoadFromFolder(t *testing.T) {
|
||||
// Make sure balance was topped-up
|
||||
// Bug reported by DigiDaz over IRC
|
||||
func TestApierGetAccountAfterLoad(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var reply *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}
|
||||
if err := rater.Call("ApierV2.GetAccount", attrs, &reply); err != nil {
|
||||
@@ -1365,9 +1232,6 @@ func TestApierGetAccountAfterLoad(t *testing.T) {
|
||||
|
||||
// Test here ResponderGetCost
|
||||
func TestApierResponderGetCost(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
tStart, _ := utils.ParseDate("2013-08-07T17:30:00Z")
|
||||
tEnd, _ := utils.ParseDate("2013-08-07T17:31:30Z")
|
||||
cd := engine.CallDescriptor{
|
||||
@@ -1392,9 +1256,6 @@ func TestApierResponderGetCost(t *testing.T) {
|
||||
|
||||
// Test here ResponderGetCost
|
||||
func TestApierGetCallCostLog(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var cc engine.CallCost
|
||||
var attrs utils.AttrGetCallCost
|
||||
// Simple test that command is executed without errors
|
||||
@@ -1409,9 +1270,7 @@ func TestApierGetCallCostLog(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierMaxDebitInexistentAcnt(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
cc := &engine.CallCost{}
|
||||
cd := engine.CallDescriptor{
|
||||
Direction: "*out",
|
||||
@@ -1433,9 +1292,6 @@ func TestApierMaxDebitInexistentAcnt(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierCdrServer(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
httpClient := new(http.Client)
|
||||
cdrForm1 := url.Values{utils.ACCID: []string{"dsafdsaf"}, utils.CDRHOST: []string{"192.168.1.1"}, utils.REQTYPE: []string{utils.META_RATED}, utils.DIRECTION: []string{"*out"},
|
||||
utils.TENANT: []string{"cgrates.org"}, utils.CATEGORY: []string{"call"}, utils.ACCOUNT: []string{"1001"}, utils.SUBJECT: []string{"1001"}, utils.DESTINATION: []string{"1002"},
|
||||
@@ -1456,9 +1312,6 @@ func TestApierCdrServer(t *testing.T) {
|
||||
|
||||
/*
|
||||
func TestApierExportCdrsToFile(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var reply *utils.ExportedFileCdrs
|
||||
req := utils.AttrExpFileCdrs{}
|
||||
//if err := rater.Call("ApierV1.ExportCdrsToFile", req, &reply); err == nil || !strings.HasPrefix(err.Error(), utils.ERR_MANDATORY_IE_MISSING) {
|
||||
@@ -1492,10 +1345,7 @@ func TestApierExportCdrsToFile(t *testing.T) {
|
||||
}
|
||||
*/
|
||||
|
||||
func TestApierLocalGetCdrs(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestApierITGetCdrs(t *testing.T) {
|
||||
var reply []*engine.ExternalCDR
|
||||
req := utils.AttrGetCdrs{MediationRunIds: []string{utils.MetaRaw}}
|
||||
if err := rater.Call("ApierV1.GetCdrs", req, &reply); err != nil {
|
||||
@@ -1505,10 +1355,7 @@ func TestApierLocalGetCdrs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierLocalProcessCdr(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestApierITProcessCdr(t *testing.T) {
|
||||
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",
|
||||
OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001",
|
||||
@@ -1530,10 +1377,7 @@ func TestApierLocalProcessCdr(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierLocalSetDC(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestApierITSetDC(t *testing.T) {
|
||||
dcs1 := []*utils.DerivedCharger{
|
||||
&utils.DerivedCharger{RunID: "extra1", RequestTypeField: "^prepaid", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
|
||||
AccountField: "rif", SubjectField: "rif", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
|
||||
@@ -1549,10 +1393,7 @@ func TestApierLocalSetDC(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierLocalGetDC(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestApierITGetDC(t *testing.T) {
|
||||
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "dan", Subject: "dan"}
|
||||
eDcs := utils.DerivedChargers{DestinationIDs: utils.NewStringMap(),
|
||||
Chargers: []*utils.DerivedCharger{
|
||||
@@ -1569,10 +1410,7 @@ func TestApierLocalGetDC(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierLocalRemDC(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestApierITRemDC(t *testing.T) {
|
||||
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "dan", Subject: "dan"}
|
||||
var reply string
|
||||
if err := rater.Call("ApierV1.RemDerivedChargers", attrs, &reply); err != nil {
|
||||
@@ -1582,10 +1420,7 @@ func TestApierLocalRemDC(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierLocalSetDestination(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestApierITSetDestination(t *testing.T) {
|
||||
attrs := utils.AttrSetDestination{Id: "TEST_SET_DESTINATION", Prefixes: []string{"+4986517174963", "+4986517174960"}}
|
||||
var reply string
|
||||
if err := rater.Call("ApierV1.SetDestination", attrs, &reply); err != nil {
|
||||
@@ -1611,10 +1446,7 @@ func TestApierLocalSetDestination(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierLocalGetAliases(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestApierITGetAliases(t *testing.T) {
|
||||
var alias engine.Alias
|
||||
//al.Direction, al.Tenant, al.Category, al.Account, al.Subject, al.Group
|
||||
if err := rater.Call("AliasesV1.GetAlias", engine.Alias{Context: utils.ALIAS_CONTEXT_RATING, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "2001", Subject: "2001"}, &alias); err == nil {
|
||||
@@ -1629,10 +1461,7 @@ func TestApierLocalGetAliases(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierLocalAddRatingSubjectAliases(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestApierITAddRatingSubjectAliases(t *testing.T) {
|
||||
addRtSubjAliases := &AttrAddRatingSubjectAliases{Tenant: "cgrates.org", Category: "call", Subject: "1001", Aliases: []string{"2001", "2002", "2003"}}
|
||||
var rply string
|
||||
if err := rater.Call("ApierV1.AddRatingSubjectAliases", addRtSubjAliases, &rply); err != nil {
|
||||
@@ -1649,10 +1478,7 @@ func TestApierLocalAddRatingSubjectAliases(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierLocalRemRatingSubjectAliases(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestApierITRemRatingSubjectAliases(t *testing.T) {
|
||||
tenantRatingSubj := engine.TenantRatingSubject{Tenant: "cgrates.org", Subject: "1001"}
|
||||
var rply string
|
||||
if err := rater.Call("ApierV1.RemRatingSubjectAliases", tenantRatingSubj, &rply); err != nil {
|
||||
@@ -1667,10 +1493,7 @@ func TestApierLocalRemRatingSubjectAliases(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierLocalAddAccountAliases(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestApierITAddAccountAliases(t *testing.T) {
|
||||
addAcntAliases := &AttrAddAccountAliases{Tenant: "cgrates.org", Category: "call", Account: "1001", Aliases: []string{"2001", "2002", "2003"}}
|
||||
var rply string
|
||||
if err := rater.Call("ApierV1.AddAccountAliases", addAcntAliases, &rply); err != nil {
|
||||
@@ -1687,10 +1510,7 @@ func TestApierLocalAddAccountAliases(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierLocalRemAccountAliases(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestApierITRemAccountAliases(t *testing.T) {
|
||||
tenantAcnt := engine.TenantAccount{Tenant: "cgrates.org", Account: "1001"}
|
||||
var rply string
|
||||
if err := rater.Call("ApierV1.RemAccountAliases", tenantAcnt, &rply); err != nil {
|
||||
@@ -1705,20 +1525,14 @@ func TestApierLocalRemAccountAliases(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierLocalGetScheduledActions(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestApierITGetScheduledActions(t *testing.T) {
|
||||
var rply []*ScheduledActions
|
||||
if err := rater.Call("ApierV1.GetScheduledActions", AttrsGetScheduledActions{}, &rply); err != nil {
|
||||
t.Error("Unexpected error: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierLocalGetDataCost(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestApierITGetDataCost(t *testing.T) {
|
||||
attrs := AttrGetDataCost{Direction: "*out", Category: "data", Tenant: "cgrates.org", Account: "1001", Subject: "1001", StartTime: time.Now(), Usage: 640113}
|
||||
var rply *engine.DataCost
|
||||
if err := rater.Call("ApierV1.GetDataCost", attrs, &rply); err != nil {
|
||||
@@ -1730,27 +1544,18 @@ func TestApierLocalGetDataCost(t *testing.T) {
|
||||
|
||||
// Test LoadTPFromStorDb
|
||||
func TestApierInitDataDb2(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
if err := engine.InitDataDb(cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierInitStorDb2(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
if err := engine.InitStorDb(cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApierReloadCache2(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
arc := new(utils.AttrReloadCache)
|
||||
// Simple test that command is executed without errors
|
||||
@@ -1762,9 +1567,6 @@ func TestApierReloadCache2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierReloadScheduler2(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
reply := ""
|
||||
// Simple test that command is executed without errors
|
||||
if err := rater.Call("ApierV1.ReloadScheduler", reply, &reply); err != nil {
|
||||
@@ -1775,9 +1577,6 @@ func TestApierReloadScheduler2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierImportTPFromFolderPath(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var reply string
|
||||
if err := rater.Call("ApierV1.ImportTariffPlanFromFolder", utils.AttrImportTPFromFolder{TPid: "TEST_TPID2", FolderPath: "/usr/share/cgrates/tariffplans/tutorial"}, &reply); err != nil {
|
||||
t.Error("Got error on ApierV1.ImportTarrifPlanFromFolder: ", err.Error())
|
||||
@@ -1787,9 +1586,6 @@ func TestApierImportTPFromFolderPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierLoadTariffPlanFromStorDbDryRun(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var reply string
|
||||
if err := rater.Call("ApierV1.LoadTariffPlanFromStorDb", AttrLoadTpFromStorDb{TPid: "TEST_TPID2", DryRun: true}, &reply); err != nil {
|
||||
t.Error("Got error on ApierV1.LoadTariffPlanFromStorDb: ", err.Error())
|
||||
@@ -1799,9 +1595,6 @@ func TestApierLoadTariffPlanFromStorDbDryRun(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierGetCacheStats2(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var rcvStats *utils.CacheStats
|
||||
var args utils.AttrCacheStats
|
||||
err := rater.Call("ApierV1.GetCacheStats", args, &rcvStats)
|
||||
@@ -1814,9 +1607,6 @@ func TestApierGetCacheStats2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApierLoadTariffPlanFromStorDb(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var reply string
|
||||
if err := rater.Call("ApierV1.LoadTariffPlanFromStorDb", AttrLoadTpFromStorDb{TPid: "TEST_TPID2"}, &reply); err != nil {
|
||||
t.Error("Got error on ApierV1.LoadTariffPlanFromStorDb: ", err.Error())
|
||||
@@ -1827,9 +1617,6 @@ func TestApierLoadTariffPlanFromStorDb(t *testing.T) {
|
||||
|
||||
/*
|
||||
func TestApierGetCacheStats3(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var rcvStats *utils.CacheStats
|
||||
expectedStats := &utils.CacheStats{Destinations: 4, RatingPlans: 3, RatingProfiles: 8, Actions: 7, SharedGroups: 1, RatingAliases: 1, AccountAliases: 1, DerivedChargers: 1}
|
||||
var args utils.AttrCacheStats
|
||||
@@ -1842,8 +1629,5 @@ func TestApierGetCacheStats3(t *testing.T) {
|
||||
|
||||
// Simply kill the engine after we are done with tests within this file
|
||||
func TestApierStopEngine(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
exec.Command("pkill", "cgr-engine").Run()
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -34,10 +36,7 @@ var cdrstCfgPath string
|
||||
var cdrstCfg *config.CGRConfig
|
||||
var cdrstRpc *rpc.Client
|
||||
|
||||
func TestCDRStatsLclLoadConfig(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestCDRStatsitLoadConfig(t *testing.T) {
|
||||
var err error
|
||||
cdrstCfgPath = path.Join(*dataDir, "conf", "samples", "cdrstats")
|
||||
if cdrstCfg, err = config.NewCGRConfigFromFolder(cfgPath); err != nil {
|
||||
@@ -45,29 +44,20 @@ func TestCDRStatsLclLoadConfig(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDRStatsLclInitDataDb(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestCDRStatsitInitDataDb(t *testing.T) {
|
||||
if err := engine.InitDataDb(cdrstCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDRStatsLclStartEngine(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestCDRStatsitStartEngine(t *testing.T) {
|
||||
if _, err := engine.StopStartEngine(cdrstCfgPath, 1000); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestCDRStatsLclRpcConn(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestCDRStatsitRpcConn(t *testing.T) {
|
||||
var err error
|
||||
cdrstRpc, err = jsonrpc.Dial("tcp", cdrstCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
@@ -75,10 +65,7 @@ func TestCDRStatsLclRpcConn(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDRStatsLclLoadTariffPlanFromFolder(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestCDRStatsitLoadTariffPlanFromFolder(t *testing.T) {
|
||||
reply := ""
|
||||
// Simple test that command is executed without errors
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "cdrstats")}
|
||||
@@ -90,10 +77,7 @@ func TestCDRStatsLclLoadTariffPlanFromFolder(t *testing.T) {
|
||||
time.Sleep(time.Duration(*waitRater) * time.Millisecond) // Give time for scheduler to execute topups
|
||||
}
|
||||
|
||||
func TestCDRStatsLclGetQueueIds2(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestCDRStatsitGetQueueIds2(t *testing.T) {
|
||||
var queueIds []string
|
||||
eQueueIds := []string{"CDRST3", "CDRST4"}
|
||||
if err := cdrstRpc.Call("CDRStatsV1.GetQueueIds", "", &queueIds); err != nil {
|
||||
@@ -110,10 +94,7 @@ func TestCDRStatsLclGetQueueIds2(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDRStatsLclPostCdrs(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestCDRStatsitPostCdrs(t *testing.T) {
|
||||
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: "dsafdsafa",
|
||||
OriginHost: "192.168.1.1", Source: "test",
|
||||
@@ -153,10 +134,7 @@ func TestCDRStatsLclPostCdrs(t *testing.T) {
|
||||
time.Sleep(time.Duration(*waitRater) * time.Millisecond)
|
||||
}
|
||||
|
||||
func TestCDRStatsLclGetMetrics1(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestCDRStatsitGetMetrics1(t *testing.T) {
|
||||
var rcvMetrics2 map[string]float64
|
||||
expectedMetrics2 := map[string]float64{"ASR": 75, "ACD": 15}
|
||||
if err := cdrstRpc.Call("CDRStatsV1.GetMetrics", AttrGetMetrics{StatsQueueId: "CDRST4"}, &rcvMetrics2); err != nil {
|
||||
@@ -167,10 +145,7 @@ func TestCDRStatsLclGetMetrics1(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test stats persistence
|
||||
func TestCDRStatsLclStatsPersistence(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestCDRStatsitStatsPersistence(t *testing.T) {
|
||||
time.Sleep(time.Duration(2) * time.Second) // Allow stats to be updated in dataDb
|
||||
if _, err := engine.StopStartEngine(cdrstCfgPath, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -189,10 +164,7 @@ func TestCDRStatsLclStatsPersistence(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDRStatsLclResetMetrics(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestCDRStatsitResetMetrics(t *testing.T) {
|
||||
var reply string
|
||||
if err := cdrstRpc.Call("CDRStatsV1.ResetQueues", utils.AttrCDRStatsReloadQueues{StatsQueueIds: []string{"CDRST4"}}, &reply); err != nil {
|
||||
t.Error("Calling CDRStatsV1.ResetQueues, got error: ", err.Error())
|
||||
@@ -209,10 +181,7 @@ func TestCDRStatsLclResetMetrics(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCDRStatsLclKillEngine(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestCDRStatsitKillEngine(t *testing.T) {
|
||||
if err := engine.KillEngine(*waitRater); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -38,9 +40,6 @@ var smgV1Rpc *rpc.Client
|
||||
var smgV1LoadInst utils.LoadInstance // Share load information between tests
|
||||
|
||||
func TestSMGV1InitCfg(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
smgV1CfgPath = path.Join(*dataDir, "conf", "samples", "smgeneric")
|
||||
// Init config first
|
||||
var err error
|
||||
@@ -54,9 +53,6 @@ func TestSMGV1InitCfg(t *testing.T) {
|
||||
|
||||
// Remove data in both rating and accounting db
|
||||
func TestSMGV1ResetDataDb(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
if err := engine.InitDataDb(smgV1Cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -64,9 +60,6 @@ func TestSMGV1ResetDataDb(t *testing.T) {
|
||||
|
||||
// Wipe out the cdr database
|
||||
func TestSMGV1ResetStorDb(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
if err := engine.InitStorDb(smgV1Cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -74,9 +67,6 @@ func TestSMGV1ResetStorDb(t *testing.T) {
|
||||
|
||||
// Start CGR Engine
|
||||
func TestSMGV1StartEngine(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
if _, err := engine.StopStartEngine(smgV1CfgPath, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -84,9 +74,6 @@ func TestSMGV1StartEngine(t *testing.T) {
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestSMGV1RpcConn(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
smgV1Rpc, err = jsonrpc.Dial("tcp", smgV1Cfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
@@ -96,9 +83,6 @@ func TestSMGV1RpcConn(t *testing.T) {
|
||||
|
||||
// Load the tariff plan, creating accounts and their balances
|
||||
func TestSMGV1LoadTariffPlanFromFolder(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutorial")}
|
||||
if err := smgV1Rpc.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &smgV1LoadInst); err != nil {
|
||||
t.Error(err)
|
||||
@@ -110,11 +94,7 @@ func TestSMGV1LoadTariffPlanFromFolder(t *testing.T) {
|
||||
|
||||
// Check loaded stats
|
||||
func TestSMGV1CacheStats(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var rcvStats *utils.CacheStats
|
||||
|
||||
expectedStats := &utils.CacheStats{Destinations: 0, RatingPlans: 4, RatingProfiles: 0, Actions: 7, ActionPlans: 4, SharedGroups: 0, Aliases: 0, ResourceLimits: 0,
|
||||
DerivedChargers: 0, LcrProfiles: 0, CdrStats: 6, Users: 3}
|
||||
var args utils.AttrCacheStats
|
||||
@@ -127,9 +107,6 @@ func TestSMGV1CacheStats(t *testing.T) {
|
||||
|
||||
// Make sure account was debited properly
|
||||
func TestSMGV1AccountsBefore(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var reply *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}
|
||||
if err := smgV1Rpc.Call("ApierV2.GetAccount", attrs, &reply); err != nil {
|
||||
@@ -142,9 +119,6 @@ func TestSMGV1AccountsBefore(t *testing.T) {
|
||||
|
||||
// Make sure account was debited properly
|
||||
func TestSMGV1GetMaxUsage(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
setupReq := &sessionmanager.SMGenericEvent{utils.REQTYPE: utils.META_PREPAID, utils.TENANT: "cgrates.org",
|
||||
utils.ACCOUNT: "1003", utils.DESTINATION: "1002", utils.SETUP_TIME: "2015-11-10T15:20:00Z"}
|
||||
var maxTime float64
|
||||
@@ -156,9 +130,6 @@ func TestSMGV1GetMaxUsage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGV1StopCgrEngine(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
if err := engine.KillEngine(100); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
testIT = flag.Bool("integration", false, "Perform the tests only on local test environment, not by default.")
|
||||
dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
|
||||
waitRater = flag.Int("wait_rater", 500, "Number of miliseconds to wait for rater to start and cache")
|
||||
)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -51,8 +53,6 @@ var cdrcCfgs []*config.CdrcConfig
|
||||
var cdrcCfg *config.CdrcConfig
|
||||
var cdrcRpc *rpc.Client
|
||||
|
||||
var testLocal = flag.Bool("local", false, "Perform the tests only on local test environment, not by default.") // This flag will be passed here via "go test -local" args
|
||||
var testIT = flag.Bool("integration", false, "Perform the tests only on local test environment, not by default.") // This flag will be passed here via "go test -local" args
|
||||
var dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
|
||||
var waitRater = flag.Int("wait_rater", 300, "Number of miliseconds to wait for rater to start and cache")
|
||||
|
||||
@@ -66,9 +66,6 @@ accid22;*postpaid;itsyscom.com;1001;+4986517174963;2013-02-03 19:54:00;123;val_e
|
||||
accid23;*rated;cgrates.org;1001;086517174963;2013-02-03 19:54:00;26;val_extra3;"";val_extra1`
|
||||
|
||||
func TestCsvITInitConfig(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
csvCfgPath = path.Join(*dataDir, "conf", "samples", "cdrccsv")
|
||||
if csvCfg, err = config.NewCGRConfigFromFolder(csvCfgPath); err != nil {
|
||||
@@ -78,18 +75,12 @@ func TestCsvITInitConfig(t *testing.T) {
|
||||
|
||||
// InitDb so we can rely on count
|
||||
func TestCsvITInitCdrDb(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
if err := engine.InitStorDb(csvCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCsvITCreateCdrDirs(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
for _, cdrcProfiles := range csvCfg.CdrcProfiles {
|
||||
for _, cdrcInst := range cdrcProfiles {
|
||||
for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} {
|
||||
@@ -105,9 +96,6 @@ func TestCsvITCreateCdrDirs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCsvITStartEngine(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
if _, err := engine.StopStartEngine(csvCfgPath, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -115,9 +103,6 @@ func TestCsvITStartEngine(t *testing.T) {
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestCsvITRpcConn(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
cdrcRpc, err = jsonrpc.Dial("tcp", csvCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
@@ -127,9 +112,6 @@ func TestCsvITRpcConn(t *testing.T) {
|
||||
|
||||
// The default scenario, out of cdrc defined in .cfg file
|
||||
func TestCsvITHandleCdr1File(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
fileName := "file1.csv"
|
||||
tmpFilePath := path.Join("/tmp", fileName)
|
||||
if err := ioutil.WriteFile(tmpFilePath, []byte(fileContent1), 0644); err != nil {
|
||||
@@ -142,9 +124,6 @@ func TestCsvITHandleCdr1File(t *testing.T) {
|
||||
|
||||
// Scenario out of first .xml config
|
||||
func TestCsvITHandleCdr2File(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
fileName := "file2.csv"
|
||||
tmpFilePath := path.Join("/tmp", fileName)
|
||||
if err := ioutil.WriteFile(tmpFilePath, []byte(fileContent2), 0644); err != nil {
|
||||
@@ -156,9 +135,6 @@ func TestCsvITHandleCdr2File(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCsvITProcessedFiles(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Duration(2**waitRater) * time.Millisecond)
|
||||
if outContent1, err := ioutil.ReadFile("/tmp/cdrctests/csvit1/out/file1.csv"); err != nil {
|
||||
t.Error(err)
|
||||
@@ -173,9 +149,6 @@ func TestCsvITProcessedFiles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCsvITAnalyseCDRs(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
var reply []*engine.ExternalCDR
|
||||
if err := cdrcRpc.Call("ApierV2.GetCdrs", utils.RPCCDRsFilter{}, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
@@ -191,9 +164,6 @@ func TestCsvITAnalyseCDRs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCsvITKillEngine(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
if err := engine.KillEngine(*waitRater); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -55,10 +57,7 @@ var part1 = `BYE|f9d3d5c3|c863a6e3|214d8f52b566e33a9349b184e72a4ccb@0:0:0:0:0:0:
|
||||
var part2 = `INVITE|f9d3d5c3|c863a6e3|214d8f52b566e33a9349b184e72a4ccb@0:0:0:0:0:0:0:0|200|OK|1436454647|*postpaid|1002|1003||1877:893549742
|
||||
INVITE|2daec40c|548625ac|dd0c4c617a9919d29a6175cdff223a9e@0:0:0:0:0:0:0:0|200|OK|1436454408|*prepaid|1001|1002||3401:2069362475`
|
||||
|
||||
func TestFlatstoreLclInitCfg(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestFlatstoreitInitCfg(t *testing.T) {
|
||||
var err error
|
||||
flatstoreCfgPath = path.Join(*dataDir, "conf", "samples", "cdrcflatstore")
|
||||
if flatstoreCfg, err = config.NewCGRConfigFromFolder(flatstoreCfgPath); err != nil {
|
||||
@@ -67,20 +66,14 @@ func TestFlatstoreLclInitCfg(t *testing.T) {
|
||||
}
|
||||
|
||||
// InitDb so we can rely on count
|
||||
func TestFlatstoreLclInitCdrDb(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestFlatstoreitInitCdrDb(t *testing.T) {
|
||||
if err := engine.InitStorDb(flatstoreCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Creates cdr files and moves them into processing folder
|
||||
func TestFlatstoreLclCreateCdrFiles(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestFlatstoreitCreateCdrFiles(t *testing.T) {
|
||||
if flatstoreCfg == nil {
|
||||
t.Fatal("Empty default cdrc configuration")
|
||||
}
|
||||
@@ -103,20 +96,14 @@ func TestFlatstoreLclCreateCdrFiles(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlatstoreLclStartEngine(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestFlatstoreitStartEngine(t *testing.T) {
|
||||
if _, err := engine.StopStartEngine(flatstoreCfgPath, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestFlatstoreLclRpcConn(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestFlatstoreitRpcConn(t *testing.T) {
|
||||
var err error
|
||||
flatstoreRpc, err = jsonrpc.Dial("tcp", flatstoreCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
@@ -124,10 +111,7 @@ func TestFlatstoreLclRpcConn(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlatstoreLclProcessFiles(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestFlatstoreitProcessFiles(t *testing.T) {
|
||||
if err := ioutil.WriteFile(path.Join("/tmp", "acc_1.log"), []byte(fullSuccessfull), 0644); err != nil {
|
||||
t.Fatal(err.Error)
|
||||
}
|
||||
@@ -146,7 +130,7 @@ func TestFlatstoreLclProcessFiles(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
time.Sleep(time.Duration(2) * time.Second) // Give time for processing to happen and the .unparired file to be written
|
||||
time.Sleep(time.Duration(3) * time.Second) // Give time for processing to happen and the .unparired file to be written
|
||||
filesInDir, _ := ioutil.ReadDir(flatstoreCdrcCfg.CdrInDir)
|
||||
if len(filesInDir) != 0 {
|
||||
t.Errorf("Files in cdrcInDir: %+v", filesInDir)
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -35,7 +37,7 @@ var fwvCfg *config.CGRConfig
|
||||
var fwvRpc *rpc.Client
|
||||
var fwvCdrcCfg *config.CdrcConfig
|
||||
|
||||
var FW_CDR_FILE1 = `HDR0001DDB ABC Some Connect A.B. DDB-Some-10022-20120711-309.CDR 00030920120711100255
|
||||
var FW_CDR_FILE1 = `HDR0001DDB ABC Some Connect A.B. DDB-Some-10022-20120711-309.CDR 00030920120711100255
|
||||
CDR0000010 0 20120708181506000123451234 0040123123120 004 000018009980010001ISDN ABC 10Buiten uw regio EHV 00000009190000000009
|
||||
CDR0000020 0 20120708190945000123451234 0040123123120 004 000016009980010001ISDN ABC 10Buiten uw regio EHV 00000009190000000009
|
||||
CDR0000030 0 20120708191009000123451234 0040123123120 004 000020009980010001ISDN ABC 10Buiten uw regio EHV 00000009190000000009
|
||||
@@ -69,13 +71,10 @@ CDR0000300 0 20120709073707000123123459 0040123234531
|
||||
CDR0000310 0 20120709085451000123451237 0040012323453100 001 000744009980030001ISDN ABD 20Internationaal NLB 00000000190000000000
|
||||
CDR0000320 0 20120709091756000123451237 0040012323453100 001 000050009980030001ISDN ABD 20Internationaal NLB 00000000190000000000
|
||||
CDR0000330 0 20120710070434000123123458 0040123232350 004 000012002760000001PSTN 276 10Buiten uw regio TB 00000009190000000009
|
||||
TRL0001DDB ABC Some Connect A.B. DDB-Some-10022-20120711-309.CDR 0003090000003300000030550000000001000000000100Y
|
||||
TRL0001DDB ABC Some Connect A.B. DDB-Some-10022-20120711-309.CDR 0003090000003300000030550000000001000000000100Y
|
||||
`
|
||||
|
||||
func TestFwvLclInitCfg(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestFwvitInitCfg(t *testing.T) {
|
||||
var err error
|
||||
fwvCfgPath = path.Join(*dataDir, "conf", "samples", "cdrcfwv")
|
||||
if fwvCfg, err = config.NewCGRConfigFromFolder(fwvCfgPath); err != nil {
|
||||
@@ -84,10 +83,7 @@ func TestFwvLclInitCfg(t *testing.T) {
|
||||
}
|
||||
|
||||
// Creates cdr files and moves them into processing folder
|
||||
func TestFwvLclCreateCdrFiles(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestFwvitCreateCdrFiles(t *testing.T) {
|
||||
if fwvCfg == nil {
|
||||
t.Fatal("Empty default cdrc configuration")
|
||||
}
|
||||
@@ -110,20 +106,14 @@ func TestFwvLclCreateCdrFiles(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFwvLclStartEngine(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestFwvitStartEngine(t *testing.T) {
|
||||
if _, err := engine.StopStartEngine(fwvCfgPath, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestFwvLclRpcConn(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestFwvitRpcConn(t *testing.T) {
|
||||
var err error
|
||||
fwvRpc, err = jsonrpc.Dial("tcp", fwvCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
@@ -131,10 +121,7 @@ func TestFwvLclRpcConn(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFwvLclProcessFiles(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestFwvitProcessFiles(t *testing.T) {
|
||||
fileName := "test1.fwv"
|
||||
if err := ioutil.WriteFile(path.Join("/tmp", fileName), []byte(FW_CDR_FILE1), 0644); err != nil {
|
||||
t.Fatal(err.Error)
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -49,9 +51,6 @@ var eCacheDumpFile1 = `4986517174963_004986517174964_04.07.2016 18:58:55,1467651
|
||||
`
|
||||
|
||||
func TestPartcsvITInitConfig(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
partpartcsvCfgPath = path.Join(*dataDir, "conf", "samples", "cdrc_partcsv")
|
||||
if partcsvCfg, err = config.NewCGRConfigFromFolder(partpartcsvCfgPath); err != nil {
|
||||
@@ -61,18 +60,12 @@ func TestPartcsvITInitConfig(t *testing.T) {
|
||||
|
||||
// InitDb so we can rely on count
|
||||
func TestPartcsvITInitCdrDb(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
if err := engine.InitStorDb(partcsvCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartcsvITCreateCdrDirs(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
for path, cdrcProfiles := range partcsvCfg.CdrcProfiles {
|
||||
for _, cdrcInst := range cdrcProfiles {
|
||||
if path == "/tmp/cdrctests/partcsv1/in" {
|
||||
@@ -93,9 +86,6 @@ func TestPartcsvITCreateCdrDirs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPartcsvITStartEngine(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
if _, err := engine.StopStartEngine(partpartcsvCfgPath, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -103,9 +93,6 @@ func TestPartcsvITStartEngine(t *testing.T) {
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestPartcsvITRpcConn(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
partcsvRPC, err = jsonrpc.Dial("tcp", partcsvCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
@@ -115,9 +102,6 @@ func TestPartcsvITRpcConn(t *testing.T) {
|
||||
|
||||
// The default scenario, out of cdrc defined in .cfg file
|
||||
func TestPartcsvITHandleCdr1File(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
fileName := "file1.csv"
|
||||
tmpFilePath := path.Join("/tmp", fileName)
|
||||
if err := ioutil.WriteFile(tmpFilePath, []byte(partCsvFileContent1), 0644); err != nil {
|
||||
@@ -130,9 +114,6 @@ func TestPartcsvITHandleCdr1File(t *testing.T) {
|
||||
|
||||
// Scenario out of first .xml config
|
||||
func TestPartcsvITHandleCdr2File(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
fileName := "file2.csv"
|
||||
tmpFilePath := path.Join("/tmp", fileName)
|
||||
if err := ioutil.WriteFile(tmpFilePath, []byte(partCsvFileContent2), 0644); err != nil {
|
||||
@@ -145,9 +126,6 @@ func TestPartcsvITHandleCdr2File(t *testing.T) {
|
||||
|
||||
// Scenario out of first .xml config
|
||||
func TestPartcsvITHandleCdr3File(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
fileName := "file3.csv"
|
||||
tmpFilePath := path.Join("/tmp", fileName)
|
||||
if err := ioutil.WriteFile(tmpFilePath, []byte(partCsvFileContent3), 0644); err != nil {
|
||||
@@ -159,9 +137,6 @@ func TestPartcsvITHandleCdr3File(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPartcsvITProcessedFiles(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Duration(3 * time.Second))
|
||||
if outContent1, err := ioutil.ReadFile(path.Join(partcsvCDRCDirOut1, "file1.csv")); err != nil {
|
||||
t.Error(err)
|
||||
@@ -194,9 +169,6 @@ func TestPartcsvITProcessedFiles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPartcsvITAnalyseCDRs(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
var reply []*engine.ExternalCDR
|
||||
if err := partcsvRPC.Call("ApierV2.GetCdrs", utils.RPCCDRsFilter{}, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
@@ -217,9 +189,6 @@ func TestPartcsvITAnalyseCDRs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPartcsvITKillEngine(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
if err := engine.KillEngine(*waitRater); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -39,9 +41,6 @@ var cdrcXmlRPC *rpc.Client
|
||||
var xmlPathIn1, xmlPathOut1 string
|
||||
|
||||
func TestXmlITInitConfig(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
xmlCfgPath = path.Join(*dataDir, "conf", "samples", "cdrcxml")
|
||||
if xmlCfg, err = config.NewCGRConfigFromFolder(xmlCfgPath); err != nil {
|
||||
@@ -51,18 +50,12 @@ func TestXmlITInitConfig(t *testing.T) {
|
||||
|
||||
// InitDb so we can rely on count
|
||||
func TestXmlITInitCdrDb(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
if err := engine.InitStorDb(xmlCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestXmlITCreateCdrDirs(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
for _, cdrcProfiles := range xmlCfg.CdrcProfiles {
|
||||
for i, cdrcInst := range cdrcProfiles {
|
||||
for _, dir := range []string{cdrcInst.CdrInDir, cdrcInst.CdrOutDir} {
|
||||
@@ -82,9 +75,6 @@ func TestXmlITCreateCdrDirs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestXmlITStartEngine(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
if _, err := engine.StopStartEngine(xmlCfgPath, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -92,9 +82,6 @@ func TestXmlITStartEngine(t *testing.T) {
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestXmlITRpcConn(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
cdrcXmlRPC, err = jsonrpc.Dial("tcp", xmlCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
@@ -104,9 +91,6 @@ func TestXmlITRpcConn(t *testing.T) {
|
||||
|
||||
// The default scenario, out of cdrc defined in .cfg file
|
||||
func TestXmlITHandleCdr1File(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
fileName := "file1.xml"
|
||||
tmpFilePath := path.Join("/tmp", fileName)
|
||||
if err := ioutil.WriteFile(tmpFilePath, []byte(cdrXmlBroadsoft), 0644); err != nil {
|
||||
@@ -118,9 +102,6 @@ func TestXmlITHandleCdr1File(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestXmlITProcessedFiles(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Duration(2**waitRater) * time.Millisecond)
|
||||
if outContent1, err := ioutil.ReadFile(path.Join(xmlPathOut1, "file1.xml")); err != nil {
|
||||
t.Error(err)
|
||||
@@ -130,9 +111,6 @@ func TestXmlITProcessedFiles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestXmlITAnalyseCDRs(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
var reply []*engine.ExternalCDR
|
||||
if err := cdrcXmlRPC.Call("ApierV2.GetCdrs", utils.RPCCDRsFilter{}, &reply); err != nil {
|
||||
t.Error("Unexpected error: ", err.Error())
|
||||
@@ -148,9 +126,6 @@ func TestXmlITAnalyseCDRs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestXmlITKillEngine(t *testing.T) {
|
||||
if !*testIT {
|
||||
return
|
||||
}
|
||||
if err := engine.KillEngine(*waitRater); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -18,19 +20,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package config
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var testLocal = flag.Bool("local", false, "Perform the tests only on local test environment, disabled by default.") // This flag will be passed here via "go test -local" args
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var mfCgrCfg *CGRConfig
|
||||
|
||||
func TestMfInitConfig(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
if mfCgrCfg, err = NewCGRConfigFromFolder("/usr/share/cgrates/conf/samples/multifiles"); err != nil {
|
||||
t.Fatal("Got config error: ", err.Error())
|
||||
@@ -38,9 +36,7 @@ func TestMfInitConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMfGeneralItems(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
if mfCgrCfg.DefaultReqType != utils.META_PSEUDOPREPAID { // Twice reconfigured
|
||||
t.Error("DefaultReqType: ", mfCgrCfg.DefaultReqType)
|
||||
}
|
||||
@@ -50,9 +46,7 @@ func TestMfGeneralItems(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMfCdreDefaultInstance(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
for _, prflName := range []string{"*default", "export1"} {
|
||||
if _, hasIt := mfCgrCfg.CdreProfiles[prflName]; !hasIt {
|
||||
t.Error("Cdre does not contain profile ", prflName)
|
||||
@@ -77,9 +71,7 @@ func TestMfCdreDefaultInstance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMfCdreExport1Instance(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
prfl := "export1"
|
||||
if mfCgrCfg.CdreProfiles[prfl].CdrFormat != "csv" {
|
||||
t.Error("Export1 instance has cdrFormat: ", mfCgrCfg.CdreProfiles[prfl].CdrFormat)
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -36,10 +38,8 @@ var actsLclCfgPath = path.Join(*dataDir, "conf", "samples", "actions")
|
||||
|
||||
var waitRater = flag.Int("wait_rater", 100, "Number of miliseconds to wait for rater to start and cache")
|
||||
|
||||
func TestActionsLocalInitCfg(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestActionsitInitCfg(t *testing.T) {
|
||||
|
||||
// Init config first
|
||||
var err error
|
||||
actsLclCfg, err = config.NewCGRConfigFromFolder(actsLclCfgPath)
|
||||
@@ -50,30 +50,24 @@ func TestActionsLocalInitCfg(t *testing.T) {
|
||||
config.SetCgrConfig(actsLclCfg)
|
||||
}
|
||||
|
||||
func TestActionsLocalInitCdrDb(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestActionsitInitCdrDb(t *testing.T) {
|
||||
|
||||
if err := InitStorDb(actsLclCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Finds cgr-engine executable and starts it with default configuration
|
||||
func TestActionsLocalStartEngine(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestActionsitStartEngine(t *testing.T) {
|
||||
|
||||
if _, err := StartEngine(actsLclCfgPath, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestActionsLocalRpcConn(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestActionsitRpcConn(t *testing.T) {
|
||||
|
||||
var err error
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
actsLclRpc, err = jsonrpc.Dial("tcp", actsLclCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
@@ -82,10 +76,8 @@ func TestActionsLocalRpcConn(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestActionsLocalSetCdrlogDebit(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestActionsitSetCdrlogDebit(t *testing.T) {
|
||||
|
||||
var reply string
|
||||
attrsSetAccount := &utils.AttrSetAccount{Tenant: "cgrates.org", Account: "dan2904"}
|
||||
if err := actsLclRpc.Call("ApierV1.SetAccount", attrsSetAccount, &reply); err != nil {
|
||||
@@ -127,10 +119,8 @@ func TestActionsLocalSetCdrlogDebit(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestActionsLocalSetCdrlogTopup(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestActionsitSetCdrlogTopup(t *testing.T) {
|
||||
|
||||
var reply string
|
||||
attrsSetAccount := &utils.AttrSetAccount{Tenant: "cgrates.org", Account: "dan2905"}
|
||||
if err := actsLclRpc.Call("ApierV1.SetAccount", attrsSetAccount, &reply); err != nil {
|
||||
@@ -173,10 +163,8 @@ func TestActionsLocalSetCdrlogTopup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestActionsLocalStopCgrEngine(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
func TestActionsitStopCgrEngine(t *testing.T) {
|
||||
|
||||
if err := KillEngine(*waitRater); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var err error
|
||||
var (
|
||||
//referenceDate = time.Date(2013, 7, 10, 10, 30, 0, 0, time.Local)
|
||||
//referenceDate = time.Date(2013, 12, 31, 23, 59, 59, 0, time.Local)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -27,14 +29,11 @@ import (
|
||||
)
|
||||
|
||||
// Arguments received via test command
|
||||
var testLocal = flag.Bool("local", false, "Perform the tests only on local test environment, not by default.") // This flag will be passed here via "go test -local" args
|
||||
var dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
|
||||
|
||||
// Sample HttpJsonPost, more for usage purposes
|
||||
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",
|
||||
OriginHost: "192.168.1.1",
|
||||
Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org",
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -37,9 +39,7 @@ var tpCsvScenario = flag.String("tp_scenario", "testtp", "Use this scenario fold
|
||||
// Create connection to ratingDb
|
||||
// Will use 3 different datadbs in order to be able to see differences in data loaded
|
||||
func TestConnDataDbs(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
lCfg, _ = config.NewDefaultCGRConfig()
|
||||
var err error
|
||||
if ratingDbCsv, err = ConfigureRatingStorage(lCfg.TpDbType, lCfg.TpDbHost, lCfg.TpDbPort, "4", lCfg.TpDbUser, lCfg.TpDbPass, lCfg.DBDataEncoding, nil, 1); err != nil {
|
||||
@@ -73,9 +73,7 @@ func TestConnDataDbs(t *testing.T) {
|
||||
|
||||
// Create/reset storage tariff plan tables, used as database connectin establishment also
|
||||
func TestCreateStorTpTables(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
db, err := NewMySQLStorage(lCfg.StorDBHost, lCfg.StorDBPort, lCfg.StorDBName, lCfg.StorDBUser, lCfg.StorDBPass, lCfg.StorDBMaxOpenConns, lCfg.StorDBMaxIdleConns)
|
||||
if err != nil {
|
||||
t.Error("Error on opening database connection: ", err)
|
||||
@@ -92,9 +90,7 @@ func TestCreateStorTpTables(t *testing.T) {
|
||||
|
||||
// Loads data from csv files in tp scenario to ratingDbCsv
|
||||
func TestLoadFromCSV(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
/*var err error
|
||||
for fn, v := range FileValidators {
|
||||
if err = ValidateCSVData(path.Join(*dataDir, "tariffplans", *tpCsvScenario, fn), v.Rule); err != nil {
|
||||
@@ -173,9 +169,7 @@ func TestLoadFromCSV(t *testing.T) {
|
||||
|
||||
// Imports data from csv files in tpScenario to storDb
|
||||
func TestImportToStorDb(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
csvImporter := TPCSVImporter{
|
||||
TPid: utils.TEST_SQL,
|
||||
StorDb: storDb,
|
||||
@@ -195,9 +189,7 @@ func TestImportToStorDb(t *testing.T) {
|
||||
|
||||
// Loads data from storDb into ratingDb
|
||||
func TestLoadFromStorDb(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
loader := NewTpReader(ratingDbStor, accountDbStor, storDb, utils.TEST_SQL, "")
|
||||
if err := loader.LoadDestinations(); err != nil {
|
||||
t.Error("Failed loading destinations: ", err.Error())
|
||||
@@ -244,9 +236,7 @@ func TestLoadFromStorDb(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadIndividualProfiles(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
loader := NewTpReader(ratingDbApier, accountDbApier, storDb, utils.TEST_SQL, "")
|
||||
// Load ratingPlans. This will also set destination keys
|
||||
if ratingPlans, err := storDb.GetTpRatingPlans(utils.TEST_SQL, "", nil); err != nil {
|
||||
@@ -367,9 +357,7 @@ func TestLoadIndividualProfiles(t *testing.T) {
|
||||
/*
|
||||
// Compares previously loaded data from csv and stor to be identical, redis specific tests
|
||||
func TestMatchLoadCsvWithStorRating(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
rsCsv, redisDb := ratingDbCsv.(*RedisStorage)
|
||||
if !redisDb {
|
||||
return // We only support these tests for redis
|
||||
@@ -402,9 +390,7 @@ func TestMatchLoadCsvWithStorRating(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMatchLoadCsvWithStorAccounting(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
rsCsv, redisDb := accountDbCsv.(*RedisStorage)
|
||||
if !redisDb {
|
||||
return // We only support these tests for redis
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -19,7 +21,6 @@ package engine
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"path"
|
||||
"strconv"
|
||||
@@ -30,12 +31,8 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var testIntegration = flag.Bool("integration", false, "Perform the tests in integration mode, not by default.") // This flag will be passed here via "go test -local" args
|
||||
|
||||
func TestITCDRsMySQL(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
|
||||
cfg, err := config.NewCGRConfigFromFolder(path.Join(*dataDir, "conf", "samples", "storage", "mysql"))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
@@ -52,9 +49,7 @@ func TestITCDRsMySQL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestITCDRsPSQL(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
|
||||
cfg, err := config.NewCGRConfigFromFolder(path.Join(*dataDir, "conf", "samples", "storage", "postgres"))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
@@ -71,9 +66,7 @@ func TestITCDRsPSQL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestITCDRsMongo(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
|
||||
cfg, err := config.NewCGRConfigFromFolder(path.Join(*dataDir, "conf", "samples", "storage", "mongo"))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -29,9 +31,7 @@ import (
|
||||
var mgoITDB *MongoStorage
|
||||
|
||||
func TestMGOitConnect(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
cdrsMongoCfgPath := path.Join(*dataDir, "conf", "samples", "cdrsv2mongo")
|
||||
mgoITCfg, err := config.NewCGRConfigFromFolder(cdrsMongoCfgPath)
|
||||
@@ -45,18 +45,14 @@ func TestMGOitConnect(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMGOitFlush(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
|
||||
if err := mgoITDB.Flush(""); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMGOitSetReqFilterIndexes(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
|
||||
idxes := map[string]map[string]utils.StringMap{
|
||||
"Account": map[string]utils.StringMap{
|
||||
"1001": utils.StringMap{
|
||||
@@ -88,9 +84,7 @@ func TestMGOitSetReqFilterIndexes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMGOitGetReqFilterIndexes(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
|
||||
eIdxes := map[string]map[string]utils.StringMap{
|
||||
"Account": map[string]utils.StringMap{
|
||||
"1001": utils.StringMap{
|
||||
@@ -127,9 +121,7 @@ func TestMGOitGetReqFilterIndexes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMGOitMatchReqFilterIndex(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
|
||||
eMp := utils.StringMap{
|
||||
"RL1": true,
|
||||
"RL2": true,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -28,12 +30,8 @@ import (
|
||||
)
|
||||
|
||||
var rds *RedisStorage
|
||||
var err error
|
||||
|
||||
func TestRDSitConnectRedis(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
cfg, _ := config.NewDefaultCGRConfig()
|
||||
rds, err = NewRedisStorage(fmt.Sprintf("%s:%s", cfg.TpDbHost, cfg.TpDbPort), 4, cfg.TpDbPass, cfg.DBDataEncoding, utils.REDIS_MAX_CONNS, nil, 1)
|
||||
if err != nil {
|
||||
@@ -42,9 +40,6 @@ func TestRDSitConnectRedis(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRDSitFlush(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := rds.Flush(""); err != nil {
|
||||
t.Error("Failed to Flush redis database", err.Error())
|
||||
}
|
||||
@@ -52,9 +47,6 @@ func TestRDSitFlush(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRDSitSetGetDerivedCharges(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
keyCharger1 := utils.ConcatenatedKey("*out", "cgrates.org", "call", "dan", "dan")
|
||||
charger1 := &utils.DerivedChargers{Chargers: []*utils.DerivedCharger{
|
||||
&utils.DerivedCharger{RunID: "extra1", RequestTypeField: "^prepaid", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
|
||||
@@ -80,9 +72,6 @@ func TestRDSitSetGetDerivedCharges(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRDSitSetReqFilterIndexes(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
idxes := map[string]map[string]utils.StringMap{
|
||||
"Account": map[string]utils.StringMap{
|
||||
"1001": utils.StringMap{
|
||||
@@ -114,9 +103,6 @@ func TestRDSitSetReqFilterIndexes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRDSitGetReqFilterIndexes(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
eIdxes := map[string]map[string]utils.StringMap{
|
||||
"Account": map[string]utils.StringMap{
|
||||
"1001": utils.StringMap{
|
||||
@@ -153,9 +139,6 @@ func TestRDSitGetReqFilterIndexes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRDSitMatchReqFilterIndex(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
eMp := utils.StringMap{
|
||||
"RL1": true,
|
||||
"RL2": true,
|
||||
|
||||
@@ -170,9 +170,6 @@ func TestCdrsFileFailover(t *testing.T) {
|
||||
// Performance test, check `lsof -a -p 8427 | wc -l`
|
||||
|
||||
func TestCdrsHttpCdrReplication2(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
cdrs := make([]*engine.CDR, 0)
|
||||
for i := 0; i < 10000; i++ {
|
||||
cdr := &engine.CDR{OriginID: fmt.Sprintf("httpjsonrpc_%d", i),
|
||||
|
||||
@@ -39,9 +39,6 @@ var destCfg *config.CGRConfig
|
||||
var destRPC *rpc.Client
|
||||
|
||||
func TestDestManagInitCfg(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
destCfgPath = path.Join(*dataDir, "conf", "samples", "tutmysql")
|
||||
// Init config first
|
||||
var err error
|
||||
@@ -55,9 +52,6 @@ func TestDestManagInitCfg(t *testing.T) {
|
||||
|
||||
// Remove data in both rating and accounting db
|
||||
func TestDestManagResetDataDb(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.InitDataDb(destCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -65,9 +59,6 @@ func TestDestManagResetDataDb(t *testing.T) {
|
||||
|
||||
// Wipe out the cdr database
|
||||
func TestDestManagResetStorDb(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.InitStorDb(destCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -75,9 +66,6 @@ func TestDestManagResetStorDb(t *testing.T) {
|
||||
|
||||
// Start CGR Engine
|
||||
func TestDestManagStartEngine(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if _, err := engine.StopStartEngine(destCfgPath, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -85,9 +73,6 @@ func TestDestManagStartEngine(t *testing.T) {
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestDestManagRpcConn(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
destRPC, err = jsonrpc.Dial("tcp", destCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
@@ -97,9 +82,6 @@ func TestDestManagRpcConn(t *testing.T) {
|
||||
|
||||
// Load the tariff plan, creating accounts and their balances
|
||||
func TestDestManagLoadTariffPlanFromFolderAll(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "test", "destinations", "alldests")}
|
||||
var destLoadInst utils.LoadInstance
|
||||
if err := destRPC.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &destLoadInst); err != nil {
|
||||
@@ -110,9 +92,6 @@ func TestDestManagLoadTariffPlanFromFolderAll(t *testing.T) {
|
||||
|
||||
|
||||
func TestDestManagAllDestinationLoaded(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
dests := make([]*engine.Destination, 0)
|
||||
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
|
||||
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
|
||||
@@ -130,9 +109,6 @@ func TestDestManagAllDestinationLoaded(t *testing.T) {
|
||||
|
||||
|
||||
func TestDestManagLoadTariffPlanFromFolderRemoveSome(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "test", "destinations", "removesome")}
|
||||
var destLoadInst utils.LoadInstance
|
||||
if err := destRPC.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &destLoadInst); err != nil {
|
||||
@@ -142,9 +118,6 @@ func TestDestManagLoadTariffPlanFromFolderRemoveSome(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDestManagRemoveSomeDestinationLoaded(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
dests := make([]*engine.Destination, 0)
|
||||
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
|
||||
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
|
||||
@@ -161,9 +134,6 @@ func TestDestManagRemoveSomeDestinationLoaded(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDestManagLoadTariffPlanFromFolderRemoveSomeFlush(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "test", "destinations", "removesome"), FlushDb: true}
|
||||
var destLoadInst utils.LoadInstance
|
||||
if err := destRPC.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &destLoadInst); err != nil {
|
||||
@@ -173,9 +143,6 @@ func TestDestManagLoadTariffPlanFromFolderRemoveSomeFlush(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDestManagRemoveSomeFlushDestinationLoaded(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
dests := make([]*engine.Destination, 0)
|
||||
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
|
||||
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
|
||||
@@ -192,9 +159,6 @@ func TestDestManagRemoveSomeFlushDestinationLoaded(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDestManagLoadTariffPlanFromFolderAddBack(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "test", "destinations", "addback")}
|
||||
var destLoadInst utils.LoadInstance
|
||||
if err := destRPC.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &destLoadInst); err != nil {
|
||||
@@ -204,9 +168,6 @@ func TestDestManagLoadTariffPlanFromFolderAddBack(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDestManagAddBackDestinationLoaded(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
dests := make([]*engine.Destination, 0)
|
||||
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
|
||||
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
|
||||
@@ -223,9 +184,6 @@ func TestDestManagAddBackDestinationLoaded(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDestManagLoadTariffPlanFromFolderAddOne(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "test", "destinations", "addone")}
|
||||
var destLoadInst utils.LoadInstance
|
||||
if err := destRPC.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &destLoadInst); err != nil {
|
||||
@@ -235,9 +193,6 @@ func TestDestManagLoadTariffPlanFromFolderAddOne(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDestManagAddOneDestinationLoaded(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
dests := make([]*engine.Destination, 0)
|
||||
if err := destRPC.Call("ApierV2.GetDestinations", v2.AttrGetDestinations{DestinationIDs: []string{}}, &dests); err != nil {
|
||||
t.Error("Got error on ApierV2.GetDestinations: ", err.Error())
|
||||
@@ -254,9 +209,6 @@ func TestDestManagAddOneDestinationLoaded(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDestManagCacheWithGetCache(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.InitDataDb(destCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -308,9 +260,6 @@ func TestDestManagCacheWithGetCache(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDestManagCacheWithGetCost(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.InitDataDb(destCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ var cfgPath string
|
||||
var cfg *config.CGRConfig
|
||||
var rater *rpc.Client
|
||||
|
||||
var testLocal = flag.Bool("local", false, "Perform the tests only on local test environment, not by default.") // This flag will be passed here via "go test -local" args
|
||||
var testCalls = flag.Bool("calls", false, "Run test calls simulation, not by default.")
|
||||
var dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
|
||||
var storDbType = flag.String("stordb_type", "mysql", "The type of the storDb database <mysql>")
|
||||
|
||||
@@ -279,9 +279,6 @@ func TestRPCITLclStatusBcastRALs1Up(t *testing.T) {
|
||||
|
||||
/*
|
||||
func TestRPCITStatusBcastCmd(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var stats utils.CacheStats
|
||||
if err := rpcRAL1.Call("ApierV2.GetCacheStats", utils.AttrCacheStats{}, &stats); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -105,9 +105,6 @@ func TestTutSMGCacheStats(t *testing.T) {
|
||||
/*
|
||||
// Make sure account was debited properly
|
||||
func TestTutSMGAccountsBefore(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
var reply *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}
|
||||
if err := tutSMGRpc.Call("ApierV2.GetAccount", attrs, &reply); err != nil {
|
||||
|
||||
@@ -1218,9 +1218,6 @@ func TestTutITSetAccount(t *testing.T) {
|
||||
/*
|
||||
// Make sure all stats queues were updated
|
||||
func TestTutITCdrStatsAfter(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var statMetrics map[string]float64
|
||||
eMetrics := map[string]float64{engine.ACD: 90.2, engine.ASR: 100, engine.TCC: 1.675, engine.TCD: 451, engine.ACC: 0.335}
|
||||
if err := tutLocalRpc.Call("CDRStatsV1.GetMetrics", v1.AttrGetMetrics{StatsQueueId: "CDRST1"}, &statMetrics); err != nil {
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
#! /usr/bin/env sh
|
||||
./test.sh
|
||||
gen=$?
|
||||
echo 'go test github.com/cgrates/cgrates/apier/v1 -local'
|
||||
go test github.com/cgrates/cgrates/apier/v1 -local
|
||||
echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=integration'
|
||||
go test github.com/cgrates/cgrates/apier/v1 -tags=integration
|
||||
ap1=$?
|
||||
echo 'go test github.com/cgrates/cgrates/apier/v2 -tags=integration'
|
||||
go test github.com/cgrates/cgrates/apier/v2 -tags=integration
|
||||
ap2=$?
|
||||
echo 'go test github.com/cgrates/cgrates/engine -local -integration'
|
||||
go test github.com/cgrates/cgrates/engine -local -integration
|
||||
echo 'go test github.com/cgrates/cgrates/engine -tags=integration'
|
||||
go test github.com/cgrates/cgrates/engine -tags=integration
|
||||
en=$?
|
||||
echo 'go test github.com/cgrates/cgrates/cdrc -local'
|
||||
go test github.com/cgrates/cgrates/cdrc -local
|
||||
echo 'go test github.com/cgrates/cgrates/cdrc -tags=integration'
|
||||
go test github.com/cgrates/cgrates/cdrc -tags=integration
|
||||
cdrc=$?
|
||||
echo 'go test github.com/cgrates/cgrates/config -local'
|
||||
go test github.com/cgrates/cgrates/config -local
|
||||
echo 'go test github.com/cgrates/cgrates/config -tags=integration'
|
||||
go test github.com/cgrates/cgrates/config -tags=integration
|
||||
cfg=$?
|
||||
echo 'go test github.com/cgrates/cgrates/utils -local'
|
||||
go test github.com/cgrates/cgrates/utils -local
|
||||
echo 'go test github.com/cgrates/cgrates/utils -tags=integration'
|
||||
go test github.com/cgrates/cgrates/utils -tags=integration
|
||||
utl=$?
|
||||
echo 'go test github.com/cgrates/cgrates/general_tests -tags=integration'
|
||||
go test github.com/cgrates/cgrates/general_tests -tags=integration
|
||||
gnr=$?
|
||||
echo 'go test github.com/cgrates/cgrates/agents -integration'
|
||||
go test github.com/cgrates/cgrates/agents -integration
|
||||
echo 'go test github.com/cgrates/cgrates/agents -tags=integration'
|
||||
go test github.com/cgrates/cgrates/agents -tags=integration
|
||||
agts=$?
|
||||
echo 'go test github.com/cgrates/cgrates/sessionmanager -integration'
|
||||
go test github.com/cgrates/cgrates/sessionmanager -integration
|
||||
echo 'go test github.com/cgrates/cgrates/sessionmanager -tags=integration'
|
||||
go test github.com/cgrates/cgrates/sessionmanager -tags=integration
|
||||
smg=$?
|
||||
|
||||
exit $gen && $ap1 && $ap2 && $en && $cdrc && $cfg && $utl && $gnr && $agts && $smg
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -29,9 +31,6 @@ import (
|
||||
)
|
||||
|
||||
func TestSMGDataInitCfg(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
daCfgPath = path.Join(*dataDir, "conf", "samples", "smg")
|
||||
// Init config first
|
||||
var err error
|
||||
@@ -45,9 +44,6 @@ func TestSMGDataInitCfg(t *testing.T) {
|
||||
|
||||
// Remove data in both rating and accounting db
|
||||
func TestSMGDataResetDataDb(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.InitDataDb(daCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -55,9 +51,6 @@ func TestSMGDataResetDataDb(t *testing.T) {
|
||||
|
||||
// Wipe out the cdr database
|
||||
func TestSMGDataResetStorDb(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.InitStorDb(daCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -65,9 +58,6 @@ func TestSMGDataResetStorDb(t *testing.T) {
|
||||
|
||||
// Start CGR Engine
|
||||
func TestSMGDataStartEngine(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if _, err := engine.StopStartEngine(daCfgPath, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -75,9 +65,7 @@ func TestSMGDataStartEngine(t *testing.T) {
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestSMGDataApierRpcConn(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
smgRPC, err = jsonrpc.Dial("tcp", daCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
@@ -87,9 +75,6 @@ func TestSMGDataApierRpcConn(t *testing.T) {
|
||||
|
||||
// Load the tariff plan, creating accounts and their balances
|
||||
func TestSMGDataTPFromFolder(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "testtp")}
|
||||
var loadInst utils.LoadInstance
|
||||
if err := smgRPC.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &loadInst); err != nil {
|
||||
@@ -99,9 +84,6 @@ func TestSMGDataTPFromFolder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGDataLastUsedData(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var acnt *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1010"}
|
||||
eAcntVal := 50000000000.000000
|
||||
@@ -194,9 +176,6 @@ func TestSMGDataLastUsedData(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGDataLastUsedMultipleData(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var acnt *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1010"}
|
||||
eAcntVal := 49999979520.000000
|
||||
@@ -392,9 +371,6 @@ func TestSMGDataLastUsedMultipleData(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGDataDerivedChargingNoCredit(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var acnt *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1011"}
|
||||
eAcntVal := 50000.0
|
||||
@@ -436,9 +412,6 @@ func TestSMGDataDerivedChargingNoCredit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGDataTTLExpired(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var acnt *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1010"}
|
||||
eAcntVal := 49999897600.000000
|
||||
@@ -485,9 +458,6 @@ func TestSMGDataTTLExpired(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGDataTTLExpiredMultiUpdates(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var acnt *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1010"}
|
||||
eAcntVal := 49998842880.000000
|
||||
@@ -571,9 +541,6 @@ func TestSMGDataTTLExpiredMultiUpdates(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGDataMultipleDataNoUsage(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var acnt *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1010"}
|
||||
eAcntVal := 49997767680.000000
|
||||
@@ -769,9 +736,6 @@ func TestSMGDataMultipleDataNoUsage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGDataMultipleDataConstantUsage(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var acnt *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1010"}
|
||||
eAcntVal := 49997767680.000000
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
)
|
||||
|
||||
var cfg, _ = config.NewDefaultCGRConfig()
|
||||
var err error
|
||||
|
||||
func TestSMGenericEventParseFields(t *testing.T) {
|
||||
smGev := SMGenericEvent{}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -30,19 +32,14 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var testIntegration = flag.Bool("integration", false, "Perform the tests in integration mode, not by default.") // This flag will be passed here via "go test -local" args
|
||||
var waitRater = flag.Int("wait_rater", 150, "Number of miliseconds to wait for rater to start and cache")
|
||||
var dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
|
||||
|
||||
var daCfgPath string
|
||||
var daCfg *config.CGRConfig
|
||||
var smgRPC *rpc.Client
|
||||
var err error
|
||||
|
||||
func TestSMGVoiceInitCfg(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
daCfgPath = path.Join(*dataDir, "conf", "samples", "smg")
|
||||
// Init config first
|
||||
var err error
|
||||
@@ -56,9 +53,6 @@ func TestSMGVoiceInitCfg(t *testing.T) {
|
||||
|
||||
// Remove data in both rating and accounting db
|
||||
func TestSMGVoiceResetDataDb(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.InitDataDb(daCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -66,9 +60,6 @@ func TestSMGVoiceResetDataDb(t *testing.T) {
|
||||
|
||||
// Wipe out the cdr database
|
||||
func TestSMGVoiceResetStorDb(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.InitStorDb(daCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -76,9 +67,7 @@ func TestSMGVoiceResetStorDb(t *testing.T) {
|
||||
|
||||
// Start CGR Engine
|
||||
func TestSMGVoiceStartEngine(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := engine.StopStartEngine(daCfgPath, *waitRater); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -86,9 +75,6 @@ func TestSMGVoiceStartEngine(t *testing.T) {
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestSMGVoiceApierRpcConn(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
smgRPC, err = jsonrpc.Dial("tcp", daCfg.RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
|
||||
if err != nil {
|
||||
@@ -98,9 +84,6 @@ func TestSMGVoiceApierRpcConn(t *testing.T) {
|
||||
|
||||
// Load the tariff plan, creating accounts and their balances
|
||||
func TestSMGVoiceTPFromFolder(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutorial")}
|
||||
var loadInst utils.LoadInstance
|
||||
if err := smgRPC.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &loadInst); err != nil {
|
||||
@@ -110,9 +93,6 @@ func TestSMGVoiceTPFromFolder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGVoiceMonetaryRefund(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
smgEv := SMGenericEvent{
|
||||
utils.EVENT_NAME: "TEST_EVENT",
|
||||
utils.TOR: utils.VOICE,
|
||||
@@ -171,9 +151,6 @@ func TestSMGVoiceMonetaryRefund(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGVoiceVoiceRefund(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
smgEv := SMGenericEvent{
|
||||
utils.EVENT_NAME: "TEST_EVENT",
|
||||
utils.TOR: utils.VOICE,
|
||||
@@ -232,9 +209,6 @@ func TestSMGVoiceVoiceRefund(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGVoiceMixedRefund(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var acnt *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}
|
||||
if err := smgRPC.Call("ApierV2.GetAccount", attrs, &acnt); err != nil {
|
||||
@@ -306,9 +280,6 @@ func TestSMGVoiceMixedRefund(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGVoiceLastUsed(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var acnt *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}
|
||||
eAcntVal := 8.790000
|
||||
@@ -423,9 +394,6 @@ func TestSMGVoiceLastUsed(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGVoiceLastUsedEnd(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var acnt *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}
|
||||
eAcntVal := 7.59000
|
||||
@@ -514,9 +482,6 @@ func TestSMGVoiceLastUsedEnd(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGVoiceLastUsedNotFixed(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var acnt *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}
|
||||
eAcntVal := 6.59000
|
||||
@@ -605,9 +570,6 @@ func TestSMGVoiceLastUsedNotFixed(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGVoiceSessionTTL(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var acnt *engine.Account
|
||||
attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"}
|
||||
eAcntVal := 5.590000
|
||||
@@ -711,9 +673,6 @@ func TestSMGVoiceSessionTTL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGVoiceSessionTTLWithRelocate(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
attrSetBalance := utils.AttrSetBalance{Tenant: "cgrates.org", Account: "TestTTLWithRelocate", BalanceType: utils.VOICE, BalanceID: utils.StringPointer("TestTTLWithRelocate"),
|
||||
Value: utils.Float64Pointer(300), RatingSubject: utils.StringPointer("*zero50ms")}
|
||||
var reply string
|
||||
@@ -831,9 +790,6 @@ func TestSMGVoiceSessionTTLWithRelocate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGVoiceRelocateWithOriginIDPrefix(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
attrSetBalance := utils.AttrSetBalance{Tenant: "cgrates.org", Account: "TestRelocateWithOriginIDPrefix",
|
||||
BalanceType: utils.VOICE, BalanceID: utils.StringPointer("TestRelocateWithOriginIDPrefix"),
|
||||
Value: utils.Float64Pointer(300), RatingSubject: utils.StringPointer("*zero1s")}
|
||||
@@ -974,9 +930,6 @@ func TestSMGVoiceRelocateWithOriginIDPrefix(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGVoiceSessionStopCgrEngine(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.KillEngine(100); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -35,9 +37,7 @@ var smgRplcMasterCfg, smgRplcSlaveCfg *config.CGRConfig
|
||||
var smgRplcMstrRPC, smgRplcSlvRPC *rpc.Client
|
||||
|
||||
func TestSMGRplcInitCfg(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
|
||||
smgRplcMasterCfgPath = path.Join(*dataDir, "conf", "samples", "smgreplcmaster")
|
||||
if smgRplcMasterCfg, err = config.NewCGRConfigFromFolder(smgRplcMasterCfgPath); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -52,9 +52,6 @@ func TestSMGRplcInitCfg(t *testing.T) {
|
||||
|
||||
// Remove data in both rating and accounting db
|
||||
func TestSMGRplcResetDB(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.InitDataDb(smgRplcMasterCfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -65,9 +62,6 @@ func TestSMGRplcResetDB(t *testing.T) {
|
||||
|
||||
// Start CGR Engine
|
||||
func TestSMGRplcStartEngine(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if _, err := engine.StopStartEngine(smgRplcSlaveCfgPath, *waitRater); err != nil { // Start slave before master
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -78,9 +72,6 @@ func TestSMGRplcStartEngine(t *testing.T) {
|
||||
|
||||
// Connect rpc client to rater
|
||||
func TestSMGRplcApierRpcConn(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if smgRplcMstrRPC, err = jsonrpc.Dial("tcp", smgRplcMasterCfg.RPCJSONListen); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -91,9 +82,6 @@ func TestSMGRplcApierRpcConn(t *testing.T) {
|
||||
|
||||
// Load the tariff plan, creating accounts and their balances
|
||||
func TestSMGRplcTPFromFolder(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
attrs := &utils.AttrLoadTpFromFolder{FolderPath: path.Join(*dataDir, "tariffplans", "tutorial")}
|
||||
var loadInst utils.LoadInstance
|
||||
if err := smgRplcMstrRPC.Call("ApierV2.LoadTariffPlanFromFolder", attrs, &loadInst); err != nil {
|
||||
@@ -103,9 +91,6 @@ func TestSMGRplcTPFromFolder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGRplcInitiate(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
var pSessions []*ActiveSession
|
||||
if err := smgRplcSlvRPC.Call("SMGenericV1.PassiveSessions", nil, &pSessions); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
@@ -159,9 +144,6 @@ func TestSMGRplcInitiate(t *testing.T) {
|
||||
|
||||
// Update on slave
|
||||
func TestSMGRplcUpdate(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
smgEv := SMGenericEvent{
|
||||
utils.EVENT_NAME: "TEST_EVENT",
|
||||
utils.ACCID: "123451",
|
||||
@@ -206,9 +188,6 @@ func TestSMGRplcUpdate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGRplcTerminate(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
smgEv := SMGenericEvent{
|
||||
utils.EVENT_NAME: "TEST_EVENT",
|
||||
utils.ACCID: "123451",
|
||||
@@ -236,9 +215,6 @@ func TestSMGRplcTerminate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSMGRplcStopCgrEngine(t *testing.T) {
|
||||
if !*testIntegration {
|
||||
return
|
||||
}
|
||||
if err := engine.KillEngine(100); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build integration
|
||||
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
@@ -19,7 +21,6 @@ package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
@@ -27,17 +28,13 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var testLocal = flag.Bool("local", false, "Perform the tests only on local test environment, not by default.") // This flag will be passed here via "go test -local" args
|
||||
|
||||
type TestContent struct {
|
||||
Var1 string
|
||||
Var2 string
|
||||
}
|
||||
|
||||
func TestHttpJsonPoster(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
content := &TestContent{Var1: "Val1", Var2: "Val2"}
|
||||
jsn, _ := json.Marshal(content)
|
||||
filePath := "/tmp/cgr_test_http_poster.json"
|
||||
@@ -55,9 +52,7 @@ func TestHttpJsonPoster(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHttpBytesPoster(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
|
||||
content := []byte(`Test
|
||||
Test2
|
||||
`)
|
||||
Reference in New Issue
Block a user