Updated call tests for asterisk

This commit is contained in:
Trial97
2020-05-22 10:35:09 +03:00
committed by Dan Christian Bogos
parent e6834e1b78
commit 77c571f7d6
3 changed files with 11 additions and 9 deletions

View File

@@ -85,16 +85,13 @@ func (sma *AsteriskAgent) connectAsterisk() (err error) {
connCfg.Address, connCfg.User, connCfg.Password, CGRAuthAPP), "http://cgrates.org",
connCfg.User, connCfg.Password, fmt.Sprintf("%s@%s", utils.CGRateS, utils.VERSION),
sma.astEvChan, sma.astErrChan, connCfg.ConnectAttempts, connCfg.Reconnects)
if err != nil {
return err
}
return nil
return
}
// ListenAndServe is called to start the service
func (sma *AsteriskAgent) ListenAndServe() (err error) {
if err := sma.connectAsterisk(); err != nil {
return err
if err = sma.connectAsterisk(); err != nil {
return
}
for {
select {
@@ -159,7 +156,6 @@ func (sma *AsteriskAgent) handleStasisStart(ev *SMAsteriskEvent) {
fmt.Sprintf("<%s> error: %s subscribing for channelID: %s",
utils.AsteriskAgent, err.Error(), ev.ChannelID()))
return
}
//authorize Session
authArgs := ev.V1AuthorizeArgs()

View File

@@ -27,6 +27,7 @@ import (
"os"
"path"
"reflect"
"sort"
"strings"
"testing"
"time"
@@ -364,7 +365,7 @@ func testCallStartPjsuaListener(t *testing.T) {
acnts, 5070, time.Duration(*waitRater)*time.Millisecond); err != nil {
t.Fatal(err)
}
time.Sleep(1 * time.Second)
time.Sleep(3 * time.Second)
}
// Call from 1001 (prepaid) to 1002
@@ -395,6 +396,11 @@ func testCallGetActiveSessions(t *testing.T) {
nil, &reply); err != nil {
t.Error("Got error on SessionSv1.GetActiveSessions: ", err.Error())
} else {
if len(*reply) == 2 {
sort.Slice(*reply, func(i, j int) bool {
return strings.Compare((*reply)[i].RequestType, (*reply)[j].RequestType) > 0
})
}
// compare some fields (eg. CGRId is generated)
if !reflect.DeepEqual((*expected)[0].RequestType, (*reply)[0].RequestType) {
t.Errorf("Expected: %s, received: %s", (*expected)[0].RequestType, (*reply)[0].RequestType)

View File

@@ -60,7 +60,7 @@ func (ast *AsteriskAgent) Start() (err error) {
defer ast.Unlock()
listenAndServe := func(sma *agents.AsteriskAgent, exitChan chan bool) {
if err = sma.ListenAndServe(); err != nil {
if err := sma.ListenAndServe(); err != nil {
utils.Logger.Err(fmt.Sprintf("<%s> runtime error: %s!", utils.AsteriskAgent, err))
}
exitChan <- true