Check what current processes are running to see if dotnet.exe/iisexpress.exe is being stopped. (#1530)
This commit is contained in:
parent
61f1a70784
commit
3842779379
|
|
@ -137,7 +137,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
|
|
||||||
Assert.True(File.Exists(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.exe")));
|
Assert.True(File.Exists(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.exe")));
|
||||||
Assert.False(File.Exists(Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll")));
|
Assert.False(File.Exists(Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll")));
|
||||||
Assert.Contains("InProcessWebSite.exe", File.ReadAllText(Path.Combine(deploymentResult.ContentRoot, "web.config")));
|
Assert.Contains("InProcessWebSite.exe", Helpers.ReadAllTextFromFile(Path.Combine(deploymentResult.ContentRoot, "web.config"), Logger));
|
||||||
|
|
||||||
await deploymentResult.AssertStarts();
|
await deploymentResult.AssertStarts();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,26 +13,15 @@ using Xunit;
|
||||||
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
{
|
{
|
||||||
[Collection(PublishedSitesCollection.Name)]
|
[Collection(PublishedSitesCollection.Name)]
|
||||||
public class LoggingTests : IISFunctionalTestBase
|
public class LoggingTests : LogFileTestBase
|
||||||
{
|
{
|
||||||
private readonly PublishedSitesFixture _fixture;
|
private readonly PublishedSitesFixture _fixture;
|
||||||
private readonly string _logFolderPath;
|
|
||||||
|
|
||||||
public LoggingTests(PublishedSitesFixture fixture)
|
public LoggingTests(PublishedSitesFixture fixture)
|
||||||
{
|
{
|
||||||
_logFolderPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
|
||||||
_fixture = fixture;
|
_fixture = fixture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
|
||||||
{
|
|
||||||
base.Dispose();
|
|
||||||
if (Directory.Exists(_logFolderPath))
|
|
||||||
{
|
|
||||||
Directory.Delete(_logFolderPath, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TestMatrix TestVariants
|
public static TestMatrix TestVariants
|
||||||
=> TestMatrix.ForServers(DeployerSelector.ServerType)
|
=> TestMatrix.ForServers(DeployerSelector.ServerType)
|
||||||
.WithTfms(Tfm.NetCoreApp22)
|
.WithTfms(Tfm.NetCoreApp22)
|
||||||
|
|
@ -65,7 +54,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
|
|
||||||
StopServer();
|
StopServer();
|
||||||
|
|
||||||
var contents = File.ReadAllText(Helpers.GetExpectedLogName(deploymentResult, _logFolderPath));
|
var contents = Helpers.ReadAllTextFromFile(Helpers.GetExpectedLogName(deploymentResult, _logFolderPath), Logger);
|
||||||
|
|
||||||
Assert.Contains("TEST MESSAGE", contents);
|
Assert.Contains("TEST MESSAGE", contents);
|
||||||
}
|
}
|
||||||
|
|
@ -158,7 +147,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
var response = await deploymentResult.HttpClient.GetAsync("/");
|
var response = await deploymentResult.HttpClient.GetAsync("/");
|
||||||
|
|
||||||
StopServer();
|
StopServer();
|
||||||
var logContents = File.ReadAllText(firstTempFile);
|
var logContents = Helpers.ReadAllTextFromFile(firstTempFile, Logger);
|
||||||
|
|
||||||
Assert.Contains("Switching debug log files to", logContents);
|
Assert.Contains("Switching debug log files to", logContents);
|
||||||
|
|
||||||
AssertLogs(secondTempFile);
|
AssertLogs(secondTempFile);
|
||||||
|
|
@ -202,7 +192,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
|
|
||||||
StopServer();
|
StopServer();
|
||||||
|
|
||||||
var contents = File.ReadAllText(Helpers.GetExpectedLogName(deploymentResult, logFolderPath));
|
var contents = Helpers.ReadAllTextFromFile(Helpers.GetExpectedLogName(deploymentResult, logFolderPath), Logger);
|
||||||
Assert.Contains("彡⾔", contents);
|
Assert.Contains("彡⾔", contents);
|
||||||
|
|
||||||
if (variant.HostingModel == HostingModel.InProcess)
|
if (variant.HostingModel == HostingModel.InProcess)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
|
@ -209,5 +210,29 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
Path.Combine(deploymentResult.DeploymentParameters.PublishedApplicationRootPath, "aspnetcore-debug.log"),
|
Path.Combine(deploymentResult.DeploymentParameters.PublishedApplicationRootPath, "aspnetcore-debug.log"),
|
||||||
"Running test allowed log file to be empty." + Environment.NewLine);
|
"Running test allowed log file to be empty." + Environment.NewLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ReadAllTextFromFile(string filename, ILogger logger)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return File.ReadAllText(filename);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// check if there is a dotnet.exe, iisexpress.exe, or w3wp.exe processes still running.
|
||||||
|
var hostingProcesses = Process.GetProcessesByName("dotnet")
|
||||||
|
.Concat(Process.GetProcessesByName("iisexpress"))
|
||||||
|
.Concat(Process.GetProcessesByName("w3wp"));
|
||||||
|
|
||||||
|
logger.LogError($"Could not read file content. Exception message {ex.Message}");
|
||||||
|
logger.LogError("Current hosting exes running:");
|
||||||
|
|
||||||
|
foreach (var hostingProcess in hostingProcesses)
|
||||||
|
{
|
||||||
|
logger.LogError($"{hostingProcess.ProcessName} pid: {hostingProcess.Id} hasExited: {hostingProcess.HasExited.ToString()}");
|
||||||
|
}
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities
|
||||||
|
|
||||||
public string GetLogFileContent(IISDeploymentResult deploymentResult)
|
public string GetLogFileContent(IISDeploymentResult deploymentResult)
|
||||||
{
|
{
|
||||||
return File.ReadAllText(Helpers.GetExpectedLogName(deploymentResult, _logFolderPath));
|
return Helpers.ReadAllTextFromFile(Helpers.GetExpectedLogName(deploymentResult, _logFolderPath), Logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ namespace IIS.FunctionalTests.Inprocess
|
||||||
|
|
||||||
StopServer();
|
StopServer();
|
||||||
|
|
||||||
var contents = File.ReadAllText(Helpers.GetExpectedLogName(deploymentResult, _logFolderPath));
|
var contents = Helpers.ReadAllTextFromFile(Helpers.GetExpectedLogName(deploymentResult, _logFolderPath), Logger);
|
||||||
var expectedString = "The specified framework 'Microsoft.NETCore.App', version '2.9.9' was not found.";
|
var expectedString = "The specified framework 'Microsoft.NETCore.App', version '2.9.9' was not found.";
|
||||||
EventLogHelpers.VerifyEventLogEvent(deploymentResult, expectedString);
|
EventLogHelpers.VerifyEventLogEvent(deploymentResult, expectedString);
|
||||||
Assert.Contains(expectedString, contents);
|
Assert.Contains(expectedString, contents);
|
||||||
|
|
@ -88,7 +88,7 @@ namespace IIS.FunctionalTests.Inprocess
|
||||||
StopServer();
|
StopServer();
|
||||||
|
|
||||||
var fileInDirectory = Directory.GetFiles(_logFolderPath).Single();
|
var fileInDirectory = Directory.GetFiles(_logFolderPath).Single();
|
||||||
var contents = File.ReadAllText(fileInDirectory);
|
var contents = Helpers.ReadAllTextFromFile(fileInDirectory, Logger);
|
||||||
EventLogHelpers.VerifyEventLogEvent(deploymentResult, "Invoked hostfxr");
|
EventLogHelpers.VerifyEventLogEvent(deploymentResult, "Invoked hostfxr");
|
||||||
Assert.Contains("Invoked hostfxr", contents);
|
Assert.Contains("Invoked hostfxr", contents);
|
||||||
}
|
}
|
||||||
|
|
@ -141,7 +141,7 @@ namespace IIS.FunctionalTests.Inprocess
|
||||||
StopServer();
|
StopServer();
|
||||||
|
|
||||||
var fileInDirectory = Directory.GetFiles(_logFolderPath).First();
|
var fileInDirectory = Directory.GetFiles(_logFolderPath).First();
|
||||||
var contents = File.ReadAllText(fileInDirectory);
|
var contents = Helpers.ReadAllTextFromFile(fileInDirectory, Logger);
|
||||||
|
|
||||||
EventLogHelpers.VerifyEventLogEvent(deploymentResult, "Invoked hostfxr");
|
EventLogHelpers.VerifyEventLogEvent(deploymentResult, "Invoked hostfxr");
|
||||||
Assert.Contains("Invoked hostfxr", contents);
|
Assert.Contains("Invoked hostfxr", contents);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue