Skip to content

Commit

Permalink
Add Tracer testing and more repos to exploration tests (#2308)
Browse files Browse the repository at this point in the history
- Adds the Tracer usecase to exploration tests
- Adds the following popular libraries to exploration tests
  - RestSharp
  - Serilog
  - Polly
  - AutoMapper
  • Loading branch information
zacharycmontoya authored Mar 29, 2022
1 parent 45b2c38 commit f855c79
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 15 deletions.
25 changes: 18 additions & 7 deletions .azure-pipelines/ultimate-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -792,11 +792,12 @@ stages:
- stage: exploration_tests_windows
condition: >
and(
succeeded(),
eq(variables['isScheduledBuild'], 'False'),
succeeded(),
eq(variables['isScheduledBuild'], 'False'),
or(
eq(stageDependencies.generate_variables.generate_variables_job.outputs['generate_variables_step.IsProfilerChanged'],'True'),
eq(stageDependencies.generate_variables.generate_variables_job.outputs['generate_variables_step.IsDebuggerChanged'], 'True')
eq(dependencies.generate_variables.outputs['generate_variables_job.generate_variables_step.IsTracerChanged'],'True'),
eq(dependencies.generate_variables.outputs['generate_variables_job.generate_variables_step.IsProfilerChanged'], 'True'),
eq(dependencies.generate_variables.outputs['generate_variables_job.generate_variables_step.IsDebuggerChanged'], 'True')
)
)
dependsOn: [build_windows_tracer, generate_variables]
Expand Down Expand Up @@ -844,8 +845,9 @@ stages:
succeeded(),
eq(variables['isScheduledBuild'], 'False'),
or(
eq(stageDependencies.generate_variables.generate_variables_job.outputs['generate_variables_step.IsProfilerChanged'], 'True'),
eq(stageDependencies.generate_variables.generate_variables_job.outputs['generate_variables_step.IsDebuggerChanged'], 'True')
eq(dependencies.generate_variables.outputs['generate_variables_job.generate_variables_step.IsTracerChanged'],'True'),
eq(dependencies.generate_variables.outputs['generate_variables_job.generate_variables_step.IsProfilerChanged'], 'True'),
eq(dependencies.generate_variables.outputs['generate_variables_job.generate_variables_step.IsDebuggerChanged'], 'True')
)
)
dependsOn: [build_linux, generate_variables]
Expand All @@ -861,6 +863,10 @@ stages:
pool:
vmImage: ubuntu-18.04

# Enable the Datadog Agent service for this job
services:
dd_agent: dd_agent

steps:
# Doing a clean of obj files _before_ restore to remove build output from previous runs
# Can't do a full clean, as otherwise restore-working-directory fails
Expand All @@ -886,20 +892,25 @@ stages:
displayName: docker-compose build ExplorationTests
env:
baseImage: $(baseImage)
azdo_network: $(agent.containernetwork)
inputs:
containerregistrytype: Container Registry
additionalDockerComposeFiles: docker-compose.ci.azdo.yml
dockerComposeCommand: build --build-arg baseImage=$(baseImage) --build-arg explorationTestUseCase=$(explorationTestUseCase) --build-arg explorationTestName=$(explorationTestName) --build-arg framework=$(publishTargetFramework) ExplorationTests

- task: DockerCompose@0
displayName: docker-compose run ExplorationTests
env:
azdo_network: $(agent.containernetwork)
inputs:
containerregistrytype: Container Registry
additionalDockerComposeFiles: docker-compose.ci.azdo.yml
dockerComposeFileArgs: |
baseImage=$(baseImage)
framework=$(publishTargetFramework)
explorationTestUseCase=$(explorationTestUseCase)
explorationTestName=$(explorationTestName)
dockerComposeCommand: run --rm -e baseImage=$(baseImage) -e explorationTestUseCase=$(explorationTestUseCase) -e explorationTestName=$(explorationTestName) -e framework=$(publishTargetFramework) ExplorationTests
dockerComposeCommand: run --rm -e DD_AGENT_HOST=dd_agent -e baseImage=$(baseImage) -e explorationTestUseCase=$(explorationTestUseCase) -e explorationTestName=$(explorationTestName) -e framework=$(publishTargetFramework) ExplorationTests

- task: DockerCompose@0
displayName: docker-compose stop services
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.ci.azdo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3'
services:
ExplorationTests:
networks:
- azdo_network

networks:
azdo_network:
external:
name: ${azdo_network}
65 changes: 63 additions & 2 deletions tracer/build/_build/Build.ExplorationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Nuke.Common;
using Nuke.Common.IO;
using Nuke.Common.Tools.DotNet;
Expand Down Expand Up @@ -45,6 +46,9 @@ void SetUpExplorationTest()
case global::ExplorationTestUseCase.ContinuousProfiler:
SetUpExplorationTest_ContinuousProfiler();
break;
case global::ExplorationTestUseCase.Tracer:
SetUpExplorationTest_Tracer();
break;
default:
throw new ArgumentOutOfRangeException(nameof(ExplorationTestUseCase), ExplorationTestUseCase, null);
}
Expand All @@ -62,6 +66,12 @@ void SetUpExplorationTest_ContinuousProfiler()
//TODO TBD
}

