Skip to content

Commit ee0fdd2

Browse files
committed
Adjust unittest
1 parent f6fdcfe commit ee0fdd2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/logcache/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ def container_metrics(source_guid:, start_time:, end_time:, envelope_limit: DEFA
4747
def with_request_error_handling(_source_guid)
4848
tries ||= 3
4949
start_time = Time.now
50-
yield
5150

5251
# convert to milliseconds to get more precise information
5352
time_taken = (Time.now - start_time) * 1000
5453
logger.info("Response time: #{time_taken.round(2)} ms")
54+
yield
5555
rescue StandardError => e
5656
raise CloudController::Errors::ApiError.new_from_details('ServiceUnavailable', 'Connection to Log Cache timed out') if e.is_a?(GRPC::DeadlineExceeded)
5757

spec/logcache/client_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module Logcache
3636
with(client_ca, client_key, client_cert).
3737
and_return(credentials)
3838
expect(Logcache::V1::Egress::Stub).to receive(:new).
39-
with("#{host}:#{port}", credentials, channel_args: channel_arg_hash, timeout: 250).
39+
with("#{host}:#{port}", credentials, channel_args: channel_arg_hash, timeout: 10).
4040
and_return(logcache_service)
4141
allow(Logcache::V1::ReadRequest).to receive(:new).and_return(logcache_request)
4242
end
@@ -68,7 +68,7 @@ module Logcache
6868
with(client_ca, client_key, client_cert).
6969
and_return(credentials)
7070
expect(Logcache::V1::Egress::Stub).to receive(:new).
71-
with("#{host}:#{port}", credentials, channel_args: channel_arg_hash, timeout: 250).
71+
with("#{host}:#{port}", credentials, channel_args: channel_arg_hash, timeout: 10).
7272
and_return(logcache_service)
7373
allow(client).to receive(:sleep)
7474
allow(Logcache::V1::ReadRequest).to receive(:new).and_return(logcache_request)
@@ -99,7 +99,7 @@ module Logcache
9999
with(client_ca, client_key, client_cert).
100100
and_return(credentials)
101101
expect(Logcache::V1::Egress::Stub).to receive(:new).
102-
with("#{host}:#{port}", credentials, channel_args: channel_arg_hash, timeout: 250).
102+
with("#{host}:#{port}", credentials, channel_args: channel_arg_hash, timeout: 10).
103103
and_return(logcache_service)
104104
allow(client).to receive(:sleep)
105105
allow(Logcache::V1::ReadRequest).to receive(:new).and_return(logcache_request)
@@ -130,7 +130,7 @@ module Logcache
130130
with(client_ca, client_key, client_cert).
131131
and_return(credentials)
132132
expect(Logcache::V1::Egress::Stub).to receive(:new).
133-
with("#{host}:#{port}", credentials, channel_args: channel_arg_hash, timeout: 250).
133+
with("#{host}:#{port}", credentials, channel_args: channel_arg_hash, timeout: 10).
134134
and_return(logcache_service)
135135
allow(client).to receive(:sleep)
136136
allow(Logcache::V1::ReadRequest).to receive(:new).and_return(logcache_request)
@@ -164,7 +164,7 @@ module Logcache
164164
before do
165165
expect(GRPC::Core::ChannelCredentials).not_to receive(:new)
166166
expect(Logcache::V1::Egress::Stub).to receive(:new).
167-
with("#{host}:#{port}", :this_channel_is_insecure, timeout: 250).
167+
with("#{host}:#{port}", :this_channel_is_insecure, timeout: 10).
168168
and_return(logcache_service)
169169
allow(Logcache::V1::ReadRequest).to receive(:new).and_return(logcache_request)
170170
end

0 commit comments

Comments
 (0)