-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ASP.NET Core on IIS Express tests (#1582)
* Convert ASP.NET Core tests to snapshot tests * Add snapshots for ASP.NET Core tests * Add tests for middleware-only branches and map branches * Update snapshots for new branches * Add CallTarget and RouteTemplateResourceNames tests * Add snapshots for CallTarget and feature flag for aspnetcore tests * Add additional IIS app types, instead of just classic/integrated To support running asp.net core on iis, both in- and out- of process * Add ASP.NET Core module to applicationHost.config Add dummy config for aspnetcore module. * Add web.config to ASP.NET Core apps * Add ASP.NET Core IIS tests * Add support for x86 tests We have to use the x86 version of dotnet.exe, to run in IIS express. So use the x86 version version on Windows when running x86 tests * Add snapshots for ASP.NET Core IIS tests * Iis tests aren't supported on Linux * Fix CallTarget setting. * Remove incorrect comment * fixup add additional iis * Fix rebasing issues
- Loading branch information
1 parent
bf05e4e
commit 8c47c98
Showing
508 changed files
with
19,161 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNetCore/AspNetCoreIisMvc21Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// <copyright file="AspNetCoreIisMvc21Tests.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
|
||
#if NETCOREAPP2_1 | ||
#pragma warning disable SA1402 // File may only contain a single class | ||
#pragma warning disable SA1649 // File name must match first type name | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using VerifyXunit; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Datadog.Trace.ClrProfiler.IntegrationTests.AspNetCore | ||
{ | ||
// Note that ASP.NET Core 2.1 does not support in-process hosting | ||
|
||
[Collection("IisTests")] | ||
public class AspNetCoreIisMvc21TestsOutOfProcess : AspNetCoreIisMvc21Tests | ||
{ | ||
public AspNetCoreIisMvc21TestsOutOfProcess(IisFixture fixture, ITestOutputHelper output) | ||
: base(fixture, output, inProcess: false, enableRouteTemplateResourceNames: false) | ||
{ | ||
} | ||
} | ||
|
||
[Collection("IisTests")] | ||
public class AspNetCoreIisMvc21TestsOutOfProcessWithFeatureFlag : AspNetCoreIisMvc21Tests | ||
{ | ||
public AspNetCoreIisMvc21TestsOutOfProcessWithFeatureFlag(IisFixture fixture, ITestOutputHelper output) | ||
: base(fixture, output, inProcess: false, enableRouteTemplateResourceNames: true) | ||
{ | ||
} | ||
} | ||
|
||
public abstract class AspNetCoreIisMvc21Tests : AspNetCoreIisMvcTestBase | ||
{ | ||
private readonly IisFixture _iisFixture; | ||
private readonly string _testName; | ||
|
||
protected AspNetCoreIisMvc21Tests(IisFixture fixture, ITestOutputHelper output, bool inProcess, bool enableRouteTemplateResourceNames) | ||
: base("AspNetCoreMvc21", fixture, output, inProcess, enableRouteTemplateResourceNames) | ||
{ | ||
_testName = GetTestName(nameof(AspNetCoreIisMvc21Tests)); | ||
_iisFixture = fixture; | ||
_iisFixture.TryStartIis(this, inProcess ? IisAppType.AspNetCoreInProcess : IisAppType.AspNetCoreOutOfProcess); | ||
} | ||
|
||
[Theory] | ||
[Trait("Category", "EndToEnd")] | ||
[Trait("Category", "LinuxUnsupported")] | ||
[Trait("RunOnWindows", "True")] | ||
[MemberData(nameof(Data))] | ||
public async Task MeetsAllAspNetCoreMvcExpectations(string path, HttpStatusCode statusCode) | ||
{ | ||
// We actually sometimes expect 2, but waiting for 1 is good enough | ||
var spans = await GetWebServerSpans(path, _iisFixture.Agent, _iisFixture.HttpPort, statusCode, expectedSpanCount: 1); | ||
|
||
var sanitisedPath = VerifyHelper.SanitisePathsForVerify(path); | ||
|
||
var settings = VerifyHelper.GetSpanVerifierSettings(sanitisedPath, statusCode); | ||
|
||
// Overriding the type name here as we have multiple test classes in the file | ||
// Ensures that we get nice file nesting in Solution Explorer | ||
await Verifier.Verify(spans, settings) | ||
.UseTypeName(_testName); | ||
} | ||
} | ||
} | ||
#endif |
87 changes: 87 additions & 0 deletions
87
test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNetCore/AspNetCoreIisMvc30Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// <copyright file="AspNetCoreIisMvc30Tests.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
|
||
#if NETCOREAPP3_0 | ||
#pragma warning disable SA1402 // File may only contain a single class | ||
#pragma warning disable SA1649 // File name must match first type name | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using VerifyXunit; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Datadog.Trace.ClrProfiler.IntegrationTests.AspNetCore | ||
{ | ||
[Collection("IisTests")] | ||
public class AspNetCoreIisMvc30TestsInProcess : AspNetCoreIisMvc30Tests | ||
{ | ||
public AspNetCoreIisMvc30TestsInProcess(IisFixture fixture, ITestOutputHelper output) | ||
: base(fixture, output, inProcess: true, enableRouteTemplateResourceNames: false) | ||
{ | ||
} | ||
} | ||
|
||
[Collection("IisTests")] | ||
public class AspNetCoreIisMvc30TestsInProcessWithFeatureFlag : AspNetCoreIisMvc30Tests | ||
{ | ||
public AspNetCoreIisMvc30TestsInProcessWithFeatureFlag(IisFixture fixture, ITestOutputHelper output) | ||
: base(fixture, output, inProcess: true, enableRouteTemplateResourceNames: true) | ||
{ | ||
} | ||
} | ||
|
||
[Collection("IisTests")] | ||
public class AspNetCoreIisMvc30TestsOutOfProcess : AspNetCoreIisMvc30Tests | ||
{ | ||
public AspNetCoreIisMvc30TestsOutOfProcess(IisFixture fixture, ITestOutputHelper output) | ||
: base(fixture, output, inProcess: false, enableRouteTemplateResourceNames: false) | ||
{ | ||
} | ||
} | ||
|
||
[Collection("IisTests")] | ||
public class AspNetCoreIisMvc30TestsOutOfProcessWithFeatureFlag : AspNetCoreIisMvc30Tests | ||
{ | ||
public AspNetCoreIisMvc30TestsOutOfProcessWithFeatureFlag(IisFixture fixture, ITestOutputHelper output) | ||
: base(fixture, output, inProcess: false, enableRouteTemplateResourceNames: true) | ||
{ | ||
} | ||
} | ||
|
||
public abstract class AspNetCoreIisMvc30Tests : AspNetCoreIisMvcTestBase | ||
{ | ||
private readonly IisFixture _iisFixture; | ||
private readonly string _testName; | ||
|
||
protected AspNetCoreIisMvc30Tests(IisFixture fixture, ITestOutputHelper output, bool inProcess, bool enableRouteTemplateResourceNames) | ||
: base("AspNetCoreMvc30", fixture, output, inProcess, enableRouteTemplateResourceNames) | ||
{ | ||
_testName = GetTestName(nameof(AspNetCoreIisMvc30Tests)); | ||
_iisFixture = fixture; | ||
_iisFixture.TryStartIis(this, inProcess ? IisAppType.AspNetCoreInProcess : IisAppType.AspNetCoreOutOfProcess); | ||
} | ||
|
||
[Theory] | ||
[Trait("Category", "EndToEnd")] | ||
[Trait("Category", "LinuxUnsupported")] | ||
[Trait("RunOnWindows", "True")] | ||
[MemberData(nameof(Data))] | ||
public async Task MeetsAllAspNetCoreMvcExpectations(string path, HttpStatusCode statusCode) | ||
{ | ||
// We actually sometimes expect 2, but waiting for 1 is good enough | ||
var spans = await GetWebServerSpans(path, _iisFixture.Agent, _iisFixture.HttpPort, statusCode, expectedSpanCount: 1); | ||
|
||
var sanitisedPath = VerifyHelper.SanitisePathsForVerify(path); | ||
|
||
var settings = VerifyHelper.GetSpanVerifierSettings(sanitisedPath, statusCode); | ||
|
||
// Overriding the type name here as we have multiple test classes in the file | ||
// Ensures that we get nice file nesting in Solution Explorer | ||
await Verifier.Verify(spans, settings) | ||
.UseTypeName(_testName); | ||
} | ||
} | ||
} | ||
#endif |
87 changes: 87 additions & 0 deletions
87
test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNetCore/AspNetCoreIisMvc31Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// <copyright file="AspNetCoreIisMvc31Tests.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
|
||
#if NETCOREAPP3_1 | ||
#pragma warning disable SA1402 // File may only contain a single class | ||
#pragma warning disable SA1649 // File name must match first type name | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using VerifyXunit; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Datadog.Trace.ClrProfiler.IntegrationTests.AspNetCore | ||
{ | ||
[Collection("IisTests")] | ||
public class AspNetCoreIisMvc31TestsInProcess : AspNetCoreIisMvc31Tests | ||
{ | ||
public AspNetCoreIisMvc31TestsInProcess(IisFixture fixture, ITestOutputHelper output) | ||
: base(fixture, output, inProcess: true, enableRouteTemplateResourceNames: false) | ||
{ | ||
} | ||
} | ||
|
||
[Collection("IisTests")] | ||
public class AspNetCoreIisMvc31TestsInProcessWithFeatureFlag : AspNetCoreIisMvc31Tests | ||
{ | ||
public AspNetCoreIisMvc31TestsInProcessWithFeatureFlag(IisFixture fixture, ITestOutputHelper output) | ||
: base(fixture, output, inProcess: true, enableRouteTemplateResourceNames: true) | ||
{ | ||
} | ||
} | ||
|
||
[Collection("IisTests")] | ||
public class AspNetCoreIisMvc31TestsOutOfProcess : AspNetCoreIisMvc31Tests | ||
{ | ||
public AspNetCoreIisMvc31TestsOutOfProcess(IisFixture fixture, ITestOutputHelper output) | ||
: base(fixture, output, inProcess: false, enableRouteTemplateResourceNames: false) | ||
{ | ||
} | ||
} | ||
|
||
[Collection("IisTests")] | ||
public class AspNetCoreIisMvc31TestsOutOfProcessWithFeatureFlag : AspNetCoreIisMvc31Tests | ||
{ | ||
public AspNetCoreIisMvc31TestsOutOfProcessWithFeatureFlag(IisFixture fixture, ITestOutputHelper output) | ||
: base(fixture, output, inProcess: false, enableRouteTemplateResourceNames: true) | ||
{ | ||
} | ||
} | ||
|
||
public abstract class AspNetCoreIisMvc31Tests : AspNetCoreIisMvcTestBase | ||
{ | ||
private readonly IisFixture _iisFixture; | ||
private readonly string _testName; | ||
|
||
protected AspNetCoreIisMvc31Tests(IisFixture fixture, ITestOutputHelper output, bool inProcess, bool enableRouteTemplateResourceNames) | ||
: base("AspNetCoreMvc31", fixture, output, inProcess, enableRouteTemplateResourceNames) | ||
{ | ||
_testName = GetTestName(nameof(AspNetCoreIisMvc31Tests)); | ||
_iisFixture = fixture; | ||
_iisFixture.TryStartIis(this, inProcess ? IisAppType.AspNetCoreInProcess : IisAppType.AspNetCoreOutOfProcess); | ||
} | ||
|
||
[Theory] | ||
[Trait("Category", "EndToEnd")] | ||
[Trait("Category", "LinuxUnsupported")] | ||
[Trait("RunOnWindows", "True")] | ||
[MemberData(nameof(Data))] | ||
public async Task MeetsAllAspNetCoreMvcExpectations(string path, HttpStatusCode statusCode) | ||
{ | ||
// We actually sometimes expect 2, but waiting for 1 is good enough | ||
var spans = await GetWebServerSpans(path, _iisFixture.Agent, _iisFixture.HttpPort, statusCode, expectedSpanCount: 1); | ||
|
||
var sanitisedPath = VerifyHelper.SanitisePathsForVerify(path); | ||
|
||
var settings = VerifyHelper.GetSpanVerifierSettings(sanitisedPath, statusCode); | ||
|
||
// Overriding the type name here as we have multiple test classes in the file | ||
// Ensures that we get nice file nesting in Solution Explorer | ||
await Verifier.Verify(spans, settings) | ||
.UseTypeName(_testName); | ||
} | ||
} | ||
} | ||
#endif |
65 changes: 65 additions & 0 deletions
65
test/Datadog.Trace.ClrProfiler.IntegrationTests/AspNetCore/AspNetCoreIisMvcTestBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// <copyright file="AspNetCoreIisMvcTestBase.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
#if NETCOREAPP | ||
|
||
using System.Runtime.InteropServices; | ||
using Datadog.Trace.Configuration; | ||
using VerifyXunit; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Datadog.Trace.ClrProfiler.IntegrationTests.AspNetCore | ||
{ | ||
[UsesVerify] | ||
public abstract class AspNetCoreIisMvcTestBase : TestHelper, IClassFixture<IisFixture> | ||
{ | ||
private readonly bool _inProcess; | ||
private readonly bool _enableRouteTemplateResourceNames; | ||
|
||
protected AspNetCoreIisMvcTestBase(string sampleName, IisFixture fixture, ITestOutputHelper output, bool inProcess, bool enableRouteTemplateResourceNames) | ||
: base(sampleName, output) | ||
{ | ||
_inProcess = inProcess; | ||
_enableRouteTemplateResourceNames = enableRouteTemplateResourceNames; | ||
SetEnvironmentVariable(ConfigurationKeys.HttpServerErrorStatusCodes, "400-403, 500-503"); | ||
|
||
SetServiceVersion("1.0.0"); | ||
|
||
SetCallTargetSettings(true); | ||
if (enableRouteTemplateResourceNames) | ||
{ | ||
SetEnvironmentVariable(ConfigurationKeys.FeatureFlags.RouteTemplateResourceNamesEnabled, "true"); | ||
} | ||
|
||
Fixture = fixture; | ||
} | ||
|
||
protected IisFixture Fixture { get; } | ||
|
||
public static TheoryData<string, int> Data() => new() | ||
{ | ||
{ "/", 200 }, | ||
{ "/delay/0", 200 }, | ||
{ "/api/delay/0", 200 }, | ||
{ "/not-found", 404 }, | ||
{ "/status-code/203", 203 }, | ||
{ "/status-code/500", 500 }, | ||
{ "/bad-request", 500 }, | ||
{ "/status-code/402", 402 }, | ||
{ "/ping", 200 }, | ||
{ "/branch/ping", 200 }, | ||
{ "/branch/not-found", 404 }, | ||
}; | ||
|
||
protected string GetTestName(string testName) | ||
{ | ||
return testName | ||
+ (_inProcess ? ".InProcess" : ".OutOfProcess") | ||
+ (_enableRouteTemplateResourceNames ? ".WithFF" : ".NoFF") | ||
+ (RuntimeInformation.ProcessArchitecture == Architecture.X64 ? ".X64" : ".X86"); // assume that arm is the same | ||
} | ||
} | ||
} | ||
#endif |
Oops, something went wrong.