Skip to content

Commit

Permalink
Try to consolidate all the integration test definitions into a single…
Browse files Browse the repository at this point in the history
… target
  • Loading branch information
andrewlock committed Jan 7, 2025
1 parent 86ce608 commit 875b4c5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 176 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/ultimate-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,7 @@ stages:
displayName: 'Initialize LocalDB'
workingDirectory: $(Build.Repository.LocalPath)
- script: tracer\build.cmd CompileTrimmingSamples BuildWindowsIntegrationTests BuildWindowsRegressionTests RunWindowsIntegrationTests RunWindowsRegressionTests -Framework $(framework) --code-coverage-enabled $(CodeCoverageEnabled)
- script: tracer\build.cmd CompileTrimmingSamples BuildWindowsIntegrationTests BuildWindowsRegressionTests RunIntegrationTests RunWindowsRegressionTests -Framework $(framework) --code-coverage-enabled $(CodeCoverageEnabled)
displayName: Run integration tests
env:
DD_LOGGER_DD_API_KEY: $(ddApiKey)
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ services:
args:
- DOTNETSDK_VERSION=${dotnetCoreSdkLatestVersion:-9.0.100}
image: dd-trace-dotnet/${baseImage:-debian}-tester:${dotnetCoreSdkLatestVersion:-9.0.100}
command: dotnet /build/bin/Debug/_build.dll RunLinuxIntegrationTests
command: dotnet /build/bin/Debug/_build.dll RunIntegrationTests
volumes:
- ./:/project
cap_add:
Expand Down Expand Up @@ -541,7 +541,7 @@ services:
args:
- DOTNETSDK_VERSION=${dotnetCoreSdkLatestVersion:-9.0.100}
image: dd-trace-dotnet/${baseImage:-debian}-tester:${dotnetCoreSdkLatestVersion:-9.0.100}
command: dotnet /build/bin/Debug/_build.dll RunLinuxIntegrationTests
command: dotnet /build/bin/Debug/_build.dll RunIntegrationTests
volumes:
- ./:/project
cap_add:
Expand Down Expand Up @@ -672,7 +672,7 @@ services:
args:
- DOTNETSDK_VERSION=${dotnetCoreSdkLatestVersion:-9.0.100}
image: dd-trace-dotnet/${baseImage:-debian}-tester:${dotnetCoreSdkLatestVersion:-9.0.100}
command: dotnet /build/bin/Debug/_build.dll RunLinuxIntegrationTests
command: dotnet /build/bin/Debug/_build.dll RunIntegrationTests
volumes:
- ./:/project
cap_add:
Expand Down
198 changes: 29 additions & 169 deletions tracer/build/_build/Build.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1512,20 +1512,21 @@ string GetSamplesToBuild()
);
});

