grntest 1.3.1 → 1.3.2
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 +6 -0
- data/grntest.gemspec +6 -4
- data/lib/grntest/executors/base-executor.rb +59 -12
- data/lib/grntest/test-runner.rb +10 -8
- data/lib/grntest/version.rb +1 -1
- metadata +36 -12
- data/lib/grntest/log-entry.rb +0 -19
- data/lib/grntest/log-parser.rb +0 -48
- data/lib/grntest/query-log-entry.rb +0 -19
- data/lib/grntest/query-log-parser.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dde3b6cf798791dc6aeafd6b352238f07c7380203fee2e8972593fec9bfc6f7
|
4
|
+
data.tar.gz: 6b12f9e76f353417c5ad8c195db96a17029fd52ee8322c4d683215db17245758
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 314b08a7d51b374159b9dc0e325b17c3c2b12e981e2508e7266132bb9e91c6ec4c2d7694d6d23435412595caf703a62a3980a7193842fc967f4f20a60c7650a1
|
7
|
+
data.tar.gz: 5d628089f0b428905fce39011c1acb827fca80932bcb139f632f891665a3bad0d3a74f7c1b403bab791c67c518f69e7c3065ee3f285dbab6d955cf02693f72f9
|
data/doc/text/news.md
CHANGED
data/grntest.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# -*-
|
1
|
+
# -*- ruby -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2012-
|
3
|
+
# Copyright (C) 2012-2019 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
#
|
5
5
|
# This program is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU General Public License as published by
|
@@ -43,10 +43,12 @@ Gem::Specification.new do |spec|
|
|
43
43
|
spec.executables = Dir.glob("*")
|
44
44
|
end
|
45
45
|
|
46
|
-
spec.add_runtime_dependency("json")
|
47
|
-
spec.add_runtime_dependency("msgpack")
|
48
46
|
spec.add_runtime_dependency("diff-lcs")
|
49
47
|
spec.add_runtime_dependency("groonga-command-parser")
|
48
|
+
spec.add_runtime_dependency("groonga-log")
|
49
|
+
spec.add_runtime_dependency("groonga-query-log", ">= 1.4.1")
|
50
|
+
spec.add_runtime_dependency("json")
|
51
|
+
spec.add_runtime_dependency("msgpack")
|
50
52
|
|
51
53
|
spec.add_development_dependency("bundler")
|
52
54
|
spec.add_development_dependency("rake")
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-
|
1
|
+
# Copyright (C) 2012-2019 Kouhei Sutou <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This program is free software: you can redistribute it and/or modify
|
4
4
|
# it under the terms of the GNU General Public License as published by
|
@@ -17,11 +17,11 @@ require "pathname"
|
|
17
17
|
require "fileutils"
|
18
18
|
require "shellwords"
|
19
19
|
|
20
|
+
require "groonga-log"
|
21
|
+
require "groonga-query-log"
|
20
22
|
require "groonga/command/parser"
|
21
23
|
|
22
24
|
require "grntest/error"
|
23
|
-
require "grntest/log-parser"
|
24
|
-
require "grntest/query-log-parser"
|
25
25
|
require "grntest/execution-context"
|
26
26
|
require "grntest/response-parser"
|
27
27
|
require "grntest/template-evaluator"
|
@@ -277,7 +277,11 @@ module Grntest
|
|
277
277
|
end
|
278
278
|
|
279
279
|
def normalize_log_level(level)
|
280
|
-
level
|
280
|
+
case level
|
281
|
+
when "info"
|
282
|
+
level = "information"
|
283
|
+
end
|
284
|
+
level.to_sym
|
281
285
|
end
|
282
286
|
|
283
287
|
def execute_directive_sleep(line, content, options)
|
@@ -424,10 +428,10 @@ module Grntest
|
|
424
428
|
|
425
429
|
def extract_important_messages(log)
|
426
430
|
important_messages = []
|
427
|
-
parser =
|
431
|
+
parser = GroongaLog::Parser.new
|
428
432
|
in_crash = false
|
429
433
|
parser.parse(log) do |entry|
|
430
|
-
if entry.log_level ==
|
434
|
+
if entry.log_level == :critical
|
431
435
|
case entry.message
|
432
436
|
when "-- CRASHED!!! --"
|
433
437
|
in_crash = true
|
@@ -441,7 +445,8 @@ module Grntest
|
|
441
445
|
next if !in_crash and backtrace_log_message?(entry.message)
|
442
446
|
end
|
443
447
|
next if thread_log_message?(entry.message)
|
444
|
-
|
448
|
+
formatted_log_level = format_log_level(entry.log_level)
|
449
|
+
important_messages << "\#|#{formatted_log_level}| #{entry.message}"
|
445
450
|
end
|
446
451
|
important_messages.join("\n")
|
447
452
|
end
|
@@ -462,8 +467,37 @@ module Grntest
|
|
462
467
|
end
|
463
468
|
|
464
469
|
def important_log_level?(log_level)
|
465
|
-
|
466
|
-
|
470
|
+
case log_level
|
471
|
+
when :emergency, :alert, :critical, :error, :warning
|
472
|
+
true
|
473
|
+
when *@custom_important_log_levels
|
474
|
+
true
|
475
|
+
else
|
476
|
+
false
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
480
|
+
def format_log_level(log_level)
|
481
|
+
case log_level
|
482
|
+
when :emergency
|
483
|
+
"E"
|
484
|
+
when :alert
|
485
|
+
"A"
|
486
|
+
when :critical
|
487
|
+
"C"
|
488
|
+
when :error
|
489
|
+
"e"
|
490
|
+
when :warning
|
491
|
+
"w"
|
492
|
+
when :notice
|
493
|
+
"n"
|
494
|
+
when :information
|
495
|
+
"i"
|
496
|
+
when :debug
|
497
|
+
"d"
|
498
|
+
when :dump
|
499
|
+
"-"
|
500
|
+
end
|
467
501
|
end
|
468
502
|
|
469
503
|
def backtrace_log_message?(message)
|
@@ -539,9 +573,22 @@ module Grntest
|
|
539
573
|
def log_query_log_content(content)
|
540
574
|
return unless @context.collect_query_log?
|
541
575
|
|
542
|
-
parser =
|
543
|
-
parser.parse(content) do |
|
544
|
-
|
576
|
+
parser = GroongaQueryLog::Parser.new
|
577
|
+
parser.parse(content) do |statistic|
|
578
|
+
relative_elapsed_time = "000000000000000"
|
579
|
+
command = statistic.command
|
580
|
+
if command
|
581
|
+
command[:output_type] = nil if command.output_type == :json
|
582
|
+
log_query("\#>#{command.to_command_format}")
|
583
|
+
end
|
584
|
+
statistic.each_operation do |operation|
|
585
|
+
message = operation[:raw_message]
|
586
|
+
if operation[:name] == "cache"
|
587
|
+
message = message.gsub(/\(\d+\)/, "(0)")
|
588
|
+
end
|
589
|
+
log_query("\#:#{relative_elapsed_time} #{message}")
|
590
|
+
end
|
591
|
+
log_query("\#<#{relative_elapsed_time} rc=#{statistic.return_code}")
|
545
592
|
end
|
546
593
|
end
|
547
594
|
|
data/lib/grntest/test-runner.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-
|
1
|
+
# Copyright (C) 2012-2019 Kouhei Sutou <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This program is free software: you can redistribute it and/or modify
|
4
4
|
# it under the terms of the GNU General Public License as published by
|
@@ -19,11 +19,11 @@ require "tempfile"
|
|
19
19
|
require "timeout"
|
20
20
|
require "socket"
|
21
21
|
|
22
|
+
require "groonga-log"
|
22
23
|
require "json"
|
23
24
|
|
24
25
|
require "grntest/platform"
|
25
26
|
require "grntest/error"
|
26
|
-
require "grntest/log-parser"
|
27
27
|
require "grntest/executors"
|
28
28
|
require "grntest/base-result"
|
29
29
|
|
@@ -379,11 +379,13 @@ call chdir("#{context.temporary_directory_path}")
|
|
379
379
|
end
|
380
380
|
yield(executor)
|
381
381
|
ensure
|
382
|
-
if
|
383
|
-
pid
|
384
|
-
|
385
|
-
|
386
|
-
|
382
|
+
if pid
|
383
|
+
if executor.shutdown(pid)
|
384
|
+
pid = nil
|
385
|
+
else
|
386
|
+
wait_groonga_http_shutdown(pid_file_path)
|
387
|
+
pid = nil if wait_pid(pid)
|
388
|
+
end
|
387
389
|
end
|
388
390
|
end
|
389
391
|
ensure
|
@@ -806,7 +808,7 @@ http {
|
|
806
808
|
end
|
807
809
|
|
808
810
|
def check_memory_leak(context)
|
809
|
-
parser =
|
811
|
+
parser = GroongaLog::Parser.new
|
810
812
|
parser.parse(context.log) do |entry|
|
811
813
|
next unless /^grn_fin \((\d+)\)$/ =~ entry.message
|
812
814
|
n_leaked_objects = $1.to_i
|
data/lib/grntest/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grntest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: diff-lcs
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: groonga-command-parser
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: groonga-log
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
@@ -54,7 +54,35 @@ dependencies:
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name: groonga-
|
57
|
+
name: groonga-query-log
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.4.1
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.4.1
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: json
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: msgpack
|
58
86
|
requirement: !ruby/object:Gem::Requirement
|
59
87
|
requirements:
|
60
88
|
- - ">="
|
@@ -176,11 +204,7 @@ files:
|
|
176
204
|
- lib/grntest/executors/base-executor.rb
|
177
205
|
- lib/grntest/executors/http-executor.rb
|
178
206
|
- lib/grntest/executors/standard-io-executor.rb
|
179
|
-
- lib/grntest/log-entry.rb
|
180
|
-
- lib/grntest/log-parser.rb
|
181
207
|
- lib/grntest/platform.rb
|
182
|
-
- lib/grntest/query-log-entry.rb
|
183
|
-
- lib/grntest/query-log-parser.rb
|
184
208
|
- lib/grntest/reporters.rb
|
185
209
|
- lib/grntest/reporters/base-reporter.rb
|
186
210
|
- lib/grntest/reporters/buffered-mark-reporter.rb
|
@@ -219,13 +243,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
243
|
version: '0'
|
220
244
|
requirements: []
|
221
245
|
rubyforge_project:
|
222
|
-
rubygems_version:
|
246
|
+
rubygems_version: 2.7.6.2
|
223
247
|
signing_key:
|
224
248
|
specification_version: 4
|
225
249
|
summary: Grntest is a testing framework for Groonga. You can write a test for Groonga
|
226
250
|
by writing Groonga commands and expected result.
|
227
251
|
test_files:
|
252
|
+
- test/test-log-parser.rb
|
228
253
|
- test/run-test.rb
|
229
254
|
- test/executors/test-base-executor.rb
|
230
255
|
- test/executors/test-standard-io-executor.rb
|
231
|
-
- test/test-log-parser.rb
|
data/lib/grntest/log-entry.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# Copyright (C) 2014 Kouhei Sutou <kou@clear-code.com>
|
2
|
-
#
|
3
|
-
# This program is free software: you can redistribute it and/or modify
|
4
|
-
# it under the terms of the GNU General Public License as published by
|
5
|
-
# the Free Software Foundation, either version 3 of the License, or
|
6
|
-
# (at your option) any later version.
|
7
|
-
#
|
8
|
-
# This program is distributed in the hope that it will be useful,
|
9
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
-
# GNU General Public License for more details.
|
12
|
-
#
|
13
|
-
# You should have received a copy of the GNU General Public License
|
14
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
-
|
16
|
-
module Grntest
|
17
|
-
class LogEntry < Struct.new(:timestamp, :log_level, :message)
|
18
|
-
end
|
19
|
-
end
|
data/lib/grntest/log-parser.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# Copyright (C) 2014 Kouhei Sutou <kou@clear-code.com>
|
2
|
-
#
|
3
|
-
# This program is free software: you can redistribute it and/or modify
|
4
|
-
# it under the terms of the GNU General Public License as published by
|
5
|
-
# the Free Software Foundation, either version 3 of the License, or
|
6
|
-
# (at your option) any later version.
|
7
|
-
#
|
8
|
-
# This program is distributed in the hope that it will be useful,
|
9
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
-
# GNU General Public License for more details.
|
12
|
-
#
|
13
|
-
# You should have received a copy of the GNU General Public License
|
14
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
-
|
16
|
-
require "grntest/log-entry"
|
17
|
-
|
18
|
-
module Grntest
|
19
|
-
class LogParser
|
20
|
-
def parse(log)
|
21
|
-
timestamp = nil
|
22
|
-
log_level = nil
|
23
|
-
message = nil
|
24
|
-
emit_entry = lambda do
|
25
|
-
if timestamp
|
26
|
-
entry = LogEntry.new(timestamp, log_level, message.chomp)
|
27
|
-
yield(entry)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
log.each_line do |line|
|
31
|
-
case line
|
32
|
-
when /\A(\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2}\.\d+)\|
|
33
|
-
([a-zA-Z])\|
|
34
|
-
(?:\d+:)?
|
35
|
-
\s*/x
|
36
|
-
emit_entry.call
|
37
|
-
timestamp = $1
|
38
|
-
log_level = $2
|
39
|
-
message = $POSTMATCH
|
40
|
-
else
|
41
|
-
message ||= ""
|
42
|
-
message << line
|
43
|
-
end
|
44
|
-
end
|
45
|
-
emit_entry.call
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# Copyright (C) 2015 Kouhei Sutou <kou@clear-code.com>
|
2
|
-
#
|
3
|
-
# This program is free software: you can redistribute it and/or modify
|
4
|
-
# it under the terms of the GNU General Public License as published by
|
5
|
-
# the Free Software Foundation, either version 3 of the License, or
|
6
|
-
# (at your option) any later version.
|
7
|
-
#
|
8
|
-
# This program is distributed in the hope that it will be useful,
|
9
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
-
# GNU General Public License for more details.
|
12
|
-
#
|
13
|
-
# You should have received a copy of the GNU General Public License
|
14
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
-
|
16
|
-
module Grntest
|
17
|
-
class QueryLogEntry < Struct.new(:timestamp, :mark, :message)
|
18
|
-
end
|
19
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# Copyright (C) 2015-2017 Kouhei Sutou <kou@clear-code.com>
|
2
|
-
#
|
3
|
-
# This program is free software: you can redistribute it and/or modify
|
4
|
-
# it under the terms of the GNU General Public License as published by
|
5
|
-
# the Free Software Foundation, either version 3 of the License, or
|
6
|
-
# (at your option) any later version.
|
7
|
-
#
|
8
|
-
# This program is distributed in the hope that it will be useful,
|
9
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
-
# GNU General Public License for more details.
|
12
|
-
#
|
13
|
-
# You should have received a copy of the GNU General Public License
|
14
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
-
|
16
|
-
require "grntest/query-log-entry"
|
17
|
-
|
18
|
-
module Grntest
|
19
|
-
class QueryLogParser
|
20
|
-
def parse(log)
|
21
|
-
log.each_line do |line|
|
22
|
-
case line
|
23
|
-
when /\A(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+)\|.+?\|(.)/
|
24
|
-
timestamp = $1
|
25
|
-
mark = $2
|
26
|
-
message = normalize_message(mark, $POSTMATCH.chomp)
|
27
|
-
entry = QueryLogEntry.new(timestamp, mark, message)
|
28
|
-
yield(entry)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
def normalize_message(mark, message)
|
35
|
-
case mark
|
36
|
-
when ">"
|
37
|
-
message = normalize_command(message)
|
38
|
-
else
|
39
|
-
message = normalize_elapsed_time(message)
|
40
|
-
message = normalize_cache_content(message)
|
41
|
-
end
|
42
|
-
message
|
43
|
-
end
|
44
|
-
|
45
|
-
def normalize_command(message)
|
46
|
-
command = nil
|
47
|
-
Groonga::Command::Parser.parse(message) do |status, *args|
|
48
|
-
case status
|
49
|
-
when :on_command
|
50
|
-
command = args[0]
|
51
|
-
when :on_load_start
|
52
|
-
command = args[0]
|
53
|
-
end
|
54
|
-
end
|
55
|
-
if command.output_type == :json
|
56
|
-
command[:output_type] = nil
|
57
|
-
end
|
58
|
-
command.to_command_format
|
59
|
-
end
|
60
|
-
|
61
|
-
def normalize_elapsed_time(message)
|
62
|
-
message.gsub(/\A\d{15} /, "0" * 15 + " ")
|
63
|
-
end
|
64
|
-
|
65
|
-
def normalize_cache_content(message)
|
66
|
-
message.gsub(/\A(0{15}) (cache\()\d+(\))\z/) do
|
67
|
-
"#{$1} #{$2}0#{$3}"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|