groonga-query-log 1.2.8 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/bin/groonga-query-log-analyze +3 -4
  3. data/bin/groonga-query-log-analyze-load +22 -0
  4. data/bin/groonga-query-log-check-command-version-compatibility +2 -2
  5. data/bin/groonga-query-log-check-crash +22 -0
  6. data/bin/groonga-query-log-detect-memory-leak +2 -2
  7. data/bin/groonga-query-log-extract +2 -2
  8. data/bin/groonga-query-log-format-regression-test-logs +2 -2
  9. data/bin/groonga-query-log-replay +3 -5
  10. data/bin/groonga-query-log-run-regression-test +2 -2
  11. data/bin/groonga-query-log-show-running-queries +2 -2
  12. data/bin/groonga-query-log-verify-server +2 -2
  13. data/doc/text/news.md +31 -0
  14. data/groonga-query-log.gemspec +5 -4
  15. data/lib/groonga-query-log.rb +42 -0
  16. data/lib/{groonga/query-log/command-line-utils.rb → groonga-query-log/command-line.rb} +25 -13
  17. data/lib/{groonga/query-log → groonga-query-log}/command-version-compatibility-checker.rb +3 -5
  18. data/lib/groonga-query-log/command/analyze-load.rb +188 -0
  19. data/lib/{groonga/query-log → groonga-query-log/command}/analyzer.rb +60 -44
  20. data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/reporter.rb +15 -20
  21. data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/reporter/console.rb +19 -18
  22. data/lib/groonga-query-log/command/analyzer/reporter/csv.rb +77 -0
  23. data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/reporter/html.rb +32 -16
  24. data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/reporter/json-stream.rb +4 -6
  25. data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/reporter/json.rb +7 -7
  26. data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/sized-grouped-operations.rb +3 -5
  27. data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/sized-statistics.rb +4 -6
  28. data/lib/{groonga/query-log → groonga-query-log/command}/analyzer/streamer.rb +4 -6
  29. data/lib/groonga-query-log/command/check-command-version-compatibility.rb +69 -0
  30. data/lib/groonga-query-log/command/check-crash.rb +169 -0
  31. data/lib/groonga-query-log/command/detect-memory-leak.rb +89 -0
  32. data/lib/groonga-query-log/command/extract.rb +171 -0
  33. data/lib/groonga-query-log/command/format-regression-test-logs.rb +143 -0
  34. data/lib/groonga-query-log/command/replay.rb +117 -0
  35. data/lib/groonga-query-log/command/run-regression-test.rb +432 -0
  36. data/lib/groonga-query-log/command/show-running-queries.rb +78 -0
  37. data/lib/{groonga/query-log/command/replay.rb → groonga-query-log/command/verify-server.rb} +68 -37
  38. data/lib/{groonga/query-log → groonga-query-log}/incompatibility-detector.rb +3 -5
  39. data/lib/{groonga/query-log → groonga-query-log}/memory-leak-detector.rb +3 -7
  40. data/lib/groonga-query-log/parser.rb +173 -0
  41. data/lib/{groonga/query-log → groonga-query-log}/replayer.rb +7 -8
  42. data/lib/{groonga/query-log → groonga-query-log}/response-comparer.rb +3 -5
  43. data/lib/{groonga/query-log → groonga-query-log}/server-verifier.rb +3 -5
  44. data/lib/groonga-query-log/statistic.rb +192 -0
  45. data/lib/{groonga/query-log → groonga-query-log}/version.rb +2 -4
  46. data/lib/groonga/query-log.rb +21 -9
  47. data/lib/groonga/query-log/command/analyzer.rb +18 -0
  48. data/lib/groonga/query-log/command/check-command-version-compatibility.rb +2 -55
  49. data/lib/groonga/query-log/command/detect-memory-leak.rb +3 -78
  50. data/lib/groonga/query-log/command/extract.rb +5 -179
  51. data/lib/groonga/query-log/command/format-regression-test-logs.rb +3 -130
  52. data/lib/groonga/query-log/command/reply.rb +18 -0
  53. data/lib/groonga/query-log/command/run-regression-test.rb +2 -418
  54. data/lib/groonga/query-log/command/show-running-queries.rb +3 -65
  55. data/lib/groonga/query-log/command/verify-server.rb +2 -137
  56. data/test/{test-analyzer.rb → command/test-analyzer.rb} +17 -11
  57. data/test/command/test-extract.rb +9 -18
  58. data/test/command/test-format-regression-test-logs.rb +3 -3
  59. data/test/fixtures/reporter/html.expected +55 -20
  60. data/test/helper.rb +22 -7
  61. data/test/test-incompatibility-detector.rb +3 -3
  62. data/test/test-parser.rb +19 -4
  63. data/test/test-replayer.rb +4 -4
  64. data/test/test-response-comparer.rb +2 -2
  65. metadata +86 -97
  66. data/lib/groonga/query-log/analyzer/statistic.rb +0 -194
  67. data/lib/groonga/query-log/parser.rb +0 -125
  68. data/test/fixtures/run-regression-test/db.new/db +0 -0
  69. data/test/fixtures/run-regression-test/db.new/db.0000000 +0 -0
  70. data/test/fixtures/run-regression-test/db.new/db.0000100 +0 -0
  71. data/test/fixtures/run-regression-test/db.new/db.0000101 +0 -0
  72. data/test/fixtures/run-regression-test/db.new/db.0000102 +0 -0
  73. data/test/fixtures/run-regression-test/db.new/db.0000103 +0 -0
  74. data/test/fixtures/run-regression-test/db.new/db.0000103.c +0 -0
  75. data/test/fixtures/run-regression-test/db.new/db.001 +0 -0
  76. data/test/fixtures/run-regression-test/db.new/db.conf +0 -0
  77. data/test/fixtures/run-regression-test/db.new/groonga.log +0 -165
  78. data/test/fixtures/run-regression-test/db.old/db +0 -0
  79. data/test/fixtures/run-regression-test/db.old/db.0000000 +0 -0
  80. data/test/fixtures/run-regression-test/db.old/db.0000100 +0 -0
  81. data/test/fixtures/run-regression-test/db.old/db.0000101 +0 -0
  82. data/test/fixtures/run-regression-test/db.old/db.0000102 +0 -0
  83. data/test/fixtures/run-regression-test/db.old/db.0000103 +0 -0
  84. data/test/fixtures/run-regression-test/db.old/db.0000103.c +0 -0
  85. data/test/fixtures/run-regression-test/db.old/db.001 +0 -0
  86. data/test/fixtures/run-regression-test/db.old/db.conf +0 -0
  87. data/test/fixtures/run-regression-test/db.old/groonga.log +0 -79
  88. data/test/fixtures/run-regression-test/results/query.log +0 -0
