2020-08-15 13:18:51 +00:00
|
|
|
using System.Threading;
|
2020-01-03 12:49:24 +00:00
|
|
|
using Lidarr.Http.ClientSchema;
|
2013-11-13 20:08:37 +00:00
|
|
|
using NLog;
|
2020-08-15 13:18:51 +00:00
|
|
|
using NUnit.Framework;
|
2021-04-27 20:26:38 +00:00
|
|
|
using NzbDrone.Common.Extensions;
|
2017-02-21 16:03:10 +00:00
|
|
|
using NzbDrone.Core.Indexers.Newznab;
|
2013-11-12 03:25:54 +00:00
|
|
|
using NzbDrone.Test.Common;
|
2013-04-22 03:18:08 +00:00
|
|
|
|
|
|
|
namespace NzbDrone.Integration.Test
|
|
|
|
{
|
2020-08-15 13:18:51 +00:00
|
|
|
[Parallelizable(ParallelScope.Fixtures)]
|
2016-04-04 17:40:51 +00:00
|
|
|
public abstract class IntegrationTest : IntegrationTestBase
|
2013-04-22 03:18:08 +00:00
|
|
|
{
|
2020-08-15 13:18:51 +00:00
|
|
|
protected static int StaticPort = 8686;
|
|
|
|
|
2016-07-31 21:40:07 +00:00
|
|
|
protected NzbDroneRunner _runner;
|
2013-11-13 20:08:37 +00:00
|
|
|
|
2017-07-02 00:21:39 +00:00
|
|
|
public override string ArtistRootFolder => GetTempDirectory("ArtistRootFolder");
|
2013-08-14 03:22:28 +00:00
|
|
|
|
2020-08-15 13:18:51 +00:00
|
|
|
protected int Port { get; private set; }
|
|
|
|
|
|
|
|
protected override string RootUrl => $"http://localhost:{Port}/";
|
2013-08-14 05:02:25 +00:00
|
|
|
|
2016-12-09 06:54:15 +00:00
|
|
|
protected override string ApiKey => _runner.ApiKey;
|
2013-08-14 05:02:25 +00:00
|
|
|
|
2016-04-04 17:40:51 +00:00
|
|
|
protected override void StartTestTarget()
|
2013-04-22 03:18:08 +00:00
|
|
|
{
|
2020-08-15 13:18:51 +00:00
|
|
|
Port = Interlocked.Increment(ref StaticPort);
|
|
|
|
|
|
|
|
_runner = new NzbDroneRunner(LogManager.GetCurrentClassLogger(), Port);
|
|
|
|
_runner.Kill();
|
2013-04-22 03:18:08 +00:00
|
|
|
|
2013-08-14 03:22:28 +00:00
|
|
|
_runner.Start();
|
2016-04-04 17:40:51 +00:00
|
|
|
}
|
2014-04-19 15:09:22 +00:00
|
|
|
|
2016-04-04 17:40:51 +00:00
|
|
|
protected override void InitializeTestTarget()
|
|
|
|
{
|
2021-04-27 20:26:38 +00:00
|
|
|
// Make sure tasks have been initialized so the config put below doesn't cause errors
|
|
|
|
WaitForCompletion(() => Tasks.All().SelectList(x => x.TaskName).Contains("RssSync"));
|
|
|
|
|
2017-10-31 01:28:29 +00:00
|
|
|
Indexers.Post(new Lidarr.Api.V1.Indexers.IndexerResource
|
2014-04-19 15:09:22 +00:00
|
|
|
{
|
2017-02-21 16:03:10 +00:00
|
|
|
EnableRss = false,
|
2017-12-02 05:03:12 +00:00
|
|
|
EnableInteractiveSearch = false,
|
|
|
|
EnableAutomaticSearch = false,
|
2017-02-21 16:03:10 +00:00
|
|
|
ConfigContract = nameof(NewznabSettings),
|
|
|
|
Implementation = nameof(Newznab),
|
|
|
|
Name = "NewznabTest",
|
2014-04-19 15:09:22 +00:00
|
|
|
Protocol = Core.Indexers.DownloadProtocol.Usenet,
|
2017-09-04 02:20:56 +00:00
|
|
|
Fields = SchemaBuilder.ToSchema(new NewznabSettings())
|
2014-04-19 15:09:22 +00:00
|
|
|
});
|
2019-07-09 20:46:10 +00:00
|
|
|
|
|
|
|
// Change Console Log Level to Debug so we get more details.
|
|
|
|
var config = HostConfig.Get(1);
|
|
|
|
config.ConsoleLogLevel = "Debug";
|
|
|
|
HostConfig.Put(config);
|
2013-08-13 05:08:37 +00:00
|
|
|
}
|
2013-04-22 03:18:08 +00:00
|
|
|
|
2016-04-04 17:40:51 +00:00
|
|
|
protected override void StopTestTarget()
|
2013-04-22 03:18:08 +00:00
|
|
|
{
|
2020-08-15 13:18:51 +00:00
|
|
|
_runner.Kill();
|
2013-04-22 03:18:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|