mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-21 23:32:27 +00:00
Run integration tests in parallel
Revert "Try to fix alpine integration tests"
This reverts commit a47854103c
This commit is contained in:
parent
4d1931fa0e
commit
74f1d804aa
6 changed files with 43 additions and 32 deletions
|
@ -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:
|
||||
|
|
|
@ -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 @@ protected override void InitializeTestTarget()
|
|||
|
||||
protected override void StopTestTarget()
|
||||
{
|
||||
_runner.KillAll();
|
||||
_runner.Kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,4 @@
|
|||
<ProjectReference Include="..\Lidarr.Api.V1\Lidarr.Api.V1.csproj" />
|
||||
<ProjectReference Include="..\NzbDrone.Test.Common\Lidarr.Test.Common.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="integration.runsettings">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<RunSettings>
|
||||
<RunConfiguration>
|
||||
<!-- 0 = As many processes as possible, limited by number of cores on machine, 1 = Sequential (1 process), 2-> Given number of processes up to limit by number of cores on machine-->
|
||||
<MaxCpuCount>1</MaxCpuCount>
|
||||
<!-- Disables in-assembly parallel execution, applies to both MSTest and NUnit -->
|
||||
<DisableParallelization>true</DisableParallelization>
|
||||
</RunConfiguration>
|
||||
<NUnit>
|
||||
<NumberOfTestWorkers>1</NumberOfTestWorkers>
|
||||
</NUnit>
|
||||
</RunSettings>
|
|
@ -23,11 +23,14 @@ public class NzbDroneRunner
|
|||
|
||||
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 @@ public void Start()
|
|||
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 @@ public void Start()
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ public void KillAll()
|
|||
|
||||
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 @@ private void Start(string outputNzbdroneConsoleExe)
|
|||
|
||||
private void OnOutputDataReceived(string data)
|
||||
{
|
||||
TestContext.Progress.WriteLine(" > " + data);
|
||||
TestContext.Progress.WriteLine($" [{Port}] > " + data);
|
||||
|
||||
if (_startupLog != null)
|
||||
{
|
||||
|
@ -147,7 +167,8 @@ private void GenerateConfigFile()
|
|||
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();
|
||||
|
||||
|
|
1
test.sh
1
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
|
||||
|
|
Loading…
Reference in a new issue