[EventEngine] Refactoring the EventEngine Test Suite: Part 1 (#32127)
* Add back EventEngine test suite tools (echo binary)
This reverts commit d5c12195a2
.
* more refactoring
* fix
* Automated change: Fix sanity tests
* fix
* fix posix oracle build def
* fix FuzzingEventEngine includes
* sanitize
* tidy and rm DNS
* fix cfstream includes
* header guards
* format & fix deps
* fix
* fix
* iwyu
* fix
* remove redundant code
* reviewer feedback
Co-authored-by: drfloob <drfloob@users.noreply.github.com>
pull/32189/head
parent
e8e9514a11
commit
3980ed706a
35 changed files with 852 additions and 240 deletions
@ -0,0 +1,61 @@ |
|||||||
|
# Copyright 2023 gRPC authors. |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") |
||||||
|
|
||||||
|
licenses(["notice"]) |
||||||
|
|
||||||
|
grpc_package(name = "test/core/event_engine/test_suite/posix") |
||||||
|
|
||||||
|
grpc_cc_library( |
||||||
|
name = "oracle_event_engine_posix", |
||||||
|
testonly = True, |
||||||
|
srcs = ["oracle_event_engine_posix.cc"], |
||||||
|
hdrs = ["oracle_event_engine_posix.h"], |
||||||
|
tags = [ |
||||||
|
"cpu:10", |
||||||
|
"no_windows", |
||||||
|
], |
||||||
|
visibility = ["//test:__subpackages__"], |
||||||
|
deps = [ |
||||||
|
"//:grpc", |
||||||
|
"//test/core/event_engine:event_engine_test_utils", |
||||||
|
"//test/core/event_engine/test_suite:event_engine_test_framework", |
||||||
|
"//test/core/util:grpc_test_util", |
||||||
|
], |
||||||
|
) |
||||||
|
|
||||||
|
grpc_cc_test( |
||||||
|
name = "oracle_event_engine_posix_test", |
||||||
|
srcs = ["oracle_event_engine_posix_test.cc"], |
||||||
|
external_deps = ["gtest"], |
||||||
|
language = "C++", |
||||||
|
tags = [ |
||||||
|
"no_test_ios", |
||||||
|
"no_windows", |
||||||
|
], |
||||||
|
# TODO(vignesbabu): This is required because the oracle event engine uses |
||||||
|
# poll syscall. If uses_polling is set to False, there will be an attempt |
||||||
|
# to run this test with GRPC_POLL_STRATEGY=none which will hijack the poll |
||||||
|
# c-wrapper causing the test to fail. A more generic posix oracle event |
||||||
|
# engine design which doesn't rely on poll is required. |
||||||
|
uses_polling = True, |
||||||
|
deps = [ |
||||||
|
"oracle_event_engine_posix", |
||||||
|
"//:grpc", |
||||||
|
"//test/core/event_engine/test_suite/tests:client", |
||||||
|
"//test/core/event_engine/test_suite/tests:server", |
||||||
|
"//test/core/util:grpc_test_util", |
||||||
|
], |
||||||
|
) |
@ -0,0 +1,88 @@ |
|||||||
|
# Copyright 2023 gRPC authors. |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_package") |
||||||
|
|
||||||
|
licenses(["notice"]) |
||||||
|
|
||||||
|
grpc_package( |
||||||
|
name = "test/core/event_engine/test_suite/tests", |
||||||
|
visibility = "public", |
||||||
|
) |
||||||
|
|
||||||
|
# TODO(hork): A single InitTestSuite() call should initialize all tests. |
||||||
|
# This can be done after each test suite specialization can explicitly opt in or out |
||||||
|
# of tests declaratively. |
||||||
|
# grpc_cc_library( |
||||||
|
# name = "init", |
||||||
|
# testonly = True, |
||||||
|
# hdrs = ["init.h"], |
||||||
|
# deps = [ |
||||||
|
# "client", |
||||||
|
# "dns", |
||||||
|
# "server", |
||||||
|
# "timer", |
||||||
|
# ], |
||||||
|
# alwayslink = 1, |
||||||
|
# ) |
||||||
|
|
||||||
|
grpc_cc_library( |
||||||
|
name = "timer", |
||||||
|
testonly = True, |
||||||
|
srcs = ["timer_test.cc"], |
||||||
|
hdrs = ["timer_test.h"], |
||||||
|
deps = [ |
||||||
|
"//test/core/event_engine:event_engine_test_utils", |
||||||
|
"//test/core/event_engine/test_suite:event_engine_test_framework", |
||||||
|
], |
||||||
|
alwayslink = 1, |
||||||
|
) |
||||||
|
|
||||||
|
grpc_cc_library( |
||||||
|
name = "dns", |
||||||
|
testonly = True, |
||||||
|
srcs = ["dns_test.cc"], |
||||||
|
hdrs = ["dns_test.h"], |
||||||
|
deps = [ |
||||||
|
"//test/core/event_engine:event_engine_test_utils", |
||||||
|
"//test/core/event_engine/test_suite:event_engine_test_framework", |
||||||
|
], |
||||||
|
alwayslink = 1, |
||||||
|
) |
||||||
|
|
||||||
|
grpc_cc_library( |
||||||
|
name = "client", |
||||||
|
testonly = True, |
||||||
|
srcs = ["client_test.cc"], |
||||||
|
hdrs = ["client_test.h"], |
||||||
|
deps = [ |
||||||
|
"//src/core:channel_args", |
||||||
|
"//test/core/event_engine:event_engine_test_utils", |
||||||
|
"//test/core/event_engine/test_suite:event_engine_test_framework", |
||||||
|
], |
||||||
|
alwayslink = 1, |
||||||
|
) |
||||||
|
|
||||||
|
grpc_cc_library( |
||||||
|
name = "server", |
||||||
|
testonly = True, |
||||||
|
srcs = ["server_test.cc"], |
||||||
|
hdrs = ["server_test.h"], |
||||||
|
deps = [ |
||||||
|
"//src/core:channel_args", |
||||||
|
"//test/core/event_engine:event_engine_test_utils", |
||||||
|
"//test/core/event_engine/test_suite:event_engine_test_framework", |
||||||
|
], |
||||||
|
alwayslink = 1, |
||||||
|
) |
@ -0,0 +1,25 @@ |
|||||||
|
// Copyright 2023 The gRPC Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef GRPC_TEST_CORE_EVENT_ENGINE_TEST_SUITE_TESTS_CLIENT_TEST_H |
||||||
|
#define GRPC_TEST_CORE_EVENT_ENGINE_TEST_SUITE_TESTS_CLIENT_TEST_H |
||||||
|
|
||||||
|
namespace grpc_event_engine { |
||||||
|
namespace experimental { |
||||||
|
|
||||||
|
void InitClientTests(); |
||||||
|
|
||||||
|
} // namespace experimental
|
||||||
|
} // namespace grpc_event_engine
|
||||||
|
|
||||||
|
#endif // GRPC_TEST_CORE_EVENT_ENGINE_TEST_SUITE_TESTS_CLIENT_TEST_H
|
@ -0,0 +1,25 @@ |
|||||||
|
// Copyright 2023 The gRPC Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef GRPC_TEST_CORE_EVENT_ENGINE_TEST_SUITE_TESTS_DNS_TEST_H |
||||||
|
#define GRPC_TEST_CORE_EVENT_ENGINE_TEST_SUITE_TESTS_DNS_TEST_H |
||||||
|
|
||||||
|
namespace grpc_event_engine { |
||||||
|
namespace experimental { |
||||||
|
|
||||||
|
void InitDNSTests(); |
||||||
|
|
||||||
|
} // namespace experimental
|
||||||
|
} // namespace grpc_event_engine
|
||||||
|
|
||||||
|
#endif // GRPC_TEST_CORE_EVENT_ENGINE_TEST_SUITE_TESTS_DNS_TEST_H
|
@ -0,0 +1,25 @@ |
|||||||
|
// Copyright 2023 The gRPC Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef GRPC_TEST_CORE_EVENT_ENGINE_TEST_SUITE_TESTS_SERVER_TEST_H |
||||||
|
#define GRPC_TEST_CORE_EVENT_ENGINE_TEST_SUITE_TESTS_SERVER_TEST_H |
||||||
|
|
||||||
|
namespace grpc_event_engine { |
||||||
|
namespace experimental { |
||||||
|
|
||||||
|
void InitServerTests(); |
||||||
|
|
||||||
|
} // namespace experimental
|
||||||
|
} // namespace grpc_event_engine
|
||||||
|
|
||||||
|
#endif // GRPC_TEST_CORE_EVENT_ENGINE_TEST_SUITE_TESTS_SERVER_TEST_H
|
@ -0,0 +1,25 @@ |
|||||||
|
// Copyright 2023 The gRPC Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef GRPC_TEST_CORE_EVENT_ENGINE_TEST_SUITE_TESTS_TIMER_TEST_H |
||||||
|
#define GRPC_TEST_CORE_EVENT_ENGINE_TEST_SUITE_TESTS_TIMER_TEST_H |
||||||
|
|
||||||
|
namespace grpc_event_engine { |
||||||
|
namespace experimental { |
||||||
|
|
||||||
|
void InitTimerTests(); |
||||||
|
|
||||||
|
} // namespace experimental
|
||||||
|
} // namespace grpc_event_engine
|
||||||
|
|
||||||
|
#endif // GRPC_TEST_CORE_EVENT_ENGINE_TEST_SUITE_TESTS_TIMER_TEST_H
|
@ -0,0 +1,70 @@ |
|||||||
|
# Copyright 2022 gRPC authors. |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
load("//bazel:grpc_build_system.bzl", "grpc_cc_binary", "grpc_cc_library", "grpc_package") |
||||||
|
|
||||||
|
licenses(["notice"]) |
||||||
|
|
||||||
|
grpc_package(name = "test/core/event_engine/test_suite/tools") |
||||||
|
|
||||||
|
# -- Implementations -- |
||||||
|
|
||||||
|
grpc_cc_binary( |
||||||
|
name = "windows_event_engine_echo_client", |
||||||
|
testonly = True, |
||||||
|
srcs = ["windows_event_engine_factory.cc"], |
||||||
|
tags = [ |
||||||
|
"bazel_only", |
||||||
|
"no_linux", |
||||||
|
"no_mac", |
||||||
|
], |
||||||
|
deps = [ |
||||||
|
"echo_client", |
||||||
|
"//src/core:windows_event_engine", |
||||||
|
], |
||||||
|
) |
||||||
|
|
||||||
|
# TODO(hork): this needs to reuse the same configuration in the test suite. |
||||||
|
grpc_cc_binary( |
||||||
|
name = "posix_event_engine_echo_client", |
||||||
|
testonly = True, |
||||||
|
srcs = ["posix_event_engine_factory.cc"], |
||||||
|
tags = [ |
||||||
|
"bazel_only", |
||||||
|
"no_windows", |
||||||
|
], |
||||||
|
deps = [ |
||||||
|
"echo_client", |
||||||
|
"//src/core:posix_event_engine", |
||||||
|
], |
||||||
|
) |
||||||
|
|
||||||
|
# -- Testing tools -- |
||||||
|
|
||||||
|
grpc_cc_library( |
||||||
|
name = "echo_client", |
||||||
|
testonly = True, |
||||||
|
srcs = ["echo_client.cc"], |
||||||
|
external_deps = [ |
||||||
|
"absl/flags:flag", |
||||||
|
"absl/flags:parse", |
||||||
|
], |
||||||
|
language = "C++", |
||||||
|
deps = [ |
||||||
|
"//:gpr_platform", |
||||||
|
"//src/core:common_event_engine_closures", |
||||||
|
"//test/core/event_engine:event_engine_test_utils", |
||||||
|
"//test/core/util:grpc_test_util", |
||||||
|
], |
||||||
|
) |
@ -0,0 +1,159 @@ |
|||||||
|
// Copyright 2022 gRPC authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <grpc/support/port_platform.h> |
||||||
|
|
||||||
|
#include <stdint.h> |
||||||
|
#include <stdlib.h> |
||||||
|
|
||||||
|
#include <grpc/event_engine/slice.h> |
||||||
|
|
||||||
|
// The echo client wraps an EventEngine::Connect and EventEngine::Endpoint
|
||||||
|
// implementations, allowing third-party TCP listeners to interact with your
|
||||||
|
// EventEngine client. Example usage:
|
||||||
|
//
|
||||||
|
// # in one shell
|
||||||
|
// choco install nmap
|
||||||
|
// ncat -klp 32000
|
||||||
|
// # wait for a connection, than send data (e.g., keyboard input)
|
||||||
|
//
|
||||||
|
// # in a separate shell
|
||||||
|
// bazel run
|
||||||
|
// //test/core/event_engine/test_suite/tools:my_event_engine_echo_client
|
||||||
|
|
||||||
|
#include <chrono> |
||||||
|
#include <memory> |
||||||
|
#include <ratio> |
||||||
|
#include <string> |
||||||
|
#include <utility> |
||||||
|
|
||||||
|
#include "absl/flags/flag.h" |
||||||
|
#include "absl/flags/parse.h" |
||||||
|
#include "absl/functional/any_invocable.h" |
||||||
|
#include "absl/status/status.h" |
||||||
|
#include "absl/status/statusor.h" |
||||||
|
#include "absl/strings/str_format.h" |
||||||
|
#include "absl/strings/string_view.h" |
||||||
|
|
||||||
|
#include <grpc/event_engine/event_engine.h> |
||||||
|
#include <grpc/event_engine/slice_buffer.h> |
||||||
|
#include <grpc/grpc.h> |
||||||
|
#include <grpc/support/log.h> |
||||||
|
|
||||||
|
#include "src/core/lib/channel/channel_args_preconditioning.h" |
||||||
|
#include "src/core/lib/config/core_configuration.h" |
||||||
|
#include "src/core/lib/event_engine/channel_args_endpoint_config.h" |
||||||
|
#include "src/core/lib/event_engine/default_event_engine.h" |
||||||
|
#include "src/core/lib/event_engine/tcp_socket_utils.h" |
||||||
|
#include "src/core/lib/gprpp/notification.h" |
||||||
|
#include "src/core/lib/resolver/resolver_registry.h" |
||||||
|
#include "src/core/lib/resource_quota/memory_quota.h" |
||||||
|
|
||||||
|
extern absl::AnyInvocable< |
||||||
|
std::unique_ptr<grpc_event_engine::experimental::EventEngine>(void)> |
||||||
|
CustomEventEngineFactory(); |
||||||
|
|
||||||
|
ABSL_FLAG(std::string, target, "ipv4:127.0.0.1:50051", "Target string"); |
||||||
|
|
||||||
|
namespace { |
||||||
|
using namespace std::chrono_literals; |
||||||
|
|
||||||
|
using ::grpc_event_engine::experimental::ChannelArgsEndpointConfig; |
||||||
|
using ::grpc_event_engine::experimental::EventEngine; |
||||||
|
using ::grpc_event_engine::experimental::GetDefaultEventEngine; |
||||||
|
using ::grpc_event_engine::experimental::Slice; |
||||||
|
using ::grpc_event_engine::experimental::SliceBuffer; |
||||||
|
using ::grpc_event_engine::experimental::URIToResolvedAddress; |
||||||
|
|
||||||
|
void SendMessage(EventEngine::Endpoint* endpoint, int message_id) { |
||||||
|
SliceBuffer buf; |
||||||
|
buf.Append(Slice::FromCopiedString( |
||||||
|
absl::StrFormat("Waiting for message %d ... \n", message_id))); |
||||||
|
grpc_core::Notification write_done; |
||||||
|
endpoint->Write( |
||||||
|
[&](absl::Status status) { |
||||||
|
GPR_ASSERT(status.ok()); |
||||||
|
write_done.Notify(); |
||||||
|
}, |
||||||
|
&buf, nullptr); |
||||||
|
write_done.WaitForNotification(); |
||||||
|
} |
||||||
|
|
||||||
|
void ReceiveAndEchoMessage(EventEngine::Endpoint* endpoint, int message_id) { |
||||||
|
SliceBuffer buf; |
||||||
|
grpc_core::Notification read_done; |
||||||
|
endpoint->Read( |
||||||
|
[&](absl::Status status) { |
||||||
|
if (!status.ok()) { |
||||||
|
gpr_log(GPR_ERROR, "Error reading from endpoint: %s", |
||||||
|
status.ToString().c_str()); |
||||||
|
exit(1); |
||||||
|
} |
||||||
|
Slice received = buf.TakeFirst(); |
||||||
|
gpr_log(GPR_ERROR, "Received message %d: %.*s", message_id, |
||||||
|
static_cast<int>(received.as_string_view().length()), |
||||||
|
received.as_string_view().data()); |
||||||
|
read_done.Notify(); |
||||||
|
}, |
||||||
|
&buf, nullptr); |
||||||
|
read_done.WaitForNotification(); |
||||||
|
} |
||||||
|
|
||||||
|
void RunUntilInterrupted() { |
||||||
|
auto engine = GetDefaultEventEngine(); |
||||||
|
std::unique_ptr<EventEngine::Endpoint> endpoint; |
||||||
|
grpc_core::Notification connected; |
||||||
|
auto memory_quota = std::make_unique<grpc_core::MemoryQuota>("bar"); |
||||||
|
ChannelArgsEndpointConfig config{grpc_core::CoreConfiguration::Get() |
||||||
|
.channel_args_preconditioning() |
||||||
|
.PreconditionChannelArgs(nullptr)}; |
||||||
|
std::string canonical_target = |
||||||
|
grpc_core::CoreConfiguration::Get() |
||||||
|
.resolver_registry() |
||||||
|
.AddDefaultPrefixIfNeeded(absl::GetFlag(FLAGS_target)); |
||||||
|
auto addr = URIToResolvedAddress(canonical_target); |
||||||
|
GPR_ASSERT(addr.ok()); |
||||||
|
engine->Connect( |
||||||
|
[&](absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> ep) { |
||||||
|
if (!ep.ok()) { |
||||||
|
gpr_log(GPR_ERROR, "Error connecting: %s", |
||||||
|
ep.status().ToString().c_str()); |
||||||
|
exit(1); |
||||||
|
} |
||||||
|
endpoint = std::move(*ep); |
||||||
|
connected.Notify(); |
||||||
|
}, |
||||||
|
*addr, config, memory_quota->CreateMemoryAllocator("client"), 2h); |
||||||
|
connected.WaitForNotification(); |
||||||
|
GPR_ASSERT(endpoint.get() != nullptr); |
||||||
|
gpr_log(GPR_DEBUG, "peer addr: %s", |
||||||
|
ResolvedAddressToString(endpoint->GetPeerAddress())->c_str()); |
||||||
|
gpr_log(GPR_DEBUG, "local addr: %s", |
||||||
|
ResolvedAddressToString(endpoint->GetLocalAddress())->c_str()); |
||||||
|
int message_id = 0; |
||||||
|
while (true) { |
||||||
|
SendMessage(endpoint.get(), message_id++); |
||||||
|
ReceiveAndEchoMessage(endpoint.get(), message_id); |
||||||
|
} |
||||||
|
} |
||||||
|
} // namespace
|
||||||
|
|
||||||
|
int main(int argc, char** argv) { |
||||||
|
absl::ParseCommandLine(argc, argv); |
||||||
|
grpc_event_engine::experimental::SetEventEngineFactory( |
||||||
|
CustomEventEngineFactory()); |
||||||
|
grpc_init(); |
||||||
|
RunUntilInterrupted(); |
||||||
|
grpc_shutdown(); |
||||||
|
return 0; |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
// Copyright 2023 gRPC authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include <grpc/support/port_platform.h> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
|
||||||
|
#include "absl/functional/any_invocable.h" |
||||||
|
|
||||||
|
#include <grpc/event_engine/event_engine.h> |
||||||
|
|
||||||
|
#include "src/core/lib/iomgr/port.h" |
||||||
|
|
||||||
|
#ifdef GRPC_POSIX_SOCKET_TCP |
||||||
|
|
||||||
|
#include "src/core/lib/event_engine/posix_engine/posix_engine.h" |
||||||
|
|
||||||
|
absl::AnyInvocable< |
||||||
|
std::unique_ptr<grpc_event_engine::experimental::EventEngine>(void)> |
||||||
|
CustomEventEngineFactory() { |
||||||
|
return []() { |
||||||
|
return std::make_unique< |
||||||
|
grpc_event_engine::experimental::PosixEventEngine>(); |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
#else |
||||||
|
|
||||||
|
absl::AnyInvocable< |
||||||
|
std::unique_ptr<grpc_event_engine::experimental::EventEngine>(void)> |
||||||
|
CustomEventEngineFactory() { |
||||||
|
GPR_ASSERT(false && "This tool was not built for Posix environments."); |
||||||
|
} |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,45 @@ |
|||||||
|
// Copyright 2022 gRPC authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include <grpc/support/port_platform.h> |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
|
||||||
|
#include "absl/functional/any_invocable.h" |
||||||
|
|
||||||
|
#include <grpc/event_engine/event_engine.h> |
||||||
|
#include <grpc/support/log.h> |
||||||
|
|
||||||
|
#ifdef GPR_WINDOWS |
||||||
|
|
||||||
|
#include "src/core/lib/event_engine/windows/windows_engine.h" |
||||||
|
|
||||||
|
absl::AnyInvocable< |
||||||
|
std::unique_ptr<grpc_event_engine::experimental::EventEngine>(void)> |
||||||
|
CustomEventEngineFactory() { |
||||||
|
return []() { |
||||||
|
return std::make_unique< |
||||||
|
grpc_event_engine::experimental::WindowsEventEngine>(); |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
#else |
||||||
|
|
||||||
|
absl::AnyInvocable< |
||||||
|
std::unique_ptr<grpc_event_engine::experimental::EventEngine>(void)> |
||||||
|
CustomEventEngineFactory() { |
||||||
|
GPR_ASSERT(false && "This tool was not built for Windows."); |
||||||
|
} |
||||||
|
|
||||||
|
#endif |
Loading…
Reference in new issue