From 453e005cfa1976f21e2e343ae9d879227a65e045 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 27 May 2021 09:19:54 +0300 Subject: [PATCH] Updated routes tests --- engine/z_filterindexer_it_test.go | 8 ++++---- engine/z_loader_it_test.go | 2 +- engine/z_onstor_it_test.go | 20 ++++++++++---------- migrator/routes_it_test.go | 11 ++++++----- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/engine/z_filterindexer_it_test.go b/engine/z_filterindexer_it_test.go index 4c1901b33..a0b15d343 100644 --- a/engine/z_filterindexer_it_test.go +++ b/engine/z_filterindexer_it_test.go @@ -1837,10 +1837,10 @@ func testITTestIndexingWithEmptyFltrID2(t *testing.T) { Weight: 20, } - if err := dataManager.SetRouteProfile(splProfile, true); err != nil { + if err := dataManager.SetRouteProfile(context.TODO(), splProfile, true); err != nil { t.Error(err) } - if err := dataManager.SetRouteProfile(splProfile2, true); err != nil { + if err := dataManager.SetRouteProfile(context.TODO(), splProfile2, true); err != nil { t.Error(err) } eIdxes := map[string]utils.StringSet{ @@ -1893,10 +1893,10 @@ func testITTestIndexingWithEmptyFltrID2(t *testing.T) { splProfile.FilterIDs = []string{"FIRST", "*prefix:~*req.Account:123"} splProfile2.ID = "SPL_WITH_FILTER2" splProfile2.FilterIDs = []string{"FIRST"} - if err := dataManager.SetRouteProfile(splProfile, true); err != nil { + if err := dataManager.SetRouteProfile(context.TODO(), splProfile, true); err != nil { t.Error(err) } - if err := dataManager.SetRouteProfile(splProfile2, true); err != nil { + if err := dataManager.SetRouteProfile(context.TODO(), splProfile2, true); err != nil { t.Error(err) } expIdx := map[string]utils.StringSet{ diff --git a/engine/z_loader_it_test.go b/engine/z_loader_it_test.go index 813204ada..6666ab223 100644 --- a/engine/z_loader_it_test.go +++ b/engine/z_loader_it_test.go @@ -290,7 +290,7 @@ func testLoaderITWriteToDatabase(t *testing.T) { } for tenatid, th := range loader.routeProfiles { - rcv, err := loader.dm.GetRouteProfile(tenatid.Tenant, tenatid.ID, false, false, utils.NonTransactional) + rcv, err := loader.dm.GetRouteProfile(context.TODO(), tenatid.Tenant, tenatid.ID, false, false, utils.NonTransactional) if err != nil { t.Errorf("Failed GetRouteProfile, tenant: %s, id: %s, error: %s ", th.Tenant, th.ID, err.Error()) } diff --git a/engine/z_onstor_it_test.go b/engine/z_onstor_it_test.go index a3d21cd38..da799a200 100644 --- a/engine/z_onstor_it_test.go +++ b/engine/z_onstor_it_test.go @@ -679,22 +679,22 @@ func testOnStorITRouteProfile(t *testing.T) { }, Weight: 20, } - if _, rcvErr := onStor.GetRouteProfile("cgrates.org", "SPRF_1", + if _, rcvErr := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1", true, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound { t.Error(rcvErr) } - if err := onStor.SetRouteProfile(splProfile, false); err != nil { + if err := onStor.SetRouteProfile(context.TODO(), splProfile, false); err != nil { t.Error(err) } //get from cache - if rcv, err := onStor.GetRouteProfile("cgrates.org", "SPRF_1", + if rcv, err := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1", true, false, utils.NonTransactional); err != nil { t.Error(err) } else if !(reflect.DeepEqual(splProfile, rcv)) { t.Errorf("Expecting: %v, received: %v", splProfile, rcv) } //get from database - if rcv, err := onStor.GetRouteProfile("cgrates.org", "SPRF_1", + if rcv, err := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1", false, false, utils.NonTransactional); err != nil { t.Error(err) } else if !(reflect.DeepEqual(splProfile, rcv)) { @@ -729,35 +729,35 @@ func testOnStorITRouteProfile(t *testing.T) { RouteParameters: "param2", }, } - if err := onStor.SetRouteProfile(splProfile, false); err != nil { + if err := onStor.SetRouteProfile(context.TODO(), splProfile, false); err != nil { t.Error(err) } //get from cache - if rcv, err := onStor.GetRouteProfile("cgrates.org", "SPRF_1", + if rcv, err := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1", true, false, utils.NonTransactional); err != nil { t.Error(err) } else if !(reflect.DeepEqual(splProfile, rcv)) { t.Errorf("Expecting: %v, received: %v", splProfile, rcv) } //get from database - if rcv, err := onStor.GetRouteProfile("cgrates.org", "SPRF_1", + if rcv, err := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1", false, false, utils.NonTransactional); err != nil { t.Error(err) } else if !(reflect.DeepEqual(splProfile, rcv)) { t.Errorf("Expecting: %v, received: %v", splProfile, rcv) } - if err := onStor.RemoveRouteProfile(splProfile.Tenant, splProfile.ID, + if err := onStor.RemoveRouteProfile(context.TODO(), splProfile.Tenant, splProfile.ID, false); err != nil { t.Error(err) } //check cache if removed - if _, rcvErr := onStor.GetRouteProfile("cgrates.org", "SPRF_1", + if _, rcvErr := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1", true, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound { t.Error(rcvErr) } //check database if removed - if _, rcvErr := onStor.GetRouteProfile("cgrates.org", "SPRF_1", + if _, rcvErr := onStor.GetRouteProfile(context.TODO(), "cgrates.org", "SPRF_1", false, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound { t.Error(rcvErr) } diff --git a/migrator/routes_it_test.go b/migrator/routes_it_test.go index 5d50e7747..9c6b9710f 100644 --- a/migrator/routes_it_test.go +++ b/migrator/routes_it_test.go @@ -26,6 +26,7 @@ import ( "reflect" "testing" + "github.com/cgrates/birpc/context" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" @@ -196,10 +197,10 @@ func testSupITMigrateAndMove(t *testing.T) { switch supAction { case utils.Migrate: // for the momment only one version of rating plans exists case utils.Move: - if err := supMigrator.dmIN.DataManager().SetRouteProfile(supPrfl, true); err != nil { + if err := supMigrator.dmIN.DataManager().SetRouteProfile(context.TODO(), supPrfl, true); err != nil { t.Error(err) } - if _, err := supMigrator.dmIN.DataManager().GetRouteProfile("cgrates.org", "SUP1", false, false, utils.NonTransactional); err != nil { + if _, err := supMigrator.dmIN.DataManager().GetRouteProfile(context.TODO(), "cgrates.org", "SUP1", false, false, utils.NonTransactional); err != nil { t.Error(err) } currentVersion := engine.CurrentDataDBVersions() @@ -208,7 +209,7 @@ func testSupITMigrateAndMove(t *testing.T) { t.Error("Error when setting version for Suppliers ", err.Error()) } - _, err = supMigrator.dmOut.DataManager().GetRouteProfile("cgrates.org", "SUP1", false, false, utils.NonTransactional) + _, err = supMigrator.dmOut.DataManager().GetRouteProfile(context.TODO(), "cgrates.org", "SUP1", false, false, utils.NonTransactional) if err != utils.ErrNotFound { t.Error(err) } @@ -217,14 +218,14 @@ func testSupITMigrateAndMove(t *testing.T) { if err != nil { t.Error("Error when migrating Suppliers ", err.Error()) } - result, err := supMigrator.dmOut.DataManager().GetRouteProfile("cgrates.org", "SUP1", false, false, utils.NonTransactional) + result, err := supMigrator.dmOut.DataManager().GetRouteProfile(context.TODO(), "cgrates.org", "SUP1", false, false, utils.NonTransactional) if err != nil { t.Fatal(err) } if !reflect.DeepEqual(result, supPrfl) { t.Errorf("Expecting: %+v, received: %+v", supPrfl, result) } - result, err = supMigrator.dmIN.DataManager().GetRouteProfile("cgrates.org", "SUP1", false, false, utils.NonTransactional) + result, err = supMigrator.dmIN.DataManager().GetRouteProfile(context.TODO(), "cgrates.org", "SUP1", false, false, utils.NonTransactional) if err != utils.ErrNotFound { t.Error(err) } else if supMigrator.stats[utils.Routes] != 1 {