Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ stages:
- script: eng\scripts\ci-flaky-tests.cmd -configuration $(_BuildConfig)
displayName: Run Flaky Tests
continueOnError: true
- script: dotnet msbuild eng/repo.targets /t:EnsureFunctionalTestLogsPreserved
displayName: Ensure functional test logs preserved
- powershell: eng\scripts\KillProcesses.ps1
displayName: Kill processes
condition: always()
Expand Down
14 changes: 3 additions & 11 deletions src/Caching/Memory/test/CapacityTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand All @@ -12,7 +12,7 @@

namespace Microsoft.Extensions.Caching.Memory
{
public class CapacityTests : LoggedTestBase
public class CapacityTests
{
[Fact]
public void MemoryDistributedCacheOptionsDefaultsTo200MBSizeLimit()
Expand Down Expand Up @@ -112,13 +112,9 @@ public void DoNotAddEntryIfItExceedsCapacity()
}

[Fact]
[CollectDump]
public async Task DoNotAddIfSizeOverflows()
{
var cache = new MemoryCache(new MemoryCacheOptions
{
SizeLimit = long.MaxValue
}, LoggerFactory);
var cache = new MemoryCache(new MemoryCacheOptions { SizeLimit = long.MaxValue });

var entryOptions = new MemoryCacheEntryOptions { Size = long.MaxValue };
var sem = new SemaphoreSlim(0, 1);
Expand Down Expand Up @@ -148,7 +144,6 @@ public async Task DoNotAddIfSizeOverflows()
}

[Fact]
[CollectDump]
public async Task ExceedsCapacityCompacts()
{
var cache = new MemoryCache(new MemoryCacheOptions
Expand Down Expand Up @@ -242,7 +237,6 @@ public void AddingReplacementWhenTotalSizeExceedsCapacityDoesNotUpdateAndRemoves
}

[Fact]
[CollectDump]
public async Task AddingReplacementWhenTotalSizeExceedsCapacityDoesNotUpdateRemovesOldEntryAndTriggersCompaction()
{
var cache = new MemoryCache(new MemoryCacheOptions
Expand Down Expand Up @@ -312,7 +306,6 @@ public void RemovingEntryDecreasesCacheSize()
}

[Fact]
[CollectDump]
public async Task ExpiringEntryDecreasesCacheSize()
{
var cache = new MemoryCache(new MemoryCacheOptions
Expand Down Expand Up @@ -348,7 +341,6 @@ public async Task ExpiringEntryDecreasesCacheSize()
}

[Fact]
[CollectDump]
public async Task CompactsToLessThanLowWatermarkUsingLRUWhenHighWatermarkExceeded()
{
var testClock = new TestClock();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="$(MSBuildThisFileDirectory)..\..\..\Logging\Logging.Testing\src\build\Microsoft.Extensions.Logging.Testing.props" />

<PropertyGroup>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);net472</TargetFrameworks>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)src\TestingUtils\Microsoft.AspNetCore.Testing\src\Microsoft.AspNetCore.Testing.csproj" />

<Reference Include="Microsoft.Extensions.Hosting.Abstractions" />
<Reference Include="Microsoft.Extensions.Logging" />
<Reference Include="Microsoft.Extensions.Logging.Console" />
<Reference Include="Microsoft.Extensions.Logging.Testing" />
<Reference Include="Serilog.Extensions.Logging" />
<Reference Include="Serilog.Sinks.File" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="$(MSBuildThisFileDirectory)..\..\..\Logging\Logging.Testing\src\build\Microsoft.Extensions.Logging.Testing.props" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(DefaultNetCoreTargetFramework);net472</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<Content Include="testroot\**\*" />
<Compile Include="$(RepoRoot)src\Logging\test\TestLoggerBuilder.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
103 changes: 55 additions & 48 deletions src/Hosting/test/FunctionalTests/ShutdownTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,29 @@
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Hosting.IntegrationTesting;
using Microsoft.Extensions.Logging.Testing;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Test;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.AspNetCore.Hosting.FunctionalTests
{
public class ShutdownTests : LoggedTest
public class ShutdownTests
{
private static readonly string StartedMessage = "Started";
private static readonly string CompletionMessage = "Stopping firing\n" +
"Stopping end\n" +
"Stopped firing\n" +
"Stopped end";
private readonly ITestOutputHelper _output;

public ShutdownTests(ITestOutputHelper output)
{
_output = output;
}

[ConditionalFact]
[OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX)]
Expand All @@ -40,67 +46,68 @@ public async Task ShutdownTestWaitForShutdown()

private async Task ExecuteShutdownTest(string testName, string shutdownMechanic)
{
using (StartLog(out var loggerFactory))
var xunitTestLoggerFactory = TestLoggerBuilder.Create(builder =>
{
var logger = loggerFactory.CreateLogger(testName);
builder.SetMinimumLevel(LogLevel.Trace);
builder.AddXunit(_output);
});

// TODO refactor deployers to not depend on source code
// see https://github.com/dotnet/extensions/issues/1697 and https://github.com/dotnet/aspnetcore/issues/10268
// TODO refactor deployers to not depend on source code
// see https://github.com/dotnet/extensions/issues/1697 and https://github.com/dotnet/aspnetcore/issues/10268
#pragma warning disable 0618
var applicationPath = Path.Combine(TestPathUtilities.GetSolutionRootDirectory("Extensions"),
"src", "Hosting", "test", "testassets", "Microsoft.Extensions.Hosting.TestApp");
var applicationPath = Path.Combine(TestPathUtilities.GetSolutionRootDirectory("Extensions"),
"src", "Hosting", "test", "testassets", "Microsoft.Extensions.Hosting.TestApp");
#pragma warning restore 0618

var deploymentParameters = new DeploymentParameters(
applicationPath,
RuntimeFlavor.CoreClr,
RuntimeArchitecture.x64)
{
TargetFramework = Tfm.NetCoreApp50,
ApplicationType = ApplicationType.Portable,
PublishApplicationBeforeDeployment = true,
StatusMessagesEnabled = false
};
var deploymentParameters = new DeploymentParameters(
applicationPath,
RuntimeFlavor.CoreClr,
RuntimeArchitecture.x64)
{
TargetFramework = Tfm.NetCoreApp50,
ApplicationType = ApplicationType.Portable,
PublishApplicationBeforeDeployment = true,
StatusMessagesEnabled = false
};

deploymentParameters.EnvironmentVariables["DOTNET_STARTMECHANIC"] = shutdownMechanic;
deploymentParameters.EnvironmentVariables["DOTNET_STARTMECHANIC"] = shutdownMechanic;

using (var deployer = new SelfHostDeployer(deploymentParameters, loggerFactory))
{
var result = await deployer.DeployAsync();
using (var deployer = new SelfHostDeployer(deploymentParameters, xunitTestLoggerFactory))
{
var result = await deployer.DeployAsync();

var started = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously);
var completed = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously);
var output = string.Empty;
deployer.HostProcess.OutputDataReceived += (sender, args) =>
var started = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously);
var completed = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously);
var output = string.Empty;
deployer.HostProcess.OutputDataReceived += (sender, args) =>
{
if (!string.IsNullOrEmpty(args.Data) && args.Data.StartsWith(StartedMessage))
{
if (!string.IsNullOrEmpty(args.Data) && args.Data.StartsWith(StartedMessage))
{
output += args.Data.Substring(StartedMessage.Length) + '\n';
started.TrySetResult(0);
}
else
{
output += args.Data + '\n';
}
output += args.Data.Substring(StartedMessage.Length) + '\n';
started.TrySetResult(0);
}
else
{
output += args.Data + '\n';
}

if (output.Contains(CompletionMessage))
{
completed.TrySetResult(0);
}
};
if (output.Contains(CompletionMessage))
{
completed.TrySetResult(0);
}
};

await started.Task.TimeoutAfter(TimeSpan.FromSeconds(60));
await started.Task.TimeoutAfter(TimeSpan.FromSeconds(60));

SendShutdownSignal(deployer.HostProcess);
SendShutdownSignal(deployer.HostProcess);

await completed.Task.TimeoutAfter(TimeSpan.FromSeconds(60));
await completed.Task.TimeoutAfter(TimeSpan.FromSeconds(60));

WaitForExitOrKill(deployer.HostProcess);
WaitForExitOrKill(deployer.HostProcess);

output = output.Trim('\n');
output = output.Trim('\n');

Assert.Equal(CompletionMessage, output);
}
Assert.Equal(CompletionMessage, output);
}
}

Expand Down
Loading