diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 9f4c6e590..b25c4e953 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -489,9 +489,8 @@ stages:
cp -r -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/. ./bin/
displayName: Move Package Contents
- bash: |
- cd ${TESTSFOLDER}
- chmod a+x test.sh
- ./test.sh ${OSNAME} Integration Test
+ chmod a+x ${TESTSFOLDER}/test.sh
+ ${TESTSFOLDER}/test.sh ${OSNAME} Integration Test
displayName: Run Integration Tests
- task: PublishTestResults@2
inputs:
@@ -567,9 +566,8 @@ stages:
cp -r -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/. ./bin/
displayName: Move Package Contents
- bash: |
- cd ${TESTSFOLDER}
- chmod a+x test.sh
- ./test.sh Linux Integration Test
+ chmod a+x ${TESTSFOLDER}/test.sh
+ ${TESTSFOLDER}/test.sh Linux Integration Test
displayName: Run Integration Tests
- task: PublishTestResults@2
inputs:
diff --git a/src/NzbDrone.Integration.Test/IntegrationTest.cs b/src/NzbDrone.Integration.Test/IntegrationTest.cs
index c4897fd24..4b18bffba 100644
--- a/src/NzbDrone.Integration.Test/IntegrationTest.cs
+++ b/src/NzbDrone.Integration.Test/IntegrationTest.cs
@@ -1,24 +1,33 @@
+using System.Threading;
using Lidarr.Http.ClientSchema;
using NLog;
+using NUnit.Framework;
using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Test.Common;
namespace NzbDrone.Integration.Test
{
+ [Parallelizable(ParallelScope.Fixtures)]
public abstract class IntegrationTest : IntegrationTestBase
{
+ protected static int StaticPort = 8686;
+
protected NzbDroneRunner _runner;
public override string ArtistRootFolder => GetTempDirectory("ArtistRootFolder");
- protected override string RootUrl => "http://localhost:8686/";
+ protected int Port { get; private set; }
+
+ protected override string RootUrl => $"http://localhost:{Port}/";
protected override string ApiKey => _runner.ApiKey;
protected override void StartTestTarget()
{
- _runner = new NzbDroneRunner(LogManager.GetCurrentClassLogger());
- _runner.KillAll();
+ Port = Interlocked.Increment(ref StaticPort);
+
+ _runner = new NzbDroneRunner(LogManager.GetCurrentClassLogger(), Port);
+ _runner.Kill();
_runner.Start();
}
@@ -45,7 +54,7 @@ namespace NzbDrone.Integration.Test
protected override void StopTestTarget()
{
- _runner.KillAll();
+ _runner.Kill();
}
}
}
diff --git a/src/NzbDrone.Integration.Test/Lidarr.Integration.Test.csproj b/src/NzbDrone.Integration.Test/Lidarr.Integration.Test.csproj
index ec44dbbbc..0458cfd28 100644
--- a/src/NzbDrone.Integration.Test/Lidarr.Integration.Test.csproj
+++ b/src/NzbDrone.Integration.Test/Lidarr.Integration.Test.csproj
@@ -19,9 +19,4 @@
-
-
- Always
-
-
diff --git a/src/NzbDrone.Integration.Test/integration.runsettings b/src/NzbDrone.Integration.Test/integration.runsettings
deleted file mode 100644
index 500abe263..000000000
--- a/src/NzbDrone.Integration.Test/integration.runsettings
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- 1
-
- true
-
-
- 1
-
-
diff --git a/src/NzbDrone.Test.Common/NzbDroneRunner.cs b/src/NzbDrone.Test.Common/NzbDroneRunner.cs
index 81f538f96..090580bd7 100644
--- a/src/NzbDrone.Test.Common/NzbDroneRunner.cs
+++ b/src/NzbDrone.Test.Common/NzbDroneRunner.cs
@@ -23,11 +23,14 @@ namespace NzbDrone.Test.Common
public string AppData { get; private set; }
public string ApiKey { get; private set; }
+ public int Port { get; private set; }
public NzbDroneRunner(Logger logger, int port = 8686)
{
_processProvider = new ProcessProvider(logger);
- _restClient = new RestClient("http://localhost:8686/api/v1");
+ _restClient = new RestClient($"http://localhost:{port}/api/v1");
+
+ Port = port;
}
public void Start()
@@ -83,7 +86,7 @@ namespace NzbDrone.Test.Common
if (statusCall.ResponseStatus == ResponseStatus.Completed)
{
_startupLog = null;
- TestContext.Progress.WriteLine("Lidarr is started. Running Tests");
+ TestContext.Progress.WriteLine($"Lidarr {Port} is started. Running Tests");
return;
}
@@ -93,6 +96,23 @@ namespace NzbDrone.Test.Common
}
}
+ public void Kill()
+ {
+ try
+ {
+ if (_nzbDroneProcess != null)
+ {
+ _processProvider.Kill(_nzbDroneProcess.Id);
+ }
+ }
+ catch (InvalidOperationException)
+ {
+ // May happen if the process closes while being closed
+ }
+
+ TestBase.DeleteTempFolder(AppData);
+ }
+
public void KillAll()
{
try
@@ -115,7 +135,7 @@ namespace NzbDrone.Test.Common
private void Start(string outputNzbdroneConsoleExe)
{
- TestContext.Progress.WriteLine("Starting instance from {0}", outputNzbdroneConsoleExe);
+ TestContext.Progress.WriteLine("Starting instance from {0} on port {1}", outputNzbdroneConsoleExe, Port);
var args = "-nobrowser -data=\"" + AppData + "\"";
_nzbDroneProcess = _processProvider.Start(outputNzbdroneConsoleExe, args, null, OnOutputDataReceived, OnOutputDataReceived);
@@ -123,7 +143,7 @@ namespace NzbDrone.Test.Common
private void OnOutputDataReceived(string data)
{
- TestContext.Progress.WriteLine(" > " + data);
+ TestContext.Progress.WriteLine($" [{Port}] > " + data);
if (_startupLog != null)
{
@@ -147,7 +167,8 @@ namespace NzbDrone.Test.Common
new XDeclaration("1.0", "utf-8", "yes"),
new XElement(ConfigFileProvider.CONFIG_ELEMENT_NAME,
new XElement(nameof(ConfigFileProvider.ApiKey), apiKey),
- new XElement(nameof(ConfigFileProvider.AnalyticsEnabled), false)));
+ new XElement(nameof(ConfigFileProvider.AnalyticsEnabled), false),
+ new XElement(nameof(ConfigFileProvider.Port), Port)));
var data = xDoc.ToString();
diff --git a/test.sh b/test.sh
index 35b42e3c9..5fbe9374b 100755
--- a/test.sh
+++ b/test.sh
@@ -49,7 +49,6 @@ if [ "$TYPE" = "Unit" ]; then
WHERE="$WHERE&Category!=IntegrationTest&Category!=AutomationTest"
elif [ "$TYPE" = "Integration" ] || [ "$TYPE" = "int" ] ; then
WHERE="$WHERE&Category=IntegrationTest"
- VSTEST_PARAMS="$VSTEST_PARAMS --settings:$TEST_DIR/integration.runsettings"
elif [ "$TYPE" = "Automation" ] ; then
WHERE="$WHERE&Category=AutomationTest"
else