void SetUpExplorationTest_Tracer()
{
Logger.Info($"Prepare environment variables for tracer.");
//TODO TBD
}

void GitCloneBuild()
{
if (ExplorationTestName.HasValue)
Expand Down Expand Up @@ -148,6 +158,9 @@ Dictionary<string, string> GetEnvironmentVariables()
case global::ExplorationTestUseCase.ContinuousProfiler:
envVariables.AddContinuousProfilerEnvironmentVariables(TracerHomeDirectory);
break;
case global::ExplorationTestUseCase.Tracer:
envVariables.AddTracerEnvironmentVariables(TracerHomeDirectory);
break;
default:
throw new ArgumentOutOfRangeException(nameof(ExplorationTestUseCase), ExplorationTestUseCase, null);
}
Expand Down Expand Up @@ -212,6 +225,9 @@ void RunExplorationTestAssertions()
case global::ExplorationTestUseCase.ContinuousProfiler:
RunExplorationTestAssertions_ContinuousProfiler();
break;
case global::ExplorationTestUseCase.Tracer:
RunExplorationTestAssertions_Tracer();
break;
default:
throw new ArgumentOutOfRangeException(nameof(ExplorationTestUseCase), ExplorationTestUseCase, null);
}
Expand All @@ -228,17 +244,23 @@ void RunExplorationTestAssertions_ContinuousProfiler()
Logger.Info($"Running assertions tests for profiler.");
//TODO TBD
}

void RunExplorationTestAssertions_Tracer()
{
Logger.Info($"Running assertions tests for tracer.");
//TODO TBD
}
}


public enum ExplorationTestUseCase
{
Debugger, ContinuousProfiler
Debugger, ContinuousProfiler, Tracer
}

public enum ExplorationTestName
{
eShopOnWeb, protobuf, cake, swashbuckle, paket, /*ilspy*/
eShopOnWeb, protobuf, cake, swashbuckle, paket, RestSharp, serilog, polly, automapper, /*ilspy*/
}

class ExplorationTestDescription
Expand Down Expand Up @@ -272,6 +294,7 @@ public string GetTestTargetPath(AbsolutePath explorationTestsDirectory, TargetFr
}

public TargetFramework[] SupportedFrameworks { get; set; }
public OSPlatform[] SupportedOSPlatforms { get; set; }

public bool IsFrameworkSupported(TargetFramework targetFramework)
{
Expand Down Expand Up @@ -337,6 +360,44 @@ public static ExplorationTestDescription GetExplorationTestDescription(Explorati
TestsToIgnore = new[] { "Loading assembly metadata works" },
SupportedFrameworks = new[] { TargetFramework.NET461 },
},
ExplorationTestName.RestSharp => new ExplorationTestDescription()
{
Name = ExplorationTestName.RestSharp,
GitRepositoryUrl = "https://github.com/restsharp/RestSharp.git",
GitRepositoryTag = "107.0.3",
IsGitShallowCloneSupported = true,
PathToUnitTestProject = "test/RestSharp.Tests",
SupportedFrameworks = new[] { TargetFramework.NET6_0 },
},
ExplorationTestName.serilog => new ExplorationTestDescription()
{
Name = ExplorationTestName.serilog,
GitRepositoryUrl = "https://github.com/serilog/serilog.git",
GitRepositoryTag = "v2.10.0",
IsGitShallowCloneSupported = true,
PathToUnitTestProject = "test/Serilog.Tests",
TestsToIgnore = new[] { "DisconnectRemoteObjectsAfterCrossDomainCallsOnDispose" },
SupportedFrameworks = new[] { TargetFramework.NETCOREAPP3_1 },
},
ExplorationTestName.polly => new ExplorationTestDescription()
{
Name = ExplorationTestName.polly,
GitRepositoryUrl = "https://github.com/app-vnext/polly.git",
GitRepositoryTag = "7.2.2+9",
IsGitShallowCloneSupported = true,
PathToUnitTestProject = "src/Polly.Specs",
SupportedFrameworks = new[] { TargetFramework.NETCOREAPP3_1, TargetFramework.NET5_0, TargetFramework.NET461 },
},
ExplorationTestName.automapper => new ExplorationTestDescription()
{
Name = ExplorationTestName.automapper,
GitRepositoryUrl = "https://github.com/automapper/automapper.git",
GitRepositoryTag = "v11.0.0",
IsGitShallowCloneSupported = true,
PathToUnitTestProject = "src/UnitTests",
SupportedFrameworks = new[] { TargetFramework.NET6_0 },
SupportedOSPlatforms = new[] { OSPlatform.Windows },
},
//ExplorationTestName.ilspy => new ExplorationTestDescription()
//{
// Name = ExplorationTestName.ilspy,
Expand Down
1 change: 1 addition & 0 deletions tracer/build/_build/Build.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,7 @@ var name when multiPackageProjects.Contains(name) => false,
new(@".*at CallTargetNativeTest\.NoOp\.Noop\dArgumentsIntegration\.OnMethodEnd.*", RegexOptions.Compiled),
new(@".*at CallTargetNativeTest\.NoOp\.Noop\dArgumentsVoidIntegration\.OnMethodBegin.*", RegexOptions.Compiled),
new(@".*at CallTargetNativeTest\.NoOp\.Noop\dArgumentsVoidIntegration\.OnMethodEnd.*", RegexOptions.Compiled),
new(@".*System.Threading.ThreadAbortException: Thread was being aborted\.", RegexOptions.Compiled),
};

