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

Ext_Proc : Adding integration test with MxN streaming enabled in both directions #37771

Merged
merged 6 commits into from
Dec 23, 2024

Conversation

yanjunxiang-google
Copy link
Contributor

Ext_Proc : Adding integration test with MxN streaming enabled in both directions

fixes issue: #37770

@yanjunxiang-google
Copy link
Contributor Author

/assign @yanavlasov @tyxia

@yanjunxiang-google
Copy link
Contributor Author

/assign @jmarantz

Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

flushing comments.

void serverReceiveHeaderDuplexStreamed(ProcessingRequest& header, bool first_message = true,
bool response = false) {
if (first_message) {
EXPECT_TRUE(grpc_upstreams_[0]->waitForHttpConnection(*dispatcher_, processor_connection_));
Copy link
Contributor

Choose a reason for hiding this comment

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

A pattern I use sometimes when looking at expectations in a helper function is to provide more context by doing << something in the EXPECT call. That way, if you have multiple calls to it from the same test method, and one of them fails, you'll know which one. You might pass a string for something into the function, or compute something from the args.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For waitForHttpConnection() and waitForNewStream(), these functions are already returning those "something", and printed out in the log, for example:

return AssertionFailure() << "Timed out waiting for new connection.";
.

I added << "something in the below two places.

EXPECT_TRUE(processor_connection_->waitForNewStream(*dispatcher_, processor_stream_));
}
EXPECT_TRUE(processor_stream_->waitForGrpcMessage(*dispatcher_, header));
if (!response) {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove the ! and flip the then/else clauses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

ProcessingResponse response_header;
auto* header_resp = response_header.mutable_request_headers();
HeadersResponse* header_resp;
if (!response) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@yanavlasov
Copy link
Contributor

/wait

Signed-off-by: Yanjun Xiang <[email protected]>
}
end_stream = body_request.response_body().end_of_stream();
} else {
EXPECT_TRUE(body_request.has_request_body()) << "Request does not have request_body \n";
Copy link
Contributor

Choose a reason for hiding this comment

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

you missed the point of what I was suggesting. If there's a failure, it will give the line number of the EXPECT but not the stack.

You have multiple call-sites to this function, so to disambiugate a failure you need to pass something from those call-sites to then put in the EXPECT annotation.

Copy link
Contributor Author

@yanjunxiang-google yanjunxiang-google Dec 20, 2024

Choose a reason for hiding this comment

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

If there is a test failure in these integration tests, the way I debug this is running the test with the trace logs enabled, which will give us the entire ext_proc state machine change sequence. And the error will be obvious by checking the logs in the context.

Copy link
Contributor Author

@yanjunxiang-google yanjunxiang-google Dec 20, 2024

Choose a reason for hiding this comment

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

For example, If I deliberately cause an error here, below are the logs are I saw. The logs give us enough info to know what's wrong:

[2024-12-20 19:02:23.127][16][debug][testing] [./test/integration/fake_upstream.h:182] Received gRPC message: request_body {
body: "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss"
}
metadata_context {
}

test/extensions/filters/http/ext_proc/ext_proc_integration_test.cc:778: Failure
Value of: body_request.has_request_body()
Actual: true
Expected: false

Stack trace:
0x3c12563: Envoy::ExtProcIntegrationTest::serverReceiveBodyDuplexStreamed()
0x3ac81c7: Envoy::ExtProcIntegrationTest_ServerWaitForBodyBeforeSendsHeaderRespDuplexStreamed_Test::TestBody()
0x9321bfb: testing::internal::HandleSehExceptionsInMethodIfSupported<>()
0x9311dfa: testing::internal::HandleExceptionsInMethodIfSupported<>()
0x92fdcd3: testing::Test::Run()
0x92fe684: testing::TestInfo::Run()
... Google Test internal frames ...

[2024-12-20 19:02:23.127][16][debug][testing] [./test/integration/fake_upstream.h:190] Waiting for gRPC message...

Copy link
Contributor

Choose a reason for hiding this comment

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

I was trying to suggest a pattern that would make test failures easier to diagnose even if you don't have deep knowledge.

It's not essential -- you could also use a debugger to figure out where the failure was. I just thought it might be easier for others without deep context to debug if you made it explicit.

@yanavlasov yanavlasov merged commit 00281d1 into envoyproxy:main Dec 23, 2024
24 checks passed
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.

4 participants