test: Add timeouts to methods that could wait forever in test/integration/fake_upstream.h.#3936
Conversation
Signed-off-by: Michael Behr <mkbehr@google.com>
Signed-off-by: Michael Behr <mkbehr@google.com>
| public: | ||
| void expectExtraHeaders(FakeStream& fake_stream) override { | ||
| fake_stream.waitForHeadersComplete(); | ||
| ASSERT(fake_stream.waitForHeadersComplete()); |
There was a problem hiding this comment.
This will be compiled out in release builds, which is not your intention, no?
There was a problem hiding this comment.
Right, yeah. Changed these to use RELEASE_ASSERT. Do you think it's worth adding a macro for this use? (RELEASE_ASSERT on an AssertionResult, using the AssertionResult's message as the RELEASE_ASSERT's message)
There was a problem hiding this comment.
ASSERT_TRUE will return from the helper function but keep the test running, so the test will probably crash anyway but in a more confusing way. (And for helpers that return things, like SquashFilterIntegrationTest::sendSquash, it won't compile.)
…rors. Signed-off-by: Michael Behr <mkbehr@google.com>
…eout Signed-off-by: Michael Behr <mkbehr@google.com>
|
Having some trouble figuring out why tests are passing on my machine but failing on circleci. |
|
The error for all those builds is: On line 345 of fake_upstream.h you add ABSL_MUST_USE_RESULT to the FakeConnectionBase::initialize() method (which returns a testing::AssertionResult). Because of the annotation, you must now do something with that AssertionResult at every call site. If it doesn't fail locally, perhaps your compiler doesn't support the annotation? |
RELEASE_ASSERT in AutonomousUpstream::createNetworkFilterChain; ABSL_MUST_USE_RESULT on FakeRawConnection::initialize Signed-off-by: Michael Behr <mkbehr@google.com>
…eout Signed-off-by: Michael Behr <mkbehr@google.com>
|
It's strange that the release build passes even though it ignores that value from autonomous_upstream.cc. It also builds fine on my machine, even though my compiler will complain about dropping results from ABSL_MUST_USE_RESULT in other places. But since the CI caught it I won't beat my head against this too long. |
|
There's at least one more instance of that problem, unfortunately. The ASAN, TSAN, Mac and (unexpectedly to me) IPv6 builds all use clang. Release and coverage use gcc. So that's why it only happens in those builds. |
|
I'll get the ci builds running on my machine so I can test with them directly. |
Signed-off-by: Michael Behr <mkbehr@google.com>
…eout Signed-off-by: Michael Behr <mkbehr@google.com>
…e-upstream-timeout Signed-off-by: Michael Behr <mkbehr@google.com>
zuercher
left a comment
There was a problem hiding this comment.
Looks good! Some minor changes I'd like to see.
test/integration/fake_upstream.h
Outdated
| void waitForReset(); | ||
| ABSL_MUST_USE_RESULT | ||
| testing::AssertionResult | ||
| waitForHeadersComplete(std::chrono::milliseconds timeout = std::chrono::milliseconds(10000)); |
There was a problem hiding this comment.
Consider replacing std::chrono::milliseconds(10000) with a static constant.
Also I think it would be easier to read these 3-line declarations if they had a blank line between them.
There was a problem hiding this comment.
Done (and the rest of these too).
test/test_common/utility.h
Outdated
| } while (false) | ||
|
|
||
| #define VERIFY_ASSERTION(statement) \ | ||
| { \ |
There was a problem hiding this comment.
do { ... } while(false) as in the other macros. (This will force VERIFY_ASSERTION() to be followed by a semicolon in all cases, which I think we want.)
test/integration/fake_upstream.h
Outdated
| // wishes to wait for a new stream, set ignore_spurious_events = true. | ||
| ABSL_MUST_USE_RESULT | ||
| testing::AssertionResult | ||
| waitForNewStream(Event::Dispatcher& client_dispatcher, FakeStreamPtr* stream, |
There was a problem hiding this comment.
Our style guide prefers using a reference for connection here, since it can't be nullptr. Also add a comment indicating that the connection is returned via the reference. (Likewise for waitForRawConnection and waitForHttpConnection.)
…e-upstream-timeout Signed-off-by: Michael Behr <mkbehr@google.com>
- Static constant for default timeouts - do while false for VERIFY_ASSERTION - Reference for output arguments in waitForNewStream et al. Signed-off-by: Michael Behr <mkbehr@google.com>
…e-upstream-timeout Signed-off-by: Michael Behr <mkbehr@google.com>
zuercher
left a comment
There was a problem hiding this comment.
Looks good. Thanks for taking this on.
Description: Part of work for #3809. This changes methods that wait for something to happen, in FakeUpstream and related classes, so that they take an optional timeout arg. Timeouts default to 10 seconds. The methods now all return AssertionResults, marked with ABSL_MUST_USE_RESULT to require tests to check for failure. Methods that used to return something else now use an output argument.
Risk Level: Low (test-only, will break builds)
Testing: bazel test //test/...
Docs Changes: n/a
Release Notes: n/a