parent
9a8f2be432
commit
953b324df9
@ -1,63 +0,0 @@
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.HealthCheck.Checks;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using static NzbDrone.Core.HealthCheck.Checks.MonoDebugCheck;
|
||||
|
||||
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
{
|
||||
[TestFixture]
|
||||
public class MonoDebugFixture : CoreTest<MonoDebugCheck>
|
||||
{
|
||||
private void GivenHasStackFrame(bool hasStackFrame)
|
||||
{
|
||||
Mocker.GetMock<StackFrameHelper>()
|
||||
.Setup(f => f.HasStackFrameInfo())
|
||||
.Returns(hasStackFrame);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_ok_if_not_mono()
|
||||
{
|
||||
if (PlatformInfo.IsMono)
|
||||
{
|
||||
throw new IgnoreException("non mono specific test");
|
||||
}
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_ok_if_not_debug()
|
||||
{
|
||||
MonoOnly();
|
||||
|
||||
GivenHasStackFrame(false);
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_log_warning_if_not_debug()
|
||||
{
|
||||
MonoOnly();
|
||||
|
||||
GivenHasStackFrame(false);
|
||||
|
||||
Subject.Check();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_ok_if_debug()
|
||||
{
|
||||
MonoOnly();
|
||||
|
||||
GivenHasStackFrame(true);
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
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 MonoNotNetCoreCheckFixture : CoreTest<MonoNotNetCoreCheck>
|
||||
{
|
||||
[Test]
|
||||
[Platform(Exclude = "Mono")]
|
||||
public void should_return_ok_if_net_core()
|
||||
{
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Platform("Mono")]
|
||||
public void should_log_warning_if_mono()
|
||||
{
|
||||
Subject.Check().ShouldBeWarning();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Platform("Mono")]
|
||||
public void should_return_ok_if_bsd()
|
||||
{
|
||||
Mocker.GetMock<IProcessProvider>()
|
||||
.Setup(x => x.StartAndCapture("uname", null, null))
|
||||
.Returns(new ProcessOutput
|
||||
{
|
||||
Lines = new List<ProcessOutputLine>
|
||||
{
|
||||
new ProcessOutputLine(ProcessOutputLevel.Standard, "FreeBSD")
|
||||
}
|
||||
});
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
using System;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.HealthCheck.Checks;
|
||||
using NzbDrone.Core.Localization;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
{
|
||||
[TestFixture]
|
||||
public class MonoVersionCheckFixture : CoreTest<MonoVersionCheck>
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<ILocalizationService>()
|
||||
.Setup(s => s.GetLocalizedString(It.IsAny<string>()))
|
||||
.Returns("Some Warning Message");
|
||||
}
|
||||
|
||||
private void GivenOutput(string version)
|
||||
{
|
||||
MonoOnly();
|
||||
|
||||
Mocker.GetMock<IPlatformInfo>()
|
||||
.SetupGet(s => s.Version)
|
||||
.Returns(new Version(version));
|
||||
}
|
||||
|
||||
[TestCase("5.18")]
|
||||
[TestCase("5.20")]
|
||||
[TestCase("6.4")]
|
||||
public void should_return_ok(string version)
|
||||
{
|
||||
GivenOutput(version);
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
|
||||
public void should_return_notice(string version)
|
||||
{
|
||||
GivenOutput(version);
|
||||
|
||||
Subject.Check().ShouldBeNotice();
|
||||
}
|
||||
|
||||
public void should_return_warning(string version)
|
||||
{
|
||||
GivenOutput(version);
|
||||
|
||||
Subject.Check().ShouldBeWarning();
|
||||
}
|
||||
|
||||
[TestCase("2.10.2")]
|
||||
[TestCase("2.10.8.1")]
|
||||
[TestCase("3.0.0.1")]
|
||||
[TestCase("3.2.0.1")]
|
||||
[TestCase("3.2.1")]
|
||||
[TestCase("3.2.7")]
|
||||
[TestCase("3.6.1")]
|
||||
[TestCase("3.8")]
|
||||
[TestCase("3.10")]
|
||||
[TestCase("4.0.0.0")]
|
||||
[TestCase("4.2")]
|
||||
[TestCase("4.4.0")]
|
||||
[TestCase("4.4.1")]
|
||||
[TestCase("5.4")]
|
||||
[TestCase("5.8")]
|
||||
[TestCase("5.10")]
|
||||
[TestCase("5.12")]
|
||||
[TestCase("5.14")]
|
||||
[TestCase("5.16")]
|
||||
public void should_return_error(string version)
|
||||
{
|
||||
GivenOutput(version);
|
||||
|
||||
Subject.Check().ShouldBeError();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Localization;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck.Checks
|
||||
{
|
||||
public class MonoDebugCheck : HealthCheckBase
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
private readonly StackFrameHelper _stackFrameHelper;
|
||||
|
||||
public override bool CheckOnSchedule => false;
|
||||
|
||||
public MonoDebugCheck(Logger logger, StackFrameHelper stackFrameHelper, ILocalizationService localizationService)
|
||||
: base(localizationService)
|
||||
{
|
||||
_logger = logger;
|
||||
_stackFrameHelper = stackFrameHelper;
|
||||
}
|
||||
|
||||
public class StackFrameHelper
|
||||
{
|
||||
public virtual bool HasStackFrameInfo()
|
||||
{
|
||||
var stackTrace = new StackTrace(true);
|
||||
|
||||
return stackTrace.FrameCount > 0 && stackTrace.GetFrame(0).GetFileName().IsNotNullOrWhiteSpace();
|
||||
}
|
||||
}
|
||||
|
||||
public override HealthCheck Check()
|
||||
{
|
||||
if (!PlatformInfo.IsMono)
|
||||
{
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
if (!_stackFrameHelper.HasStackFrameInfo())
|
||||
{
|
||||
_logger.Warn("Mono is not running with --debug switch");
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Processes;
|
||||
using NzbDrone.Core.Localization;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck.Checks
|
||||
{
|
||||
public class MonoNotNetCoreCheck : HealthCheckBase
|
||||
{
|
||||
private static string[] MonoUnames = new string[] { "FreeBSD", "OpenBSD", "MidnightBSD", "NetBSD" };
|
||||
private readonly IOsInfo _osInfo;
|
||||
private readonly IProcessProvider _processProvider;
|
||||
|
||||
public MonoNotNetCoreCheck(IOsInfo osInfo,
|
||||
IProcessProvider processProvider,
|
||||
ILocalizationService localizationService,
|
||||
Logger logger)
|
||||
: base(localizationService)
|
||||
{
|
||||
_osInfo = osInfo;
|
||||
_processProvider = processProvider;
|
||||
}
|
||||
|
||||
public override HealthCheck Check()
|
||||
{
|
||||
if (!PlatformInfo.IsMono)
|
||||
{
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
// Don't warn on arm based synology - could be arm5 or something else rubbish
|
||||
if (_osInfo.Name == "DSM" && RuntimeInformation.ProcessArchitecture == Architecture.Arm)
|
||||
{
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
// Check for BSD
|
||||
var output = _processProvider.StartAndCapture("uname");
|
||||
if (output?.ExitCode == 0 && MonoUnames.Contains(output?.Lines.First().Content))
|
||||
{
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType(),
|
||||
HealthCheckResult.Warning,
|
||||
_localizationService.GetLocalizedString("MonoNotNetCoreCheckMessage"),
|
||||
"#update-to-net-core-version");
|
||||
}
|
||||
|
||||
public override bool CheckOnSchedule => false;
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using NLog;
|
||||
using NLog.Fluent;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Instrumentation.Extensions;
|
||||
using NzbDrone.Core.Localization;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck.Checks
|
||||
{
|
||||
public class MonoTlsCheck : HealthCheckBase
|
||||
{
|
||||
private readonly IPlatformInfo _platformInfo;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public MonoTlsCheck(IPlatformInfo platformInfo, ILocalizationService localizationService, Logger logger)
|
||||
: base(localizationService)
|
||||
{
|
||||
_platformInfo = platformInfo;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public override HealthCheck Check()
|
||||
{
|
||||
if (!PlatformInfo.IsMono)
|
||||
{
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
var monoVersion = _platformInfo.Version;
|
||||
|
||||
if (monoVersion >= new Version("5.8.0") && Environment.GetEnvironmentVariable("MONO_TLS_PROVIDER") == "legacy")
|
||||
{
|
||||
_logger.Debug()
|
||||
.Message("Mono version {0} and legacy TLS provider is selected, recommending user to switch to btls.", monoVersion)
|
||||
.WriteSentryDebug("LegacyTlsProvider", monoVersion.ToString())
|
||||
.Write();
|
||||
|
||||
return new HealthCheck(GetType(), HealthCheckResult.Warning, _localizationService.GetLocalizedString("MonoTlsCheckMessage"));
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
public override bool CheckOnSchedule => false;
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
using System;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Core.Localization;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck.Checks
|
||||
{
|
||||
public class MonoVersionCheck : HealthCheckBase
|
||||
{
|
||||
private readonly IPlatformInfo _platformInfo;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public MonoVersionCheck(IPlatformInfo platformInfo, ILocalizationService localizationService, Logger logger)
|
||||
: base(localizationService)
|
||||
{
|
||||
_platformInfo = platformInfo;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public override HealthCheck Check()
|
||||
{
|
||||
if (!PlatformInfo.IsMono)
|
||||
{
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
var monoVersion = _platformInfo.Version;
|
||||
|
||||
// Known buggy Mono versions
|
||||
if (monoVersion == new Version("4.4.0") || monoVersion == new Version("4.4.1"))
|
||||
{
|
||||
_logger.Debug("Mono version {0}", monoVersion);
|
||||
return new HealthCheck(GetType(),
|
||||
HealthCheckResult.Error,
|
||||
$"Currently installed Mono version {monoVersion} has a bug that causes issues connecting to indexers/download clients. You should upgrade to a higher version",
|
||||
"#currently-installed-mono-version-is-old-and-unsupported");
|
||||
}
|
||||
|
||||
// Currently best stable Mono version (5.18 gets us .net 4.7.2 support)
|
||||
var bestVersion = new Version("5.20");
|
||||
var targetVersion = new Version("5.18");
|
||||
if (monoVersion >= targetVersion)
|
||||
{
|
||||
_logger.Debug("Mono version is {0} or better: {1}", targetVersion, monoVersion);
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
// Stable Mono versions
|
||||
var stableVersion = new Version("5.18");
|
||||
if (monoVersion >= stableVersion)
|
||||
{
|
||||
_logger.Debug("Mono version is {0} or better: {1}", stableVersion, monoVersion);
|
||||
return new HealthCheck(GetType(),
|
||||
HealthCheckResult.Notice,
|
||||
string.Format(_localizationService.GetLocalizedString("MonoVersionCheckUpgradeRecommendedMessage"), monoVersion, bestVersion),
|
||||
"#currently-installed-mono-version-is-supported-but-upgrading-is-recommended");
|
||||
}
|
||||
|
||||
var oldVersion = new Version("5.4");
|
||||
if (monoVersion >= oldVersion)
|
||||
{
|
||||
return new HealthCheck(GetType(),
|
||||
HealthCheckResult.Error,
|
||||
string.Format(_localizationService.GetLocalizedString("MonoVersionCheckUpgradeRecommendedMessage"), monoVersion, bestVersion),
|
||||
"#currently-installed-mono-version-is-old-and-unsupported");
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType(),
|
||||
HealthCheckResult.Error,
|
||||
string.Format(_localizationService.GetLocalizedString("MonoVersionCheckUpgradeRecommendedMessage"), monoVersion, bestVersion),
|
||||
"#currently-installed-mono-version-is-old-and-unsupported");
|
||||
}
|
||||
|
||||
public override bool CheckOnSchedule => false;
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Core.Update;
|
||||
using Radarr.Http.REST;
|
||||
|
||||
namespace Radarr.Api.V3.Update
|
||||
{
|
||||
public class UpdateResource : RestResource
|
||||
{
|
||||
[JsonConverter(typeof(Newtonsoft.Json.Converters.VersionConverter))]
|
||||
public Version Version { get; set; }
|
||||
|
||||
public string Branch { get; set; }
|
||||
public DateTime ReleaseDate { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string Url { get; set; }
|
||||
public bool Installed { get; set; }
|
||||
public DateTime? InstalledOn { get; set; }
|
||||
public bool Installable { get; set; }
|
||||
public bool Latest { get; set; }
|
||||
public UpdateChanges Changes { get; set; }
|
||||
public string Hash { get; set; }
|
||||
}
|
||||
|
||||
public static class UpdateResourceMapper
|
||||
{
|
||||
public static UpdateResource ToResource(this UpdatePackage model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new UpdateResource
|
||||
{
|
||||
Version = model.Version,
|
||||
|
||||
Branch = model.Branch,
|
||||
ReleaseDate = model.ReleaseDate,
|
||||
FileName = model.FileName,
|
||||
Url = model.Url,
|
||||
|
||||
//Installed
|
||||
//Installable
|
||||
//Latest
|
||||
Changes = model.Changes,
|
||||
Hash = model.Hash,
|
||||
};
|
||||
}
|
||||
|
||||
public static List<UpdateResource> ToResource(this IEnumerable<UpdatePackage> models)
|
||||
{
|
||||
return models.Select(ToResource).ToList();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue