Skip to content

Fix flaky LongPolling tests #14395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand Down Expand Up @@ -34,6 +34,32 @@ public void Dispose()

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

#if NETCOREAPP2_1 || NETCOREAPP2_2 || NET461
// -- Remove this code after 2.2 --
// This section of code is resolving test flakiness caused by a race in LongPolling
// The race has been resolved in version 3.0
// The below code tries to find is a DELETE request has arrived from the client before removing error logs associated with the race
// 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
var foundDelete = false;
var allLogs = _sink.GetLogs();
foreach (var log in allLogs)
{
if (foundDelete == false && log.Write.Message.Contains("Request starting") && log.Write.Message.Contains("DELETE"))
{
foundDelete = true;
}

if (foundDelete)
{
if ((log.Write.EventId.Name == "LongPollingTerminated" || log.Write.EventId.Name == "ApplicationError" || log.Write.EventId.Name == "FailedDispose")
&& log.Write.Exception?.Message.Contains("Reading is not allowed after reader was completed.") == true)
{
results.Remove(log);
}
}
}
#endif

if (_expectedErrorsFilter != null)
{
results = results.Where(w => !_expectedErrorsFilter(w.Write)).ToList();
Expand Down Expand Up @@ -64,4 +90,4 @@ public void Dispose()
}
}
}
}
}