Skip to content

Commit 43f945b

Browse files
authored
Fix missing sync to async changes (#7157)
## Summary of changes This PR complete the missing sync to async changes from the previous PR ## Reason for change I missed a couple of them ## Implementation details ## Test coverage ## 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. --> --------- Signed-off-by: Tony Redondo <[email protected]>
1 parent b77b4d6 commit 43f945b

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/DynamicConfigurationTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ static string FlattenJsonArray(JToken json)
221221
json["tags"]?.ToString(Formatting.None).Should().Be(expectedConfig.GlobalTags ?? "[]");
222222
}
223223

224-
WaitForTelemetry(agent);
224+
await WaitForTelemetryAsync(agent);
225225

226-
AssertConfigurationChanged(agent.Telemetry, config);
226+
await AssertConfigurationChangedAsync(agent.Telemetry, config);
227227
}
228228

229-
private bool WaitForTelemetry(MockTracerAgent agent)
229+
private async Task<bool> WaitForTelemetryAsync(MockTracerAgent agent)
230230
{
231231
var deadline = DateTime.UtcNow.AddSeconds(20);
232232

@@ -240,13 +240,13 @@ private bool WaitForTelemetry(MockTracerAgent agent)
240240
}
241241
}
242242

243-
Thread.Sleep(500);
243+
await Task.Delay(500);
244244
}
245245

246246
return false;
247247
}
248248