Target RunWindowsIntegrationTests => _ => _
Target RunIntegrationTests => _ => _
.Unlisted()
.After(BuildTracerHome)
.After(CompileIntegrationTests)
.After(CompileSamples)
.After(CompileTrimmingSamples)
.After(BuildWindowsIntegrationTests)
.After(CompileLinuxOrOsxIntegrationTests)
.DependsOn(CleanTestLogs)
.Requires(() => IsWin)
.Requires(() => Framework)
.Triggers(PrintSnapshotsDiff)
.Executes(() =>
{
var isDebugRun = IsDebugRun();
var filter = GetFilter();

try
{
Expand All @@ -1542,6 +1543,7 @@ string GetSamplesToBuild()
.SetIsDebugRun(isDebugRun)
.SetProcessEnvironmentVariable("MonitoringHomeDirectory", MonitoringHomeDirectory)
.SetLogsDirectory(TestLogsDirectory)
// Don't apply a custom filter to these tests, they should all be able to be run
.When(!string.IsNullOrWhiteSpace(Filter), c => c.SetFilter(Filter))
.When(TestAllPackageVersions, o => o.SetProcessEnvironmentVariable("TestAllPackageVersions", "true"))
.When(CodeCoverageEnabled, ConfigureCodeCoverage)
Expand All @@ -1550,22 +1552,20 @@ string GetSamplesToBuild()
.WithDatadogLogger()
.SetProjectFile(project)), degreeOfParallelism: 4);


// TODO: I think we should change this filter to run on Windows by default
// (RunOnWindows!=False|Category=Smoke)&LoadFromGAC!=True&IIS!=True
DotNetTest(config => config
.SetDotnetPath(TargetPlatform)
.SetConfiguration(BuildConfiguration)
.SetTargetPlatformAnyCPU()
.SetFramework(Framework)
//.WithMemoryDumpAfter(timeoutInMinutes: 30)
.EnableCrashDumps()
.EnableNoRestore()
.EnableNoBuild()
.SetFilter(string.IsNullOrWhiteSpace(Filter) ? "(RunOnWindows=True)&(LoadFromGAC!=True)&(IIS!=True)&(Category!=AzureFunctions)&(SkipInCI!=True)" : Filter)
.SetTestTargetPlatform(TargetPlatform)
.SetIsDebugRun(isDebugRun)
.SetProcessEnvironmentVariable("MonitoringHomeDirectory", MonitoringHomeDirectory)
.SetLogsDirectory(TestLogsDirectory)
.When(!string.IsNullOrWhiteSpace(filter), c => c.SetFilter(filter))
.When(TestAllPackageVersions, o => o.SetProcessEnvironmentVariable("TestAllPackageVersions", "true"))
.When(CodeCoverageEnabled, ConfigureCodeCoverage)
.CombineWith(ClrProfilerIntegrationTests, (s, project) => s
Expand All @@ -1577,6 +1577,29 @@ string GetSamplesToBuild()
{
CopyDumpsToBuildData();
}

string GetFilter()
{
var dockerFilter = IncludeTestsRequiringDocker switch
{
true => "&(RequiresDockerDependency=true)",
false => "&(RequiresDockerDependency!=true)",
null => string.Empty,
};

var armFilter = IsArm64 ? "&(Category!=ArmUnsupported)" : string.Empty;

var filter = (string.IsNullOrWhiteSpace(Filter), IsWin) switch
{
(false, _) => $"({Filter}){dockerFilter}{armFilter}",
(true, false) => $"(Category!=LinuxUnsupported)&(Category!=Lambda)&(Category!=AzureFunctions)&(SkipInCI!=True){dockerFilter}{armFilter}",
// TODO: I think we should change this filter to run on Windows by default, e.g.
// (RunOnWindows!=False|Category=Smoke)&LoadFromGAC!=True&IIS!=True
(true, true) => "(RunOnWindows=True)&(LoadFromGAC!=True)&(IIS!=True)&(Category!=AzureFunctions)&(SkipInCI!=True)",
};

return filter;
}
});

Target CompileAzureFunctionsSamplesWindows => _ => _
Expand Down Expand Up @@ -1845,169 +1868,6 @@ void RunWindowsIisIntegrationTests(Project project)
}
});

