Fix integration tests

This commit is contained in:
ionutboangiu
2021-11-12 17:48:03 +02:00
committed by Dan Christian Bogos
parent 1901be0485
commit 53c5bca394
12 changed files with 113 additions and 39 deletions

View File

@@ -192,7 +192,10 @@ func testAnalyzerSChargerSv1ProcessEvent(t *testing.T) {
"RunID": "*raw",
"Subject": "Something_inter",
},
APIOpts: map[string]interface{}{"*subsys": "*chargers"},
APIOpts: map[string]interface{}{
"*subsys": "*chargers",
utils.OptsAttributesProfileIDs: []string{"*constant:*req.RequestType:*none"},
},
},
},
}

View File

@@ -378,7 +378,9 @@ func testAttributeSProcessEvent(t *testing.T) {
utils.Subject: "1001",
utils.Destination: "+491511231234",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
var rplyEv engine.AttrSProcessEventReply
@@ -505,7 +507,9 @@ func testAttributeSProcessEventWithNoneSubstitute(t *testing.T) {
utils.AccountField: "1001",
utils.Destination: "+491511231234",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
@@ -574,7 +578,9 @@ func testAttributeSProcessEventWithNoneSubstitute2(t *testing.T) {
utils.AccountField: "1001",
utils.Destination: "+491511231234",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
eRply2 := &engine.AttrSProcessEventReply{
@@ -588,7 +594,9 @@ func testAttributeSProcessEventWithNoneSubstitute2(t *testing.T) {
utils.AccountField: "1001",
utils.Destination: "+491511231234",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
var rplyEv engine.AttrSProcessEventReply
@@ -657,7 +665,9 @@ func testAttributeSProcessEventWithNoneSubstitute3(t *testing.T) {
utils.Subject: "1001",
utils.Destination: "+491511231234",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
var rplyEv engine.AttrSProcessEventReply
@@ -703,7 +713,7 @@ func testAttributeSProcessEventWithHeader(t *testing.T) {
"Field1": "Value1",
},
APIOpts: map[string]interface{}{
utils.OptsAttributesProcessRuns: 1,
utils.OptsAttributesProcessRuns: 1.,
utils.OptsContext: utils.MetaSessionS,
},
}
@@ -718,7 +728,8 @@ func testAttributeSProcessEventWithHeader(t *testing.T) {
"Field2": "Value1",
},
APIOpts: map[string]interface{}{
utils.OptsAttributesProcessRuns: 1,
utils.OptsAttributesProcessRuns: 1.,
utils.OptsContext: utils.MetaSessionS,
},
},
}
@@ -1044,6 +1055,7 @@ func testAttributeSProcessEventWithSearchAndReplace(t *testing.T) {
},
APIOpts: map[string]interface{}{
utils.OptsAttributesProcessRuns: 1,
utils.OptsContext: utils.MetaSessionS,
},
},
}

View File

@@ -144,7 +144,9 @@ func testCacheSReplicateProcessAttributes(t *testing.T) {
utils.AccountField: "1001",
"OfficeGroup": "Marketing",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
var rplyEv engine.AttrSProcessEventReply

View File

@@ -330,7 +330,11 @@ func testChargerSProcessEvent(t *testing.T) {
"Password": "CGRateS.org",
"RunID": utils.MetaDefault,
},
APIOpts: map[string]interface{}{utils.OptsContext: "simpleauth", utils.Subsys: utils.MetaChargers},
APIOpts: map[string]interface{}{
utils.OptsContext: "simpleauth",
utils.Subsys: utils.MetaChargers,
utils.OptsAttributesProfileIDs: []string{"ATTR_1001_SIMPLEAUTH"},
},
},
},
}
@@ -359,7 +363,11 @@ func testChargerSProcessEvent(t *testing.T) {
utils.Category: "call",
utils.RunID: utils.MetaDefault,
},
APIOpts: map[string]interface{}{utils.OptsContext: "simpleauth", utils.Subsys: utils.MetaChargers},
APIOpts: map[string]interface{}{
utils.OptsContext: "simpleauth",
utils.Subsys: utils.MetaChargers,
utils.OptsAttributesProfileIDs: []string{"*constant:*req.RequestType:*rated;*constant:*req.Category:call"},
},
},
},
}
@@ -533,7 +541,10 @@ func testChargerSProcessWithNotFoundAttribute(t *testing.T) {
"CustomField": "WithoutAttributes",
"RunID": "CustomRun",
},
APIOpts: map[string]interface{}{utils.Subsys: utils.MetaChargers},
APIOpts: map[string]interface{}{
utils.Subsys: utils.MetaChargers,
utils.OptsAttributesProfileIDs: nil,
},
},
},
}
@@ -597,7 +608,8 @@ func testChargerSProccessEventWithProcceSRunS(t *testing.T) {
},
APIOpts: map[string]interface{}{
utils.Subsys: utils.MetaChargers,
utils.OptsAttributesProcessRuns: 1.,
utils.OptsAttributesProfileIDs: []string{"*constant:*req.Account:1002", "*constant:*req.Account:1003"},
utils.OptsAttributesProcessRuns: 1,
},
},
},
@@ -608,7 +620,7 @@ func testChargerSProccessEventWithProcceSRunS(t *testing.T) {
Event: map[string]interface{}{
utils.AccountField: "1010",
},
APIOpts: map[string]interface{}{utils.OptsAttributesProcessRuns: 1.},
APIOpts: map[string]interface{}{utils.OptsAttributesProcessRuns: 1},
}
var result2 []*engine.ChrgSProcessEventReply
if err := chargerRPC.Call(utils.ChargerSv1ProcessEvent, cgrEv, &result2); err != nil {

View File

@@ -235,6 +235,9 @@ func testCGRConfigReloadThresholdS(t *testing.T) {
PrefixIndexedFields: &[]string{},
SuffixIndexedFields: &[]string{},
IndexedSelects: true,
Opts: &ThresholdsOpts{
ProfileIDs: []string{},
},
}
if !reflect.DeepEqual(expAttr, cfg.ThresholdSCfg()) {
t.Errorf("Expected %s , received: %s ", utils.ToJSON(expAttr), utils.ToJSON(cfg.ThresholdSCfg()))
@@ -262,6 +265,9 @@ func testCGRConfigReloadStatS(t *testing.T) {
SuffixIndexedFields: &[]string{},
IndexedSelects: true,
ThresholdSConns: []string{utils.MetaLocalHost},
Opts: &StatsOpts{
ProfileIDs: []string{},
},
}
if !reflect.DeepEqual(expAttr, cfg.StatSCfg()) {
t.Errorf("Expected %s , received: %s ", utils.ToJSON(expAttr), utils.ToJSON(cfg.StatSCfg()))
@@ -289,6 +295,11 @@ func testCGRConfigReloadResourceS(t *testing.T) {
SuffixIndexedFields: &[]string{},
IndexedSelects: true,
ThresholdSConns: []string{utils.MetaLocalHost},
Opts: &ResourcesOpts{
UsageID: utils.EmptyString,
UsageTTL: 72 * time.Hour,
Units: 1,
},
}
if !reflect.DeepEqual(expAttr, cfg.ResourceSCfg()) {
t.Errorf("Expected %s , received: %s ", utils.ToJSON(expAttr), utils.ToJSON(cfg.ResourceSCfg()))
@@ -320,6 +331,12 @@ func testCGRConfigReloadSupplierS(t *testing.T) {
RALsConns: []string{},
IndexedSelects: true,
DefaultRatio: 1,
Opts: &RoutesOpts{
Context: utils.MetaRoutes,
IgnoreErrors: false,
MaxCost: utils.EmptyString,
ProfileCount: 1,
},
}
if !reflect.DeepEqual(expAttr, cfg.RouteSCfg()) {
t.Errorf("Expected %s , received: %s ", utils.ToJSON(expAttr), utils.ToJSON(cfg.RouteSCfg()))

View File

@@ -255,7 +255,8 @@ func testDspAttrGetAttrFailover(t *testing.T) {
"Password": "CGRateS.org",
},
APIOpts: map[string]interface{}{
utils.OptsAPIKey: "attr12345",
utils.OptsAPIKey: "attr12345",
utils.OptsContext: "simpleauth",
},
},
}
@@ -599,7 +600,8 @@ func testDspAttrGetAttrInternal(t *testing.T) {
"Password": "CGRateS.com",
},
APIOpts: map[string]interface{}{
utils.OptsAPIKey: "attr12345",
utils.OptsAPIKey: "attr12345",
utils.OptsContext: "simpleauth",
},
},
}

View File

@@ -534,7 +534,7 @@ func TestRoutesSortedForEventWithLimitAndOffset(t *testing.T) {
},
}}
testRoutesArgs[1].APIOpts[utils.OptsRoutesLimit] = 1
testRoutesArgs[1].APIOpts[utils.OptsRoutesLimit] = 1
testRoutesArgs[1].APIOpts[utils.OptsRoutesOffset] = 1
sprf, err := routeService.sortedRoutesForEvent("cgrates.org", testRoutesArgs[1])
if err != nil {
t.Fatal(err)

View File

@@ -902,7 +902,7 @@ func testSectConfigSReloadAttributes(t *testing.T) {
} else if reply != utils.OK {
t.Errorf("Expected OK received: %+v", reply)
}
cfgStr := "{\"attributes\":{\"any_context\":true,\"apiers_conns\":[\"*internal\"],\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"process_runs\":1,\"profile_runs\":0,\"resources_conns\":[\"*internal\"],\"stats_conns\":[\"*internal\"],\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"]}}"
cfgStr := "{\"attributes\":{\"any_context\":true,\"apiers_conns\":[\"*internal\"],\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"opts\":{\"*processRuns\":1,\"*profileIDs\":[],\"*profileIgnoreFilters\":false,\"*profileRuns\":0},\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"resources_conns\":[\"*internal\"],\"stats_conns\":[\"*internal\"],\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"]}}"
var rpl string
if err := testSectRPC.Call(utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
@@ -981,7 +981,7 @@ func testSectConfigSReloadResources(t *testing.T) {
} else if reply != utils.OK {
t.Errorf("Expected OK received: %+v", reply)
}
cfgStr := "{\"resources\":{\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"store_interval\":\"-1ns\",\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"],\"thresholds_conns\":[\"*internal\"]}}"
cfgStr := "{\"resources\":{\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"opts\":{\"*units\":1,\"*usageID\":\"\",\"*usageTTL\":259200000000000},\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"store_interval\":\"-1ns\",\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"],\"thresholds_conns\":[\"*internal\"]}}"
var rpl string
if err := testSectRPC.Call(utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",
@@ -1022,7 +1022,7 @@ func testSectConfigSReloadStats(t *testing.T) {
} else if reply != utils.OK {
t.Errorf("Expected OK received: %+v", reply)
}
cfgStr := "{\"stats\":{\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"store_interval\":\"-1ns\",\"store_uncompressed_limit\":1,\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"],\"thresholds_conns\":[\"*internal\"]}}"
cfgStr := "{\"stats\":{\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"opts\":{\"*profileIDs\":[],\"*profileIgnoreFilters\":false},\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"store_interval\":\"-1ns\",\"store_uncompressed_limit\":1,\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"],\"thresholds_conns\":[\"*internal\"]}}"
var rpl string
if err := testSectRPC.Call(utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",
@@ -1052,7 +1052,7 @@ func testSectConfigSReloadThresholds(t *testing.T) {
} else if reply != utils.OK {
t.Errorf("Expected OK received: %+v", reply)
}
cfgStr := "{\"thresholds\":{\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"store_interval\":\"-1ns\",\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"]}}"
cfgStr := "{\"thresholds\":{\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"opts\":{\"*profileIDs\":[],\"*profileIgnoreFilters\":false},\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"store_interval\":\"-1ns\",\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"]}}"
var rpl string
if err := testSectRPC.Call(utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",
@@ -1095,7 +1095,7 @@ func testSectConfigSReloadRoutes(t *testing.T) {
} else if reply != utils.OK {
t.Errorf("Expected OK received: %+v", reply)
}
cfgStr := "{\"routes\":{\"attributes_conns\":[\"*localhost\"],\"default_ratio\":1,\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"rals_conns\":[\"*localhost\"],\"resources_conns\":[\"*localhost\"],\"stats_conns\":[\"*localhost\"],\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"]}}"
cfgStr := "{\"routes\":{\"attributes_conns\":[\"*localhost\"],\"default_ratio\":1,\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":true,\"opts\":{\"*context\":\"*routes\",\"*ignoreErrors\":false,\"*maxCost\":\"\",\"*profileCount\":1},\"prefix_indexed_fields\":[\"prefix_indexed_fields\"],\"rals_conns\":[\"*localhost\"],\"resources_conns\":[\"*localhost\"],\"stats_conns\":[\"*localhost\"],\"string_indexed_fields\":[\"string_indexed_fields\"],\"suffix_indexed_fields\":[\"suffix_indexed_fields\"]}}"
var rpl string
if err := testSectRPC.Call(utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{
Tenant: "cgrates.org",

View File

@@ -229,7 +229,9 @@ func testAttributeSetFltr2(t *testing.T) {
"Subject": "4444",
"FL1": "Al1",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
var rplyEv engine.AttrSProcessEventReply

View File

@@ -149,7 +149,9 @@ func testAttributeSProcessEvent(t *testing.T) {
utils.Category: utils.MetaVoice,
utils.ToR: utils.MetaVoice,
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
sort.Strings(eRply.AlteredFields)
@@ -230,7 +232,9 @@ func testAttributeSProcessEventWithAccount(t *testing.T) {
"EventName": "AddAccountInfo",
"Balance": "10",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
sort.Strings(eRply.AlteredFields)
@@ -439,7 +443,9 @@ func testAttributeSProcessEventWithStat(t *testing.T) {
"EventName": "AddStatEvent",
"AcdMetric": "11000000000",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
sort.Strings(eRply.AlteredFields)
@@ -520,7 +526,9 @@ func testAttributeSProcessEventWithStatFull(t *testing.T) {
"EventName": "AddFullStats",
"AllMetrics": "{\"*acd\":11000000000,\"*asr\":100,\"*tcd\":22000000000}",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
sort.Strings(eRply.AlteredFields)
@@ -660,7 +668,9 @@ func testAttributeSProcessEventWithResource(t *testing.T) {
"EventName": "AddResourceUsages",
"ResourceTotalUsages": "5",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
sort.Strings(eRply.AlteredFields)
@@ -834,7 +844,9 @@ func testAttributeSProcessEventWithLibPhoneNumber(t *testing.T) {
"Destination": "+447779330921",
"DestinationCarrier": "Orange",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
sort.Strings(eRply.AlteredFields)
@@ -935,7 +947,9 @@ func testAttributeSProcessEventWithLibPhoneNumberComposed(t *testing.T) {
"Destination": "+447779330921",
"DestinationCarrier": "Orange;44",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
sort.Strings(eRply.AlteredFields)
@@ -1018,7 +1032,9 @@ func testAttributeSProcessEventWithLibPhoneNumberFull(t *testing.T) {
"Destination": "+447779330921",
"DestinationDetails": "{\"Carrier\":\"Orange\",\"CountryCode\":44,\"CountryCodeSource\":1,\"Extension\":\"\",\"GeoLocation\":\"\",\"ItalianLeadingZero\":false,\"LengthOfNationalDestinationCode\":0,\"NationalNumber\":7779330921,\"NumberOfLeadingZeros\":1,\"NumberType\":1,\"PreferredDomesticCarrierCode\":\"\",\"RawInput\":\"+447779330921\",\"Region\":\"GB\"}",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: utils.MetaSessionS,
},
},
}
sort.Strings(eRply.AlteredFields)

View File

@@ -938,7 +938,8 @@ func testV1FltrChargerSuffix(t *testing.T) {
utils.Destination: "999",
},
APIOpts: map[string]interface{}{
utils.Subsys: utils.MetaChargers,
utils.Subsys: utils.MetaChargers,
utils.OptsAttributesProfileIDs: []string{"*constant:*req.Subject:intraState"},
},
},
},
@@ -975,7 +976,8 @@ func testV1FltrChargerSuffix(t *testing.T) {
utils.Destination: "999",
},
APIOpts: map[string]interface{}{
utils.Subsys: utils.MetaChargers,
utils.Subsys: utils.MetaChargers,
utils.OptsAttributesProfileIDs: []string{"*constant:*req.Subject:interState"},
},
},
},
@@ -1034,7 +1036,9 @@ func testV1FltrAttributesPrefix(t *testing.T) {
"CustomField2": "+2007",
utils.Destination: "+1207",
},
APIOpts: map[string]interface{}{},
APIOpts: map[string]interface{}{
utils.OptsContext: "prefix",
},
},
}
cgrEv := &utils.CGREvent{
@@ -1139,7 +1143,10 @@ func testV1FltrPopulateTimings(t *testing.T) {
Event: map[string]interface{}{
utils.AnswerTime: "2021-04-29T10:45:00Z",
},
APIOpts: make(map[string]interface{}),
APIOpts: map[string]interface{}{
utils.OptsAttributesProfileIDs: []string{"FltrTest"},
utils.OptsContext: utils.MetaAny,
},
},
}

View File

@@ -176,8 +176,9 @@ func testRPCChargerSWithAttr(t *testing.T) {
"RunID": "raw",
},
APIOpts: map[string]interface{}{
"*processRuns": 1.,
"*subsys": "*chargers",
utils.OptsAttributesProcessRuns: 1,
utils.OptsAttributesProfileIDs: []string{"*constant:*req.RequestType:*none"},
"*subsys": "*chargers",
},
},
}, {
@@ -192,8 +193,8 @@ func testRPCChargerSWithAttr(t *testing.T) {
"Subject": "SUPPLIER1",
},
APIOpts: map[string]interface{}{
"*processRuns": 1.,
"*subsys": "*chargers",
utils.OptsAttributesProcessRuns: 1,
"*subsys": "*chargers",
},
},
},