Updated migrator redis storage

This commit is contained in:
Tripon Alexandru-Ionut
2019-05-29 15:35:09 +03:00
committed by Dan Christian Bogos
parent f4e0685659
commit 325af1d4b6
2 changed files with 37 additions and 10 deletions

View File

@@ -44,6 +44,8 @@ var (
var sTestsAttrIT = []func(t *testing.T){
testAttrITConnect,
testAttrITFlush,
testAttrITMigrateOnlyVersion,
testAttrITFlush,
testAttrITMigrateAndMove,
testAttrITFlush,
testAttrITMigrateV2,
@@ -225,6 +227,31 @@ func testAttrITFlush(t *testing.T) {
}
}
func testAttrITMigrateOnlyVersion(t *testing.T) {
currentVersion := engine.Versions{utils.Attributes: 1}
err := attrMigrator.dmIN.DataManager().DataDB().SetVersions(currentVersion, false)
if err != nil {
t.Error("Error when setting version for Attributes ", err.Error())
}
if vrs, err := attrMigrator.dmIN.DataManager().DataDB().GetVersions(""); err != nil {
t.Error(err)
} else if vrs[utils.Attributes] != 1 {
t.Errorf("Unexpected version returned: %d", vrs[utils.Attributes])
}
err, _ = attrMigrator.Migrate([]string{utils.MetaAttributes})
if err != nil {
t.Error("Error when migrating Attributes ", err.Error())
}
if vrs, err := attrMigrator.dmOut.DataManager().DataDB().GetVersions(""); err != nil {
t.Error(err)
} else if vrs[utils.Attributes] != 4 {
t.Errorf("Unexpected version returned: %d", vrs[utils.Attributes])
}
}
func testAttrITMigrateAndMove(t *testing.T) {
mapSubstitutes := make(map[string]map[string]*v1Attribute)
mapSubstitutes["FL1"] = make(map[string]*v1Attribute)

View File

@@ -157,7 +157,7 @@ func (v1rs *redisMigrator) getV1ActionPlans() (v1aps *v1ActionPlans, err error)
if err != nil {
return
} else if len(v1rs.dataKeys) == 0 {
return nil, utils.ErrNotFound
return nil, utils.ErrNoMoreData
}
v1rs.qryIdx = utils.IntPointer(0)
}
@@ -198,7 +198,7 @@ func (v1rs *redisMigrator) getV1Actions() (v1acs *v1Actions, err error) {
if err != nil {
return
} else if len(v1rs.dataKeys) == 0 {
return nil, utils.ErrNotFound
return nil, utils.ErrNoMoreData
}
v1rs.qryIdx = utils.IntPointer(0)
}
@@ -239,7 +239,7 @@ func (v1rs *redisMigrator) getV1ActionTriggers() (v1acts *v1ActionTriggers, err
if err != nil {
return
} else if len(v1rs.dataKeys) == 0 {
return nil, utils.ErrNotFound
return nil, utils.ErrNoMoreData
}
v1rs.qryIdx = utils.IntPointer(0)
}
@@ -280,7 +280,7 @@ func (v1rs *redisMigrator) getV1SharedGroup() (v1sg *v1SharedGroup, err error) {
if err != nil {
return
} else if len(v1rs.dataKeys) == 0 {
return nil, utils.ErrNotFound
return nil, utils.ErrNoMoreData
}
v1rs.qryIdx = utils.IntPointer(0)
}
@@ -321,7 +321,7 @@ func (v1rs *redisMigrator) getV1Stats() (v1st *v1Stat, err error) {
if err != nil {
return
} else if len(v1rs.dataKeys) == 0 {
return nil, utils.ErrNotFound
return nil, utils.ErrNoMoreData
}
v1rs.qryIdx = utils.IntPointer(0)
}
@@ -362,7 +362,7 @@ func (v1rs *redisMigrator) getV2ActionTrigger() (v2at *v2ActionTrigger, err erro
if err != nil {
return
} else if len(v1rs.dataKeys) == 0 {
return nil, utils.ErrNotFound
return nil, utils.ErrNoMoreData
}
v1rs.qryIdx = utils.IntPointer(0)
}
@@ -404,7 +404,7 @@ func (v1rs *redisMigrator) getV1AttributeProfile() (v1attrPrf *v1AttributeProfil
if err != nil {
return
} else if len(v1rs.dataKeys) == 0 {
return nil, utils.ErrNotFound
return nil, utils.ErrNoMoreData
}
v1rs.qryIdx = utils.IntPointer(0)
}
@@ -446,7 +446,7 @@ func (v1rs *redisMigrator) getV2ThresholdProfile() (v2T *v2Threshold, err error)
if err != nil {
return
} else if len(v1rs.dataKeys) == 0 {
return nil, utils.ErrNotFound
return nil, utils.ErrNoMoreData
}
v1rs.qryIdx = utils.IntPointer(0)
}
@@ -668,7 +668,7 @@ func (v1rs *redisMigrator) getV2AttributeProfile() (v2attrPrf *v2AttributeProfil
if err != nil {
return
} else if len(v1rs.dataKeys) == 0 {
return nil, utils.ErrNotFound
return nil, utils.ErrNoMoreData
}
v1rs.qryIdx = utils.IntPointer(0)
}
@@ -716,7 +716,7 @@ func (v1rs *redisMigrator) getV3AttributeProfile() (v3attrPrf *v3AttributeProfil
if err != nil {
return
} else if len(v1rs.dataKeys) == 0 {
return nil, utils.ErrNotFound
return nil, utils.ErrNoMoreData
}
v1rs.qryIdx = utils.IntPointer(0)
}