fluent-plugin-google-cloud 0.6.9.pre.1 → 0.6.10.pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +23 -25
- data/fluent-plugin-google-cloud.gemspec +4 -4
- data/lib/fluent/plugin/out_google_cloud.rb +93 -77
- data/test/plugin/base_test.rb +37 -24
- data/test/plugin/constants.rb +119 -110
- data/test/plugin/test_out_google_cloud.rb +2 -1
- data/test/plugin/test_out_google_cloud_grpc.rb +41 -24
- metadata +4 -10
@@ -273,7 +273,8 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
|
|
273
273
|
|
274
274
|
private
|
275
275
|
|
276
|
-
WRITE_LOG_ENTRIES_URI =
|
276
|
+
WRITE_LOG_ENTRIES_URI =
|
277
|
+
'https://logging.googleapis.com/v2/entries:write'.freeze
|
277
278
|
|
278
279
|
def rename_key(hash, old_key, new_key)
|
279
280
|
hash.merge(new_key => hash[old_key]).reject { |k, _| k == old_key }
|
@@ -91,8 +91,8 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
|
|
91
91
|
[true, 13, 1, 2, [0, 1, 0, 0, 2]]
|
92
92
|
].each do |should_fail, code, request_count, entry_count, metric_values|
|
93
93
|
setup_prometheus
|
94
|
-
|
95
|
-
(
|
94
|
+
(1..request_count).each do
|
95
|
+
setup_logging_stubs(should_fail, code, 'SomeMessage') do
|
96
96
|
d = create_driver(USE_GRPC_CONFIG + PROMETHEUS_ENABLE_CONFIG, 'test',
|
97
97
|
GRPCLoggingMockFailingService.rpc_stub_class)
|
98
98
|
(1..entry_count).each do |i|
|
@@ -205,14 +205,21 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
|
|
205
205
|
|
206
206
|
private
|
207
207
|
|
208
|
-
GRPC_MOCK_HOST = 'localhost:56789'
|
209
|
-
|
210
208
|
WriteLogEntriesRequest = Google::Logging::V2::WriteLogEntriesRequest
|
211
209
|
WriteLogEntriesResponse = Google::Logging::V2::WriteLogEntriesResponse
|
212
210
|
|
213
211
|
USE_GRPC_CONFIG = %(
|
214
212
|
use_grpc true
|
215
|
-
)
|
213
|
+
).freeze
|
214
|
+
|
215
|
+
@@mock_port = 0 # rubocop:disable Style/ClassVars
|
216
|
+
|
217
|
+
def generate_mock_host
|
218
|
+
# rubocop:disable Style/ClassVars
|
219
|
+
@@mock_port = (@@mock_port + 1) % 10_000 + 50_000
|
220
|
+
"localhost:#{@@mock_port}"
|
221
|
+
# rubocop:enable Style/ClassVars
|
222
|
+
end
|
216
223
|
|
217
224
|
# Create a Fluentd output test driver with the Google Cloud Output plugin with
|
218
225
|
# grpc enabled. The signature of this method is different between the grpc
|
@@ -222,14 +229,16 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
|
|
222
229
|
grpc_stub = GRPCLoggingMockService.rpc_stub_class)
|
223
230
|
conf += USE_GRPC_CONFIG
|
224
231
|
Fluent::Test::BufferedOutputTestDriver.new(
|
225
|
-
GoogleCloudOutputWithGRPCMock.new(grpc_stub
|
232
|
+
GoogleCloudOutputWithGRPCMock.new(grpc_stub, @mock_host),
|
233
|
+
tag).configure(conf, true)
|
226
234
|
end
|
227
235
|
|
228
236
|
# Google Cloud Fluent output stub with grpc mock.
|
229
237
|
class GoogleCloudOutputWithGRPCMock < Fluent::GoogleCloudOutput
|
230
|
-
def initialize(grpc_stub)
|
238
|
+
def initialize(grpc_stub, mock_host)
|
231
239
|
super()
|
232
240
|
@grpc_stub = grpc_stub
|
241
|
+
@mock_host = mock_host
|
233
242
|
end
|
234
243
|
|
235
244
|
def api_client
|
@@ -240,7 +249,7 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
|
|
240
249
|
|
241
250
|
# Here we have obtained the creds, but for the mock, we will leave the
|
242
251
|
# channel insecure.
|
243
|
-
@grpc_stub.new(
|
252
|
+
@grpc_stub.new(@mock_host, :this_channel_is_insecure)
|
244
253
|
end
|
245
254
|
end
|
246
255
|
|
@@ -261,15 +270,15 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
|
|
261
270
|
# These methods should never be called, so they will just fail the tests
|
262
271
|
# with "unimplemented" errors..
|
263
272
|
def _undefined
|
264
|
-
|
273
|
+
raise "Method #{__callee__} is unimplemented and needs to be overridden."
|
265
274
|
end
|
266
275
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
276
|
+
alias list_logs _undefined
|
277
|
+
alias list_log_entries _undefined
|
278
|
+
alias list_log_services _undefined
|
279
|
+
alias list_log_service_indexes _undefined
|
280
|
+
alias list_monitored_resource_descriptors _undefined
|
281
|
+
alias delete_log _undefined
|
273
282
|
undef_method :_undefined
|
274
283
|
end
|
275
284
|
|
@@ -288,7 +297,7 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
|
|
288
297
|
|
289
298
|
def write_log_entries(_request, _call)
|
290
299
|
@failed_attempts << 1
|
291
|
-
|
300
|
+
raise GRPC::BadStatus.new(@code, @message)
|
292
301
|
end
|
293
302
|
|
294
303
|
# TODO(lingshi) Remove these dummy methods when grpc/9033 is fixed.
|
@@ -296,20 +305,27 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
|
|
296
305
|
# These methods should never be called, so they will just fail the tests
|
297
306
|
# with "unimplemented" errors..
|
298
307
|
def _undefined
|
299
|
-
|
308
|
+
raise "Method #{__callee__} is unimplemented and needs to be overridden."
|
300
309
|
end
|
301
310
|
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
311
|
+
alias list_logs _undefined
|
312
|
+
alias list_log_entries _undefined
|
313
|
+
alias list_log_services _undefined
|
314
|
+
alias list_log_service_indexes _undefined
|
315
|
+
alias list_monitored_resource_descriptors _undefined
|
316
|
+
alias delete_log _undefined
|
308
317
|
undef_method :_undefined
|
309
318
|
end
|
310
319
|
|
311
320
|
# Set up grpc stubs to mock the external calls.
|
321
|
+
# TODO(qingling128): Remove this comment after grpc/grpc#12506 is resolved.
|
322
|
+
# Due to a gRPC load balancing issue (grpc/grpc#12506), we have to use a
|
323
|
+
# different port each time we create a gRPC mock as a temporary workaround.
|
324
|
+
# Thus we can only create one driver in each setup_logging_stubs context.
|
312
325
|
def setup_logging_stubs(should_fail = false, code = 0, message = 'Ok')
|
326
|
+
# Save the mock host in an instance variable, so later on when creating the
|
327
|
+
# logging driver, we can refer to this host with exactly the same port.
|
328
|
+
@mock_host = generate_mock_host
|
313
329
|
srv = GRPC::RpcServer.new
|
314
330
|
@failed_attempts = []
|
315
331
|
@requests_sent = []
|
@@ -319,7 +335,7 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
|
|
319
335
|
grpc = GRPCLoggingMockService.new(@requests_sent)
|
320
336
|
end
|
321
337
|
srv.handle(grpc)
|
322
|
-
srv.add_http2_port(
|
338
|
+
srv.add_http2_port(@mock_host, :this_port_is_insecure)
|
323
339
|
t = Thread.new { srv.run }
|
324
340
|
srv.wait_till_running
|
325
341
|
begin
|
@@ -331,6 +347,7 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
|
|
331
347
|
end
|
332
348
|
srv.stop
|
333
349
|
t.join
|
350
|
+
@mock_host = nil
|
334
351
|
end
|
335
352
|
|
336
353
|
# Verify the number and the content of the log entries match the expectation.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-google-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.10.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Derr
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -100,9 +100,6 @@ dependencies:
|
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '1.0'
|
103
|
-
- - "<"
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version: '1.3'
|
106
103
|
type: :runtime
|
107
104
|
prerelease: false
|
108
105
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -110,9 +107,6 @@ dependencies:
|
|
110
107
|
- - "~>"
|
111
108
|
- !ruby/object:Gem::Version
|
112
109
|
version: '1.0'
|
113
|
-
- - "<"
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
version: '1.3'
|
116
110
|
- !ruby/object:Gem::Dependency
|
117
111
|
name: json
|
118
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,14 +155,14 @@ dependencies:
|
|
161
155
|
requirements:
|
162
156
|
- - "~>"
|
163
157
|
- !ruby/object:Gem::Version
|
164
|
-
version: 0.
|
158
|
+
version: 0.39.0
|
165
159
|
type: :development
|
166
160
|
prerelease: false
|
167
161
|
version_requirements: !ruby/object:Gem::Requirement
|
168
162
|
requirements:
|
169
163
|
- - "~>"
|
170
164
|
- !ruby/object:Gem::Version
|
171
|
-
version: 0.
|
165
|
+
version: 0.39.0
|
172
166
|
- !ruby/object:Gem::Dependency
|
173
167
|
name: webmock
|
174
168
|
requirement: !ruby/object:Gem::Requirement
|