Skip to content

http: testing failed writes#19021

Merged
alyssawilk merged 5 commits intoenvoyproxy:mainfrom
alyssawilk:socket_fail
Dec 1, 2021
Merged

http: testing failed writes#19021
alyssawilk merged 5 commits intoenvoyproxy:mainfrom
alyssawilk:socket_fail

Conversation

@alyssawilk
Copy link
Copy Markdown
Contributor

Risk Level: n/a (test only)
Testing: new integration test
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Copy Markdown
Contributor Author

cc @danzh2010

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

I'm a little bit worried that this test could be flaky. If anything in the process opens a file descriptor for any reason after close(), the fd could become valid again and result in unexpected behavior.

Another possible way to test would be to set a mock API that returns EINVAL or something from syscalls just for this one fd.


// Touches raw sockets.
#ifndef WIN32
TEST_P(DownstreamProtocolIntegrationTest, HandleSocketFail) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment on what this is testing?

class OnSocketFailFilter : public Http::PassThroughFilter {
public:
Http::FilterHeadersStatus encodeHeaders(Http::ResponseHeaderMap&, bool) override {
close(fd());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add comment on why this doesn't call ioHandle()->close() (so that IoHandle doesn't know the fd is invalid).

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

LGTM

@alyssawilk alyssawilk merged commit a02d3ce into envoyproxy:main Dec 1, 2021
@alyssawilk alyssawilk deleted the socket_fail branch August 4, 2022 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants