Merge branch 'merge/release/2.2-to-master'
This commit is contained in:
commit
197a19b433
|
|
@ -47,6 +47,8 @@ FileOutputManager::Start()
|
||||||
SYSTEMTIME systemTime;
|
SYSTEMTIME systemTime;
|
||||||
SECURITY_ATTRIBUTES saAttr = { 0 };
|
SECURITY_ATTRIBUTES saAttr = { 0 };
|
||||||
STRU struPath;
|
STRU struPath;
|
||||||
|
FILETIME processCreationTime;
|
||||||
|
FILETIME dummyFileTime;
|
||||||
|
|
||||||
// Concatenate the log file name and application path
|
// Concatenate the log file name and application path
|
||||||
RETURN_IF_FAILED(FILE_UTILITY::ConvertPathToFullPath(
|
RETURN_IF_FAILED(FILE_UTILITY::ConvertPathToFullPath(
|
||||||
|
|
@ -56,18 +58,18 @@ FileOutputManager::Start()
|
||||||
|
|
||||||
RETURN_IF_FAILED(FILE_UTILITY::EnsureDirectoryPathExist(struPath.QueryStr()));
|
RETURN_IF_FAILED(FILE_UTILITY::EnsureDirectoryPathExist(struPath.QueryStr()));
|
||||||
|
|
||||||
// Get the module name and add it to the log file name
|
|
||||||
// as two log files will be created, one from the shim
|
|
||||||
// and one from the request handler.
|
|
||||||
WCHAR path[MAX_PATH];
|
|
||||||
RETURN_LAST_ERROR_IF(!GetModuleFileName(g_hModule, path, sizeof(path)));
|
|
||||||
std::filesystem::path fsPath(path);
|
|
||||||
|
|
||||||
// TODO fix string as it is incorrect
|
// TODO fix string as it is incorrect
|
||||||
GetSystemTime(&systemTime);
|
RETURN_LAST_ERROR_IF(!GetProcessTimes(
|
||||||
|
GetCurrentProcess(),
|
||||||
|
&processCreationTime,
|
||||||
|
&dummyFileTime,
|
||||||
|
&dummyFileTime,
|
||||||
|
&dummyFileTime));
|
||||||
|
RETURN_LAST_ERROR_IF(!FileTimeToSystemTime(&processCreationTime, &systemTime));
|
||||||
|
|
||||||
RETURN_IF_FAILED(
|
RETURN_IF_FAILED(
|
||||||
m_struLogFilePath.SafeSnwprintf(L"%s_%d%02d%02d%02d%02d%02d_%d_%s.log",
|
m_struLogFilePath.SafeSnwprintf(L"%s_%d%02d%02d%02d%02d%02d_%d.log",
|
||||||
struPath.QueryStr(),
|
struPath.QueryStr(),
|
||||||
systemTime.wYear,
|
systemTime.wYear,
|
||||||
systemTime.wMonth,
|
systemTime.wMonth,
|
||||||
|
|
@ -75,8 +77,7 @@ FileOutputManager::Start()
|
||||||
systemTime.wHour,
|
systemTime.wHour,
|
||||||
systemTime.wMinute,
|
systemTime.wMinute,
|
||||||
systemTime.wSecond,
|
systemTime.wSecond,
|
||||||
GetCurrentProcessId(),
|
GetCurrentProcessId()));
|
||||||
fsPath.filename().stem().c_str()));
|
|
||||||
|
|
||||||
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||||
saAttr.bInheritHandle = TRUE;
|
saAttr.bInheritHandle = TRUE;
|
||||||
|
|
|
||||||
|
|
@ -254,6 +254,9 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
||||||
}
|
}
|
||||||
|
|
||||||
HostProcess = Process.GetProcessById(workerProcess.ProcessId);
|
HostProcess = Process.GetProcessById(workerProcess.ProcessId);
|
||||||
|
// cache the process start time for verifying log file name.
|
||||||
|
var _ = HostProcess.StartTime;
|
||||||
|
|
||||||
Logger.LogInformation("Site has started.");
|
Logger.LogInformation("Site has started.");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -249,6 +249,8 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_hostProcess = process;
|
_hostProcess = process;
|
||||||
|
// cache the process start time for verifying log file name.
|
||||||
|
var _ = _hostProcess.StartTime;
|
||||||
Logger.LogInformation("Started iisexpress successfully. Process Id : {processId}, Port: {port}", _hostProcess.Id, port);
|
Logger.LogInformation("Started iisexpress successfully. Process Id : {processId}, Port: {port}", _hostProcess.Id, port);
|
||||||
return (url: url, hostExitToken: hostExitTokenSource.Token);
|
return (url: url, hostExitToken: hostExitTokenSource.Token);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
||||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||||
using Microsoft.AspNetCore.Testing.xunit;
|
using Microsoft.AspNetCore.Testing.xunit;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
|
|
@ -18,12 +17,23 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
public class LoggingTests : IISFunctionalTestBase
|
public class LoggingTests : IISFunctionalTestBase
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
[InlineData("CheckErrLogFile")]
|
[InlineData("CheckErrLogFile")]
|
||||||
[InlineData("CheckLogFile")]
|
[InlineData("CheckLogFile")]
|
||||||
|
|
@ -31,35 +41,18 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
{
|
{
|
||||||
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
|
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
|
||||||
|
|
||||||
deploymentParameters.WebConfigActionList.Add(
|
deploymentParameters.EnableLogging(_logFolderPath);
|
||||||
WebConfigHelpers.AddOrModifyAspNetCoreSection("stdoutLogEnabled", "true"));
|
|
||||||
|
|
||||||
var pathToLogs = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
|
||||||
deploymentParameters.WebConfigActionList.Add(
|
|
||||||
WebConfigHelpers.AddOrModifyAspNetCoreSection("stdoutLogFile", Path.Combine(pathToLogs, "std")));
|
|
||||||
|
|
||||||
var deploymentResult = await DeployAsync(deploymentParameters);
|
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||||
|
|
||||||
|
await Helpers.AssertStarts(deploymentResult, path);
|
||||||
|
|
||||||
try
|
StopServer();
|
||||||
{
|
|
||||||
await Helpers.AssertStarts(deploymentResult, path);
|
|
||||||
|
|
||||||
StopServer();
|
var contents = File.ReadAllText(Helpers.GetExpectedLogName(deploymentResult, _logFolderPath));
|
||||||
|
|
||||||
var fileInDirectory = Directory.GetFiles(pathToLogs).Single(fileName => fileName.Contains("inprocess"));
|
Assert.NotNull(contents);
|
||||||
var contents = File.ReadAllText(fileInDirectory);
|
Assert.Contains("TEST MESSAGE", contents);
|
||||||
|
|
||||||
Assert.NotNull(contents);
|
|
||||||
Assert.Contains("TEST MESSAGE", contents);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
RetryHelper.RetryOperation(
|
|
||||||
() => Directory.Delete(pathToLogs, true),
|
|
||||||
e => Logger.LogWarning($"Failed to delete directory : {e.Message}"),
|
|
||||||
retryCount: 3,
|
|
||||||
retryDelayMilliseconds: 100);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConditionalFact]
|
[ConditionalFact]
|
||||||
|
|
@ -77,6 +70,21 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
await Helpers.AssertStarts(deploymentResult, "HelloWorld");
|
await Helpers.AssertStarts(deploymentResult, "HelloWorld");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ConditionalFact]
|
||||||
|
public async Task OnlyOneFileCreatedWithProcessStartTime()
|
||||||
|
{
|
||||||
|
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
|
||||||
|
|
||||||
|
deploymentParameters.EnableLogging(_logFolderPath);
|
||||||
|
|
||||||
|
var deploymentResult = await DeployAsync(deploymentParameters);
|
||||||
|
await Helpers.AssertStarts(deploymentResult, "CheckLogFile");
|
||||||
|
|
||||||
|
StopServer();
|
||||||
|
|
||||||
|
Assert.Single(Directory.GetFiles(_logFolderPath), Helpers.GetExpectedLogName(deploymentResult, _logFolderPath));
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalFact]
|
[ConditionalFact]
|
||||||
public async Task StartupMessagesAreLoggedIntoDebugLogFile()
|
public async Task StartupMessagesAreLoggedIntoDebugLogFile()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -46,15 +46,22 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
|
|
||||||
var eventLog = new EventLog("Application");
|
var eventLog = new EventLog("Application");
|
||||||
|
|
||||||
// Perf: only get the last 20 events from the event log.
|
|
||||||
// Eventlog is already sorted based on time of event in ascending time.
|
// Eventlog is already sorted based on time of event in ascending time.
|
||||||
// Add results in reverse order.
|
// Check results in reverse order.
|
||||||
var expectedRegexEventLog = new Regex(expectedRegexMatchString);
|
var expectedRegexEventLog = new Regex(expectedRegexMatchString);
|
||||||
var processIdString = $"Process Id: {deploymentResult.HostProcess.Id}.";
|
var processIdString = $"Process Id: {deploymentResult.HostProcess.Id}.";
|
||||||
|
|
||||||
for (var i = eventLog.Entries.Count - 1; i >= eventLog.Entries.Count - 20; i--)
|
// Event log messages round down to the nearest second, so subtract a second
|
||||||
|
var processStartTime = deploymentResult.HostProcess.StartTime.AddSeconds(-1);
|
||||||
|
for (var i = eventLog.Entries.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
var eventLogEntry = eventLog.Entries[i];
|
var eventLogEntry = eventLog.Entries[i];
|
||||||
|
if (eventLogEntry.TimeGenerated < processStartTime)
|
||||||
|
{
|
||||||
|
// If event logs is older than the process start time, we didn't find a match.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (eventLogEntry.ReplacementStrings == null ||
|
if (eventLogEntry.ReplacementStrings == null ||
|
||||||
eventLogEntry.ReplacementStrings.Length < 3)
|
eventLogEntry.ReplacementStrings.Length < 3)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -142,5 +142,14 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
{
|
{
|
||||||
return dictionary.Keys.Select(k => new[] { k });
|
return dictionary.Keys.Select(k => new[] { k });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetExpectedLogName(IISDeploymentResult deploymentResult, string logFolderPath)
|
||||||
|
{
|
||||||
|
var startTime = deploymentResult.HostProcess.StartTime.ToUniversalTime();
|
||||||
|
return Path.Combine(logFolderPath, $"std_{startTime.Year}{startTime.Month:D2}" +
|
||||||
|
$"{startTime.Day:D2}{startTime.Hour:D2}" +
|
||||||
|
$"{startTime.Minute:D2}{startTime.Second:D2}_" +
|
||||||
|
$"{deploymentResult.HostProcess.Id}.log");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,7 @@ namespace IIS.FunctionalTests.Inprocess
|
||||||
|
|
||||||
StopServer();
|
StopServer();
|
||||||
|
|
||||||
var fileInDirectory = Directory.GetFiles(_logFolderPath).Single();
|
var contents = File.ReadAllText(Helpers.GetExpectedLogName(deploymentResult, _logFolderPath));
|
||||||
var contents = File.ReadAllText(fileInDirectory);
|
|
||||||
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, TestSink, expectedString);
|
EventLogHelpers.VerifyEventLogEvent(deploymentResult, TestSink, expectedString);
|
||||||
Assert.Contains(expectedString, contents);
|
Assert.Contains(expectedString, contents);
|
||||||
|
|
@ -98,14 +97,10 @@ namespace IIS.FunctionalTests.Inprocess
|
||||||
|
|
||||||
StopServer();
|
StopServer();
|
||||||
|
|
||||||
var filesInDirectory = Directory.GetFiles(_logFolderPath);
|
var fileInDirectory = Directory.GetFiles(_logFolderPath).Single();
|
||||||
Assert.Equal(2, filesInDirectory.Length);
|
var contents = File.ReadAllText(fileInDirectory);
|
||||||
foreach (var file in filesInDirectory)
|
EventLogHelpers.VerifyEventLogEvent(deploymentResult, TestSink, "Invoked hostfxr");
|
||||||
{
|
Assert.Contains("Invoked hostfxr", contents);
|
||||||
var contents = File.ReadAllText(file);
|
|
||||||
EventLogHelpers.VerifyEventLogEvent(deploymentResult, TestSink, "Invoked hostfxr");
|
|
||||||
Assert.Contains("Invoked hostfxr", contents);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VersionPrefix>3.0.0</VersionPrefix>
|
<DotNetMajorVersion>3</DotNetMajorVersion>
|
||||||
|
<DotNetMinorVersion>0</DotNetMinorVersion>
|
||||||
|
<DotNetPatchVersion>0</DotNetPatchVersion>
|
||||||
|
<VersionPrefix>$(DotNetMajorVersion).$(DotNetMinorVersion).$(DotNetPatchVersion)</VersionPrefix>
|
||||||
|
<AspNetCoreModuleVersionMajor>13</AspNetCoreModuleVersionMajor>
|
||||||
|
<AspNetCoreModuleVersionMinor>$(DotNetMajorVersion)</AspNetCoreModuleVersionMinor>
|
||||||
|
<AspNetCoreModuleVersionRevision>$(DotNetPatchVersion)</AspNetCoreModuleVersionRevision>
|
||||||
<VersionSuffix>alpha1</VersionSuffix>
|
<VersionSuffix>alpha1</VersionSuffix>
|
||||||
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' == 'rtm' ">$(VersionPrefix)</PackageVersion>
|
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' == 'rtm' ">$(VersionPrefix)</PackageVersion>
|
||||||
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' != 'rtm' ">$(VersionPrefix)-$(VersionSuffix)-final</PackageVersion>
|
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' != 'rtm' ">$(VersionPrefix)-$(VersionSuffix)-final</PackageVersion>
|
||||||
|
|
@ -8,9 +14,6 @@
|
||||||
<FeatureBranchVersionPrefix Condition="'$(FeatureBranchVersionPrefix)' == ''">a-</FeatureBranchVersionPrefix>
|
<FeatureBranchVersionPrefix Condition="'$(FeatureBranchVersionPrefix)' == ''">a-</FeatureBranchVersionPrefix>
|
||||||
<VersionSuffix Condition="'$(VersionSuffix)' != '' And '$(FeatureBranchVersionSuffix)' != ''">$(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-'))</VersionSuffix>
|
<VersionSuffix Condition="'$(VersionSuffix)' != '' And '$(FeatureBranchVersionSuffix)' != ''">$(FeatureBranchVersionPrefix)$(VersionSuffix)-$([System.Text.RegularExpressions.Regex]::Replace('$(FeatureBranchVersionSuffix)', '[^\w-]', '-'))</VersionSuffix>
|
||||||
<VersionSuffix Condition="'$(VersionSuffix)' != '' And '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
|
<VersionSuffix Condition="'$(VersionSuffix)' != '' And '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
|
||||||
<AspNetCoreModuleVersionMajor>13</AspNetCoreModuleVersionMajor>
|
|
||||||
<AspNetCoreModuleVersionMinor>0</AspNetCoreModuleVersionMinor>
|
|
||||||
<AspNetCoreModuleVersionRevision>0</AspNetCoreModuleVersionRevision>
|
|
||||||
<AspNetCoreModuleOutOfProcessVersion>2.0.0</AspNetCoreModuleOutOfProcessVersion>
|
<AspNetCoreModuleOutOfProcessVersion>2.0.0</AspNetCoreModuleOutOfProcessVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue