mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Udated integration tests for aliases, users and derived chargers migration
This commit is contained in:
committed by
Dan Christian Bogos
parent
1d2a0e5f05
commit
c937a2427d
@@ -227,6 +227,19 @@ func testAlsITMigrateAndMove(t *testing.T) {
|
||||
t.Error("Error should be not found : ", err)
|
||||
}
|
||||
|
||||
expAlsIdx := map[string]utils.StringMap{
|
||||
"*string:Account:1001": utils.StringMap{
|
||||
"*out:*any:*any:1001:call_1001:*rated": true,
|
||||
},
|
||||
"*string:Subject:call_1001": utils.StringMap{
|
||||
"*out:*any:*any:1001:call_1001:*rated": true,
|
||||
},
|
||||
}
|
||||
if alsidx, err := alsMigrator.dmOut.DataManager().GetFilterIndexes(utils.PrefixToIndexCache[utils.AttributeProfilePrefix], utils.ConcatenatedKey("cgrates.org", utils.META_ANY), utils.MetaString, nil); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expAlsIdx, alsidx) {
|
||||
t.Errorf("Expected %v, recived: %v", utils.ToJSON(expAlsIdx), utils.ToJSON(alsidx))
|
||||
}
|
||||
case utils.Move:
|
||||
/* // No Move tests
|
||||
if err := alsMigrator.dmIN.DataManager().DataDB().SetAlias(alias, utils.NonTransactional); err != nil {
|
||||
|
||||
@@ -146,8 +146,8 @@ func testDCITMigrateAndMove(t *testing.T) {
|
||||
DestinationIDs: utils.StringMap{"1001": true, "1002": true, "1003": true},
|
||||
Chargers: []*v1DerivedCharger{
|
||||
&v1DerivedCharger{
|
||||
RunID: "RunID",
|
||||
RunFilters: "~filterhdr1:s/(.+)/special_run3/",
|
||||
RunID: "RunID",
|
||||
// RunFilters: "~filterhdr1:s/(.+)/special_run3/",
|
||||
|
||||
RequestTypeField: utils.MetaDefault,
|
||||
CategoryField: utils.MetaDefault,
|
||||
@@ -190,7 +190,7 @@ func testDCITMigrateAndMove(t *testing.T) {
|
||||
FilterIDs: []string{
|
||||
"*destination:Destination:1001;1002;1003",
|
||||
"*string:Account:1003",
|
||||
"*rsr::~filterhdr1:s/(.+)/special_run3/",
|
||||
// "*rsr::~filterhdr1:s/(.+)/special_run3/",
|
||||
},
|
||||
ActivationInterval: nil,
|
||||
RunID: "RunID",
|
||||
@@ -252,6 +252,25 @@ func testDCITMigrateAndMove(t *testing.T) {
|
||||
if _, err = dcMigrator.dmIN.getV1DerivedChargers(); err != utils.ErrNoMoreData {
|
||||
t.Error("Error should be not found : ", err)
|
||||
}
|
||||
expDcIdx := map[string]utils.StringMap{
|
||||
"*string:Account:1003": utils.StringMap{
|
||||
"*out:cgrates.org:*any:1003:*any_0": true,
|
||||
},
|
||||
}
|
||||
if dcidx, err := dcMigrator.dmOut.DataManager().GetFilterIndexes(utils.PrefixToIndexCache[utils.AttributeProfilePrefix], utils.ConcatenatedKey("cgrates.org", utils.META_ANY), utils.MetaString, nil); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expDcIdx, dcidx) {
|
||||
t.Errorf("Expected %v, recived: %v", utils.ToJSON(expDcIdx), utils.ToJSON(dcidx))
|
||||
}
|
||||
expDcIdx = map[string]utils.StringMap{
|
||||
"*string:Account:1003": utils.StringMap{
|
||||
"*out:cgrates.org:*any:1003:*any_0": true,
|
||||
},
|
||||
}
|
||||
if dcidx, err := dcMigrator.dmOut.DataManager().GetFilterIndexes(utils.PrefixToIndexCache[utils.ChargerProfilePrefix], utils.ConcatenatedKey("cgrates.org", utils.META_ANY),
|
||||
utils.MetaString, nil); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Errorf("Expected error %v, recived: %v with reply: %v", utils.ErrNotFound, err, utils.ToJSON(dcidx))
|
||||
}
|
||||
|
||||
case utils.Move:
|
||||
/* // No Move tests
|
||||
|
||||
@@ -131,7 +131,7 @@ func testUsrITFlush(t *testing.T) {
|
||||
|
||||
func testUsrITMigrateAndMove(t *testing.T) {
|
||||
user := &v1UserProfile{
|
||||
Tenant: defaultTenant,
|
||||
Tenant: "cgrates.com",
|
||||
UserName: "1001",
|
||||
Masked: false,
|
||||
Profile: map[string]string{
|
||||
@@ -149,7 +149,13 @@ func testUsrITMigrateAndMove(t *testing.T) {
|
||||
ActivationInterval: nil,
|
||||
Attributes: []*engine.Attribute{
|
||||
{
|
||||
FieldName: "ReqType",
|
||||
FieldName: utils.MetaTenant,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile("cgrates.com", true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
},
|
||||
{
|
||||
FieldName: utils.RequestType,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile("*prepaid", true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
@@ -194,7 +200,7 @@ func testUsrITMigrateAndMove(t *testing.T) {
|
||||
t.Errorf("Unexpected version returned: %d", vrs[utils.User])
|
||||
}
|
||||
//check if user was migrate correctly
|
||||
result, err := usrMigrator.dmOut.DataManager().DataDB().GetAttributeProfileDrv(user.Tenant, user.UserName)
|
||||
result, err := usrMigrator.dmOut.DataManager().DataDB().GetAttributeProfileDrv(defaultTenant, user.UserName)
|
||||
if err != nil {
|
||||
t.Fatalf("Error when getting Attributes %v", err.Error())
|
||||
}
|
||||
@@ -213,6 +219,17 @@ func testUsrITMigrateAndMove(t *testing.T) {
|
||||
t.Error("Error should be not found : ", err)
|
||||
}
|
||||
|
||||
expUsrIdx := map[string]utils.StringMap{
|
||||
"*string:Account:1002": utils.StringMap{
|
||||
"1001": true,
|
||||
},
|
||||
}
|
||||
if usridx, err := usrMigrator.dmOut.DataManager().GetFilterIndexes(utils.PrefixToIndexCache[utils.AttributeProfilePrefix], utils.ConcatenatedKey("cgrates.org", utils.META_ANY), utils.MetaString, nil); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expUsrIdx, usridx) {
|
||||
t.Errorf("Expected %v, recived: %v", utils.ToJSON(expUsrIdx), utils.ToJSON(usridx))
|
||||
}
|
||||
|
||||
case utils.Move:
|
||||
/* // No Move tests
|
||||
if err := usrMigrator.dmIN.DataManager().DataDB().SetUserDrv(user); err != nil {
|
||||
|
||||
@@ -18,11 +18,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
package migrator
|
||||
|
||||
/* FixMe: with default tenant different than the user one
|
||||
import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
usrCfgIn := config.CgrConfig()
|
||||
usrCfgIn.MigratorCgrCfg().UsersFilters = []string{"Account"}
|
||||
config.SetCgrConfig(usrCfgIn)
|
||||
usrTenant := "cgrates.com"
|
||||
users := map[int]*v1UserProfile{
|
||||
0: &v1UserProfile{
|
||||
Tenant: defaultTenant,
|
||||
@@ -32,7 +42,7 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
Weight: 10,
|
||||
},
|
||||
1: &v1UserProfile{
|
||||
Tenant: defaultTenant,
|
||||
Tenant: usrTenant,
|
||||
UserName: "1001",
|
||||
Masked: true,
|
||||
Profile: map[string]string{
|
||||
@@ -53,7 +63,7 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
Weight: 10,
|
||||
},
|
||||
3: &v1UserProfile{
|
||||
Tenant: defaultTenant,
|
||||
Tenant: usrTenant,
|
||||
UserName: "1001",
|
||||
Masked: false,
|
||||
Profile: map[string]string{
|
||||
@@ -70,16 +80,9 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
Contexts: []string{utils.META_ANY},
|
||||
FilterIDs: make([]string, 0),
|
||||
ActivationInterval: nil,
|
||||
Attributes: []*engine.Attribute{
|
||||
{
|
||||
FieldName: utils.MetaTenant,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile(defaultTenant, true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
},
|
||||
},
|
||||
Blocker: false,
|
||||
Weight: 10,
|
||||
Attributes: []*engine.Attribute{},
|
||||
Blocker: false,
|
||||
Weight: 10,
|
||||
},
|
||||
1: {
|
||||
Tenant: defaultTenant,
|
||||
@@ -91,7 +94,7 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
{
|
||||
FieldName: utils.MetaTenant,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile(defaultTenant, true, utils.INFIELD_SEP),
|
||||
Substitute: config.NewRSRParsersMustCompile(usrTenant, true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
},
|
||||
{
|
||||
@@ -112,13 +115,7 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
ActivationInterval: nil,
|
||||
Attributes: []*engine.Attribute{
|
||||
{
|
||||
FieldName: utils.MetaTenant,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile(defaultTenant, true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
},
|
||||
{
|
||||
FieldName: "ReqType",
|
||||
FieldName: utils.RequestType,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile("*prepaid", true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
@@ -143,11 +140,11 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
{
|
||||
FieldName: utils.MetaTenant,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile(defaultTenant, true, utils.INFIELD_SEP),
|
||||
Substitute: config.NewRSRParsersMustCompile(usrTenant, true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
},
|
||||
{
|
||||
FieldName: "ReqType",
|
||||
FieldName: utils.RequestType,
|
||||
Initial: utils.META_ANY,
|
||||
Substitute: config.NewRSRParsersMustCompile("*prepaid", true, utils.INFIELD_SEP),
|
||||
Append: true,
|
||||
@@ -166,8 +163,7 @@ func TestUserProfile2attributeProfile(t *testing.T) {
|
||||
return rply.Attributes[i].FieldName < rply.Attributes[j].FieldName
|
||||
}) // only for test; map returns random keys
|
||||
if !reflect.DeepEqual(expected[i], rply) {
|
||||
t.Errorf("For %v expected: %s ,recived: %s ", i, utils.ToJSON(expected[i]), utils.ToJSON(rply))
|
||||
t.Errorf("For %v expected: %s ,received: %s ", i, utils.ToJSON(expected[i]), utils.ToJSON(rply))
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user