Skip to content

Commit

Permalink
Refactor test folder to group related projects (#2094)
Browse files Browse the repository at this point in the history
* Move benchmarks away from tests and mark IsPackable false in root

* Move profiler tests in own subfolder

* Create test/profiler/applications

* move KafkaSample

* move MySqlDataSample

* move NpgsqlSample

* move OracleManagedDataAccessCoreSample

* move OracleManagedDataAccessSample

* move RabbitMqSample

* move SatalliteAssemblySample

* move SqlClientSample

* move SqliteSample

* move AdoNet helpers

* Ensure outputpath is not relative

* update profiler tests path in workflows

* reference to Microsoft.Net.Test.SDK dictates IsTestProject not Directory.Build.props

* centralize test configuration

* Move azure tests to test/azure

* move instrumentation tests to their own folder

* Move related grpc test sample project to tests
  • Loading branch information
Mpdreamz committed May 30, 2023
1 parent eb7cc0b commit 17a34b3
Show file tree
Hide file tree
Showing 245 changed files with 330 additions and 466 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
uses: ./.github/workflows/test
with:
name: 'profiler'
project: 'test/Elastic.Apm.Profiler.Managed.Tests/Elastic.Apm.Profiler.Managed.Tests.csproj'
project: 'test/profiler/Elastic.Apm.Profiler.Managed.Tests/Elastic.Apm.Profiler.Managed.Tests.csproj'

- name: Create Docker Image
run: .ci/linux/build_docker.sh
2 changes: 1 addition & 1 deletion .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ jobs:
uses: ./.github/workflows/test
with:
name: 'profiler'
project: 'test/Elastic.Apm.Profiler.Managed.Tests/Elastic.Apm.Profiler.Managed.Tests.csproj'
project: 'test/profiler/Elastic.Apm.Profiler.Managed.Tests/Elastic.Apm.Profiler.Managed.Tests.csproj'
4 changes: 4 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<ExposedPublicKey>002400000480000094000000060200000024000052534131000400000100010051df3e4d8341d66c6dfbf35b2fda3627d08073156ed98eef81122b94e86ef2e44e7980202d21826e367db9f494c265666ae30869fb4cd1a434d171f6b634aa67fa8ca5b9076d55dc3baa203d3a23b9c1296c9f45d06a45cf89520bef98325958b066d8c626db76dd60d0508af877580accdd0e9f88e46b6421bf09a33de53fe1</ExposedPublicKey>
<ExposedPublicKeySampleApps>0024000004800000940000000602000000240000525341310004000001000100553bc065771cba5728dd48f670a8f93d119fe6f165a3b65dbff073687a014dd033b9a0019cb7d790c7ffaff9e8b5204eb56364ea7e3da5b681136e3082a2c5ae826018f9d1578536923205ad6e9d7d877dffc22d33099c561f3409874fb286641bac5ec51017baf7817cef7dbf727b05d26e1dccc54de08d786398381b5085b2</ExposedPublicKeySampleApps>
<DelaySign>false</DelaySign>
<!-- Suppress warnings when a proj is marked <IsPackable>false</IsPackable>
but dotnet pack expects to pack it e.g. Microsoft.NET.Sdk.Web test and sample projects. -->
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
<IsPackable>false</IsPackable>
</PropertyGroup>
<!-- MinVer Configuration -->
<PropertyGroup>
Expand Down
128 changes: 74 additions & 54 deletions ElasticApmAgent.sln

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions benchmarks/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Project>
<!-- Test Directory Build Properties -->
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
<ItemGroup>
<ProjectReference Include="..\..\sample\SampleAspNetCoreApp\SampleAspNetCoreApp.csproj"/>
<ProjectReference Include="..\..\src\Elastic.Apm\Elastic.Apm.csproj"/>
<ProjectReference Include="..\Elastic.Apm.Tests.Utilities\Elastic.Apm.Tests.Utilities.csproj"/>
<ProjectReference Include="..\Elastic.Apm.Tests\Elastic.Apm.Tests.csproj"/>
<ProjectReference Include="..\..\test\Elastic.Apm.Tests.Utilities\Elastic.Apm.Tests.Utilities.csproj"/>
</ItemGroup>

<ItemGroup>
Expand Down
File renamed without changes.
37 changes: 23 additions & 14 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,37 @@
<!-- Test Directory Build Properties -->
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
<PropertyGroup>
<IsPackable>false</IsPackable>
<!-- Suppress warnings when a proj is marked <IsPackable>false</IsPackable>
but dotnet pack expects to pack it e.g. Microsoft.NET.Sdk.Web test and sample projects. -->
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
<!-- Always generate debug symbols this allows fluent symbols exception messages to include variable names -->
<DebugSymbols>True</DebugSymbols>
<!-- All projects in this directory are assumed to be Test projects by default i.e. containing tests. Some may not
be however, so they can override this setting so that common test components are not added.
-->
<IsTestProject>true</IsTestProject>

<!-- Elastic.Apm.AspNetFullFramework is completely self managed since it needs a lot of special care (for now) -->
<IsAspNetFullFrameworkTests Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(ProjectName), '^(.*)AspNetFullFramework\.Tests$'))">true</IsAspNetFullFrameworkTests>
<IsRegularTestProject Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(ProjectName), '^(.*)Tests$')) AND '$(IsAspNetFullFrameworkTests)' == ''">true</IsRegularTestProject>
</PropertyGroup>

