logstash-output-scalyr 0.2.7.beta → 0.2.9.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/Gemfile +5 -2
- data/README.md +2 -4
- data/lib/logstash/outputs/scalyr.rb +192 -48
- data/lib/scalyr/common/client.rb +40 -4
- data/lib/scalyr/common/util.rb +5 -5
- data/lib/scalyr/constants.rb +1 -1
- data/logstash-output-scalyr.gemspec +2 -2
- metadata +3 -23
- data/spec/benchmarks/bignum_fixing.rb +0 -87
- data/spec/benchmarks/flattening_and_serialization.rb +0 -100
- data/spec/benchmarks/json_serialization.rb +0 -85
- data/spec/benchmarks/metrics_overhead.rb +0 -48
- data/spec/benchmarks/set_session_level_serverhost_on_events.rb +0 -107
- data/spec/benchmarks/util.rb +0 -24
- data/spec/logstash/outputs/fixtures/example_com.pem +0 -41
- data/spec/logstash/outputs/scalyr_integration_spec.rb +0 -318
- data/spec/logstash/outputs/scalyr_spec.rb +0 -1262
- data/spec/scalyr/common/util_spec.rb +0 -543
@@ -1,543 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "scalyr/common/util"
|
3
|
-
|
4
|
-
# Require the specific version of `json` used in logstash
|
5
|
-
gem 'json', '1.8.6'
|
6
|
-
require 'json'
|
7
|
-
|
8
|
-
LARGE_OBJECT_IN = {
|
9
|
-
"level": "info",
|
10
|
-
"ts": "2020-08-11T02:26:17.078Z",
|
11
|
-
"caller": "api/foo:480",
|
12
|
-
"msg": "assign active task foobar",
|
13
|
-
"accountId": 12345,
|
14
|
-
"cycleId": 6789,
|
15
|
-
"uuid": "a405a4b58810e3aaa078f751bd32baa8b60aaad1",
|
16
|
-
"task": {
|
17
|
-
"Id": 1211111181111111400,
|
18
|
-
"TaskTypes": [
|
19
|
-
4,
|
20
|
-
11,
|
21
|
-
10,
|
22
|
-
12,
|
23
|
-
17,
|
24
|
-
14
|
25
|
-
],
|
26
|
-
"Ips": [
|
27
|
-
"127.0.0.1",
|
28
|
-
"127.0.0.2",
|
29
|
-
"127.0.0.3",
|
30
|
-
"127.0.0.4",
|
31
|
-
"127.0.0.5",
|
32
|
-
],
|
33
|
-
"FooProps": {
|
34
|
-
"10": {
|
35
|
-
"TcpPorts": [
|
36
|
-
22,
|
37
|
-
23,
|
38
|
-
25,
|
39
|
-
80,
|
40
|
-
55,
|
41
|
-
8000,
|
42
|
-
8080,
|
43
|
-
],
|
44
|
-
"UdpPorts": []
|
45
|
-
}
|
46
|
-
},
|
47
|
-
"Subnet": "127.0.0.0/24"
|
48
|
-
},
|
49
|
-
"relevance": 0,
|
50
|
-
"scannerIp": "10.0.0.2",
|
51
|
-
"gatewayIp": "10.0.0.1",
|
52
|
-
"gatewayMac": "fa:fa:fa:fa",
|
53
|
-
"wired": true,
|
54
|
-
"elapsed": 74.86664
|
55
|
-
}
|
56
|
-
|
57
|
-
LARGE_OBJECT_OUT = {
|
58
|
-
"accountId" => 12345,
|
59
|
-
"caller" => "api/foo:480",
|
60
|
-
"cycleId" => 6789,
|
61
|
-
"elapsed" => 74.86664,
|
62
|
-
"gatewayIp" => "10.0.0.1",
|
63
|
-
"gatewayMac" => "fa:fa:fa:fa",
|
64
|
-
"level" => "info",
|
65
|
-
"msg" => "assign active task foobar",
|
66
|
-
"relevance" => 0,
|
67
|
-
"scannerIp" => "10.0.0.2",
|
68
|
-
"task_FooProps_10_TcpPorts_0" => 22,
|
69
|
-
"task_FooProps_10_TcpPorts_1" => 23,
|
70
|
-
"task_FooProps_10_TcpPorts_2" => 25,
|
71
|
-
"task_FooProps_10_TcpPorts_3" => 80,
|
72
|
-
"task_FooProps_10_TcpPorts_4" => 55,
|
73
|
-
"task_FooProps_10_TcpPorts_5" => 8000,
|
74
|
-
"task_FooProps_10_TcpPorts_6" => 8080,
|
75
|
-
"task_FooProps_10_UdpPorts" => [],
|
76
|
-
"task_Id" => 1211111181111111400,
|
77
|
-
"task_Ips_0" => "127.0.0.1",
|
78
|
-
"task_Ips_1" => "127.0.0.2",
|
79
|
-
"task_Ips_2" => "127.0.0.3",
|
80
|
-
"task_Ips_3" => "127.0.0.4",
|
81
|
-
"task_Ips_4" => "127.0.0.5",
|
82
|
-
"task_Subnet" => "127.0.0.0/24",
|
83
|
-
"task_TaskTypes_0" => 4,
|
84
|
-
"task_TaskTypes_1" => 11,
|
85
|
-
"task_TaskTypes_2" => 10,
|
86
|
-
"task_TaskTypes_3" => 12,
|
87
|
-
"task_TaskTypes_4" => 17,
|
88
|
-
"task_TaskTypes_5" => 14,
|
89
|
-
"ts" => "2020-08-11T02:26:17.078Z",
|
90
|
-
"uuid" => "a405a4b58810e3aaa078f751bd32baa8b60aaad1",
|
91
|
-
"wired" => true,
|
92
|
-
}
|
93
|
-
|
94
|
-
LARGE_OBJECT_OUT_NO_FLATTEN_ARRAYS = {
|
95
|
-
"accountId" => 12345,
|
96
|
-
"caller" => "api/foo:480",
|
97
|
-
"cycleId" => 6789,
|
98
|
-
"elapsed" => 74.86664,
|
99
|
-
"gatewayIp" => "10.0.0.1",
|
100
|
-
"gatewayMac" => "fa:fa:fa:fa",
|
101
|
-
"level" => "info",
|
102
|
-
"msg" => "assign active task foobar",
|
103
|
-
"relevance" => 0,
|
104
|
-
"scannerIp" => "10.0.0.2",
|
105
|
-
"task_FooProps_10_TcpPorts" => [22, 23, 25, 80, 55, 8000, 8080],
|
106
|
-
"task_FooProps_10_UdpPorts" => [],
|
107
|
-
"task_Id" => 1211111181111111400,
|
108
|
-
"task_Ips" => ["127.0.0.1", "127.0.0.2", "127.0.0.3", "127.0.0.4", "127.0.0.5"],
|
109
|
-
"task_Subnet" => "127.0.0.0/24",
|
110
|
-
"task_TaskTypes" => [4, 11, 10, 12, 17, 14],
|
111
|
-
"ts" => "2020-08-11T02:26:17.078Z",
|
112
|
-
"uuid" => "a405a4b58810e3aaa078f751bd32baa8b60aaad1",
|
113
|
-
"wired" => true,
|
114
|
-
}
|
115
|
-
describe Scalyr::Common::Util do
|
116
|
-
it "does not flatten an already-flat dict" do
|
117
|
-
din = {
|
118
|
-
'a' => 1,
|
119
|
-
'b' => 'two',
|
120
|
-
}
|
121
|
-
dout = {
|
122
|
-
'a' => 1,
|
123
|
-
'b' => 'two'
|
124
|
-
}
|
125
|
-
expect(Scalyr::Common::Util.flatten(din)).to eq(dout)
|
126
|
-
end
|
127
|
-
|
128
|
-
it "flattens a single-level sub-dict" do
|
129
|
-
din = {
|
130
|
-
'a' => 1,
|
131
|
-
'b' => {
|
132
|
-
'c' => 100,
|
133
|
-
'd' => 200,
|
134
|
-
}
|
135
|
-
}
|
136
|
-
dout = {
|
137
|
-
'a' => 1,
|
138
|
-
'b_c' => 100,
|
139
|
-
'b_d' => 200,
|
140
|
-
}
|
141
|
-
expect(Scalyr::Common::Util.flatten(din)).to eq(dout)
|
142
|
-
end
|
143
|
-
|
144
|
-
it "flattens a two-level sub-dict" do
|
145
|
-
din = {
|
146
|
-
'a' => 1,
|
147
|
-
'b' => {
|
148
|
-
'c' => {
|
149
|
-
'e' => 1000,
|
150
|
-
'f' => 2000,
|
151
|
-
},
|
152
|
-
'd' => 200,
|
153
|
-
}
|
154
|
-
}
|
155
|
-
dout = {
|
156
|
-
'a' => 1,
|
157
|
-
'b_c_e' => 1000,
|
158
|
-
'b_c_f' => 2000,
|
159
|
-
'b_d' => 200,
|
160
|
-
}
|
161
|
-
expect(Scalyr::Common::Util.flatten(din)).to eq(dout)
|
162
|
-
end
|
163
|
-
|
164
|
-
it "flattens a single-level array" do
|
165
|
-
din = [1, 2, 3]
|
166
|
-
dout = {
|
167
|
-
'0' => 1,
|
168
|
-
'1' => 2,
|
169
|
-
'2' => 3,
|
170
|
-
}
|
171
|
-
expect(Scalyr::Common::Util.flatten(din)).to eq(dout)
|
172
|
-
end
|
173
|
-
|
174
|
-
it "flattens a multi-level array" do
|
175
|
-
din = ['a', 'b', ['c', ['d', 'e', 'f'], 'g'], 'h', 'i']
|
176
|
-
dout = {
|
177
|
-
'0' => 'a',
|
178
|
-
'1' => 'b',
|
179
|
-
'2_0' => 'c',
|
180
|
-
'2_1_0' => 'd',
|
181
|
-
'2_1_1' => 'e',
|
182
|
-
'2_1_2' => 'f',
|
183
|
-
'2_2' => 'g',
|
184
|
-
'3' => 'h',
|
185
|
-
'4' => 'i',
|
186
|
-
}
|
187
|
-
expect(Scalyr::Common::Util.flatten(din)).to eq(dout)
|
188
|
-
end
|
189
|
-
|
190
|
-
it "flattens a hash that contains an array" do
|
191
|
-
din = {
|
192
|
-
'a' => 1,
|
193
|
-
'c' => [100, 200, 300]
|
194
|
-
}
|
195
|
-
dout = {
|
196
|
-
'a' => 1,
|
197
|
-
'c_0' => 100,
|
198
|
-
'c_1' => 200,
|
199
|
-
'c_2' => 300,
|
200
|
-
}
|
201
|
-
expect(Scalyr::Common::Util.flatten(din)).to eq(dout)
|
202
|
-
end
|
203
|
-
|
204
|
-
it "flattens a hash that contains an array that contains a hash" do
|
205
|
-
din = {
|
206
|
-
'a' => 1,
|
207
|
-
'c' => [
|
208
|
-
100,
|
209
|
-
{'d' => 1000, 'e' => 2000},
|
210
|
-
300
|
211
|
-
]
|
212
|
-
}
|
213
|
-
dout = {
|
214
|
-
'a' => 1,
|
215
|
-
'c_0' => 100,
|
216
|
-
'c_1_d' => 1000,
|
217
|
-
'c_1_e' => 2000,
|
218
|
-
'c_2' => 300,
|
219
|
-
}
|
220
|
-
expect(Scalyr::Common::Util.flatten(din)).to eq(dout)
|
221
|
-
end
|
222
|
-
|
223
|
-
it "flattens a hash that contains an array that contains a hash that contains an array" do
|
224
|
-
din = {
|
225
|
-
'a' => 1,
|
226
|
-
'c' => [
|
227
|
-
100,
|
228
|
-
{'d' => 1000, 'e' => 2000, 'f' => [4, 5, 6]},
|
229
|
-
300
|
230
|
-
]
|
231
|
-
}
|
232
|
-
dout = {
|
233
|
-
'a' => 1,
|
234
|
-
'c_0' => 100,
|
235
|
-
'c_1_d' => 1000,
|
236
|
-
'c_1_e' => 2000,
|
237
|
-
'c_1_f_0' => 4,
|
238
|
-
'c_1_f_1' => 5,
|
239
|
-
'c_1_f_2' => 6,
|
240
|
-
'c_2' => 300,
|
241
|
-
}
|
242
|
-
expect(Scalyr::Common::Util.flatten(din)).to eq(dout)
|
243
|
-
end
|
244
|
-
|
245
|
-
it "flattens a single-level array, no array flattening" do
|
246
|
-
din = [1, 2, 3]
|
247
|
-
dout = [1, 2, 3]
|
248
|
-
expect(Scalyr::Common::Util.flatten(din, "_", flatten_arrays=false)).to eq(dout)
|
249
|
-
end
|
250
|
-
|
251
|
-
it "flattens a multi-level array, no array flattening" do
|
252
|
-
din = ['a', 'b', ['c', ['d', 'e', 'f'], 'g'], 'h', 'i']
|
253
|
-
dout = ['a', 'b', ['c', ['d', 'e', 'f'], 'g'], 'h', 'i']
|
254
|
-
expect(Scalyr::Common::Util.flatten(din, "_", flatten_arrays=false)).to eq(dout)
|
255
|
-
end
|
256
|
-
|
257
|
-
it "flattens a hash that contains an array with hashes, no array flattening" do
|
258
|
-
din = {
|
259
|
-
'a' => 1,
|
260
|
-
"b" => {"a": "a"},
|
261
|
-
'c' => { "f" => [100, 200, {"g" => 1}] }
|
262
|
-
}
|
263
|
-
dout = {
|
264
|
-
'a' => 1,
|
265
|
-
"b_a" => "a",
|
266
|
-
'c_f' => [100, 200, {"g" => 1}]
|
267
|
-
}
|
268
|
-
expect(Scalyr::Common::Util.flatten(din, "_", flatten_arrays=false)).to eq(dout)
|
269
|
-
end
|
270
|
-
|
271
|
-
it "flattens a hash that contains an array, no array flattening" do
|
272
|
-
din = {
|
273
|
-
'a' => 1,
|
274
|
-
'c' => [100, 200, 300]
|
275
|
-
}
|
276
|
-
dout = {
|
277
|
-
'a' => 1,
|
278
|
-
'c' => [100, 200, 300]
|
279
|
-
}
|
280
|
-
expect(Scalyr::Common::Util.flatten(din, "_", flatten_arrays=false)).to eq(dout)
|
281
|
-
end
|
282
|
-
|
283
|
-
it "flattens a hash that contains an array that contains a hash, no array flattening" do
|
284
|
-
din = {
|
285
|
-
'a' => 1,
|
286
|
-
'c' => [
|
287
|
-
100,
|
288
|
-
{'d' => 1000, 'e' => 2000},
|
289
|
-
300
|
290
|
-
]
|
291
|
-
}
|
292
|
-
dout = {
|
293
|
-
'a' => 1,
|
294
|
-
'c' => [
|
295
|
-
100,
|
296
|
-
{'d' => 1000, 'e' => 2000},
|
297
|
-
300
|
298
|
-
]
|
299
|
-
}
|
300
|
-
expect(Scalyr::Common::Util.flatten(din, "_", flatten_arrays=false)).to eq(dout)
|
301
|
-
end
|
302
|
-
|
303
|
-
it "flattens a hash that contains an array that contains a hash that contains an array, no array flattening" do
|
304
|
-
din = {
|
305
|
-
'a' => 1,
|
306
|
-
'c' => [
|
307
|
-
100,
|
308
|
-
{'d' => 1000, 'e' => 2000, 'f' => [4, 5, 6]},
|
309
|
-
300
|
310
|
-
]
|
311
|
-
}
|
312
|
-
dout = {
|
313
|
-
'a' => 1,
|
314
|
-
'c' => [
|
315
|
-
100,
|
316
|
-
{'d' => 1000, 'e' => 2000, 'f' => [4, 5, 6]},
|
317
|
-
300
|
318
|
-
]
|
319
|
-
}
|
320
|
-
expect(Scalyr::Common::Util.flatten(din, "_", flatten_arrays=false)).to eq(dout)
|
321
|
-
end
|
322
|
-
|
323
|
-
it "flattens large hash correctly" do
|
324
|
-
expect(Scalyr::Common::Util.flatten(LARGE_OBJECT_IN, "_", flatten_arrays=true)).to eq(LARGE_OBJECT_OUT)
|
325
|
-
end
|
326
|
-
|
327
|
-
it "flattens large hash correctly not flatten arrays" do
|
328
|
-
expect(Scalyr::Common::Util.flatten(LARGE_OBJECT_IN, "_", flatten_arrays=false)).to eq(LARGE_OBJECT_OUT_NO_FLATTEN_ARRAYS)
|
329
|
-
end
|
330
|
-
|
331
|
-
it "flattens hash containing empty list correctly" do
|
332
|
-
obj_in = {
|
333
|
-
"abc" => 123,
|
334
|
-
"array" => [],
|
335
|
-
"hash" => {
|
336
|
-
"value" => "abc123",
|
337
|
-
"another_array" => []
|
338
|
-
}
|
339
|
-
}
|
340
|
-
|
341
|
-
obj_out = {
|
342
|
-
"abc" => 123,
|
343
|
-
"array" => [],
|
344
|
-
"hash_value" => "abc123",
|
345
|
-
"hash_another_array" => []
|
346
|
-
}
|
347
|
-
expect(Scalyr::Common::Util.flatten(obj_in, "_", flatten_arrays=true)).to eq(obj_out)
|
348
|
-
end
|
349
|
-
|
350
|
-
it "flattens hash containing empty list correctly not flatten arrays" do
|
351
|
-
obj_in = {
|
352
|
-
"abc" => 123,
|
353
|
-
"array" => [],
|
354
|
-
"hash" => {
|
355
|
-
"value" => "abc123",
|
356
|
-
"another_array" => []
|
357
|
-
}
|
358
|
-
}
|
359
|
-
|
360
|
-
obj_out = {
|
361
|
-
"abc" => 123,
|
362
|
-
"array" => [],
|
363
|
-
"hash_value" => "abc123",
|
364
|
-
"hash_another_array" => []
|
365
|
-
}
|
366
|
-
expect(Scalyr::Common::Util.flatten(obj_in, "_", flatten_arrays=false)).to eq(obj_out)
|
367
|
-
end
|
368
|
-
|
369
|
-
it "flattens hash containing empty hash correctly" do
|
370
|
-
obj_in = {
|
371
|
-
"abc" => 123,
|
372
|
-
"empty_hash" => {},
|
373
|
-
"hash" => {
|
374
|
-
"value" => "abc123",
|
375
|
-
"another_hash" => {}
|
376
|
-
}
|
377
|
-
}
|
378
|
-
|
379
|
-
obj_out = {
|
380
|
-
"abc" => 123,
|
381
|
-
"empty_hash" => {},
|
382
|
-
"hash_value" => "abc123",
|
383
|
-
"hash_another_hash" => {}
|
384
|
-
}
|
385
|
-
expect(Scalyr::Common::Util.flatten(obj_in, "_", flatten_arrays=true)).to eq(obj_out)
|
386
|
-
end
|
387
|
-
|
388
|
-
it "flattens hash containing nested bignum correctly" do
|
389
|
-
obj_in = {
|
390
|
-
"abc" => 123,
|
391
|
-
"hash" => {
|
392
|
-
"value" => 2000023030042002050202030320240
|
393
|
-
}
|
394
|
-
}
|
395
|
-
|
396
|
-
obj_out = {
|
397
|
-
"abc" => 123,
|
398
|
-
"hash_value" => 2000023030042002050202030320240
|
399
|
-
}
|
400
|
-
expect(Scalyr::Common::Util.flatten(obj_in, "_", flatten_arrays=true)).to eq(obj_out)
|
401
|
-
end
|
402
|
-
|
403
|
-
it "flattens hash containing nested boolean correctly" do
|
404
|
-
obj_in = {
|
405
|
-
"abc" => 123,
|
406
|
-
"hash" => {
|
407
|
-
"value" => true,
|
408
|
-
"otherValue" => false
|
409
|
-
}
|
410
|
-
}
|
411
|
-
|
412
|
-
obj_out = {
|
413
|
-
"abc" => 123,
|
414
|
-
"hash_value" => true,
|
415
|
-
"hash_otherValue" => false
|
416
|
-
}
|
417
|
-
expect(Scalyr::Common::Util.flatten(obj_in, "_", flatten_arrays=true)).to eq(obj_out)
|
418
|
-
end
|
419
|
-
|
420
|
-
it "flattens hash containing nested float correctly" do
|
421
|
-
obj_in = {
|
422
|
-
"abc" => 123,
|
423
|
-
"hash" => {
|
424
|
-
"value" => 321.12345,
|
425
|
-
"otherValue" => 0.0000003
|
426
|
-
}
|
427
|
-
}
|
428
|
-
|
429
|
-
obj_out = {
|
430
|
-
"abc" => 123,
|
431
|
-
"hash_value" => 321.12345,
|
432
|
-
"hash_otherValue" => 0.0000003
|
433
|
-
}
|
434
|
-
expect(Scalyr::Common::Util.flatten(obj_in, "_", flatten_arrays=true)).to eq(obj_out)
|
435
|
-
end
|
436
|
-
|
437
|
-
it "accepts custom delimiters" do
|
438
|
-
din = {
|
439
|
-
'a' => 1,
|
440
|
-
'b' => {
|
441
|
-
'c' => 100,
|
442
|
-
'd' => 200,
|
443
|
-
}
|
444
|
-
}
|
445
|
-
dout = {
|
446
|
-
'a' => 1,
|
447
|
-
'b:c' => 100,
|
448
|
-
'b:d' => 200,
|
449
|
-
}
|
450
|
-
expect(Scalyr::Common::Util.flatten(din, ':')).to eq(dout)
|
451
|
-
end
|
452
|
-
|
453
|
-
it "accepts custom delimiters with greater depth" do
|
454
|
-
din = {
|
455
|
-
'a' => 1,
|
456
|
-
'b' => {
|
457
|
-
'c' => {
|
458
|
-
'e' => 100
|
459
|
-
},
|
460
|
-
'd' => 200,
|
461
|
-
}
|
462
|
-
}
|
463
|
-
dout = {
|
464
|
-
'a' => 1,
|
465
|
-
'b:c_e' => 100,
|
466
|
-
'b:d' => 200,
|
467
|
-
}
|
468
|
-
expect(Scalyr::Common::Util.flatten(din, ':')).to eq(dout)
|
469
|
-
end
|
470
|
-
|
471
|
-
it "accepts custom delimiters with greater depth and deep delimiters fix" do
|
472
|
-
din = {
|
473
|
-
'a' => 1,
|
474
|
-
'b' => {
|
475
|
-
'c' => {
|
476
|
-
'e' => 100
|
477
|
-
},
|
478
|
-
'd' => 200,
|
479
|
-
}
|
480
|
-
}
|
481
|
-
dout = {
|
482
|
-
'a' => 1,
|
483
|
-
'b:c:e' => 100,
|
484
|
-
'b:d' => 200,
|
485
|
-
}
|
486
|
-
expect(Scalyr::Common::Util.flatten(din, ':', true, true)).to eq(dout)
|
487
|
-
end
|
488
|
-
|
489
|
-
it "stringifies non-string keys" do
|
490
|
-
din = {
|
491
|
-
'a' => 1,
|
492
|
-
1 => {
|
493
|
-
'c' => 100,
|
494
|
-
'd' => 200,
|
495
|
-
}
|
496
|
-
}
|
497
|
-
dout = {
|
498
|
-
'a' => 1,
|
499
|
-
'1:c' => 100,
|
500
|
-
'1:d' => 200,
|
501
|
-
}
|
502
|
-
expect(Scalyr::Common::Util.flatten(din, ':')).to eq(dout)
|
503
|
-
end
|
504
|
-
|
505
|
-
it "handles nil values" do
|
506
|
-
din = {
|
507
|
-
'a' => nil,
|
508
|
-
1 => {
|
509
|
-
'c' => 100,
|
510
|
-
'd' => nil,
|
511
|
-
}
|
512
|
-
}
|
513
|
-
dout = {
|
514
|
-
'a' => nil,
|
515
|
-
'1:c' => 100,
|
516
|
-
'1:d' => nil,
|
517
|
-
}
|
518
|
-
expect(Scalyr::Common::Util.flatten(din, ':')).to eq(dout)
|
519
|
-
end
|
520
|
-
|
521
|
-
it "raises exception if a non-dict is provided" do
|
522
|
-
expect {Scalyr::Common::Util.flatten(1)}.to raise_error(TypeError)
|
523
|
-
end
|
524
|
-
|
525
|
-
it "flattens a hash 5000 layers deep" do
|
526
|
-
din = {
|
527
|
-
'a' => {},
|
528
|
-
}
|
529
|
-
hash = din
|
530
|
-
for i in 0...4999
|
531
|
-
hash = hash["a"]
|
532
|
-
hash["a"] = {}
|
533
|
-
if i == 4998
|
534
|
-
hash["a"] = "b"
|
535
|
-
end
|
536
|
-
end
|
537
|
-
|
538
|
-
dout = {
|
539
|
-
'a' + "_a" * 4999 => "b",
|
540
|
-
}
|
541
|
-
expect(Scalyr::Common::Util.flatten(din, '_')).to eq(dout)
|
542
|
-
end
|
543
|
-
end
|