Skip to content

Commit

Permalink
Reorganize integration tests into one project (#878)
Browse files Browse the repository at this point in the history
* Move integration tests to Helpers project

* Remove empty projects

* Flatten test project structure

* Move IntegrationTests.AspNet to IntegrationTests

* Update dependabot.yml

* Update AspNetTests.cs
  • Loading branch information
pellared authored Jun 23, 2022
1 parent 07d5e80 commit bf22f03
Show file tree
Hide file tree
Showing 70 changed files with 54 additions and 342 deletions.
38 changes: 1 addition & 37 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,43 +110,7 @@ updates:
open-pull-requests-limit: 20

- package-ecosystem: nuget
directory: /test/integration-tests/aspnet/IntegrationTests.AspNet
schedule:
interval: "daily"
open-pull-requests-limit: 20

- package-ecosystem: nuget
directory: /test/integration-tests/IntegrationTests.GraphQL
schedule:
interval: "daily"
open-pull-requests-limit: 20

- package-ecosystem: nuget
directory: /test/integration-tests/IntegrationTests.Helpers
schedule:
interval: "daily"
open-pull-requests-limit: 20

- package-ecosystem: nuget
directory: /test/integration-tests/IntegrationTests.Http
schedule:
interval: "daily"
open-pull-requests-limit: 20

- package-ecosystem: nuget
directory: /test/integration-tests/IntegrationTests.StartupHook
schedule:
interval: "daily"
open-pull-requests-limit: 20

- package-ecosystem: nuget
directory: /test/integration-tests/IntegrationTests.MongoDB
schedule:
interval: "daily"
open-pull-requests-limit: 20

- package-ecosystem: nuget
directory: /test/integration-tests/IntegrationTests.SqlClient
directory: /test/IntegrationTests
schedule:
interval: "daily"
open-pull-requests-limit: 20
Expand Down
17 changes: 3 additions & 14 deletions OpenTelemetry.AutoInstrumentation.proj
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
<TestApplicationProject Include="test\test-applications\integrations\dependency-libs\*\*.csproj" />
<TestApplicationProjectFX Include="test\test-applications\integrations\aspnet\*\*.csproj" Condition="'$(OS)' == 'Windows_NT'" />
<MockProject Include="test\test-applications\mocks\*\*.csproj" />
<IntegrationProject Include="test\integration-tests\*\*.csproj" />
<IntegrationProjectFX Include="test\integration-tests\aspnet\*\*.csproj" Condition="'$(OS)' == 'Windows_NT'" />
<IntegrationProject Include="test\IntegrationTests\IntegrationTests.csproj" />
</ItemGroup>

<Target Name="Restore">
<MSBuild Targets="Restore" Projects="@(CsharpProject);@(UnitTestProject);@(TestApplicationProject);@(IntegrationProject);@(MockProject)"/>
<MSBuild Targets="Restore" Projects="@(CsharpProject);@(UnitTestProject);@(TestApplicationProject);@(MockProject)"/>
</Target>

<Target Name="Clean">
<MSBuild Targets="Clean" Projects="@(CsharpProject);@(UnitTestProject);@(TestApplicationProject);@(IntegrationProject);@(MockProject)"/>
<MSBuild Targets="Clean" Projects="@(CsharpProject);@(UnitTestProject);@(TestApplicationProject);@(MockProject)"/>
</Target>

<!-- default target -->
Expand Down Expand Up @@ -59,16 +58,6 @@
</MSBuild>
</Target>

<Target Name="BuildCsharpFXTest">
<MSBuild Targets="Restore" Projects="@(TestApplicationProjectFX);@(IntegrationProjectFX)">
<Output TaskParameter="TargetOutputs" ItemName="CollectedBuildOutput"/>
</MSBuild>

<MSBuild Targets="Build" Projects="@(TestApplicationProjectFX);@(IntegrationProjectFX)">
<Output TaskParameter="TargetOutputs" ItemName="CollectedBuildOutput"/>
</MSBuild>
</Target>

<Target Name="BuildCpp">
<MSBuild Targets="Build" Projects="@(CppProject)" Condition="'$(Platform)' == 'x64' OR '$(Platform)' == 'All'" Properties="Platform=x64">
<Output TaskParameter="TargetOutputs" ItemName="CollectedBuildOutput"/>
Expand Down
120 changes: 13 additions & 107 deletions OpenTelemetry.AutoInstrumentation.sln

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/nuke/Build.Steps.Linux.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ partial class Build
.Unlisted()
.After(CompileNativeSrcLinux)
.After(CompileNativeTestsLinux)
.After(PublishManagedProfiler)
.OnlyWhenStatic(() => IsLinux)
.Executes(() =>
{
Expand Down
46 changes: 2 additions & 44 deletions build/nuke/Build.Steps.Windows.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.IO;
using Extensions;
using Nuke.Common;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
Expand All @@ -8,11 +7,9 @@
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.MSBuild;
using Serilog;
using static DotNetMSBuildTasks;
using static Nuke.Common.EnvironmentInfo;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.Tools.Docker.DockerTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using static Nuke.Common.Tools.MSBuild.MSBuildTasks;

partial class Build
Expand Down Expand Up @@ -85,6 +82,7 @@ partial class Build
.Unlisted()
.After(CompileNativeSrcWindows)
.After(CompileNativeTestsWindows)
.After(PublishManagedProfiler)
.OnlyWhenStatic(() => IsWin)
.Executes(() =>
{
Expand All @@ -96,27 +94,9 @@ partial class Build
testExe("--gtest_output=xml", workingDirectory: workingDirectory);
});

Target CompileManagedTestsWindows => _ => _
.Unlisted()
.After(CompileManagedTests)
.OnlyWhenStatic(() => IsWin)
.Triggers(PublishIisTestApplications)
.Executes(() =>
{
// Compile .NET Framework projects

DotNetMSBuild(x => x
.SetTargetPath(MsBuildProject)
.SetTargetPlatform(Platform)
.SetConfiguration(BuildConfiguration)
.DisableRestore()
.SetTargets("BuildCsharpFXTest")
);
});

Target PublishIisTestApplications => _ => _
.Unlisted()
.After(CompileManagedTestsWindows)
.After(CompileManagedTests)
.OnlyWhenStatic(() => IsWin)
.OnlyWhenStatic(() => Containers == ContainersWindows)
.Executes(() =>
Expand Down Expand Up @@ -144,26 +124,4 @@ partial class Build
);
}
});

