Skip to content
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

Redisign HTTP/2 KeepAlive PING tests #56736

Merged
merged 12 commits into from
Aug 6, 2021

Conversation

antonfirsov
Copy link
Member

@antonfirsov antonfirsov commented Aug 2, 2021

Completely redesign tests for HTTP/2 KeepAlive PING, so they:

  • Work well with RTT pings introduced in Implement dynamic HTTP/2 window scaling #54755
  • Run sequentially, reducing the chance of failing because of timing issues caused by parallel workloads
  • Are better organized: multiple test cases for different scenarios, instead of one theory with complex branches on parameters

I used a similar pattern as in the dynamic window PR: instead of reading / reacting to frames inline, there is a separate Task for processing incoming frames, responding to PING immediately and pushing other frames to a Channel<Frame>.

Fixes #41929

@ghost
Copy link

ghost commented Aug 2, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Completely redesign tests for HTTP/2 KeepAlive PING, so they:

I used a similar pattern as in the dynamic window PR: instead of reading / reacting frames inline, there is a separate Task for processing incoming frames, reacting immediately to PING.

Fixes #41929

Author: antonfirsov
Assignees: -
Labels:

area-System.Net.Http

Milestone: -

@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@antonfirsov antonfirsov requested a review from a team August 3, 2021 12:26
Copy link
Contributor

@alnikola alnikola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to get rid of fixed time delays to speed up tests?

DisablePingResponse();

// Simulate inactive period:
await Task.Delay(6_000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need such long delay here? Is there any way to implement this on synchronization primitives like AutoResetEvent, ManualResetEvent, etc?

Copy link
Member Author

@antonfirsov antonfirsov Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need such long delay here?

By having a big difference between the KeepAlivePingDelay and making sure the tests runs sequentially, we can be relatively safe from CI timing issues. Removing any of these conditions will lead to certain failures IMO.

Note that he minimum value for KeepAlivePingDelay and KeepAlivePingTimeout is 1 sec, so I can't make this faster by using low delay values

Is there any way to implement this on synchronization primitives

I don't see how. The API exposes TimeSpan parameters without any testability-focused abstractions that would allow us to use events.

I understand that the extra ~1 minute added here is very bad from testing perspective, but the only alternative I see is to remove the KeepAlive tests, which means loosing coverage. I wish we used whitebox testing techniques in dotnet/runtime ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I got it.

if (policy == HttpKeepAlivePingPolicy.Always)
{
// Simulate inactive period:
await Task.Delay(5_000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same about a long delay here.

await Task.Delay(5_000);

// We may have received one RTT PING in response to HEADERS, but should receive no KeepAlive PING
Assert.True(_pingCounter <= 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we count only PINGs relevant to this test and ignore RTT ones? AFAIR, they should have different payload and be distinguishable, no?

Copy link
Member Author

@antonfirsov antonfirsov Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to avoid taking a test-dependency on such an arbitrary implementation detail.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually like the idea of leveraging the different ranges for KeepAlive (>0) and RTT (<0) in tests 😄
We're already counting on details like heartbeat interval and timings, so this doesn't seem to me like something dangerous.

Copy link
Contributor

@alnikola alnikola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have some outerloop runs after the latest changes?

Otherwise looks good, thanks.

@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@antonfirsov
Copy link
Member Author

Outerloop failures are unrelated, mostly instances of #54260

@antonfirsov antonfirsov merged commit a8baca1 into dotnet:main Aug 6, 2021
@karelz karelz added this to the 6.0.0 milestone Aug 17, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants