Skip to content

quiche: add epoll_server for testing#6650

Merged
htuch merged 15 commits intoenvoyproxy:masterfrom
danzh2010:epoll_server
Apr 26, 2019
Merged

quiche: add epoll_server for testing#6650
htuch merged 15 commits intoenvoyproxy:masterfrom
danzh2010:epoll_server

Conversation

@danzh2010
Copy link
Contributor

@danzh2010 danzh2010 commented Apr 18, 2019

Add platform implementation for epoll_server. Build epoll_server and test it.
Add more DCHECK related macros in quic_logging_impl.h which is used by simple_epoll_server.cc
Update tar ball to quiche commit: 3e188a56edbcc471799499958bfd7c05ec45b9e2
Plumb through envoy_cc_test to pass in copt.

Risk Level: low
Testing: bring in simple_epoll_server_test.cc
Part of #2557

Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Contributor Author

/assign @wu-bin

)

envoy_cc_test(
name = "epoll_server_test",
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

"quiche/epoll_server/fake_simple_epoll_server.h",
"quiche/epoll_server/simple_epoll_server.h",
],
copts = envoy_copts("@envoy") + ["-Wno-error=unused-parameter"],
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where to put the global list? envoy_build_system.bzl?

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

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, and change it to -Wno-unused-parameter to suppress the warning entirely. Otherwise there will be too many warning output.


int addressFamilyUnderTestHelper() {
std::vector<Envoy::Network::Address::IpVersion> versions =
Envoy::TestEnvironment::getIpVersionsForTest();
Copy link
Contributor

Choose a reason for hiding this comment

The 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) {
return AF_INET;
}

if (std::find(versions.begin(), versions.end(), Envoy::Network::Address::IpVersion::v6) {
return AF_INET6;
}

return -1;

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

Copy link
Contributor

Choose a reason for hiding this comment

The 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()) {
return AF_INET;
}
// Same for v6

} // namespace

int AddressFamilyUnderTestImpl() {
static const int* version = new int(addressFamilyUnderTestHelper());
Copy link
Contributor

Choose a reason for hiding this comment

The 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();
return version;

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

#define EPOLL_PLOG_IMPL(severity) QUIC_PLOG_IMPL(severity)

#ifndef NDEBUG
#define EPOLL_DVLOG_IMPL(verbosity) QUIC_VLOG_IMPL(verbosity)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not
#define EPOLL_DVLOG_IMPL(verbosity) QUIC_DVLOG_IMPL(verbosity)
?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point. done!


namespace epoll_server {

template <typename T, typename... Args> std::unique_ptr<T> EpollMakeUniqueImpl(Args&&... args) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

template <typename T, typename... Args>
using EpollMakeUniqueImpl = std::make_unique<T, 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.

alias doesn't work with function template.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry about the wrong suggestion, and thanks for trying:)

#include "gmock/gmock.h"
#include "gtest/gtest.h"

#define EpollTestImpl ::testing::Test
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: prefer type alias to macro:

namespace epoll_server {
using EpollTestImpl = ::testing::Test;
} // namespace epoll_server

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

#ifdef NDEBUG
// Release build
#define DCHECK(condition) QUIC_COMPILED_OUT_LOG()
#define DCHECK(condition) \
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious, what is the problem without this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we have:
{
bool a = true;
DCHECK(a)
}

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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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())

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

Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
#define QUIC_DLOG_IF_IMPL(severity, condition) QUIC_COMPILED_OUT_LOG()
#define DCHECK(condition) QUIC_COMPILED_OUT_LOG(condition)
#define QUIC_COMPILED_OUT_LOG(condition) \
QUIC_LOG_IMPL_INTERNAL(false && condition, quic::NullLogStream().stream())
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add parentheses around "condition": false && (condition)

Otherwise DCHECK(false || true) will unexpectedly create a NullLogStream.

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

std::vector<Envoy::Network::Address::IpVersion> versions =
Envoy::TestEnvironment::getIpVersionsForTest();
if (std::find(versions.begin(), versions.end(), Envoy::Network::Address::IpVersion::v4) !=
std::end(versions)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: How about we either use versions.(begin|end), or std::(begin|end)(versions), but not a mix of them?

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


namespace epoll_server {

template <typename T, typename... Args> std::unique_ptr<T> EpollMakeUniqueImpl(Args&&... args) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry about the wrong suggestion, and thanks for trying:)

Signed-off-by: Dan Zhang <danzh@google.com>
wu-bin
wu-bin previously approved these changes Apr 19, 2019
Copy link
Contributor

@wu-bin wu-bin left a comment

Choose a reason for hiding this comment

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

LGTM, modulo the comment on "unused-parameter".

Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Contributor Author

/assign @alyssawilk

@danzh2010
Copy link
Contributor Author

/assign @htuch for changes in envoy_build_system.bzl

@repokitteh-read-only
Copy link

🙀 Error while processing event:

evaluation error
error: function _rk_error error: path contains forbidden characters
🐱

Caused by: a #6650 (comment) was created by @danzh2010.

see: more, trace.

Signed-off-by: Dan Zhang <danzh@google.com>
alyssawilk
alyssawilk previously approved these changes Apr 22, 2019

} // namespace

int AddressFamilyUnderTestImpl() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this is confusingly named, but doing the right thing.
Possibly worth a rename or comments that this returns the "highest" supported address version of v4/v6. Given it's test code and I suspect will be unused I'm fine landing as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Contributor Author

/assign @htuch
For changes in envoy_build_system.bzl

deps = ["@envoy//test/extensions/quic_listeners/quiche/platform:epoll_server_platform_impl_lib"],
)

cc_library(
Copy link
Member

Choose a reason for hiding this comment

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

Why are these cc_library rather than envoy_cc_library? The latter is preferred, it simplifies Google import and removes boilerplate.

Copy link
Contributor Author

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.

Copy link
Member

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.

Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: tsan (failed build)
🔨 rebuilding ci/circleci: release (failed build)

🐱

Caused by: a #6650 (comment) was created by @danzh2010.

see: more, trace.

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Looks good, one comment and needs master merge to resolve conflict.

"quiche/epoll_server/fake_simple_epoll_server.h",
"quiche/epoll_server/simple_epoll_server.h",
],
copts = envoy_copts("@envoy") + quiche_copt,
Copy link
Member

Choose a reason for hiding this comment

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

Do you need to explicitly add the envoy_copts if this is a envoy_cc_test_library?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not needed actually. Removed.

Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
htuch
htuch previously approved these changes Apr 23, 2019
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM, but needs master merge.

Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Contributor Author

sync'ed with #6700 to fix thread test failure. PTAL

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks!

@htuch htuch merged commit 3c367db into envoyproxy:master Apr 26, 2019
mpuncel added a commit to mpuncel/envoy that referenced this pull request May 1, 2019
* master: (35 commits)
  Revert "api: Add total_issued_requests to Upstream Locality and Endpoint Stats. (envoyproxy#6692)" (envoyproxy#6761)
  Add test for the SocketOptionFactory::buildLiteralOptions() method. (envoyproxy#6724)
  Add test of parsing weighted_cluster route configuration to improve test coverage. (envoyproxy#6711)
  test: reducing H2 test permutations, increasing coverage time (envoyproxy#6753)
  Support gRPC-JSON translate without the google.api.http option. (envoyproxy#6731)
  quiche: implement QuicEpollClock (envoyproxy#6745)
  http: rc details for main Envoy workflow (envoyproxy#6560)
  quiche: implement QuicSystemEventLoopImpl (envoyproxy#6723)
  http: tracking 100s from upstream in stats (envoyproxy#6746)
  coverage: run without deprecated  option (envoyproxy#6752)
  quiche: Implement spdy_test_helpers_impl. (envoyproxy#6741)
  [test] convert listener test stubs to v2 API (envoyproxy#6735)
  api: Add total_issued_requests to Upstream Locality and Endpoint Stats. (envoyproxy#6692)
  quiche: Implement http2_reconstruct_object_impl.h. (envoyproxy#6717)
  build: patch protobuf for UBSAN issue. (envoyproxy#6721)
  router: scoped rds (2a): scoped routing configuration protos (envoyproxy#6675)
  tap: use move semantics for submitTrace (envoyproxy#6709)
  quiche: add epoll_server for testing (envoyproxy#6650)
  Increase timeout of the coverage test run to 3000 seconds as it is now bumping in the current 2000s limit causing coverage run to abort sometimes. (envoyproxy#6722)
  quiche: Update tarball to commit 43a1c0f10f2855c3cd142f500e8d19ac6d6f5a8c (envoyproxy#6718)
  ...

Signed-off-by: Michael Puncel <mpuncel@squareup.com>
jeffpiazza-google pushed a commit to jeffpiazza-google/envoy that referenced this pull request May 3, 2019
Add platform implementation for epoll_server. Build epoll_server and test it.
Add more DCHECK related macros in quic_logging_impl.h which is used by simple_epoll_server.cc
Update tar ball to quiche commit: 3e188a56edbcc471799499958bfd7c05ec45b9e2
Plumb through envoy_cc_test to pass in copt.

Risk Level: low
Testing: bring in simple_epoll_server_test.cc

Part of envoyproxy#2557

Signed-off-by: Dan Zhang <danzh@google.com>

Signed-off-by: Jeff Piazza <jeffpiazza@google.com>
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.

5 participants