Target RunManagedTestsWindows => _ => _
.Unlisted()
.After(RunManagedTests)
.DependsOn(CompileManagedTestsWindows)
.DependsOn(PublishIisTestApplications)
.OnlyWhenStatic(() => IsWin)
.Executes(() =>
{
Project[] aspNetTests = Solution.GetWindowsOnlyIntegrationTests();

DotNetTest(config => config
.SetConfiguration(BuildConfiguration)
.SetTargetPlatform(Platform)
.SetFramework(TargetFramework.NET462)
.SetFilter(ContainersTestFilter())
.EnableNoRestore()
.EnableNoBuild()
.CombineWith(aspNetTests, (s, project) => s
.EnableTrxLogOutput(GetResultsDirectory(project))
.SetProjectFile(project)), degreeOfParallelism: 4);
});
}
11 changes: 4 additions & 7 deletions build/nuke/Build.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ partial class Build
.Unlisted()
.Description("Compiles the managed code in the test directory")
.After(CompileManagedSrc)
.Triggers(CompileManagedTestsWindows)
.Executes(() =>
{
// Always AnyCPU
Expand Down Expand Up @@ -240,7 +239,6 @@ partial class Build
.After(PublishMocks)
.Triggers(RunManagedUnitTests)
.Triggers(RunManagedIntegrationTests)
.Triggers(RunManagedTestsWindows)
.Executes(() => { });

Target PublishMocks => _ => _
Expand Down Expand Up @@ -302,22 +300,21 @@ partial class Build
.Unlisted()
.Executes(() =>
{
Project[] integrationTests = Solution.GetCrossPlatformIntegrationTests();
var project = Solution.GetProject("IntegrationTests");

IEnumerable<TargetFramework> frameworks = IsWin ? TestFrameworks : TestFrameworks.ExceptNetFramework();

DotNetTest(config => config
.SetConfiguration(BuildConfiguration)
.SetTargetPlatform(Platform)
.SetFilter(ContainersTestFilter())
.EnableTrxLogOutput(GetResultsDirectory(project))
.SetProjectFile(project)
.EnableNoRestore()
.EnableNoBuild()
.CombineWith(frameworks, (s, fx) => s
.SetFramework(fx)
)
.CombineWith(integrationTests, (s, project) => s
.EnableTrxLogOutput(GetResultsDirectory(project))
.SetProjectFile(project)), degreeOfParallelism: 4);
));
});

