mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-20 06:38:45 +05:00
Return error is connection to cdr server is nil
This commit is contained in:
committed by
Dan Christian Bogos
parent
472316ed78
commit
bc52d6f08f
@@ -279,7 +279,9 @@ func parseTemplateValue(rsrFlds utils.RSRFields, acnt *Account, action *Action)
|
||||
}
|
||||
|
||||
func cdrLogAction(acc *Account, sq *CDRStatsQueueTriggered, a *Action, acs Actions) (err error) {
|
||||
|
||||
if (schedCdrsConns == nil) || (schedCdrsConns != nil && reflect.ValueOf(schedCdrsConns).IsNil()) {
|
||||
return fmt.Errorf("No connection with CDR Server")
|
||||
}
|
||||
defaultTemplate := map[string]utils.RSRFields{
|
||||
utils.ToR: utils.ParseRSRFieldsMustCompile("BalanceType", utils.INFIELD_SEP),
|
||||
utils.OriginHost: utils.ParseRSRFieldsMustCompile("^127.0.0.1", utils.INFIELD_SEP),
|
||||
@@ -339,9 +341,6 @@ func cdrLogAction(acc *Account, sq *CDRStatsQueueTriggered, a *Action, acs Actio
|
||||
}
|
||||
}
|
||||
cdrs = append(cdrs, cdr)
|
||||
if (schedCdrsConns == nil) || (schedCdrsConns != nil && reflect.ValueOf(schedCdrsConns).IsNil()) {
|
||||
continue
|
||||
}
|
||||
var rply string
|
||||
// After compute the CDR send it to CDR Server to be processed
|
||||
if err := schedCdrsConns.Call(utils.CdrsV2ProcessCDR, cdr.AsCGREvent(), &rply); err != nil {
|
||||
|
||||
@@ -75,45 +75,6 @@ func TestActionsitRpcConn(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestActionsitAddChargers(t *testing.T) {
|
||||
chargerProfile := &ChargerProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Charger1",
|
||||
FilterIDs: []string{"*string:Account:dan2904"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
|
||||
},
|
||||
RunID: "*default",
|
||||
AttributeIDs: []string{"*none"},
|
||||
Weight: 20,
|
||||
}
|
||||
var result string
|
||||
if err := actsLclRpc.Call("ApierV1.SetChargerProfile", chargerProfile, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if result != utils.OK {
|
||||
t.Error("Unexpected reply returned", result)
|
||||
}
|
||||
chargerProfile2 := &ChargerProfile{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Charger2",
|
||||
FilterIDs: []string{"*string:Account:dan2905"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
|
||||
},
|
||||
RunID: "*default",
|
||||
AttributeIDs: []string{"*none"},
|
||||
Weight: 20,
|
||||
}
|
||||
if err := actsLclRpc.Call("ApierV1.SetChargerProfile", chargerProfile2, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if result != utils.OK {
|
||||
t.Error("Unexpected reply returned", result)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestActionsitSetCdrlogDebit(t *testing.T) {
|
||||
var reply string
|
||||
attrsSetAccount := &utils.AttrSetAccount{Tenant: "cgrates.org", Account: "dan2904"}
|
||||
|
||||
@@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package engine
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
@@ -1468,6 +1467,7 @@ func TestTopupActionLoaded(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Disabled tests with cdrLogAction because it need a rpc connection
|
||||
func TestActionCdrlogEmpty(t *testing.T) {
|
||||
acnt := &Account{ID: "cgrates.org:dan2904"}
|
||||
cdrlog := &Action{
|
||||
@@ -1553,6 +1553,7 @@ func TestActionCdrLogParamsWithOverload(t *testing.T) {
|
||||
t.Errorf("Expecting extra fields: %+v, received: %+v", expectedExtraFields, cdrs[0].ExtraFields)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func TestActionSetDDestination(t *testing.T) {
|
||||
acc := &Account{BalanceMap: map[string]Balances{
|
||||
@@ -2390,6 +2391,7 @@ func TestActionExpNoExp(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestActionCdrlogBalanceValue(t *testing.T) {
|
||||
err := dm.DataDB().SetAccount(&Account{
|
||||
ID: "cgrates.org:bv",
|
||||
@@ -2451,6 +2453,7 @@ func TestActionCdrlogBalanceValue(t *testing.T) {
|
||||
t.Errorf("Wrong cdrlogs: %s", utils.ToIJSON(cdrs))
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func TestActionTopUpZeroNegative(t *testing.T) {
|
||||
account := &Account{
|
||||
|
||||
Reference in New Issue
Block a user