Target RunLinuxIntegrationTests => _ => _
.After(CompileLinuxOrOsxIntegrationTests)
.After(CompileTrimmingSamples)
.DependsOn(CleanTestLogs)
.Description("Runs the linux integration tests")
.Requires(() => Framework)
.Requires(() => !IsWin)
.Triggers(PrintSnapshotsDiff)
.Executes(() =>
{
var isDebugRun = IsDebugRun();

var dockerFilter = IncludeTestsRequiringDocker switch
{
true => "&(RequiresDockerDependency=true)",
false => "&(RequiresDockerDependency!=true)",
null => string.Empty,
};

var armFilter = IsArm64 ? "&(Category!=ArmUnsupported)" : string.Empty;

var filter = string.IsNullOrWhiteSpace(Filter) switch
{
false => $"({Filter}){dockerFilter}{armFilter}",
true => $"(Category!=LinuxUnsupported)&(Category!=Lambda)&(Category!=AzureFunctions)&(SkipInCI!=True){dockerFilter}{armFilter}",
};

try
{
// Run these ones in parallel
DotNetTest(config => config
.SetConfiguration(BuildConfiguration)
.EnableNoRestore()
.EnableNoBuild()
.SetFramework(Framework)
//.WithMemoryDumpAfter(timeoutInMinutes: 30)
.EnableCrashDumps()
.SetFilter(filter)
.SetIsDebugRun(isDebugRun)
.SetProcessEnvironmentVariable("MonitoringHomeDirectory", MonitoringHomeDirectory)
.SetTestTargetPlatform(TargetPlatform)
.SetLogsDirectory(TestLogsDirectory)
.When(TestAllPackageVersions, o => o.SetProcessEnvironmentVariable("TestAllPackageVersions", "true"))
.When(IncludeMinorPackageVersions, o => o.SetProperty("IncludeMinorPackageVersions", "true"))
.When(IncludeTestsRequiringDocker is not null, o => o.SetProperty("IncludeTestsRequiringDocker", IncludeTestsRequiringDocker.Value ? "true" : "false"))
.When(CodeCoverageEnabled, ConfigureCodeCoverage)
.CombineWith(ParallelIntegrationTests, (s, project) => s
.EnableTrxLogOutput(GetResultsDirectory(project))
.WithDatadogLogger()
.SetProjectFile(project)),
degreeOfParallelism: 2);

// Run this one separately so we can tail output
DotNetTest(config => config
.SetConfiguration(BuildConfiguration)
.EnableNoRestore()
.EnableNoBuild()
.SetFramework(Framework)
//.WithMemoryDumpAfter(timeoutInMinutes: 30)
.EnableCrashDumps()
.SetFilter(filter)
.SetProcessEnvironmentVariable("MonitoringHomeDirectory", MonitoringHomeDirectory)
.SetTestTargetPlatform(TargetPlatform)
.SetLogsDirectory(TestLogsDirectory)
.When(TestAllPackageVersions, o => o.SetProcessEnvironmentVariable("TestAllPackageVersions", "true"))
.When(IncludeMinorPackageVersions, o => o.SetProperty("IncludeMinorPackageVersions", "true"))
.When(IncludeTestsRequiringDocker is not null, o => o.SetProperty("IncludeTestsRequiringDocker", IncludeTestsRequiringDocker.Value ? "true" : "false"))
.When(CodeCoverageEnabled, ConfigureCodeCoverage)
.CombineWith(ClrProfilerIntegrationTests, (s, project) => s
.EnableTrxLogOutput(GetResultsDirectory(project))
.WithDatadogLogger()
.SetProjectFile(project))
);
}
finally
{
CopyDumpsToBuildData();
}
});

