mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 07:08:45 +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
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user