Exemplo n.º 1
0
func startCDRS(responder *engine.Responder, cdrDb engine.CdrStorage, mediChan, doneChan chan struct{}) {
	if cfg.CDRSMediator == utils.INTERNAL {
		<-mediChan // Deadlock if mediator not started
		if medi == nil {
			engine.Logger.Crit("<CDRS> Could not connect to mediator, exiting.")
			exitChan <- true
			return
		}
	}
	cdrServer = engine.NewCdrS(cdrDb, medi, cdrStats, cfg)
	cdrServer.RegisterHanlersToServer(server)
	engine.Logger.Info("Registering CDRS RPC service.")
	server.RpcRegister(&apier.CDRSV1{CdrSrv: cdrServer})
	responder.CdrSrv = cdrServer // Make the cdrserver available for internal communication
	close(doneChan)
}
Exemplo n.º 2
0
func TestEvCorelate(t *testing.T) {
	cfg, _ := config.NewDefaultCGRConfig()
	engine.NewCdrS(nil, nil, nil, cfg) // So we can set the package cfg
	answerEv := new(sessionmanager.FSEvent).New(answerEvent)
	if answerEv.GetName() != "CHANNEL_ANSWER" {
		t.Error("Event not parsed correctly: ", answerEv)
	}
	cdrEv, err := engine.NewFSCdr(jsonCdr)
	if err != nil {
		t.Errorf("Error loading cdr: %v", err.Error())
	} else if cdrEv.AsStoredCdr().AccId != "86cfd6e2-dbda-45a3-b59d-f683ec368e8b" {
		t.Error("Unexpected acntId received", cdrEv.AsStoredCdr().AccId)
	}
	if answerEv.GetCgrId() != cdrEv.AsStoredCdr().CgrId {
		t.Error("CgrIds do not match", answerEv.GetCgrId(), cdrEv.AsStoredCdr().CgrId)
	}

}