Skip to content

Commit

Permalink
Re-enable AspNet integration tests in CI (open-telemetry#1414)
Browse files Browse the repository at this point in the history
Runs the AspNet tests added by DataDog/dd-trace-dotnet#1288 . Currently, this only tests the `AspNetMvc` and `AspNetWebApi2` integrations because the `AspNet` integration is not yet enabled via automatic instrumentation.

The tests are run in the Windows IIS runs for the following reasons:
- Restoring the projects and publishing can be grouped into the existing `samples-iis.sln` solution
- Instrumenting IIS and IIS Express requires the Datadog.Trace assemblies to be in the GAC

- Adding the AspNet CI applications to `samples-iis.sln`, which we are already properly restoring and publishing in the Windows IIS jobs
- Removing some compile-time references to `Datadog.Trace.dll` and `Datadog.Trace.ClrProfiler.Managed.dll` with lookups via reflection. This is used so the site can give us a clear indicator whether automatic instrumentation is running
- Miscellaneous change: Stop Visual Studio from auto-generating a `launchSettings.json` for the Datadog.Trace.IntegrationTests project
  • Loading branch information
zacharycmontoya authored and RassK committed Apr 26, 2021
1 parent 580aaf1 commit d5c77e5
Show file tree
Hide file tree
Showing 18 changed files with 159 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ jobs:
inputs:
solution: test/test-applications/aspnet/samples-iis.sln
configuration: '$(buildConfiguration)'
msbuildArguments: '/p:DeployOnBuild=true /p:PublishProfile=FolderProfile.pubxml'
msbuildArguments: '/p:DeployOnBuild=true /p:PublishProfile=$(System.DefaultWorkingDirectory)/test/test-applications/aspnet/PublishProfiles/FolderProfile.pubxml'
maximumCpuCount: true

- task: DockerCompose@0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public AspNetMvc4Tests(IisFixture iisFixture, ITestOutputHelper output, bool ena

[Theory]
[Trait("Category", "EndToEnd")]
[Trait("Integration", nameof(Integrations.AspNetMvcIntegration))]
[Trait("RunOnWindows", "True")]
[Trait("LoadFromGAC", "True")]
[MemberData(nameof(AspNetMvc4TestData.WithoutFeatureFlag), MemberType = typeof(AspNetMvc4TestData))]
public async Task SubmitsTraces(
string path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public AspNetMvc4WithFeatureFlagTests(IisFixture iisFixture, ITestOutputHelper o

[Theory]
[Trait("Category", "EndToEnd")]
[Trait("Integration", nameof(Integrations.AspNetMvcIntegration))]
[Trait("RunOnWindows", "True")]
[Trait("LoadFromGAC", "True")]
[MemberData(nameof(AspNetMvc4TestData.WithFeatureFlag), MemberType = typeof(AspNetMvc4TestData))]
public async Task WithNewResourceNames_SubmitsTraces(
string path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public AspNetMvc5Tests(IisFixture iisFixture, ITestOutputHelper output, bool ena

[Theory]
[Trait("Category", "EndToEnd")]
[Trait("Integration", nameof(Integrations.AspNetMvcIntegration))]
[Trait("RunOnWindows", "True")]
[Trait("LoadFromGAC", "True")]
[MemberData(nameof(AspNetMvc5TestData.WithoutFeatureFlag), MemberType = typeof(AspNetMvc5TestData))]
public async Task SubmitsTraces(
string path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public AspNetMvc5WithFeatureFlagTests(IisFixture iisFixture, ITestOutputHelper o

[Theory]
[Trait("Category", "EndToEnd")]
[Trait("Integration", nameof(Integrations.AspNetMvcIntegration))]
[Trait("RunOnWindows", "True")]
[Trait("LoadFromGAC", "True")]
[MemberData(nameof(AspNetMvc5TestData.WithFeatureFlag), MemberType = typeof(AspNetMvc5TestData))]
public async Task SubmitsTraces(
string path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public AspNetWebApi2Tests(IisFixture iisFixture, ITestOutputHelper output, bool

[Theory]
[Trait("Category", "EndToEnd")]
[Trait("Integration", nameof(Integrations.AspNetWebApi2Integration))]
[Trait("RunOnWindows", "True")]
[Trait("LoadFromGAC", "True")]
[MemberData(nameof(AspNetWebApi2TestData.WithoutFeatureFlag), MemberType = typeof(AspNetWebApi2TestData))]
public async Task SubmitsTraces(
string path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public AspNetWebApi2WithFeatureFlagTests(IisFixture iisFixture, ITestOutputHelpe

[Theory]
[Trait("Category", "EndToEnd")]
[Trait("Integration", nameof(Integrations.AspNetWebApi2Integration))]
[Trait("RunOnWindows", "True")]
[Trait("LoadFromGAC", "True")]
[MemberData(nameof(AspNetWebApi2TestData.WithFeatureFlag), MemberType = typeof(AspNetWebApi2TestData))]
public async Task SubmitsTraces(
string path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ public AspNetWebFormsTests(IisFixture iisFixture, ITestOutputHelper output)
_iisFixture.TryStartIis(this);
}

[Theory]
[Theory(Skip = "This example does not use MVC or WebApi, so we will not generate traces until AspNet is invoked via automatic instrumentation.")]
[Trait("Category", "EndToEnd")]
[Trait("Integration", nameof(AspNetWebFormsTests))]
[Trait("RunOnWindows", "True")]
[Trait("LoadFromGAC", "True")]
[InlineData("/Account/Login", "GET /account/login", false)]
public async Task SubmitsTraces(
string path,
Expand All @@ -50,9 +51,10 @@ await AssertWebServerSpan(
"1.0.0");
}

[Fact]
[Fact(Skip = "This test requires Elasticsearch to be running on the host, which is not currently enabled in CI.")]
[Trait("Category", "EndToEnd")]
[Trait("Integration", nameof(AspNetWebFormsTests))]
[Trait("RunOnWindows", "True")]
[Trait("LoadFromGAC", "True")]
public async Task NestedAsyncElasticCallSubmitsTrace()
{
var testStart = DateTime.UtcNow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

<PropertyGroup>
<OutputType>Library</OutputType>

<!-- Tell Visual Studio to not create a new launchSettings.json file, even though we have AspNetCore assets -->
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion test/Datadog.Trace.TestHelpers/EnvironmentHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,10 @@ public string GetSampleApplicationOutputDirectory(string packageVersion = "", st

if (_samplesDirectory.Contains("aspnet"))
{
outputDir = binDir;
outputDir = Path.Combine(
binDir,
EnvironmentTools.GetBuildConfiguration(),
"publish");
}
else if (EnvironmentTools.GetOS() == "win")
{
Expand Down
18 changes: 18 additions & 0 deletions test/test-applications/aspnet/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>bin\Release\publish</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,6 @@
<Content Include="Scripts\jquery-3.3.1.slim.min.map" />
<Content Include="Scripts\jquery-3.3.1.min.map" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\src\Datadog.Trace.ClrProfiler.Managed\Datadog.Trace.ClrProfiler.Managed.csproj">
<Project>{85f35aaf-d102-4960-8b41-3bd9cbd0e77f}</Project>
<Name>Datadog.Trace.ClrProfiler.Managed</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\src\Datadog.Trace\Datadog.Trace.csproj">
<Project>{5dfdf781-f24c-45b1-82ef-9125875a80a4}</Project>
<Name>Datadog.Trace</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
@model List<KeyValuePair<string, string>>
@using System.Linq
@using System.Reflection

@{
ViewBag.Title = "Index";

var instrumentationType = Type.GetType("Datadog.Trace.ClrProfiler.Instrumentation, Datadog.Trace.ClrProfiler.Managed");
var profilerAttached = instrumentationType?.GetProperty("ProfilerAttached", BindingFlags.Public | BindingFlags.Static)?.GetValue(null) ?? false;
var tracerAssemblyLocation = Type.GetType("Datadog.Trace.Tracer, Datadog.Trace")?.Assembly.Location ?? "(none)";
var clrProfilerAssemblyLocation = instrumentationType?.Assembly.Location ?? "(none)";
}

<div class="container">
Expand All @@ -14,15 +20,15 @@
</tr>
<tr>
<th scope="row">Profiler attached</th>
<td>@Datadog.Trace.ClrProfiler.Instrumentation.ProfilerAttached</td>
<td>@profilerAttached</td>
</tr>
<tr>
<th scope="row">OpenTelemetry.AutoInstrumentation.dll path</th>
<td>@typeof(Datadog.Trace.Tracer).Assembly.Location</td>
<td>@tracerAssemblyLocation</td>
</tr>
<tr>
<th scope="row">OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed.dll</th>
<td>@typeof(Datadog.Trace.ClrProfiler.Instrumentation).Assembly.Location</td>
<td>@clrProfilerAssemblyLocation</td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public override void RegisterArea(AreaRegistrationContext context)
context.MapRoute(
"Datadog_default",
"Datadog/{controller}/{action}/{id}",
new { area = AreaName, action = "Index", id = UrlParameter.Optional }
//new { area = AreaName, action = "Index", id = UrlParameter.Optional }
new { area = AreaName, controller = "DogHouse", action = "Index", id = UrlParameter.Optional }
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,14 @@
<Folder Include="Models\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\src\Datadog.Trace\Datadog.Trace.csproj">
<Project>{8e1baa6a-47cc-47f0-a7d6-74741118eb7c}</Project>
<Name>Datadog.Trace</Name>
</ProjectReference>
<ProjectReference Include="..\..\integrations\dependency-libs\Samples.Shared\Samples.Shared.csproj">
<Project>{b4ae8b0f-c2b2-41df-88bb-d97e267d8964}</Project>
<Name>Samples.Shared</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\src\Datadog.Trace.ClrProfiler.Managed\Datadog.Trace.ClrProfiler.Managed.csproj">
<Project>{85f35aaf-d102-4960-8b41-3bd9cbd0e77f}</Project>
<Name>Datadog.Trace.ClrProfiler.Managed</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\src\Datadog.Trace\Datadog.Trace.csproj">
<Project>{5dfdf781-f24c-45b1-82ef-9125875a80a4}</Project>
<Name>Datadog.Trace</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
@model List<KeyValuePair<string, string>>
@using System.Reflection

@{
ViewBag.Title = "Index";

var instrumentationType = Type.GetType("Datadog.Trace.ClrProfiler.Instrumentation, Datadog.Trace.ClrProfiler.Managed");
var profilerAttached = instrumentationType?.GetProperty("ProfilerAttached", BindingFlags.Public | BindingFlags.Static)?.GetValue(null) ?? false;
var tracerAssemblyLocation = Type.GetType("Datadog.Trace.Tracer, Datadog.Trace")?.Assembly.Location ?? "(none)";
var clrProfilerAssemblyLocation = instrumentationType?.Assembly.Location ?? "(none)";
}

<div class="container">
Expand All @@ -13,7 +19,7 @@
</tr>
<tr>
<th scope="row">Profiler attached</th>
<td>@Datadog.Trace.ClrProfiler.Instrumentation.ProfilerAttached</td>
<td>@profilerAttached</td>
</tr>
<tr>
<th scope="row">Current directory</th>
Expand All @@ -25,11 +31,11 @@
</tr>
<tr>
<th scope="row">OpenTelemetry.AutoInstrumentation.dll path</th>
<td>@typeof(Datadog.Trace.Tracer).Assembly.Location</td>
<td>@tracerAssemblyLocation</td>
</tr>
<tr>
<th scope="row">OpenTelemetry.AutoInstrumentation.ClrProfiler.Managed.dll</th>
<td>@typeof(Datadog.Trace.ClrProfiler.Instrumentation).Assembly.Location</td>
<td>@clrProfilerAssemblyLocation</td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\src\Datadog.Trace\Datadog.Trace.csproj">
<Project>{5dfdf781-f24c-45b1-82ef-9125875a80a4}</Project>
<Project>{8e1baa6a-47cc-47f0-a7d6-74741118eb7c}</Project>
<Name>Datadog.Trace</Name>
</ProjectReference>
</ItemGroup>
Expand Down
Loading

0 comments on commit d5c77e5

Please sign in to comment.