Skip to content

Commit 164ddfd

Browse files
BrennanConroyanalogrelay
authored andcommitted
Fix flaky LongPolling tests (#14395)
1 parent 0269733 commit 164ddfd

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

src/SignalR/common/testassets/Tests.Utils/VerifyNoErrorsScope.cs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -34,6 +34,32 @@ public void Dispose()
3434

3535
var results = _sink.GetLogs().Where(w => w.Write.LogLevel >= LogLevel.Error).ToList();
3636

37+
#if NETCOREAPP2_1 || NETCOREAPP2_2 || NET461
38+
// -- Remove this code after 2.2 --
39+
// This section of code is resolving test flakiness caused by a race in LongPolling
40+
// The race has been resolved in version 3.0
41+
// The below code tries to find is a DELETE request has arrived from the client before removing error logs associated with the race
42+
// We do this because we don't want to hide any actual issues, but we feel confident that looking for DELETE first wont hide any real problems
43+
var foundDelete = false;
44+
var allLogs = _sink.GetLogs();
45+
foreach (var log in allLogs)
46+
{
47+
if (foundDelete == false && log.Write.Message.Contains("Request starting") && log.Write.Message.Contains("DELETE"))
48+
{
49+
foundDelete = true;
50+
}
51+
52+
if (foundDelete)
53+
{
54+
if ((log.Write.EventId.Name == "LongPollingTerminated" || log.Write.EventId.Name == "ApplicationError" || log.Write.EventId.Name == "FailedDispose")
55+
&& log.Write.Exception?.Message.Contains("Reading is not allowed after reader was completed.") == true)
56+
{
57+
results.Remove(log);
58+
}
59+
}
60+
}
61+
#endif
62+
3763
if (_expectedErrorsFilter != null)
3864
{
3965
results = results.Where(w => !_expectedErrorsFilter(w.Write)).ToList();
@@ -64,4 +90,4 @@ public void Dispose()
6490
}
6591
}
6692
}
67-
}
93+
}

0 commit comments

Comments
 (0)