You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
4.6 KiB

8 years ago
8 years ago
8 years ago
build(deps): Bump google.golang.org/grpc from 1.41.0 to 1.42.0 (#7200) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.41.0 to 1.42.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/grpc/grpc-go/releases">google.golang.org/grpc's releases</a>.</em></p> <blockquote> <h2>Release 1.42.0</h2> <h1>Behavior Changes</h1> <ul> <li>grpc: Dial(&quot;unix://relative-path&quot;) no longer works (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4817">#4817</a>) <ul> <li>use &quot;unix://absolute-path&quot; or &quot;unix:relative-path&quot; instead in accordance with <a href="https://github.com/grpc/grpc/blob/master/doc/naming.md#name-syntax">our documentation</a></li> </ul> </li> <li>xds/csds: use new field <code>GenericXdsConfig</code> instead of <code>PerXdsConfig</code> (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4898">#4898</a>)</li> </ul> <h1>New Features</h1> <ul> <li>grpc: support <code>grpc.WithAuthority</code> when secure credentials are used (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4817">#4817</a>)</li> <li>creds/google: add NewDefaultCredentialsWithOptions() to support custom per-RPC creds (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4830">#4830</a>)</li> <li>authz: create file watcher interceptor for gRPC SDK API (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4760">#4760</a>)</li> <li>attributes: add <code>Equal</code> method (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4855">#4855</a>)</li> <li>resolver: add <code>AddressMap</code> and <code>State.BalancerAttributes</code> (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4855">#4855</a>)</li> <li>resolver: Add <code>URL</code> field to <code>Target</code> to store parsed dial target (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4817">#4817</a>)</li> <li>grpclb: add a <code>target_name</code> field to lb config to specify target when used as a child policy (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4847">#4847</a>)</li> <li>grpclog: support formatting log output as JSON (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4854">#4854</a>)</li> </ul> <h1>Bug Fixes</h1> <ul> <li>server: add missing conn.Close if the connection dies before reading the HTTP/2 preface (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4837">#4837</a>)</li> <li>grpclb: recover if addresses are received after an empty server list was received previously (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4879">#4879</a>)</li> <li>authz: support empty principals and fix rbac authenticated matcher (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4883">#4883</a>)</li> <li>xds/rds: NACK the RDS response if it contains unknown cluster specifier (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4788">#4788</a>)</li> <li>xds/priority: do not switch to low priority when high priority is in Idle (e.g. ringhash) (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4889">#4889</a>)</li> </ul> <h1>Documentation</h1> <ul> <li>grpc: stabilize WithDefaultServiceConfig and improve godoc (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4888">#4888</a>)</li> <li>status: clarify FromError docstring (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4880">#4880</a>)</li> <li>examples: add example illustrating the use of unix abstract sockets (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4848">#4848</a>)</li> <li>examples: update load balancing example to use loadBalancingConfig (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4887">#4887</a>)</li> <li>doc: promote WithDisableRetry to stable; clarify retry is enabled by default (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4901">#4901</a>)</li> </ul> <h1>API Changes</h1> <ul> <li>credentials: Mark <code>TransportCredentials.OverrideServerName</code> method as deprecated (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4817">#4817</a>)</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/grpc/grpc-go/commit/aff571cc86e6e7e740130dbbb32a9741558db805"><code>aff571c</code></a> Change version to 1.42.0 (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4910">#4910</a>)</li> <li><a href="https://github.com/grpc/grpc-go/commit/2d7bdf2d2327ce888df559ca90db6bac53ef8b99"><code>2d7bdf2</code></a> xds: Set RBAC on by default (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4909">#4909</a>)</li> <li><a href="https://github.com/grpc/grpc-go/commit/d47437c91e798b5370e019660cd74c9c0c8e32fb"><code>d47437c</code></a> xds: Fix invert functionality for header matcher (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4902">#4902</a>)</li> <li><a href="https://github.com/grpc/grpc-go/commit/9fa26982649594f2b84a442644d3c8995d4dac1b"><code>9fa2698</code></a> xds/csds: populate new GenericXdsConfig field (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4898">#4898</a>)</li> <li><a href="https://github.com/grpc/grpc-go/commit/6e8625df635bd7afe589d38a1559ebacf4273b07"><code>6e8625d</code></a> doc: promote WithDisableRetry to stable; clarify retry is enabled by default ...</li> <li><a href="https://github.com/grpc/grpc-go/commit/f1d87c14c2165a7ddbc26f6319e777c88c1b3c85"><code>f1d87c1</code></a> client: properly disable retry if GRPC_GO_RETRY=off (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4899">#4899</a>)</li> <li><a href="https://github.com/grpc/grpc-go/commit/03753f593ccb9034846f7a17db5165a4827b35a2"><code>03753f5</code></a> creds/google: fix CFE cluster name check (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4893">#4893</a>)</li> <li><a href="https://github.com/grpc/grpc-go/commit/4f21cde702d9f9b1c874791e1c3751b1f7d192ce"><code>4f21cde</code></a> authz: support empty principals and fix rbac authenticated matcher (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4883">#4883</a>)</li> <li><a href="https://github.com/grpc/grpc-go/commit/f00baa6c3c8455ef1db2ac64f7b89a63ec7d2776"><code>f00baa6</code></a> resolver: replace AddressMap.Range with Keys (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4891">#4891</a>)</li> <li><a href="https://github.com/grpc/grpc-go/commit/2a312458e6bd0d3fd9ffccee9b6906b6e753bb8f"><code>2a31245</code></a> client: don't force passthrough as default resolver (<a href="https://github-redirect.dependabot.com/grpc/grpc-go/issues/4890">#4890</a>)</li> <li>Additional commits viewable in <a href="https://github.com/grpc/grpc-go/compare/v1.41.0...v1.42.0">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=google.golang.org/grpc&package-manager=go_modules&previous-version=1.41.0&new-version=1.42.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details>
3 years ago
8 years ago
8 years ago
8 years ago
  1. package example
  2. import (
  3. "context"
  4. "fmt"
  5. "math/rand"
  6. "net"
  7. "os"
  8. "reflect"
  9. "testing"
  10. "time"
  11. "github.com/stretchr/testify/require"
  12. "google.golang.org/grpc"
  13. "github.com/tendermint/tendermint/libs/log"
  14. tmnet "github.com/tendermint/tendermint/libs/net"
  15. abciclient "github.com/tendermint/tendermint/abci/client"
  16. "github.com/tendermint/tendermint/abci/example/code"
  17. "github.com/tendermint/tendermint/abci/example/kvstore"
  18. abciserver "github.com/tendermint/tendermint/abci/server"
  19. "github.com/tendermint/tendermint/abci/types"
  20. )
  21. func init() {
  22. rand.Seed(time.Now().UnixNano())
  23. }
  24. func TestKVStore(t *testing.T) {
  25. ctx, cancel := context.WithCancel(context.Background())
  26. defer cancel()
  27. fmt.Println("### Testing KVStore")
  28. testStream(ctx, t, kvstore.NewApplication())
  29. }
  30. func TestBaseApp(t *testing.T) {
  31. ctx, cancel := context.WithCancel(context.Background())
  32. defer cancel()
  33. fmt.Println("### Testing BaseApp")
  34. testStream(ctx, t, types.NewBaseApplication())
  35. }
  36. func TestGRPC(t *testing.T) {
  37. ctx, cancel := context.WithCancel(context.Background())
  38. defer cancel()
  39. fmt.Println("### Testing GRPC")
  40. testGRPCSync(ctx, t, types.NewGRPCApplication(types.NewBaseApplication()))
  41. }
  42. func testStream(ctx context.Context, t *testing.T, app types.Application) {
  43. t.Helper()
  44. const numDeliverTxs = 20000
  45. socketFile := fmt.Sprintf("test-%08x.sock", rand.Int31n(1<<30))
  46. defer os.Remove(socketFile)
  47. socket := fmt.Sprintf("unix://%v", socketFile)
  48. logger := log.TestingLogger()
  49. // Start the listener
  50. server := abciserver.NewSocketServer(logger.With("module", "abci-server"), socket, app)
  51. t.Cleanup(server.Wait)
  52. err := server.Start(ctx)
  53. require.NoError(t, err)
  54. // Connect to the socket
  55. client := abciclient.NewSocketClient(log.TestingLogger().With("module", "abci-client"), socket, false)
  56. t.Cleanup(client.Wait)
  57. err = client.Start(ctx)
  58. require.NoError(t, err)
  59. done := make(chan struct{})
  60. counter := 0
  61. client.SetResponseCallback(func(req *types.Request, res *types.Response) {
  62. // Process response
  63. switch r := res.Value.(type) {
  64. case *types.Response_DeliverTx:
  65. counter++
  66. if r.DeliverTx.Code != code.CodeTypeOK {
  67. t.Error("DeliverTx failed with ret_code", r.DeliverTx.Code)
  68. }
  69. if counter > numDeliverTxs {
  70. t.Fatalf("Too many DeliverTx responses. Got %d, expected %d", counter, numDeliverTxs)
  71. }
  72. if counter == numDeliverTxs {
  73. go func() {
  74. time.Sleep(time.Second * 1) // Wait for a bit to allow counter overflow
  75. close(done)
  76. }()
  77. return
  78. }
  79. case *types.Response_Flush:
  80. // ignore
  81. default:
  82. t.Error("Unexpected response type", reflect.TypeOf(res.Value))
  83. }
  84. })
  85. // Write requests
  86. for counter := 0; counter < numDeliverTxs; counter++ {
  87. // Send request
  88. _, err = client.DeliverTxAsync(ctx, types.RequestDeliverTx{Tx: []byte("test")})
  89. require.NoError(t, err)
  90. // Sometimes send flush messages
  91. if counter%128 == 0 {
  92. err = client.FlushSync(context.Background())
  93. require.NoError(t, err)
  94. }
  95. }
  96. // Send final flush message
  97. _, err = client.FlushAsync(ctx)
  98. require.NoError(t, err)
  99. <-done
  100. }
  101. //-------------------------
  102. // test grpc
  103. func dialerFunc(ctx context.Context, addr string) (net.Conn, error) {
  104. return tmnet.Connect(addr)
  105. }
  106. func testGRPCSync(ctx context.Context, t *testing.T, app types.ABCIApplicationServer) {
  107. numDeliverTxs := 2000
  108. socketFile := fmt.Sprintf("/tmp/test-%08x.sock", rand.Int31n(1<<30))
  109. defer os.Remove(socketFile)
  110. socket := fmt.Sprintf("unix://%v", socketFile)
  111. logger := log.TestingLogger()
  112. // Start the listener
  113. server := abciserver.NewGRPCServer(logger.With("module", "abci-server"), socket, app)
  114. if err := server.Start(ctx); err != nil {
  115. t.Fatalf("Error starting GRPC server: %v", err.Error())
  116. }
  117. t.Cleanup(func() { server.Wait() })
  118. // Connect to the socket
  119. conn, err := grpc.Dial(socket, grpc.WithInsecure(), grpc.WithContextDialer(dialerFunc))
  120. if err != nil {
  121. t.Fatalf("Error dialing GRPC server: %v", err.Error())
  122. }
  123. t.Cleanup(func() {
  124. if err := conn.Close(); err != nil {
  125. t.Error(err)
  126. }
  127. })
  128. client := types.NewABCIApplicationClient(conn)
  129. // Write requests
  130. for counter := 0; counter < numDeliverTxs; counter++ {
  131. // Send request
  132. response, err := client.DeliverTx(context.Background(), &types.RequestDeliverTx{Tx: []byte("test")})
  133. if err != nil {
  134. t.Fatalf("Error in GRPC DeliverTx: %v", err.Error())
  135. }
  136. counter++
  137. if response.Code != code.CodeTypeOK {
  138. t.Error("DeliverTx failed with ret_code", response.Code)
  139. }
  140. if counter > numDeliverTxs {
  141. t.Fatal("Too many DeliverTx responses")
  142. }
  143. t.Log("response", counter)
  144. if counter == numDeliverTxs {
  145. go func() {
  146. time.Sleep(time.Second * 1) // Wait for a bit to allow counter overflow
  147. }()
  148. }
  149. }
  150. }