fluent-plugin-google-cloud 0.7.2 → 0.7.3
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 +3 -3
- data/fluent-plugin-google-cloud.gemspec +1 -1
- data/lib/fluent/plugin/out_google_cloud.rb +9 -1
- data/test/plugin/base_test.rb +118 -24
- data/test/plugin/constants.rb +36 -4
- data/test/plugin/test_out_google_cloud.rb +34 -14
- data/test/plugin/test_out_google_cloud_grpc.rb +71 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbcd8e43170062fe787c54619c5ad959f0a8d1603fb7dfc2a1c2be5ac7997d4e
|
4
|
+
data.tar.gz: d22989b9d59f470ecc3e184bff6bd1bc049f66f0d0e3918a649f36e2cbbd0424
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5b5e63ddf4cc5bffcc92ae9a89dc47b25570c4108c5fde3a34a9c3a77b8b15dbeb2832e55295a5b44505fb2b7b3919a521ab89f847642427728f8c698537a1e
|
7
|
+
data.tar.gz: 19554fb0fc748dc0a246850053874dcc53dbc7264d4d75d321e0a64c812f2beb887616945d73f104090aae92656386dde464f87b52ffc9e6c745ad72c10d2bf3
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-google-cloud (0.7.
|
4
|
+
fluent-plugin-google-cloud (0.7.3)
|
5
5
|
fluentd (= 1.2.5)
|
6
6
|
google-api-client (= 0.23.9)
|
7
7
|
google-cloud-logging (= 1.5.4)
|
@@ -129,7 +129,7 @@ GEM
|
|
129
129
|
stackdriver-core (1.3.3)
|
130
130
|
google-cloud-core (~> 1.2)
|
131
131
|
strptime (0.2.3)
|
132
|
-
test-unit (3.2.
|
132
|
+
test-unit (3.2.9)
|
133
133
|
power_assert
|
134
134
|
thread_safe (0.3.6)
|
135
135
|
tzinfo (1.2.5)
|
@@ -137,7 +137,7 @@ GEM
|
|
137
137
|
tzinfo-data (1.2018.7)
|
138
138
|
tzinfo (>= 1.0.0)
|
139
139
|
uber (0.1.0)
|
140
|
-
unicode-display_width (1.4.
|
140
|
+
unicode-display_width (1.4.1)
|
141
141
|
webmock (2.3.2)
|
142
142
|
addressable (>= 2.3.6)
|
143
143
|
crack (>= 0.3.2)
|
@@ -10,7 +10,7 @@ eos
|
|
10
10
|
gem.homepage =
|
11
11
|
'https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud'
|
12
12
|
gem.license = 'Apache-2.0'
|
13
|
-
gem.version = '0.7.
|
13
|
+
gem.version = '0.7.3'
|
14
14
|
gem.authors = ['Stackdriver Agents Team']
|
15
15
|
gem.email = ['stackdriver-agents@google.com']
|
16
16
|
gem.required_ruby_version = Gem::Requirement.new('>= 2.2')
|
@@ -186,6 +186,7 @@ module Fluent
|
|
186
186
|
%w(responseSize response_size parse_int),
|
187
187
|
%w(userAgent user_agent parse_string),
|
188
188
|
%w(remoteIp remote_ip parse_string),
|
189
|
+
%w(serverIp server_ip parse_string),
|
189
190
|
%w(referer referer parse_string),
|
190
191
|
%w(cacheHit cache_hit parse_bool),
|
191
192
|
%w(cacheValidatedWithOriginServer
|
@@ -609,7 +610,14 @@ module Fluent
|
|
609
610
|
# allow for determining whether we should parse the log or message
|
610
611
|
# field.
|
611
612
|
preserved_keys = [
|
612
|
-
'time',
|
613
|
+
'time',
|
614
|
+
'severity',
|
615
|
+
@http_request_key,
|
616
|
+
@insert_id_key,
|
617
|
+
@operation_key,
|
618
|
+
@source_location_key,
|
619
|
+
@span_id_key,
|
620
|
+
@trace_key
|
613
621
|
]
|
614
622
|
|
615
623
|
# If the log is json, we want to export it as a structured log
|
data/test/plugin/base_test.rb
CHANGED
@@ -612,6 +612,30 @@ module BaseTest
|
|
612
612
|
end
|
613
613
|
end
|
614
614
|
|
615
|
+
# Verify that when the log has only one effective field (named 'log',
|
616
|
+
# 'message', or 'msg') and the field is in JSON format, the field is parsed as
|
617
|
+
# JSON and sent as jsonPayload.
|
618
|
+
def test_detect_json_auto_triggered_with_one_field
|
619
|
+
setup_gce_metadata_stubs
|
620
|
+
json_string = '{"msg": "test log entry 0", "tag2": "test", ' \
|
621
|
+
'"data": 5000, "some_null_field": null}'
|
622
|
+
setup_logging_stubs do
|
623
|
+
d = create_driver(DETECT_JSON_CONFIG)
|
624
|
+
%w(message log msg).each do |field|
|
625
|
+
d.emit(PRESERVED_KEYS_MAP.merge(field => json_string))
|
626
|
+
end
|
627
|
+
d.run
|
628
|
+
end
|
629
|
+
verify_log_entries(3, COMPUTE_PARAMS, 'jsonPayload') do |entry|
|
630
|
+
fields = get_fields(entry['jsonPayload'])
|
631
|
+
assert_equal 4, fields.size, entry
|
632
|
+
assert_equal 'test log entry 0', get_string(fields['msg']), entry
|
633
|
+
assert_equal 'test', get_string(fields['tag2']), entry
|
634
|
+
assert_equal 5000, get_number(fields['data']), entry
|
635
|
+
assert_equal null_value, fields['some_null_field'], entry
|
636
|
+
end
|
637
|
+
end
|
638
|
+
|
615
639
|
# Verify that we drop the log entries when 'require_valid_tags' is true and
|
616
640
|
# any non-string tags or tags with non-utf8 characters are detected.
|
617
641
|
def test_reject_invalid_tags_with_require_valid_tags_true
|
@@ -1219,6 +1243,8 @@ module BaseTest
|
|
1219
1243
|
verify_log_entries(1, DATAFLOW_PARAMS)
|
1220
1244
|
end
|
1221
1245
|
|
1246
|
+
# Verify the subfields extraction of LogEntry fields.
|
1247
|
+
|
1222
1248
|
def test_log_entry_http_request_field_from_record
|
1223
1249
|
verify_subfields_from_record(DEFAULT_HTTP_REQUEST_KEY)
|
1224
1250
|
end
|
@@ -1231,6 +1257,9 @@ module BaseTest
|
|
1231
1257
|
verify_subfields_from_record(DEFAULT_OPERATION_KEY)
|
1232
1258
|
end
|
1233
1259
|
|
1260
|
+
# Verify the subfields extraction of LogEntry fields when there are other
|
1261
|
+
# fields.
|
1262
|
+
|
1234
1263
|
def test_log_entry_http_request_field_partial_from_record
|
1235
1264
|
verify_subfields_partial_from_record(DEFAULT_HTTP_REQUEST_KEY)
|
1236
1265
|
end
|
@@ -1243,6 +1272,8 @@ module BaseTest
|
|
1243
1272
|
verify_subfields_partial_from_record(DEFAULT_OPERATION_KEY)
|
1244
1273
|
end
|
1245
1274
|
|
1275
|
+
# Verify the subfields extraction of LogEntry fields when they are not hashes.
|
1276
|
+
|
1246
1277
|
def test_log_entry_http_request_field_when_not_hash
|
1247
1278
|
verify_subfields_when_not_hash(DEFAULT_HTTP_REQUEST_KEY)
|
1248
1279
|
end
|
@@ -1255,6 +1286,8 @@ module BaseTest
|
|
1255
1286
|
verify_subfields_when_not_hash(DEFAULT_OPERATION_KEY)
|
1256
1287
|
end
|
1257
1288
|
|
1289
|
+
# Verify the subfields extraction of LogEntry fields when they are nil.
|
1290
|
+
|
1258
1291
|
def test_log_entry_http_request_field_when_nil
|
1259
1292
|
verify_subfields_when_nil(DEFAULT_HTTP_REQUEST_KEY)
|
1260
1293
|
end
|
@@ -1324,9 +1357,23 @@ module BaseTest
|
|
1324
1357
|
end
|
1325
1358
|
end
|
1326
1359
|
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1360
|
+
# Verify the default and customization of LogEntry field extraction key.
|
1361
|
+
|
1362
|
+
def test_log_entry_insert_id_field
|
1363
|
+
verify_field_key('insertId', DEFAULT_INSERT_ID_KEY, 'custom_insert_id_key',
|
1364
|
+
CONFIG_CUSTOM_INSERT_ID_KEY_SPECIFIED, INSERT_ID)
|
1365
|
+
end
|
1366
|
+
|
1367
|
+
def test_log_entry_operation_field
|
1368
|
+
verify_field_key('operation', DEFAULT_OPERATION_KEY, 'custom_operation_key',
|
1369
|
+
CONFIG_CUSTOM_OPERATION_KEY_SPECIFIED, OPERATION_MESSAGE)
|
1370
|
+
end
|
1371
|
+
|
1372
|
+
def test_log_entry_source_location_field
|
1373
|
+
verify_field_key('sourceLocation', DEFAULT_SOURCE_LOCATION_KEY,
|
1374
|
+
'custom_source_location_key',
|
1375
|
+
CONFIG_CUSTOM_SOURCE_LOCATION_KEY_SPECIFIED,
|
1376
|
+
source_location_message)
|
1330
1377
|
end
|
1331
1378
|
|
1332
1379
|
def test_log_entry_span_id_field
|
@@ -1334,24 +1381,47 @@ module BaseTest
|
|
1334
1381
|
CONFIG_CUSTOM_SPAN_ID_KEY_SPECIFIED, SPAN_ID)
|
1335
1382
|
end
|
1336
1383
|
|
1337
|
-
def
|
1338
|
-
verify_field_key('
|
1339
|
-
|
1384
|
+
def test_log_entry_trace_field
|
1385
|
+
verify_field_key('trace', DEFAULT_TRACE_KEY, 'custom_trace_key',
|
1386
|
+
CONFIG_CUSTOM_TRACE_KEY_SPECIFIED, TRACE)
|
1340
1387
|
end
|
1341
1388
|
|
1342
|
-
|
1389
|
+
# Verify the cascading JSON detection of LogEntry fields.
|
1390
|
+
|
1391
|
+
def test_cascading_json_detection_with_log_entry_insert_id_field
|
1343
1392
|
verify_cascading_json_detection_with_log_entry_fields(
|
1344
|
-
'
|
1393
|
+
'insertId', DEFAULT_INSERT_ID_KEY,
|
1394
|
+
root_level_value: INSERT_ID,
|
1395
|
+
nested_level_value: INSERT_ID2)
|
1396
|
+
end
|
1397
|
+
|
1398
|
+
def test_cascading_json_detection_with_log_entry_operation_field
|
1399
|
+
verify_cascading_json_detection_with_log_entry_fields(
|
1400
|
+
'operation', DEFAULT_OPERATION_KEY,
|
1401
|
+
root_level_value: OPERATION_MESSAGE,
|
1402
|
+
nested_level_value: OPERATION_MESSAGE2,
|
1403
|
+
expected_value_from_nested: expected_operation_message2)
|
1404
|
+
end
|
1405
|
+
|
1406
|
+
def test_cascading_json_detection_with_log_entry_source_location_field
|
1407
|
+
verify_cascading_json_detection_with_log_entry_fields(
|
1408
|
+
'sourceLocation', DEFAULT_SOURCE_LOCATION_KEY,
|
1409
|
+
root_level_value: source_location_message,
|
1410
|
+
nested_level_value: source_location_message2)
|
1345
1411
|
end
|
1346
1412
|
|
1347
1413
|
def test_cascading_json_detection_with_log_entry_span_id_field
|
1348
1414
|
verify_cascading_json_detection_with_log_entry_fields(
|
1349
|
-
'spanId', DEFAULT_SPAN_ID_KEY,
|
1415
|
+
'spanId', DEFAULT_SPAN_ID_KEY,
|
1416
|
+
root_level_value: SPAN_ID,
|
1417
|
+
nested_level_value: SPAN_ID2)
|
1350
1418
|
end
|
1351
1419
|
|
1352
|
-
def
|
1420
|
+
def test_cascading_json_detection_with_log_entry_trace_field
|
1353
1421
|
verify_cascading_json_detection_with_log_entry_fields(
|
1354
|
-
'
|
1422
|
+
'trace', DEFAULT_TRACE_KEY,
|
1423
|
+
root_level_value: TRACE,
|
1424
|
+
nested_level_value: TRACE2)
|
1355
1425
|
end
|
1356
1426
|
|
1357
1427
|
# Metadata Agent related tests.
|
@@ -2177,7 +2247,14 @@ module BaseTest
|
|
2177
2247
|
# left with name "log", "message" or "msg". This test verifies additional
|
2178
2248
|
# LogEntry fields like spanId and traceId do not disable that by accident.
|
2179
2249
|
def verify_cascading_json_detection_with_log_entry_fields(
|
2180
|
-
log_entry_field, default_key,
|
2250
|
+
log_entry_field, default_key, expectation)
|
2251
|
+
root_level_value = expectation[:root_level_value]
|
2252
|
+
nested_level_value = expectation[:nested_level_value]
|
2253
|
+
expected_value_from_root = expectation.fetch(
|
2254
|
+
:expected_value_from_root, root_level_value)
|
2255
|
+
expected_value_from_nested = expectation.fetch(
|
2256
|
+
:expected_value_from_nested, nested_level_value)
|
2257
|
+
|
2181
2258
|
setup_gce_metadata_stubs
|
2182
2259
|
|
2183
2260
|
# {
|
@@ -2215,9 +2292,9 @@ module BaseTest
|
|
2215
2292
|
default_key => root_level_value)
|
2216
2293
|
|
2217
2294
|
{
|
2218
|
-
log_entry_with_root_level_field =>
|
2219
|
-
log_entry_with_nested_level_field =>
|
2220
|
-
log_entry_with_both_level_fields =>
|
2295
|
+
log_entry_with_root_level_field => expected_value_from_root,
|
2296
|
+
log_entry_with_nested_level_field => expected_value_from_nested,
|
2297
|
+
log_entry_with_both_level_fields => expected_value_from_nested
|
2221
2298
|
}.each_with_index do |(input_log_entry, expected_value), index|
|
2222
2299
|
setup_logging_stubs do
|
2223
2300
|
@logs_sent = []
|
@@ -2283,20 +2360,12 @@ module BaseTest
|
|
2283
2360
|
payload_fields = get_fields(entry['jsonPayload'])
|
2284
2361
|
assert_equal input[:expected_payload].size, payload_fields.size, input
|
2285
2362
|
payload_fields.each do |key, value|
|
2286
|
-
|
2363
|
+
assert_hash_equal_json(input[:expected_payload][key], value)
|
2287
2364
|
end
|
2288
2365
|
end
|
2289
2366
|
end
|
2290
2367
|
end
|
2291
2368
|
|
2292
|
-
def http_request_message
|
2293
|
-
HTTP_REQUEST_MESSAGE
|
2294
|
-
end
|
2295
|
-
|
2296
|
-
def source_location_message
|
2297
|
-
SOURCE_LOCATION_MESSAGE
|
2298
|
-
end
|
2299
|
-
|
2300
2369
|
# Replace the 'referer' field with nil.
|
2301
2370
|
def http_request_message_with_nil_referer
|
2302
2371
|
http_request_message.merge('referer' => nil)
|
@@ -2395,6 +2464,31 @@ module BaseTest
|
|
2395
2464
|
_undefined
|
2396
2465
|
end
|
2397
2466
|
|
2467
|
+
# Defined in specific gRPC or REST files.
|
2468
|
+
def http_request_message
|
2469
|
+
_undefined
|
2470
|
+
end
|
2471
|
+
|
2472
|
+
# Defined in specific gRPC or REST files.
|
2473
|
+
def source_location_message
|
2474
|
+
_undefined
|
2475
|
+
end
|
2476
|
+
|
2477
|
+
# Defined in specific gRPC or REST files.
|
2478
|
+
def source_location_message2
|
2479
|
+
_undefined
|
2480
|
+
end
|
2481
|
+
|
2482
|
+
# Defined in specific gRPC or REST files.
|
2483
|
+
def expected_operation_message2
|
2484
|
+
_undefined
|
2485
|
+
end
|
2486
|
+
|
2487
|
+
# Defined in specific gRPC or REST files.
|
2488
|
+
def assert_hash_equal_json(_expected, _actual)
|
2489
|
+
_undefined
|
2490
|
+
end
|
2491
|
+
|
2398
2492
|
def _undefined
|
2399
2493
|
raise "Method #{__callee__} is unimplemented and needs to be overridden."
|
2400
2494
|
end
|
data/test/plugin/constants.rb
CHANGED
@@ -371,16 +371,24 @@ module Constants
|
|
371
371
|
label_map { "name": "#{ML_CONSTANTS[:service]}/job_id/log_area" }
|
372
372
|
).freeze
|
373
373
|
|
374
|
-
|
375
|
-
|
374
|
+
CONFIG_CUSTOM_INSERT_ID_KEY_SPECIFIED = %(
|
375
|
+
insert_id_key custom_insert_id_key
|
376
|
+
).freeze
|
377
|
+
|
378
|
+
CONFIG_CUSTOM_OPERATION_KEY_SPECIFIED = %(
|
379
|
+
operation_key custom_operation_key
|
380
|
+
).freeze
|
381
|
+
|
382
|
+
CONFIG_CUSTOM_SOURCE_LOCATION_KEY_SPECIFIED = %(
|
383
|
+
source_location_key custom_source_location_key
|
376
384
|
).freeze
|
377
385
|
|
378
386
|
CONFIG_CUSTOM_SPAN_ID_KEY_SPECIFIED = %(
|
379
387
|
span_id_key custom_span_id_key
|
380
388
|
).freeze
|
381
389
|
|
382
|
-
|
383
|
-
|
390
|
+
CONFIG_CUSTOM_TRACE_KEY_SPECIFIED = %(
|
391
|
+
trace_key custom_trace_key
|
384
392
|
).freeze
|
385
393
|
|
386
394
|
# Service configurations for various services.
|
@@ -740,6 +748,7 @@ module Constants
|
|
740
748
|
'responseSize' => 65,
|
741
749
|
'userAgent' => 'USER AGENT 1.0',
|
742
750
|
'remoteIp' => '55.55.55.55',
|
751
|
+
'serverIp' => '66.66.66.66',
|
743
752
|
'referer' => 'http://referer/',
|
744
753
|
'cacheHit' => true,
|
745
754
|
'cacheValidatedWithOriginServer' => true
|
@@ -751,12 +760,24 @@ module Constants
|
|
751
760
|
'line' => 18
|
752
761
|
}.freeze
|
753
762
|
|
763
|
+
SOURCE_LOCATION_MESSAGE2 = {
|
764
|
+
'file' => 'src/file',
|
765
|
+
'function' => 'my_func',
|
766
|
+
'line' => 8
|
767
|
+
}.freeze
|
768
|
+
|
754
769
|
OPERATION_MESSAGE = {
|
755
770
|
'id' => 'op_id',
|
756
771
|
'producer' => 'my/app',
|
757
772
|
'last' => true
|
758
773
|
}.freeze
|
759
774
|
|
775
|
+
OPERATION_MESSAGE2 = {
|
776
|
+
'id' => 'op_id2',
|
777
|
+
'producer' => 'my/app2',
|
778
|
+
'last' => false
|
779
|
+
}.freeze
|
780
|
+
|
760
781
|
CUSTOM_LABELS_MESSAGE = {
|
761
782
|
'customKey' => 'value'
|
762
783
|
}.freeze
|
@@ -950,4 +971,15 @@ module Constants
|
|
950
971
|
'grpc-status-details-bin' => status_details.to_proto
|
951
972
|
}.freeze
|
952
973
|
end
|
974
|
+
|
975
|
+
PRESERVED_KEYS_MAP = {
|
976
|
+
'time' => K8S_TIMESTAMP,
|
977
|
+
'severity' => CONTAINER_SEVERITY,
|
978
|
+
DEFAULT_HTTP_REQUEST_KEY => HTTP_REQUEST_MESSAGE,
|
979
|
+
DEFAULT_INSERT_ID_KEY => INSERT_ID,
|
980
|
+
DEFAULT_OPERATION_KEY => OPERATION_MESSAGE,
|
981
|
+
DEFAULT_SOURCE_LOCATION_KEY => SOURCE_LOCATION_MESSAGE,
|
982
|
+
DEFAULT_SPAN_ID_KEY => SPAN_ID,
|
983
|
+
DEFAULT_TRACE_KEY => TRACE
|
984
|
+
}.freeze
|
953
985
|
end
|
@@ -407,24 +407,44 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
|
|
407
407
|
nil
|
408
408
|
end
|
409
409
|
|
410
|
-
#
|
411
|
-
#
|
412
|
-
#
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
410
|
+
# Convert certain fields to strings for compatibility between gRPC and REST.
|
411
|
+
# See more details in:
|
412
|
+
# https://github.com/google/google-api-ruby-client/issues/619.
|
413
|
+
def convert_subfields_to_strings(full_hash, fields_to_convert)
|
414
|
+
full_hash.merge(Hash[
|
415
|
+
fields_to_convert.collect do |field_name|
|
416
|
+
[field_name, full_hash[field_name].to_s]
|
417
|
+
end
|
418
|
+
])
|
419
|
+
end
|
420
|
+
|
421
|
+
# 'responseSize' and 'requestSize' are Integers in the gRPC protos, yet
|
422
|
+
# Strings in REST API client libraries.
|
417
423
|
def http_request_message
|
418
|
-
|
419
|
-
|
420
|
-
'requestSize' => HTTP_REQUEST_MESSAGE['requestSize'].to_s
|
421
|
-
)
|
424
|
+
convert_subfields_to_strings(
|
425
|
+
HTTP_REQUEST_MESSAGE, %w(responseSize requestSize))
|
422
426
|
end
|
423
427
|
|
424
428
|
# 'line' is an Integer in the gRPC proto, yet a String in the REST API client.
|
425
429
|
def source_location_message
|
426
|
-
|
427
|
-
|
428
|
-
|
430
|
+
convert_subfields_to_strings(
|
431
|
+
SOURCE_LOCATION_MESSAGE, ['line'])
|
432
|
+
end
|
433
|
+
|
434
|
+
# 'line' is an Integer in the gRPC proto, yet a String in the REST API client.
|
435
|
+
def source_location_message2
|
436
|
+
convert_subfields_to_strings(
|
437
|
+
SOURCE_LOCATION_MESSAGE2, ['line'])
|
438
|
+
end
|
439
|
+
|
440
|
+
def expected_operation_message2
|
441
|
+
OPERATION_MESSAGE2
|
442
|
+
end
|
443
|
+
|
444
|
+
# Both expected and actual are Ruby hashes that represent JSON
|
445
|
+
# objects.
|
446
|
+
# This method has a different implementation at the gRPC side.
|
447
|
+
def assert_hash_equal_json(expected, actual)
|
448
|
+
assert_equal expected, actual, "expected: #{expected}\nactual: #{actual}"
|
429
449
|
end
|
430
450
|
end
|
@@ -466,8 +466,79 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
|
|
466
466
|
field['numberValue']
|
467
467
|
end
|
468
468
|
|
469
|
+
def get_bool(field)
|
470
|
+
field['boolValue']
|
471
|
+
end
|
472
|
+
|
469
473
|
# The null value.
|
470
474
|
def null_value
|
471
475
|
{ 'nullValue' => 'NULL_VALUE' }
|
472
476
|
end
|
477
|
+
|
478
|
+
def http_request_message
|
479
|
+
HTTP_REQUEST_MESSAGE
|
480
|
+
end
|
481
|
+
|
482
|
+
def source_location_message
|
483
|
+
SOURCE_LOCATION_MESSAGE
|
484
|
+
end
|
485
|
+
|
486
|
+
def source_location_message2
|
487
|
+
SOURCE_LOCATION_MESSAGE2
|
488
|
+
end
|
489
|
+
|
490
|
+
def expected_operation_message2
|
491
|
+
# 'last' is a boolean field with false as default value. Protobuf omit
|
492
|
+
# fields with default values during deserialization.
|
493
|
+
OPERATION_MESSAGE2.reject { |k, _| k == 'last' }
|
494
|
+
end
|
495
|
+
|
496
|
+
# expected: A Ruby hash that represents a JSON object.
|
497
|
+
# e.g.:
|
498
|
+
# {
|
499
|
+
# "file" => "source/file",
|
500
|
+
# "function" => "my_function",
|
501
|
+
# "line" => 18
|
502
|
+
# }
|
503
|
+
#
|
504
|
+
# actual: A Ruby hash that represents a Proto object.
|
505
|
+
# e.g.:
|
506
|
+
# {
|
507
|
+
# "structValue" => {
|
508
|
+
# "fields" => {
|
509
|
+
# "file" => {
|
510
|
+
# "stringValue" => "source/file"
|
511
|
+
# },
|
512
|
+
# "function" => {
|
513
|
+
# "stringValue" => "my_function"
|
514
|
+
# },
|
515
|
+
# "line" => {
|
516
|
+
# "numberValue" => 18
|
517
|
+
# }
|
518
|
+
# }
|
519
|
+
# }
|
520
|
+
# }
|
521
|
+
# This method has a different implementation at the REST side.
|
522
|
+
def assert_hash_equal_json(expected, actual)
|
523
|
+
error_message = "expected: #{expected}\nactual: #{actual}"
|
524
|
+
assert_true actual.is_a?(Hash),
|
525
|
+
"Expect the actual value to be a hash. #{error_message}"
|
526
|
+
if actual.key?('stringValue')
|
527
|
+
assert_equal expected, get_string(actual), error_message
|
528
|
+
elsif actual.key?('numberValue')
|
529
|
+
assert_equal expected, get_number(actual), error_message
|
530
|
+
elsif actual.key?('boolValue')
|
531
|
+
assert_equal expected, get_bool(actual), error_message
|
532
|
+
elsif actual.key?('structValue')
|
533
|
+
expected_copy = expected.dup
|
534
|
+
get_fields(get_struct(actual)).each do |field_name, nested_actual|
|
535
|
+
assert_hash_equal_json expected_copy[field_name], nested_actual
|
536
|
+
expected_copy.reject! { |k, _| k == field_name }
|
537
|
+
end
|
538
|
+
# Make sure all fields are matched.
|
539
|
+
assert_true expected_copy.empty?
|
540
|
+
else
|
541
|
+
assert_true false, "Unsupported proto format. #{error_message}"
|
542
|
+
end
|
543
|
+
end
|
473
544
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-google-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stackdriver Agents Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|