groonga-query-log 1.1.5 → 1.1.6
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 +14 -0
- data/lib/groonga/query-log/command/extract.rb +131 -131
- data/lib/groonga/query-log/command/run-regression-test.rb +10 -3
- data/lib/groonga/query-log/command/verify-server.rb +6 -1
- data/lib/groonga/query-log/response-comparer.rb +21 -9
- data/lib/groonga/query-log/server-verifier.rb +15 -4
- data/lib/groonga/query-log/version.rb +1 -1
- data/test/{test-extractor.rb → command/test-extract.rb} +15 -14
- data/test/test-response-comparer.rb +18 -8
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd3f1d02cb11d8b4cf26fd7cbc1418a56e6ef7d9
|
4
|
+
data.tar.gz: f9b7f8f92de3af6e8652db79e53652ee84a4ee1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a38dfe89fc55a24c9860aa2c8cde1c2886eb3c6b11d356bf979f4074aed0ec41ac3f5cc09dfec8f9eb79b66e128b318feb08662f8a87db1a7d61951677e35fb
|
7
|
+
data.tar.gz: 2ef01816c6484747c88935637f870aaccd1a0cc7580a14ee639cc0f78b1b95b0cbc52bd0129be8a2da8a9af955d0a0b622a689a3cad7839de8297c3b90656fda
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 1.1.6: 2015-08-19
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* groonga-query-log-run-regression-test: Added `--no-care-order`
|
8
|
+
option that doesn't care order of records in response.
|
9
|
+
* groonga-query-log-verify-server: Added `--no-care-order`
|
10
|
+
option that doesn't care order of records in response.
|
11
|
+
* groonga-query-log-verify-server: Added the following commands to
|
12
|
+
the default target command names:
|
13
|
+
* `logical_count`
|
14
|
+
* `logical_range_filter`
|
15
|
+
* `logical_select`
|
16
|
+
|
3
17
|
## 1.1.5: 2015-08-12
|
4
18
|
|
5
19
|
### Improvements
|
@@ -26,167 +26,167 @@ require "groonga/query-log/command-line-utils"
|
|
26
26
|
module Groonga
|
27
27
|
module QueryLog
|
28
28
|
module Command
|
29
|
-
|
30
|
-
|
29
|
+
class Extract
|
30
|
+
include CommandLineUtils
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
attr_accessor :options
|
36
|
-
attr_reader :option_parser
|
32
|
+
class Error < StandardError
|
33
|
+
end
|
37
34
|
|
38
|
-
|
39
|
-
|
40
|
-
@option_parser = nil
|
41
|
-
setup_options
|
42
|
-
end
|
35
|
+
attr_accessor :options
|
36
|
+
attr_reader :option_parser
|
43
37
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
# extractor = Groonga::QueryLog::Command::Extract.new
|
49
|
-
# extractor.run("--output", "commands.output",
|
50
|
-
# "--command", "select",
|
51
|
-
# "query.log")
|
52
|
-
#
|
53
|
-
# If only paths of query log files are specified,
|
54
|
-
# this method prints command(s) of them to console.
|
55
|
-
#
|
56
|
-
# @param [Array<String>] arguments arguments for
|
57
|
-
# groonga-query-log-extract. Please execute
|
58
|
-
# "groonga-query-log-extract --help" or see #setup_options.
|
59
|
-
def run(arguments)
|
60
|
-
begin
|
61
|
-
log_paths = @option_parser.parse!(arguments)
|
62
|
-
rescue OptionParser::ParseError
|
63
|
-
$stderr.puts($!.message)
|
64
|
-
return false
|
38
|
+
def initialize
|
39
|
+
@options = nil
|
40
|
+
@option_parser = nil
|
41
|
+
setup_options
|
65
42
|
end
|
66
43
|
|
67
|
-
|
68
|
-
|
69
|
-
|
44
|
+
# Executes extractor for groonga's query logs.
|
45
|
+
# "groonga-query-log-extract" command runs this method.
|
46
|
+
#
|
47
|
+
# @example
|
48
|
+
# extractor = Groonga::QueryLog::Command::Extract.new
|
49
|
+
# extractor.run("--output", "commands.output",
|
50
|
+
# "--command", "select",
|
51
|
+
# "query.log")
|
52
|
+
#
|
53
|
+
# If only paths of query log files are specified,
|
54
|
+
# this method prints command(s) of them to console.
|
55
|
+
#
|
56
|
+
# @param [Array<String>] arguments arguments for
|
57
|
+
# groonga-query-log-extract. Please execute
|
58
|
+
# "groonga-query-log-extract --help" or see #setup_options.
|
59
|
+
def run(arguments)
|
60
|
+
begin
|
61
|
+
log_paths = @option_parser.parse!(arguments)
|
62
|
+
rescue OptionParser::ParseError
|
63
|
+
$stderr.puts($!.message)
|
70
64
|
return false
|
71
65
|
end
|
72
|
-
log = $stdin
|
73
|
-
else
|
74
|
-
log = log_paths
|
75
|
-
end
|
76
66
|
|
77
|
-
|
78
|
-
|
79
|
-
|
67
|
+
if log_paths.empty?
|
68
|
+
unless log_via_stdin?
|
69
|
+
$stderr.puts("Error: Please specify input log files.")
|
70
|
+
return false
|
71
|
+
end
|
72
|
+
log = $stdin
|
73
|
+
else
|
74
|
+
log = log_paths
|
80
75
|
end
|
81
|
-
else
|
82
|
-
extract(log, $stdout)
|
83
|
-
end
|
84
76
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
@options.unify_format = nil
|
92
|
-
@options.commands = []
|
93
|
-
@options.exclude_commands = []
|
94
|
-
@options.output_path = nil
|
95
|
-
@option_parser = OptionParser.new do |parser|
|
96
|
-
parser.version = VERSION
|
97
|
-
parser.banner += " QUERY_LOG1 ..."
|
98
|
-
|
99
|
-
available_formats = ["uri", "command"]
|
100
|
-
parser.on("--unify-format=FORMAT",
|
101
|
-
available_formats,
|
102
|
-
"Unify command format to FORMAT.",
|
103
|
-
"(#{available_formats.join(', ')})",
|
104
|
-
"[not unify]") do |format|
|
105
|
-
@options.unify_format = format
|
77
|
+
if @options.output_path
|
78
|
+
File.open(@options.output_path, "w") do |output|
|
79
|
+
extract(log, output)
|
80
|
+
end
|
81
|
+
else
|
82
|
+
extract(log, $stdout)
|
106
83
|
end
|
107
84
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
85
|
+
true
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
def setup_options
|
90
|
+
@options = OpenStruct.new
|
91
|
+
@options.unify_format = nil
|
92
|
+
@options.commands = []
|
93
|
+
@options.exclude_commands = []
|
94
|
+
@options.output_path = nil
|
95
|
+
@option_parser = OptionParser.new do |parser|
|
96
|
+
parser.version = VERSION
|
97
|
+
parser.banner += " QUERY_LOG1 ..."
|
98
|
+
|
99
|
+
available_formats = ["uri", "command"]
|
100
|
+
parser.on("--unify-format=FORMAT",
|
101
|
+
available_formats,
|
102
|
+
"Unify command format to FORMAT.",
|
103
|
+
"(#{available_formats.join(', ')})",
|
104
|
+
"[not unify]") do |format|
|
105
|
+
@options.unify_format = format
|
119
106
|
end
|
120
|
-
end
|
121
107
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
108
|
+
parser.on("--command=COMMAND",
|
109
|
+
"Extract only COMMAND.",
|
110
|
+
"To extract one or more commands,",
|
111
|
+
"specify this command a number of times.",
|
112
|
+
"Use /.../ as COMMAND to match command with regular expression.",
|
113
|
+
"[all commands]") do |command|
|
114
|
+
case command
|
115
|
+
when /\A\/(.*)\/(i)?\z/
|
116
|
+
@options.commands << Regexp.new($1, $2 == "i")
|
117
|
+
when
|
118
|
+
@options.commands << command
|
119
|
+
end
|
133
120
|
end
|
134
|
-
end
|
135
121
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
122
|
+
parser.on("--exclude-command=COMMAND",
|
123
|
+
"Don't extract COMMAND.",
|
124
|
+
"To ignore one or more commands,",
|
125
|
+
"specify this command a number of times.",
|
126
|
+
"Use /.../ as COMMAND to match command with regular expression.",
|
127
|
+
"[no commands]") do |command|
|
128
|
+
case command
|
129
|
+
when /\A\/(.*)\/(i)?\z/
|
130
|
+
@options.exclude_commands << Regexp.new($1, $2 == "i")
|
131
|
+
when
|
132
|
+
@options.exclude_commands << command
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
parser.on("--output=PATH",
|
137
|
+
"Output to PATH.",
|
138
|
+
"[standard output]") do |path|
|
139
|
+
@options.output_path = path
|
140
|
+
end
|
140
141
|
end
|
141
142
|
end
|
142
|
-
end
|
143
143
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
144
|
+
def extract(log, output)
|
145
|
+
if log.instance_of?(Array)
|
146
|
+
log.each do |log_path|
|
147
|
+
File.open(log_path) do |log_file|
|
148
|
+
extract_command(log_file, output)
|
149
|
+
end
|
149
150
|
end
|
151
|
+
else
|
152
|
+
extract_command(log, output)
|
150
153
|
end
|
151
|
-
else
|
152
|
-
extract_command(log, output)
|
153
154
|
end
|
154
|
-
end
|
155
155
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
156
|
+
def extract_command(log, output)
|
157
|
+
parser = Groonga::QueryLog::Parser.new
|
158
|
+
parser.parse(log) do |statistic|
|
159
|
+
command = statistic.command
|
160
|
+
next unless target?(command)
|
161
|
+
command_text = nil
|
162
|
+
case @options.unify_format
|
163
|
+
when "uri"
|
164
|
+
command_text = command.to_uri_format
|
165
|
+
when "command"
|
166
|
+
command_text = command.to_command_format
|
167
|
+
else
|
168
|
+
command_text = statistic.raw_command
|
169
|
+
end
|
170
|
+
output.puts(command_text)
|
169
171
|
end
|
170
|
-
output.puts(command_text)
|
171
172
|
end
|
172
|
-
end
|
173
173
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
174
|
+
def target?(command)
|
175
|
+
name = command.name
|
176
|
+
target_commands = @options.commands
|
177
|
+
exclude_commands = @options.exclude_commands
|
178
178
|
|
179
|
-
|
180
|
-
|
181
|
-
|
179
|
+
unless target_commands.empty?
|
180
|
+
return target_commands.any? {|target_command| target_command === name}
|
181
|
+
end
|
182
182
|
|
183
|
-
|
184
|
-
|
185
|
-
|
183
|
+
unless exclude_commands.empty?
|
184
|
+
return (not exclude_commands.any? {|exclude_command| exclude_command === name})
|
185
|
+
end
|
186
186
|
|
187
|
-
|
187
|
+
true
|
188
|
+
end
|
188
189
|
end
|
189
190
|
end
|
190
|
-
end
|
191
191
|
end
|
192
192
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2014-2015 Kouhei Sutou <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
|
@@ -43,6 +43,7 @@ module Groonga
|
|
43
43
|
@run_queries = true
|
44
44
|
@skip_finished_queries = false
|
45
45
|
@output_query_log = false
|
46
|
+
@care_order = true
|
46
47
|
end
|
47
48
|
|
48
49
|
def run(command_line)
|
@@ -124,6 +125,10 @@ module Groonga
|
|
124
125
|
"Output query log in verified target Groonga servers") do
|
125
126
|
@output_query_log = true
|
126
127
|
end
|
128
|
+
parser.on("--no-care-order",
|
129
|
+
"Don't care order of select response records") do
|
130
|
+
@care_order = false
|
131
|
+
end
|
127
132
|
|
128
133
|
parser
|
129
134
|
end
|
@@ -148,7 +153,8 @@ module Groonga
|
|
148
153
|
|
149
154
|
def tester_options
|
150
155
|
options = {
|
151
|
-
:n_clients
|
156
|
+
:n_clients => @n_clients,
|
157
|
+
:care_order => @care_order,
|
152
158
|
}
|
153
159
|
directory_options.merge(options)
|
154
160
|
end
|
@@ -372,8 +378,9 @@ module Groonga
|
|
372
378
|
"--groonga2-protocol=http",
|
373
379
|
"--target-command-name=select",
|
374
380
|
"--output", test_log_path.to_s,
|
375
|
-
query_log_path.to_s,
|
376
381
|
]
|
382
|
+
command_line << "--no-care-order" if @options[:care_order] == false
|
383
|
+
command_line << query_log_path.to_s
|
377
384
|
verify_serer = VerifyServer.new
|
378
385
|
verify_serer.run(command_line)
|
379
386
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013-
|
3
|
+
# Copyright (C) 2013-2015 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -124,6 +124,11 @@ module Groonga
|
|
124
124
|
@options.target_command_names = names
|
125
125
|
end
|
126
126
|
|
127
|
+
parser.on("--no-care-order",
|
128
|
+
"Don't care order of select response records") do
|
129
|
+
@options.care_order = false
|
130
|
+
end
|
131
|
+
|
127
132
|
parser.on("--output=PATH",
|
128
133
|
"Output results to PATH",
|
129
134
|
"[stdout]") do |path|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2014-2015 Kouhei Sutou <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
|
@@ -17,10 +17,12 @@
|
|
17
17
|
module Groonga
|
18
18
|
module QueryLog
|
19
19
|
class ResponseComparer
|
20
|
-
def initialize(command, response1, response2)
|
20
|
+
def initialize(command, response1, response2, options={})
|
21
21
|
@command = command
|
22
22
|
@response1 = response1
|
23
23
|
@response2 = response2
|
24
|
+
@options = options
|
25
|
+
@options[:care_order] = true if @options[:care_order].nil?
|
24
26
|
end
|
25
27
|
|
26
28
|
def same?
|
@@ -32,7 +34,7 @@ module Groonga
|
|
32
34
|
end
|
33
35
|
else
|
34
36
|
case @command.name
|
35
|
-
when "select"
|
37
|
+
when "select", "logical_select"
|
36
38
|
same_select_response?
|
37
39
|
else
|
38
40
|
same_response?
|
@@ -56,16 +58,26 @@ module Groonga
|
|
56
58
|
end
|
57
59
|
|
58
60
|
def same_select_response?
|
59
|
-
if
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
if care_order?
|
62
|
+
if all_output_columns?
|
63
|
+
same_all_output_columns?
|
64
|
+
else
|
65
|
+
same_response?
|
66
|
+
end
|
63
67
|
else
|
64
|
-
|
68
|
+
same_size_response?
|
65
69
|
end
|
66
70
|
end
|
67
71
|
|
72
|
+
def care_order?
|
73
|
+
return false unless @options[:care_order]
|
74
|
+
return false if random_sort?
|
75
|
+
|
76
|
+
true
|
77
|
+
end
|
78
|
+
|
68
79
|
def random_score?
|
80
|
+
return false unless @command.respond_to?(:scorer)
|
69
81
|
@command.scorer == "_score=rand()"
|
70
82
|
end
|
71
83
|
|
@@ -81,7 +93,7 @@ module Groonga
|
|
81
93
|
normalized_sort_items.include?("_score")
|
82
94
|
end
|
83
95
|
|
84
|
-
def
|
96
|
+
def same_size_response?
|
85
97
|
records_result1 = @response1.body[0] || []
|
86
98
|
records_result2 = @response2.body[0] || []
|
87
99
|
return false if records_result1.size != records_result2.size
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013-
|
3
|
+
# Copyright (C) 2013-2015 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -76,7 +76,7 @@ module Groonga
|
|
76
76
|
begin
|
77
77
|
verify_command(groonga1_client, groonga2_client,
|
78
78
|
statistic.command)
|
79
|
-
rescue
|
79
|
+
rescue
|
80
80
|
log_client_error($!) do
|
81
81
|
$stderr.puts(statistic.command.original_source)
|
82
82
|
end
|
@@ -108,7 +108,11 @@ module Groonga
|
|
108
108
|
command["output_type"] = :json
|
109
109
|
response1 = groonga1_client.execute(command)
|
110
110
|
response2 = groonga2_client.execute(command)
|
111
|
-
|
111
|
+
compare_options = {
|
112
|
+
:care_order => @options.care_order,
|
113
|
+
}
|
114
|
+
comparer = ResponseComparer.new(command, response1, response2,
|
115
|
+
compare_options)
|
112
116
|
unless comparer.same?
|
113
117
|
@different_results.push([command, response1, response2])
|
114
118
|
end
|
@@ -141,6 +145,7 @@ module Groonga
|
|
141
145
|
attr_writer :disable_cache
|
142
146
|
attr_accessor :target_command_names
|
143
147
|
attr_accessor :output_path
|
148
|
+
attr_accessor :care_order
|
144
149
|
def initialize
|
145
150
|
@groonga1 = GroongaOptions.new
|
146
151
|
@groonga2 = GroongaOptions.new
|
@@ -148,7 +153,13 @@ module Groonga
|
|
148
153
|
@request_queue_size = nil
|
149
154
|
@disable_cache = false
|
150
155
|
@output_path = nil
|
151
|
-
@target_command_names = [
|
156
|
+
@target_command_names = [
|
157
|
+
"logical_count",
|
158
|
+
"logical_range_filter",
|
159
|
+
"logical_select",
|
160
|
+
"select",
|
161
|
+
]
|
162
|
+
@care_order = true
|
152
163
|
end
|
153
164
|
|
154
165
|
def request_queue_size
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# -*- coding: utf-8 -*-
|
3
3
|
#
|
4
4
|
# Copyright (C) 2012 Haruka Yoshihara <yoshihara@clear-code.com>
|
5
|
+
# Copyright (C) 2015 Kouhei Sutou <kou@clear-code.com>
|
5
6
|
#
|
6
7
|
# This library is free software; you can redistribute it and/or
|
7
8
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -18,17 +19,17 @@
|
|
18
19
|
|
19
20
|
require "stringio"
|
20
21
|
require "groonga/command"
|
21
|
-
require "groonga/query-log/
|
22
|
+
require "groonga/query-log/command/extract"
|
22
23
|
|
23
|
-
class
|
24
|
+
class ExtractCommandTest < Test::Unit::TestCase
|
24
25
|
setup
|
25
26
|
def setup_fixtures
|
26
|
-
@fixtures_path = File.join(File.dirname(__FILE__), "fixtures")
|
27
|
+
@fixtures_path = File.join(File.dirname(__FILE__), "..", "fixtures")
|
27
28
|
@query_log_path = File.join(@fixtures_path, "query.log")
|
28
29
|
end
|
29
30
|
|
30
31
|
def setup
|
31
|
-
@
|
32
|
+
@extract_command = Groonga::QueryLog::Command::Extract.new
|
32
33
|
end
|
33
34
|
|
34
35
|
class TestInputFile < self
|
@@ -102,7 +103,7 @@ EOC
|
|
102
103
|
Tempfile.open("extract.output") do |output|
|
103
104
|
open_error_output do |error|
|
104
105
|
arguments << "--output" << output.path
|
105
|
-
if @
|
106
|
+
if @extract_command.run(arguments)
|
106
107
|
File.read(output.path)
|
107
108
|
else
|
108
109
|
File.read(error.path)
|
@@ -137,7 +138,7 @@ EOL
|
|
137
138
|
end
|
138
139
|
|
139
140
|
def test_command_format
|
140
|
-
@
|
141
|
+
@extract_command.options.unify_format = "command"
|
141
142
|
expected_formatted_command = "select --output_columns \"_key,name\""+
|
142
143
|
" --query \"follower:@groonga\"" +
|
143
144
|
" --table \"Users\"\n"
|
@@ -145,7 +146,7 @@ EOL
|
|
145
146
|
end
|
146
147
|
|
147
148
|
def test_uri_format
|
148
|
-
@
|
149
|
+
@extract_command.options.unify_format = "uri"
|
149
150
|
expected_formatted_command = "/d/select?output_columns=_key%2Cname" +
|
150
151
|
"&query=follower%3A%40groonga" +
|
151
152
|
"&table=Users\n"
|
@@ -153,7 +154,7 @@ EOL
|
|
153
154
|
end
|
154
155
|
|
155
156
|
def test_not_unify
|
156
|
-
@
|
157
|
+
@extract_command.options.unify_format = nil
|
157
158
|
expected_formatted_command = "select --table Users" +
|
158
159
|
" --query follower:@groonga" +
|
159
160
|
" --output_columns _key,name\n"
|
@@ -163,20 +164,20 @@ EOL
|
|
163
164
|
private
|
164
165
|
def extract
|
165
166
|
output = StringIO.new
|
166
|
-
@
|
167
|
+
@extract_command.send(:extract, @log, output)
|
167
168
|
output.string
|
168
169
|
end
|
169
170
|
end
|
170
171
|
|
171
172
|
class TestTarget < self
|
172
173
|
def test_include
|
173
|
-
@
|
174
|
+
@extract_command.options.commands = ["register"]
|
174
175
|
assert_true(target?("register"))
|
175
176
|
assert_false(target?("dump"))
|
176
177
|
end
|
177
178
|
|
178
179
|
def test_exclude
|
179
|
-
@
|
180
|
+
@extract_command.options.exclude_commands = ["dump"]
|
180
181
|
assert_true(target?("register"))
|
181
182
|
assert_false(target?("dump"))
|
182
183
|
end
|
@@ -187,13 +188,13 @@ EOL
|
|
187
188
|
end
|
188
189
|
|
189
190
|
def test_regular_expression_include
|
190
|
-
@
|
191
|
+
@extract_command.options.commands = [/table/]
|
191
192
|
assert_true(target?("table_create"))
|
192
193
|
assert_false(target?("dump"))
|
193
194
|
end
|
194
195
|
|
195
196
|
def test_regular_expression_exclude
|
196
|
-
@
|
197
|
+
@extract_command.options.exclude_commands = [/table/]
|
197
198
|
assert_false(target?("table_create"))
|
198
199
|
assert_true(target?("dump"))
|
199
200
|
end
|
@@ -202,7 +203,7 @@ EOL
|
|
202
203
|
def target?(name)
|
203
204
|
command_class = Groonga::Command.find(name)
|
204
205
|
command = command_class.new(name, [])
|
205
|
-
@
|
206
|
+
@extract_command.send(:target?, command)
|
206
207
|
end
|
207
208
|
end
|
208
209
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2014-2015 Kouhei Sutou <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
|
@@ -16,14 +16,15 @@
|
|
16
16
|
|
17
17
|
class ResponseComparerTest < Test::Unit::TestCase
|
18
18
|
private
|
19
|
-
def comparer(response1, response2)
|
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
|
22
|
+
Groonga::QueryLog::ResponseComparer.new(@command, response1, response2,
|
23
|
+
options)
|
23
24
|
end
|
24
25
|
|
25
|
-
def same?(response1, response2)
|
26
|
-
comparer(response1, response2).same?
|
26
|
+
def same?(response1, response2, options={})
|
27
|
+
comparer(response1, response2, options).same?
|
27
28
|
end
|
28
29
|
|
29
30
|
def response(body)
|
@@ -105,7 +106,7 @@ class ResponseComparerTest < Test::Unit::TestCase
|
|
105
106
|
private
|
106
107
|
def random_score?(scorer)
|
107
108
|
@command["scorer"] = scorer
|
108
|
-
comparer([[[0]]], [[[0]]]).send(:random_score?)
|
109
|
+
comparer([[[0], []]], [[[0], []]]).send(:random_score?)
|
109
110
|
end
|
110
111
|
end
|
111
112
|
end
|
@@ -115,7 +116,7 @@ class ResponseComparerTest < Test::Unit::TestCase
|
|
115
116
|
private
|
116
117
|
def score_sort?(sortby)
|
117
118
|
@command["sortby"] = sortby
|
118
|
-
comparer([[[0]]], [[[0]]]).send(:score_sort?)
|
119
|
+
comparer([[[0], []]], [[[0], []]]).send(:score_sort?)
|
119
120
|
end
|
120
121
|
|
121
122
|
class NoScoreTest < self
|
@@ -224,11 +225,20 @@ class ResponseComparerTest < Test::Unit::TestCase
|
|
224
225
|
private
|
225
226
|
def all_output_columns?(output_columns)
|
226
227
|
@command["output_columns"] = output_columns if output_columns
|
227
|
-
comparer([[[0]]], [[[0]]]).send(:all_output_columns?)
|
228
|
+
comparer([[[0], []]], [[[0], []]]).send(:all_output_columns?)
|
228
229
|
end
|
229
230
|
end
|
230
231
|
end
|
231
232
|
|
233
|
+
class ForceNoCareOrderTest < self
|
234
|
+
def test_different_order
|
235
|
+
@command["output_columns"] = "_id"
|
236
|
+
assert_true(same?([[[3], [["_id", "UInt32"]], [1], [2], [3]]],
|
237
|
+
[[[3], [["_id", "UInt32"]], [3], [2], [1]]],
|
238
|
+
:care_order => false))
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
232
242
|
class ErrorTest < self
|
233
243
|
def test_with_location
|
234
244
|
response1_header = [
|
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.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: groonga-command-parser
|
@@ -211,6 +211,7 @@ files:
|
|
211
211
|
- lib/groonga/query-log/response-comparer.rb
|
212
212
|
- lib/groonga/query-log/server-verifier.rb
|
213
213
|
- lib/groonga/query-log/version.rb
|
214
|
+
- test/command/test-extract.rb
|
214
215
|
- test/command/test-format-regression-test-logs.rb
|
215
216
|
- test/fixtures/multi.expected
|
216
217
|
- test/fixtures/n_entries.expected
|
@@ -230,7 +231,6 @@ files:
|
|
230
231
|
- test/helper.rb
|
231
232
|
- test/run-test.rb
|
232
233
|
- test/test-analyzer.rb
|
233
|
-
- test/test-extractor.rb
|
234
234
|
- test/test-incompatibility-detector.rb
|
235
235
|
- test/test-parser.rb
|
236
236
|
- test/test-replayer.rb
|
@@ -266,6 +266,7 @@ test_files:
|
|
266
266
|
- test/test-analyzer.rb
|
267
267
|
- test/test-parser.rb
|
268
268
|
- test/test-response-comparer.rb
|
269
|
+
- test/command/test-extract.rb
|
269
270
|
- test/command/test-format-regression-test-logs.rb
|
270
271
|
- test/fixtures/other-query.log
|
271
272
|
- test/fixtures/reporter/console.expected
|
@@ -285,6 +286,5 @@ test_files:
|
|
285
286
|
- test/helper.rb
|
286
287
|
- test/run-test.rb
|
287
288
|
- test/test-incompatibility-detector.rb
|
288
|
-
- test/test-extractor.rb
|
289
289
|
- test/test-replayer.rb
|
290
290
|
has_rdoc:
|