data/test/helper.rb CHANGED
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2011-2012 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2011-2017 Kouhei Sutou <kou@clear-code.com>
4
2
  #
5
3
  # This library is free software; you can redistribute it and/or
6
4
  # modify it under the terms of the GNU Lesser General Public
@@ -21,10 +19,27 @@ require "stringio"
21
19
 
22
20
  require "groonga/command"
23
21
 
24
- require "groonga/query-log"
22
+ require "groonga-query-log"
23
+
24
+ module Helper
25
+ module Path
26
+ def fixture_path(*components)
27
+ File.join(File.dirname(__FILE__), "fixtures", *components)
28
+ end
29
+ end
25
30
 
26
- module Path
27
- def fixture_path(*components)
28
- File.join(File.dirname(__FILE__), "fixtures", *components)
31
+ module Command
32
+ def open_error_output
33
+ Tempfile.open("groonga-query-log.error") do |error|
34
+ error.sync = true
35
+ original_stderr = $stderr.dup
36
+ $stderr.reopen(error)
37
+ begin
38
+ yield(error)
39
+ ensure
40
+ $stderr.reopen(original_stderr)
41
+ end
42
+ end
43
+ end
29
44
  end
30
45
  end
@@ -25,7 +25,7 @@ class IncompatibilityDetectorTest < Test::Unit::TestCase
25
25
  end
