grpc 1.4.5-x86-mingw32 → 1.6.0.pre1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/etc/roots.pem +0 -412
  3. data/grpc_c.32.ruby +0 -0
  4. data/grpc_c.64.ruby +0 -0
  5. data/src/ruby/bin/apis/google/protobuf/empty.rb +10 -25
  6. data/src/ruby/bin/apis/pubsub_demo.rb +10 -25
  7. data/src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb +10 -25
  8. data/src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb +10 -25
  9. data/src/ruby/bin/math_client.rb +10 -25
  10. data/src/ruby/bin/math_server.rb +10 -25
  11. data/src/ruby/bin/math_services_pb.rb +10 -25
  12. data/src/ruby/bin/noproto_client.rb +10 -25
  13. data/src/ruby/bin/noproto_server.rb +10 -25
  14. data/src/ruby/ext/grpc/extconf.rb +10 -25
  15. data/src/ruby/ext/grpc/rb_byte_buffer.c +10 -25
  16. data/src/ruby/ext/grpc/rb_byte_buffer.h +10 -25
  17. data/src/ruby/ext/grpc/rb_call.c +44 -25
  18. data/src/ruby/ext/grpc/rb_call.h +10 -25
  19. data/src/ruby/ext/grpc/rb_call_credentials.c +10 -25
  20. data/src/ruby/ext/grpc/rb_call_credentials.h +10 -25
  21. data/src/ruby/ext/grpc/rb_channel.c +10 -25
  22. data/src/ruby/ext/grpc/rb_channel.h +10 -25
  23. data/src/ruby/ext/grpc/rb_channel_args.c +10 -25
  24. data/src/ruby/ext/grpc/rb_channel_args.h +10 -25
  25. data/src/ruby/ext/grpc/rb_channel_credentials.c +10 -25
  26. data/src/ruby/ext/grpc/rb_channel_credentials.h +10 -25
  27. data/src/ruby/ext/grpc/rb_completion_queue.c +10 -25
  28. data/src/ruby/ext/grpc/rb_completion_queue.h +10 -25
  29. data/src/ruby/ext/grpc/rb_compression_options.c +10 -25
  30. data/src/ruby/ext/grpc/rb_compression_options.h +10 -25
  31. data/src/ruby/ext/grpc/rb_event_thread.c +10 -25
  32. data/src/ruby/ext/grpc/rb_event_thread.h +10 -25
  33. data/src/ruby/ext/grpc/rb_grpc.c +10 -25
  34. data/src/ruby/ext/grpc/rb_grpc.h +10 -25
  35. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -25
  36. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +16 -31
  37. data/src/ruby/ext/grpc/rb_loader.c +10 -25
  38. data/src/ruby/ext/grpc/rb_loader.h +10 -25
  39. data/src/ruby/ext/grpc/rb_server.c +10 -25
  40. data/src/ruby/ext/grpc/rb_server.h +10 -25
  41. data/src/ruby/ext/grpc/rb_server_credentials.c +10 -25
  42. data/src/ruby/ext/grpc/rb_server_credentials.h +10 -25
  43. data/src/ruby/lib/grpc.rb +10 -25
  44. data/src/ruby/lib/grpc/2.0/grpc_c.so +0 -0
  45. data/src/ruby/lib/grpc/2.1/grpc_c.so +0 -0
  46. data/src/ruby/lib/grpc/2.2/grpc_c.so +0 -0
  47. data/src/ruby/lib/grpc/2.3/grpc_c.so +0 -0
  48. data/src/ruby/lib/grpc/2.4/grpc_c.so +0 -0
  49. data/src/ruby/lib/grpc/core/time_consts.rb +10 -25
  50. data/src/ruby/lib/grpc/errors.rb +16 -30
  51. data/src/ruby/lib/grpc/generic/active_call.rb +25 -27
  52. data/src/ruby/lib/grpc/generic/bidi_call.rb +17 -27
  53. data/src/ruby/lib/grpc/generic/client_stub.rb +10 -25
  54. data/src/ruby/lib/grpc/generic/rpc_desc.rb +10 -25
  55. data/src/ruby/lib/grpc/generic/rpc_server.rb +10 -25
  56. data/src/ruby/lib/grpc/generic/service.rb +10 -25
  57. data/src/ruby/lib/grpc/grpc.rb +10 -25
  58. data/src/ruby/lib/grpc/grpc_c.so +0 -0
  59. data/src/ruby/lib/grpc/logconfig.rb +10 -25
  60. data/src/ruby/lib/grpc/notifier.rb +10 -25
  61. data/src/ruby/lib/grpc/version.rb +11 -26
  62. data/src/ruby/pb/generate_proto_ruby.sh +10 -25
  63. data/src/ruby/pb/grpc/health/checker.rb +10 -25
  64. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +10 -25
  65. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services_pb.rb +10 -25
  66. data/src/ruby/pb/grpc/testing/metrics_services_pb.rb +10 -25
  67. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +10 -25
  68. data/src/ruby/pb/test/client.rb +10 -25
  69. data/src/ruby/pb/test/server.rb +10 -25
  70. data/src/ruby/spec/call_credentials_spec.rb +10 -25
  71. data/src/ruby/spec/call_spec.rb +43 -25
  72. data/src/ruby/spec/channel_connection_spec.rb +10 -25
  73. data/src/ruby/spec/channel_credentials_spec.rb +11 -26
  74. data/src/ruby/spec/channel_spec.rb +10 -25
  75. data/src/ruby/spec/client_auth_spec.rb +10 -25
  76. data/src/ruby/spec/client_server_spec.rb +66 -25
  77. data/src/ruby/spec/compression_options_spec.rb +10 -25
  78. data/src/ruby/spec/error_sanity_spec.rb +10 -25
  79. data/src/ruby/spec/generic/active_call_spec.rb +10 -25
  80. data/src/ruby/spec/generic/client_stub_spec.rb +146 -35
  81. data/src/ruby/spec/generic/rpc_desc_spec.rb +10 -25
  82. data/src/ruby/spec/generic/rpc_server_pool_spec.rb +10 -25
  83. data/src/ruby/spec/generic/rpc_server_spec.rb +124 -34
  84. data/src/ruby/spec/generic/service_spec.rb +10 -25
  85. data/src/ruby/spec/pb/duplicate/codegen_spec.rb +10 -25
  86. data/src/ruby/spec/pb/health/checker_spec.rb +10 -25
  87. data/src/ruby/spec/server_credentials_spec.rb +10 -25
  88. data/src/ruby/spec/server_spec.rb +10 -25
  89. data/src/ruby/spec/spec_helper.rb +10 -25
  90. data/src/ruby/spec/time_consts_spec.rb +10 -25
  91. metadata +5 -5
