XdsChannelStackModifier class (#27744)

* ChannelStackModifier class

* Regenerate projects

* clang-tidy

* Use CoreConfiguration for inserting xDS HTTP filters

* New lines

* Move test to test/core/xds

* Add comment for placement of filter stack

* Fix sanity

* Fix memory leak - destroy builder

* Don't build xds_channel_stack_modifier_test on non-bazel build systems due to census dependency
pull/27827/head
Yash Tibrewal 3 years ago committed by GitHub
parent eab375e439
commit 6d2a641dd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      BUILD
  2. 1
      CMakeLists.txt
  3. 2
      Makefile
  4. 2
      build_autogenerated.yaml
  5. 1
      config.m4
  6. 1
      config.w32
  7. 2
      gRPC-C++.podspec
  8. 3
      gRPC-Core.podspec
  9. 2
      grpc.gemspec
  10. 1
      grpc.gyp
  11. 2
      package.xml
  12. 113
      src/core/ext/xds/xds_channel_stack_modifier.cc
  13. 52
      src/core/ext/xds/xds_channel_stack_modifier.h
  14. 7
      src/core/plugin_registry/grpc_plugin_registry.cc
  15. 1
      src/python/grpcio/grpc_core_dependencies.py
  16. 15
      test/core/xds/BUILD
  17. 171
      test/core/xds/xds_channel_stack_modifier_test.cc
  18. 3
      tools/buildgen/extract_metadata_from_bazel_xml.py
  19. 2
      tools/doxygen/Doxyfile.c++.internal
  20. 2
      tools/doxygen/Doxyfile.core.internal

18
BUILD

@ -2476,6 +2476,23 @@ grpc_cc_library(
],
)
grpc_cc_library(
name = "grpc_xds_channel_stack_modifier",
srcs = [
"src/core/ext/xds/xds_channel_stack_modifier.cc",
],
hdrs = [
"src/core/ext/xds/xds_channel_stack_modifier.h",
],
language = "c++",
deps = [
"channel_init",
"config",
"gpr_base",
"grpc_base",
],
)
grpc_cc_library(
name = "grpc_xds_server_config_fetcher",
srcs = [
@ -2488,6 +2505,7 @@ grpc_cc_library(
deps = [
"gpr_base",
"grpc_base",
"grpc_xds_channel_stack_modifier",
"grpc_xds_client",
],
)

1
CMakeLists.txt generated

@ -1797,6 +1797,7 @@ add_library(grpc
src/core/ext/xds/xds_api.cc
src/core/ext/xds/xds_bootstrap.cc
src/core/ext/xds/xds_certificate_provider.cc
src/core/ext/xds/xds_channel_stack_modifier.cc
src/core/ext/xds/xds_client.cc
src/core/ext/xds/xds_client_stats.cc
src/core/ext/xds/xds_http_fault_filter.cc

2
Makefile generated

@ -1349,6 +1349,7 @@ LIBGRPC_SRC = \
src/core/ext/xds/xds_api.cc \
src/core/ext/xds/xds_bootstrap.cc \
src/core/ext/xds/xds_certificate_provider.cc \
src/core/ext/xds/xds_channel_stack_modifier.cc \
src/core/ext/xds/xds_client.cc \
src/core/ext/xds/xds_client_stats.cc \
src/core/ext/xds/xds_http_fault_filter.cc \
@ -2902,6 +2903,7 @@ src/core/ext/xds/file_watcher_certificate_provider_factory.cc: $(OPENSSL_DEP)
src/core/ext/xds/xds_api.cc: $(OPENSSL_DEP)
src/core/ext/xds/xds_bootstrap.cc: $(OPENSSL_DEP)
src/core/ext/xds/xds_certificate_provider.cc: $(OPENSSL_DEP)
src/core/ext/xds/xds_channel_stack_modifier.cc: $(OPENSSL_DEP)
src/core/ext/xds/xds_client.cc: $(OPENSSL_DEP)
src/core/ext/xds/xds_client_stats.cc: $(OPENSSL_DEP)
src/core/ext/xds/xds_http_fault_filter.cc: $(OPENSSL_DEP)

@ -717,6 +717,7 @@ libs:
- src/core/ext/xds/xds_bootstrap.h
- src/core/ext/xds/xds_certificate_provider.h
- src/core/ext/xds/xds_channel_args.h
- src/core/ext/xds/xds_channel_stack_modifier.h
- src/core/ext/xds/xds_client.h
- src/core/ext/xds/xds_client_stats.h
- src/core/ext/xds/xds_http_fault_filter.h
@ -1263,6 +1264,7 @@ libs:
- src/core/ext/xds/xds_api.cc
- src/core/ext/xds/xds_bootstrap.cc
- src/core/ext/xds/xds_certificate_provider.cc
- src/core/ext/xds/xds_channel_stack_modifier.cc
- src/core/ext/xds/xds_client.cc
- src/core/ext/xds/xds_client_stats.cc
- src/core/ext/xds/xds_http_fault_filter.cc

1
config.m4 generated

@ -357,6 +357,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/xds/xds_api.cc \
src/core/ext/xds/xds_bootstrap.cc \
src/core/ext/xds/xds_certificate_provider.cc \
src/core/ext/xds/xds_channel_stack_modifier.cc \
src/core/ext/xds/xds_client.cc \
src/core/ext/xds/xds_client_stats.cc \
src/core/ext/xds/xds_http_fault_filter.cc \

1
config.w32 generated

@ -323,6 +323,7 @@ if (PHP_GRPC != "no") {
"src\\core\\ext\\xds\\xds_api.cc " +
"src\\core\\ext\\xds\\xds_bootstrap.cc " +
"src\\core\\ext\\xds\\xds_certificate_provider.cc " +
"src\\core\\ext\\xds\\xds_channel_stack_modifier.cc " +
"src\\core\\ext\\xds\\xds_client.cc " +
"src\\core\\ext\\xds\\xds_client_stats.cc " +
"src\\core\\ext\\xds\\xds_http_fault_filter.cc " +

2
gRPC-C++.podspec generated

@ -506,6 +506,7 @@ Pod::Spec.new do |s|
'src/core/ext/xds/xds_bootstrap.h',
'src/core/ext/xds/xds_certificate_provider.h',
'src/core/ext/xds/xds_channel_args.h',
'src/core/ext/xds/xds_channel_stack_modifier.h',
'src/core/ext/xds/xds_client.h',
'src/core/ext/xds/xds_client_stats.h',
'src/core/ext/xds/xds_http_fault_filter.h',
@ -1178,6 +1179,7 @@ Pod::Spec.new do |s|
'src/core/ext/xds/xds_bootstrap.h',
'src/core/ext/xds/xds_certificate_provider.h',
'src/core/ext/xds/xds_channel_args.h',
'src/core/ext/xds/xds_channel_stack_modifier.h',
'src/core/ext/xds/xds_client.h',
'src/core/ext/xds/xds_client_stats.h',
'src/core/ext/xds/xds_http_fault_filter.h',

3
gRPC-Core.podspec generated

@ -803,6 +803,8 @@ Pod::Spec.new do |s|
'src/core/ext/xds/xds_certificate_provider.cc',
'src/core/ext/xds/xds_certificate_provider.h',
'src/core/ext/xds/xds_channel_args.h',
'src/core/ext/xds/xds_channel_stack_modifier.cc',
'src/core/ext/xds/xds_channel_stack_modifier.h',
'src/core/ext/xds/xds_client.cc',
'src/core/ext/xds/xds_client.h',
'src/core/ext/xds/xds_client_stats.cc',
@ -1754,6 +1756,7 @@ Pod::Spec.new do |s|
'src/core/ext/xds/xds_bootstrap.h',
'src/core/ext/xds/xds_certificate_provider.h',
'src/core/ext/xds/xds_channel_args.h',
'src/core/ext/xds/xds_channel_stack_modifier.h',
'src/core/ext/xds/xds_client.h',
'src/core/ext/xds/xds_client_stats.h',
'src/core/ext/xds/xds_http_fault_filter.h',

2
grpc.gemspec generated

@ -723,6 +723,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/xds/xds_certificate_provider.cc )
s.files += %w( src/core/ext/xds/xds_certificate_provider.h )
s.files += %w( src/core/ext/xds/xds_channel_args.h )
s.files += %w( src/core/ext/xds/xds_channel_stack_modifier.cc )
s.files += %w( src/core/ext/xds/xds_channel_stack_modifier.h )
s.files += %w( src/core/ext/xds/xds_client.cc )
s.files += %w( src/core/ext/xds/xds_client.h )
s.files += %w( src/core/ext/xds/xds_client_stats.cc )

1
grpc.gyp generated

@ -790,6 +790,7 @@
'src/core/ext/xds/xds_api.cc',
'src/core/ext/xds/xds_bootstrap.cc',
'src/core/ext/xds/xds_certificate_provider.cc',
'src/core/ext/xds/xds_channel_stack_modifier.cc',
'src/core/ext/xds/xds_client.cc',
'src/core/ext/xds/xds_client_stats.cc',
'src/core/ext/xds/xds_http_fault_filter.cc',

2
package.xml generated

@ -703,6 +703,8 @@
<file baseinstalldir="/" name="src/core/ext/xds/xds_certificate_provider.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_certificate_provider.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_channel_args.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_channel_stack_modifier.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_channel_stack_modifier.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_client.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_client.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_client_stats.cc" role="src" />

@ -0,0 +1,113 @@
//
//
// Copyright 2021 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 "src/core/ext/xds/xds_channel_stack_modifier.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/surface/channel_init.h"
namespace grpc_core {
namespace {
void* XdsChannelStackModifierArgCopy(void* p) {
XdsChannelStackModifier* arg = static_cast<XdsChannelStackModifier*>(p);
return arg->Ref().release();
}
void XdsChannelStackModifierArgDestroy(void* p) {
XdsChannelStackModifier* arg = static_cast<XdsChannelStackModifier*>(p);
arg->Unref();
}
int XdsChannelStackModifierArgCmp(void* p, void* q) {
return QsortCompare(p, q);
}
const grpc_arg_pointer_vtable kChannelArgVtable = {
XdsChannelStackModifierArgCopy, XdsChannelStackModifierArgDestroy,
XdsChannelStackModifierArgCmp};
const char* kXdsChannelStackModifierChannelArgName =
"grpc.internal.xds_channel_stack_modifier";
} // namespace
bool XdsChannelStackModifier::ModifyChannelStack(
grpc_channel_stack_builder* builder) {
// Insert the filters after the census filter if present.
grpc_channel_stack_builder_iterator* it =
grpc_channel_stack_builder_create_iterator_at_first(builder);
while (grpc_channel_stack_builder_move_next(it)) {
if (grpc_channel_stack_builder_iterator_is_end(it)) break;
const char* filter_name_at_it =
grpc_channel_stack_builder_iterator_filter_name(it);
if (strcmp("census_server", filter_name_at_it) == 0 ||
strcmp("opencensus_server", filter_name_at_it) == 0) {
break;
}
}
if (grpc_channel_stack_builder_iterator_is_end(it)) {
// No census filter found. Reset iterator to the beginning. This will result
// in prepending the list of xDS HTTP filters to the current stack. Note
// that this stage is run before the stage that adds the top server filter,
// resulting in these filters being finally placed after the `server`
// filter.
grpc_channel_stack_builder_iterator_destroy(it);
it = grpc_channel_stack_builder_create_iterator_at_first(builder);
}
GPR_ASSERT(grpc_channel_stack_builder_move_next(it));
for (const grpc_channel_filter* filter : filters_) {
GPR_ASSERT(grpc_channel_stack_builder_add_filter_before(it, filter, nullptr,
nullptr));
}
grpc_channel_stack_builder_iterator_destroy(it);
return true;
}
grpc_arg XdsChannelStackModifier::MakeChannelArg() const {
return grpc_channel_arg_pointer_create(
const_cast<char*>(kXdsChannelStackModifierChannelArgName),
const_cast<XdsChannelStackModifier*>(this), &kChannelArgVtable);
}
RefCountedPtr<XdsChannelStackModifier>
XdsChannelStackModifier::GetFromChannelArgs(const grpc_channel_args& args) {
XdsChannelStackModifier* config_selector_provider =
grpc_channel_args_find_pointer<XdsChannelStackModifier>(
&args, kXdsChannelStackModifierChannelArgName);
return config_selector_provider != nullptr ? config_selector_provider->Ref()
: nullptr;
}
void RegisterXdsChannelStackModifier(CoreConfiguration::Builder* builder) {
builder->channel_init()->RegisterStage(
GRPC_SERVER_CHANNEL, INT_MAX, [](grpc_channel_stack_builder* builder) {
grpc_core::RefCountedPtr<XdsChannelStackModifier>
channel_stack_modifier =
XdsChannelStackModifier::GetFromChannelArgs(
*grpc_channel_stack_builder_get_channel_arguments(builder));
if (channel_stack_modifier != nullptr) {
return channel_stack_modifier->ModifyChannelStack(builder);
}
return true;
});
}
} // namespace grpc_core

@ -0,0 +1,52 @@
//
//
// Copyright 2021 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_CORE_EXT_XDS_XDS_CHANNEL_STACK_MODIFIER_H
#define GRPC_CORE_EXT_XDS_XDS_CHANNEL_STACK_MODIFIER_H
#include <grpc/support/port_platform.h>
#include <vector>
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/gprpp/ref_counted.h"
namespace grpc_core {
// XdsChannelStackModifier allows for inserting xDS HTTP filters into the
// channel stack. It is registered to mutate the `grpc_channel_stack_builder`
// object via ChannelInit::Builder::RegisterStage.
class XdsChannelStackModifier : public RefCounted<XdsChannelStackModifier> {
public:
explicit XdsChannelStackModifier(
std::vector<const grpc_channel_filter*> filters)
: filters_(std::move(filters)) {}
// Returns true on success, false otherwise.
bool ModifyChannelStack(grpc_channel_stack_builder* builder);
grpc_arg MakeChannelArg() const;
static RefCountedPtr<XdsChannelStackModifier> GetFromChannelArgs(
const grpc_channel_args& args);
private:
std::vector<const grpc_channel_filter*> filters_;
};
} // namespace grpc_core
#endif /* GRPC_CORE_EXT_XDS_XDS_CHANNEL_STACK_MODIFIER_H */

@ -165,6 +165,10 @@ extern void RegisterMessageSizeFilter(CoreConfiguration::Builder* builder);
extern void RegisterSecurityFilters(CoreConfiguration::Builder* builder);
extern void RegisterServiceConfigChannelArgFilter(
CoreConfiguration::Builder* builder);
#ifndef GRPC_NO_XDS
extern void RegisterXdsChannelStackModifier(
CoreConfiguration::Builder* builder);
#endif
void BuildCoreConfiguration(CoreConfiguration::Builder* builder) {
BuildClientChannelConfiguration(builder);
@ -177,6 +181,9 @@ void BuildCoreConfiguration(CoreConfiguration::Builder* builder) {
RegisterDeadlineFilter(builder);
RegisterMessageSizeFilter(builder);
RegisterServiceConfigChannelArgFilter(builder);
#ifndef GRPC_NO_XDS
RegisterXdsChannelStackModifier(builder);
#endif
// Run last so it gets a consistent location.
// TODO(ctiller): Is this actually necessary?
RegisterSecurityFilters(builder);

@ -332,6 +332,7 @@ CORE_SOURCE_FILES = [
'src/core/ext/xds/xds_api.cc',
'src/core/ext/xds/xds_bootstrap.cc',
'src/core/ext/xds/xds_certificate_provider.cc',
'src/core/ext/xds/xds_channel_stack_modifier.cc',
'src/core/ext/xds/xds_client.cc',
'src/core/ext/xds/xds_client_stats.cc',
'src/core/ext/xds/xds_http_fault_filter.cc',

@ -69,6 +69,21 @@ grpc_cc_test(
],
)
grpc_cc_test(
name = "xds_channel_stack_modifier_test",
srcs = ["xds_channel_stack_modifier_test.cc"],
external_deps = ["gtest"],
language = "C++",
tags = ["no_test_ios"],
deps = [
"//:gpr",
"//:grpc",
"//:grpc_opencensus_plugin",
"//:grpc_xds_channel_stack_modifier",
"//test/core/util:grpc_test_util",
],
)
grpc_cc_test(
name = "xds_certificate_provider_test",
srcs = ["xds_certificate_provider_test.cc"],

@ -0,0 +1,171 @@
//
//
// Copyright 2021 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 "src/core/ext/xds/xds_channel_stack_modifier.h"
#include <gtest/gtest.h>
#include <grpcpp/opencensus.h>
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/transport/transport_impl.h"
#include "test/core/util/test_config.h"
namespace grpc_core {
namespace testing {
namespace {
// Test that XdsChannelStackModifier can be safely copied to channel args
// and destroyed
TEST(XdsChannelStackModifierTest, CopyChannelArgs) {
grpc_init();
auto server_config_selector_provider =
MakeRefCounted<XdsChannelStackModifier>(
std::vector<const grpc_channel_filter*>{});
grpc_arg arg = server_config_selector_provider->MakeChannelArg();
grpc_channel_args* args = grpc_channel_args_copy_and_add(nullptr, &arg, 1);
EXPECT_EQ(server_config_selector_provider,
XdsChannelStackModifier::GetFromChannelArgs(*args));
grpc_channel_args_destroy(args);
grpc_shutdown();
}
// Test compare on channel args with the same XdsChannelStackModifier
TEST(XdsChannelStackModifierTest, ChannelArgsCompare) {
grpc_init();
auto server_config_selector_provider =
MakeRefCounted<XdsChannelStackModifier>(
std::vector<const grpc_channel_filter*>{});
grpc_arg arg = server_config_selector_provider->MakeChannelArg();
grpc_channel_args* args = grpc_channel_args_copy_and_add(nullptr, &arg, 1);
grpc_channel_args* new_args = grpc_channel_args_copy(args);
EXPECT_EQ(XdsChannelStackModifier::GetFromChannelArgs(*new_args),
XdsChannelStackModifier::GetFromChannelArgs(*args));
grpc_channel_args_destroy(args);
grpc_channel_args_destroy(new_args);
grpc_shutdown();
}
constexpr char kTestFilter1[] = "test_filter_1";
constexpr char kTestFilter2[] = "test_filter_2";
// Test filters insertion
TEST(XdsChannelStackModifierTest, XdsHttpFiltersInsertion) {
CoreConfiguration::Reset();
grpc_init();
// Add 2 test filters to XdsChannelStackModifier
const grpc_channel_filter test_filter_1 = {
nullptr, nullptr, 0, nullptr, nullptr, nullptr,
0, nullptr, nullptr, nullptr, kTestFilter1};
const grpc_channel_filter test_filter_2 = {
nullptr, nullptr, 0, nullptr, nullptr, nullptr,
0, nullptr, nullptr, nullptr, kTestFilter2};
auto server_config_selector_provider =
MakeRefCounted<XdsChannelStackModifier>(
std::vector<const grpc_channel_filter*>{&test_filter_1,
&test_filter_2});
grpc_arg arg = server_config_selector_provider->MakeChannelArg();
// Create a phony grpc_channel_stack_builder object
grpc_channel_args* args = grpc_channel_args_copy_and_add(nullptr, &arg, 1);
grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
grpc_channel_stack_builder_set_channel_arguments(builder, args);
grpc_channel_args_destroy(args);
grpc_transport_vtable fake_transport_vtable;
memset(&fake_transport_vtable, 0, sizeof(grpc_transport_vtable));
fake_transport_vtable.name = "fake";
grpc_transport fake_transport = {&fake_transport_vtable};
grpc_channel_stack_builder_set_transport(builder, &fake_transport);
// Construct channel stack and verify that the test filters were successfully
// added
ASSERT_TRUE(CoreConfiguration::Get().channel_init().CreateStack(
builder, GRPC_SERVER_CHANNEL));
grpc_channel_stack_builder_iterator* it =
grpc_channel_stack_builder_create_iterator_at_first(builder);
ASSERT_TRUE(grpc_channel_stack_builder_move_next(it));
ASSERT_STREQ(grpc_channel_stack_builder_iterator_filter_name(it), "server");
ASSERT_TRUE(grpc_channel_stack_builder_move_next(it));
ASSERT_STREQ(grpc_channel_stack_builder_iterator_filter_name(it),
kTestFilter1);
ASSERT_TRUE(grpc_channel_stack_builder_move_next(it));
ASSERT_STREQ(grpc_channel_stack_builder_iterator_filter_name(it),
kTestFilter2);
grpc_channel_stack_builder_iterator_destroy(it);
grpc_channel_stack_builder_destroy(builder);
grpc_shutdown();
}
// Test filters insertion with OpenCensus plugin registered
TEST(XdsChannelStackModifierTest, XdsHttpFiltersInsertionAfterCensus) {
CoreConfiguration::Reset();
grpc::RegisterOpenCensusPlugin();
grpc_init();
// Add 2 test filters to XdsChannelStackModifier
const grpc_channel_filter test_filter_1 = {
nullptr, nullptr, 0, nullptr, nullptr, nullptr,
0, nullptr, nullptr, nullptr, kTestFilter1};
const grpc_channel_filter test_filter_2 = {
nullptr, nullptr, 0, nullptr, nullptr, nullptr,
0, nullptr, nullptr, nullptr, kTestFilter2};
auto server_config_selector_provider =
MakeRefCounted<XdsChannelStackModifier>(
std::vector<const grpc_channel_filter*>{&test_filter_1,
&test_filter_2});
grpc_arg arg = server_config_selector_provider->MakeChannelArg();
// Create a phony grpc_channel_stack_builder object
grpc_channel_args* args = grpc_channel_args_copy_and_add(nullptr, &arg, 1);
grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create();
grpc_channel_stack_builder_set_channel_arguments(builder, args);
grpc_channel_args_destroy(args);
grpc_transport_vtable fake_transport_vtable;
memset(&fake_transport_vtable, 0, sizeof(grpc_transport_vtable));
fake_transport_vtable.name = "fake";
grpc_transport fake_transport = {&fake_transport_vtable};
grpc_channel_stack_builder_set_transport(builder, &fake_transport);
// Construct channel stack and verify that the test filters were successfully
// added after the census filter
ASSERT_TRUE(CoreConfiguration::Get().channel_init().CreateStack(
builder, GRPC_SERVER_CHANNEL));
grpc_channel_stack_builder_iterator* it =
grpc_channel_stack_builder_create_iterator_at_first(builder);
ASSERT_TRUE(grpc_channel_stack_builder_move_next(it));
ASSERT_STREQ(grpc_channel_stack_builder_iterator_filter_name(it), "server");
ASSERT_TRUE(grpc_channel_stack_builder_move_next(it));
ASSERT_STREQ(grpc_channel_stack_builder_iterator_filter_name(it),
"opencensus_server");
ASSERT_TRUE(grpc_channel_stack_builder_move_next(it));
ASSERT_STREQ(grpc_channel_stack_builder_iterator_filter_name(it),
kTestFilter1);
ASSERT_TRUE(grpc_channel_stack_builder_move_next(it));
ASSERT_STREQ(grpc_channel_stack_builder_iterator_filter_name(it),
kTestFilter2);
grpc_channel_stack_builder_iterator_destroy(it);
grpc_channel_stack_builder_destroy(builder);
grpc_shutdown();
}
} // namespace
} // namespace testing
} // namespace grpc_core
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
grpc::testing::TestEnvironment env(argc, argv);
int ret = RUN_ALL_TESTS();
return ret;
}

@ -491,7 +491,8 @@ def _exclude_unwanted_cc_tests(tests: List[str]) -> List[str]:
# we have trouble with census dependency outside of bazel
tests = [
test for test in tests
if not test.startswith('test/cpp/ext/filters/census:')
if not test.startswith('test/cpp/ext/filters/census:') and
not test.startswith('test/core/xds:xds_channel_stack_modifier_test')
]
# missing opencensus/stats/stats.h

@ -1656,6 +1656,8 @@ src/core/ext/xds/xds_bootstrap.h \
src/core/ext/xds/xds_certificate_provider.cc \
src/core/ext/xds/xds_certificate_provider.h \
src/core/ext/xds/xds_channel_args.h \
src/core/ext/xds/xds_channel_stack_modifier.cc \
src/core/ext/xds/xds_channel_stack_modifier.h \
src/core/ext/xds/xds_client.cc \
src/core/ext/xds/xds_client.h \
src/core/ext/xds/xds_client_stats.cc \

@ -1492,6 +1492,8 @@ src/core/ext/xds/xds_bootstrap.h \
src/core/ext/xds/xds_certificate_provider.cc \
src/core/ext/xds/xds_certificate_provider.h \
src/core/ext/xds/xds_channel_args.h \
src/core/ext/xds/xds_channel_stack_modifier.cc \
src/core/ext/xds/xds_channel_stack_modifier.h \
src/core/ext/xds/xds_client.cc \
src/core/ext/xds/xds_client.h \
src/core/ext/xds/xds_client_stats.cc \

Loading…
Cancel
Save