Skip to content

Commit ff8ac4c

Browse files
committed
improving AppInsights test
1 parent e9c83ce commit ff8ac4c

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

test/WebJobs.Script.Tests.Integration/ApplicationInsights/ApplicationInsightsEndToEndTestsBase.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,20 @@ public async Task Validate_HostLogs()
222222
{
223223
// Validate the host startup traces. Order by message string as the requests may come in
224224
// slightly out-of-order or on different threads
225-
TraceTelemetry[] traces = _fixture.Channel.Telemetries
226-
.OfType<TraceTelemetry>()
227-
.Where(t => t.Context.Operation.Id == null)
228-
.OrderBy(t => t.Message)
229-
.ToArray();
225+
TraceTelemetry[] traces = null;
226+
227+
await TestHelpers.Await(() =>
228+
{
229+
traces = _fixture.Channel.Telemetries
230+
.OfType<TraceTelemetry>()
231+
.Where(t => t.Context.Operation.Id == null)
232+
.OrderBy(t => t.Message)
233+
.ToArray();
234+
235+
return traces.Length >= 10;
236+
});
230237

231-
Assert.Equal(10, traces.Length);
238+
Assert.True(traces.Length == 10, $"Expected 10 messages, but found {traces.Length}. Actual logs:{Environment.NewLine}{string.Join(Environment.NewLine, traces.Select(t => t.Message))}");
232239

233240
ValidateTrace(traces[0], "Found the following functions:\r\n", LogCategories.Startup);
234241
ValidateTrace(traces[1], "Generating 2 job function(s)", LogCategories.Startup);

0 commit comments

Comments
 (0)