26
26
 
27
27
  def parse_query_log(query_log)
28
- parser = Groonga::QueryLog::Parser.new
28
+ parser = GroongaQueryLog::Parser.new
29
29
  parser.parse(query_log) do |statistic|
30
30
  return statistic
31
31
  end
@@ -33,13 +33,13 @@ class IncompatibilityDetectorTest < Test::Unit::TestCase
33
33
 
34
34
  sub_test_case("version1") do
35
35
  def setup
36
- @detector = Groonga::QueryLog::IncompatibilityDetector::Version1.new
36
+ @detector = GroongaQueryLog::IncompatibilityDetector::Version1.new
37
37
  end
38
38
  end
39
39
 
40
40
  sub_test_case("version2") do
41
41
  def setup
42
- @detector = Groonga::QueryLog::IncompatibilityDetector::Version2.new
42
+ @detector = GroongaQueryLog::IncompatibilityDetector::Version2.new
43
43
  end
44
44
 
45
45
  sub_test_case("select") do
data/test/test-parser.rb CHANGED
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2011-2013 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2011-2017 Kouhei Sutou <kou@clear-code.com>
4
2
  #
5
3
  # This library is free software; you can redistribute it and/or
6
4
  # modify it under the terms of the GNU Lesser General Public
@@ -48,7 +46,7 @@ class ParserTest < Test::Unit::TestCase
48
46
  private
49
47
  def parse(log)
50
48
  statistics = []
51
- parser = Groonga::QueryLog::Parser.new
49
+ parser = GroongaQueryLog::Parser.new
52
50
  parser.parse(StringIO.new(log)) do |statistic|
53
51
  statistics << statistic
54
52
  end
@@ -257,4 +255,21 @@ class ParserTest < Test::Unit::TestCase
257
255
  end
258
256
  end
259
257
  end
258
+
259
+ class ExtraFieldTest < self
260
+ def test_load
261
+ statistics = parse(<<-LOG)
262
+ 2017-12-11 09:37:04.516938|0x7fffc430dff0|>load --table Numbers
263
+ 2017-12-11 09:37:04.517993|0x7fffc430dff0|:000000001056310 load(3): [1][2][3]
264
+ 2017-12-11 09:37:04.517999|0x7fffc430dff0|<000000001061996 rc=-22
265
+ LOG
266
+ operations = statistics.first.operations.collect do |operation|
267
+ [operation[:name], operation[:n_records], operation[:extra]]
268
+ end
269
+ expected = [
270
+ ["load", 3, "[1][2][3]"],
271
+ ]
272
+ assert_equal(expected, operations)
273
+ end
274
+ end
260
275
  end
@@ -20,7 +20,7 @@ class ReplayerTest < Test::Unit::TestCase
20
20
  class OptionTest < self
21
21
  class ClientTest < self
22
22
  def setup
23
- @options = Groonga::QueryLog::Replayer::Options.new
23
+ @options = GroongaQueryLog::Replayer::Options.new
24
24
  @options.n_clients = 1
25
25
  end
26
26
 
@@ -40,7 +40,7 @@ class ReplayerTest < Test::Unit::TestCase
40
40
 
41
41
  private
42
42
  def replay
43
- replayer = Groonga::QueryLog::Replayer.new(@options)
43
+ replayer = GroongaQueryLog::Replayer.new(@options)
44
44
  replayer.replay(StringIO.new(""))
45
45
  end
46
46
 
@@ -49,7 +49,7 @@ class ReplayerTest < Test::Unit::TestCase
49
49
  default_options = {
50
50
  :host => "127.0.0.1",
51
51
  :port => 10041,
52
- :protocol => :gqtp,
52
+ :protocol => :http,
53
53
  }
54
54
  expected_open_options = default_options.merge(expected_options)
55
55
  mock(Groonga::Client).open(expected_open_options).yields(client) do
