groonga-query-log 1.7.5 → 1.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/text/news.md +16 -0
- data/groonga-query-log.gemspec +1 -0
- data/lib/groonga-query-log/command/analyze-load.rb +8 -1
- data/lib/groonga-query-log/command/run-regression-test.rb +24 -1
- data/lib/groonga-query-log/command/verify-server.rb +16 -0
- data/lib/groonga-query-log/replayer.rb +10 -0
- data/lib/groonga-query-log/server-verifier.rb +40 -1
- data/lib/groonga-query-log/statistic.rb +1 -0
- data/lib/groonga-query-log/version.rb +2 -2
- data/test/command/test-analyzer.rb +2 -1
- data/test/command/test-extract.rb +2 -1
- data/test/fixtures/reporter/json-stream.expected +1 -1
- data/test/fixtures/reporter/json.expected +1 -1
- data/test/helper.rb +5 -1
- data/test/test-replayer.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af3ac522ec27ea395b44209b8ab56521de14b828d67bf4b8d4dad52bb0df2d1c
|
4
|
+
data.tar.gz: c570a4a49aad267b71047d992e0593afac1290135711a7f45b8114ded4232dbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f0dc1247dc380bd50f8b249fcc7976a800bb67de75f10e4cd600741508f4236d89aa750277043336dc4abd561641804cf53056373338ef9ae2dd2b0f9cc5c0e
|
7
|
+
data.tar.gz: ddcce99bb10e8b8876fbbce95d9c0c49f5d1b8ca7e6ce8beb4a9178624ab169475ce49173c33f1e1a5796909ae20c1fa1976126033c944757859f18e9a05689f
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 1.7.7: 2024-04-08
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* `run-regression-test`: Added a test to verify that the `request_cancel` command can be successfully cancelled.
|
8
|
+
|
9
|
+
* `analyze-load`: Added support for reporting throughput.
|
10
|
+
|
11
|
+
## 1.7.6: 2021-02-24
|
12
|
+
|
13
|
+
### Improvements
|
14
|
+
|
15
|
+
* `replayer`: Ignored `load` without `values`.
|
16
|
+
|
17
|
+
* `statistics`: Added `n_records` to each operation.
|
18
|
+
|
3
19
|
## 1.7.5: 2020-11-18
|
4
20
|
|
5
21
|
### Improvements
|
data/groonga-query-log.gemspec
CHANGED
@@ -54,6 +54,7 @@ Gem::Specification.new do |spec|
|
|
54
54
|
|
55
55
|
spec.add_runtime_dependency("charty")
|
56
56
|
spec.add_runtime_dependency("diff-lcs")
|
57
|
+
spec.add_runtime_dependency("net-smtp")
|
57
58
|
spec.add_runtime_dependency("groonga-client", ">= 0.6.2")
|
58
59
|
spec.add_runtime_dependency("groonga-log", ">= 0.1.2")
|
59
60
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2017-
|
1
|
+
# Copyright (C) 2017-2024 Sutou Kouhei <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -147,9 +147,15 @@ module GroongaQueryLog
|
|
147
147
|
n_column_errors = nil
|
148
148
|
total = nil
|
149
149
|
end
|
150
|
+
if n_loaded_records and n_loaded_records > 0
|
151
|
+
throughput = statistic.elapsed_in_seconds / n_loaded_records
|
152
|
+
else
|
153
|
+
throughput = nil
|
154
|
+
end
|
150
155
|
entry = [
|
151
156
|
statistic.start_time.iso8601,
|
152
157
|
statistic.elapsed_in_seconds,
|
158
|
+
throughput,
|
153
159
|
load_command.table,
|
154
160
|
n_loaded_records,
|
155
161
|
n_record_errors,
|
@@ -171,6 +177,7 @@ module GroongaQueryLog
|
|
171
177
|
header = [
|
172
178
|
"start_time",
|
173
179
|
"elapsed",
|
180
|
+
"throughput",
|
174
181
|
"table",
|
175
182
|
"n_loaded_records",
|
176
183
|
"n_record_errors",
|
@@ -67,6 +67,8 @@ module GroongaQueryLog
|
|
67
67
|
@debug_rewrite = false
|
68
68
|
@omit_rate = 0.0
|
69
69
|
@max_limit = -1
|
70
|
+
@verify_cancel = false
|
71
|
+
@cancel_max_wait = 5.0
|
70
72
|
|
71
73
|
@care_order = true
|
72
74
|
@ignored_drilldown_keys = []
|
@@ -426,6 +428,20 @@ module GroongaQueryLog
|
|
426
428
|
"(#{@notifier_options[:mail_only_on_failure]})") do |boolean|
|
427
429
|
@notifier_options[:mail_only_on_failure] = boolean
|
428
430
|
end
|
431
|
+
parser.on("--[no-]verify-cancel",
|
432
|
+
"Verify cancellation",
|
433
|
+
"(#{@verify_cancel})") do |boolean|
|
434
|
+
@verify_cancel = boolean
|
435
|
+
end
|
436
|
+
parser.on("--cancel-max-wait=SECONDS", Float,
|
437
|
+
"Used with --verify_cancel. " +
|
438
|
+
"You can specify the maximum number of seconds to wait " +
|
439
|
+
"before sending request_cancel command. " +
|
440
|
+
"For example, if you specify 5.0 in this option, " +
|
441
|
+
"wait randomly between 0~5.0 seconds before sending request_cancel command.",
|
442
|
+
"(#{@cancel_max_wait})") do |seconds|
|
443
|
+
@cancel_max_wait = seconds
|
444
|
+
end
|
429
445
|
parser
|
430
446
|
end
|
431
447
|
|
@@ -478,6 +494,8 @@ module GroongaQueryLog
|
|
478
494
|
:verify_performance => @verify_performance,
|
479
495
|
:performance_verfifier_options => @performance_verfifier_options,
|
480
496
|
:read_timeout => @read_timeout,
|
497
|
+
:verify_cancel => @verify_cancel,
|
498
|
+
:cancel_max_wait => @cancel_max_wait,
|
481
499
|
}
|
482
500
|
directory_options.merge(options)
|
483
501
|
end
|
@@ -517,7 +535,7 @@ module GroongaQueryLog
|
|
517
535
|
end
|
518
536
|
formatted << "\n"
|
519
537
|
unless n_leaked_objects.zero?
|
520
|
-
formatted << "\nLeaked: #{n_leaked_objects}"
|
538
|
+
formatted << "\nLeaked: #{n_leaked_objects}\n"
|
521
539
|
end
|
522
540
|
unless success
|
523
541
|
output = StringIO.new
|
@@ -945,6 +963,11 @@ module GroongaQueryLog
|
|
945
963
|
command_line << "--read-timeout"
|
946
964
|
command_line << @options[:read_timeout].to_s
|
947
965
|
end
|
966
|
+
if @options[:verify_cancel]
|
967
|
+
command_line << "--verify_cancel"
|
968
|
+
command_line << "--cancel-max-wait"
|
969
|
+
command_line << @options[:cancel_max_wait].to_s
|
970
|
+
end
|
948
971
|
verify_server = VerifyServer.new
|
949
972
|
same = verify_server.run(command_line, &callback)
|
950
973
|
@n_executed_commands = verify_server.n_executed_commands
|
@@ -287,6 +287,22 @@ module GroongaQueryLog
|
|
287
287
|
@options.max_limit = limit
|
288
288
|
end
|
289
289
|
|
290
|
+
parser.on("--[no-]verify-cancel",
|
291
|
+
"Verify cancellation",
|
292
|
+
"(#{@options.verify_cancel?})") do |boolean|
|
293
|
+
@options.verify_cancel = boolean
|
294
|
+
end
|
295
|
+
|
296
|
+
parser.on("--cancel-max-wait=SECONDS", Float,
|
297
|
+
"Used with --verify_cancel. " +
|
298
|
+
"You can specify the maximum number of seconds to wait " +
|
299
|
+
"before sending request_cancel command. " +
|
300
|
+
"For example, if you specify 5.0 in this option, " +
|
301
|
+
"wait randomly between 0~5.0 seconds before sending request_cancel command.",
|
302
|
+
"(#{@options.cancel_max_wait})") do |seconds|
|
303
|
+
@options.cancel_max_wait = seconds
|
304
|
+
end
|
305
|
+
|
290
306
|
create_parser_performance(parser)
|
291
307
|
|
292
308
|
parser.separator("")
|
@@ -47,6 +47,7 @@ module GroongaQueryLog
|
|
47
47
|
parser.parse(input) do |statistic|
|
48
48
|
next if statistic.command.nil?
|
49
49
|
next unless target_command?(statistic.command)
|
50
|
+
next unless available_command?(statistic.command)
|
50
51
|
# TODO: validate orignal_source is one line
|
51
52
|
output.puts(statistic.command.original_source)
|
52
53
|
output.flush
|
@@ -132,6 +133,15 @@ module GroongaQueryLog
|
|
132
133
|
@options.target_command_name?(command.command_name)
|
133
134
|
end
|
134
135
|
|
136
|
+
def available_command?(command)
|
137
|
+
case command.command_name
|
138
|
+
when "load"
|
139
|
+
not command.values.nil?
|
140
|
+
else
|
141
|
+
true
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
135
145
|
class NullOutput
|
136
146
|
class << self
|
137
147
|
def open
|
@@ -27,12 +27,15 @@ require "groonga-query-log/response-comparer"
|
|
27
27
|
|
28
28
|
module GroongaQueryLog
|
29
29
|
class ServerVerifier
|
30
|
+
GRN_CANCEL = -77
|
31
|
+
|
30
32
|
attr_reader :n_executed_commands
|
31
33
|
def initialize(options)
|
32
34
|
@options = options
|
33
35
|
@queue = SizedQueue.new(@options.request_queue_size)
|
34
36
|
@events = Queue.new
|
35
37
|
@n_executed_commands = 0
|
38
|
+
@request_id_counter = 0
|
36
39
|
end
|
37
40
|
|
38
41
|
def verify(input, &callback)
|
@@ -167,9 +170,15 @@ module GroongaQueryLog
|
|
167
170
|
@options.stop_on_failure? and failed?
|
168
171
|
end
|
169
172
|
|
173
|
+
def generate_request_id
|
174
|
+
(@request_id_counter += 1).to_s
|
175
|
+
end
|
176
|
+
|
170
177
|
def verify_command(groonga1_client, groonga2_client, command)
|
171
178
|
command["cache"] = "no" if @options.disable_cache?
|
172
179
|
command["cache"] = "no" if @options.verify_performance?
|
180
|
+
command["request_id"] = generate_request_id if @options.verify_cancel?
|
181
|
+
|
173
182
|
if @options.max_limit >= 0 and command["limit"]
|
174
183
|
limit = command["limit"].to_i
|
175
184
|
if limit >= 0
|
@@ -181,8 +190,26 @@ module GroongaQueryLog
|
|
181
190
|
command["output_type"] = "json"
|
182
191
|
rewrite_filter(command, "filter")
|
183
192
|
rewrite_filter(command, "scorer")
|
193
|
+
|
184
194
|
response1 = groonga1_client.execute(command)
|
185
|
-
|
195
|
+
# groonga2 is new Groonga.
|
196
|
+
response2 = nil
|
197
|
+
if @options.verify_cancel?
|
198
|
+
request = groonga2_client.execute(command) do |response|
|
199
|
+
response2 = response
|
200
|
+
end
|
201
|
+
# Randomize timing of sending request_cancel command
|
202
|
+
sleep(rand(0..@options.cancel_max_wait))
|
203
|
+
@options.groonga2.create_client do |cancel_client|
|
204
|
+
cancel_client.execute("request_cancel", id: command.request_id)
|
205
|
+
end
|
206
|
+
request.wait
|
207
|
+
|
208
|
+
return if response2.return_code == GRN_CANCEL
|
209
|
+
else
|
210
|
+
response2 = groonga2_client.execute(command)
|
211
|
+
end
|
212
|
+
|
186
213
|
compare_options = {
|
187
214
|
:care_order => @options.care_order,
|
188
215
|
:ignored_drilldown_keys => @options.ignored_drilldown_keys,
|
@@ -326,6 +353,8 @@ module GroongaQueryLog
|
|
326
353
|
attr_writer :debug_rewrite
|
327
354
|
attr_writer :omit_rate
|
328
355
|
attr_accessor :max_limit
|
356
|
+
attr_writer :verify_cancel
|
357
|
+
attr_writer :cancel_max_wait
|
329
358
|
def initialize
|
330
359
|
@groonga1 = GroongaOptions.new
|
331
360
|
@groonga2 = GroongaOptions.new
|
@@ -361,6 +390,8 @@ module GroongaQueryLog
|
|
361
390
|
@debug_rewrite = false
|
362
391
|
@omit_rate = 0.0
|
363
392
|
@max_limit = -1
|
393
|
+
@verify_cancel = false
|
394
|
+
@cancel_max_wait = 5.0
|
364
395
|
end
|
365
396
|
|
366
397
|
def request_queue_size
|
@@ -460,6 +491,14 @@ module GroongaQueryLog
|
|
460
491
|
def omit_rate
|
461
492
|
@omit_rate
|
462
493
|
end
|
494
|
+
|
495
|
+
def verify_cancel?
|
496
|
+
@verify_cancel
|
497
|
+
end
|
498
|
+
|
499
|
+
def cancel_max_wait
|
500
|
+
@cancel_max_wait
|
501
|
+
end
|
463
502
|
end
|
464
503
|
|
465
504
|
class GroongaOptions
|
@@ -152,6 +152,7 @@ module GroongaQueryLog
|
|
152
152
|
operation_data["relative_elapsed"] = operation[:relative_elapsed_in_seconds]
|
153
153
|
operation_data["context"] = operation[:context]
|
154
154
|
operation_data["slow"] = operation[:slow?]
|
155
|
+
operation_data["n_records"] = operation[:n_records]
|
155
156
|
operations << operation_data
|
156
157
|
end
|
157
158
|
data["operations"] = operations
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-
|
1
|
+
# Copyright (C) 2012-2021 Sutou Kouhei <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -15,5 +15,5 @@
|
|
15
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
16
|
|
17
17
|
module GroongaQueryLog
|
18
|
-
VERSION = "1.7.
|
18
|
+
VERSION = "1.7.7"
|
19
19
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (C) 2012 Haruka Yoshihara <yoshihara@clear-code.com>
|
2
|
-
# Copyright (C) 2014-
|
2
|
+
# Copyright (C) 2014-2021 Sutou Kouhei <kou@clear-code.com>
|
3
3
|
#
|
4
4
|
# This library is free software; you can redistribute it and/or
|
5
5
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -42,6 +42,7 @@ class AnalyzerCommandTest < Test::Unit::TestCase
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_no_specified
|
45
|
+
require_tty
|
45
46
|
assert_equal("Error: Please specify input log files.\n",
|
46
47
|
run_analyzer)
|
47
48
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (C) 2012 Haruka Yoshihara <yoshihara@clear-code.com>
|
2
|
-
# Copyright (C) 2015-
|
2
|
+
# Copyright (C) 2015-2021 Sutou Kouhei <kou@clear-code.com>
|
3
3
|
#
|
4
4
|
# This library is free software; you can redistribute it and/or
|
5
5
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -45,6 +45,7 @@ column_create --flags "COLUMN_SCALAR" --name "title" --table "Comments" --type "
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_no_specified
|
48
|
+
require_tty
|
48
49
|
assert_equal("Error: Please specify input log files.\n",
|
49
50
|
run_extractor)
|
50
51
|
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
{"start_time":START_TIME,"end_time":END_TIME,"elapsed":0.003128856,"return_code":0,"slow":false,"command":{"raw":"load --table Video","name":"load","parameters":[{"key":"table","value":"Video"}]},"operations":[]}
|
2
|
-
{"start_time":START_TIME,"end_time":END_TIME,"elapsed":0.00121714,"return_code":0,"slow":false,"command":{"raw":"select --table Users --query follower:@groonga --output_columns _key,name","name":"select","parameters":[{"key":"table","value":"Users"},{"key":"query","value":"follower:@groonga"},{"key":"output_columns","value":"_key,name"}]},"operations":[{"name":"filter","relative_elapsed":0.0008429529999999999,"context":"Users.follower match \"groonga\"","slow":false},{"name":"select","relative_elapsed":2.7947e-05,"context":null,"slow":false},{"name":"output","relative_elapsed":0.000195852,"context":"_key,name","slow":false}]}
|
2
|
+
{"start_time":START_TIME,"end_time":END_TIME,"elapsed":0.00121714,"return_code":0,"slow":false,"command":{"raw":"select --table Users --query follower:@groonga --output_columns _key,name","name":"select","parameters":[{"key":"table","value":"Users"},{"key":"query","value":"follower:@groonga"},{"key":"output_columns","value":"_key,name"}]},"operations":[{"name":"filter","relative_elapsed":0.0008429529999999999,"context":"Users.follower match \"groonga\"","slow":false,"n_records":2},{"name":"select","relative_elapsed":2.7947e-05,"context":null,"slow":false,"n_records":2},{"name":"output","relative_elapsed":0.000195852,"context":"_key,name","slow":false,"n_records":2}]}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
[
|
2
2
|
{"start_time":START_TIME,"end_time":END_TIME,"elapsed":0.003128856,"return_code":0,"slow":false,"command":{"raw":"load --table Video","name":"load","parameters":[{"key":"table","value":"Video"}]},"operations":[]},
|
3
|
-
{"start_time":START_TIME,"end_time":END_TIME,"elapsed":0.00121714,"return_code":0,"slow":false,"command":{"raw":"select --table Users --query follower:@groonga --output_columns _key,name","name":"select","parameters":[{"key":"table","value":"Users"},{"key":"query","value":"follower:@groonga"},{"key":"output_columns","value":"_key,name"}]},"operations":[{"name":"filter","relative_elapsed":0.0008429529999999999,"context":"Users.follower match \"groonga\"","slow":false},{"name":"select","relative_elapsed":2.7947e-05,"context":null,"slow":false},{"name":"output","relative_elapsed":0.000195852,"context":"_key,name","slow":false}]}
|
3
|
+
{"start_time":START_TIME,"end_time":END_TIME,"elapsed":0.00121714,"return_code":0,"slow":false,"command":{"raw":"select --table Users --query follower:@groonga --output_columns _key,name","name":"select","parameters":[{"key":"table","value":"Users"},{"key":"query","value":"follower:@groonga"},{"key":"output_columns","value":"_key,name"}]},"operations":[{"name":"filter","relative_elapsed":0.0008429529999999999,"context":"Users.follower match \"groonga\"","slow":false,"n_records":2},{"name":"select","relative_elapsed":2.7947e-05,"context":null,"slow":false,"n_records":2},{"name":"output","relative_elapsed":0.000195852,"context":"_key,name","slow":false,"n_records":2}]}
|
4
4
|
]
|
data/test/helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2011-
|
1
|
+
# Copyright (C) 2011-2021 Sutou Kouhei <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -29,6 +29,10 @@ module Helper
|
|
29
29
|
end
|
30
30
|
|
31
31
|
module Command
|
32
|
+
def require_tty
|
33
|
+
omit("Require tty") unless $stdin.tty?
|
34
|
+
end
|
35
|
+
|
32
36
|
def open_error_output
|
33
37
|
Tempfile.open("groonga-query-log.error") do |error|
|
34
38
|
error.sync = true
|
data/test/test-replayer.rb
CHANGED
@@ -51,7 +51,7 @@ class ReplayerTest < Test::Unit::TestCase
|
|
51
51
|
:read_timeout => 60,
|
52
52
|
}
|
53
53
|
expected_open_options = default_options.merge(expected_options)
|
54
|
-
mock(Groonga::Client).open(expected_open_options).yields(client) do
|
54
|
+
mock(Groonga::Client).open(**expected_open_options).yields(client) do
|
55
55
|
client
|
56
56
|
end
|
57
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groonga-query-log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: charty
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: net-smtp
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: groonga-client
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -315,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
315
329
|
- !ruby/object:Gem::Version
|
316
330
|
version: '0'
|
317
331
|
requirements: []
|
318
|
-
rubygems_version: 3.
|
332
|
+
rubygems_version: 3.3.5
|
319
333
|
signing_key:
|
320
334
|
specification_version: 4
|
321
335
|
summary: Groonga-query-log is a collection of library and tools to process [Groonga](http://groonga.org/)'s
|