Remove grpc_client_channel_get_subchannel_call().

pull/24919/head
Mark D. Roth 4 years ago
parent 6c440e820b
commit e4faf1945d
  1. 3
      CMakeLists.txt
  2. 6
      build_autogenerated.yaml
  3. 2
      gRPC-Core.podspec
  4. 2
      grpc.gyp
  5. 8
      src/core/ext/filters/client_channel/client_channel.cc
  6. 4
      src/core/ext/filters/client_channel/client_channel.h
  7. 14
      test/core/util/BUILD
  8. 57
      test/core/util/debugger_macros.cc
  9. 27
      test/core/util/debugger_macros.h
  10. 33
      test/cpp/end2end/cfstream_test.cc
  11. 14
      test/cpp/end2end/flaky_network_test.cc

@ -2098,7 +2098,6 @@ if(gRPC_BUILD_TESTS)
add_library(grpc_test_util
test/core/util/cmdline.cc
test/core/util/debugger_macros.cc
test/core/util/eval_args_mock_endpoint.cc
test/core/util/fuzzer_util.cc
test/core/util/grpc_profiler.cc
@ -2170,7 +2169,6 @@ if(gRPC_BUILD_TESTS)
add_library(grpc_test_util_unsecure
test/core/util/cmdline.cc
test/core/util/debugger_macros.cc
test/core/util/eval_args_mock_endpoint.cc
test/core/util/fuzzer_util.cc
test/core/util/grpc_profiler.cc
@ -15237,7 +15235,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/simple_messages.pb.h
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/testing/simple_messages.grpc.pb.h
test/core/util/cmdline.cc
test/core/util/debugger_macros.cc
test/core/util/eval_args_mock_endpoint.cc
test/core/util/fuzzer_util.cc
test/core/util/grpc_profiler.cc

@ -1424,7 +1424,6 @@ libs:
public_headers: []
headers:
- test/core/util/cmdline.h
- test/core/util/debugger_macros.h
- test/core/util/eval_args_mock_endpoint.h
- test/core/util/fuzzer_util.h
- test/core/util/grpc_profiler.h
@ -1446,7 +1445,6 @@ libs:
- test/core/util/trickle_endpoint.h
src:
- test/core/util/cmdline.cc
- test/core/util/debugger_macros.cc
- test/core/util/eval_args_mock_endpoint.cc
- test/core/util/fuzzer_util.cc
- test/core/util/grpc_profiler.cc
@ -1482,7 +1480,6 @@ libs:
public_headers: []
headers:
- test/core/util/cmdline.h
- test/core/util/debugger_macros.h
- test/core/util/eval_args_mock_endpoint.h
- test/core/util/fuzzer_util.h
- test/core/util/grpc_profiler.h
@ -1504,7 +1501,6 @@ libs:
- test/core/util/trickle_endpoint.h
src:
- test/core/util/cmdline.cc
- test/core/util/debugger_macros.cc
- test/core/util/eval_args_mock_endpoint.cc
- test/core/util/fuzzer_util.cc
- test/core/util/grpc_profiler.cc
@ -7818,7 +7814,6 @@ targets:
language: c++
headers:
- test/core/util/cmdline.h
- test/core/util/debugger_macros.h
- test/core/util/eval_args_mock_endpoint.h
- test/core/util/fuzzer_util.h
- test/core/util/grpc_profiler.h
@ -7843,7 +7838,6 @@ targets:
- src/proto/grpc/testing/echo_messages.proto
- src/proto/grpc/testing/simple_messages.proto
- test/core/util/cmdline.cc
- test/core/util/debugger_macros.cc
- test/core/util/eval_args_mock_endpoint.cc
- test/core/util/fuzzer_util.cc
- test/core/util/grpc_profiler.cc

@ -2023,8 +2023,6 @@ Pod::Spec.new do |s|
'test/core/end2end/tests/write_buffering_at_end.cc',
'test/core/util/cmdline.cc',
'test/core/util/cmdline.h',
'test/core/util/debugger_macros.cc',
'test/core/util/debugger_macros.h',
'test/core/util/eval_args_mock_endpoint.cc',
'test/core/util/eval_args_mock_endpoint.h',
'test/core/util/fuzzer_util.cc',

@ -1004,7 +1004,6 @@
],
'sources': [
'test/core/util/cmdline.cc',
'test/core/util/debugger_macros.cc',
'test/core/util/eval_args_mock_endpoint.cc',
'test/core/util/fuzzer_util.cc',
'test/core/util/grpc_profiler.cc',
@ -1042,7 +1041,6 @@
],
'sources': [
'test/core/util/cmdline.cc',
'test/core/util/debugger_macros.cc',
'test/core/util/eval_args_mock_endpoint.cc',
'test/core/util/fuzzer_util.cc',
'test/core/util/grpc_profiler.cc',

@ -424,8 +424,6 @@ class CallData {
// will not run until after this method returns.
void AsyncPickDone(grpc_call_element* elem, grpc_error* error);
RefCountedPtr<SubchannelCall> subchannel_call() { return subchannel_call_; }
private:
class ResolverQueuedCallCanceller;
class LbQueuedCallCanceller;
@ -4588,9 +4586,3 @@ void grpc_client_channel_stop_connectivity_watch(
auto* chand = static_cast<ChannelData*>(elem->channel_data);
chand->RemoveConnectivityWatcher(watcher);
}
grpc_core::RefCountedPtr<grpc_core::SubchannelCall>
grpc_client_channel_get_subchannel_call(grpc_call_element* elem) {
auto* calld = static_cast<CallData*>(elem->call_data);
return calld->subchannel_call();
}

@ -75,8 +75,4 @@ void grpc_client_channel_stop_connectivity_watch(
grpc_channel_element* elem,
grpc_core::AsyncConnectivityStateWatcherInterface* watcher);
/* Debug helper: pull the subchannel call from a call stack element */
grpc_core::RefCountedPtr<grpc_core::SubchannelCall>
grpc_client_channel_get_subchannel_call(grpc_call_element* elem);
#endif // GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_H

@ -21,19 +21,6 @@ grpc_package(
visibility = "public",
)
grpc_cc_library(
name = "grpc_debugger_macros",
srcs = [
"debugger_macros.cc",
],
hdrs = [
"debugger_macros.h",
],
deps = [
"//:grpc_common",
],
)
grpc_cc_library(
name = "grpc_test_util_base",
srcs = [
@ -91,7 +78,6 @@ grpc_cc_library(
],
language = "C++",
deps = [
":grpc_debugger_macros",
":stack_tracer",
"//:gpr",
"//:grpc_base_c",

@ -1,57 +0,0 @@
/*
*
* Copyright 2016 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.
*
*/
/*
* A collection of 'macros' that help navigating the grpc object hierarchy
* Not intended to be robust for main-line code, often cuts across abstraction
* boundaries.
*/
#include <stdio.h>
#include "src/core/ext/filters/client_channel/client_channel.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/lib/channel/connected_channel.h"
#include "src/core/lib/surface/call.h"
grpc_stream* grpc_transport_stream_from_call(grpc_call* call) {
grpc_call_stack* cs = grpc_call_get_call_stack(call);
for (;;) {
grpc_call_element* el = grpc_call_stack_element(cs, cs->count - 1);
if (el->filter == &grpc_client_channel_filter) {
grpc_core::RefCountedPtr<grpc_core::SubchannelCall> scc =
grpc_client_channel_get_subchannel_call(el);
if (scc == nullptr) {
fprintf(stderr, "No subchannel-call");
fflush(stderr);
return nullptr;
}
cs = scc->GetCallStack();
} else if (el->filter == &grpc_connected_filter) {
return grpc_connected_channel_get_stream(el);
} else {
fprintf(stderr, "Unrecognized filter: %s", el->filter->name);
fflush(stderr);
return nullptr;
}
}
}
grpc_chttp2_stream* grpc_chttp2_stream_from_call(grpc_call* call) {
return reinterpret_cast<grpc_chttp2_stream*>(
grpc_transport_stream_from_call(call));
}

@ -1,27 +0,0 @@
/*
*
* Copyright 2016 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_UTIL_DEBUGGER_MACROS_H
#define GRPC_TEST_CORE_UTIL_DEBUGGER_MACROS_H
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/lib/surface/call.h"
grpc_chttp2_stream* grpc_chttp2_stream_from_call(grpc_call* call);
#endif /* GRPC_TEST_CORE_UTIL_DEBUGGER_MACROS_H */

@ -42,7 +42,6 @@
#include "src/core/lib/gpr/env.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/debugger_macros.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
#include "test/cpp/end2end/test_service_impl.h"
@ -145,18 +144,6 @@ class CFStreamTest : public ::testing::TestWithParam<TestScenario> {
return CreateCustomChannel(server_address.str(), channel_creds, args);
}
int GetStreamID(ClientContext& context) {
int stream_id = 0;
grpc_call* call = context.c_call();
if (call) {
grpc_chttp2_stream* stream = grpc_chttp2_stream_from_call(call);
if (stream) {
stream_id = stream->id;
}
}
return stream_id;
}
void SendRpc(
const std::unique_ptr<grpc::testing::EchoTestService::Stub>& stub,
bool expect_success = false) {
@ -166,13 +153,11 @@ class CFStreamTest : public ::testing::TestWithParam<TestScenario> {
request.set_message(msg);
ClientContext context;
Status status = stub->Echo(&context, request, response.get());
int stream_id = GetStreamID(context);
if (status.ok()) {
gpr_log(GPR_DEBUG, "RPC with stream_id %d succeeded", stream_id);
gpr_log(GPR_DEBUG, "RPC with succeeded");
EXPECT_EQ(msg, response->message());
} else {
gpr_log(GPR_DEBUG, "RPC with stream_id %d failed: %s", stream_id,
status.error_message().c_str());
gpr_log(GPR_DEBUG, "RPC failed: %s", status.error_message().c_str());
}
if (expect_success) {
EXPECT_TRUE(status.ok());
@ -392,17 +377,16 @@ TEST_P(CFStreamTest, NetworkFlapRpcsInFlight) {
++total_completions;
GPR_ASSERT(ok);
AsyncClientCall* call = static_cast<AsyncClientCall*>(got_tag);
int stream_id = GetStreamID(call->context);
if (!call->status.ok()) {
gpr_log(GPR_DEBUG, "RPC with stream_id %d failed with error: %s",
stream_id, call->status.error_message().c_str());
gpr_log(GPR_DEBUG, "RPC failed with error: %s",
call->status.error_message().c_str());
// Bring network up when RPCs start failing
if (network_down) {
NetworkUp();
network_down = false;
}
} else {
gpr_log(GPR_DEBUG, "RPC with stream_id %d succeeded", stream_id);
gpr_log(GPR_DEBUG, "RPC succeeded");
}
delete call;
}
@ -440,13 +424,12 @@ TEST_P(CFStreamTest, ConcurrentRpc) {
++total_completions;
GPR_ASSERT(ok);
AsyncClientCall* call = static_cast<AsyncClientCall*>(got_tag);
int stream_id = GetStreamID(call->context);
if (!call->status.ok()) {
gpr_log(GPR_DEBUG, "RPC with stream_id %d failed with error: %s",
stream_id, call->status.error_message().c_str());
gpr_log(GPR_DEBUG, "RPC failed with error: %s",
call->status.error_message().c_str());
// Bring network up when RPCs start failing
} else {
gpr_log(GPR_DEBUG, "RPC with stream_id %d succeeded", stream_id);
gpr_log(GPR_DEBUG, "RPC succeeded");
}
delete call;
}

@ -43,7 +43,6 @@
#include "src/core/lib/backoff/backoff.h"
#include "src/core/lib/gpr/env.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/core/util/debugger_macros.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
#include "test/cpp/end2end/test_service_impl.h"
@ -226,19 +225,10 @@ class FlakyNetworkTest : public ::testing::TestWithParam<TestScenario> {
}
Status status = stub->Echo(&context, request, response.get());
auto ok = status.ok();
int stream_id = 0;
grpc_call* call = context.c_call();
if (call) {
grpc_chttp2_stream* stream = grpc_chttp2_stream_from_call(call);
if (stream) {
stream_id = stream->id;
}
}
if (ok) {
gpr_log(GPR_DEBUG, "RPC with stream_id %d succeeded", stream_id);
gpr_log(GPR_DEBUG, "RPC succeeded");
} else {
gpr_log(GPR_DEBUG, "RPC with stream_id %d failed: %s", stream_id,
status.error_message().c_str());
gpr_log(GPR_DEBUG, "RPC failed: %s", status.error_message().c_str());
}
return ok;
}

Loading…
Cancel
Save