@@ -60,7 +60,7 @@ class ReplayerTest < Test::Unit::TestCase
60
60
 
61
61
  class TargetCommandNameTest < self
62
62
  def setup
63
- @options = Groonga::QueryLog::Replayer::Options.new
63
+ @options = GroongaQueryLog::Replayer::Options.new
64
64
  end
65
65
 
66
66
  def test_default
@@ -19,8 +19,8 @@ class ResponseComparerTest < Test::Unit::TestCase
19
19
  def comparer(response1, response2, options={})
20
20
  response1 = normalize_response(response1)
21
21
  response2 = normalize_response(response2)
22
- Groonga::QueryLog::ResponseComparer.new(@command, response1, response2,
23
- options)
22
+ GroongaQueryLog::ResponseComparer.new(@command, response1, response2,
23
+ options)
24
24
  end
25
25
 
26
26
  def same?(response1, response2, options={})
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.2.8
4
+ version: 1.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2018-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: groonga-command-parser
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: groonga-log
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.2
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: test-unit
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -154,15 +168,17 @@ description: ''
154
168
  email:
155
169
  - kou@clear-code.com
156
170
  executables:
157
- - groonga-query-log-replay
171
+ - groonga-query-log-check-command-version-compatibility
172
+ - groonga-query-log-extract
173
+ - groonga-query-log-run-regression-test
174
+ - groonga-query-log-analyze
175
+ - groonga-query-log-check-crash
176
+ - groonga-query-log-analyze-load
177
+ - groonga-query-log-verify-server
158
178
  - groonga-query-log-format-regression-test-logs
179
+ - groonga-query-log-replay
159
180
  - groonga-query-log-show-running-queries
160
181
  - groonga-query-log-detect-memory-leak
161
- - groonga-query-log-verify-server
162
- - groonga-query-log-run-regression-test
163
- - groonga-query-log-check-command-version-compatibility
164
- - groonga-query-log-analyze
165
- - groonga-query-log-extract
166
182
  extensions: []
167
183
  extra_rdoc_files: []
168
184
  files:
@@ -171,7 +187,9 @@ files:
171
187
  - README.md
172
188
  - Rakefile
173
189
  - bin/groonga-query-log-analyze
190
+ - bin/groonga-query-log-analyze-load
174
191
  - bin/groonga-query-log-check-command-version-compatibility
192
+ - bin/groonga-query-log-check-crash
175
193
  - bin/groonga-query-log-detect-memory-leak
176
194
  - bin/groonga-query-log-extract
177
195
  - bin/groonga-query-log-format-regression-test-logs
@@ -183,34 +201,48 @@ files:
183
201
  - doc/text/news.md
184
202
  - doc/text/run-regression-test.md
185
203
  - groonga-query-log.gemspec
204
+ - lib/groonga-query-log.rb
205
+ - lib/groonga-query-log/command-line.rb
206
+ - lib/groonga-query-log/command-version-compatibility-checker.rb
207
+ - lib/groonga-query-log/command/analyze-load.rb
208
+ - lib/groonga-query-log/command/analyzer.rb
209
+ - lib/groonga-query-log/command/analyzer/reporter.rb
210
+ - lib/groonga-query-log/command/analyzer/reporter/console.rb
211
+ - lib/groonga-query-log/command/analyzer/reporter/csv.rb
212
+ - lib/groonga-query-log/command/analyzer/reporter/html.rb
213
+ - lib/groonga-query-log/command/analyzer/reporter/json-stream.rb
214
+ - lib/groonga-query-log/command/analyzer/reporter/json.rb
215
+ - lib/groonga-query-log/command/analyzer/sized-grouped-operations.rb
216
+ - lib/groonga-query-log/command/analyzer/sized-statistics.rb
217
+ - lib/groonga-query-log/command/analyzer/streamer.rb
218
+ - lib/groonga-query-log/command/check-command-version-compatibility.rb
219
+ - lib/groonga-query-log/command/check-crash.rb
220
+ - lib/groonga-query-log/command/detect-memory-leak.rb
221
+ - lib/groonga-query-log/command/extract.rb
222
+ - lib/groonga-query-log/command/format-regression-test-logs.rb
223
+ - lib/groonga-query-log/command/replay.rb
224
+ - lib/groonga-query-log/command/run-regression-test.rb
225
+ - lib/groonga-query-log/command/show-running-queries.rb
226
+ - lib/groonga-query-log/command/verify-server.rb
227
+ - lib/groonga-query-log/incompatibility-detector.rb
228
+ - lib/groonga-query-log/memory-leak-detector.rb
229
+ - lib/groonga-query-log/parser.rb
230
+ - lib/groonga-query-log/replayer.rb
231
+ - lib/groonga-query-log/response-comparer.rb
232
+ - lib/groonga-query-log/server-verifier.rb
233
+ - lib/groonga-query-log/statistic.rb
234
+ - lib/groonga-query-log/version.rb
186
235
  - lib/groonga/query-log.rb
187
- - lib/groonga/query-log/analyzer.rb
188
- - lib/groonga/query-log/analyzer/reporter.rb
189
- - lib/groonga/query-log/analyzer/reporter/console.rb
190
- - lib/groonga/query-log/analyzer/reporter/html.rb
191
- - lib/groonga/query-log/analyzer/reporter/json-stream.rb
192
- - lib/groonga/query-log/analyzer/reporter/json.rb
193
- - lib/groonga/query-log/analyzer/sized-grouped-operations.rb
194
- - lib/groonga/query-log/analyzer/sized-statistics.rb
195
- - lib/groonga/query-log/analyzer/statistic.rb
196
- - lib/groonga/query-log/analyzer/streamer.rb
197
- - lib/groonga/query-log/command-line-utils.rb
198
- - lib/groonga/query-log/command-version-compatibility-checker.rb
236
+ - lib/groonga/query-log/command/analyzer.rb
199
237
  - lib/groonga/query-log/command/check-command-version-compatibility.rb
200
238
  - lib/groonga/query-log/command/detect-memory-leak.rb
201
239
  - lib/groonga/query-log/command/extract.rb
202
240
  - lib/groonga/query-log/command/format-regression-test-logs.rb
203
- - lib/groonga/query-log/command/replay.rb
241
+ - lib/groonga/query-log/command/reply.rb
204
242
  - lib/groonga/query-log/command/run-regression-test.rb
205
243
  - lib/groonga/query-log/command/show-running-queries.rb
206
244
  - lib/groonga/query-log/command/verify-server.rb
207
- - lib/groonga/query-log/incompatibility-detector.rb
208
- - lib/groonga/query-log/memory-leak-detector.rb
209
- - lib/groonga/query-log/parser.rb
210
- - lib/groonga/query-log/replayer.rb
211
- - lib/groonga/query-log/response-comparer.rb
212
- - lib/groonga/query-log/server-verifier.rb
213
- - lib/groonga/query-log/version.rb
245
+ - test/command/test-analyzer.rb
214
246
  - test/command/test-extract.rb
215
247
  - test/command/test-format-regression-test-logs.rb
216
248
  - test/fixtures/multi.expected
@@ -229,35 +261,13 @@ files:
229
261
  - test/fixtures/reporter/json-stream.expected
230
262
  - test/fixtures/reporter/json.expected
231
263
  - test/fixtures/run-regression-test/data/data.grn
