func TestCdrsInitConfig(t *testing.T) {
	var err error
	cdrsMasterCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsreplicationmaster")
	if cdrsMasterCfg, err = config.NewCGRConfigFromFolder(cdrsMasterCfgPath); err != nil {
		t.Fatal("Got config error: ", err.Error())
	}
	cdrsSlaveCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsreplicationslave")
	if cdrsSlaveCfg, err = config.NewCGRConfigFromFolder(cdrsSlaveCfgPath); err != nil {
		t.Fatal("Got config error: ", err.Error())
	}
}
Beispiel #2
0
func TestSMGRplcInitCfg(t *testing.T) {

	smgRplcMasterCfgPath = path.Join(*dataDir, "conf", "samples", "smgreplcmaster")
	if smgRplcMasterCfg, err = config.NewCGRConfigFromFolder(smgRplcMasterCfgPath); err != nil {
		t.Fatal(err)
	}
	smgRplcMasterCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(smgRplcMasterCfg)
	smgRplcSlaveCfgPath = path.Join(*dataDir, "conf", "samples", "smgreplcslave")
	if smgRplcSlaveCfg, err = config.NewCGRConfigFromFolder(smgRplcSlaveCfgPath); err != nil {
		t.Fatal(err)
	}
}
Beispiel #3
0
func TestRPCITLclInitCfg(t *testing.T) {
	rpcITCfgPath1 = path.Join(*dataDir, "conf", "samples", "multiral1")
	rpcITCfgPath2 = path.Join(*dataDir, "conf", "samples", "multiral2")
	rpcITCfg1, err = config.NewCGRConfigFromFolder(rpcITCfgPath1)
	if err != nil {
		t.Error(err)
	}
	rpcITCfg2, err = config.NewCGRConfigFromFolder(rpcITCfgPath2)
	if err != nil {
		t.Error(err)
	}
	if err := engine.InitDataDb(rpcITCfg1); err != nil {
		t.Fatal(err)
	}
}
func TestMCDRCLoadConfig(t *testing.T) {
	var err error
	cfgPath = path.Join(*dataDir, "conf", "samples", "multiplecdrc")
	if cfg, err = config.NewCGRConfigFromFolder(cfgPath); err != nil {
		t.Error(err)
	}
}
Beispiel #5
0
func TestCDRStatsitLoadConfig(t *testing.T) {
	var err error
	cdrstCfgPath = path.Join(*dataDir, "conf", "samples", "cdrstats")
	if cdrstCfg, err = config.NewCGRConfigFromFolder(cfgPath); err != nil {
		t.Error(err)
	}
}
Beispiel #6
0
func main() {
	flag.Parse()
	var err error
	var cdrsMasterRpc *rpcclient.RpcClient
	var cdrsMasterCfgPath string
	var cdrsMasterCfg *config.CGRConfig
	cdrsMasterCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsreplicationmaster")
	if cdrsMasterCfg, err = config.NewCGRConfigFromFolder(cdrsMasterCfgPath); err != nil {
		log.Fatal("Got config error: ", err.Error())
	}
	cdrsMasterRpc, err = rpcclient.NewRpcClient("tcp", cdrsMasterCfg.RPCJSONListen, 1, 1, time.Duration(1*time.Second), time.Duration(2*time.Second), "json", nil)
	if err != nil {
		log.Fatal("Could not connect to rater: ", err.Error())
	}
	cdrs := make([]*engine.CDR, 0)
	for i := 0; i < 10000; i++ {
		cdr := &engine.CDR{OriginID: fmt.Sprintf("httpjsonrpc_%d", i),
			ToR: utils.VOICE, OriginHost: "192.168.1.1", Source: "UNKNOWN", RequestType: utils.META_PSEUDOPREPAID,
			Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002",
			SetupTime: time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2013, 12, 7, 8, 42, 26, 0, time.UTC),
			Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}}
		cdrs = append(cdrs, cdr)
	}
	var reply string
	for _, cdr := range cdrs {
		if err := cdrsMasterRpc.Call("CdrsV2.ProcessCdr", cdr, &reply); err != nil {
			log.Fatal("Unexpected error: ", err.Error())
		} else if reply != utils.OK {
			log.Fatal("Unexpected reply received: ", reply)
		}
	}
}
Beispiel #7
0
func TestPartcsvITInitConfig(t *testing.T) {
	var err error
	partpartcsvCfgPath = path.Join(*dataDir, "conf", "samples", "cdrc_partcsv")
	if partcsvCfg, err = config.NewCGRConfigFromFolder(partpartcsvCfgPath); err != nil {
		t.Fatal("Got config error: ", err.Error())
	}
}
Beispiel #8
0
func TestFlatstoreitInitCfg(t *testing.T) {
	var err error
	flatstoreCfgPath = path.Join(*dataDir, "conf", "samples", "cdrcflatstore")
	if flatstoreCfg, err = config.NewCGRConfigFromFolder(flatstoreCfgPath); err != nil {
		t.Fatal("Got config error: ", err.Error())
	}
}
Beispiel #9
0
func TestXmlITInitConfig(t *testing.T) {
	var err error
	xmlCfgPath = path.Join(*dataDir, "conf", "samples", "cdrcxml")
	if xmlCfg, err = config.NewCGRConfigFromFolder(xmlCfgPath); err != nil {
		t.Fatal("Got config error: ", err.Error())
	}
}
Beispiel #10
0
func testV2CDRsInitConfig(t *testing.T) {
	var err error
	cdrsCfgPath = path.Join(*dataDir, "conf", "samples", cdrsConfDIR)
	if cdrsCfg, err = config.NewCGRConfigFromFolder(cdrsCfgPath); err != nil {
		t.Fatal("Got config error: ", err.Error())
	}
}
Beispiel #11
0
func TestSTIInitCfg(t *testing.T) {
	// Init config first
	var err error
	stiCfg, err = config.NewCGRConfigFromFolder(*configDir)
	if err != nil {
		t.Error(err)
	}
}
Beispiel #12
0
func TestApierV2itLoadConfig(t *testing.T) {
	if !*testIT {
		return
	}
	apierCfgPath = path.Join(*dataDir, "conf", "samples", "tutmysql")
	if apierCfg, err = config.NewCGRConfigFromFolder(tpCfgPath); err != nil {
		t.Error(err)
	}
}
Beispiel #13
0
// Need it here and not in init since Travis has no possibility to load local file
func TestLoadConfigt(*testing.T) {
	if !*testLocal {
		return
	}
	cfgPath = path.Join(*dataDir, "conf", "samples", "apier")
	cfg, _ = config.NewCGRConfigFromFolder(cfgPath)
	if len(cfg.CdrcProfiles) > 0 {
		cdrcCfgs = cfg.CdrcProfiles["/var/log/cgrates/cdrc/in"]
	}
}
Beispiel #14
0
func TestV2CDRsPSQLInitConfig(t *testing.T) {
	if !*testLocal {
		return
	}
	var err error
	cdrsPsqlCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsv2psql")
	if cdrsPsqlCfg, err = config.NewCGRConfigFromFolder(cdrsPsqlCfgPath); err != nil {
		t.Fatal(err)
	}
}
func TestTutOsipsCallsInitCfg(t *testing.T) {
	// Init config first
	var err error
	tutOsipsCallsCfg, err = config.NewCGRConfigFromFolder(path.Join(*dataDir, "tutorials", "osips_async", "cgrates", "etc", "cgrates"))
	if err != nil {
		t.Error(err)
	}
	tutOsipsCallsCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(tutOsipsCallsCfg)
}
Beispiel #16
0
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 {
		t.Fatal("Got config error: ", err.Error())
	}
}
Beispiel #17
0
func TestV2CdrsMongoInitConfig(t *testing.T) {
	if !*testLocal {
		return
	}
	var err error
	cdrsMongoCfgPath = path.Join(*dataDir, "conf", "samples", "cdrsv2mongo")
	if cdrsMongoCfg, err = config.NewCGRConfigFromFolder(cdrsMongoCfgPath); err != nil {
		t.Fatal("Got config error: ", err.Error())
	}
}
Beispiel #18
0
func TestFwvLclInitCfg(t *testing.T) {
	if !*testLocal {
		return
	}
	var err error
	fwvCfgPath = path.Join(*dataDir, "conf", "samples", "cdrcfwv")
	if fwvCfg, err = config.NewCGRConfigFromFolder(fwvCfgPath); err != nil {
		t.Fatal("Got config error: ", err.Error())
	}
}
func TestTutSMGInitCfg(t *testing.T) {
	tutSMGCfgPath = path.Join(*dataDir, "conf", "samples", "smgeneric")
	// Init config first
	var err error
	tutSMGCfg, err = config.NewCGRConfigFromFolder(tutSMGCfgPath)
	if err != nil {
		t.Error(err)
	}
	tutSMGCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(tutSMGCfg)
}
Beispiel #20
0
func TestOnStorITMongoConnect(t *testing.T) {
	cdrsMongoCfgPath := path.Join(*dataDir, "conf", "samples", "cdrsv2mongo")
	mgoITCfg, err := config.NewCGRConfigFromFolder(cdrsMongoCfgPath)
	if err != nil {
		t.Fatal(err)
	}
	if mgoITdb, err = NewMongoStorage(mgoITCfg.StorDBHost, mgoITCfg.StorDBPort, mgoITCfg.StorDBName, mgoITCfg.StorDBUser, mgoITCfg.StorDBPass,
		utils.StorDB, nil, mgoITCfg.CacheConfig, mgoITCfg.LoadHistorySize); err != nil {
		t.Fatal(err)
	}
}
Beispiel #21
0
func TestActionsitInitCfg(t *testing.T) {

	// Init config first
	var err error
	actsLclCfg, err = config.NewCGRConfigFromFolder(actsLclCfgPath)
	if err != nil {
		t.Error(err)
	}
	actsLclCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(actsLclCfg)
}
Beispiel #22
0
func testTPitLoadConfig(t *testing.T) {
	tpCfgPath = path.Join(*dataDir, "conf", "samples", configDIR)
	if tpCfg, err = config.NewCGRConfigFromFolder(tpCfgPath); err != nil {
		t.Error(err)
	}
	switch configDIR {
	case "tutmongo": // Mongo needs more time to reset db, need to investigate
		delay = 4000
	default:
		delay = *waitRater
	}
}
Beispiel #23
0
func TestStorDBitMySQL(t *testing.T) {
	if cfg, err = config.NewCGRConfigFromFolder(path.Join(*dataDir, "conf", "samples", "storage", "mysql")); err != nil {
		t.Fatal(err)
	}
	if storDB, err = NewMySQLStorage(cfg.StorDBHost, cfg.StorDBPort, cfg.StorDBName,
		cfg.StorDBUser, cfg.StorDBPass, cfg.StorDBMaxOpenConns, cfg.StorDBMaxIdleConns); err != nil {
		t.Fatal(err)
	}
	for _, stest := range sTestsStorDBit {
		t.Run("TestStorDBitMySQL", stest)
	}
}
Beispiel #24
0
func TestDmtAgentInitCfg(t *testing.T) {
	daCfgPath = path.Join(*dataDir, "conf", "samples", "dmtagent")
	// Init config first
	var err error
	daCfg, err = config.NewCGRConfigFromFolder(daCfgPath)
	if err != nil {
		t.Error(err)
	}
	daCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(daCfg)
	rplyTimeout, _ = utils.ParseDurationWithSecs(*replyTimeout)
}
func TestTutAstCallsInitCfg(t *testing.T) {
	if !*testCalls {
		return
	}
	// Init config first
	var err error
	tutAstCallsCfg, err = config.NewCGRConfigFromFolder(path.Join(*dataDir, "tutorials", "asterisk_events", "cgrates", "etc", "cgrates"))
	if err != nil {
		t.Error(err)
	}
	tutAstCallsCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(tutAstCallsCfg)
}
Beispiel #26
0
// Retrieves the callCost out of CGR logDb
func (apier *ApierV1) ReloadCdrcConfig(attrs AttrReloadConfig, reply *string) error {
	if attrs.ConfigDir == "" {
		attrs.ConfigDir = utils.CONFIG_DIR
	}
	newCfg, err := config.NewCGRConfigFromFolder(attrs.ConfigDir)
	if err != nil {
		return utils.NewErrServerError(err)
	}
	apier.Config.CdrcProfiles = newCfg.CdrcProfiles // ToDo: Check if there can be any concurency involved here so we need to lock maybe
	apier.Config.ConfigReloads[utils.CDRC] <- struct{}{}
	*reply = OK
	return nil
}
Beispiel #27
0
func TestSMGInitCfg(t *testing.T) {
	if !*testIntegration {
		return
	}
	daCfgPath = path.Join(*dataDir, "conf", "samples", "smg")
	// Init config first
	var err error
	daCfg, err = config.NewCGRConfigFromFolder(daCfgPath)
	if err != nil {
		t.Error(err)
	}
	daCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(daCfg)
}
Beispiel #28
0
func TestTutLocalInitCfg(t *testing.T) {
	if !*testLocal {
		return
	}
	tutLocalCfgPath = path.Join(*dataDir, "conf", "samples", "tutlocal")
	// Init config first
	var err error
	tutFsLocalCfg, err = config.NewCGRConfigFromFolder(tutLocalCfgPath)
	if err != nil {
		t.Error(err)
	}
	tutFsLocalCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(tutFsLocalCfg)
}
Beispiel #29
0
// Reloads CDRE configuration out of folder specified
func (apier *ApierV1) ReloadCdreConfig(attrs AttrReloadConfig, reply *string) error {
	if attrs.ConfigDir == "" {
		attrs.ConfigDir = utils.CONFIG_DIR
	}
	newCfg, err := config.NewCGRConfigFromFolder(attrs.ConfigDir)
	if err != nil {
		return utils.NewErrServerError(err)
	}
	cdreReloadStruct := <-apier.Config.ConfigReloads[utils.CDRE] // Get the CDRE reload channel                     // Read the content of the channel, locking it
	apier.Config.CdreProfiles = newCfg.CdreProfiles
	apier.Config.ConfigReloads[utils.CDRE] <- cdreReloadStruct // Unlock reloads
	utils.Logger.Info("<CDRE> Configuration reloaded")
	*reply = OK
	return nil
}
Beispiel #30
0
func TestITCDRsMongo(t *testing.T) {

	cfg, err := config.NewCGRConfigFromFolder(path.Join(*dataDir, "conf", "samples", "storage", "mongo"))
	if err != nil {
		t.Error(err)
	}
	if err := testGetCDRs(cfg); err != nil {
		t.Error(err)
	}
	if err := testSetCDR(cfg); err != nil {
		t.Error(err)
	}
	if err := testSMCosts(cfg); err != nil {
		t.Error(err)
	}
}