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

Commit a66d09a

Browse files
Ian Sturdyg-easy
authored andcommitted
Reenable the stats_plugin_end2end_test on ci. (#69)
Two changes: - Switch to IPv4--for some reason this fixes the consistent timeouts, despite our Travis configuration nominally supporting IPv6 loopback. - Add some short sleeps to give the server a chance to update stats before verifying.
1 parent a8392de commit a66d09a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

opencensus/plugins/grpc/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ cc_test(
6565
linkopts = [
6666
"-pthread",
6767
],
68-
tags = ["noci"], # TODO: determine why this times out on Travis and reenable.
6968
deps = [
7069
":grpc_plugin",
7170
"//opencensus/plugins/grpc/internal/testing:echo_proto",
7271
"//opencensus/stats",
7372
"@com_github_grpc_grpc//:grpc++",
7473
"@com_google_absl//absl/strings",
74+
"@com_google_absl//absl/time",
7575
"@com_google_googletest//:gtest_main",
7676
],
7777
)

opencensus/plugins/grpc/internal/stats_plugin_end2end_test.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include "absl/strings/str_cat.h"
2020
#include "absl/strings/string_view.h"
21+
#include "absl/time/clock.h"
22+
#include "absl/time/time.h"
2123
#include "gmock/gmock.h"
2224
#include "gtest/gtest.h"
2325
#include "include/grpc++/grpc++.h"
@@ -52,13 +54,14 @@ class StatsPluginEnd2EndTest : public ::testing::Test {
5254
// interface.
5355
::grpc::ServerBuilder builder;
5456
int port;
55-
builder.AddListeningPort("[::]:0", ::grpc::InsecureServerCredentials(),
57+
// Use IPv4 here because it's less flaky than IPv6 ("[::]:0") on Travis.
58+
builder.AddListeningPort("0.0.0.0:0", ::grpc::InsecureServerCredentials(),
5659
&port);
5760
builder.RegisterService(&service_);
5861
server_ = builder.BuildAndStart();
5962
ASSERT_NE(nullptr, server_);
6063
ASSERT_NE(0, port);
61-
server_address_ = absl::StrCat("[::]:", port);
64+
server_address_ = absl::StrCat("0.0.0.0:", port);
6265
server_thread_ = std::thread(&StatsPluginEnd2EndTest::RunServerLoop, this);
6366

6467
stub_ = EchoService::NewStub(::grpc::CreateChannel(
@@ -123,6 +126,7 @@ TEST_F(StatsPluginEnd2EndTest, ErrorCount) {
123126
::grpc::ClientContext context;
124127
::grpc::Status status = stub_->Echo(&context, request, &response);
125128
}
129+
absl::SleepFor(absl::Milliseconds(500));
126130

127131
EXPECT_THAT(client_method_view.GetData().double_data(),
128132
::testing::UnorderedElementsAre(
@@ -172,6 +176,7 @@ TEST_F(StatsPluginEnd2EndTest, RequestResponseBytes) {
172176
ASSERT_TRUE(status.ok());
173177
EXPECT_EQ("foo", response.message());
174178
}
179+
absl::SleepFor(absl::Milliseconds(500));
175180

176181
EXPECT_THAT(
177182
client_request_bytes_view.GetData().distribution_data(),
@@ -224,6 +229,8 @@ TEST_F(StatsPluginEnd2EndTest, Latency) {
224229
// entire time spent making the RPC.
225230
const double max_time = absl::ToDoubleMilliseconds(absl::Now() - start_time);
226231

232+
absl::SleepFor(absl::Milliseconds(500));
233+
227234
EXPECT_THAT(
228235
client_latency_view.GetData().distribution_data(),
229236
::testing::UnorderedElementsAre(::testing::Pair(
@@ -282,6 +289,7 @@ TEST_F(StatsPluginEnd2EndTest, StartFinishCount) {
282289
ASSERT_TRUE(status.ok());
283290
EXPECT_EQ("foo", response.message());
284291
}
292+
absl::SleepFor(absl::Milliseconds(500));
285293

286294
EXPECT_THAT(client_started_count_view.GetData().double_data(),
287295
::testing::UnorderedElementsAre(::testing::Pair(
@@ -316,6 +324,7 @@ TEST_F(StatsPluginEnd2EndTest, RequestResponseCount) {
316324
ASSERT_TRUE(status.ok());
317325
EXPECT_EQ("foo", response.message());
318326
}
327+
absl::SleepFor(absl::Milliseconds(500));
319328

320329
EXPECT_THAT(client_request_count_view.GetData().distribution_data(),
321330
::testing::UnorderedElementsAre(::testing::Pair(

0 commit comments

Comments
 (0)