aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/end2end
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-05-27 16:28:34 -0700
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-05-27 16:28:34 -0700
commit5d8310e104d32ff13cac651b817a9748d7714783 (patch)
tree57c761ddb1d85665ba9867f5daaf428a365f3eed /test/cpp/end2end
parentf3b07aaad2479e45413b2257206e8200cbf3ec73 (diff)
parent8c627c8cd01449571679de4e1521511d302b2ff1 (diff)
Merge github.com:grpc/grpc into we-dont-need-no-backup
Diffstat (limited to 'test/cpp/end2end')
-rw-r--r--test/cpp/end2end/server_crash_test.cc36
1 files changed, 25 insertions, 11 deletions
diff --git a/test/cpp/end2end/server_crash_test.cc b/test/cpp/end2end/server_crash_test.cc
index 11d73aec7d..3fdae9bc07 100644
--- a/test/cpp/end2end/server_crash_test.cc
+++ b/test/cpp/end2end/server_crash_test.cc
@@ -69,10 +69,15 @@ namespace testing {
namespace {
-class ServiceImpl GRPC_FINAL : public ::grpc::cpp::test::util::TestService::Service {
+class ServiceImpl GRPC_FINAL
+ : public ::grpc::cpp::test::util::TestService::Service {
+ public:
+ ServiceImpl() : bidi_stream_count_(0), response_stream_count_(0) {}
+
Status BidiStream(ServerContext* context,
ServerReaderWriter<EchoResponse, EchoRequest>* stream)
GRPC_OVERRIDE {
+ bidi_stream_count_++;
EchoRequest request;
EchoResponse response;
while (stream->Read(&request)) {
@@ -87,6 +92,7 @@ class ServiceImpl GRPC_FINAL : public ::grpc::cpp::test::util::TestService::Serv
Status ResponseStream(ServerContext* context, const EchoRequest* request,
ServerWriter<EchoResponse>* writer) GRPC_OVERRIDE {
EchoResponse response;
+ response_stream_count_++;
for (int i = 0;; i++) {
std::ostringstream msg;
msg << "Hello " << i;
@@ -96,23 +102,27 @@ class ServiceImpl GRPC_FINAL : public ::grpc::cpp::test::util::TestService::Serv
}
return Status::OK;
}
+
+ int bidi_stream_count() { return bidi_stream_count_; }
+
+ int response_stream_count() { return response_stream_count_; }
+
+ private:
+ int bidi_stream_count_;
+ int response_stream_count_;
};
class CrashTest : public ::testing::Test {
protected:
CrashTest() {}
- std::unique_ptr<Server>
- CreateServerAndClient(const std::string& mode) {
+ std::unique_ptr<Server> CreateServerAndClient(const std::string& mode) {
auto port = grpc_pick_unused_port_or_die();
std::ostringstream addr_stream;
addr_stream << "localhost:" << port;
auto addr = addr_stream.str();
- client_.reset(new SubProcess({
- g_root + "/server_crash_test_client",
- "--address=" + addr,
- "--mode=" + mode
- }));
+ client_.reset(new SubProcess({g_root + "/server_crash_test_client",
+ "--address=" + addr, "--mode=" + mode}));
GPR_ASSERT(client_);
ServerBuilder builder;
@@ -121,9 +131,11 @@ class CrashTest : public ::testing::Test {
return builder.BuildAndStart();
}
- void KillClient() {
- client_.reset();
- }
+ void KillClient() { client_.reset(); }
+
+ bool HadOneBidiStream() { return service_.bidi_stream_count() == 1; }
+
+ bool HadOneResponseStream() { return service_.response_stream_count() == 1; }
private:
std::unique_ptr<SubProcess> client_;
@@ -136,6 +148,7 @@ TEST_F(CrashTest, ResponseStream) {
gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(5)));
KillClient();
server->Shutdown();
+ GPR_ASSERT(HadOneResponseStream());
}
TEST_F(CrashTest, BidiStream) {
@@ -144,6 +157,7 @@ TEST_F(CrashTest, BidiStream) {
gpr_sleep_until(gpr_time_add(gpr_now(), gpr_time_from_seconds(5)));
KillClient();
server->Shutdown();
+ GPR_ASSERT(HadOneBidiStream());
}
} // namespace