Updated integration tests

This commit is contained in:
Trial97
2020-11-27 17:53:11 +02:00
committed by Dan Christian Bogos
parent 9de6a2d172
commit bd10472bf8
9 changed files with 280 additions and 182 deletions

View File

@@ -1003,7 +1003,7 @@ func testAccITAccountWithTriggers(t *testing.T) {
if len(acnt.ActionTriggers) != 1 {
t.Errorf("Expected 1, received: %+v", len(acnt.ActionTriggers))
} else {
if acnt.ActionTriggers[0].Executed != false {
if acnt.ActionTriggers[0].Executed {
t.Errorf("Expected false, received: %+v", acnt.ActionTriggers[0].Executed)
}
}
@@ -1038,7 +1038,7 @@ func testAccITAccountWithTriggers(t *testing.T) {
if len(acnt.ActionTriggers) != 1 {
t.Errorf("Expected 1, received: %+v", len(acnt.ActionTriggers))
} else {
if acnt.ActionTriggers[0].Executed != true {
if !acnt.ActionTriggers[0].Executed {
t.Errorf("Expected true, received: %+v", acnt.ActionTriggers[0].Executed)
}
}
@@ -1053,6 +1053,7 @@ func testAccITAccountWithTriggers(t *testing.T) {
t.Errorf("Calling APIerSv1.ExecuteAction received: %s", reply)
}
acnt = engine.Account{}
if err := accRPC.Call(utils.APIerSv2GetAccount, attrAcc, &acnt); err != nil {
t.Fatal(err)
} else {
@@ -1070,8 +1071,8 @@ func testAccITAccountWithTriggers(t *testing.T) {
if len(acnt.ActionTriggers) != 1 {
t.Errorf("Expected 1, received: %+v", len(acnt.ActionTriggers))
} else {
if acnt.ActionTriggers[0].Executed != false {
t.Errorf("Expected true, received: %+v", acnt.ActionTriggers[0].Executed)
if acnt.ActionTriggers[0].Executed {
t.Errorf("Expected false, received: %+v", acnt.ActionTriggers[0].Executed)
}
}
}

View File

@@ -207,6 +207,10 @@ func testAttributeSGetAttributeForEvent(t *testing.T) {
},
Weight: 10.0,
}
if *encoding == utils.MetaGOB {
eAttrPrf.Attributes[0].FilterIDs = nil
eAttrPrf.Attributes[1].FilterIDs = nil
}
eAttrPrf.Compile()
var attrReply *engine.AttributeProfile
if err := attrSRPC.Call(utils.AttributeSv1GetAttributeForEvent,

View File

@@ -170,11 +170,37 @@ func testConfigSSetConfigSessionS(t *testing.T) {
"terminate_attempts": 5.,
}
if *encoding == utils.MetaGOB {
var empty []interface{}
exp["replication_conns"] = empty
exp["scheduler_conns"] = empty
exp["stats_conns"] = empty
exp["thresholds_conns"] = empty
var empty []string
exp = map[string]interface{}{
"enabled": true,
"listen_bijson": "127.0.0.1:2014",
"chargers_conns": []string{utils.MetaInternal},
"rals_conns": []string{utils.MetaInternal},
"resources_conns": []string{utils.MetaLocalHost},
"thresholds_conns": empty,
"stats_conns": empty,
"routes_conns": []string{utils.MetaLocalHost},
"attributes_conns": []string{utils.MetaLocalHost},
"cdrs_conns": []string{utils.MetaInternal},
"replication_conns": empty,
"scheduler_conns": empty,
"session_indexes": []string{"OriginID"},
"client_protocol": 1.,
"terminate_attempts": 5,
"channel_sync_interval": "0",
"debit_interval": "0",
"session_ttl": "0",
"store_session_costs": false,
"min_dur_low_balance": "0",
"alterable_fields": empty,
"stir": map[string]interface{}{
"allowed_attest": []string{utils.META_ANY},
"default_attest": "A",
"payload_maxduration": "-1",
"privatekey_path": "",
"publickey_path": "",
},
}
}
exp = map[string]interface{}{
config.SessionSJson: exp,
@@ -221,6 +247,39 @@ func testConfigSv1GetJSONSectionWithoutTenant(t *testing.T) {
"publickey_path": "",
},
}
if *encoding == utils.MetaGOB {
var empty []string
exp = map[string]interface{}{
"enabled": true,
"listen_bijson": "127.0.0.1:2014",
"chargers_conns": []string{utils.MetaInternal},
"rals_conns": []string{utils.MetaInternal},
"resources_conns": []string{utils.MetaLocalHost},
"thresholds_conns": empty,
"stats_conns": empty,
"routes_conns": []string{utils.MetaLocalHost},
"attributes_conns": []string{utils.MetaLocalHost},
"cdrs_conns": []string{utils.MetaInternal},
"replication_conns": empty,
"scheduler_conns": empty,
"session_indexes": []string{"OriginID"},
"client_protocol": 1.,
"terminate_attempts": 5,
"channel_sync_interval": "0",
"debit_interval": "0",
"session_ttl": "0",
"store_session_costs": false,
"min_dur_low_balance": "0",
"alterable_fields": empty,
"stir": map[string]interface{}{
"allowed_attest": []string{utils.META_ANY},
"default_attest": "A",
"payload_maxduration": "-1",
"privatekey_path": "",
"publickey_path": "",
},
}
}
exp = map[string]interface{}{
config.SessionSJson: exp,
}

View File

@@ -596,31 +596,38 @@ func testV1RatePrfStopEngine(t *testing.T) {
}
func testV1RateGetRemoveRateProfileWithoutTenant(t *testing.T) {
rateProfile := &engine.RateProfile{
ID: "RPWithoutTenant",
FilterIDs: []string{"*string:~*req.Subject:1001"},
Weight: 0,
RoundingMethod: "*up",
RoundingDecimals: 4,
MinCost: 0.1,
MaxCost: 0.6,
MaxCostStrategy: "*free",
Rates: map[string]*engine.Rate{
"RT_WEEK": {
ID: "RT_WEEK",
Weight: 0,
ActivationTimes: "* * * * 1-5",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.12,
Unit: time.Minute,
Increment: time.Minute,
rateProfile := &RateProfileWithCache{
RateProfileWithOpts: &engine.RateProfileWithOpts{
RateProfile: &engine.RateProfile{
ID: "RPWithoutTenant",
FilterIDs: []string{"*string:~*req.Subject:1001"},
Weight: 0,
RoundingMethod: "*up",
RoundingDecimals: 4,
MinCost: 0.1,
MaxCost: 0.6,
MaxCostStrategy: "*free",
Rates: map[string]*engine.Rate{
"RT_WEEK": {
ID: "RT_WEEK",
Weight: 0,
ActivationTimes: "* * * * 1-5",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.12,
Unit: time.Minute,
Increment: time.Minute,
},
},
},
},
},
},
}
if *encoding == utils.MetaGOB {
rateProfile.Rates["RT_WEEK"].FilterIDs = nil
}
var reply string
if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfile, rateProfile, &reply); err != nil {
t.Error(err)
@@ -633,8 +640,8 @@ func testV1RateGetRemoveRateProfileWithoutTenant(t *testing.T) {
&utils.TenantIDWithOpts{TenantID: &utils.TenantID{ID: "RPWithoutTenant"}},
&result); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(result, rateProfile) {
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(rateProfile), utils.ToJSON(result))
} else if !reflect.DeepEqual(result, rateProfile.RateProfile) {
t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(rateProfile.RateProfile), utils.ToJSON(result))
}
}
@@ -693,63 +700,72 @@ func testV1RatePrfGetRateProfileIDsCount(t *testing.T) {
}
func testV1RatePrfGetRateProfileRatesWithoutTenant(t *testing.T) {
rPrf := &engine.RateProfile{
ID: "SpecialRate",
FilterIDs: []string{"*string:~*req.Subject:1001"},
Weight: 0,
RoundingMethod: "*up",
RoundingDecimals: 4,
MinCost: 0.1,
MaxCost: 0.6,
MaxCostStrategy: "*free",
Rates: map[string]*engine.Rate{
"RT_WEEK": {
ID: "RT_WEEK",
Weight: 0,
ActivationTimes: "* * * * 1-5",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.12,
Unit: time.Minute,
Increment: time.Minute,
rPrf := &RateProfileWithCache{
RateProfileWithOpts: &engine.RateProfileWithOpts{
RateProfile: &engine.RateProfile{
ID: "SpecialRate",
FilterIDs: []string{"*string:~*req.Subject:1001"},
Weight: 0,
RoundingMethod: "*up",
RoundingDecimals: 4,
MinCost: 0.1,
MaxCost: 0.6,
MaxCostStrategy: "*free",
Rates: map[string]*engine.Rate{
"RT_WEEK": {
ID: "RT_WEEK",
Weight: 0,
ActivationTimes: "* * * * 1-5",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.12,
Unit: time.Minute,
Increment: time.Minute,
},
{
IntervalStart: time.Minute,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
},
},
},
{
IntervalStart: time.Minute,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
"RT_WEEKEND": {
ID: "RT_WEEKEND",
Weight: 10,
ActivationTimes: "* * * * 0,6",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
},
},
},
},
},
"RT_WEEKEND": {
ID: "RT_WEEKEND",
Weight: 10,
ActivationTimes: "* * * * 0,6",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
},
},
},
"RT_CHRISTMAS": {
ID: "RT_CHRISTMAS",
Weight: 30,
ActivationTimes: "* * 24 12 *",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
"RT_CHRISTMAS": {
ID: "RT_CHRISTMAS",
Weight: 30,
ActivationTimes: "* * 24 12 *",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
},
},
},
},
},
},
}
if *encoding == utils.MetaGOB {
rPrf.Rates["RT_WEEK"].FilterIDs = nil
rPrf.Rates["RT_WEEKEND"].FilterIDs = nil
rPrf.Rates["RT_CHRISTMAS"].FilterIDs = nil
}
var reply string
if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfileRates, rPrf, &reply); err != nil {
t.Error(err)
@@ -762,8 +778,8 @@ func testV1RatePrfGetRateProfileRatesWithoutTenant(t *testing.T) {
utils.TenantIDWithOpts{TenantID: &utils.TenantID{ID: "SpecialRate"}},
&rply); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(rPrf, rply) {
t.Errorf("Expecting: %+v, \n received: %+v", utils.ToJSON(rPrf), utils.ToJSON(rply))
} else if !reflect.DeepEqual(rPrf.RateProfile, rply) {
t.Errorf("Expecting: %+v, \n received: %+v", utils.ToJSON(rPrf.RateProfile), utils.ToJSON(rply))
}
}
@@ -798,12 +814,16 @@ func testV1RateCostForEventWithDefault(t *testing.T) {
},
},
}
rPrf := &engine.RateProfile{
ID: "DefaultRate",
FilterIDs: []string{"*string:~*req.Subject:1001"},
Weight: 10,
Rates: map[string]*engine.Rate{
"RATE1": rate1,
rPrf := &RateProfileWithCache{
RateProfileWithOpts: &engine.RateProfileWithOpts{
RateProfile: &engine.RateProfile{
ID: "DefaultRate",
FilterIDs: []string{"*string:~*req.Subject:1001"},
Weight: 10,
Rates: map[string]*engine.Rate{
"RATE1": rate1,
},
},
},
}
var reply string
@@ -828,21 +848,17 @@ func testV1RateCostForEventWithDefault(t *testing.T) {
exp := &engine.RateProfileCost{
ID: "DefaultRate",
Cost: 0.12,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
},
CompressFactor: 1,
},
},
RateSIntervals: []*engine.RateSInterval{{
UsageStart: 0,
Increments: []*engine.RateSIncrement{{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
}},
CompressFactor: 1,
}},
}
if err := ratePrfRpc.Call(utils.RateSv1CostForEvent, &argsRt, &rply); err != nil {
t.Error(err)
@@ -891,17 +907,17 @@ func testV1RateCostForEventWithUsage(t *testing.T) {
ID: "DefaultRate",
Cost: 0.19,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
&engine.RateSIncrement{
{
UsageStart: time.Minute,
Usage: time.Minute + 10*time.Second,
Rate: rate1,
@@ -938,17 +954,17 @@ func testV1RateCostForEventWithUsage(t *testing.T) {
ID: "DefaultRate",
Cost: 15.075,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
&engine.RateSIncrement{
{
UsageStart: time.Minute,
Usage: 4*time.Hour + 9*time.Minute + 15*time.Second,
Rate: rate1,
@@ -1029,10 +1045,10 @@ func testV1RateCostForEventWithStartTime(t *testing.T) {
ID: "DefaultRate",
Cost: 0.12,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
@@ -1133,17 +1149,17 @@ func testV1RateCostForEventWithOpts(t *testing.T) {
ID: "DefaultRate",
Cost: 0.19,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
&engine.RateSIncrement{
{
UsageStart: time.Minute,
Usage: time.Minute + 10*time.Second,
Rate: rate1,
@@ -1181,17 +1197,17 @@ func testV1RateCostForEventWithOpts(t *testing.T) {
ID: "DefaultRate",
Cost: 15.075,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
&engine.RateSIncrement{
{
UsageStart: time.Minute,
Usage: 4*time.Hour + 9*time.Minute + 15*time.Second,
Rate: rate1,
@@ -1234,22 +1250,24 @@ func testV1RateCostForEventSpecial(t *testing.T) {
ID: "RT_CHRISTMAS",
Weight: 30,
ActivationTimes: "* * 24 12 *",
IntervalRates: []*engine.IntervalRate{
{
IntervalStart: 0,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
},
},
IntervalRates: []*engine.IntervalRate{{
IntervalStart: 0,
RecurrentFee: 0.06,
Unit: time.Minute,
Increment: time.Second,
}},
}
rPrf := &engine.RateProfile{
ID: "RateChristmas",
FilterIDs: []string{"*string:~*req.Subject:1002"},
Weight: 50,
Rates: map[string]*engine.Rate{
"RATE1": rate1,
"RATE_CHRISTMAS": rtChristmas,
rPrf := &RateProfileWithCache{
RateProfileWithOpts: &engine.RateProfileWithOpts{
RateProfile: &engine.RateProfile{
ID: "RateChristmas",
FilterIDs: []string{"*string:~*req.Subject:1002"},
Weight: 50,
Rates: map[string]*engine.Rate{
"RATE1": rate1,
"RATE_CHRISTMAS": rtChristmas,
},
},
},
}
var reply string
@@ -1279,17 +1297,17 @@ func testV1RateCostForEventSpecial(t *testing.T) {
ID: "RateChristmas",
Cost: 93.725,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
&engine.RateSIncrement{
{
UsageStart: 1 * time.Minute,
Usage: 59 * time.Minute,
Rate: rate1,
@@ -1299,10 +1317,10 @@ func testV1RateCostForEventSpecial(t *testing.T) {
},
CompressFactor: 1,
},
&engine.RateSInterval{
{
UsageStart: time.Hour,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: time.Hour,
Usage: 24 * time.Hour,
Rate: rtChristmas,
@@ -1312,10 +1330,10 @@ func testV1RateCostForEventSpecial(t *testing.T) {
},
CompressFactor: 1,
},
&engine.RateSInterval{
{
UsageStart: 25 * time.Hour,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 25 * time.Hour,
Usage: 735 * time.Second,
Rate: rate1,
@@ -1382,14 +1400,18 @@ func testV1RateCostForEventThreeRates(t *testing.T) {
},
},
}
rPrf := &engine.RateProfile{
ID: "RateNewYear",
FilterIDs: []string{"*string:~*req.Subject:1003"},
Weight: 50,
Rates: map[string]*engine.Rate{
"RATE1": rate1,
"NEW_YEAR1": rtNewYear1,
"NEW_YEAR2": rtNewYear2,
rPrf := &RateProfileWithCache{
RateProfileWithOpts: &engine.RateProfileWithOpts{
RateProfile: &engine.RateProfile{
ID: "RateNewYear",
FilterIDs: []string{"*string:~*req.Subject:1003"},
Weight: 50,
Rates: map[string]*engine.Rate{
"RATE1": rate1,
"NEW_YEAR1": rtNewYear1,
"NEW_YEAR2": rtNewYear2,
},
},
},
}
var reply string
@@ -1419,17 +1441,17 @@ func testV1RateCostForEventThreeRates(t *testing.T) {
ID: "RateNewYear",
Cost: 157.925,
RateSIntervals: []*engine.RateSInterval{
&engine.RateSInterval{
{
UsageStart: 0,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 0,
Usage: time.Minute,
Rate: rate1,
IntervalRateIndex: 0,
CompressFactor: 1,
},
&engine.RateSIncrement{
{
UsageStart: 1 * time.Minute,
Usage: 119 * time.Minute,
Rate: rate1,
@@ -1439,10 +1461,10 @@ func testV1RateCostForEventThreeRates(t *testing.T) {
},
CompressFactor: 1,
},
&engine.RateSInterval{
{
UsageStart: 2 * time.Hour,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 2 * time.Hour,
Usage: 12 * time.Hour,
Rate: rtNewYear1,
@@ -1452,10 +1474,10 @@ func testV1RateCostForEventThreeRates(t *testing.T) {
},
CompressFactor: 1,
},
&engine.RateSInterval{
{
UsageStart: 14 * time.Hour,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 14 * time.Hour,
Usage: 46800 * time.Second,
Rate: rtNewYear2,
@@ -1465,10 +1487,10 @@ func testV1RateCostForEventThreeRates(t *testing.T) {
},
CompressFactor: 1,
},
&engine.RateSInterval{
{
UsageStart: 27 * time.Hour,
Increments: []*engine.RateSIncrement{
&engine.RateSIncrement{
{
UsageStart: 27 * time.Hour,
Usage: 29535 * time.Second,
Rate: rate1,