Commit Graph

155 Commits

Author SHA1 Message Date
Kun Zhang 3f63cd0ad4
core: always call StreamTracer.streamClosed() when stream is officially closed. (#4331)
Previously StreamTracer.streamClosed() is called in
ServerStream.close(), but it is not exactly when the stream is
officially closed.  ServerStreamListener.closed() is guaranteed to be
called and it is the official end of the stream.
2018-04-12 09:05:48 -07:00
zpencer 7c37f1d32b
core,netty,okhttp,services: expose socket options to channelz (#4228)
For okhttp, expose the standard options from the Socket object.

For netty, expose all the `io.netty.channel.ChannelOption`s of the
`channel.config()`.
2018-03-30 08:48:37 -07:00
Amit Desai 8fe313f598 Marking GrpcServerRule as final
Resolves #4239
2018-03-23 16:34:20 -07:00
zpencer a5b55bb24c
netty,okhttp,testing: always set TRANSPORT_ATTR_REMOTE_ADDR (#4217)
Always set the remote address, no reason why this should be a TLS-only
feature. This is needed for channelz, and is especially useful in unit
tests where we are using plaintext.

This PR adds the attr for plaintext.
2018-03-23 15:44:40 -07:00
Eric Anderson 7eab0d9468 netty: Add support for Conscrypt 2018-03-23 10:05:45 -07:00
zpencer 2a778f126a
testing: temporarily disable socketStats_addresses test (#4216)
Hardcoding 127.0.0.1 leads to failure in ipv6
2018-03-13 18:42:11 -07:00
ZHANG Dapeng a83f67a706
core,netty,okhttp: Transparent retry
Changes:

- `ClientStreamListener.onClose(Status status, RpcProgress rpcProgress, Metadata trailers)` added.

- `AbstractClientStream.transportReportStatus(Status status, RpcProgress rpcProgress, boolean stopDelivery, Metadata trailers)` added

- `ClientCallImpl.ClientStreamListenerImpl` will ignore the arg `rpcProgress` (non retry)

- `RetriableStream.SubListener` will handle `rpcProgress` and decide if transparent retry.

- `NettyClientHandler` and `OkHttpClientTransport` will pass `RpcProgress.REFUSED` to client stream listener for later stream ids when received GOAWAY, or for stream received a RST_STREAM frame with REFUSED code.

- All other files are just a result of refactoring.
2018-03-12 14:12:46 -07:00
zpencer 921b668ad5
core,netty,okhttp,testing: separate local vs remote stream start times for channelz (#4194)
The channelz spec states that the two must be separate.
2018-03-08 16:57:12 -08:00
zpencer f0eb6d2102
core,netty,okhttp,testing: nest TransportStats inside SocketStats for channelz (#4190)
Transport ststistics should really be a child member of SocketStats.
While we're at it, let's add the local and remote SocketAddress to
SocketStats, with a test.
2018-03-08 14:56:04 -08:00
Kun Zhang df65bef881
core: delete outboundMessage() and inboundMessage() on StreamTracer. (#4014)
They were deprecated in 1.7.0.
2018-01-29 13:42:14 -08:00
zpencer 0465bb5aeb
core,testing: deprecate passing ServerCall to StatsTraceContext (#3912)
Instead, pass a ServerCallInfo object containing the interesting bits
of info. This lets us modify the call handler for binary logging, but
still provide the original info to the StatsTraceContext API.
2018-01-26 16:51:45 -08:00
Bogdan Drutu af936919f3 Update opencensus to 0.11.0 and remove extra dependencies. 2018-01-26 13:04:26 -08:00
zpencer 199a5203c5
core: move ChannelStats and TransportStats to io.grpc.internal.Channelz (#4008) 2018-01-25 23:24:49 -08:00
Eric Anderson 35a6bf863d Enable the Guava Beta Checker 2018-01-08 14:52:51 -08:00
ZHANG Dapeng 659cce52b6
Revert "testing: delete deprecated StreamRecorder" (#3801)
This reverts commit dc71083ce9.

StreamRecorder is too old and may have users unable to migrate it out easily soon.
2017-12-20 10:05:17 -08:00
zpencer f1151f91b9
core: InternalInstrumented<T> for instrumented classes (#3817)
Entities that report stats to channelz will implement this interface.
2017-12-13 12:56:25 -08:00
zpencer 25cd0be24c
core,netty,okhttp: move TransportTracer.Stats to io.grpc (#3812)
io.grpc can not refer to io.grpc.internal so this needs to be moved
out.
2017-11-30 13:01:58 -08:00
Eric Anderson 2bde25d2d9 testing: Remove DeadlineSubject
The class is still used internally, so we move it to context's tests for
it to be reused. To avoid a circular dependency with context's tests
depending on core's tests, StaticTestingClassLoader was also moved to
context's tests.

This is driven by a need to modernize DeadlineSubject for newer versions
of Truth, but the newer versions of Truth update Guava. To avoid leaking
the Guava update to all users of grpc-testing, we're removing the
Subject. In our internal tests we can update the Truth dependency with
less issue.
2017-11-22 17:57:46 -08:00
ZHANG Dapeng 6c6538648b
testing: add testing package to javadoc 2017-11-22 16:10:25 -08:00
dapengzhang0 3275dcbc0f testing: delete some deprecated APIs in TestUtils 2017-11-22 16:09:59 -08:00
dapengzhang0 dc71083ce9 testing: delete deprecated StreamRecorder 2017-11-22 16:09:59 -08:00
dapengzhang0 83c417b639 testing: delete deprecated NoopClientCall and NoopServerCall 2017-11-22 16:09:59 -08:00
dapengzhang0 baebca213e testing: remove deprecated noopMethodDescriptor 2017-11-22 16:09:59 -08:00
Steve Conover 167029610e testing: bazel build targets
Adds necessary dependencies and bazel build rules to create `@grpc_java//testing`.
2017-11-20 10:48:57 -08:00
zpencer 47bee4feee
core,netty: plumb fake clock into transport tracer tests (#3724) 2017-11-13 15:58:29 -08:00
Kun Zhang ca9a41a46e
core: record RPC upstarts to Census. (#3708)
RPC upstarts are counted into metrics
RPC_{CLIENT,SERVER}_STARTED_COUNT. In addition, RPC completions are
counted into metrics RPC_{CLIENT,SERVER}_FINISHED_COUNT.  From these
metrics, users will be able to derive count of RPCs that are currently
active.
2017-11-10 17:22:22 -08:00
zpencer d0a84ae5b8
core,netty: wire TransportTracer to netty client (#3705) 2017-11-10 15:55:21 -08:00
zpencer f2968f518f
core,netty: correctly count streams that ended due to client cancel (#3683)
Only bump the counter from AbstractServerStream.TransportState, and hole punch
from AbstractServerStream to TransportState when the application calls close.
2017-11-08 13:18:12 -08:00
sebright ef2ec94911 core: use new OpenCensus stats/tagging API. (#3647)
This commit updates gRPC core to use io.opencensus:opencensus-api and
io.opencensus:opencensus-contrib-grpc-metrics instead of
com.google.instrumentation:instrumentation-api for stats and tagging. The gRPC
Monitoring Service continues to use instrumentation-api.

The main changes affecting gRPC:

- The StatsContextFactory is replaced by three objects, StatsRecorder, Tagger,
  and TagContextBinarySerializer.

- The StatsRecorder, Tagger, and TagContextBinarySerializer are never null,
  but the objects are no-ops when the OpenCensus implementation is not
  available.

This commit includes changes written by @songy23 and @sebright.
2017-11-07 12:25:03 -08:00
ZHANG Dapeng 34555e497a
testing: add TlsTesting.loadCert 2017-11-02 16:40:49 -07:00
zpencer 2162cd07d5
netty,core: add a TransportTracer class (#3454) 2017-11-02 15:44:21 -07:00
Eric Anderson f9f603570d Allow tests to run on IPv6-less machines
Our Travis-CI builds are failing with "Protocol family unavailable" due
to the usage of ::1. Although it's 2017 and we'd expect to have ipv6
_loopback_ anywhere that mattered, apparently that's not the case.

The tests now work equally well on IPv4-only and IPv6-only machines.
2017-11-02 13:32:34 -07:00
ZHANG Dapeng 8a9660c700
testing: move TestUtils.recordServerCallInterceptor internal 2017-11-01 09:37:42 -07:00
ZHANG Dapeng d6ff4c259f
testing: move io.grpc.testing.StreamRecorder to internal 2017-11-01 09:37:22 -07:00
ZHANG Dapeng 27ae09522d
testing: mark io.grpc.testing.DeadlineSubject experimental 2017-11-01 09:37:00 -07:00
ZHANG Dapeng 9a06c4eb0e
testing: favor voidMethod and deprecate noopMethod 2017-11-01 09:36:24 -07:00
Eric Anderson 733f5ac665 testing: Use StringBuilder instead of StringBuffer
We don't need the synchronization StringBuffer provides
2017-10-27 15:29:51 -07:00
ZHANG Dapeng 071942dc3b core: fix a race in InProcessTransport
Resolves #3571
2017-10-26 09:32:41 -07:00
zpencer 7df9ae9753 core,netty,okhttp: detect proxy via ProxySelector (#3021)
This lets us specify the proxy using `-Dhttps.proxyHost=host -Dhttps.proxyPort=port`
along with auth info like username and password.
2017-10-17 19:26:11 -07:00
Kun Zhang 8edead0851 core: make in-process transport support StreamTracer
This is needed for both completeness and stats/tracing contexts propagation.

Stats recording with Census is intentionally disabled (#2284), while the rest of the Census-related logic work the same as on the other transports.
2017-10-09 10:14:36 -07:00
Eric Gribkoff a8db154702 testing: reduce mocks in AbstractTransportTest to eliminate flakes 2017-09-25 17:58:05 -07:00
Kun Zhang 7e534ed704 core: record individual messages with sizes to Census/tracing (#3461)
Two methods, outboundMessageSent() and inboundMessageRead() are added to StreamTracer in order to associate individual messages with sizes. Both types of sizes are optional, as allowed by Census tracing.

Both methods accept a sequence number as the type ID as required by Census. The original outboundMesage() and inboundMessage() are also replaced by overrides that take the sequence number, to better match the new methods. The deprecation of the old overrides are tracked by #3460
2017-09-19 09:22:11 -07:00
Eric Anderson a3ff9cd784 all: Keep artifacts dependencyConvergence-clean
Maven Enforcer's dependencyConvergence is commonly used in Spring
projects, as it is inherited by all starter projects[1]. While I find
that option to be crazy and harmful (and would instead support
requireUpperBoundDeps), it does bother people.

1. https://github.com/spring-projects/spring-boot/blob/v1.5.6.RELEASE/spring-boot-starters/pom.xml#L94
2017-09-18 16:20:18 -07:00
Kun Zhang 41410345e6 core: pass status to ManagedClientTransport.shutdown() (#3351)
This aligns with shutdownNow(), which is already accepting a status.
The status will be propagated to application when RPCs failed because
of transport shutdown, which will become useful information for debug.
2017-08-16 10:23:07 -07:00
ZHANG Dapeng c71e2919de all: fix typo of overridden
s/overriden/overridden/g
2017-08-11 16:53:53 -07:00
Eric Gribkoff 16575d01a3 core,netty,okhttp,testing: switch to StreamListener.messagesAvailable 2017-08-11 16:52:45 -07:00
Carl Mastrangelo 02cb718767 testing,core: don't use mocks for stream tracers (#3305)
This is a big, but mostly mechanical change.  The newly added Test*StreamTracer classes are designed to be extended which is why they are non final and have protected fields.  There are a few notable things in this:

1.  verifyNoMoreInteractions is gone.   The API for StreamTracers doesn't make this guarantee.  I have recovered this behavior by failing duplicate calls.  This has resulted in a few bugs in the test code being fixed.

2.  StreamTracers cannot be mocked anymore.  Tracers need to be thread safe, which mocks simply are not.  This leads to a HUGE number of reports when trying to find real races in gRPC.

3.  If these classes are useful, we can promote them out of internal.  I just put them here out of convenience.
2017-08-03 16:59:06 -07:00
Kun Zhang 04e0450304 core: pass CallOptions to newClientStreamTracer(). (#3276)
Resolves #3256
2017-07-27 12:07:25 -07:00
zpencer e14fc404f0 netty: add timeouts to address test flakiness (#3169)
This test is sometimes flakey
2017-07-17 17:14:16 -07:00
ZHANG Dapeng ff0ad5fac3 testing: refactor part of TestUtils to internal
Moved the following APIs from `io.grpc.testing.TestUtils` to `io.grpc.internal.TestUtils`:

`InetSocketAddress testServerAddress(String host, int port)`
`InetSocketAddress testServerAddress(int port)`
`List<String> preferredTestCiphers()`
`File loadCert(String name)`
`X509Certificate loadX509Cert(String fileName)`
`SSLSocketFactory newSslSocketFactoryForCa(Provider provider, File certChainFile)`
`void sleepAtLeast(long millis)`

APIs not to be moved:

`ServerInterceptor recordRequestHeadersInterceptor()`
`ServerInterceptor recordServerCallInterceptor()`
2017-07-10 16:30:38 -07:00