Target RunOsxIntegrationTests => _ => _
.After(CompileLinuxOrOsxIntegrationTests)
.DependsOn(CleanTestLogs)
.Description("Runs the osx integration tests")
.Requires(() => Framework)
.Requires(() => IsOsx)
.Triggers(PrintSnapshotsDiff)
.Executes(() =>
{
var isDebugRun = IsDebugRun();

var dockerFilter = IncludeTestsRequiringDocker switch
{
true => "&(RequiresDockerDependency=true)",
false => "&(RequiresDockerDependency!=true)",
null => string.Empty,
};

var armFilter = IsArm64 ? "&(Category!=ArmUnsupported)" : string.Empty;

var filter = string.IsNullOrWhiteSpace(Filter) switch
{
false => Filter,
true => $"(Category!=LinuxUnsupported)&(Category!=Lambda)&(Category!=AzureFunctions)&(SkipInCI!=True){dockerFilter}{armFilter}",
};

var targetPlatform = IsArm64 ? (MSBuildTargetPlatform)"arm64" : TargetPlatform;

try
{
// Run these ones in parallel
DotNetTest(config => config
.SetConfiguration(BuildConfiguration)
.EnableNoRestore()
.EnableNoBuild()
.SetFramework(Framework)
//.WithMemoryDumpAfter(timeoutInMinutes: 30)
.EnableCrashDumps()
.SetFilter(filter)
.SetIsDebugRun(isDebugRun)
.SetProcessEnvironmentVariable("MonitoringHomeDirectory", MonitoringHomeDirectory)
.SetLocalOsxEnvironmentVariables()
.SetTestTargetPlatform(targetPlatform)
.SetLogsDirectory(TestLogsDirectory)
.When(TestAllPackageVersions, o => o.SetProcessEnvironmentVariable("TestAllPackageVersions", "true"))
.When(IncludeMinorPackageVersions, o => o.SetProperty("IncludeMinorPackageVersions", "true"))
.When(IncludeTestsRequiringDocker is not null, o => o.SetProperty("IncludeTestsRequiringDocker", IncludeTestsRequiringDocker.Value ? "true" : "false"))
.When(CodeCoverageEnabled, ConfigureCodeCoverage)
.CombineWith(ParallelIntegrationTests, (s, project) => s
.EnableTrxLogOutput(GetResultsDirectory(project))
.WithDatadogLogger()
.SetProjectFile(project)),
degreeOfParallelism: 2);

// Run this one separately so we can tail output
DotNetTest(config => config
.SetConfiguration(BuildConfiguration)
.EnableNoRestore()
.EnableNoBuild()
.SetFramework(Framework)
//.WithMemoryDumpAfter(timeoutInMinutes: 30)
.EnableCrashDumps()
.SetFilter(filter)
.SetProcessEnvironmentVariable("MonitoringHomeDirectory", MonitoringHomeDirectory)
.SetLocalOsxEnvironmentVariables()
.SetTestTargetPlatform(targetPlatform)
.SetLogsDirectory(TestLogsDirectory)
.When(TestAllPackageVersions, o => o.SetProcessEnvironmentVariable("TestAllPackageVersions", "true"))
.When(IncludeMinorPackageVersions, o => o.SetProperty("IncludeMinorPackageVersions", "true"))
.When(IncludeTestsRequiringDocker is not null, o => o.SetProperty("IncludeTestsRequiringDocker", IncludeTestsRequiringDocker.Value ? "true" : "false"))
.When(CodeCoverageEnabled, ConfigureCodeCoverage)
.CombineWith(ClrProfilerIntegrationTests, (s, project) => s
.EnableTrxLogOutput(GetResultsDirectory(project))
.WithDatadogLogger()
.SetProjectFile(project))
);
}
finally
{
CopyDumpsToBuildData();
}
});

Target InstallDdTraceTool => _ => _
.Description("Installs the dd-trace tool")
.OnlyWhenDynamic(() => (ToolSource != null))
Expand Down
6 changes: 3 additions & 3 deletions tracer/build/_build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void DeleteReparsePoints(string path)
.DependsOn(BuildWindowsIntegrationTests)
.DependsOn(CompileSamples)
.DependsOn(CompileTrimmingSamples)
.DependsOn(RunWindowsIntegrationTests);
.DependsOn(RunIntegrationTests);

Target BuildAndRunWindowsRegressionTests => _ => _
.Requires(() => IsWin)
Expand Down Expand Up @@ -327,7 +327,7 @@ void DeleteReparsePoints(string path)
.Requires(() => !IsWin)
.Description("Builds and runs the linux integration tests. Requires docker-compose dependencies")
.DependsOn(BuildLinuxIntegrationTests)
.DependsOn(RunLinuxIntegrationTests)
.DependsOn(RunIntegrationTests)
.DependsOn(RunLinuxDdDotnetIntegrationTests);

Target BuildOsxIntegrationTests => _ => _
Expand All @@ -344,7 +344,7 @@ void DeleteReparsePoints(string path)
.DependsOn(BuildOsxIntegrationTests)
.DependsOn(CompileSamples)
.DependsOn(CompileTrimmingSamples)
.DependsOn(RunOsxIntegrationTests);
.DependsOn(RunIntegrationTests);

Target BuildAndRunToolArtifactTests => _ => _
.Description("Builds and runs the tool artifacts tests")
Expand Down

0 comments on commit 875b4c5

Please sign in to comment.