diff --git a/apier/v1/tproutes_it_test.go b/apier/v1/tproutes_it_test.go index 187e6bb46..0e9ff1191 100644 --- a/apier/v1/tproutes_it_test.go +++ b/apier/v1/tproutes_it_test.go @@ -35,110 +35,110 @@ import ( ) var ( - tpSplPrfCfgPath string - tpSplPrfCfg *config.CGRConfig - tpSplPrfRPC *rpc.Client - tpSplPrfDataDire = "/usr/share/cgrates" - tpSplPr *utils.TPRouteProfile - tpSplPrfDelay int - tpSplPrfConfigDIR string //run tests for specific configuration + tpRouteCfgPath string + tpRouteCfg *config.CGRConfig + tpRouteRPC *rpc.Client + tpRouteDataDire = "/usr/share/cgrates" + tpRoutePrf *utils.TPRouteProfile + tpRouteDelay int + tpRouteConfigDIR string //run tests for specific configuration ) -var sTestsTPSplPrf = []func(t *testing.T){ - testTPSplPrfInitCfg, - testTPSplPrfResetStorDb, - testTPSplPrfStartEngine, - testTPSplPrfRPCConn, - testTPSplPrfGetTPSplPrfBeforeSet, - testTPSplPrfSetTPSplPrf, - testTPSplPrfGetTPSplPrfAfterSet, - testTPSplPrfGetTPSplPrfIDs, - testTPSplPrfUpdateTPSplPrf, - testTPSplPrfGetTPSplPrfAfterUpdate, - testTPSplPrfRemTPSplPrf, - testTPSplPrfGetTPSplPrfAfterRemove, - testTPSplPrfKillEngine, +var sTestsTPRoute = []func(t *testing.T){ + testTPRouteInitCfg, + testTPRouteResetStorDb, + testTPRouteStartEngine, + testTPRouteRPCConn, + testTPRouteGetTPRouteBeforeSet, + testTPRouteSetTPRoute, + testTPRouteGetTPRouteAfterSet, + testTPRouteGetTPRouteIDs, + testTPRouteUpdateTPRoute, + testTPRouteGetTPRouteAfterUpdate, + testTPRouteRemTPRoute, + testTPRouteGetTPRouteAfterRemove, + testTPRouteKillEngine, } //Test start here -func TestTPSplPrfIT(t *testing.T) { +func TestTPRouteIT(t *testing.T) { switch *dbType { case utils.MetaInternal: - tpSplPrfConfigDIR = "tutinternal" + tpRouteConfigDIR = "tutinternal" case utils.MetaMySQL: - tpSplPrfConfigDIR = "tutmysql" + tpRouteConfigDIR = "tutmysql" case utils.MetaMongo: - tpSplPrfConfigDIR = "tutmongo" + tpRouteConfigDIR = "tutmongo" case utils.MetaPostgres: t.SkipNow() default: t.Fatal("Unknown Database type") } - for _, stest := range sTestsTPSplPrf { - t.Run(tpSplPrfConfigDIR, stest) + for _, stest := range sTestsTPRoute { + t.Run(tpRouteConfigDIR, stest) } } -func testTPSplPrfInitCfg(t *testing.T) { +func testTPRouteInitCfg(t *testing.T) { var err error - tpSplPrfCfgPath = path.Join(tpSplPrfDataDire, "conf", "samples", tpSplPrfConfigDIR) - tpSplPrfCfg, err = config.NewCGRConfigFromPath(tpSplPrfCfgPath) + tpRouteCfgPath = path.Join(tpRouteDataDire, "conf", "samples", tpRouteConfigDIR) + tpRouteCfg, err = config.NewCGRConfigFromPath(tpRouteCfgPath) if err != nil { t.Error(err) } - tpSplPrfCfg.DataFolderPath = tpSplPrfDataDire // Share DataFolderPath through config towards StoreDb for Flush() - config.SetCgrConfig(tpSplPrfCfg) - tpSplPrfDelay = 1000 + tpRouteCfg.DataFolderPath = tpRouteDataDire // Share DataFolderPath through config towards StoreDb for Flush() + config.SetCgrConfig(tpRouteCfg) + tpRouteDelay = 1000 } // Wipe out the cdr database -func testTPSplPrfResetStorDb(t *testing.T) { - if err := engine.InitStorDb(tpSplPrfCfg); err != nil { +func testTPRouteResetStorDb(t *testing.T) { + if err := engine.InitStorDb(tpRouteCfg); err != nil { t.Fatal(err) } } // Start CGR Engine -func testTPSplPrfStartEngine(t *testing.T) { - if _, err := engine.StopStartEngine(tpSplPrfCfgPath, tpSplPrfDelay); err != nil { +func testTPRouteStartEngine(t *testing.T) { + if _, err := engine.StopStartEngine(tpRouteCfgPath, tpRouteDelay); err != nil { t.Fatal(err) } } // Connect rpc client to rater -func testTPSplPrfRPCConn(t *testing.T) { +func testTPRouteRPCConn(t *testing.T) { var err error - tpSplPrfRPC, err = jsonrpc.Dial(utils.TCP, tpSplPrfCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed + tpRouteRPC, err = jsonrpc.Dial(utils.TCP, tpRouteCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed if err != nil { t.Fatal(err) } } -func testTPSplPrfGetTPSplPrfBeforeSet(t *testing.T) { +func testTPRouteGetTPRouteBeforeSet(t *testing.T) { var reply *utils.TPRoute - if err := tpSplPrfRPC.Call(utils.APIerSv1GetTPRouteProfile, - &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "SUPL_1"}, + if err := tpRouteRPC.Call(utils.APIerSv1GetTPRouteProfile, + &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "RoutePrf"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) } } -func testTPSplPrfSetTPSplPrf(t *testing.T) { - tpSplPr = &utils.TPRouteProfile{ +func testTPRouteSetTPRoute(t *testing.T) { + tpRoutePrf = &utils.TPRouteProfile{ TPid: "TP1", Tenant: "cgrates.org", - ID: "SUPL_1", + ID: "RoutePrf", FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"}, ActivationInterval: &utils.TPActivationInterval{ ActivationTime: "2014-07-29T15:00:00Z", ExpiryTime: "", }, - Sorting: "*lowest_cost", + Sorting: "*lc", SortingParameters: []string{}, Routes: []*utils.TPRoute{ &utils.TPRoute{ - ID: "supplier1", + ID: "route1", FilterIDs: []string{"FLTR_1"}, AccountIDs: []string{"Acc1", "Acc2"}, RatingPlanIDs: []string{"RPL_1"}, @@ -151,32 +151,32 @@ func testTPSplPrfSetTPSplPrf(t *testing.T) { }, Weight: 20, } - sort.Strings(tpSplPr.FilterIDs) + sort.Strings(tpRoutePrf.FilterIDs) var result string - if err := tpSplPrfRPC.Call(utils.APIerSv1SetTPRouteProfile, - tpSplPr, &result); err != nil { + if err := tpRouteRPC.Call(utils.APIerSv1SetTPRouteProfile, + tpRoutePrf, &result); err != nil { t.Error(err) } else if result != utils.OK { t.Error("Unexpected reply returned", result) } } -func testTPSplPrfGetTPSplPrfAfterSet(t *testing.T) { +func testTPRouteGetTPRouteAfterSet(t *testing.T) { var reply *utils.TPRouteProfile - if err := tpSplPrfRPC.Call(utils.APIerSv1GetTPRouteProfile, - &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "SUPL_1"}, &reply); err != nil { + if err := tpRouteRPC.Call(utils.APIerSv1GetTPRouteProfile, + &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "RoutePrf"}, &reply); err != nil { t.Fatal(err) } sort.Strings(reply.FilterIDs) - if !reflect.DeepEqual(tpSplPr, reply) { - t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(tpSplPr), utils.ToJSON(reply)) + if !reflect.DeepEqual(tpRoutePrf, reply) { + t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(tpRoutePrf), utils.ToJSON(reply)) } } -func testTPSplPrfGetTPSplPrfIDs(t *testing.T) { +func testTPRouteGetTPRouteIDs(t *testing.T) { var result []string - expectedTPID := []string{"cgrates.org:SUPL_1"} - if err := tpSplPrfRPC.Call(utils.APIerSv1GetTPRouteProfileIDs, + expectedTPID := []string{"cgrates.org:RoutePrf"} + if err := tpRouteRPC.Call(utils.APIerSv1GetTPRouteProfileIDs, &AttrGetTPRouteProfileIDs{TPid: "TP1"}, &result); err != nil { t.Error(err) } else if !reflect.DeepEqual(expectedTPID, result) { @@ -185,10 +185,10 @@ func testTPSplPrfGetTPSplPrfIDs(t *testing.T) { } -func testTPSplPrfUpdateTPSplPrf(t *testing.T) { - tpSplPr.Routes = []*utils.TPRoute{ +func testTPRouteUpdateTPRoute(t *testing.T) { + tpRoutePrf.Routes = []*utils.TPRoute{ &utils.TPRoute{ - ID: "supplier1", + ID: "route1", FilterIDs: []string{"FLTR_1"}, AccountIDs: []string{"Acc1", "Acc2"}, RatingPlanIDs: []string{"RPL_1"}, @@ -199,7 +199,7 @@ func testTPSplPrfUpdateTPSplPrf(t *testing.T) { RouteParameters: "SortingParam1", }, &utils.TPRoute{ - ID: "supplier2", + ID: "route2", FilterIDs: []string{"FLTR_1"}, AccountIDs: []string{"Acc3"}, RatingPlanIDs: []string{"RPL_1"}, @@ -211,36 +211,36 @@ func testTPSplPrfUpdateTPSplPrf(t *testing.T) { }, } var result string - if err := tpSplPrfRPC.Call(utils.APIerSv1SetTPRouteProfile, - tpSplPr, &result); err != nil { + if err := tpRouteRPC.Call(utils.APIerSv1SetTPRouteProfile, + tpRoutePrf, &result); err != nil { t.Error(err) } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - sort.Slice(tpSplPr.Routes, func(i, j int) bool { - return strings.Compare(tpSplPr.Routes[i].ID, tpSplPr.Routes[j].ID) == -1 + sort.Slice(tpRoutePrf.Routes, func(i, j int) bool { + return strings.Compare(tpRoutePrf.Routes[i].ID, tpRoutePrf.Routes[j].ID) == -1 }) } -func testTPSplPrfGetTPSplPrfAfterUpdate(t *testing.T) { +func testTPRouteGetTPRouteAfterUpdate(t *testing.T) { var reply *utils.TPRouteProfile - if err := tpSplPrfRPC.Call(utils.APIerSv1GetTPRouteProfile, - &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "SUPL_1"}, &reply); err != nil { + if err := tpRouteRPC.Call(utils.APIerSv1GetTPRouteProfile, + &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "RoutePrf"}, &reply); err != nil { t.Fatal(err) } sort.Strings(reply.FilterIDs) sort.Slice(reply.Routes, func(i, j int) bool { return strings.Compare(reply.Routes[i].ID, reply.Routes[j].ID) == -1 }) - if !reflect.DeepEqual(tpSplPr.Routes, reply.Routes) { - t.Errorf("Expecting: %+v,\n received: %+v", utils.ToJSON(tpSplPr), utils.ToJSON(reply)) + if !reflect.DeepEqual(tpRoutePrf.Routes, reply.Routes) { + t.Errorf("Expecting: %+v,\n received: %+v", utils.ToJSON(tpRoutePrf), utils.ToJSON(reply)) } } -func testTPSplPrfRemTPSplPrf(t *testing.T) { +func testTPRouteRemTPRoute(t *testing.T) { var resp string - if err := tpSplPrfRPC.Call(utils.APIerSv1RemoveTPRouteProfile, - &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "SUPL_1"}, + if err := tpRouteRPC.Call(utils.APIerSv1RemoveTPRouteProfile, + &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "RoutePrf"}, &resp); err != nil { t.Error(err) } else if resp != utils.OK { @@ -248,17 +248,17 @@ func testTPSplPrfRemTPSplPrf(t *testing.T) { } } -func testTPSplPrfGetTPSplPrfAfterRemove(t *testing.T) { +func testTPRouteGetTPRouteAfterRemove(t *testing.T) { var reply *utils.TPRouteProfile - if err := tpSplPrfRPC.Call(utils.APIerSv1GetTPRouteProfile, - &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "SUPL_1"}, + if err := tpRouteRPC.Call(utils.APIerSv1GetTPRouteProfile, + &utils.TPTntID{TPid: "TP1", Tenant: "cgrates.org", ID: "RoutePrf"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) } } -func testTPSplPrfKillEngine(t *testing.T) { - if err := engine.KillEngine(tpSplPrfDelay); err != nil { +func testTPRouteKillEngine(t *testing.T) { + if err := engine.KillEngine(tpRouteDelay); err != nil { t.Error(err) } } diff --git a/engine/libtest.go b/engine/libtest.go index 93beee74e..0aeda1ef8 100644 --- a/engine/libtest.go +++ b/engine/libtest.go @@ -257,10 +257,10 @@ cgrates.org,FLTR_DST_NL,*destinations,~*req.Destination,DST_NL,2014-07-29T15:00: ` RoutesCSVContent = ` #Tenant[0],ID[1],FilterIDs[2],ActivationInterval[3],Sorting[4],SortingParameters[5],RouteID[6],RouteFilterIDs[7],RouteAccountIDs[8],RouteRatingPlanIDs[9],RouteResourceIDs[10],RouteStatIDs[11],RouteWeight[12],RouteBlocker[13],RouteParameters[14],Weight[15] -cgrates.org,SPP_1,*string:~*req.Account:dan,2014-07-29T15:00:00Z,*least_cost,,supplier1,FLTR_ACNT_dan,Account1;Account1_1,RPL_1,ResGroup1,Stat1,10,true,param1,20 -cgrates.org,SPP_1,,,,,supplier1,,,RPL_2,ResGroup2,,10,,, -cgrates.org,SPP_1,,,,,supplier1,FLTR_DST_DE,Account2,RPL_3,ResGroup3,Stat2,10,,, -cgrates.org,SPP_1,,,,,supplier1,,,,ResGroup4,Stat3,10,,, +cgrates.org,RoutePrf1,*string:~*req.Account:dan,2014-07-29T15:00:00Z,*lc,,route1,FLTR_ACNT_dan,Account1;Account1_1,RPL_1,ResGroup1,Stat1,10,true,param1,20 +cgrates.org,RoutePrf1,,,,,route1,,,RPL_2,ResGroup2,,10,,, +cgrates.org,RoutePrf1,,,,,route1,FLTR_DST_DE,Account2,RPL_3,ResGroup3,Stat2,10,,, +cgrates.org,RoutePrf1,,,,,route1,,,,ResGroup4,Stat3,10,,, ` AttributesCSVContent = ` #Tenant,ID,Contexts,FilterIDs,ActivationInterval,AttributeFilterIDs,Path,Type,Value,Blocker,Weight diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index cc3e0fe3b..a09fe4d61 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -92,7 +92,7 @@ func init() { log.Print("error in LoadThresholds:", err) } if err := csvr.LoadRouteProfiles(); err != nil { - log.Print("error in LoadSupplierProfiles:", err) + log.Print("error in LoadRouteProfiles:", err) } if err := csvr.LoadAttributeProfiles(); err != nil { log.Print("error in LoadAttributeProfiles:", err) @@ -1238,16 +1238,16 @@ func TestLoadRouteProfiles(t *testing.T) { eSppProfile := &utils.TPRouteProfile{ TPid: testTPID, Tenant: "cgrates.org", - ID: "SPP_1", + ID: "RoutePrf1", FilterIDs: []string{"*string:~*req.Account:dan"}, ActivationInterval: &utils.TPActivationInterval{ ActivationTime: "2014-07-29T15:00:00Z", }, - Sorting: "*least_cost", + Sorting: utils.MetaLC, SortingParameters: []string{}, Routes: []*utils.TPRoute{ { - ID: "supplier1", + ID: "route1", FilterIDs: []string{"FLTR_ACNT_dan"}, AccountIDs: []string{"Account1", "Account1_1"}, RatingPlanIDs: []string{"RPL_1"}, @@ -1258,7 +1258,7 @@ func TestLoadRouteProfiles(t *testing.T) { RouteParameters: "param1", }, { - ID: "supplier1", + ID: "route1", RatingPlanIDs: []string{"RPL_2"}, ResourceIDs: []string{"ResGroup2", "ResGroup4"}, StatIDs: []string{"Stat3"}, @@ -1267,7 +1267,7 @@ func TestLoadRouteProfiles(t *testing.T) { RouteParameters: utils.EmptyString, }, { - ID: "supplier1", + ID: "route1", FilterIDs: []string{"FLTR_DST_DE"}, AccountIDs: []string{"Account2"}, RatingPlanIDs: []string{"RPL_3"}, @@ -1284,9 +1284,9 @@ func TestLoadRouteProfiles(t *testing.T) { return strings.Compare(eSppProfile.Routes[i].ID+strings.Join(eSppProfile.Routes[i].FilterIDs, utils.CONCATENATED_KEY_SEP), eSppProfile.Routes[j].ID+strings.Join(eSppProfile.Routes[j].FilterIDs, utils.CONCATENATED_KEY_SEP)) < 0 }) - resKey := utils.TenantID{Tenant: "cgrates.org", ID: "SPP_1"} + resKey := utils.TenantID{Tenant: "cgrates.org", ID: "RoutePrf1"} if len(csvr.routeProfiles) != 1 { - t.Errorf("Failed to load SupplierProfiles: %s", utils.ToIJSON(csvr.routeProfiles)) + t.Errorf("Failed to load RouteProfiles: %s", utils.ToIJSON(csvr.routeProfiles)) } else { rcvRoute := csvr.routeProfiles[resKey] if rcvRoute == nil { diff --git a/engine/routes_test.go b/engine/routes_test.go index 9c8daade1..23f018f55 100644 --- a/engine/routes_test.go +++ b/engine/routes_test.go @@ -28,13 +28,13 @@ import ( var ( expTimeRoutes = time.Now().Add(time.Duration(20 * time.Minute)) - splService *RouteService + routeService *RouteService dmSPP *DataManager sppTest = RouteProfiles{ &RouteProfile{ Tenant: "cgrates.org", ID: "RouteProfile1", - FilterIDs: []string{"FLTR_SUPP_1"}, + FilterIDs: []string{"FLTR_RPP_1"}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), ExpiryTime: expTimeRoutes, @@ -43,7 +43,7 @@ var ( SortingParameters: []string{}, Routes: []*Route{ { - ID: "supplier1", + ID: "route1", FilterIDs: []string{}, AccountIDs: []string{}, RatingPlanIDs: []string{}, @@ -68,7 +68,7 @@ var ( SortingParameters: []string{}, Routes: []*Route{ { - ID: "supplier2", + ID: "route2", FilterIDs: []string{}, AccountIDs: []string{}, RatingPlanIDs: []string{}, @@ -78,7 +78,7 @@ var ( RouteParameters: "param2", }, { - ID: "supplier3", + ID: "route3", FilterIDs: []string{}, AccountIDs: []string{}, RatingPlanIDs: []string{}, @@ -88,7 +88,7 @@ var ( RouteParameters: "param3", }, { - ID: "supplier1", + ID: "route1", FilterIDs: []string{}, AccountIDs: []string{}, RatingPlanIDs: []string{}, @@ -113,7 +113,7 @@ var ( SortingParameters: []string{}, Routes: []*Route{ { - ID: "supplier1", + ID: "route1", FilterIDs: []string{}, AccountIDs: []string{}, RatingPlanIDs: []string{}, @@ -188,7 +188,7 @@ func TestRoutesSort(t *testing.T) { sprs := RouteProfiles{ &RouteProfile{ Tenant: "cgrates.org", - ID: "supplierprofile1", + ID: "RoutePrf1", FilterIDs: []string{}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), @@ -198,7 +198,7 @@ func TestRoutesSort(t *testing.T) { SortingParameters: []string{}, Routes: []*Route{ { - ID: "supplier1", + ID: "route1", FilterIDs: []string{}, AccountIDs: []string{}, RatingPlanIDs: []string{}, @@ -213,7 +213,7 @@ func TestRoutesSort(t *testing.T) { }, &RouteProfile{ Tenant: "cgrates.org", - ID: "supplierprofile2", + ID: "RoutePrf2", FilterIDs: []string{}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), @@ -223,7 +223,7 @@ func TestRoutesSort(t *testing.T) { SortingParameters: []string{}, Routes: []*Route{ { - ID: "supplier1", + ID: "route1", FilterIDs: []string{}, AccountIDs: []string{}, RatingPlanIDs: []string{}, @@ -240,7 +240,7 @@ func TestRoutesSort(t *testing.T) { eRouteProfile := RouteProfiles{ &RouteProfile{ Tenant: "cgrates.org", - ID: "supplierprofile2", + ID: "RoutePrf2", FilterIDs: []string{}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), @@ -250,7 +250,7 @@ func TestRoutesSort(t *testing.T) { SortingParameters: []string{}, Routes: []*Route{ { - ID: "supplier1", + ID: "route1", FilterIDs: []string{}, AccountIDs: []string{}, RatingPlanIDs: []string{}, @@ -265,7 +265,7 @@ func TestRoutesSort(t *testing.T) { }, &RouteProfile{ Tenant: "cgrates.org", - ID: "supplierprofile1", + ID: "RoutePrf1", FilterIDs: []string{}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), @@ -275,7 +275,7 @@ func TestRoutesSort(t *testing.T) { SortingParameters: []string{}, Routes: []*Route{ { - ID: "supplier1", + ID: "route1", FilterIDs: []string{}, AccountIDs: []string{}, RatingPlanIDs: []string{}, @@ -301,7 +301,7 @@ func TestRoutesPopulateRouteService(t *testing.T) { dmSPP = NewDataManager(data, config.CgrConfig().CacheCfg(), nil) defaultCfg.RouteSCfg().StringIndexedFields = nil defaultCfg.RouteSCfg().PrefixIndexedFields = nil - splService, err = NewRouteService(dmSPP, &FilterS{ + routeService, err = NewRouteService(dmSPP, &FilterS{ dm: dmSPP, cfg: defaultCfg}, defaultCfg, nil) if err != nil { t.Errorf("Error: %+v", err) @@ -311,7 +311,7 @@ func TestRoutesPopulateRouteService(t *testing.T) { func TestRoutesAddFilters(t *testing.T) { fltrSupp1 := &Filter{ Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, - ID: "FLTR_SUPP_1", + ID: "FLTR_RPP_1", Rules: []*FilterRule{ { Type: utils.MetaString, @@ -373,7 +373,7 @@ func TestRoutesCache(t *testing.T) { t.Errorf("Error: %+v", err) } } - //Test each supplier profile from cache + //Test each route profile from cache for _, spp := range sppTest { if tempSpp, err := dmSPP.GetRouteProfile(spp.Tenant, spp.ID, true, true, utils.NonTransactional); err != nil { @@ -385,7 +385,7 @@ func TestRoutesCache(t *testing.T) { } func TestRoutesmatchingRouteProfilesForEvent(t *testing.T) { - sprf, err := splService.matchingRouteProfilesForEvent(argsGetRoutes[0].CGREvent, true) + sprf, err := routeService.matchingRouteProfilesForEvent(argsGetRoutes[0].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -393,7 +393,7 @@ func TestRoutesmatchingRouteProfilesForEvent(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0]) } - sprf, err = splService.matchingRouteProfilesForEvent(argsGetRoutes[1].CGREvent, true) + sprf, err = routeService.matchingRouteProfilesForEvent(argsGetRoutes[1].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -401,7 +401,7 @@ func TestRoutesmatchingRouteProfilesForEvent(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0]) } - sprf, err = splService.matchingRouteProfilesForEvent(argsGetRoutes[2].CGREvent, true) + sprf, err = routeService.matchingRouteProfilesForEvent(argsGetRoutes[2].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -417,7 +417,7 @@ func TestRoutesSortedForEvent(t *testing.T) { Count: 1, SortedRoutes: []*SortedRoute{ { - RouteID: "supplier1", + RouteID: "route1", SortingData: map[string]interface{}{ "Weight": 10.0, }, @@ -425,7 +425,7 @@ func TestRoutesSortedForEvent(t *testing.T) { }, }, } - sprf, err := splService.sortedRoutesForEvent(argsGetRoutes[0]) + sprf, err := routeService.sortedRoutesForEvent(argsGetRoutes[0]) if err != nil { t.Errorf("Error: %+v", err) } @@ -439,21 +439,21 @@ func TestRoutesSortedForEvent(t *testing.T) { Count: 3, SortedRoutes: []*SortedRoute{ { - RouteID: "supplier1", + RouteID: "route1", SortingData: map[string]interface{}{ "Weight": 30.0, }, RouteParameters: "param1", }, { - RouteID: "supplier2", + RouteID: "route2", SortingData: map[string]interface{}{ "Weight": 20.0, }, RouteParameters: "param2", }, { - RouteID: "supplier3", + RouteID: "route3", SortingData: map[string]interface{}{ "Weight": 10.0, }, @@ -462,7 +462,7 @@ func TestRoutesSortedForEvent(t *testing.T) { }, } - sprf, err = splService.sortedRoutesForEvent(argsGetRoutes[1]) + sprf, err = routeService.sortedRoutesForEvent(argsGetRoutes[1]) if err != nil { t.Errorf("Error: %+v", err) } @@ -476,7 +476,7 @@ func TestRoutesSortedForEvent(t *testing.T) { Count: 1, SortedRoutes: []*SortedRoute{ { - RouteID: "supplier1", + RouteID: "route1", SortingData: map[string]interface{}{ "Weight": 10.0, }, @@ -485,7 +485,7 @@ func TestRoutesSortedForEvent(t *testing.T) { }, } - sprf, err = splService.sortedRoutesForEvent(argsGetRoutes[2]) + sprf, err = routeService.sortedRoutesForEvent(argsGetRoutes[2]) if err != nil { t.Errorf("Error: %+v", err) } @@ -501,14 +501,14 @@ func TestRoutesSortedForEventWithLimit(t *testing.T) { Count: 2, SortedRoutes: []*SortedRoute{ { - RouteID: "supplier1", + RouteID: "route1", SortingData: map[string]interface{}{ "Weight": 30.0, }, RouteParameters: "param1", }, { - RouteID: "supplier2", + RouteID: "route2", SortingData: map[string]interface{}{ "Weight": 20.0, }, @@ -519,7 +519,7 @@ func TestRoutesSortedForEventWithLimit(t *testing.T) { argsGetRoutes[1].Paginator = utils.Paginator{ Limit: utils.IntPointer(2), } - sprf, err := splService.sortedRoutesForEvent(argsGetRoutes[1]) + sprf, err := routeService.sortedRoutesForEvent(argsGetRoutes[1]) if err != nil { t.Errorf("Error: %+v", err) } @@ -535,7 +535,7 @@ func TestRoutesSortedForEventWithOffset(t *testing.T) { Count: 1, SortedRoutes: []*SortedRoute{ { - RouteID: "supplier3", + RouteID: "route3", SortingData: map[string]interface{}{ "Weight": 10.0, }, @@ -546,7 +546,7 @@ func TestRoutesSortedForEventWithOffset(t *testing.T) { argsGetRoutes[1].Paginator = utils.Paginator{ Offset: utils.IntPointer(2), } - sprf, err := splService.sortedRoutesForEvent(argsGetRoutes[1]) + sprf, err := routeService.sortedRoutesForEvent(argsGetRoutes[1]) if err != nil { t.Errorf("Error: %+v", err) } @@ -562,7 +562,7 @@ func TestRoutesSortedForEventWithLimitAndOffset(t *testing.T) { Count: 1, SortedRoutes: []*SortedRoute{ { - RouteID: "supplier2", + RouteID: "route2", SortingData: map[string]interface{}{ "Weight": 20.0, }, @@ -574,7 +574,7 @@ func TestRoutesSortedForEventWithLimitAndOffset(t *testing.T) { Limit: utils.IntPointer(1), Offset: utils.IntPointer(1), } - sprf, err := splService.sortedRoutesForEvent(argsGetRoutes[1]) + sprf, err := routeService.sortedRoutesForEvent(argsGetRoutes[1]) if err != nil { t.Errorf("Error: %+v", err) } @@ -634,8 +634,8 @@ func TestRoutesAsOptsGetRoutesMaxCost(t *testing.T) { } func TestRoutesMatchWithIndexFalse(t *testing.T) { - splService.cgrcfg.RouteSCfg().IndexedSelects = false - sprf, err := splService.matchingRouteProfilesForEvent(argsGetRoutes[0].CGREvent, true) + routeService.cgrcfg.RouteSCfg().IndexedSelects = false + sprf, err := routeService.matchingRouteProfilesForEvent(argsGetRoutes[0].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -643,7 +643,7 @@ func TestRoutesMatchWithIndexFalse(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0]) } - sprf, err = splService.matchingRouteProfilesForEvent(argsGetRoutes[1].CGREvent, true) + sprf, err = routeService.matchingRouteProfilesForEvent(argsGetRoutes[1].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -651,7 +651,7 @@ func TestRoutesMatchWithIndexFalse(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0]) } - sprf, err = splService.matchingRouteProfilesForEvent(argsGetRoutes[2].CGREvent, true) + sprf, err = routeService.matchingRouteProfilesForEvent(argsGetRoutes[2].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } diff --git a/loaders/loader_test.go b/loaders/loader_test.go index 154bb5377..1673e18a1 100644 --- a/loaders/loader_test.go +++ b/loaders/loader_test.go @@ -774,16 +774,16 @@ func TestLoaderProcessRoutes(t *testing.T) { eSp := &engine.RouteProfile{ Tenant: "cgrates.org", - ID: "SPP_1", + ID: "RoutePrf1", FilterIDs: []string{"*string:~*req.Account:dan"}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 29, 15, 0, 0, 0, time.UTC), }, - Sorting: "*least_cost", + Sorting: utils.MetaLC, SortingParameters: []string{}, Routes: []*engine.Route{ { - ID: "supplier1", + ID: "route1", FilterIDs: []string{"FLTR_ACNT_dan"}, AccountIDs: []string{"Account1", "Account1_1"}, RatingPlanIDs: []string{"RPL_1"}, @@ -794,7 +794,7 @@ func TestLoaderProcessRoutes(t *testing.T) { RouteParameters: "param1", }, { - ID: "supplier1", + ID: "route1", FilterIDs: []string{"FLTR_DST_DE"}, AccountIDs: []string{"Account2"}, RatingPlanIDs: []string{"RPL_3"}, @@ -805,7 +805,7 @@ func TestLoaderProcessRoutes(t *testing.T) { RouteParameters: utils.EmptyString, }, { - ID: "supplier1", + ID: "route1", RatingPlanIDs: []string{"RPL_2"}, ResourceIDs: []string{"ResGroup2", "ResGroup4"}, StatIDs: []string{"Stat3"}, @@ -821,7 +821,7 @@ func TestLoaderProcessRoutes(t *testing.T) { eSp.Routes[j].ID+strings.Join(eSp.Routes[j].FilterIDs, utils.CONCATENATED_KEY_SEP)) < 0 }) - aps, err := ldr.dm.GetRouteProfile("cgrates.org", "SPP_1", + aps, err := ldr.dm.GetRouteProfile("cgrates.org", "RoutePrf1", true, false, utils.NonTransactional) if err != nil { t.Fatal(err)