Commit Graph

465 Commits

Author SHA1 Message Date
Zou Nengren 4e63bcab52
test: replace manual.GenerateAndRegisterManualResolver with grpc.WithResolvers (#3700) 2020-06-23 09:49:44 -07:00
Menghan Li 9aa97f9cb4
stream: fix calloption.After() race in finish (#3672) 2020-06-10 18:00:24 -07:00
Doug Fawley 4eb418e5b2
balancer: move Balancer and Picker to V2; delete legacy API (#3431) 2020-04-28 14:52:49 -07:00
Damien Neil 15653fec60
all: refactor .pb.go generation (#3451)
Replace various //go:generate lines and regenerate.sh scripts with a
single, top-level regenerate.sh that regenerates all .pb.go files.

Placing generation in a single script ensures that all files are
generated with similar parameters. The new regenerate.sh uses the
protoc-gen-go version defined in test/tools/go.mod and automatically
handles new .proto files as they are added.

Do some minor refactoring on .proto files: Every file now has a
go_package option (which will be required by a future version of the
code generator), and file imports are all relative to the repository
root.
2020-04-24 08:54:03 -07:00
Easwar Swaminathan d15f1a4aa1
test: Move creds related to tests to creds_test.go (#3542) 2020-04-16 16:30:23 -07:00
Garrett Gutierrez 132187f04c
Modified tests to use tlogger. (#3343)
* Modified tests to use tlogger.

* Fail on errors, with error expectations.

* Added expects and MixedCapsed grpclb_config tests

* Moved tlogger to grpctest, moved leakcheck tester to grpctest.go

* Added ExpectErrorN()

* Removed redundant leak checks

* Fixed new test

* Made tlogger globals into tlogger methods

* ErrorsLeft -> EndTest

* Removed some redundant lines

* Fixed error in test and empty map in EndTest
2020-02-06 13:03:20 -08:00
Garrett Gutierrez e8a4440d49 grpctest: implement grpclogger using testing.T and inject in tests (#3260) 2020-01-13 14:02:31 -08:00
Doug Fawley c35a580b0c
Revert "balancer: move Balancer and Picker to V2; delete legacy… (#3315)
This reverts commit 336cf8d761.
2020-01-13 13:12:55 -08:00
Doug Fawley 336cf8d761
balancer: move Balancer and Picker to V2; delete legacy API (#3301) 2020-01-10 13:44:48 -08:00
Joe Tsai 2d2f65684c cleanup: fix generic comparisons on protobuf messages (#3153)
Generated protobuf messages contain internal data structures
that general purpose comparison functions (e.g., reflect.DeepEqual,
pretty.Compare, etc) do not properly compare. It is already the case
today that these functions may report a difference when two messages
are actually semantically equivalent.

Fix all usages by either calling proto.Equal directly if
the top-level types are themselves proto.Message, or by calling
cmp.Equal with the cmp.Comparer(proto.Equal) option specified.
This option teaches cmp to use proto.Equal anytime it encounters
proto.Message types.
2019-11-06 14:25:07 -08:00
Doug Fawley 6dac020480
test: add test of malformed gzip payload (#3141) 2019-11-05 11:11:34 -08:00
lzhfromustc da2bec01b9 test & testutils: prevent goroutine leaks in test functions (#3133) 2019-11-01 14:51:58 -07:00
Doug Fawley c0909e91a5
resolver: move dns and passthrough to internal (#3116)
Nobody should directly need to reference these packages.

This is technically a breaking change. However:

- Package dns was exporting a NewBuilder method. This should never have been necessary to use, but if so, it can be replaced by importing the "grpc" package and then using resolver.Get("dns").

- Package passthrough was not exporting any symbols and there was never a need to even blank-import it.

After as much searching as possible, it appears nobody in the open source community is referencing either of these packages.
2019-10-22 13:01:54 -07:00
Doug Fawley 7c3115d8bb
client: fix bug with cancellation propagation for unary RPCs (#3106) 2019-10-17 13:04:53 -07:00
Easwar Swaminathan ef403a2ec1
Make healthcheck tests in end2end_test.go more readable. (#2883)
* Make healthcheck tests in end2end_test.go more readable.

- Made these tests use the default health service implementation
  wherever possible.
- Refactored some common code used in these tests into helper functions.
- Added function comments for all these tests to improve readability.

In a follow up PR, I will be moving all these tests into
healthcheck_test.go.
2019-10-11 10:38:51 -07:00
Joe Betz 2e7984e2c0 clientconn: override authority with address's ServerName, if set (#3073) 2019-10-08 13:59:02 -07:00
Doug Fawley df162eae76
test: embed Unimplemented___Server in every service (#3076) 2019-10-04 13:22:31 -07:00
Doug Fawley ed563a02ea
resolver: add State fields to support error handling (#2951) 2019-10-04 12:59:43 -07:00
Shane Liebling 47d3cfe042 Adding a RequestInfo struct for propagating request data to Get… (#3057)
Add a RequestInfo struct which initially is used for passing the full request method (though could later be expanded to pass more info) so that things like GetRequestMetadata can be used to apply logic based on that data.

This is a fix for #3019
2019-10-04 09:27:09 -07:00
Doug Fawley e75b8f4830
test: fix flake in GoAwayThenClose (#3052)
In the event of a race, the first server may not be fully serving before the
client attempt to connect, then the second server may attempt to field the
FullDuplexCall, which it does not implement.

Fix the race by giving the client only the first server's address until after
the FullDuplexCall is started.
2019-09-27 13:42:15 -07:00
Doug Fawley 977142214c
client: fix race between transport draining and new RPCs (#2919)
Before these fixes, it was possible to see errors on new RPCs after a
connection began draining, and before establishing a new connection.  There is
an inherent race between choosing a SubConn and attempting to creating a stream
on it.  We should be able to avoid application-visible RPC errors due to this
with transparent retry.  However, several bugs were preventing this from
working correctly:

1. Non-wait-for-ready RPCs were skipping transparent retry, though the retry
design calls for retrying them.

2. The transport closed itself (and would consequently error new RPCs) before
notifying the SubConn that it was draining.

3. The SubConn wasn't synchronously updating itself once it was notified about
the closing or draining state.

4. The SubConn would go into the TRANSIENT_FAILURE state instantaneously,
causing RPCs to fail instead of queue.
2019-07-22 16:07:55 -07:00
Yongzheng Lai 7472edcc1e metadata: write original md before appended md (#2879) 2019-06-25 10:34:12 -07:00
Easwar Swaminathan 70e8b38052
test: end2end test improvements separate server and client configs. (#2877)
- Seperated and documented the options for client and server sides.
- Better support for multiple grpc.Servers. This will be used in other
  improvements that I have in the works.
- Moved some common functionality from channelz_test.go to
  end2end_test.go.
- Added an option to use the default health service implementation, instead
 of each test creating a new health.Server and passing it in. The
 inidividual tests have not been changed in this PR. I will do that in a
 follow up PR to keep the changes to a reasonable size.
- Fixed one of the tests which had to be fixed because of the separation
  of client and server configs.
2019-06-24 14:53:45 -07:00
Easwar Swaminathan ecb921ddb9
test: end2end test cleanup http handler server (#2876)
* end2end test cleanup #1

- Removed some old code which has a TODO asking for it's removal once
  Go1.6 and Go1.7 support is gone.
- Cleaned up a couple of error messages along with it.
2019-06-20 15:35:55 -07:00
Menghan Li fc15416d24
test: fix GoAwayThenClose by wait for cc state change (#2855)
In the end of the test, 10 RPCs are made to make sure data is sent to
the second server. The first RPC of these 10 is made right after the
second server's listener receives a connection. But at this time, the
connectivity state on the client side is not set to READY yet (though
ac's state should be either connecting or ready, the race between ac
and balancer could cause cc to still be in transient failure). So the
first RPC fails due to transient failure, but the following 9 will
succeed.
2019-06-13 15:57:55 -07:00
Menghan Li c7831546a1
test: extend RPC timeout for TestHTTPHeaderFrameErrorHandlingHTTPMode (#2861)
This test sometimes fails with error creating stream due to
DeadlineExceeded. It's very hard to reproduce (failed twice in 100000
runs). Extend the RPC timeout in case it's too short.
2019-06-13 15:29:28 -07:00
Easwar Swaminathan 684ef04609
Fix a typo in the comment. (#2866)
I was trying to run this test and I had copied the name of the function
from the comment, and it took a good while to figure out why
`go test -run` was returning `testing: warning: no tests to run`.
2019-06-12 15:56:39 -07:00
Menghan Li cd89eaf40e
test: fix Test/GracefulStop by not removing activeStreams too aggresivelly (#2857)
Before this fix, stream is removed from activeStreams in finishStream,
which happens when the service handler returns status, without waiting
for the status to be sent by loopyWriter. If GracefulStop() is called in
between, it will close the connection (because activeStreams is empty),
which causes the RPC to fail with "transport is closing". This change
moves the activeStreams cleanup into loopyWriter, after sending status
on wire.
2019-06-12 10:26:18 -07:00
Easwar Swaminathan a5396fd45c
Remove call to proto.Clone() in http2Server.WriteStatus. (#2842)
* Expose a method from the internal package to get to the raw
  StatusProto wrapped by the status error, and use it from
  http2Server.WriteStatus().
* Add a helper method in internal/testutils to compare two status errors
  and update test code to use that instead of reflect.DeepEqual()
2019-06-10 15:03:12 -07:00
Doug Fawley d40a995895
balancer/resolver: add loadBalancingConfig and pre-parsing support (#2732) 2019-05-30 09:12:58 -07:00
lyuxuan 42baa8b199
channelz: wait for clean up before next test (#2797) 2019-05-02 14:47:50 -07:00
Qitao Yu 47e1ebe575 client: return helpful error message when wait-for-ready RPCs fail with timeout (#2777) 2019-04-29 12:42:19 -07:00
Prannay Khosla 8260df7a61 grpc: implementation of PreparedMsg API
grpc: implementation of PreparedMsg API
2019-04-19 14:08:08 -07:00
Doug Fawley 3910b873d3
bar: add ability to update resolver state atomically and pass directly to the balancer (#2693) 2019-03-22 10:48:55 -07:00
lyuxuan 77ce7bc228
minor: typo fix (#2680) 2019-03-11 15:06:47 -07:00
lyuxuan 79c9bc6794
client: handle HTTP header parsing error correctly (#2599) 2019-03-06 10:59:01 -08:00
Nguyen Quang Huy 2773c7bbcf Fix styling (#2647)
Fix styling
2019-02-21 16:37:37 -08:00
Doug Fawley ed70822b12 keepalive: apply minimum ping time of 10s to client and 1s to server (#2642)
* keepalive: apply minimum ping time of 10s to client and 1s to server

* review fixes
2019-02-21 13:09:37 -08:00
Can Guler 32559e2175
internal: server deletes stream after receiving an RST_STREAM frame
* Fixes established streams leak in the loopy writer.

RSTStreamFrames used to be ignored by the server transport, if a trailer had already been put into the transport's control buffer. If loopy writer couldn't write anything into a stream because of an error on the client side, then this trailer would never be sent. At that point, server would receive an RSTStreamFrame from client. But this RSTStreamFrame would be ignored because a trailer was already put into the control buffer. This would keep the stream open and in memory on the server side.

With this change, a cleanupStream item is put into the transport's control buffer, whenever an RSTStreamFrame is received by the server, even after a trailer has been put into the buffer.

* When client sends a header to initiate a stream just after sending an RST_STREAM, server gets these frames in the correct order.
When server receives the RST_STREAM, it marks the stream as done and defers the deletion of the stream to the loopy writer by putting a cleanupStream item into control buffer.
Then the server receives the header to initiate a stream. It acts on the header immediately and attempts to create the stream. But because the old stream is not deleted, it hits the number of streams limit and fails.
This commit solves this problem by letting server handle the deletion immediately after receiving the RST_STREAM.

* Refactors deleteStream method.

* Moves consts declarations into test function's body.
2019-02-11 17:33:22 -08:00
Doug Fawley d14ffaeb5c
client: deprecate CallCustomCodec and provide new version using encoding.Codec (#2556) 2019-02-01 10:21:31 -08:00
Doug Fawley 8e6533ee6e
client: clean up v1 balancer wrapper error handling (#2511) 2019-01-30 10:56:23 -08:00
Doug Fawley dfd7708d35
cleanup: use time.Until(t) instead of t.Sub(time.Now) (#2571) 2019-01-15 16:09:50 -08:00
Doug Fawley 6cc789b34b
client: make handshake required 'on' by default, not 'hybrid' (#2565) 2019-01-15 09:19:32 -08:00
Doug Fawley 98a94b0cb0
test: disable leakcheck after the first failure (#2563) 2019-01-14 15:40:20 -08:00
Doug Fawley 0a391ff2b7
grpctest: add new package to manage tests and support per-test setup/teardown (#2523)
- Migrate `grpc` & `grpc/test` packages to use `Teardown` support to guarantee `leakcheck` is used
2019-01-07 14:24:56 -08:00
Can Guler 29a7ac4deb
client: deprecates FailFast & replaces its use by WaitForReady. 2018-12-13 15:15:11 -08:00
Doug Fawley 04ea82009c
cleanup: replace "x/net/context" import with "context" (#2439) 2018-11-12 13:30:41 -08:00
Doug Fawley a612bb6847
client: block RPCs early until the resolver has returned addresses (#2409)
This allows the initial RPC(s) an opportunity to apply settings from the service config; without this change we would still block, but only after observing the current service config settings.
2018-11-09 13:53:47 -08:00
Menghan Li 12ed5d0f69
internal: split health proto package import in test (#2445) 2018-11-07 10:31:21 -08:00
Can Guler 7271c8bb04
Fixes a broken test case. (#2425) 2018-10-31 16:29:11 -07:00
Can Guler c86bc5cd5f
health: Checks if the service's serving status has changed before sending an update (#2424) 2018-10-31 15:45:18 -07:00
Jean de Klerk ff2aa05958
internal: fix GO_AWAY deadlock (#2391)
internal: fix GO_AWAY deadlock

A deadlock can occur when a GO_AWAY is followed by a connection closure. This
happens because onClose needlessly closes the current ac.transport: if a
GO_AWAY already occured, and the transport was already reset, then the later
closure (of the original address) sets ac.transport - which is now healthy -
to nil.

The manifestation of this problem is that picker_wrapper spins forever trying
to use a READY connection whose ac.transport is nil.
2018-10-19 14:11:21 -07:00
Jean de Klerk 04c0c4d299
internal: fix client send preface problems (#2380)
internal: fix client send preface problems

This CL fixes three problems:

- In clientconn_state_transitions_test.go, sometimes tests would flake because there's not enough buffer to send client side settings, causing the connection to unpredictably enter TRANSIENT FAILURE. Each time we set up a server to send SETTINGS, we should also set up the server to read. This allows the client to successfully send its SETTINGS, unflaking the test.

- In clientconn.go, we incorrectly transitioned into TRANSIENT FAILURE when creating an http2client returned an error. This should be handled in the outer resetTransport main reset loop. The reason this became a problem is that the outer resetTransport has very specific conditions around when to transition into TRANSIENT FAILURE that the egregious transition did not have. So, it could transition into TRANSIENT FAILURE after failing to dial, even if it was trying to connect to a non-final address in the list of addresses.

- In clientconn.go, we incorrectly stay in CONNECTING after `createTransport` when a server sends its connection preface but the client is not able to send its connection preface. This CL causes the addrconn to correctly enter TRANSIENT FAILURE when `createTransport` fails, even if a server preface was received. It does so by making ac.successfulHandshake to consider both server preface received as well as client preface sent.
2018-10-18 14:31:34 -07:00
Can Guler 23d111fa0d
Health server watch method (#2365)
Implements the Watch method of Health server and it's end2end tests.
2018-10-16 14:39:16 -07:00
Doug Fawley cfb9600851
server: fix handling of RPC timeouts that overflow int64 nanos (#2379)
Fixes #2374
2018-10-16 13:34:53 -07:00
dfawley b48e364c83
client: read from Conn while writing preface to unblock synchronous Conns (#2337) 2018-09-28 10:38:48 -07:00
Menghan Li 4dedfdc82c
credentials: support google default creds (#2315)
Google default creds is a combo of ALTS, TLS and OAuth2. The right set of creds will be picked to use based on environment.

This PR contains:
 - A new `creds.Bundle` type
   - changes to use it in ClientConn and transport
   - dial option to set the bundle for a ClientConn
   - balancer options and NewSubConnOption to set it for SubConn
 - Google default creds implementation by @cesarghali 
 - grpclb changes to use different creds mode for different servers
 - interop client changes for google default creds testing
2018-09-25 13:17:25 -07:00
dfawley 5fe10fccaf
Remove unused symbols (#2287) 2018-09-05 12:29:02 -07:00
dfawley 826807ed07
change 'if x == true' to 'if x' (#2289) 2018-09-04 15:10:47 -07:00
lyuxuan da7e20b83e
channelz: turn on channelz when importing service package, delete RegisterChannelz from grpc package (#2277) 2018-08-29 11:01:36 -07:00
dfawley a344a35754
internal: remove TestingUseHandlerImpl (#2253) 2018-08-03 09:35:00 -07:00
lyuxuan 264daa2be4
Set and respect HTTP/2 SETTINGS_MAX_HEADER_LIST_SIZE (#2084) 2018-07-09 11:27:58 -07:00
dfawley 40a879c23a
client: Implement gRFC A6: configurable client-side retry support (#2111) 2018-06-27 16:18:41 -07:00
mmukhi 3ec535a269
client, server: update dial/server buffer options to support a "disable" setting (#2147) 2018-06-27 11:16:33 -07:00
Menghan Li e218c924aa
status: handle invalid utf-8 characters (#2109) (#2134)
fixes #2078

A status with invalid utf-8 characters could still be created, but invalid characters will be replaced with [Unicode replacement character](https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character) before being sent out. Those bytes will still be percent encoded.

All details added to this invalid status will be dropped.
2018-06-14 13:53:31 -07:00
Jean de Klerk 0e5a36b652
internal: move leakcheck to internal/ (#2129)
internal: move leakcheck to internal/
2018-06-07 16:57:56 -07:00
Menghan Li 26ac8d285c
Revert "status: handle invalid utf-8 characters" (#2127)
Reverts grpc/grpc-go#2109

Test failure:
https://travis-ci.org/grpc/grpc-go/builds/388898555

Possible reason: `proto.Marshal` doesn't always return error even if message contains invalid utf8 char.
2018-06-06 17:58:36 -07:00
Menghan Li 9c658603f0
status: handle invalid utf-8 characters (#2109)
fixes #2078

A status with invalid utf-8 characters could still be created, but invalid characters will be replaced with [Unicode replacement character](https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character) before being sent out. Those bytes will still be percent encoded.

All details added to this invalid status will be dropped.
2018-06-06 10:58:32 -07:00
Carl Mastrangelo dbffeabcbc test: make end2end test use split grpc / proto imports (#2069) 2018-05-16 10:03:45 -07:00
mmukhi 0bc7c3280e
Revert "Less mem (#1987)" (#2049)
This reverts commit 7a8c989507.
2018-05-03 11:37:59 -07:00
mmukhi 3592bccfd9
interop: Fix unimplemented method test (#2040)
* Don't send nil requests.

* Fix import name and get rid of condition.

* Let registered encoder deal with nil requests.

* Break encode into encode and compress.
2018-05-02 16:08:12 -07:00
lyuxuan 4166ea7dad
Stage 2: Channelz metric collection (#1909) 2018-04-23 11:22:25 -07:00
Menghan Li 0c6b34bbc3 cleanup: extend dial context for TestFailFastRPCErrorOnBadCertificates to 10 seconds (#1984) 2018-04-12 15:05:04 -07:00
lyuxuan 7f73c863c0
Channelz: Entity Registration and Deletion (#1811) 2018-04-09 11:13:06 -07:00
mmukhi d0a21a3347
Export changes to OSS. (#1962) 2018-04-05 10:45:41 -07:00
dfawley 2eae9d0c74
server: add grpc.Method function for extracting method from context (#1961) 2018-04-02 13:08:04 -07:00
lyuxuan 738eb6b62f
fix minor typos and remove grpc.Codec related code in TestInterceptorCanAccessCallOptions (#1929) 2018-03-19 14:19:42 -07:00
Joshua Humphries fa28bef939 client: export types implementing CallOptions for access by interceptors (#1902) 2018-03-16 15:57:34 -07:00
Menghan Li 3926816d54
addrConn: Report underlying connection error in RPC error (#1855) 2018-02-14 14:13:10 -08:00
dfawley 445b7284b1
Fix data race in TestServerGoAwayPendingRPC (#1862) 2018-02-13 16:48:27 -08:00
mmukhi 484b3ebb4a
transport: fix race causing flow control discrepancy when sending messages over server limit (#1859)
* In case of an error write transport quota back.

* Added test.
2018-02-13 11:17:19 -08:00
dfawley 365770fcbd
streams: Stop cleaning up after orphaned streams (#1854)
This change introduces some behavior changes that should not impact users that
are following the proper stream protocol. Specifically, one of the following
conditions must be satisfied:

1. The user calls Close on the ClientConn.
2. The user cancels the context provided to NewClientStream, or its deadline
    expires. (Note that it if the context is no longer needed before the deadline
    expires, it is still recommended to call cancel to prevent bloat.) It is always
    recommended to cancel contexts when they are no longer needed, and to
    never use the background context directly, so all users should always be
    doing this.
3. The user calls RecvMsg (or Recv in generated code) until a non-nil error is
    returned.
4. The user receives any error from Header or SendMsg (or Send in generated
    code) besides io.EOF.  If none of the above happen, this will leak a goroutine
    and a context, and grpc will not call the optionally-configured stats handler
    with a stats.End message.

Before this change, if a user created a stream and the server ended the stream,
the stats handler would be invoked with a stats.End containing the final status
of the stream. Subsequent calls to RecvMsg would then trigger the stats handler
with InPayloads, which may be unexpected by stats handlers.
2018-02-08 10:51:16 -08:00
dfawley d09ec43545
Implement unary functionality using streams (#1835) 2018-02-05 12:54:13 -08:00
Menghan Li 424e3e9894
Stream: do not cancel ctx created with service config timeout (#1838) 2018-02-02 10:35:15 -08:00
Menghan Li f9628db66d
Fix lint error and typo (#1843) 2018-02-01 11:38:14 -08:00
lyuxuan c22018a9fb
client: send RST_STREAM on client-side errors to prevent server from blocking (#1823) 2018-01-24 11:18:05 -08:00
dfawley 5ba054bf37
encoding: Introduce new method for registering and choosing codecs (#1813) 2018-01-23 11:39:40 -08:00
mmukhi 46bef23bc3
Write should fail when the stream was done but context wasn't cancelled. (#1792) 2018-01-18 15:49:00 -08:00
dfawley 09fc336d84
server: fix bug preventing Serve from exiting when Listener is closed (#1765) 2017-12-22 12:42:04 -08:00
Menghan Li e6549e636d
Add dial option to set balancer (#1697)
WithBalancerName dial option specifies the name of the balancer to be used by the ClientConn. Service config updates can NOT override the balancer option.
2017-12-18 15:35:42 -08:00
dfawley f4b523765c
status: add Code convenience function (#1754) 2017-12-18 15:00:50 -08:00
Daniel Nephin 4e393e0b21 grpc: fix deprecation comments to conform to standard (#1691) 2017-12-18 09:23:42 -08:00
dfawley d1fc8fa770
Deflake tests that rely on Stop() then Dial() not reconnecting (#1728) 2017-12-13 09:30:53 -08:00
dfawley 43083423e4
Change parseTimeout to not handle non-second durations (#1706) 2017-12-05 10:04:04 -08:00
lyuxuan d6cc72862b
switch balancer based on service config info (#1670) 2017-11-17 11:11:05 -08:00
dfawley 816fa5b06f
Add proper support for 'identity' encoding type (#1664) 2017-11-17 09:24:54 -08:00
Menghan Li 409fd8e23b
addrConn: set ac.state to TransientFailure upon non-temporary errors (#1657)
So failfast RPCs will fail with unavailable errors when this happens.
2017-11-13 16:33:42 -08:00
dfawley 8ff8683602
Implement transparent retries for gRFC A6 (#1597) 2017-11-06 13:45:11 -08:00
Gyu-Ho Lee 865013bc17 *: replace deprecated grpc.Errorf calls with status.Errorf (#1651) 2017-11-06 10:24:20 -08:00
Zhouyihai Ding 5db344a40a Introduce new Compressor/Decompressor API (#1428) 2017-10-31 10:21:13 -07:00