use of io.grpc.examples.helloworld.HelloReply in project grpc-java by grpc.
the class SafeMethodCachingInterceptorTest method responseNoStoreDirective_notCached.
@Test
public void responseNoStoreDirective_notCached() throws Exception {
cacheControlDirectives.add("no-store");
HelloReply reply1 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
HelloReply reply2 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
assertNotEquals(reply1, reply2);
Truth.assertThat(cache.internalCache).isEmpty();
Truth.assertThat(cache.removedKeys).isEmpty();
}
use of io.grpc.examples.helloworld.HelloReply in project grpc-java by grpc.
the class SafeMethodCachingInterceptorTest method responseMaxAge_caseInsensitive.
@Test
public void responseMaxAge_caseInsensitive() throws Exception {
cacheControlDirectives.add("MaX-aGe=0");
HelloReply reply1 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
HelloReply reply2 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
assertNotEquals(reply1, reply2);
Truth.assertThat(cache.internalCache).isEmpty();
Truth.assertThat(cache.removedKeys).isEmpty();
}
use of io.grpc.examples.helloworld.HelloReply in project grpc-java by grpc.
the class HostnameGreeterTest method sayHello_fixedHostname.
@Test
public void sayHello_fixedHostname() throws Exception {
grpcCleanup.register(InProcessServerBuilder.forName("hostname").directExecutor().addService(new HostnameGreeter("me")).build().start());
HelloReply reply = blockingStub.sayHello(HelloRequest.newBuilder().setName("you").build());
assertEquals("Hello you, from me", reply.getMessage());
}
use of io.grpc.examples.helloworld.HelloReply in project brave by openzipkin.
the class BaseITTracingClientInterceptor method callbackContextIsFromInvocationTime.
/**
* This ensures that response callbacks run in the invocation context, not the client one. This
* allows async chaining to appear caused by the parent, not by the most recent client. Otherwise,
* we would see a client span child of a client span, which could be confused with duplicate
* instrumentation and affect dependency link counts.
*/
@Test
public void callbackContextIsFromInvocationTime() {
AssertableCallback<HelloReply> callback = new AssertableCallback<>();
// Capture the current trace context when onSuccess or onError occur
AtomicReference<TraceContext> invocationContext = new AtomicReference<>();
callback.setListener(() -> invocationContext.set(currentTraceContext.get()));
TraceContext parent = newTraceContext(SamplingFlags.SAMPLED);
try (Scope scope = currentTraceContext.newScope(parent)) {
GreeterGrpc.newStub(client).sayHello(HELLO_REQUEST, new StreamObserverAdapter(callback));
}
// ensures listener ran
callback.join();
assertThat(invocationContext.get()).isSameAs(parent);
assertChildOf(testSpanHandler.takeRemoteSpan(CLIENT), parent);
}
use of io.grpc.examples.helloworld.HelloReply in project brave by openzipkin.
the class BaseITTracingClientInterceptor method messageTagging_streaming.
@Test
public void messageTagging_streaming() {
initMessageTaggingClient();
ScopedSpan span = tracing.tracer().startScopedSpan("parent");
try {
Iterator<HelloReply> replies = GreeterGrpc.newBlockingStub(client).sayHelloWithManyReplies(HELLO_REQUEST);
assertThat(replies).toIterable().hasSize(10);
} finally {
span.finish();
}
assertThat(testSpanHandler.takeRemoteSpan(CLIENT).tags()).containsKey("grpc.message_send.1");
// Response processing happens on the invocation (parent) trace context
// Intentionally verbose here to show 10 replies
assertThat(testSpanHandler.takeLocalSpan().tags()).containsKeys("grpc.message_recv.1", "grpc.message_recv.2", "grpc.message_recv.3", "grpc.message_recv.4", "grpc.message_recv.5", "grpc.message_recv.6", "grpc.message_recv.7", "grpc.message_recv.8", "grpc.message_recv.9", "grpc.message_recv.10");
}
Aggregations