mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 20:42:37 +01:00
Added Mono version health check
This commit is contained in:
parent
1d4738b18f
commit
01d3decf7e
@ -36,7 +36,7 @@ public void should_get_free_space_for_drive_that_doesnt_exist()
|
||||
[Test]
|
||||
public void should_be_able_to_check_space_on_ramdrive()
|
||||
{
|
||||
LinuxOnly();
|
||||
MonoOnly();
|
||||
Subject.GetAvailableSpace("/run/").Should().NotBe(0);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ public void EnsureWindowsPath(string path)
|
||||
[TestCase(@"/var/user/file with, comma.mkv")]
|
||||
public void EnsureLinuxPath(string path)
|
||||
{
|
||||
LinuxOnly();
|
||||
MonoOnly();
|
||||
Ensure.That(path, () => path).IsValidPath();
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public void Clean_Path_Windows(string dirty, string clean)
|
||||
[TestCase(@"//CAPITAL//lower// ", @"/CAPITAL/lower")]
|
||||
public void Clean_Path_Linux(string dirty, string clean)
|
||||
{
|
||||
LinuxOnly();
|
||||
MonoOnly();
|
||||
|
||||
var result = dirty.CleanFilePath();
|
||||
result.Should().Be(clean);
|
||||
@ -139,7 +139,7 @@ public void get_actual_casing_should_return_actual_casing_for_local_dir_in_windo
|
||||
[Test]
|
||||
public void get_actual_casing_should_return_original_value_in_linux()
|
||||
{
|
||||
LinuxOnly();
|
||||
MonoOnly();
|
||||
var path = Directory.GetCurrentDirectory();
|
||||
path.GetActualCasing().Should().Be(path);
|
||||
path.GetActualCasing().Should().Be(path);
|
||||
|
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Core.HealthCheck.Checks;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
{
|
||||
[TestFixture]
|
||||
public class MonoVersionCheckFixture : CoreTest<DownloadClientCheck>
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
MonoOnly();
|
||||
}
|
||||
|
||||
private void GivenOutput(string version)
|
||||
{
|
||||
Mocker.GetMock<IProcessProvider>()
|
||||
.Setup(s => s.StartAndCapture("mono", "--version"))
|
||||
.Returns(new ProcessOutput
|
||||
{
|
||||
Standard = new List<string>
|
||||
{
|
||||
String.Format("Mono JIT compiler version {0} (Debian {0}-8)", version),
|
||||
"Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_warning_when_mono_3_0()
|
||||
{
|
||||
GivenOutput("3.0.0.1");
|
||||
|
||||
Subject.Check().ShouldBeWarning();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_warning_when_mono_2_10_8()
|
||||
{
|
||||
GivenOutput("2.10.8.1");
|
||||
|
||||
Subject.Check().ShouldBeWarning();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_null_when_mono_3_2()
|
||||
{
|
||||
GivenOutput("3.2.0.1");
|
||||
|
||||
Subject.Check().Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_null_when_mono_4_0()
|
||||
{
|
||||
GivenOutput("4.0.0.0");
|
||||
|
||||
Subject.Check().Should().BeNull();
|
||||
}
|
||||
}
|
||||
}
|
@ -75,7 +75,7 @@ public void should_return_false_if_in_working_folder_and_last_write_time_was_rec
|
||||
[Test]
|
||||
public void should_return_false_if_unopacking_on_linux()
|
||||
{
|
||||
LinuxOnly();
|
||||
MonoOnly();
|
||||
|
||||
GivenInWorkingFolder();
|
||||
GivenLastWriteTimeUtc(DateTime.UtcNow.AddDays(-5));
|
||||
|
@ -108,7 +108,7 @@ public void filter_should_return_none_existing_files_ignoring_case()
|
||||
[Test]
|
||||
public void filter_should_return_none_existing_files_not_ignoring_case()
|
||||
{
|
||||
LinuxOnly();
|
||||
MonoOnly();
|
||||
|
||||
var files = new List<string>()
|
||||
{
|
||||
|
@ -125,10 +125,11 @@
|
||||
<Compile Include="Framework\CoreTest.cs" />
|
||||
<Compile Include="Framework\DbTest.cs" />
|
||||
<Compile Include="Framework\NBuilderExtensions.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DownloadClientCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\UpdateCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DroneFactoryCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DownloadClientCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\MonoVersionCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\HealthCheckFixtureExtentions.cs" />
|
||||
<Compile Include="HistoryTests\HistoryServiceFixture.cs" />
|
||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedHistoryItemsFixture.cs" />
|
||||
|
49
src/NzbDrone.Core/HealthCheck/Checks/MonoVersionnCheck.cs
Normal file
49
src/NzbDrone.Core/HealthCheck/Checks/MonoVersionnCheck.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Processes;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck.Checks
|
||||
{
|
||||
public class MonoVersionnCheck : IProvideHealthCheck
|
||||
{
|
||||
private readonly IProcessProvider _processProvider;
|
||||
private readonly Logger _logger;
|
||||
private static readonly Regex VersionRegex = new Regex(@"(?<=\W)(?<version>\d+\.\d+\.\d+\.\d+)(?=\W)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
public MonoVersionnCheck(IProcessProvider processProvider, Logger logger)
|
||||
{
|
||||
_processProvider = processProvider;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public HealthCheck Check()
|
||||
{
|
||||
if (!OsInfo.IsMono)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var output = _processProvider.StartAndCapture("mono", "--version");
|
||||
|
||||
foreach (var line in output.Standard)
|
||||
{
|
||||
var versionMatch = VersionRegex.Match(line);
|
||||
|
||||
if (versionMatch.Success)
|
||||
{
|
||||
var version = new Version(versionMatch.Groups["version"].Value);
|
||||
|
||||
if (version >= new Version(3, 2))
|
||||
{
|
||||
_logger.Debug("mono version is 3.2 or better: {0}", version.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new HealthCheck(HealthCheckResultType.Warning, "mono version is less than 3.2, upgrade for improved stability");
|
||||
}
|
||||
}
|
||||
}
|
@ -268,6 +268,7 @@
|
||||
<Compile Include="Exceptions\StatusCodeToExceptions.cs" />
|
||||
<Compile Include="HealthCheck\CheckHealthCommand.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DownloadClientCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\MonoVersionnCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DroneFactoryCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\UpdateCheck.cs" />
|
||||
|
@ -8,7 +8,7 @@ public class DiskProviderFixture : DiskProviderFixtureBase<DiskProvider>
|
||||
{
|
||||
public DiskProviderFixture()
|
||||
{
|
||||
LinuxOnly();
|
||||
MonoOnly();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ public class FreeSpaceFixture : FreeSpaceFixtureBase<DiskProvider>
|
||||
{
|
||||
public FreeSpaceFixture()
|
||||
{
|
||||
LinuxOnly();
|
||||
MonoOnly();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ protected void WindowsOnly()
|
||||
}
|
||||
|
||||
|
||||
protected void LinuxOnly()
|
||||
protected void MonoOnly()
|
||||
{
|
||||
if (!OsInfo.IsMono)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user