@@ -1,31 +1,16 @@
1
- # Copyright 2015, Google Inc.
2
- # All rights reserved.
1
+ # Copyright 2015 gRPC authors.
3
2
  #
4
- # Redistribution and use in source and binary forms, with or without
5
- # modification, are permitted provided that the following conditions are
6
- # met:
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
7
6
  #
8
- # * Redistributions of source code must retain the above copyright
9
- # notice, this list of conditions and the following disclaimer.
10
- # * Redistributions in binary form must reproduce the above
11
- # copyright notice, this list of conditions and the following disclaimer
12
- # in the documentation and/or other materials provided with the
13
- # distribution.
14
- # * Neither the name of Google Inc. nor the names of its
15
- # contributors may be used to endorse or promote products derived from
16
- # this software without specific prior written permission.
7
+ # http://www.apache.org/licenses/LICENSE-2.0
17
8
  #
18
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
- # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
- # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
- # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
- # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
29
14
 
30
15
  require 'grpc'
31
16
 
@@ -35,7 +20,7 @@ describe GRPC::Core::ChannelCredentials do
35
20
 
36
21
  def load_test_certs
37
22
  test_root = File.join(File.dirname(__FILE__), 'testdata')
38
- files = ['ca.pem', 'server1.pem', 'server1.key']
23
+ files = ['ca.pem', 'server1.key', 'server1.pem']
39
24
  files.map { |f| File.open(File.join(test_root, f)).read }
40
25
  end
41
26
 
@@ -1,31 +1,16 @@
1
- # Copyright 2015, Google Inc.
2
- # All rights reserved.
1
+ # Copyright 2015 gRPC authors.
3
2
  #
4
- # Redistribution and use in source and binary forms, with or without
5
- # modification, are permitted provided that the following conditions are
6
- # met:
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
7
6
  #