232
- - test/fixtures/run-regression-test/db.new/db
233
- - test/fixtures/run-regression-test/db.new/db.0000000
234
- - test/fixtures/run-regression-test/db.new/db.0000100
235
- - test/fixtures/run-regression-test/db.new/db.0000101
236
- - test/fixtures/run-regression-test/db.new/db.0000102
237
- - test/fixtures/run-regression-test/db.new/db.0000103
238
- - test/fixtures/run-regression-test/db.new/db.0000103.c
239
- - test/fixtures/run-regression-test/db.new/db.001
240
- - test/fixtures/run-regression-test/db.new/db.conf
241
- - test/fixtures/run-regression-test/db.new/groonga.log
242
- - test/fixtures/run-regression-test/db.old/db
243
- - test/fixtures/run-regression-test/db.old/db.0000000
244
- - test/fixtures/run-regression-test/db.old/db.0000100
245
- - test/fixtures/run-regression-test/db.old/db.0000101
246
- - test/fixtures/run-regression-test/db.old/db.0000102
247
- - test/fixtures/run-regression-test/db.old/db.0000103
248
- - test/fixtures/run-regression-test/db.old/db.0000103.c
249
- - test/fixtures/run-regression-test/db.old/db.001
250
- - test/fixtures/run-regression-test/db.old/db.conf
251
- - test/fixtures/run-regression-test/db.old/groonga.log
252
264
  - test/fixtures/run-regression-test/indexes/indexes.grn
253
265
  - test/fixtures/run-regression-test/query-logs/query.log
254
- - test/fixtures/run-regression-test/results/query.log
255
266
  - test/fixtures/run-regression-test/schema/schema.grn
256
267
  - test/fixtures/target-commands.expected
257
268
  - test/fixtures/target-tables.expected
258
269
  - test/helper.rb
259
270
  - test/run-test.rb
260
- - test/test-analyzer.rb
261
271
  - test/test-incompatibility-detector.rb
262
272
  - test/test-parser.rb
263
273
  - test/test-replayer.rb
@@ -282,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
292
  version: '0'
283
293
  requirements: []
284
294
  rubyforge_project:
285
- rubygems_version: 2.5.2.1
295
+ rubygems_version: 2.5.2.2
286
296
  signing_key:
287
297
  specification_version: 4