<ItemGroup>
<!-- use xunit config for all test files. Allow assemblies to run in parallel -->
<Content Include="$(SolutionRoot)/xunit.runner.json" CopyToOutputDirectory="PreserveNewest" Condition="'$(IsTestProject)' == 'true'" />
<Content Include="$(SolutionRoot)\xunit.runner.json" CopyToOutputDirectory="PreserveNewest" Condition="'$(IsRegularTestProject)' == 'true'" />
</ItemGroup>

<ItemGroup>
<!-- Add coverlet collector for all platforms and frameworks, except net462 -->
<PackageReference Include="coverlet.collector" Version="3.0.2" Condition="'$(IsTestProject)' == 'true' AND '$(TargetFramework)' != 'net462'">

<PropertyGroup
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(ProjectName), '^(.*)Tests$')) AND !$([System.Text.RegularExpressions.Regex]::IsMatch($(ProjectName), '^(.*)AspNetFullFramework\.Tests$'))">
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(ProjectName), '^(.*)Tests$')) AND !$([System.Text.RegularExpressions.Regex]::IsMatch($(ProjectName), '^(.*)AspNetFullFramework\.Tests$'))">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />

<PackageReference Include="JunitXml.TestLogger" Version="3.0.114" PrivateAssets="All" />
<PackageReference Include="Nullean.VsTest.Pretty.TestLogger" Version="0.3.0" PrivateAssets="All" />

<PackageReference Include="FluentAssertions" Version="5.6.0" />
<PackageReference Include="FluentAssertions.Analyzers" Version="0.11.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="JunitXml.TestLogger" Version="2.1.81" Condition="'$(IsTestProject)' == 'true'" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,7 @@
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="FluentAssertions" Version="5.6.0" />
<PackageReference Include="FluentAssertions.Analyzers" Version="0.11.4" />
<PackageReference Include="Moq" Version="4.12.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0"/>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="FluentAssertions" Version="5.6.0" />
<PackageReference Include="FluentAssertions.Analyzers" Version="0.11.4" />
<PackageReference Include="Moq" Version="4.12.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0" />
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions test/Elastic.Apm.Docker.Tests/Elastic.Apm.Docker.Tests.csproj

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="FluentAssertions" Version="5.6.0" />
<PackageReference Include="Moq" Version="4.12.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="FluentAssertions" Version="5.6.0" />
<PackageReference Include="Moq" Version="4.12.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion test/Elastic.Apm.Feature.Tests/CloudProviderSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ public void CloudMetadataKeyEqualsValue(string key, string value)
var token = payloadCollector.Payloads[0].Body[0].SelectToken($"metadata.cloud.{key}");

token.Should().NotBeNull();
token.Value<string>().Should().Be(value);
var prop = token as JProperty;
prop.Should().NotBeNull();
prop.Value<string>().Should().Be(value);

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>
<PackageReference Include="FluentAssertions" Version="5.6.0"/>
<PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0"/>
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.5.5"/>
<PackageReference Include="SpecFlow.xUnit" Version="3.5.5"/>
<PackageReference Include="xunit" Version="2.4.1"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"/>
</ItemGroup>

<ItemGroup>
Expand Down
21 changes: 0 additions & 21 deletions test/Elastic.Apm.MongoDb.Tests/Elastic.Apm.MongoDb.Tests.csproj

This file was deleted.

This file was deleted.

Loading

0 comments on commit 17a34b3

Please sign in to comment.