-
Notifications
You must be signed in to change notification settings - Fork 5.5k
quiche: add epoll_server for testing #6650
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
Changes from 2 commits
1068b8e
30a1dd6
79570f3
fa174ac
f44663a
35c09c6
8105de3
4c18507
05fb83b
2a6b9f8
ea66710
93f08e6
751b7a9
3883e6d
499ccb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ load(":genrule_cmd.bzl", "genrule_cmd") | |
| load( | ||
| "@envoy//bazel:envoy_build_system.bzl", | ||
| "envoy_cc_test", | ||
| "envoy_copts", | ||
| "envoy_select_quiche", | ||
| ) | ||
|
|
||
|
|
@@ -253,6 +254,48 @@ cc_library( | |
| deps = [":quic_platform_export"], | ||
| ) | ||
|
|
||
| cc_library( | ||
| name = "epoll_server_platform", | ||
| testonly = 1, | ||
| hdrs = [ | ||
| "quiche/epoll_server/platform/api/epoll_address_test_utils.h", | ||
| "quiche/epoll_server/platform/api/epoll_bug.h", | ||
| "quiche/epoll_server/platform/api/epoll_expect_bug.h", | ||
| "quiche/epoll_server/platform/api/epoll_export.h", | ||
| "quiche/epoll_server/platform/api/epoll_logging.h", | ||
| "quiche/epoll_server/platform/api/epoll_ptr_util.h", | ||
| "quiche/epoll_server/platform/api/epoll_test.h", | ||
| "quiche/epoll_server/platform/api/epoll_thread.h", | ||
| "quiche/epoll_server/platform/api/epoll_time.h", | ||
| ], | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@envoy//test/extensions/quic_listeners/quiche/platform:epoll_server_platform_impl_lib"], | ||
| ) | ||
|
|
||
| cc_library( | ||
| name = "epoll_server_lib", | ||
| testonly = 1, | ||
| srcs = [ | ||
| "quiche/epoll_server/fake_simple_epoll_server.cc", | ||
| "quiche/epoll_server/simple_epoll_server.cc", | ||
| ], | ||
| hdrs = [ | ||
| "quiche/epoll_server/fake_simple_epoll_server.h", | ||
| "quiche/epoll_server/simple_epoll_server.h", | ||
| ], | ||
| copts = envoy_copts("@envoy") + ["-Wno-error=unused-parameter"], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of ignoring it, can we fix the unused-parameter warning in epoll_server code? We don't need to change envoy_build_system.bzl that way.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. QUICHE allows unused-parameter, so I think we will run into this warning in quic and h2 code as well. That's why I modify envoy_build_system.bzl. Suppressing this warning in Envoy seems more reasonable than adding this enforcement in QUICHE.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM, please move "-Wno-error=unused-parameter" into a global list and use it in here and epoll_server_test.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case you missed it, this comment still needs to be resolved. @danzh2010
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where to put the global list? envoy_build_system.bzl?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this file(bazel/external/quiche.BUILD), since it's only needed by quiche build rules.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done, and change it to -Wno-unused-parameter to suppress the warning entirely. Otherwise there will be too many warning output. |
||
| visibility = ["//visibility:public"], | ||
| deps = [":epoll_server_platform"], | ||
| ) | ||
|
|
||
| envoy_cc_test( | ||
| name = "epoll_server_test", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is also defined in test/extensions/quic_listeners/quiche/platform/BUILD, should we delete one of them?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, the one is //test/ is used for debugging. I removed that one instead. |
||
| srcs = ["quiche/epoll_server/simple_epoll_server_test.cc"], | ||
| copts = ["-Wno-error=unused-parameter"], | ||
| repository = "@envoy", | ||
| deps = [":epoll_server_lib"], | ||
| ) | ||
|
|
||
| envoy_cc_test( | ||
| name = "http2_platform_test", | ||
| srcs = envoy_select_quiche( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,9 +59,18 @@ | |
| #define CHECK(condition) \ | ||
| QUIC_LOG_IF_IMPL(FATAL, ABSL_PREDICT_FALSE(!(condition))) << "CHECK failed: " #condition "." | ||
|
|
||
| #define CHECK_GT(a, b) CHECK((a) > (b)) | ||
| #define CHECK_GE(a, b) CHECK((a) >= (b)) | ||
| #define CHECK_LT(a, b) CHECK((a) < (b)) | ||
| #define CHECK_LE(a, b) CHECK((a) <= (b)) | ||
| #define CHECK_NE(a, b) CHECK((a) != (b)) | ||
| #define CHECK_EQ(a, b) CHECK((a) == (b)) | ||
|
|
||
| #ifdef NDEBUG | ||
| // Release build | ||
| #define DCHECK(condition) QUIC_COMPILED_OUT_LOG() | ||
| #define DCHECK(condition) \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious, what is the problem without this change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we have: In release build, w/o this change a is not used. We can supress unused-variable too. But that seems to be over-kill as QUICHE also forbids unused-variable.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. There are other macros defined to "QUIC_COMPILED_OUT_LOG" as well, maybe change "QUIC_COMPILED_OUT_LOG" to take a "condition" instead? #define QUIC_COMPILED_OUT_LOG(condition) QUIC_LOG_IMPL_INTERNAL(false && (condition), quic::NullLogStream().stream())
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| while (false && (condition)) \ | ||
| QUIC_COMPILED_OUT_LOG() | ||
| #define QUIC_COMPILED_OUT_LOG() QUIC_LOG_IMPL_INTERNAL(false, quic::NullLogStream().stream()) | ||
| #define QUIC_DVLOG_IMPL(verbosity) QUIC_COMPILED_OUT_LOG() | ||
| #define QUIC_DVLOG_IF_IMPL(verbosity, condition) QUIC_COMPILED_OUT_LOG() | ||
|
|
@@ -83,6 +92,11 @@ | |
| #endif | ||
|
|
||
| #define DCHECK_GE(a, b) DCHECK((a) >= (b)) | ||
| #define DCHECK_GT(a, b) DCHECK((a) > (b)) | ||
| #define DCHECK_LT(a, b) DCHECK((a) < (b)) | ||
| #define DCHECK_LE(a, b) DCHECK((a) <= (b)) | ||
| #define DCHECK_NE(a, b) DCHECK((a) != (b)) | ||
| #define DCHECK_EQ(a, b) DCHECK((a) == (b)) | ||
|
|
||
| #define QUIC_PREDICT_FALSE_IMPL(x) ABSL_PREDICT_FALSE(x) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #pragma once | ||
|
|
||
| // NOLINT(namespace-envoy) | ||
|
|
||
| // This file is part of the QUICHE platform implementation, and is not to be | ||
| // consumed or referenced directly by other Envoy code. It serves purely as a | ||
| // porting layer for QUICHE. | ||
|
|
||
| #include <sys/socket.h> | ||
|
|
||
| #include "envoy/network/address.h" | ||
|
|
||
| #include "test/test_common/environment.h" | ||
|
|
||
| namespace epoll_server { | ||
|
|
||
| namespace { | ||
|
|
||
| int addressFamilyUnderTestHelper() { | ||
| std::vector<Envoy::Network::Address::IpVersion> versions = | ||
| Envoy::TestEnvironment::getIpVersionsForTest(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about using std::find for clarity? if (std::find(versions.begin(), versions.end(), Envoy::Network::Address::IpVersion::v4) { if (std::find(versions.begin(), versions.end(), Envoy::Network::Address::IpVersion::v6) { return -1;
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, my code in comment doesn't actually work, it should be if (std::find(versions.begin(), versions.end(), Envoy::Network::Address::IpVersion::v4) != versions.end()) { |
||
| if (versions.size() == 2 || | ||
| (versions.size() == 1 && versions[0] == Envoy::Network::Address::IpVersion::v4)) { | ||
| return AF_INET; | ||
| } else if (versions.size() == 1) { | ||
| ASSERT(versions[0] == Envoy::Network::Address::IpVersion::v6); | ||
| return AF_INET6; | ||
| } | ||
| return -1; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| int AddressFamilyUnderTestImpl() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this is confusingly named, but doing the right thing.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renaming requires upstream change. I added a comment here for the return value. |
||
| static const int* version = new int(addressFamilyUnderTestHelper()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: no need to call new since int is trivial to destruct, just do: static const int version = addressFamilyUnderTestHelper();
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| return *version; | ||
| } | ||
|
|
||
| } // namespace epoll_server | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #pragma once | ||
|
|
||
| // NOLINT(namespace-envoy) | ||
|
|
||
| // This file is part of the QUICHE platform implementation, and is not to be | ||
| // consumed or referenced directly by other Envoy code. It serves purely as a | ||
| // porting layer for QUICHE. | ||
|
|
||
| #include "extensions/quic_listeners/quiche/platform/quic_bug_tracker_impl.h" | ||
|
|
||
| #define EPOLL_BUG_IMPL QUIC_BUG_IMPL |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #pragma once | ||
|
|
||
| // NOLINT(namespace-envoy) | ||
|
|
||
| // This file is part of the QUICHE platform implementation, and is not to be | ||
| // consumed or referenced directly by other Envoy code. It serves purely as a | ||
| // porting layer for QUICHE. | ||
|
|
||
| #include "extensions/quic_listeners/quiche/platform/quic_expect_bug_impl.h" | ||
|
|
||
| #define EXPECT_EPOLL_BUG_IMPL EXPECT_QUIC_BUG_IMPL |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #pragma once | ||
|
|
||
| // NOLINT(namespace-envoy) | ||
|
|
||
| // This file is part of the QUICHE platform implementation, and is not to be | ||
| // consumed or referenced directly by other Envoy code. It serves purely as a | ||
| // porting layer for QUICHE. | ||
|
|
||
| #define EPOLL_EXPORT | ||
| #define EPOLL_EXPORT_PRIVATE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #pragma once | ||
|
|
||
| // NOLINT(namespace-envoy) | ||
|
|
||
| // This file is part of the QUICHE platform implementation, and is not to be | ||
| // consumed or referenced directly by other Envoy code. It serves purely as a | ||
| // porting layer for QUICHE. | ||
|
|
||
| #include "extensions/quic_listeners/quiche/platform/quic_logging_impl.h" | ||
|
|
||
| namespace epoll_server { | ||
|
|
||
| #define EPOLL_LOG_IMPL(severity) QUIC_LOG_IMPL(severity) | ||
| #define EPOLL_VLOG_IMPL(verbosity) QUIC_VLOG_IMPL(verbosity) | ||
|
|
||
| #define EPOLL_PLOG_IMPL(severity) QUIC_PLOG_IMPL(severity) | ||
|
|
||
| #ifndef NDEBUG | ||
| #define EPOLL_DVLOG_IMPL(verbosity) QUIC_VLOG_IMPL(verbosity) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point. done! |
||
| #else | ||
| #define EPOLL_DVLOG_IMPL(verbosity) QUIC_VLOG_IF_IMPL(verbosity, false) | ||
| #endif | ||
|
|
||
| } // namespace epoll_server | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #pragma once | ||
|
|
||
| // NOLINT(namespace-envoy) | ||
|
|
||
| // This file is part of the QUICHE platform implementation, and is not to be | ||
| // consumed or referenced directly by other Envoy code. It serves purely as a | ||
| // porting layer for QUICHE. | ||
|
|
||
| #include <memory> | ||
|
|
||
| namespace epoll_server { | ||
|
|
||
| template <typename T, typename... Args> std::unique_ptr<T> EpollMakeUniqueImpl(Args&&... args) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: template <typename T, typename... Args>
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alias doesn't work with function template.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry about the wrong suggestion, and thanks for trying:) |
||
| return std::make_unique<T>(std::forward<Args>(args)...); | ||
| } | ||
|
|
||
| } // namespace epoll_server | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #pragma once | ||
|
|
||
| // NOLINT(namespace-envoy) | ||
|
|
||
| // This file is part of the QUICHE platform implementation, and is not to be | ||
| // consumed or referenced directly by other Envoy code. It serves purely as a | ||
| // porting layer for QUICHE. | ||
|
|
||
| #include "gmock/gmock.h" | ||
| #include "gtest/gtest.h" | ||
|
|
||
| #define EpollTestImpl ::testing::Test | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: prefer type alias to macro: namespace epoll_server {
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #pragma once | ||
|
|
||
| // NOLINT(namespace-envoy) | ||
|
|
||
| // This file is part of the QUICHE platform implementation, and is not to be | ||
| // consumed or referenced directly by other Envoy code. It serves purely as a | ||
| // porting layer for QUICHE. | ||
|
|
||
| #include "extensions/quic_listeners/quiche/platform/quic_thread_impl.h" | ||
|
|
||
| namespace epoll_server { | ||
|
|
||
| using EpollThreadImpl = quic::QuicThreadImpl; | ||
|
|
||
| } // namespace epoll_server |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #pragma once | ||
|
|
||
| // NOLINT(namespace-envoy) | ||
|
|
||
| // This file is part of the QUICHE platform implementation, and is not to be | ||
| // consumed or referenced directly by other Envoy code. It serves purely as a | ||
| // porting layer for QUICHE. | ||
|
|
||
| #include "absl/time/clock.h" | ||
|
|
||
| namespace epoll_server { | ||
|
|
||
| inline int64_t WallTimeNowInUsecImpl() { return absl::GetCurrentTimeNanos() / 1000; } | ||
|
|
||
| } // namespace epoll_server |
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.
Why are these
cc_libraryrather thanenvoy_cc_library? The latter is preferred, it simplifies Google import and removes boilerplate.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 think the original intention was that these targets are not in the envoy workspace and to use envoy_cc_library we need to explicitly specify
repository = "@envoy". But since it benefits to code import, I just switched to use envoy_cc_library.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 guess internally we will use a different QUICHE binding actually. But, it's good either way.