-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
proto: Add PATCH method to RequestMethod enum #6737
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good. I'm wondering if we can solidify this by adding a test. @junr03 thoughts?
Yes, it would be good. Couldn't think of appropriate place to test it though, will be glad to hear suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @venilnoronha, it would be nice to add some testing here so that we verify completeness. There is some prior art around response flags that you can take inspiration from. Let us know if you need some pointers.
will it be tested there? @junr03 said that text logs work without proto so it seems that tests for access_log will work anyway. It probably makes sense to test the part that works with proto to make sure it really works. Or do this tests actually work with proto and I'm missing something here? |
I think @venilnoronha linked for inspiration, not necessarily suggesting that the test would be written there. Yes, those tests are not for the ALS, they are for text logs. I haven't looked closely at the test suite for the ALS, let me know if you'd like me to take a look for guidance. |
Added test similar to the part below that checks METHOD_UNSPECIFIED However, I see that in the part below "request_headers" is initialized but not passed to access_log_->log (nullptr is passed instead). And when I modified it to pass headers, new field "request_headers_bytes" appeared in the result and test failed. I guess it just doesn't work correctly right now, what do you think? |
@glebmish what if: Create a TEST_F(HttpGrpcAccessLogTest, LogWithRequestMethod) {
InSequence s;
expectLogRequestMethod("GET");
expectLogRequestMethod("HEAD");
expectLogRequestMethod("POST");
expectLogRequestMethod("PUT");
expectLogRequestMethod("DELETE");
expectLogRequestMethod("CONNECT");
expectLogRequestMethod("OPTIONS");
expectLogRequestMethod("TRACE");
expectLogRequestMethod("PATCH");
} The body of NiceMock<StreamInfo::MockStreamInfo> stream_info;
stream_info.host_ = nullptr;
Http::TestHeaderMapImpl request_headers{
{":scheme", "scheme_value"},
{":authority", "authority_value"},
{":path", "path_value"},
{":method", request_method},
};
expectLog(fmt::format(R"EOF(
// !!!TODO: replace with the expected structured log here (yes in yaml format). The `fmt::format` helps you to build the string. hint: {} as placeholder, while {{}} to escape.
)EOF",
request_method, /* more parameters here, hint: related to `request_headers_bytes` */ ));
access_log_->log(&request_headers, nullptr, nullptr, stream_info); WDYT? |
@dio it looks good, I can do that. Do you think it also make sense to move METHOD_UNSPECIFIED there? Something like |
You can be as creative as you want 😄.
I think those two tests check different things i.e. the second one checks on marshaling |
@dio added changes you proposed, thanks! Decided to leave METHOD_UNSPECIFIED tests as it is, just fixed them there. |
I see failed test suites, but I can't understand the reason. Can somebody help me with this? |
@glebmish I think you need to run the formatter. In this case against this file: test/extensions/access_loggers/http_grpc/grpc_access_log_impl_test.cc.
Then add and commit that. The following is the diff after the format is fixed: diff --git a/test/extensions/access_loggers/http_grpc/grpc_access_log_impl_test.cc b/test/extensions/access_loggers/http_grpc/grpc_access_log_impl_test.cc
index 89423934e..5aa545b12 100644
--- a/test/extensions/access_loggers/http_grpc/grpc_access_log_impl_test.cc
+++ b/test/extensions/access_loggers/http_grpc/grpc_access_log_impl_test.cc
@@ -143,7 +143,7 @@ public:
stream_info.host_ = nullptr;
Http::TestHeaderMapImpl request_headers{
- {":method", request_method},
+ {":method", request_method},
};
expectLog(fmt::format(R"EOF(
@@ -163,7 +163,8 @@ public:
request_method: {}
request_headers_bytes: {}
response: {{}}
- )EOF", request_method, request_method.length() + 7));
+ )EOF",
+ request_method, request_method.length() + 7));
access_log_->log(&request_headers, nullptr, nullptr, stream_info);
} |
@dio thank you! fixed |
I see that coverage suite is failing with exit code 36. I took a look on bazel exit codes and it seems like it some environment issue, I guess some process is not stopping correctly. What can I do about it? https://docs.bazel.build/versions/master/guide.html
|
/retest |
🔨 rebuilding |
Well, it doesn't seem to be healed by restart :(
Did you see this in other PRs? If it's something with environment it should probably fail everywhere |
@glebmish hum, while investigating the build errors, would you mind to merge master? |
Signed-off-by: glebmish <glebmish@yandex-team.ru>
Signed-off-by: glebmish <glebmish@yandex-team.ru>
Signed-off-by: glebmish <glebmish@yandex-team.ru>
Signed-off-by: glebmish <glebmish@yandex-team.ru>
Signed-off-by: glebmish <glebmish@yandex-team.ru>
@dio it definitely helped, thanks! Now I understand what's the problem there, coverage is less than threshold. This is funny, I added 1 line of code and several tests and somehow decreased coverage :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the coverage issues are broken in master and we are working on them. I will just force merge this for you. Thank you!
thanks @mattklein123 ! |
* master: (65 commits) proto: Add PATCH method to RequestMethod enum (envoyproxy#6737) exe: drop unused deps on zlib compressor code (envoyproxy#7022) coverage: fix some misc coverage (envoyproxy#7033) Enable proto schema for router_check_tool (envoyproxy#6992) stats: rework stat sink flushing to centralize counter latching (envoyproxy#6996) [test] convert lds api test config stubs to v2 (envoyproxy#7021) router: scoped rds (2c): implement scoped rds API (envoyproxy#6932) build: Add option for size-optimized binary (envoyproxy#6960) test: adding an integration test framework for file-based LDS (envoyproxy#6933) doc: update obsolete ref to api/XDS_PROTOCOL.md (envoyproxy#7002) dispatcher: faster runOnAllThreads (envoyproxy#7011) example: add csrf sandbox (envoyproxy#6805) fix syntax of gcov exclusion zone. (envoyproxy#7023) /runtime_modify: add support for query params in body (envoyproxy#6977) stats: Create stats for http codes with the symbol table. (envoyproxy#6733) health check: fix more fallout from inline deletion change (envoyproxy#6988) Max heap fix (envoyproxy#7016) Add support to unregister from lifecycle notifications (envoyproxy#6984) build spdy_core_alt_svc_wire_format (envoyproxy#7010) ext_authz: Make sure initiateCall only called once (envoyproxy#6949) ... Signed-off-by: Michael Puncel <mpuncel@squareup.com>
Description: Add PATCH method to protobuf so that ALS can receive and log it properly
Risk Level: Low
Testing: None
Docs Changes: -
Release Notes: -
Fixes #6694