288
298
  summary: Groonga-query-log is a collection of library and tools to process [Groonga](http://groonga.org/)'s
@@ -290,54 +300,33 @@ summary: Groonga-query-log is a collection of library and tools to process [Groo
290
300
  as a library. You can analyze your Groonga's queries and test with your Groonga's
291
301
  query log by using groonga-query-log as a tool.
292
302
  test_files:
293
- - test/test-analyzer.rb
294
- - test/fixtures/multi.expected
295
- - test/fixtures/target-tables.expected
296
- - test/fixtures/target-commands.expected
297
- - test/fixtures/n_entries.expected
298
- - test/fixtures/query.log
299
- - test/fixtures/other-query.log
300
- - test/fixtures/order/-start-time.expected
301
- - test/fixtures/order/elapsed.expected
302
- - test/fixtures/order/-elapsed.expected
303
- - test/fixtures/order/start-time.expected
304
- - test/fixtures/regression-test-logs/url-format.log
305
- - test/fixtures/regression-test-logs/command-format.log
306
- - test/fixtures/reporter/json.expected
307
- - test/fixtures/reporter/console.expected
308
- - test/fixtures/reporter/html.expected
309
- - test/fixtures/reporter/json-stream.expected
310
- - test/fixtures/run-regression-test/db.old/db.0000100
311
- - test/fixtures/run-regression-test/db.old/db.0000103
312
- - test/fixtures/run-regression-test/db.old/db.0000103.c
313
- - test/fixtures/run-regression-test/db.old/db.0000101
314
- - test/fixtures/run-regression-test/db.old/db
315
- - test/fixtures/run-regression-test/db.old/db.0000000
316
- - test/fixtures/run-regression-test/db.old/db.001
317
- - test/fixtures/run-regression-test/db.old/db.conf
318
- - test/fixtures/run-regression-test/db.old/db.0000102
319
- - test/fixtures/run-regression-test/db.old/groonga.log
320
- - test/fixtures/run-regression-test/query-logs/query.log
321
- - test/fixtures/run-regression-test/schema/schema.grn
322
- - test/fixtures/run-regression-test/data/data.grn
323
- - test/fixtures/run-regression-test/indexes/indexes.grn
324
- - test/fixtures/run-regression-test/db.new/db.0000100
325
- - test/fixtures/run-regression-test/db.new/db.0000103
326
- - test/fixtures/run-regression-test/db.new/db.0000103.c
327
- - test/fixtures/run-regression-test/db.new/db.0000101
328
- - test/fixtures/run-regression-test/db.new/db
329
- - test/fixtures/run-regression-test/db.new/db.0000000
330
- - test/fixtures/run-regression-test/db.new/db.001
331
- - test/fixtures/run-regression-test/db.new/db.conf
332
- - test/fixtures/run-regression-test/db.new/db.0000102
333
- - test/fixtures/run-regression-test/db.new/groonga.log
334
- - test/fixtures/run-regression-test/results/query.log
335
- - test/fixtures/no-report-summary.expected
303
+ - test/run-test.rb
336
304
  - test/helper.rb
337
- - test/command/test-format-regression-test-logs.rb
338
305
  - test/command/test-extract.rb
306
+ - test/command/test-format-regression-test-logs.rb
307
+ - test/command/test-analyzer.rb
308
+ - test/test-parser.rb
339
309
  - test/test-replayer.rb
340
310
  - test/test-incompatibility-detector.rb
341
- - test/run-test.rb
342
- - test/test-parser.rb
343
311
  - test/test-response-comparer.rb
312
+ - test/fixtures/no-report-summary.expected
313
+ - test/fixtures/regression-test-logs/command-format.log
314
+ - test/fixtures/regression-test-logs/url-format.log
315
+ - test/fixtures/target-tables.expected
316
+ - test/fixtures/run-regression-test/query-logs/query.log
317
+ - test/fixtures/run-regression-test/data/data.grn
318
+ - test/fixtures/run-regression-test/schema/schema.grn
319
+ - test/fixtures/run-regression-test/indexes/indexes.grn
320
+ - test/fixtures/order/start-time.expected
321
+ - test/fixtures/order/elapsed.expected
322
+ - test/fixtures/order/-start-time.expected
323
+ - test/fixtures/order/-elapsed.expected
324
+ - test/fixtures/n_entries.expected
325
+ - test/fixtures/reporter/console.expected
326
+ - test/fixtures/reporter/json.expected
327
+ - test/fixtures/reporter/json-stream.expected
328
+ - test/fixtures/reporter/html.expected
329
+ - test/fixtures/target-commands.expected
330
+ - test/fixtures/other-query.log
331
+ - test/fixtures/query.log
332
+ - test/fixtures/multi.expected
@@ -1,194 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2011-2012 Kouhei Sutou <kou@clear-code.com>
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License as published by the Free Software Foundation; either
8
- # version 2.1 of the License, or (at your option) any later version.
9
- #
10
- # This library is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Lesser General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Lesser General Public
16
- # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
-
19
- require "groonga/command/parser"
20
-
21
- module Groonga
22
- module QueryLog
23
- class Analyzer
24
- class Statistic
25
- DEFAULT_SLOW_OPERATION_THRESHOLD = 0.1
26
- DEFAULT_SLOW_RESPONSE_THRESHOLD = 0.2
27
-
28
- attr_reader :context_id, :start_time, :raw_command
29
- attr_reader :elapsed, :return_code
30
- attr_accessor :slow_operation_threshold, :slow_response_threshold
31
- def initialize(context_id)
32
- @context_id = context_id
33
- @start_time = nil
34
- @command = nil
35
- @raw_command = nil
36
- @operations = []
37
- @elapsed = nil
38
- @return_code = 0
39
- @slow_operation_threshold = DEFAULT_SLOW_OPERATION_THRESHOLD
40
- @slow_response_threshold = DEFAULT_SLOW_RESPONSE_THRESHOLD
41
- end
42
-
43
- def start(start_time, command)
44
- @start_time = start_time
45
- @raw_command = command
46
- end
47
-
48
- def finish(elapsed, return_code)
49
- @elapsed = elapsed
50
- @return_code = return_code
51
- end
52
-
53
- def command
54
- Groonga::Command::Parser.parse(@raw_command) do |status, command|
55
- case status
56
- when :on_load_start
57
- @loading = false
58
- @command ||= command
59
- when :on_command
60
- @command ||= command
61
- end
62
- end
63
- @command
64
- end
65
-
66
- def elapsed_in_seconds
67
- nano_seconds_to_seconds(@elapsed)
68
- end
69
-
70
- def last_time
71
- @start_time + elapsed_in_seconds
72
- end
73
-
74
- def slow?
75
- elapsed_in_seconds >= @slow_response_threshold
76
- end
77
-
78
- def each_operation
79
- previous_elapsed = 0
80
- ensure_parse_command
81
- operation_context_context = {
82
- :filter_index => 0,
83
- :drilldown_index => 0,
84
- }
85
- @operations.each_with_index do |operation, i|
86
- relative_elapsed = operation[:elapsed] - previous_elapsed
87
- relative_elapsed_in_seconds = nano_seconds_to_seconds(relative_elapsed)
88
- previous_elapsed = operation[:elapsed]
89
- parsed_operation = {
90
- :i => i,
91
- :elapsed => operation[:elapsed],
92
- :elapsed_in_seconds => nano_seconds_to_seconds(operation[:elapsed]),
93
- :relative_elapsed => relative_elapsed,
94
- :relative_elapsed_in_seconds => relative_elapsed_in_seconds,
95
- :name => operation[:name],
96
- :context => operation_context(operation[:name],
97
- operation_context_context),
98
- :n_records => operation[:n_records],
99
- :slow? => slow_operation?(relative_elapsed_in_seconds),
100
- }
101
- yield parsed_operation
102
- end
103
- end
104
-
105
- def add_operation(operation)
106
- @operations << operation
107
- end
108
-
109
- def operations
110
- _operations = []
111
- each_operation do |operation|
112
- _operations << operation
113
- end
114
- _operations
115
- end
116
-
117
- def select_command?
118
- command.name == "select"
119
- end
120
-
121
- def to_hash
122
- data = {
123
- "start_time" => start_time.to_f,
124
- "last_time" => last_time.to_f,
125
- "elapsed" => elapsed_in_seconds,
126
- "return_code" => return_code,
127
- "slow" => slow?,
128
- }
129
- arguments = command.arguments.collect do |key, value|
130
- {"key" => key, "value" => value}
131
- end
132
- data["command"] = {
133
- "raw" => raw_command,
134
- "name" => command.name,
135
- "parameters" => arguments,
136
- }
137
- operations = []
138
- each_operation do |operation|
139
- operation_data = {}
140
- operation_data["name"] = operation[:name]
141
- operation_data["relative_elapsed"] = operation[:relative_elapsed_in_seconds]
142
- operation_data["context"] = operation[:context]
143
- operation_data["slow"] = operation[:slow?]
144
- operations << operation_data
145
- end
146
- data["operations"] = operations
147
- data
148
- end
149
-
150
- private
151
- def nano_seconds_to_seconds(nano_seconds)
152
- nano_seconds / 1000.0 / 1000.0 / 1000.0
153
- end
154
-
155
- def operation_context(label, context)
156
- return nil if @select_command.nil?
157
-
158
- case label
159
- when "filter"
160
- if @select_command.query and context[:query_used].nil?
161
- context[:query_used] = true
162
- "query: #{@select_command.query}"
163
- else
164
- index = context[:filter_index]
165
- context[:filter_index] += 1
166
- @select_command.conditions[index]
167
- end
168
- when "sort"
169
- @select_command.sortby
170
- when "score"
171
- @select_command.scorer
172
- when "output"
173
- @select_command.output_columns
174
- when "drilldown"
175
- index = context[:drilldown_index]
176
- context[:drilldown_index] += 1
177
- @select_command.drilldowns[index]
178
- else
179
- nil
180
- end
181
- end
182
-
183
- def ensure_parse_command
184
- return unless select_command?
185
- @select_command = Groonga::Command::Parser.parse(@raw_command)
186
- end
187
-
188
- def slow_operation?(elapsed)
189
- elapsed >= @slow_operation_threshold
190
- end
191
- end
192
- end
193
- end
194
- end