var logDirectory = BuildDataDirectory / "logs";
Expand Down
22 changes: 16 additions & 6 deletions tracer/build/_build/Build.VariableGenerations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Extensions.FileSystemGlobbing;
using Newtonsoft.Json;
Expand Down Expand Up @@ -30,14 +31,17 @@ Target GenerateVariables

void GenerateConditionVariables()
{
GenerateConditionVariableBasedOnGitChange("isDebuggerChanged", new[] { "tracer/src/Datadog.Trace.ClrProfiler.Native/Debugger" });
GenerateConditionVariableBasedOnGitChange("isProfilerChanged", new[] { "profiler/src" });
GenerateConditionVariableBasedOnGitChange("isTracerChanged", new[] { "tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation", "tracer/src/Datadog.Trace.ClrProfiler.Native" }, new[] { "tracer/src/Datadog.Trace.ClrProfiler.Native/Debugger" });
GenerateConditionVariableBasedOnGitChange("isDebuggerChanged", new[] { "tracer/src/Datadog.Trace.ClrProfiler.Native/Debugger" }, new string[] { });
GenerateConditionVariableBasedOnGitChange("isProfilerChanged", new[] { "profiler/src" }, new string[] { });

void GenerateConditionVariableBasedOnGitChange(string variableName, string[] filters)
void GenerateConditionVariableBasedOnGitChange(string variableName, string[] filters, string[] exclusionFilters)
{
var changedFiles = GetGitChangedFiles("origin/master");

var isChanged = filters.Any(filter => changedFiles.Any(s => s.Contains(filter)));
var isChanged = changedFiles.Any(s => filters.Any(filter => s.Contains(filter)) && !exclusionFilters.Any(filter => s.Contains(filter)));

// Choose changedFiles that meet any of the filters => Choose changedFiles that DON'T meet any of the exclusion filters

Logger.Info($"{variableName} - {isChanged}");

Expand Down Expand Up @@ -114,10 +118,16 @@ void GenerateIntegrationTestsLinuxMatrix()

void GenerateExplorationTestMatrices()
{
var isTracerChanged = bool.Parse(EnvironmentInfo.GetVariable<string>("isTracerChanged") ?? "false");
var isDebuggerChanged = bool.Parse(EnvironmentInfo.GetVariable<string>("isDebuggerChanged") ?? "false");
var isProfilerChanged = bool.Parse(EnvironmentInfo.GetVariable<string>("isProfilerChanged") ?? "false");

var useCases = new List<string>();
if (isTracerChanged)
{
useCases.Add(global::ExplorationTestUseCase.Tracer.ToString());
}

if (isDebuggerChanged)
{
useCases.Add(global::ExplorationTestUseCase.Debugger.ToString());
Expand Down Expand Up @@ -168,11 +178,11 @@ void GenerateExplorationTestsLinuxMatrix(IEnumerable<string> useCases)
{
foreach (var testDescription in testDescriptions)
{
if (testDescription.IsFrameworkSupported(targetFramework))
if (testDescription.IsFrameworkSupported(targetFramework) && (testDescription.SupportedOSPlatforms is null || testDescription.SupportedOSPlatforms.Contains(OSPlatform.Linux)))
{
matrix.Add(
$"{baseImage}_{targetFramework}_{explorationTestUseCase}_{testDescription.Name}",
new { baseImage = baseImage, targetFramework = targetFramework, explorationTestUseCase = explorationTestUseCase, explorationTestName = testDescription.Name });
new { baseImage = baseImage, publishTargetFramework = targetFramework, explorationTestUseCase = explorationTestUseCase, explorationTestName = testDescription.Name });
}
}
}
Expand Down

0 comments on commit f855c79

Please sign in to comment.