Fixed function in services

This commit is contained in:
andronache
2021-02-10 14:37:32 +02:00
committed by Dan Christian Bogos
parent 7f03bafbc9
commit 25b2fdb6ec
3 changed files with 16 additions and 5 deletions

View File

@@ -92,7 +92,7 @@ func TestFreeSwitchAgentReload(t *testing.T) {
}
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)

View File

@@ -78,12 +78,11 @@ func (kam *KamailioAgent) Start() (err error) {
// Reload handles the change of config
func (kam *KamailioAgent) Reload() (err error) {
if err = kam.Shutdown(); err != nil {
return
}
kam.Lock()
defer kam.Unlock()
if err = kam.kam.Shutdown(); err != nil {
return
}
kam.kam.Reload()
go func(k *agents.KamailioAgent) {
if err = k.Connect(); err != nil {

View File

@@ -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"
@@ -76,7 +78,17 @@ func TestKamailioAgentReload(t *testing.T) {
} else if reply != utils.OK {
t.Errorf("Expecting OK ,received %s", reply)
}
kaCfg := &config.KamAgentCfg{
Enabled: true,
SessionSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaSessionS)},
CreateCdr: true,
EvapiConns: []*config.KamConnCfg{{Address: "127.0.0.1:8448", Reconnects: 10, Alias: "randomAlias"}},
Timezone: "Local",
}
srv.(*KamailioAgent).kam = agents.NewKamailioAgent(kaCfg, nil, "")
srv.Reload()
runtime.Gosched()
time.Sleep(10 * time.Millisecond) //need to switch to gorutine
// the engine should be stoped as we could not connect to kamailio