New: Various HealthCheck Improvements

(cherry picked from commit 0f6f6814388b25b8fb3fccb6f33bfa16e962549f)

Closes #2310
pull/2489/head
bakerboy448 2 years ago committed by Bogdan
parent 2f7d7fb220
commit 1495fa183f

@ -47,7 +47,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
if (wikiFragment.IsNotNullOrWhiteSpace())
{
result.WikiUrl.ToString().Should().Contain(wikiFragment);
result.WikiUrl.Fragment.Should().Be(wikiFragment);
}
}
}

@ -66,10 +66,6 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
.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 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
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 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
};
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 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
_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 @@ namespace NzbDrone.Core.HealthCheck.Checks
// 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 @@ namespace NzbDrone.Core.HealthCheck.Checks
{
_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…
Cancel
Save