aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/end2end/tests/channelz.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/end2end/tests/channelz.cc')
-rw-r--r--test/core/end2end/tests/channelz.cc87
1 files changed, 63 insertions, 24 deletions
diff --git a/test/core/end2end/tests/channelz.cc b/test/core/end2end/tests/channelz.cc
index 533703a2be..922783aa0d 100644
--- a/test/core/end2end/tests/channelz.cc
+++ b/test/core/end2end/tests/channelz.cc
@@ -22,12 +22,14 @@
#include <string.h>
#include "src/core/lib/surface/channel.h"
+#include "src/core/lib/surface/server.h"
#include <grpc/byte_buffer.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
+#include "src/core/lib/channel/channelz_registry.h"
#include "src/core/lib/gpr/string.h"
#include "test/core/end2end/cq_verifier.h"
@@ -198,17 +200,23 @@ static void run_one_request(grpc_end2end_test_config config,
static void test_channelz(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f;
- grpc_arg client_a;
- client_a.type = GRPC_ARG_INTEGER;
- client_a.key = const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ);
- client_a.value.integer = true;
- grpc_channel_args client_args = {1, &client_a};
+ grpc_arg arg[] = {
+ grpc_channel_arg_integer_create(
+ const_cast<char*>(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE),
+ 0),
+ grpc_channel_arg_integer_create(
+ const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ), true)};
+ grpc_channel_args args = {GPR_ARRAY_SIZE(arg), arg};
- f = begin_test(config, "test_channelz", &client_args, nullptr);
+ f = begin_test(config, "test_channelz", &args, &args);
grpc_core::channelz::ChannelNode* channelz_channel =
grpc_channel_get_channelz_node(f.client);
-
GPR_ASSERT(channelz_channel != nullptr);
+
+ grpc_core::channelz::ServerNode* channelz_server =
+ grpc_server_get_channelz_node(f.server);
+ GPR_ASSERT(channelz_server != nullptr);
+
char* json = channelz_channel->RenderJsonString();
GPR_ASSERT(json != nullptr);
// nothing is present yet
@@ -231,16 +239,30 @@ static void test_channelz(grpc_end2end_test_config config) {
json = channelz_channel->RenderJsonString();
GPR_ASSERT(json != nullptr);
- gpr_log(GPR_INFO, "%s", json);
GPR_ASSERT(nullptr != strstr(json, "\"callsStarted\":\"2\""));
GPR_ASSERT(nullptr != strstr(json, "\"callsFailed\":\"1\""));
GPR_ASSERT(nullptr != strstr(json, "\"callsSucceeded\":\"1\""));
- // channel tracing is not enables, so these should not be preset.
+ // channel tracing is not enabled, so these should not be preset.
GPR_ASSERT(nullptr == strstr(json, "\"trace\""));
GPR_ASSERT(nullptr == strstr(json, "\"description\":\"Channel created\""));
GPR_ASSERT(nullptr == strstr(json, "\"severity\":\"CT_INFO\""));
gpr_free(json);
+ json = channelz_server->RenderJsonString();
+ GPR_ASSERT(json != nullptr);
+ GPR_ASSERT(nullptr != strstr(json, "\"callsStarted\":\"2\""));
+ GPR_ASSERT(nullptr != strstr(json, "\"callsFailed\":\"1\""));
+ GPR_ASSERT(nullptr != strstr(json, "\"callsSucceeded\":\"1\""));
+ // channel tracing is not enabled, so these should not be preset.
+ GPR_ASSERT(nullptr == strstr(json, "\"trace\""));
+ GPR_ASSERT(nullptr == strstr(json, "\"description\":\"Channel created\""));
+ GPR_ASSERT(nullptr == strstr(json, "\"severity\":\"CT_INFO\""));
+ gpr_free(json);
+
+ json = channelz_server->RenderServerSockets(0);
+ GPR_ASSERT(nullptr != strstr(json, "\"socketRef\":"));
+ gpr_free(json);
+
end_test(&f);
config.tear_down_data(&f);
}
@@ -248,30 +270,39 @@ static void test_channelz(grpc_end2end_test_config config) {
static void test_channelz_with_channel_trace(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f;
- grpc_arg client_a[2];
- client_a[0].type = GRPC_ARG_INTEGER;
- client_a[0].key =
- const_cast<char*>(GRPC_ARG_MAX_CHANNEL_TRACE_EVENTS_PER_NODE);
- client_a[0].value.integer = 5;
- client_a[1].type = GRPC_ARG_INTEGER;
- client_a[1].key = const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ);
- client_a[1].value.integer = true;
- grpc_channel_args client_args = {GPR_ARRAY_SIZE(client_a), client_a};
-
- f = begin_test(config, "test_channelz_with_channel_trace", &client_args,
- nullptr);
+ grpc_arg arg[] = {
+ grpc_channel_arg_integer_create(
+ const_cast<char*>(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE),
+ 1024 * 1024),
+ grpc_channel_arg_integer_create(
+ const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ), true)};
+ grpc_channel_args args = {GPR_ARRAY_SIZE(arg), arg};
+
+ f = begin_test(config, "test_channelz_with_channel_trace", &args, &args);
grpc_core::channelz::ChannelNode* channelz_channel =
grpc_channel_get_channelz_node(f.client);
-
GPR_ASSERT(channelz_channel != nullptr);
+
+ grpc_core::channelz::ServerNode* channelz_server =
+ grpc_server_get_channelz_node(f.server);
+ GPR_ASSERT(channelz_server != nullptr);
+
+ run_one_request(config, f, true);
+
char* json = channelz_channel->RenderJsonString();
GPR_ASSERT(json != nullptr);
- gpr_log(GPR_INFO, "%s", json);
GPR_ASSERT(nullptr != strstr(json, "\"trace\""));
GPR_ASSERT(nullptr != strstr(json, "\"description\":\"Channel created\""));
GPR_ASSERT(nullptr != strstr(json, "\"severity\":\"CT_INFO\""));
gpr_free(json);
+ json = channelz_server->RenderJsonString();
+ GPR_ASSERT(json != nullptr);
+ GPR_ASSERT(nullptr != strstr(json, "\"trace\""));
+ GPR_ASSERT(nullptr != strstr(json, "\"description\":\"Server created\""));
+ GPR_ASSERT(nullptr != strstr(json, "\"severity\":\"CT_INFO\""));
+ gpr_free(json);
+
end_test(&f);
config.tear_down_data(&f);
}
@@ -279,7 +310,15 @@ static void test_channelz_with_channel_trace(grpc_end2end_test_config config) {
static void test_channelz_disabled(grpc_end2end_test_config config) {
grpc_end2end_test_fixture f;
- f = begin_test(config, "test_channelz_disabled", nullptr, nullptr);
+ grpc_arg arg[] = {
+ grpc_channel_arg_integer_create(
+ const_cast<char*>(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE),
+ 0),
+ grpc_channel_arg_integer_create(
+ const_cast<char*>(GRPC_ARG_ENABLE_CHANNELZ), false)};
+ grpc_channel_args args = {GPR_ARRAY_SIZE(arg), arg};
+
+ f = begin_test(config, "test_channelz_disabled", &args, &args);
grpc_core::channelz::ChannelNode* channelz_channel =
grpc_channel_get_channelz_node(f.client);
GPR_ASSERT(channelz_channel == nullptr);