Target CopyAdditionalDeps => _ => _
Expand Down
1 change: 1 addition & 0 deletions build/nuke/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void DeleteReparsePoints(string path)
.DependsOn(CompileManagedTests)
.DependsOn(CompileMocks)
.DependsOn(PublishMocks)
.DependsOn(PublishIisTestApplications)
.DependsOn(RunManagedTests);

Target BuildExamples => _ => _
Expand Down
34 changes: 0 additions & 34 deletions build/nuke/Extensions/SolutionExtensions.cs

This file was deleted.

2 changes: 0 additions & 2 deletions build/nuke/Projects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public static class Tests
public const string AutoInstrumentationLoaderTests = "OpenTelemetry.AutoInstrumentation.Loader.Tests";
public const string AutoInstrumentationBootstrappingTests = "OpenTelemetry.AutoInstrumentation.Bootstrapping.Tests";
public const string AutoInstrumentationTests = "OpenTelemetry.AutoInstrumentation.Tests";

public const string IntegrationTestsHelpers = "IntegrationTests.Helpers";
}

public static class Mocks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// <copyright file="AspNetTests.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

#if NETFRAMEWORK
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
Expand Down Expand Up @@ -44,3 +61,4 @@ public async Task SubmitsTraces()
}
}
}
#endif
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
// </copyright>

#if !NETFRAMEWORK
using System;
using System.Linq;
using FluentAssertions;
Expand Down Expand Up @@ -145,3 +146,4 @@ public void SubmitMetrics()
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\OpenTelemetry.AutoInstrumentation\OpenTelemetry.AutoInstrumentation.csproj" />
<ProjectReference Include="..\..\src\OpenTelemetry.AutoInstrumentation\OpenTelemetry.AutoInstrumentation.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public void SubmitsTraces()

if (Regex.IsMatch(span.Name, "employees\\.*"))
{
Assert.Equal("mongodb", span.Tags?.GetValueOrDefault("db.system"));
Assert.Equal("test-db", span.Tags?.GetValueOrDefault("db.name"));
Assert.True("1.0.0.0" == span.Tags?.GetValueOrDefault("otel.library.version"), span.ToString());
Assert.Equal("mongodb", span.Tags["db.system"]);
Assert.Equal("test-db", span.Tags["db.name"]);
Assert.True("1.0.0.0" == span.Tags["otel.library.version"], span.ToString());

if (span.Tags?.ContainsKey("db.statement") ?? false)
{
Expand All @@ -82,7 +82,7 @@ public void SubmitsTraces()
else
{
// These are manual (DiagnosticSource) traces
Assert.True("1.0.0" == span.Tags?.GetValueOrDefault("otel.library.version"), span.ToString());
Assert.True("1.0.0" == span.Tags["otel.library.version"], span.ToString());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# IntegrationTests.Helpers

This project contains code that can be used other integration test
projects to support writing integration tests.
# Integration Tests

## OTLP protos

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
// </copyright>

#if !NETFRAMEWORK
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand Down Expand Up @@ -131,3 +132,4 @@ private void AssertExpectationsMet(List<WebServerSpanExpectation> expectations,
Assert.True(!failures.Any(), finalMessage);
}
}
#endif

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit bf22f03

Please sign in to comment.