249-
private void AssertConfigurationChanged(ConcurrentStack<object> events, Config config)
249+
private async Task AssertConfigurationChangedAsync(ConcurrentStack<object> events, Config config)
250250
{
251251
var expectedKeys = new List<(string Key, object Value)>
252252
{
@@ -297,7 +297,7 @@ private void AssertConfigurationChanged(ConcurrentStack<object> events, Config c
297297

298298
if (latestConfig.Count < expectedCount)
299299
{
300-
Thread.Sleep(500);
300+
await Task.Delay(500);
301301
}
302302
}
303303

tracer/test/Datadog.Trace.Debugger.IntegrationTests/AspNetBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ protected async Task<IImmutableList<MockSpan>> SendRequestsAsync(MockTracerAgent
7878
var minDateTime = DateTime.UtcNow; // when ran sequentially, we get the spans from the previous tests!
7979
await SendRequestsAsyncNoWaitForSpans(url, body, numberOfAttacks, contentType, userAgent);
8080

81-
return WaitForSpans(agent, expectedSpans, phase, minDateTime, url);
81+
return await WaitForSpansAsync(agent, expectedSpans, phase, minDateTime, url);
8282
}
8383

84-
protected IImmutableList<MockSpan> WaitForSpans(MockTracerAgent agent, int expectedSpans, string phase, DateTime minDateTime, string url)
84+
protected async Task<IImmutableList<MockSpan>> WaitForSpansAsync(MockTracerAgent agent, int expectedSpans, string phase, DateTime minDateTime, string url)
8585
{
8686
agent.SpanFilters.Clear();
8787

@@ -90,7 +90,7 @@ protected IImmutableList<MockSpan> WaitForSpans(MockTracerAgent agent, int expec
9090
agent.SpanFilters.Add(s => s.Tags.ContainsKey("http.url") && s.Tags["http.url"].IndexOf(url, StringComparison.InvariantCultureIgnoreCase) > -1);
9191
}
9292

93-
var spans = agent.WaitForSpans(expectedSpans, minDateTime: minDateTime);
93+
var spans = await agent.WaitForSpansAsync(expectedSpans, minDateTime: minDateTime);
9494
if (spans.Count != expectedSpans)
9595
{
9696
Output?.WriteLine($"spans.Count: {spans.Count} != expectedSpans: {expectedSpans}, this is phase: {phase}");

tracer/test/Datadog.Trace.Debugger.IntegrationTests/ProbesTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ private async Task VerifySpanDecorationResults(DebuggerSampleProcessHelper sampl
575575
var testName = isMultiPhase ? $"{testDescription.TestType.Name}_#{phaseNumber}." : testDescription.TestType.Name;
576576
settings.UseFileName($"{nameof(ProbeTests)}.{testName}.{testNameSuffix}");
577577

578-
var spans = agent.WaitForSpans(expectedSpanCount);
578+
var spans = await agent.WaitForSpansAsync(expectedSpanCount);
579579

580580
Assert.Equal(expectedSpanCount, spans.Count);
581581

@@ -616,7 +616,7 @@ private async Task VerifySpanProbeResults(ProbeDefinition[] snapshotProbes, Prob
616616
var testName = isMultiPhase ? $"{testDescription.TestType.Name}_#{phaseNumber}." : testDescription.TestType.Name;
617617
settings.UseFileName($"{nameof(ProbeTests)}.{testName}.Spans");
618618

619-
var spans = agent.WaitForSpans(spanProbes.Length, operationName: spanProbeOperationName);
619+
var spans = await agent.WaitForSpansAsync(spanProbes.Length, operationName: spanProbeOperationName);
620620
// Assert.Equal(spanProbes.Length, spans.Count);
621621
foreach (var span in spans)
622622
{

tracer/test/Datadog.Trace.Security.IntegrationTests/ApiSecurity/AspNetCore2ApiSecurity.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ namespace Datadog.Trace.Security.IntegrationTests.ApiSecurity
1919
public class AspNetCore2ApiSecurityEnabled : AspNetCoreApiSecurity
2020
{
2121
public AspNetCore2ApiSecurityEnabled(AspNetCoreTestFixture fixture, ITestOutputHelper outputHelper)
22-
: base(fixture, outputHelper, true, "AspNetCore2")
22+
: base(fixture, outputHelper, true, true, "AspNetCore2")
2323
{
2424
}
2525
}
2626

2727
public class AspNetCore2ApiSecurityDisabled : AspNetCoreApiSecurity
2828
{
2929
public AspNetCore2ApiSecurityDisabled(AspNetCoreTestFixture fixture, ITestOutputHelper outputHelper)
30-
: base(fixture, outputHelper, false, sampleName: "AspNetCore2")
30+
: base(fixture, outputHelper, false, true, sampleName: "AspNetCore2")
3131
{
3232
}
3333
}

tracer/test/Datadog.Trace.Security.IntegrationTests/AspNetMvc5RateLimiter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public async Task TestRateLimiterSecurity(int totalRequests, string url = Defaul
124124
// tracing module and mvc actions
125125
await TestRateLimiter(_enableSecurity, url, _iisFixture.Agent, _traceRateLimit.GetValueOrDefault(100), totalRequests, 2);
126126
// have to wait a second for the rate limiter to reset (or restart iis express completely)
127-
Thread.Sleep(1000);
127+
await Task.Delay(1_000);
128128
}
129129

130130
public async Task InitializeAsync()

tracer/test/Datadog.Trace.Tests/Agent/MovingAverageKeepRateCalculatorTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void Calculator_ShouldHandleOverflows()
8787
}
8888

8989
[Fact(Skip = "Flaky as is very timing/load dependent")]
90-
public void Calculator_ShouldUpdateAutomatically()
90+
public async Task Calculator_ShouldUpdateAutomatically()
9191
{
9292
const int bucketSize = 10;
9393
const int bucketDuration = 10;
@@ -112,12 +112,12 @@ public void Calculator_ShouldUpdateAutomatically()
112112
break;
113113
}
114114

115-
Thread.Sleep(5);
115+
await Task.Delay(5);
116116
}
117117

118118
Assert.True(updatedKeepRate, "Keep rate was not updated automatically");
119119

120-
Thread.Sleep(bucketDuration * bucketSize);
120+
await Task.Delay(bucketDuration * bucketSize);
121121

122122
// buckets should all be empty again now
123123
Assert.Equal(0, calc.GetKeepRate());

tracer/test/Datadog.Trace.Tests/DataStreamsMonitoring/DataStreamsManagerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ public void WhenEnabled_TracksBacklog()
123123
}
124124

125125
[Fact]
126-
public void WhenEnabled_TimeInQueueIsNotUsedForSecondCheckpoint()
126+
public async Task WhenEnabled_TimeInQueueIsNotUsedForSecondCheckpoint()
127127
{
128128
long latencyMs = 100;
129129
var latencyNs = latencyMs * 1_000_000;
130130

131131
var dsm = GetDataStreamManager(true, out var writer);
132132
var parent = dsm.SetCheckpoint(parentPathway: null, CheckpointKind.Consume, new[] { "some-tags" }, 100, latencyMs);
133-
Thread.Sleep(1);
133+
await Task.Delay(1);
134134
dsm.SetCheckpoint(parentPathway: parent, CheckpointKind.Consume, new[] { "some-tags" }, 100, latencyMs);
135135

136136
writer.Points.Should().HaveCount(2);

tracer/test/Datadog.Trace.Tests/Util/ClockTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Datadog.Trace.Tests.Util
1919
public class ClockTests
2020
{
2121
[Fact]
22-
public void Should_use_real_clock_if_not_overriden()
22+
public async Task Should_use_real_clock_if_not_overriden()
2323
{
2424
// If everything works, the fastpath should be used and this clock ignored
2525
using var lease = Clock.SetForCurrentThread(new SimpleClock());
@@ -29,7 +29,7 @@ public void Should_use_real_clock_if_not_overriden()
2929

3030
var now = Clock.UtcNow;
3131

32-
Thread.Sleep(100);
32+
await Task.Delay(100);
3333

3434
var then = Clock.UtcNow;
3535

0 commit comments

Comments
 (0)