-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathgrpc_test.rb
49 lines (40 loc) · 1.28 KB
/
grpc_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require_relative "test_helper"
require "google/protobuf"
Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "requester.Config" do
optional :name, :string, 1
end
add_message "requester.Response" do
optional :message, :string, 1
end
end
module Requester
Config = Google::Protobuf::DescriptorPool.generated_pool.lookup("requester.Config").msgclass
Response = Google::Protobuf::DescriptorPool.generated_pool.lookup("requester.Response").msgclass
end
module Requester
module Requester
class Service
include GRPC::GenericService
self.marshal_class_method = :encode
self.unmarshal_class_method = :decode
self.service_name = 'requester.Requester'
rpc :Process, Config, Response
end
Stub = Service.rpc_stub_class
end
end
class GrpcTest < Minitest::Test
def test_connect
stub = Requester::Requester::Stub.new("#{connect_host}:50051", :this_channel_is_insecure, timeout: 1)
assert_timeout(GRPC::DeadlineExceeded) do
stub.process(Requester::Config.new(name: "Mark"))
end
end
def test_read
stub = Requester::Requester::Stub.new(read_host_and_port, :this_channel_is_insecure, timeout: 1)
assert_timeout(GRPC::DeadlineExceeded) do
stub.process(Requester::Config.new(name: "Mark"))
end
end
end