8
- # * Redistributions of source code must retain the above copyright
9
- # notice, this list of conditions and the following disclaimer.
10
- # * Redistributions in binary form must reproduce the above
11
- # copyright notice, this list of conditions and the following disclaimer
12
- # in the documentation and/or other materials provided with the
13
- # distribution.
14
- # * Neither the name of Google Inc. nor the names of its
15
- # contributors may be used to endorse or promote products derived from
16
- # this software without specific prior written permission.
7
+ # http://www.apache.org/licenses/LICENSE-2.0
17
8
  #
18
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
- # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
- # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
- # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
- # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
29
14
 
30
15
  require 'grpc'
31
16
 
@@ -1,31 +1,16 @@
1
- # Copyright 2015, Google Inc.
2
- # All rights reserved.
1
+ # Copyright 2015 gRPC authors.
3
2
  #
4
- # Redistribution and use in source and binary forms, with or without
5
- # modification, are permitted provided that the following conditions are
6
- # met:
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
7
6
  #
8
- # * Redistributions of source code must retain the above copyright
9
- # notice, this list of conditions and the following disclaimer.
10
- # * Redistributions in binary form must reproduce the above
11
- # copyright notice, this list of conditions and the following disclaimer
12
- # in the documentation and/or other materials provided with the
13
- # distribution.
14
- # * Neither the name of Google Inc. nor the names of its
15
- # contributors may be used to endorse or promote products derived from
16
- # this software without specific prior written permission.
7
+ # http://www.apache.org/licenses/LICENSE-2.0
17
8
  #
18
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
- # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
- # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
- # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
- # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
29
14
 
30
15
  require 'grpc'
31
16
 
@@ -1,31 +1,16 @@
1
- # Copyright 2015, Google Inc.
2
- # All rights reserved.
1
+ # Copyright 2015 gRPC authors.
3
2
  #
4
- # Redistribution and use in source and binary forms, with or without
5
- # modification, are permitted provided that the following conditions are
6
- # met:
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
7
6
  #
8
- # * Redistributions of source code must retain the above copyright
9
- # notice, this list of conditions and the following disclaimer.
10
- # * Redistributions in binary form must reproduce the above
11
- # copyright notice, this list of conditions and the following disclaimer
12
- # in the documentation and/or other materials provided with the
13
- # distribution.
14
- # * Neither the name of Google Inc. nor the names of its
15
- # contributors may be used to endorse or promote products derived from
16
- # this software without specific prior written permission.
7
+ # http://www.apache.org/licenses/LICENSE-2.0
17
8
  #
18
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
- # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
- # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
- # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
- # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
29
14
 
30
15
  require 'grpc'
31
16
 
@@ -241,6 +226,62 @@ shared_examples 'basic GRPC message delivery is OK' do
241
226
  svr_batch = server_call.run_batch(server_ops)
242
227
  expect(svr_batch.send_close).to be true
243
228
  end
229
+
230
+ def client_cancel_test(cancel_proc, expected_code,
231
+ expected_details)
232
+ call = new_client_call
233
+ server_call = nil
234
+
235
+ server_thread = Thread.new do
236
+ server_call = server_allows_client_to_proceed
237
+ end
238
+
239
+ client_ops = {
240
+ CallOps::SEND_INITIAL_METADATA => {},
241
+ CallOps::RECV_INITIAL_METADATA => nil
242
+ }
243
+ batch_result = call.run_batch(client_ops)
244
+ expect(batch_result.send_metadata).to be true
245
+ expect(batch_result.metadata).to eq({})
246
+
247
+ cancel_proc.call(call)
248
+
249
+ server_thread.join
250
+ server_ops = {
251
+ CallOps::RECV_CLOSE_ON_SERVER => nil
252
+ }
253
+ svr_batch = server_call.run_batch(server_ops)
254
+ expect(svr_batch.send_close).to be true
255
+
256
+ client_ops = {
257
+ CallOps::RECV_STATUS_ON_CLIENT => {}
258
+ }
259
+ batch_result = call.run_batch(client_ops)
260
+
261
+ expect(batch_result.status.code).to be expected_code
262
+ expect(batch_result.status.details).to eq expected_details
263
+ end
264
+
265
+ it 'clients can cancel a call on the server' do
266
+ expected_code = StatusCodes::CANCELLED
267
+ expected_details = 'Cancelled'
268
+ cancel_proc = proc { |call| call.cancel }
269
+ client_cancel_test(cancel_proc, expected_code, expected_details)
270
+ end
271
+
272
+ it 'cancel_with_status unknown status' do
273
+ code = StatusCodes::UNKNOWN
274
+ details = 'test unknown reason'
275
+ cancel_proc = proc { |call| call.cancel_with_status(code, details) }
276
+ client_cancel_test(cancel_proc, code, details)
277
+ end
278
+
279
+ it 'cancel_with_status unknown status' do
280
+ code = StatusCodes::FAILED_PRECONDITION
281
+ details = 'test failed precondition reason'
282
+ cancel_proc = proc { |call| call.cancel_with_status(code, details) }
283
+ client_cancel_test(cancel_proc, code, details)
284
+ end
244
285
  end
