Skip to content

Commit

Permalink
Handle write errors in ServerDeathTest
Browse files Browse the repository at this point in the history
We think this fixes #274 which we think is caused by the client
attempting to write a request after the server has already exited.

This commit ensures that `call.Finish()` is called whether or not the
client's write succeeds.
  • Loading branch information
CodingCanuck authored Apr 18, 2022
1 parent 586db34 commit a464b0a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/grpc/server-death-test.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <filesystem>

#include "eventuals/finally.h"
#include "eventuals/grpc/client.h"
#include "eventuals/grpc/server.h"
#include "eventuals/head.h"
#include "eventuals/let.h"
#include "eventuals/terminal.h"
#include "eventuals/then.h"
Expand All @@ -16,10 +16,10 @@ using helloworld::HelloRequest;

using stout::Borrowable;

using eventuals::Head;
using eventuals::Finally;
using eventuals::Let;
using eventuals::Terminate;
using eventuals::Then;
using eventuals::grpc::ClientCall;

using eventuals::grpc::Client;
using eventuals::grpc::CompletionPool;
Expand Down Expand Up @@ -90,15 +90,18 @@ TEST_F(EventualsGrpcTest, ServerDeathTest) {

auto call = [&]() {
return client.Call<Greeter, HelloRequest, HelloReply>("SayHello")
| Then(Let([](auto& call) {
| Then(Let([](ClientCall<HelloRequest, HelloReply>& call) {
HelloRequest request;
request.set_name("emily");
return call.Writer().WriteLast(request)
| call.Finish();
| Finally(
[&](std::optional<std::exception_ptr>&&) {
return call.Finish();
});
}));
};

auto status = *call();
const ::grpc::Status status = *call();

EXPECT_EQ(grpc::UNAVAILABLE, status.error_code());

Expand Down

0 comments on commit a464b0a

Please sign in to comment.