Skip to content

Commit

Permalink
fix flaky failure in CI for RichErrorModelTest (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
laglangyue committed Apr 13, 2024
1 parent 92a0577 commit 7f4b94c
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import io.grpc.protobuf.StatusProto;
import java.time.Duration;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.grpc.GrpcClientSettings;
import org.apache.pekko.http.javadsl.Http;
Expand All @@ -43,7 +45,6 @@ private CompletionStage<ServerBinding> run(ActorSystem sys) throws Exception {

org.apache.pekko.japi.function.Function<HttpRequest, CompletionStage<HttpResponse>> service =
GreeterServiceHandlerFactory.create(impl, sys);

return Http.get(sys).newServerAt("127.0.0.1", 8090).bind(service);
}

Expand All @@ -52,8 +53,7 @@ private CompletionStage<ServerBinding> run(ActorSystem sys) throws Exception {
public void testManualApproach() throws Exception {
Config conf = ConfigFactory.load();
ActorSystem sys = ActorSystem.create("HelloWorld", conf);
run(sys);

ServerBinding serverBinding = run(sys).toCompletableFuture().get(60, TimeUnit.SECONDS);
GrpcClientSettings settings =
GrpcClientSettings.connectToServiceAt("127.0.0.1", 8090, sys).withTls(false);

Expand All @@ -68,9 +68,7 @@ public void testManualApproach() throws Exception {
response
.toCompletableFuture()
.handle(
(res, ex) -> {
return (StatusRuntimeException) ex;
})
(res, ex) -> (StatusRuntimeException) ex)
.get();

com.google.rpc.Status status =
Expand All @@ -94,6 +92,8 @@ public void testManualApproach() throws Exception {
} finally {
if (client != null) client.close();
sys.terminate();
serverBinding.unbind();
serverBinding.terminate(Duration.ofSeconds(10));
}
}
}

0 comments on commit 7f4b94c

Please sign in to comment.