Additional logging in case of integration test startup failures

Closes #1231
This commit is contained in:
Taloth Saldono 2019-09-13 14:23:01 +02:00 committed by Qstick
parent 6abe5f3df3
commit 25ab30605b
1 changed files with 12 additions and 1 deletions

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
@ -6,6 +7,7 @@ using System.Xml.Linq;
using NLog; using NLog;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Processes; using NzbDrone.Common.Processes;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using RestSharp; using RestSharp;
@ -17,6 +19,7 @@ namespace NzbDrone.Test.Common
private readonly IProcessProvider _processProvider; private readonly IProcessProvider _processProvider;
private readonly IRestClient _restClient; private readonly IRestClient _restClient;
private Process _nzbDroneProcess; private Process _nzbDroneProcess;
private List<string> _startupLog;
public string AppData { get; private set; } public string AppData { get; private set; }
public string ApiKey { get; private set; } public string ApiKey { get; private set; }
@ -48,6 +51,7 @@ namespace NzbDrone.Test.Common
lidarrConsoleExe = "Lidarr"; lidarrConsoleExe = "Lidarr";
} }
_startupLog = new List<string>();
if (BuildInfo.IsDebug) if (BuildInfo.IsDebug)
{ {
var frameworkFolder = PlatformInfo.IsNetCore ? "netcoreapp3.1" : "net462"; var frameworkFolder = PlatformInfo.IsNetCore ? "netcoreapp3.1" : "net462";
@ -66,7 +70,8 @@ namespace NzbDrone.Test.Common
{ {
TestContext.Progress.WriteLine("Lidarr has exited unexpectedly"); TestContext.Progress.WriteLine("Lidarr has exited unexpectedly");
Thread.Sleep(2000); Thread.Sleep(2000);
Assert.Fail("Process has exited: ExitCode={0}", _nzbDroneProcess.ExitCode); var output = _startupLog.Join(Environment.NewLine);
Assert.Fail("Process has exited: ExitCode={0} Output={1}", _nzbDroneProcess.ExitCode, output);
} }
var request = new RestRequest("system/status"); var request = new RestRequest("system/status");
@ -77,6 +82,7 @@ namespace NzbDrone.Test.Common
if (statusCall.ResponseStatus == ResponseStatus.Completed) if (statusCall.ResponseStatus == ResponseStatus.Completed)
{ {
_startupLog = null;
TestContext.Progress.WriteLine("Lidarr is started. Running Tests"); TestContext.Progress.WriteLine("Lidarr is started. Running Tests");
return; return;
} }
@ -119,6 +125,11 @@ namespace NzbDrone.Test.Common
{ {
TestContext.Progress.WriteLine(" > " + data); TestContext.Progress.WriteLine(" > " + data);
if (_startupLog != null)
{
_startupLog.Add(data);
}
if (data.Contains("Press enter to exit")) if (data.Contains("Press enter to exit"))
{ {
_nzbDroneProcess.StandardInput.WriteLine(" "); _nzbDroneProcess.StandardInput.WriteLine(" ");