245
286
 
246
287
  shared_examples 'GRPC metadata delivery works OK' do
@@ -1,31 +1,16 @@
1
- # Copyright 2015, Google Inc.
2
- # All rights reserved.
1
+ # Copyright 2015 gRPC authors.
3
2
  #
4
- # Redistribution and use in source and binary forms, with or without
5
- # modification, are permitted provided that the following conditions are
6
- # met:
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
7
6
  #
8
- # * Redistributions of source code must retain the above copyright
9
- # notice, this list of conditions and the following disclaimer.
10
- # * Redistributions in binary form must reproduce the above
11
- # copyright notice, this list of conditions and the following disclaimer
12
- # in the documentation and/or other materials provided with the
13
- # distribution.
14
- # * Neither the name of Google Inc. nor the names of its
15
- # contributors may be used to endorse or promote products derived from
16
- # this software without specific prior written permission.
7
+ # http://www.apache.org/licenses/LICENSE-2.0
17
8
  #
18
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
- # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
- # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
- # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
- # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
29
14
 
30
15
  require 'grpc'
31
16
 
@@ -1,31 +1,16 @@
1
- # Copyright 2015, Google Inc.
2
- # All rights reserved.
1
+ # Copyright 2015 gRPC authors.
3
2
  #
4
- # Redistribution and use in source and binary forms, with or without
5
- # modification, are permitted provided that the following conditions are
6
- # met:
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
7
6
  #
8
- # * Redistributions of source code must retain the above copyright
9
- # notice, this list of conditions and the following disclaimer.
10
- # * Redistributions in binary form must reproduce the above
11
- # copyright notice, this list of conditions and the following disclaimer
12
- # in the documentation and/or other materials provided with the
13
- # distribution.
14
- # * Neither the name of Google Inc. nor the names of its
15
- # contributors may be used to endorse or promote products derived from
16
- # this software without specific prior written permission.
7
+ # http://www.apache.org/licenses/LICENSE-2.0
17
8
  #
18
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
- # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
- # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
- # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
- # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
29
14
 
30
15
  require 'grpc'
31
16
 
@@ -1,31 +1,16 @@
1
- # Copyright 2015, Google Inc.
2
- # All rights reserved.
1
+ # Copyright 2015 gRPC authors.
3
2
  #
4
- # Redistribution and use in source and binary forms, with or without
5
- # modification, are permitted provided that the following conditions are
6
- # met:
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
7
6
  #
8
- # * Redistributions of source code must retain the above copyright
9
- # notice, this list of conditions and the following disclaimer.
10
- # * Redistributions in binary form must reproduce the above
11
- # copyright notice, this list of conditions and the following disclaimer
12
- # in the documentation and/or other materials provided with the
13
- # distribution.
14
- # * Neither the name of Google Inc. nor the names of its
15
- # contributors may be used to endorse or promote products derived from
16
- # this software without specific prior written permission.
7
+ # http://www.apache.org/licenses/LICENSE-2.0
17
8
  #
18
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
- # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
- # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
- # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
- # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
29
14
 
30
15
  require 'grpc'
31
16
 
@@ -1,31 +1,16 @@
1
- # Copyright 2015, Google Inc.
2
- # All rights reserved.
1
+ # Copyright 2015 gRPC authors.
3
2
  #
4
- # Redistribution and use in source and binary forms, with or without
5
- # modification, are permitted provided that the following conditions are
6
- # met:
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
7
6
  #
