adding the db path from the stordb type

This commit is contained in:
gezimbll
2023-03-03 08:43:59 -05:00
committed by Dan Christian Bogos
parent 7dcbd09a1f
commit df09129ad5
21 changed files with 42 additions and 37 deletions

View File

@@ -26,6 +26,7 @@ import (
"log"
"path"
"reflect"
"strings"
"testing"
"time"
@@ -42,6 +43,9 @@ var (
accMigrator *Migrator
accAction string
dataDir = flag.String("data_dir", "/usr/share/cgrates", "CGR data dir path here")
dbPath = func(dbType string) string {
return strings.TrimPrefix(dbType, "*")
}
sTestsAccIT = []func(t *testing.T){
testAccITConnect,
testAccITFlush,

View File

@@ -104,7 +104,7 @@ func testCdrITConnect(t *testing.T) {
func testCdrITFlush(t *testing.T) {
if err := cdrMigrator.storDBOut.StorDB().Flush(
path.Join(cdrCfgIn.DataFolderPath, "storage", cdrCfgIn.StorDbCfg().Type)); err != nil {
path.Join(cdrCfgIn.DataFolderPath, "storage", dbPath(cdrCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -142,7 +142,7 @@ func testSessionCostITRename(t *testing.T) {
func testSessionCostITFlush(t *testing.T) {
if err := sCostMigrator.storDBOut.StorDB().Flush(
path.Join(sCostCfgIn.DataFolderPath, "storage", sCostCfgIn.StorDbCfg().Type)); err != nil {
path.Join(sCostCfgIn.DataFolderPath, "storage", dbPath(sCostCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -95,13 +95,14 @@ func testTpAccActITConnect(t *testing.T) {
}
func testTpAccActITFlush(t *testing.T) {
if err := tpAccActMigrator.storDBIn.StorDB().Flush(
path.Join(tpAccActCfgIn.DataFolderPath, "storage", tpAccActCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpAccActCfgIn.DataFolderPath, "storage", dbPath(tpAccActCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpAccActMigrator.storDBOut.StorDB().Flush(
path.Join(tpAccActCfgOut.DataFolderPath, "storage", tpAccActCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpAccActCfgOut.DataFolderPath, "storage", dbPath(tpAccActCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -96,12 +96,12 @@ func testTpActPlnITConnect(t *testing.T) {
func testTpActPlnITFlush(t *testing.T) {
if err := tpActPlnMigrator.storDBIn.StorDB().Flush(
path.Join(tpActPlnCfgIn.DataFolderPath, "storage", tpActPlnCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpActPlnCfgIn.DataFolderPath, "storage", dbPath(tpActPlnCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpActPlnMigrator.storDBOut.StorDB().Flush(
path.Join(tpActPlnCfgOut.DataFolderPath, "storage", tpActPlnCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpActPlnCfgOut.DataFolderPath, "storage", dbPath(tpActPlnCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -96,12 +96,12 @@ func testTpActTrgITConnect(t *testing.T) {
func testTpActTrgITFlush(t *testing.T) {
if err := tpActTrgMigrator.storDBIn.StorDB().Flush(
path.Join(tpActTrgCfgIn.DataFolderPath, "storage", tpActTrgCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpActTrgCfgIn.DataFolderPath, "storage", dbPath(tpActTrgCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpActTrgMigrator.storDBOut.StorDB().Flush(
path.Join(tpActTrgCfgOut.DataFolderPath, "storage", tpActTrgCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpActTrgCfgOut.DataFolderPath, "storage", dbPath(tpActTrgCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -96,12 +96,12 @@ func testTpActITConnect(t *testing.T) {
func testTpActITFlush(t *testing.T) {
if err := tpActMigrator.storDBIn.StorDB().Flush(
path.Join(tpActCfgIn.DataFolderPath, "storage", tpActCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpActCfgIn.DataFolderPath, "storage", dbPath(tpActCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpActMigrator.storDBOut.StorDB().Flush(
path.Join(tpActCfgOut.DataFolderPath, "storage", tpActCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpActCfgOut.DataFolderPath, "storage", dbPath(tpActCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -96,12 +96,12 @@ func testTpDstRtITConnect(t *testing.T) {
func testTpDstRtITFlush(t *testing.T) {
if err := tpDstRtMigrator.storDBIn.StorDB().Flush(
path.Join(tpDstRtCfgIn.DataFolderPath, "storage", tpDstRtCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpDstRtCfgIn.DataFolderPath, "storage", dbPath(tpDstRtCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpDstRtMigrator.storDBOut.StorDB().Flush(
path.Join(tpDstRtCfgOut.DataFolderPath, "storage", tpDstRtCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpDstRtCfgOut.DataFolderPath, "storage", dbPath(tpDstRtCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -96,12 +96,12 @@ func testTpDstITConnect(t *testing.T) {
func testTpDstITFlush(t *testing.T) {
if err := tpDstMigrator.storDBIn.StorDB().Flush(
path.Join(tpDstCfgIn.DataFolderPath, "storage", tpDstCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpDstCfgIn.DataFolderPath, "storage", dbPath(tpDstCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpDstMigrator.storDBOut.StorDB().Flush(
path.Join(tpDstCfgOut.DataFolderPath, "storage", tpDstCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpDstCfgOut.DataFolderPath, "storage", dbPath(tpDstCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -97,13 +97,13 @@ func testTpDispITConnect(t *testing.T) {
func testTpDispITFlush(t *testing.T) {
if err := tpDispMigrator.storDBIn.StorDB().Flush(
path.Join(tpDispCfgIn.DataFolderPath, "storage",
tpDispCfgIn.StorDbCfg().Type)); err != nil {
dbPath(tpDispCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpDispMigrator.storDBOut.StorDB().Flush(
path.Join(tpDispCfgOut.DataFolderPath, "storage",
tpDispCfgOut.StorDbCfg().Type)); err != nil {
dbPath(tpDispCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -96,12 +96,12 @@ func testTpFltrITConnect(t *testing.T) {
func testTpFltrITFlush(t *testing.T) {
if err := tpFltrMigrator.storDBIn.StorDB().Flush(
path.Join(tpFltrCfgIn.DataFolderPath, "storage", tpFltrCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpFltrCfgIn.DataFolderPath, "storage", dbPath(tpFltrCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpFltrMigrator.storDBOut.StorDB().Flush(
path.Join(tpFltrCfgOut.DataFolderPath, "storage", tpFltrCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpFltrCfgOut.DataFolderPath, "storage", dbPath(tpFltrCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -96,12 +96,12 @@ func testTpRatesITConnect(t *testing.T) {
func testTpRatesITFlush(t *testing.T) {
if err := tpRatesMigrator.storDBIn.StorDB().Flush(
path.Join(tpRatesCfgIn.DataFolderPath, "storage", tpRatesCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpRatesCfgIn.DataFolderPath, "storage", dbPath(tpRatesCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpRatesMigrator.storDBOut.StorDB().Flush(
path.Join(tpRatesCfgOut.DataFolderPath, "storage", tpRatesCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpRatesCfgOut.DataFolderPath, "storage", dbPath(tpRatesCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -96,12 +96,12 @@ func testTpRatPlnITConnect(t *testing.T) {
func testTpRatPlnITFlush(t *testing.T) {
if err := tpRatPlnMigrator.storDBIn.StorDB().Flush(
path.Join(tpRatPlnCfgIn.DataFolderPath, "storage", tpRatPlnCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpRatPlnCfgIn.DataFolderPath, "storage", dbPath(tpRatPlnCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpRatPlnMigrator.storDBOut.StorDB().Flush(
path.Join(tpRatPlnCfgOut.DataFolderPath, "storage", tpRatPlnCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpRatPlnCfgOut.DataFolderPath, "storage", dbPath(tpRatPlnCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -96,12 +96,12 @@ func testTpRatPrfITConnect(t *testing.T) {
func testTpRatPrfITFlush(t *testing.T) {
if err := tpRatPrfMigrator.storDBIn.StorDB().Flush(
path.Join(tpRatPrfCfgIn.DataFolderPath, "storage", tpRatPrfCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpRatPrfCfgIn.DataFolderPath, "storage", dbPath(tpRatPrfCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpRatPrfMigrator.storDBOut.StorDB().Flush(
path.Join(tpRatPrfCfgOut.DataFolderPath, "storage", tpRatPrfCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpRatPrfCfgOut.DataFolderPath, "storage", dbPath(tpRatPrfCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -98,12 +98,12 @@ func testTpResITConnect(t *testing.T) {
func testTpResITFlush(t *testing.T) {
if err := tpResMigrator.storDBIn.StorDB().Flush(
path.Join(tpResCfgIn.DataFolderPath, "storage", tpResCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpResCfgIn.DataFolderPath, "storage", dbPath(tpResCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpResMigrator.storDBOut.StorDB().Flush(
path.Join(tpResCfgOut.DataFolderPath, "storage", tpResCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpResCfgOut.DataFolderPath, "storage", dbPath(tpResCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -96,12 +96,12 @@ func testTpShrGrITConnect(t *testing.T) {
func testTpShrGrITFlush(t *testing.T) {
if err := tpShrGrMigrator.storDBIn.StorDB().Flush(
path.Join(tpShrGrCfgIn.DataFolderPath, "storage", tpShrGrCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpShrGrCfgIn.DataFolderPath, "storage", dbPath(tpShrGrCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpShrGrMigrator.storDBOut.StorDB().Flush(
path.Join(tpShrGrCfgOut.DataFolderPath, "storage", tpShrGrCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpShrGrCfgOut.DataFolderPath, "storage", dbPath(tpShrGrCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -96,12 +96,12 @@ func testTpStatsITConnect(t *testing.T) {
func testTpStatsITFlush(t *testing.T) {
if err := tpStatsMigrator.storDBIn.StorDB().Flush(
path.Join(tpStatsCfgIn.DataFolderPath, "storage", tpStatsCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpStatsCfgIn.DataFolderPath, "storage", dbPath(tpStatsCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpStatsMigrator.storDBOut.StorDB().Flush(
path.Join(tpStatsCfgOut.DataFolderPath, "storage", tpStatsCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpStatsCfgOut.DataFolderPath, "storage", dbPath(tpStatsCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -97,12 +97,12 @@ func testTpSplITConnect(t *testing.T) {
func testTpSplITFlush(t *testing.T) {
if err := tpSplMigrator.storDBIn.StorDB().Flush(
path.Join(tpSplCfgIn.DataFolderPath, "storage", tpSplCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpSplCfgIn.DataFolderPath, "storage", dbPath(tpSplCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpSplMigrator.storDBOut.StorDB().Flush(
path.Join(tpSplCfgOut.DataFolderPath, "storage", tpSplCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpSplCfgOut.DataFolderPath, "storage", dbPath(tpSplCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -97,12 +97,12 @@ func testTpTresITConnect(t *testing.T) {
func testTpTresITFlush(t *testing.T) {
if err := tpTresMigrator.storDBIn.StorDB().Flush(
path.Join(tpTresCfgIn.DataFolderPath, "storage", tpTresCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpTresCfgIn.DataFolderPath, "storage", dbPath(tpTresCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpTresMigrator.storDBOut.StorDB().Flush(
path.Join(tpTresCfgOut.DataFolderPath, "storage", tpTresCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpTresCfgOut.DataFolderPath, "storage", dbPath(tpTresCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -96,12 +96,12 @@ func testTpTimITConnect(t *testing.T) {
func testTpTimITFlush(t *testing.T) {
if err := tpTimMigrator.storDBIn.StorDB().Flush(
path.Join(tpTimCfgIn.DataFolderPath, "storage", tpTimCfgIn.StorDbCfg().Type)); err != nil {
path.Join(tpTimCfgIn.DataFolderPath, "storage", dbPath(tpTimCfgIn.StorDbCfg().Type))); err != nil {
t.Error(err)
}
if err := tpTimMigrator.storDBOut.StorDB().Flush(
path.Join(tpTimCfgOut.DataFolderPath, "storage", tpTimCfgOut.StorDbCfg().Type)); err != nil {
path.Join(tpTimCfgOut.DataFolderPath, "storage", dbPath(tpTimCfgOut.StorDbCfg().Type))); err != nil {
t.Error(err)
}
}

View File

@@ -103,7 +103,7 @@ func testVrsITConnect(t *testing.T) {
func testVrsITFlush(t *testing.T) {
vrsMigrator.dmOut.DataManager().DataDB().Flush("")
vrsMigrator.storDBOut.StorDB().Flush((path.Join(vrsCfg.DataFolderPath, "storage",
vrsCfg.StorDbCfg().Type)))
dbPath(vrsCfg.StorDbCfg().Type))))
if vrs, err := vrsMigrator.dmOut.DataManager().DataDB().GetVersions(""); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Errorf("Expected err=%s recived err=%v and rply=%s", utils.ErrNotFound.Error(), err, utils.ToJSON(vrs))
}