New errors for dispatcher hosts/profile

This commit is contained in:
adi
2022-10-18 16:57:42 +03:00
committed by Dan Christian Bogos
parent b8682b9772
commit eb1000fcb9
21 changed files with 86 additions and 86 deletions

View File

@@ -160,7 +160,7 @@ func (dS *DispatcherService) dispatcherProfilesForEvent(tnt string, ev *utils.CG
for prflID := range prflIDs {
prfl, err := dS.dm.GetDispatcherProfile(tnt, prflID, true, true, utils.NonTransactional)
if err != nil {
if err != utils.ErrNotFound {
if err != utils.ErrDSPProfileNotFound {
return nil, err
}
continue

View File

@@ -926,7 +926,7 @@ func TestDispatcherServiceDispatchDspErrHostNotFound(t *testing.T) {
}
subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
err = dss.Dispatch(ev, subsys, "", "", "")
expected := "HOST_NOT_FOUND"
expected := "DSP_HOST_NOT_FOUND"
if err == nil || err.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
}
@@ -1146,7 +1146,7 @@ func TestDispatcherServiceDispatchDspErrHostNotFound2(t *testing.T) {
}
subsys := utils.IfaceAsString(ev.APIOpts[utils.MetaSubsys])
err = dss.Dispatch(ev, subsys, "", "", "")
expected := "HOST_NOT_FOUND"
expected := "DSP_HOST_NOT_FOUND"
if err == nil || err.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
}

View File

@@ -216,7 +216,7 @@ func (sd *singleResultDispatcher) Dispatch(dm *engine.DataManager, flts *engine.
if hostIDs, err = sd.sorter.Sort(flts, ev, tnt, sd.hosts); err != nil {
return
} else if len(hostIDs) == 0 { // in case we do not match any host
return utils.ErrHostNotFound
return utils.ErrDSPHostNotFound
}
for _, hostID := range hostIDs {
var dRh *DispatcherRoute
@@ -229,7 +229,8 @@ func (sd *singleResultDispatcher) Dispatch(dm *engine.DataManager, flts *engine.
}
if err = callDHwithID(tnt, hostID, routeID, dRh, dm,
serviceMethod, args, reply); err == nil ||
(err != utils.ErrNotFound && !rpcclient.IsNetworkError(err)) { // successful dispatch with normal errors
err != utils.ErrDSPHostNotFound ||
!rpcclient.IsNetworkError(err) { // successful dispatch with normal errors
return
}
if err != nil {
@@ -260,7 +261,7 @@ func (b *broadcastDispatcher) Dispatch(dm *engine.DataManager, flts *engine.Filt
for _, hostID := range hostIDs {
var dH *engine.DispatcherHost
if dH, err = dm.GetDispatcherHost(tnt, hostID, true, true, utils.NonTransactional); err != nil {
if err == utils.ErrNotFound {
if err == utils.ErrDSPHostNotFound {
utils.Logger.Warning(fmt.Sprintf("<%s> could not find host with ID %q",
utils.DispatcherS, hostID))
err = nil
@@ -284,7 +285,7 @@ func (b *broadcastDispatcher) Dispatch(dm *engine.DataManager, flts *engine.Filt
})
}
if !hasHosts { // in case we do not match any host
return utils.ErrHostNotFound
return utils.ErrDSPHostNotFound
}
return pool.Call(serviceMethod, args, reply)
}
@@ -325,7 +326,7 @@ func (ld *loadDispatcher) Dispatch(dm *engine.DataManager, flts *engine.FilterS,
if hostIDs, err = ld.sorter.Sort(flts, ev, tnt, lM.getHosts(ld.hosts)); err != nil {
return
} else if len(hostIDs) == 0 { // in case we do not match any host
return utils.ErrHostNotFound
return utils.ErrDSPHostNotFound
}
for _, hostID := range hostIDs {
var dRh *DispatcherRoute

View File

@@ -389,7 +389,7 @@ func TestLibDispatcherSingleResultDispatcherDispatch(t *testing.T) {
dataDB := engine.NewInternalDB(nil, nil, true, config.CgrConfig().DataDbCfg().Items)
dM := engine.NewDataManager(dataDB, config.CgrConfig().CacheCfg(), nil)
err := wgDsp.Dispatch(dM, nil, nil, "", "", &DispatcherRoute{}, "", "", "")
expected := "HOST_NOT_FOUND"
expected := "DSP_HOST_NOT_FOUND"
if err == nil || err.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
}
@@ -400,7 +400,7 @@ func TestLibDispatcherSingleResultDispatcherDispatchRouteID(t *testing.T) {
dataDB := engine.NewInternalDB(nil, nil, true, config.CgrConfig().DataDbCfg().Items)
dM := engine.NewDataManager(dataDB, config.CgrConfig().CacheCfg(), nil)
err := wgDsp.Dispatch(dM, nil, nil, "", "routeID", &DispatcherRoute{}, "", "", "")
expected := "HOST_NOT_FOUND"
expected := "DSP_HOST_NOT_FOUND"
if err == nil || err.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
}
@@ -411,7 +411,7 @@ func TestLibDispatcherBroadcastDispatcherDispatch(t *testing.T) {
dataDB := engine.NewInternalDB(nil, nil, true, config.CgrConfig().DataDbCfg().Items)
dM := engine.NewDataManager(dataDB, config.CgrConfig().CacheCfg(), nil)
err := wgDsp.Dispatch(dM, nil, nil, "", "", &DispatcherRoute{}, "", "", "")
expected := "HOST_NOT_FOUND"
expected := "DSP_HOST_NOT_FOUND"
if err == nil || err.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
}
@@ -422,7 +422,7 @@ func TestLibDispatcherBroadcastDispatcherDispatchRouteID(t *testing.T) {
dataDB := engine.NewInternalDB(nil, nil, true, config.CgrConfig().DataDbCfg().Items)
dM := engine.NewDataManager(dataDB, config.CgrConfig().CacheCfg(), nil)
err := wgDsp.Dispatch(dM, nil, nil, "", "routeID", &DispatcherRoute{}, "", "", "")
expected := "HOST_NOT_FOUND"
expected := "DSP_HOST_NOT_FOUND"
if err == nil || err.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
}
@@ -433,7 +433,7 @@ func TestLibDispatcherLoadDispatcherDispatch(t *testing.T) {
dataDB := engine.NewInternalDB(nil, nil, true, config.CgrConfig().DataDbCfg().Items)
dM := engine.NewDataManager(dataDB, config.CgrConfig().CacheCfg(), nil)
err := wgDsp.Dispatch(dM, nil, nil, "", "", &DispatcherRoute{}, "", "", "")
expected := "HOST_NOT_FOUND"
expected := "DSP_HOST_NOT_FOUND"
if err == nil || err.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
}
@@ -450,7 +450,7 @@ func TestLibDispatcherLoadDispatcherDispatchHostsID(t *testing.T) {
dataDB := engine.NewInternalDB(nil, nil, true, config.CgrConfig().DataDbCfg().Items)
dM := engine.NewDataManager(dataDB, config.CgrConfig().CacheCfg(), nil)
err := wgDsp.Dispatch(dM, nil, nil, "", "routeID", &DispatcherRoute{}, "", "", "")
expected := "HOST_NOT_FOUND"
expected := "DSP_HOST_NOT_FOUND"
if err == nil || err.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
}
@@ -603,7 +603,7 @@ func TestLibDispatcherBroadcastDispatcherDispatchError2(t *testing.T) {
nil, nil, true, utils.NonTransactional)
wgDsp := &broadcastDispatcher{hosts: engine.DispatcherHostProfiles{{ID: "testID"}}}
err := wgDsp.Dispatch(nil, nil, nil, "testTenant", "testID", &DispatcherRoute{}, "", "", "")
expected := "HOST_NOT_FOUND"
expected := "DSP_HOST_NOT_FOUND"
if err == nil || err.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
}
@@ -654,7 +654,7 @@ func TestLibDispatcherLoadDispatcherCacheError(t *testing.T) {
value, nil, true, utils.NonTransactional)
wgDsp := &loadDispatcher{sorter: new(noSort), hosts: engine.DispatcherHostProfiles{{ID: "testID"}}}
err := wgDsp.Dispatch(nil, nil, nil, "testTenant", "testID", &DispatcherRoute{}, "", "", "")
expected := "HOST_NOT_FOUND"
expected := "DSP_HOST_NOT_FOUND"
if err == nil || err.Error() != expected {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, err)
}