Updated integration tests

This commit is contained in:
Trial97
2020-06-12 13:55:54 +03:00
committed by Dan Christian Bogos
parent 6b84c27b2d
commit 39d49dcd2f
11 changed files with 40 additions and 38 deletions

View File

@@ -50,7 +50,8 @@
"*dispatcher_profiles":{"remote":true},
"*dispatcher_hosts":{"remote":true},
"*filter_indexes" :{"remote":true},
"*load_ids":{"remote":true}
"*load_ids":{"remote":true},
"*indexes":{"remote":true}
}
},

View File

@@ -56,7 +56,8 @@
"*dispatcher_profiles":{"replicate":false},
"*dispatcher_hosts":{"replicate":false},
"*filter_indexes" :{"replicate":false},
"*load_ids":{"replicate":false}
"*load_ids":{"replicate":false},
"*indexes":{"replicate":false}
}
},

View File

@@ -37,6 +37,7 @@
"cdrs": {
"enabled": true,
"stats_conns": ["*localhost"],
"chargers_conns": ["*internal"],
"rals_conns": ["*localhost"],
"sessions_cost_retries": 5,
},
@@ -59,7 +60,7 @@
"thresholds_conns": ["*localhost"],
"chargers_conns": ["*localhost"],
"debit_interval": "5s",
"channel_sync_interval":"7s",
"channel_sync_interval":"7s",
},
@@ -101,6 +102,7 @@
"enabled": true,
"resources_conns": ["*internal"],
"stats_conns": ["*internal"],
"rals_conns": ["*internal"],
"string_indexed_fields": ["Account"],
},

View File

