mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Update integration test for migrator
This commit is contained in:
@@ -137,9 +137,9 @@ func testAlsITMigrateAndMove(t *testing.T) {
|
||||
ID: alias.GetId(),
|
||||
Contexts: []string{utils.META_ANY},
|
||||
FilterIDs: []string{
|
||||
"*string:~Account:1001",
|
||||
"*string:~Subject:call_1001",
|
||||
"*destinations:~Destination:DST_1003",
|
||||
"*string:~*req.Account:1001",
|
||||
"*string:~*req.Subject:call_1001",
|
||||
"*destinations:~*req.Destination:DST_1003",
|
||||
},
|
||||
ActivationInterval: nil,
|
||||
Attributes: []*engine.Attribute{
|
||||
@@ -207,10 +207,10 @@ func testAlsITMigrateAndMove(t *testing.T) {
|
||||
}
|
||||
|
||||
expAlsIdx := map[string]utils.StringMap{
|
||||
"*string:~Account:1001": utils.StringMap{
|
||||
"*string:~*req.Account:1001": utils.StringMap{
|
||||
"*out:*any:*any:1001:call_1001:*rated": true,
|
||||
},
|
||||
"*string:~Subject:call_1001": utils.StringMap{
|
||||
"*string:~*req.Subject:call_1001": utils.StringMap{
|
||||
"*out:*any:*any:1001:call_1001:*rated": true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -134,7 +134,10 @@ func derivedChargers2Charger(dc *v1DerivedCharger, tenant string, key string, fi
|
||||
if strings.HasPrefix(filter, utils.STATIC_VALUE_PREFIX) {
|
||||
filter = filter[1:]
|
||||
}
|
||||
ch.FilterIDs = append(ch.FilterIDs, "*rsr::"+filter)
|
||||
if strings.HasPrefix(filter, utils.DynamicDataPrefix) {
|
||||
filter = filter[1:]
|
||||
}
|
||||
ch.FilterIDs = append(ch.FilterIDs, "*rsr::"+utils.DynamicDataPrefix+utils.MetaReq+utils.NestingSep+filter)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -144,7 +147,7 @@ func (m *Migrator) derivedChargers2Chargers(dck *v1DerivedChargersWithKey) (err
|
||||
skey := utils.SplitConcatenatedKey(dck.Key)
|
||||
destination := ""
|
||||
if len(dck.Value.DestinationIDs) != 0 {
|
||||
destination = fmt.Sprintf("%s:~%s:", utils.MetaDestinations, utils.Destination)
|
||||
destination = fmt.Sprintf("%s:~%s:", utils.MetaDestinations, utils.MetaReq+utils.NestingSep+utils.Destination)
|
||||
keys := dcGetMapKeys(dck.Value.DestinationIDs)
|
||||
destination += strings.Join(keys, utils.INFIELD_SEP)
|
||||
}
|
||||
@@ -154,13 +157,13 @@ func (m *Migrator) derivedChargers2Chargers(dck *v1DerivedChargersWithKey) (err
|
||||
filter = append(filter, destination)
|
||||
}
|
||||
if len(skey[2]) != 0 && skey[2] != utils.META_ANY {
|
||||
filter = append(filter, fmt.Sprintf("%s:~%s:%s", utils.MetaReq+utils.NestingSep+utils.MetaString, utils.Category, skey[2]))
|
||||
filter = append(filter, fmt.Sprintf("%s:~%s:%s", utils.MetaString, utils.MetaReq+utils.NestingSep+utils.Category, skey[2]))
|
||||
}
|
||||
if len(skey[3]) != 0 && skey[3] != utils.META_ANY {
|
||||
filter = append(filter, fmt.Sprintf("%s:~%s:%s", utils.MetaReq+utils.NestingSep+utils.MetaString, utils.Account, skey[3]))
|
||||
filter = append(filter, fmt.Sprintf("%s:~%s:%s", utils.MetaString, utils.MetaReq+utils.NestingSep+utils.Account, skey[3]))
|
||||
}
|
||||
if len(skey[4]) != 0 && skey[4] != utils.META_ANY {
|
||||
filter = append(filter, fmt.Sprintf("%s:~%s:%s", utils.MetaReq+utils.NestingSep+utils.MetaString, utils.Subject, skey[4]))
|
||||
filter = append(filter, fmt.Sprintf("%s:~%s:%s", utils.MetaString, utils.MetaReq+utils.NestingSep+utils.Subject, skey[4]))
|
||||
}
|
||||
for i, dc := range dck.Value.Chargers {
|
||||
attr := derivedChargers2AttributeProfile(dc, skey[1], fmt.Sprintf("%s_%v", dck.Key, i), filter)
|
||||
|
||||
@@ -143,8 +143,8 @@ func testDCITMigrateAndMove(t *testing.T) {
|
||||
ID: fmt.Sprintf("%s_%v", derivch.Key, 0),
|
||||
Contexts: []string{utils.MetaChargers},
|
||||
FilterIDs: []string{
|
||||
"*destinations:~Destination:1001;1002;1003",
|
||||
"*string:~Account:1003",
|
||||
"*destinations:~*req.Destination:1001;1002;1003",
|
||||
"*string:~*req.Account:1003",
|
||||
},
|
||||
ActivationInterval: nil,
|
||||
Attributes: []*engine.Attribute{
|
||||
@@ -167,9 +167,9 @@ func testDCITMigrateAndMove(t *testing.T) {
|
||||
Tenant: defaultTenant,
|
||||
ID: fmt.Sprintf("%s_%v", derivch.Key, 0),
|
||||
FilterIDs: []string{
|
||||
"*destinations:~Destination:1001;1002;1003",
|
||||
"*string:~Account:1003",
|
||||
"*rsr::~filterhdr1:s/(.+)/special_run3/",
|
||||
"*destinations:~*req.Destination:1001;1002;1003",
|
||||
"*string:~*req.Account:1003",
|
||||
"*rsr::~*req.filterhdr1:s/(.+)/special_run3/",
|
||||
},
|
||||
ActivationInterval: nil,
|
||||
RunID: "RunID",
|
||||
@@ -228,7 +228,7 @@ func testDCITMigrateAndMove(t *testing.T) {
|
||||
t.Error("Error should be not found : ", err)
|
||||
}
|
||||
expDcIdx := map[string]utils.StringMap{
|
||||
"*string:~Account:1003": utils.StringMap{
|
||||
"*string:~*req.Account:1003": utils.StringMap{
|
||||
"*out:cgrates.org:*any:1003:*any_0": true,
|
||||
},
|
||||
}
|
||||
@@ -239,7 +239,7 @@ func testDCITMigrateAndMove(t *testing.T) {
|
||||
t.Errorf("Expected %v, recived: %v", utils.ToJSON(expDcIdx), utils.ToJSON(dcidx))
|
||||
}
|
||||
expDcIdx = map[string]utils.StringMap{
|
||||
"*string:~Account:1003": utils.StringMap{
|
||||
"*string:~*req.Account:1003": utils.StringMap{
|
||||
"*out:cgrates.org:*any:1003:*any_0": true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -152,12 +152,12 @@ func TestDerivedChargers2AttributeProfile(t *testing.T) {
|
||||
},
|
||||
Tenant: defaultTenant,
|
||||
Key: "key1",
|
||||
Filters: []string{"*string:~Subject:1005"},
|
||||
Filters: []string{"*string:~*req.Subject:1005"},
|
||||
Expected: &engine.AttributeProfile{
|
||||
Tenant: defaultTenant,
|
||||
ID: "key1",
|
||||
Contexts: []string{utils.MetaChargers},
|
||||
FilterIDs: []string{"*string:~Subject:1005"},
|
||||
FilterIDs: []string{"*string:~*req.Subject:1005"},
|
||||
ActivationInterval: nil,
|
||||
Attributes: []*engine.Attribute{
|
||||
&engine.Attribute{
|
||||
@@ -213,16 +213,16 @@ func TestDerivedChargers2Charger(t *testing.T) {
|
||||
Tenant: defaultTenant,
|
||||
Key: "key2",
|
||||
Filters: []string{
|
||||
"*string:~Category:*voice1",
|
||||
"*string:~Account:1001",
|
||||
"*string:~*req.Category:*voice1",
|
||||
"*string:~*req.Account:1001",
|
||||
},
|
||||
Expected: &engine.ChargerProfile{
|
||||
Tenant: defaultTenant,
|
||||
ID: "key2",
|
||||
FilterIDs: []string{
|
||||
"*string:~Category:*voice1",
|
||||
"*string:~Account:1001",
|
||||
"*rsr::~Header4:s/a/${1}b/{*duration_seconds&*round:2}(b&c)",
|
||||
"*string:~*req.Category:*voice1",
|
||||
"*string:~*req.Account:1001",
|
||||
"*rsr::~*req.Header4:s/a/${1}b/{*duration_seconds&*round:2}(b&c)",
|
||||
},
|
||||
ActivationInterval: nil,
|
||||
RunID: "runID",
|
||||
@@ -242,7 +242,7 @@ func TestDerivedChargers2Charger(t *testing.T) {
|
||||
Expected: &engine.ChargerProfile{
|
||||
Tenant: defaultTenant,
|
||||
ID: "key2",
|
||||
FilterIDs: []string{"*rsr::1003"},
|
||||
FilterIDs: []string{"*rsr::~*req.1003"},
|
||||
ActivationInterval: nil,
|
||||
RunID: "runID2",
|
||||
AttributeIDs: make([]string, 0),
|
||||
@@ -252,7 +252,7 @@ func TestDerivedChargers2Charger(t *testing.T) {
|
||||
}
|
||||
for i, v := range tests {
|
||||
if rply := derivedChargers2Charger(v.DC, v.Tenant, v.Key, v.Filters); !reflect.DeepEqual(v.Expected, rply) {
|
||||
t.Errorf("For %v expected: %s ,recieved: %s", i, utils.ToJSON(v.Expected), utils.ToJSON(rply))
|
||||
t.Errorf("For %v expected: %s ,\n recieved: %s", i, utils.ToJSON(v.Expected), utils.ToJSON(rply))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ func testFltrITMigrateAndMove(t *testing.T) {
|
||||
Rules: []*engine.FilterRule{
|
||||
&engine.FilterRule{
|
||||
Type: utils.MetaPrefix,
|
||||
FieldName: "~Account",
|
||||
FieldName: "~*req.Account",
|
||||
Values: []string{"1001"},
|
||||
},
|
||||
},
|
||||
@@ -171,7 +171,7 @@ func testFltrITMigrateAndMove(t *testing.T) {
|
||||
Tenant: "cgrates.org",
|
||||
ID: "ATTR_1",
|
||||
Contexts: []string{utils.META_ANY},
|
||||
FilterIDs: []string{"*string:~Account:1001", "FLTR_2"},
|
||||
FilterIDs: []string{"*string:~*req.Account:1001", "FLTR_2"},
|
||||
ActivationInterval: nil,
|
||||
Attributes: []*engine.Attribute{
|
||||
{
|
||||
@@ -233,8 +233,8 @@ func testFltrITMigrateAndMove(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expAttrProf), utils.ToJSON(resultattr))
|
||||
}
|
||||
expFltrIdx := map[string]utils.StringMap{
|
||||
"*prefix:~Account:1001": utils.StringMap{"ATTR_1": true},
|
||||
"*string:~Account:1001": utils.StringMap{"ATTR_1": true}}
|
||||
"*prefix:~*req.Account:1001": utils.StringMap{"ATTR_1": true},
|
||||
"*string:~*req.Account:1001": utils.StringMap{"ATTR_1": true}}
|
||||
|
||||
if fltridx, err := fltrMigrator.dmOut.DataManager().GetFilterIndexes(utils.PrefixToIndexCache[utils.AttributeProfilePrefix], utils.ConcatenatedKey(attrProf.Tenant, utils.META_ANY), utils.MetaString, nil); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user