mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Fixed function and test in services
This commit is contained in:
committed by
Dan Christian Bogos
parent
adaad39c3b
commit
7f03bafbc9
@@ -75,11 +75,11 @@ func (fS *FreeswitchAgent) Start() (err error) {
|
||||
|
||||
// Reload handles the change of config
|
||||
func (fS *FreeswitchAgent) Reload() (err error) {
|
||||
if err = fS.Shutdown(); err != nil {
|
||||
return
|
||||
}
|
||||
fS.Lock()
|
||||
defer fS.Unlock()
|
||||
if err = fS.fS.Shutdown(); err != nil {
|
||||
return
|
||||
}
|
||||
fS.fS.Reload()
|
||||
go func(f *agents.FSsessions) {
|
||||
if err := fS.fS.Connect(); err != nil {
|
||||
|
||||
@@ -26,6 +26,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/agents"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/cores"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
@@ -75,11 +77,26 @@ func TestFreeSwitchAgentReload(t *testing.T) {
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Expecting OK ,received %s", reply)
|
||||
}
|
||||
|
||||
time.Sleep(10 * time.Millisecond) //need to switch to gorutine
|
||||
// the engine should be stopped as we could not connect to freeswitch
|
||||
if srv.IsRunning() {
|
||||
t.Errorf("Expected service to be down")
|
||||
}
|
||||
|
||||
agentCfg := &config.FsAgentCfg{
|
||||
Enabled: true,
|
||||
CreateCdr: true,
|
||||
SubscribePark: true,
|
||||
EventSocketConns: []*config.FsConnCfg{},
|
||||
}
|
||||
|
||||
srv.(*FreeswitchAgent).fS = agents.NewFSsessions(agentCfg, "", nil)
|
||||
//srv.(*FreeswitchAgent).fS = new(agents.FSsessions)
|
||||
err := srv.Reload()
|
||||
if err != nil {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
shdChan.CloseOnce()
|
||||
runtime.Gosched()
|
||||
|
||||
Reference in New Issue
Block a user