Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 9f7970e

Browse files
authored
Fix port selection in and reenable the stats_plugin_end2end_test. (#25)
1 parent ea7a781 commit 9f7970e

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

opencensus/plugins/BUILD

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,19 @@ cc_library(
5858

5959
# TODO: grpc_plugin_end2end_test
6060

61-
# TODO: Enable this test:
62-
# cc_test(
63-
# name = "stats_plugin_end2end_test",
64-
# srcs = ["internal/stats_plugin_end2end_test.cc"],
65-
# copts = TEST_COPTS,
66-
# linkopts = [
67-
# "-pthread",
68-
# ],
69-
# deps = [
70-
# ":grpc_plugin",
71-
# "//opencensus/plugins/internal/testing:echo_proto",
72-
# "//opencensus/stats",
73-
# "@com_github_grpc_grpc//:grpc++",
74-
# "@com_github_grpc_grpc//test/core/util:grpc_test_util_base",
75-
# "@com_google_absl//absl/strings",
76-
# "@com_google_googletest//:gtest_main",
77-
# ],
78-
# )
61+
cc_test(
62+
name = "stats_plugin_end2end_test",
63+
srcs = ["internal/stats_plugin_end2end_test.cc"],
64+
copts = TEST_COPTS,
65+
linkopts = [
66+
"-pthread",
67+
],
68+
deps = [
69+
":grpc_plugin",
70+
"//opencensus/plugins/internal/testing:echo_proto",
71+
"//opencensus/stats",
72+
"@com_github_grpc_grpc//:grpc++",
73+
"@com_google_absl//absl/strings",
74+
"@com_google_googletest//:gtest_main",
75+
],
76+
)

opencensus/plugins/internal/stats_plugin_end2end_test.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "opencensus/plugins/grpc_plugin.h"
2525
#include "opencensus/plugins/internal/testing/echo.grpc.pb.h"
2626
#include "opencensus/stats/stats.h"
27-
#include "test/core/util/port.h"
2827

2928
namespace opencensus {
3029
namespace testing {
@@ -51,12 +50,15 @@ class StatsPluginEnd2EndTest : public ::testing::Test {
5150
void SetUp() {
5251
// Set up a synchronous server on a different thread to avoid the asynch
5352
// interface.
54-
server_address_ = absl::StrCat("[::]:", grpc_pick_unused_port_or_die());
5553
::grpc::ServerBuilder builder;
56-
builder.AddListeningPort(server_address_,
57-
::grpc::InsecureServerCredentials());
54+
int port;
55+
builder.AddListeningPort("[::]:0", ::grpc::InsecureServerCredentials(),
56+
&port);
5857
builder.RegisterService(&service_);
5958
server_ = builder.BuildAndStart();
59+
ASSERT_NE(nullptr, server_);
60+
ASSERT_NE(0, port);
61+
server_address_ = absl::StrCat("[::]:", port);
6062
server_thread_ = std::thread(&StatsPluginEnd2EndTest::RunServerLoop, this);
6163

6264
stub_ = EchoService::NewStub(::grpc::CreateChannel(

0 commit comments

Comments
 (0)