mirror of
https://github.com/Readarr/Readarr
synced 2026-01-02 05:37:45 +01:00
New: Various HealthCheck Improvements
(cherry picked from commit 0f6f6814388b25b8fb3fccb6f33bfa16e962549f) Closes #2310
This commit is contained in:
parent
2f7d7fb220
commit
1495fa183f
3 changed files with 20 additions and 8 deletions
|
|
@ -47,7 +47,7 @@ public static void ShouldBeError(this Core.HealthCheck.HealthCheck result, strin
|
|||
|
||||
if (wikiFragment.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
result.WikiUrl.ToString().Should().Contain(wikiFragment);
|
||||
result.WikiUrl.Fragment.Should().Be(wikiFragment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,10 +66,6 @@ public void Setup()
|
|||
.Setup(s => s.GetDownloadClients(It.IsAny<bool>()))
|
||||
.Returns(new IDownloadClient[] { _downloadClient.Object });
|
||||
|
||||
Mocker.GetMock<IProvideDownloadClient>()
|
||||
.Setup(s => s.Get(It.IsAny<int>()))
|
||||
.Returns(_downloadClient.Object);
|
||||
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.Setup(s => s.EnableCompletedDownloadHandling)
|
||||
.Returns(true);
|
||||
|
|
@ -180,7 +176,7 @@ public void should_return_docker_path_mapping_error_if_on_docker_and_root_missin
|
|||
public void should_return_ok_on_book_imported_event()
|
||||
{
|
||||
GivenFolderExists(_downloadRootPath);
|
||||
var importEvent = new TrackImportedEvent(new LocalBook(), new BookFile(), new List<BookFile>(), true, _downloadItem);
|
||||
var importEvent = new TrackImportedEvent(new LocalBook(), new BookFile(), new List<BookFile>(), true, new DownloadClientItem());
|
||||
|
||||
Subject.Check(importEvent).ShouldBeOk();
|
||||
}
|
||||
|
|
@ -194,7 +190,7 @@ public void should_return_permissions_error_on_book_import_failed_event_if_file_
|
|||
};
|
||||
GivenFileExists(localBook.Path);
|
||||
|
||||
var importEvent = new TrackImportFailedEvent(new Exception(), localBook, true, _downloadItem);
|
||||
var importEvent = new TrackImportFailedEvent(new Exception(), localBook, true, new DownloadClientItem());
|
||||
|
||||
Subject.Check(importEvent).ShouldBeError(wikiFragment: "permissions-error");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
|
@ -101,6 +102,10 @@ public override HealthCheck Check()
|
|||
{
|
||||
_logger.Debug(ex, "Unable to communicate with {0}", client.Definition.Name);
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
_logger.Debug(ex, "Unable to communicate with {0}", client.Definition.Name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "Unknown error occured in RemotePathMapping HealthCheck");
|
||||
|
|
@ -140,7 +145,14 @@ public HealthCheck Check(IEvent message)
|
|||
|
||||
// If the previous case did not match then the failure occured in DownloadedTracksImportService,
|
||||
// while trying to locate the files reported by the download client
|
||||
var client = _downloadClientProvider.Get(failureMessage.DownloadClientInfo.Id);
|
||||
// Only check clients not in failure status, those get another message
|
||||
var client = _downloadClientProvider.GetDownloadClients(true).FirstOrDefault(x => x.Definition.Name == failureMessage.DownloadClientInfo.Name);
|
||||
|
||||
if (client == null)
|
||||
{
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var status = client.GetStatus();
|
||||
|
|
@ -193,6 +205,10 @@ public HealthCheck Check(IEvent message)
|
|||
{
|
||||
_logger.Debug(ex, "Unable to communicate with {0}", client.Definition.Name);
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
_logger.Debug(ex, "Unable to communicate with {0}", client.Definition.Name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "Unknown error occured in RemotePathMapping HealthCheck");
|
||||
|
|
|
|||
Loading…
Reference in a new issue