Skip to content

Commit f412953

Browse files
chrisnasveerbia
authored andcommitted
[Profiler] Avoid ETW tests flackiness (#6368)
## Summary of changes Pick a less CPU intensive scenario and increase test timeout ## Reason for change The previous version of the tests showed that the agent proxy was not able to asynchronously send the recorded events before the test ends. ## Implementation details Increase the timeout so the profiled application lives long enough to receive the recorded events ## Test coverage yes ## Other details <!-- Fixes #{issue} --> <!-- ⚠️ Note: where possible, please obtain 2 approvals prior to merging. Unless CODEOWNERS specifies otherwise, for external teams it is typically best to have one review from a team member, and one review from apm-dotnet. Trivial changes do not require 2 reviews. -->
1 parent 4c96771 commit f412953

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

profiler/test/Datadog.Profiler.IntegrationTests/Allocations/AllocationsProfilerTest.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class AllocationsProfilerTest
1818
{
1919
private const string ScenarioGenerics = "--scenario 9";
2020
private const string ScenarioMeasureAllocation = "--scenario 16";
21-
private const string ScenarioWithoutGC = "--scenario 25 --threads 2 --param 1000";
21+
private const string ScenarioWithoutGC = "--scenario 6 --threads 1";
2222

2323
private readonly ITestOutputHelper _output;
2424

@@ -130,6 +130,8 @@ public void MeasureAllocations(string appName, string framework, string appAssem
130130
public void ShouldGetAllocationSamplesViaEtw(string appName, string framework, string appAssembly)
131131
{
132132
var runner = new TestApplicationRunner(appName, framework, appAssembly, _output, commandLine: ScenarioWithoutGC);
133+
// allow agent proxy to send the recorded events
134+
runner.TestDurationInSeconds = 30;
133135

134136
EnvironmentHelper.DisableDefaultProfilers(runner);
135137
runner.Environment.SetVariable(EnvironmentVariables.AllocationProfilerEnabled, "1");

profiler/test/Datadog.Profiler.IntegrationTests/Contention/ContentionProfilerTest.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Datadog.Profiler.IntegrationTests.Contention
1515
public class ContentionProfilerTest
1616
{
1717
private const string ScenarioContention = "--scenario 10 --threads 20";
18-
private const string ScenarioWithoutContention = "--scenario 25 --threads 2 --param 1000";
18+
private const string ScenarioWithoutContention = "--scenario 6 --threads 1";
1919

2020
private readonly ITestOutputHelper _output;
2121

@@ -90,6 +90,8 @@ public void ExplicitlyDisableContentionProfiler(string appName, string framework
9090
public void ShouldGetLockContentionSamplesViaEtw(string appName, string framework, string appAssembly)
9191
{
9292
var runner = new TestApplicationRunner(appName, framework, appAssembly, _output, commandLine: ScenarioWithoutContention);
93+
// allow agent proxy to send the recorded events
94+
runner.TestDurationInSeconds = 30;
9395

9496
EnvironmentHelper.DisableDefaultProfilers(runner);
9597
runner.Environment.SetVariable(EnvironmentVariables.ContentionProfilerEnabled, "1");

profiler/test/Datadog.Profiler.IntegrationTests/GarbageCollections/GarbageCollectionsProfilerTest.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Datadog.Profiler.IntegrationTests.GarbageCollections
1414
public class GarbageCollectionsProfilerTest
1515
{
1616
private const string ScenarioGenerics = "--scenario 12";
17-
private const string ScenarioWithoutGC = "--scenario 25 --threads 2 --param 1000";
17+
private const string ScenarioWithoutGC = "--scenario 6 --threads 1";
1818
private const string GcRootFrame = "|lm: |ns: |ct: |cg: |fn:Garbage Collector |fg: |sg:";
1919

2020
private readonly ITestOutputHelper _output;
@@ -62,6 +62,8 @@ public void ShouldGetGarbageCollectionSamplesByDefault(string appName, string fr
6262
public void ShouldGetGarbageCollectionSamplesViaEtw(string appName, string framework, string appAssembly)
6363
{
6464
var runner = new TestApplicationRunner(appName, framework, appAssembly, _output, commandLine: ScenarioWithoutGC);
65+
// allow agent proxy to send the recorded events
66+
runner.TestDurationInSeconds = 30;
6567

6668
// disable default profilers except GC
6769
runner.Environment.SetVariable(EnvironmentVariables.WallTimeProfilerEnabled, "0");

0 commit comments

Comments
 (0)