8
- # * Redistributions of source code must retain the above copyright
9
- # notice, this list of conditions and the following disclaimer.
10
- # * Redistributions in binary form must reproduce the above
11
- # copyright notice, this list of conditions and the following disclaimer
12
- # in the documentation and/or other materials provided with the
13
- # distribution.
14
- # * Neither the name of Google Inc. nor the names of its
15
- # contributors may be used to endorse or promote products derived from
16
- # this software without specific prior written permission.
7
+ # http://www.apache.org/licenses/LICENSE-2.0
17
8
  #
18
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
- # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
- # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
- # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
- # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
29
14
 
30
15
  require 'grpc'
31
16
 
@@ -487,15 +472,36 @@ describe 'ClientStub' do
487
472
  host = "localhost:#{server_port}"
488
473
  stub = GRPC::ClientStub.new(host, :this_channel_is_insecure)
489
474
  expect do
490
- get_responses(stub)
475
+ get_responses(stub).collect { |r| r }
491
476
  end.to raise_error(ArgumentError,
492
477
  /Header values must be of type string or array/)
493
478
  end
494
479
 
480
+ def run_server_streamer_against_client_with_unmarshal_error(
481
+ expected_input, replys)
482
+ wakey_thread do |notifier|
483
+ c = expect_server_to_be_invoked(notifier)
484
+ expect(c.remote_read).to eq(expected_input)
485
+ begin
486
+ replys.each { |r| c.remote_send(r) }
487
+ rescue GRPC::Core::CallError
488
+ # An attempt to write to the client might fail. This is ok
489
+ # because the client call is expected to fail when
490
+ # unmarshalling the first response, and to cancel the call,
491
+ # and there is a race as for when the server-side call will
492
+ # start to fail.
493
+ p 'remote_send failed (allowed because call expected to cancel)'
494
+ ensure
495
+ c.send_status(OK, 'OK', true)
496
+ end
497
+ end
498
+ end
499
+
495
500
  it 'the call terminates when there is an unmarshalling error' do
496
501
  server_port = create_test_server
497
502
  host = "localhost:#{server_port}"
498
- th = run_server_streamer(@sent_msg, @replys, @pass)
503
+ th = run_server_streamer_against_client_with_unmarshal_error(
504
+ @sent_msg, @replys)
499
505
  stub = GRPC::ClientStub.new(host, :this_channel_is_insecure)
500
506
 
501
507
  unmarshal = proc { fail(ArgumentError, 'test unmarshalling error') }
@@ -610,8 +616,22 @@ describe 'ClientStub' do
610
616
  th.join
611
617
  end
612
618
 
613
- # TODO: add test for metadata-related ArgumentError in a bidi call once
614
- # issue mentioned in https://github.com/grpc/grpc/issues/10526 is fixed
619
+ it 'should raise ArgumentError if metadata contains invalid values' do
620
+ @metadata.merge!(k3: 3)
621
+ stub = GRPC::ClientStub.new(@host, :this_channel_is_insecure)
622
+ expect do
623
+ get_responses(stub).collect { |r| r }
624
+ end.to raise_error(ArgumentError,
625
+ /Header values must be of type string or array/)
626
+ end
627
+
628
+ it 'terminates if the call fails to start' do
629
+ # don't start the server
630
+ stub = GRPC::ClientStub.new(@host, :this_channel_is_insecure)
631
+ expect do
632
+ get_responses(stub, deadline: from_relative_time(0)).collect { |r| r }
633
+ end.to raise_error(GRPC::BadStatus)
634
+ end
615
635
 
616
636
  it 'should send metadata to the server ok' do