@@ -217,14 +217,12 @@ route[CGRATES_SESSIONAUTH_REPLY] {
$dlg_var(cgrDestination) = $rU;
$dlg_var(paypalAccount) = $avp(PaypalAccount);
if $var(cgrMaxUsage) != -1 {
if $var(cgrMaxUsage) == 0 { // Not enough balance, do not allow the call to go through
sl_send_reply("403","Insufficient credit");
exit;
} else if !dlg_set_timeout("$var(cgrMaxUsage)") {
sl_send_reply("503","CGR_MAX_USAGE_ERROR");
exit;
}
if $var(cgrMaxUsage) == 0 { // Not enough balance, do not allow the call to go through
sl_send_reply("403","Insufficient credit");
exit;
} else if !dlg_set_timeout("$var(cgrMaxUsage)") {
sl_send_reply("503","CGR_MAX_USAGE_ERROR");
exit;
}
if $var(cgrSuppliers) != "" { # Enforce the supplier variable to the first one received from CGRateS, here more for demo purposes

View File

@@ -37,6 +37,7 @@
"cdrs": {
"enabled": true,
"stats_conns": ["*localhost"],
"chargers_conns": ["*internal"],
"rals_conns": ["*localhost"],
"sessions_cost_retries": 5,
},
@@ -101,6 +102,7 @@
"enabled": true,
"resources_conns": ["*internal"],
"stats_conns": ["*internal"],
"rals_conns": ["*internal"],
"string_indexed_fields": ["Account"],
},

View File

@@ -703,12 +703,20 @@ func testDspSessionProcessEvent2(t *testing.T) {
func testDspSessionReplicate(t *testing.T) {
allEngine.initDataDb(t)
allEngine.resetStorDb(t)
var reply string
// reload cache in order to corectly cahce the indexes
if err := allEngine.RPC.Call(utils.CacheSv1Clear, &utils.AttrCacheIDsWithArgDispatcher{
CacheIDs: nil,
}, &reply); err != nil {
t.Error(err)
} else if reply != utils.OK {
t.Error("Reply: ", reply)
}
allEngine.loadData(t, path.Join(dspDataDir, "tariffplans", "testit"))
testDspSessionAddBalacne(t)
testDspSessionAuthorize(t)
testDspSessionInit(t)
var reply string
if err := dispEngine.RPC.Call(utils.SessionSv1ReplicateSessions, &ArgsReplicateSessionsWithApiKey{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("ses12345"),
@@ -789,7 +797,7 @@ func testDspSessionPassive(t *testing.T) {
utils.Usage: 5 * time.Minute,
}),
SRuns: []*sessions.SRun{
&sessions.SRun{
{
Event: engine.NewMapEvent(map[string]interface{}{
"RunID": "CustomerCharges",
utils.CGRID: "c87609aa1cb6e9529ab1836cfeeebaab7aa7ebaf",

View File

@@ -549,9 +549,7 @@ func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREvent,
break
}
}
if errCh := Cache.Set(utils.CacheEventResources, evUUID, rs.resIDsMp(), nil, true, ""); errCh != nil {
return nil, errCh
}
err = Cache.Set(utils.CacheEventResources, evUUID, rs.resIDsMp(), nil, true, "")
return
}

View File

@@ -552,7 +552,7 @@ func (tpr *TpReader) LoadActionPlans() (err error) {
return err
}
storAps := MapTPActionTimings(tps)
for atId, ats := range storAps {
for atID, ats := range storAps {
for _, at := range ats {
_, exists := tpr.actions[at.ActionsId]
@@ -569,9 +569,9 @@ func (tpr *TpReader) LoadActionPlans() (err error) {
return fmt.Errorf("[ActionPlans] Could not load the timing for tag: %v", at.TimingId)
}
var actPln *ActionPlan
if actPln, exists = tpr.actionPlans[atId]; !exists {
if actPln, exists = tpr.actionPlans[atID]; !exists {
actPln = &ActionPlan{
Id: atId,
Id: atID,
}
}
actPln.ActionTimings = append(actPln.ActionTimings, &ActionTiming{
@@ -589,7 +589,7 @@ func (tpr *TpReader) LoadActionPlans() (err error) {
ActionsID: at.ActionsId,
})
tpr.actionPlans[atId] = actPln
tpr.actionPlans[atID] = actPln
}
}
return nil
@@ -1796,7 +1796,7 @@ func (tpr *TpReader) ShowStatistics() {
prefixDist := make(map[int]int, 50)
prefixCount := 0
for _, d := range tpr.destinations {
prefixDist[len(d.Prefixes)] += 1
prefixDist[len(d.Prefixes)]++
prefixCount += len(d.Prefixes)
}
log.Print("Avg Prefixes: ", prefixCount/destCount)
@@ -1810,7 +1810,7 @@ func (tpr *TpReader) ShowStatistics() {
destRatesDist := make(map[int]int, 50)
destRatesCount := 0
for _, rpl := range tpr.ratingPlans {
destRatesDist[len(rpl.DestinationRates)] += 1
destRatesDist[len(rpl.DestinationRates)]++
destRatesCount += len(rpl.DestinationRates)
}
log.Print("Avg Destination Rates: ", destRatesCount/rplCount)
@@ -1824,7 +1824,7 @@ func (tpr *TpReader) ShowStatistics() {
activDist := make(map[int]int, 50)
activCount := 0
for _, rpf := range tpr.ratingProfiles {
activDist[len(rpf.RatingPlanActivations)] += 1
activDist[len(rpf.RatingPlanActivations)]++
activCount += len(rpf.RatingPlanActivations)
}
log.Print("Avg Activations: ", activCount/rpfCount)

View File

@@ -38,23 +38,15 @@ func TestUnitCounterClone(t *testing.T) {
uc = &UnitCounter{
CounterType: "testCounterType",
Counters: []*CounterFilter{
&CounterFilter{
Value: 0.7,
},
&CounterFilter{
Value: 0.8,
},
{Value: 0.7},
{Value: 0.8},
},
}
eOut = &UnitCounter{
CounterType: "testCounterType",
Counters: []*CounterFilter{
&CounterFilter{
Value: 0.7,
},
&CounterFilter{
Value: 0.8,
},
{Value: 0.7},
{Value: 0.8},
},
}
if rcv := uc.Clone(); !reflect.DeepEqual(eOut, rcv) {

View File

@@ -173,7 +173,7 @@ func NewErrResourceS(err error) error {
}
func NewErrSupplierS(err error) error {
return fmt.Errorf("SUPPLIERS_ERROR:%s", err)
return fmt.Errorf("ROUTES_ERROR:%s", err)
}
func NewErrAttributeS(err error) error {

View File

@@ -116,8 +116,8 @@ func TestNewErrResourceS(t *testing.T) {
func TestNewErrSupplierS(t *testing.T) {
cgrError := NewCGRError("context", "apiError", "shortError", "longError")
if rcv := NewErrSupplierS(cgrError); rcv.Error() != "SUPPLIERS_ERROR:shortError" {
t.Errorf("Expecting: SUPPLIERS_ERROR:shortError, received: %+v", rcv)
if rcv := NewErrSupplierS(cgrError); rcv.Error() != "ROUTES_ERROR:shortError" {
t.Errorf("Expecting: ROUTES_ERROR:shortError, received: %+v", rcv)
}
}
func TestNewErrAttributeS(t *testing.T) {