617
637
  th = run_bidi_streamer_echo_ping_pong(@sent_msgs, @pass, true,
@@ -621,12 +641,102 @@ describe 'ClientStub' do
621
641
  expect(e.collect { |r| r }).to eq(@sent_msgs)
622
642
  th.join
623
643
  end
644
+
645
+ # Prompted by grpc/github #10526
646
+ describe 'surfacing of errors when sending requests' do
647
+ def run_server_bidi_send_one_then_read_indefinitely
648
+ @server.start
649
+ recvd_rpc = @server.request_call
650
+ recvd_call = recvd_rpc.call
651
+ server_call = GRPC::ActiveCall.new(
652
+ recvd_call, noop, noop, INFINITE_FUTURE,
653
+ metadata_received: true, started: false)
654
+ server_call.send_initial_metadata
655
+ server_call.remote_send('server response')
656
+ loop do
657
+ m = server_call.remote_read
658
+ break if m.nil?
659
+ end
660
+ # can't fail since initial metadata already sent
661
+ server_call.send_status(@pass, 'OK', true)
662
+ end
663
+
664
+ def verify_error_from_write_thread(stub, requests_to_push,
665
+ request_queue, expected_description)
666
+ # TODO: an improvement might be to raise the original exception from
667
+ # bidi call write loops instead of only cancelling the call
668
+ failing_marshal_proc = proc do |req|
669
+ fail req if req.is_a?(StandardError)
670
+ req
671
+ end
672
+ begin
673
+ e = get_responses(stub, marshal_proc: failing_marshal_proc)
674
+ first_response = e.next
675
+ expect(first_response).to eq('server response')
676
+ requests_to_push.each { |req| request_queue.push(req) }
677
+ e.collect { |r| r }
678
+ rescue GRPC::Unknown => e
679
+ exception = e
680
+ end
681
+ expect(exception.message.include?(expected_description)).to be(true)
682
+ end
683
+
684
+ # Provides an Enumerable view of a Queue
685
+ class BidiErrorTestingEnumerateForeverQueue
686
+ def initialize(queue)
687
+ @queue = queue
688
+ end
689
+
690
+ def each
691
+ loop do
692
+ msg = @queue.pop
693
+ yield msg
694
+ end
695
+ end
696
+ end
697
+
698
+ def run_error_in_client_request_stream_test(requests_to_push,
699
+ expected_error_message)
700
+ # start a server that waits on a read indefinitely - it should
701
+ # see a cancellation and be able to break out
702
+ th = Thread.new { run_server_bidi_send_one_then_read_indefinitely }
703
+ stub = GRPC::ClientStub.new(@host, :this_channel_is_insecure)
704
+
705
+ request_queue = Queue.new
706
+ @sent_msgs = BidiErrorTestingEnumerateForeverQueue.new(request_queue)
707
+
708
+ verify_error_from_write_thread(stub,
709
+ requests_to_push,
710
+ request_queue,
711
+ expected_error_message)
712
+ # the write loop errror should cancel the call and end the
713
+ # server's request stream
714
+ th.join
715
+ end
716
+
717
+ it 'non-GRPC errors from the write loop surface when raised ' \
718
+ 'at the start of a request stream' do
719
+ expected_error_message = 'expect error on first request'
720
+ requests_to_push = [StandardError.new(expected_error_message)]
721
+ run_error_in_client_request_stream_test(requests_to_push,
722
+ expected_error_message)
723
+ end
724
+
725
+ it 'non-GRPC errors from the write loop surface when raised ' \
726
+ 'during the middle of a request stream' do
727
+ expected_error_message = 'expect error on last request'
728
+ requests_to_push = %w( one two )
729
+ requests_to_push << StandardError.new(expected_error_message)
730
+ run_error_in_client_request_stream_test(requests_to_push,
731
+ expected_error_message)
732
+ end
733
+ end
624
734
  end
625
735
 
626
736
  describe 'without a call operation' do
627
- def get_responses(stub)
628
- e = stub.bidi_streamer(@method, @sent_msgs, noop, noop,
629
- metadata: @metadata)
737
+ def get_responses(stub, deadline: nil, marshal_proc: noop)
738
+ e = stub.bidi_streamer(@method, @sent_msgs, marshal_proc, noop,
739
+ metadata: @metadata, deadline: deadline)
630
740
  expect(e).to be_a(Enumerator)
631
741
  e
632
742
  end
@@ -638,10 +748,11 @@ describe 'ClientStub' do
638
748
  after(:each) do
639
749
  @op.wait # make sure wait doesn't hang
640
750
  end
641
- def get_responses(stub, run_start_call_first: false)
642
- @op = stub.bidi_streamer(@method, @sent_msgs, noop, noop,
751
+ def get_responses(stub, run_start_call_first: false, deadline: nil,
752
+ marshal_proc: noop)
753
+ @op = stub.bidi_streamer(@method, @sent_msgs, marshal_proc, noop,
643
754
  return_op: true,
644
- metadata: @metadata)
755
+ metadata: @metadata, deadline: deadline)
645
756
  expect(@op).to be_a(GRPC::ActiveCall::Operation)
646
757
  @op.start_call if run_start_call_first
647
758
  e = @op.execute