drntest 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +7 -2
- data/drntest.gemspec +3 -1
- data/lib/drntest/{path.rb → configuration.rb} +23 -4
- data/lib/drntest/engine.rb +136 -0
- data/lib/drntest/response-normalizer.rb +32 -12
- data/lib/drntest/test-executor.rb +21 -11
- data/lib/drntest/test-loader.rb +4 -6
- data/lib/drntest/test-results.rb +10 -13
- data/lib/drntest/test-runner.rb +26 -124
- data/lib/drntest/tester.rb +78 -83
- data/lib/drntest/version.rb +1 -1
- metadata +41 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b3b80ccd126e2d0a6a7ad3e382dba7b649e8bdd
|
4
|
+
data.tar.gz: 357a79d56578bbcd180923738cb4347b939b1da7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6be667ad7d2f5cc435c094c598290e70f91711c846daa547fe68351972b2084aff707b0ad3558fa59dfe154f8a67d4442bf8f88b65391e07e45cc689bb273ccf
|
7
|
+
data.tar.gz: 4e89a601e6f3f91a71eaeb488d0155fa8a27a07a2d7e4f9fdfe50e8aedec952914acce61ea8ada086c9458da253b89a0724d2a143d96e7dff7243fa55e56a42c
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- mode: ruby; coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013 Droonga Project
|
3
|
+
# Copyright (C) 2013-2014 Droonga Project
|
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
|
@@ -17,8 +17,8 @@
|
|
17
17
|
|
18
18
|
task :default => :test
|
19
19
|
|
20
|
-
require "rubygems"
|
21
20
|
require "bundler/gem_helper"
|
21
|
+
require "packnga"
|
22
22
|
|
23
23
|
base_dir = File.join(File.dirname(__FILE__))
|
24
24
|
|
@@ -30,6 +30,11 @@ end
|
|
30
30
|
helper.install
|
31
31
|
spec = helper.gemspec
|
32
32
|
|
33
|
+
Packnga::DocumentTask.new(spec) do |task|
|
34
|
+
task.original_language = "en"
|
35
|
+
task.translate_languages = ["ja"]
|
36
|
+
end
|
37
|
+
|
33
38
|
desc "Run tests"
|
34
39
|
task :test do
|
35
40
|
# No test
|
data/drntest.gemspec
CHANGED
@@ -42,8 +42,10 @@ Gem::Specification.new do |spec|
|
|
42
42
|
|
43
43
|
spec.add_runtime_dependency("json")
|
44
44
|
spec.add_runtime_dependency("yajl-ruby")
|
45
|
-
spec.add_runtime_dependency("droonga-client", ">= 0.1.
|
45
|
+
spec.add_runtime_dependency("droonga-client", ">= 0.1.1")
|
46
46
|
|
47
47
|
spec.add_development_dependency("bundler")
|
48
48
|
spec.add_development_dependency("rake")
|
49
|
+
spec.add_development_dependency("packnga")
|
50
|
+
spec.add_development_dependency("kramdown")
|
49
51
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C)
|
1
|
+
# Copyright (C) 2014 Droonga Project
|
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
|
@@ -14,8 +14,27 @@
|
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
|
16
16
|
module Drntest
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
class Configuration
|
18
|
+
attr_accessor :port, :host, :tag
|
19
|
+
attr_accessor :base_path, :engine_config
|
20
|
+
attr_accessor :fluentd, :fluentd_options
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@port = 24224
|
24
|
+
@host = "localhost"
|
25
|
+
@tag = "droonga"
|
26
|
+
@base_path = Pathname(Dir.pwd)
|
27
|
+
@engine_config = "default"
|
28
|
+
@fluentd = "fluentd"
|
29
|
+
@fluentd_options = []
|
30
|
+
end
|
31
|
+
|
32
|
+
def suite_path
|
33
|
+
@base_path + "suite"
|
34
|
+
end
|
35
|
+
|
36
|
+
def engine_config_path
|
37
|
+
@base_path + "config" + @engine_config
|
38
|
+
end
|
20
39
|
end
|
21
40
|
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# Copyright (C) 2014 Droonga Project
|
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 "json"
|
17
|
+
require "yajl"
|
18
|
+
require "pathname"
|
19
|
+
require "fileutils"
|
20
|
+
|
21
|
+
module Drntest
|
22
|
+
class Engine
|
23
|
+
def initialize(config)
|
24
|
+
@config = config
|
25
|
+
end
|
26
|
+
|
27
|
+
def start
|
28
|
+
prepare
|
29
|
+
setup
|
30
|
+
end
|
31
|
+
|
32
|
+
def stop
|
33
|
+
teardown
|
34
|
+
end
|
35
|
+
|
36
|
+
def config_file
|
37
|
+
@config.engine_config_path + "fluentd.conf"
|
38
|
+
end
|
39
|
+
|
40
|
+
def catalog_file
|
41
|
+
@config.engine_config_path + "catalog.json"
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def prepare
|
46
|
+
if catalog_file.exist?
|
47
|
+
catalog_json = JSON.parse(catalog_file.read, :symbolize_names => true)
|
48
|
+
zone = catalog_json[:zones].first
|
49
|
+
/\A([^:]+):(\d+)\/(.+)\z/ =~ zone
|
50
|
+
@config.host = "localhost" # $1
|
51
|
+
@config.port = $2.to_i
|
52
|
+
@config.tag = $3
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def setup
|
57
|
+
return unless temporary?
|
58
|
+
|
59
|
+
setup_temporary_dir
|
60
|
+
|
61
|
+
temporary_config = temporary_dir + "fluentd.conf"
|
62
|
+
FileUtils.cp(config_file, temporary_config)
|
63
|
+
temporary_catalog = temporary_dir + "catalog.json"
|
64
|
+
FileUtils.cp(catalog_file, temporary_catalog)
|
65
|
+
|
66
|
+
command = [
|
67
|
+
@config.fluentd,
|
68
|
+
"--config", temporary_config.to_s,
|
69
|
+
*@config.fluentd_options,
|
70
|
+
]
|
71
|
+
env = {
|
72
|
+
"DROONGA_CATALOG" => temporary_catalog.to_s,
|
73
|
+
}
|
74
|
+
options = {
|
75
|
+
:chdir => temporary_dir.to_s,
|
76
|
+
STDERR => STDOUT,
|
77
|
+
}
|
78
|
+
arguments = [env, *command]
|
79
|
+
arguments << options
|
80
|
+
@pid = Process.spawn(*arguments)
|
81
|
+
|
82
|
+
wait_until_ready
|
83
|
+
end
|
84
|
+
|
85
|
+
def teardown
|
86
|
+
return unless temporary?
|
87
|
+
|
88
|
+
Process.kill(:TERM, @pid)
|
89
|
+
Process.wait(@pid)
|
90
|
+
|
91
|
+
teardown_temporary_dir
|
92
|
+
end
|
93
|
+
|
94
|
+
def setup_temporary_dir
|
95
|
+
tmpfs = Pathname("/run/shm")
|
96
|
+
if tmpfs.directory? and tmpfs.writable?
|
97
|
+
FileUtils.rm_rf(temporary_base_dir)
|
98
|
+
FileUtils.ln_s(tmpfs.to_s, temporary_base_dir.to_s)
|
99
|
+
end
|
100
|
+
FileUtils.rm_rf(temporary_dir)
|
101
|
+
FileUtils.mkdir_p(temporary_dir)
|
102
|
+
end
|
103
|
+
|
104
|
+
def teardown_temporary_dir
|
105
|
+
FileUtils.rm_rf(temporary_dir.to_s)
|
106
|
+
end
|
107
|
+
|
108
|
+
def temporary_base_dir
|
109
|
+
@config.base_path + "tmp"
|
110
|
+
end
|
111
|
+
|
112
|
+
def temporary_dir
|
113
|
+
temporary_base_dir + "drntest"
|
114
|
+
end
|
115
|
+
|
116
|
+
def temporary?
|
117
|
+
@config.fluentd && config_file.exist?
|
118
|
+
end
|
119
|
+
|
120
|
+
def ready?
|
121
|
+
begin
|
122
|
+
socket = TCPSocket.new(@config.host, @config.port)
|
123
|
+
socket.close
|
124
|
+
true
|
125
|
+
rescue Errno::ECONNREFUSED
|
126
|
+
false
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def wait_until_ready
|
131
|
+
until ready?
|
132
|
+
sleep 1
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Droonga Project
|
1
|
+
# Copyright (C) 2013-2014 Droonga Project
|
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
|
@@ -24,28 +24,30 @@ module Drntest
|
|
24
24
|
return @response if @response.nil?
|
25
25
|
|
26
26
|
normalized_response = @response.dup
|
27
|
-
|
28
|
-
|
27
|
+
normalize_fluent_message!(normalized_response)
|
28
|
+
normalize_droonga_message!(normalized_response[2])
|
29
29
|
normalized_response
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
33
|
-
def
|
33
|
+
def normalize_fluent_message!(fluent_message)
|
34
34
|
normalized_start_time = 0
|
35
|
-
|
35
|
+
fluent_message[1] = normalized_start_time
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def normalize_droonga_message!(droonga_message)
|
39
|
+
normalize_droonga_message_envelope!(droonga_message)
|
40
|
+
normalize_droonga_message_body!(droonga_message["body"])
|
41
|
+
end
|
42
|
+
|
43
|
+
def normalize_droonga_message_body!(body)
|
39
44
|
return unless groonga_command?
|
40
|
-
|
41
|
-
normalize_groonga_command_response!(normalized_response[2])
|
42
|
-
rescue StandardError => error
|
43
|
-
p error
|
44
|
-
end
|
45
|
+
normalize_groonga_command_response!(body)
|
45
46
|
end
|
46
47
|
|
47
48
|
GROONGA_COMMANDS = [
|
48
49
|
"table_create",
|
50
|
+
"table_remove",
|
49
51
|
"column_create",
|
50
52
|
"select",
|
51
53
|
]
|
@@ -53,8 +55,26 @@ module Drntest
|
|
53
55
|
GROONGA_COMMANDS.include?(@request["type"])
|
54
56
|
end
|
55
57
|
|
58
|
+
def normalize_droonga_message_envelope!(message)
|
59
|
+
normalized_in_reply_to = "request-id"
|
60
|
+
in_reply_to = message["inReplyTo"]
|
61
|
+
message["inReplyTo"] = normalized_in_reply_to if in_reply_to
|
62
|
+
|
63
|
+
errors = message["errors"]
|
64
|
+
message["errors"] = normalize_errors(errors) if errors
|
65
|
+
end
|
66
|
+
|
67
|
+
def normalize_errors(errors)
|
68
|
+
normalized_errors = {}
|
69
|
+
error_details = errors.values
|
70
|
+
errors.keys.each_with_index do |source, index|
|
71
|
+
normalized_errors["sources#{index}"] = error_details[index]
|
72
|
+
end
|
73
|
+
normalized_errors
|
74
|
+
end
|
75
|
+
|
56
76
|
def normalize_groonga_command_response!(response)
|
57
|
-
normalize_groonga_command_header!(response[
|
77
|
+
normalize_groonga_command_header!(response[0])
|
58
78
|
end
|
59
79
|
|
60
80
|
def normalize_groonga_command_header!(header)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Droonga Project
|
1
|
+
# Copyright (C) 2013-2014 Droonga Project
|
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
|
@@ -20,15 +20,13 @@ require "drntest/response-normalizer"
|
|
20
20
|
|
21
21
|
module Drntest
|
22
22
|
class TestExecutor
|
23
|
-
|
24
|
-
|
25
|
-
def initialize(owner, test_path)
|
26
|
-
@owner = owner
|
23
|
+
def initialize(config, test_path)
|
24
|
+
@config = config
|
27
25
|
@test_path = test_path
|
28
26
|
end
|
29
27
|
|
30
28
|
def execute
|
31
|
-
Droonga::Client.open(tag:
|
29
|
+
Droonga::Client.open(tag: @config.tag, port: @config.port) do |client|
|
32
30
|
context = Context.new(client)
|
33
31
|
operations.each do |operation|
|
34
32
|
context.execute(operation)
|
@@ -40,7 +38,7 @@ module Drntest
|
|
40
38
|
|
41
39
|
private
|
42
40
|
def operations
|
43
|
-
loader = TestLoader.new(@
|
41
|
+
loader = TestLoader.new(@config, @test_path)
|
44
42
|
loader.load
|
45
43
|
end
|
46
44
|
|
@@ -80,11 +78,23 @@ module Drntest
|
|
80
78
|
|
81
79
|
def execute_request(request)
|
82
80
|
if @logging
|
83
|
-
|
84
|
-
|
81
|
+
request_process = @client.request(request) do |response|
|
82
|
+
begin
|
83
|
+
@responses << normalize_response(request, response)
|
84
|
+
rescue
|
85
|
+
@responses << {
|
86
|
+
"error" => {
|
87
|
+
"message" => "failed to normalize response",
|
88
|
+
"detail" => "#{$!.message} (#{$!.class})",
|
89
|
+
"backtrace" => $!.backtrace,
|
90
|
+
"response" => response,
|
91
|
+
},
|
92
|
+
}
|
93
|
+
end
|
94
|
+
end
|
95
|
+
request_process.wait
|
85
96
|
else
|
86
|
-
@requests << @client.
|
87
|
-
:connect_timeout => 2) do
|
97
|
+
@requests << @client.request(request) do
|
88
98
|
end
|
89
99
|
end
|
90
100
|
end
|
data/lib/drntest/test-loader.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Droonga Project
|
1
|
+
# Copyright (C) 2013-2014 Droonga Project
|
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
|
@@ -18,10 +18,8 @@ require "drntest/directive"
|
|
18
18
|
|
19
19
|
module Drntest
|
20
20
|
class TestLoader
|
21
|
-
|
22
|
-
|
23
|
-
def initialize(owner, test_path)
|
24
|
-
@owner = owner
|
21
|
+
def initialize(config, test_path)
|
22
|
+
@config = config
|
25
23
|
@test_path = test_path
|
26
24
|
end
|
27
25
|
|
@@ -33,7 +31,7 @@ module Drntest
|
|
33
31
|
def resolve_relative_path(path)
|
34
32
|
path = path.to_s
|
35
33
|
path = path[2..-1] if path[0..1] == "./"
|
36
|
-
Pathname(path).expand_path(@
|
34
|
+
Pathname(path).expand_path(@config.base_path)
|
37
35
|
end
|
38
36
|
|
39
37
|
def load_test_file(path)
|
data/lib/drntest/test-results.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Droonga Project
|
1
|
+
# Copyright (C) 2013-2014 Droonga Project
|
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
|
@@ -15,27 +15,24 @@
|
|
15
15
|
|
16
16
|
module Drntest
|
17
17
|
class TestResults
|
18
|
-
attr_accessor :name, :actuals, :expecteds
|
18
|
+
attr_accessor :name, :actuals, :expecteds, :errors
|
19
19
|
|
20
20
|
def initialize(name)
|
21
21
|
@name = name
|
22
22
|
@actuals = []
|
23
23
|
@expecteds = []
|
24
|
+
@errors = []
|
24
25
|
end
|
25
26
|
|
26
27
|
def status
|
27
|
-
unless @
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
else
|
35
|
-
:not_checked
|
36
|
-
end
|
28
|
+
return :error unless @errors.empty?
|
29
|
+
return :no_response if @actuals.empty?
|
30
|
+
return :not_checked if @expecteds.empty?
|
31
|
+
|
32
|
+
if @actuals == @expecteds
|
33
|
+
:success
|
37
34
|
else
|
38
|
-
:
|
35
|
+
:failure
|
39
36
|
end
|
40
37
|
end
|
41
38
|
end
|
data/lib/drntest/test-runner.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Droonga Project
|
1
|
+
# Copyright (C) 2013-2014 Droonga Project
|
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,138 +19,40 @@ require "tempfile"
|
|
19
19
|
require "pp"
|
20
20
|
require "fileutils"
|
21
21
|
|
22
|
-
require "drntest/path"
|
23
22
|
require "drntest/test-results"
|
24
23
|
require "drntest/test-executor"
|
25
24
|
require "drntest/json-loader"
|
25
|
+
require "drntest/engine"
|
26
26
|
|
27
27
|
module Drntest
|
28
28
|
class TestRunner
|
29
|
-
|
30
|
-
|
31
|
-
def initialize(owner, target)
|
32
|
-
@owner = owner
|
33
|
-
@base_path = Pathname(owner.base_path)
|
29
|
+
def initialize(config, target)
|
30
|
+
@config = config
|
34
31
|
@target_path = Pathname(target)
|
32
|
+
@engine = Engine.new(@config)
|
35
33
|
end
|
36
34
|
|
37
35
|
def run
|
38
36
|
print "#{@target_path}: "
|
39
|
-
|
40
|
-
setup
|
37
|
+
@engine.start
|
41
38
|
begin
|
42
39
|
results = process_requests
|
43
40
|
ensure
|
44
|
-
|
41
|
+
@engine.stop
|
45
42
|
end
|
46
43
|
results
|
47
44
|
end
|
48
45
|
|
49
|
-
def config_dir
|
50
|
-
(@base_path + Path::CONFIG) + @owner.config
|
51
|
-
end
|
52
|
-
|
53
|
-
def config_file
|
54
|
-
config_dir + "fluentd.conf"
|
55
|
-
end
|
56
|
-
|
57
|
-
def catalog_file
|
58
|
-
config_dir + "catalog.json"
|
59
|
-
end
|
60
|
-
|
61
|
-
def port
|
62
|
-
@port || @owner.port
|
63
|
-
end
|
64
|
-
|
65
|
-
def host
|
66
|
-
@host || @owner.host
|
67
|
-
end
|
68
|
-
|
69
|
-
def tag
|
70
|
-
@tag || @owner.tag
|
71
|
-
end
|
72
|
-
|
73
46
|
private
|
74
|
-
def prepare
|
75
|
-
if catalog_file.exist?
|
76
|
-
catalog_json = JSON.parse(catalog_file.read, :symbolize_names => true)
|
77
|
-
zone = catalog_json[:zones].first
|
78
|
-
/\A([^:]+):(\d+)\/(.+)\z/ =~ zone
|
79
|
-
@host = "localhost" # $1
|
80
|
-
@port = $2.to_i
|
81
|
-
@tag = $3
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def setup
|
86
|
-
return unless temporary_engine?
|
87
|
-
|
88
|
-
setup_temporary_dir
|
89
|
-
|
90
|
-
temporary_config = temporary_dir + "fluentd.conf"
|
91
|
-
FileUtils.cp(config_file, temporary_config)
|
92
|
-
temporary_catalog = temporary_dir + "catalog.json"
|
93
|
-
FileUtils.cp(catalog_file, temporary_catalog)
|
94
|
-
|
95
|
-
engine_command = [
|
96
|
-
@owner.fluentd,
|
97
|
-
"--config", temporary_config.to_s,
|
98
|
-
*@owner.fluentd_options,
|
99
|
-
]
|
100
|
-
engine_env = {
|
101
|
-
"DROONGA_CATALOG" => temporary_catalog.to_s,
|
102
|
-
}
|
103
|
-
engine_options = {
|
104
|
-
:chdir => temporary_dir.to_s,
|
105
|
-
STDERR => STDOUT,
|
106
|
-
}
|
107
|
-
arguments = [engine_env, *engine_command]
|
108
|
-
arguments << engine_options
|
109
|
-
@engine_pid = Process.spawn(*arguments)
|
110
|
-
|
111
|
-
wait_until_engine_ready
|
112
|
-
end
|
113
|
-
|
114
|
-
def teardown
|
115
|
-
return unless temporary_engine?
|
116
|
-
|
117
|
-
Process.kill(:TERM, @engine_pid)
|
118
|
-
Process.wait(@engine_pid)
|
119
|
-
|
120
|
-
teardown_temporary_dir
|
121
|
-
end
|
122
|
-
|
123
|
-
def setup_temporary_dir
|
124
|
-
tmpfs = Pathname("/run/shm")
|
125
|
-
if tmpfs.directory? and tmpfs.writable?
|
126
|
-
FileUtils.rm_rf(temporary_base_dir)
|
127
|
-
FileUtils.ln_s(tmpfs.to_s, temporary_base_dir.to_s)
|
128
|
-
end
|
129
|
-
FileUtils.rm_rf(temporary_dir)
|
130
|
-
FileUtils.mkdir_p(temporary_dir)
|
131
|
-
end
|
132
|
-
|
133
|
-
def teardown_temporary_dir
|
134
|
-
FileUtils.rm_rf(temporary_dir.to_s)
|
135
|
-
end
|
136
|
-
|
137
|
-
def temporary_base_dir
|
138
|
-
@base_path + "tmp"
|
139
|
-
end
|
140
|
-
|
141
|
-
def temporary_dir
|
142
|
-
temporary_base_dir + "drntest"
|
143
|
-
end
|
144
|
-
|
145
|
-
def temporary_engine?
|
146
|
-
@owner.fluentd && config_file.exist?
|
147
|
-
end
|
148
|
-
|
149
47
|
def process_requests
|
150
48
|
results = TestResults.new(@target_path)
|
151
49
|
|
152
|
-
executor = TestExecutor.new(
|
153
|
-
|
50
|
+
executor = TestExecutor.new(@config, @target_path)
|
51
|
+
begin
|
52
|
+
results.actuals = executor.execute
|
53
|
+
rescue
|
54
|
+
results.errors << $!
|
55
|
+
end
|
154
56
|
if expected_exist?
|
155
57
|
results.expecteds = load_expected_responses
|
156
58
|
end
|
@@ -168,6 +70,9 @@ module Drntest
|
|
168
70
|
when :not_checked
|
169
71
|
puts "NOT CHECKED"
|
170
72
|
output_actual_file(results.actuals)
|
73
|
+
when :error
|
74
|
+
puts "ERROR"
|
75
|
+
output_errors(results.errors)
|
171
76
|
end
|
172
77
|
|
173
78
|
results
|
@@ -260,19 +165,16 @@ module Drntest
|
|
260
165
|
yield(file)
|
261
166
|
end
|
262
167
|
|
263
|
-
def
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
def wait_until_engine_ready
|
274
|
-
until engine_ready?
|
275
|
-
sleep 1
|
168
|
+
def output_errors(errors)
|
169
|
+
return if errors.empty?
|
170
|
+
n_digits = (Math.log10(errors.size) + 1).ceil
|
171
|
+
mark = "=" * 78
|
172
|
+
errors.each_with_index do |error, i|
|
173
|
+
puts(mark)
|
174
|
+
formatted_nth = "%*d)" % [n_digits, i + 1]
|
175
|
+
puts("#{formatted_nth} #{error.message} (#{error.class})")
|
176
|
+
puts(error.backtrace)
|
177
|
+
puts(mark)
|
276
178
|
end
|
277
179
|
end
|
278
180
|
end
|
data/lib/drntest/tester.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Droonga Project
|
1
|
+
# Copyright (C) 2013-2014 Droonga Project
|
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
|
@@ -18,7 +18,7 @@ require "optparse"
|
|
18
18
|
require "pathname"
|
19
19
|
|
20
20
|
require "drntest/version"
|
21
|
-
require "drntest/
|
21
|
+
require "drntest/configuration"
|
22
22
|
require "drntest/test-runner"
|
23
23
|
require "drntest/test-suites-result"
|
24
24
|
|
@@ -28,99 +28,27 @@ module Drntest
|
|
28
28
|
def run(argv=nil)
|
29
29
|
argv ||= ARGV.dup
|
30
30
|
tester = new
|
31
|
-
|
32
|
-
targets = option_parser.parse!(argv)
|
31
|
+
*targets = tester.parse_command_line_options(argv)
|
33
32
|
tester.run(*targets)
|
34
33
|
end
|
35
|
-
|
36
|
-
private
|
37
|
-
def create_option_parser(tester)
|
38
|
-
parser = OptionParser.new
|
39
|
-
|
40
|
-
parser.banner += " TEST_FILE..."
|
41
|
-
|
42
|
-
parser.on("--port=PORT",
|
43
|
-
"Connect to fluent-plugin-droonga on PORT",
|
44
|
-
"(#{tester.port})") do |port|
|
45
|
-
tester.port = port
|
46
|
-
end
|
47
|
-
|
48
|
-
parser.on("--host=HOST",
|
49
|
-
"Connect to fluent-plugin-droonga on HOST",
|
50
|
-
"(#{tester.host})") do |host|
|
51
|
-
tester.host = host
|
52
|
-
end
|
53
|
-
|
54
|
-
parser.on("--tag=TAG",
|
55
|
-
"Send messages to fluent-plugin-droonga with TAG",
|
56
|
-
"(#{tester.tag})") do |tag|
|
57
|
-
tester.tag = tag
|
58
|
-
end
|
59
|
-
|
60
|
-
parser.on("--base-path=PATH",
|
61
|
-
"Path to the base directory including test suite, config and fixture",
|
62
|
-
"(#{tester.base_path})") do |base_path|
|
63
|
-
tester.base_path = Pathname(base_path).expand_path(Dir.pwd)
|
64
|
-
end
|
65
|
-
|
66
|
-
parser.on("--config=NAME",
|
67
|
-
"Name of the configuration directory for Droonga engine",
|
68
|
-
"(#{tester.config})") do |config|
|
69
|
-
tester.config = config
|
70
|
-
end
|
71
|
-
|
72
|
-
parser.on("--fluentd=PATH",
|
73
|
-
"Path to the fluentd executable",
|
74
|
-
"(#{tester.fluentd})") do |fluentd|
|
75
|
-
tester.fluentd = fluentd
|
76
|
-
end
|
77
|
-
|
78
|
-
parser.on("--fluentd-options=OPTIONS",
|
79
|
-
"Options for fluentd",
|
80
|
-
"You can specify this option multiple times") do |options|
|
81
|
-
tester.fluentd_options.concat(Shellwords.split(options))
|
82
|
-
end
|
83
|
-
|
84
|
-
parser.on("--test=PATTERN",
|
85
|
-
"Run only tests which have a name matched to the given PATTERN") do |pattern|
|
86
|
-
if /\A\/(.+)\/\z/ =~ pattern
|
87
|
-
pattern = Regexp.new($1)
|
88
|
-
end
|
89
|
-
tester.test_pattern = pattern
|
90
|
-
end
|
91
|
-
|
92
|
-
parser.on("--test-suite=PATTERN",
|
93
|
-
"Run only test suites which have a path matched to the given PATTERN") do |pattern|
|
94
|
-
if /\A\/(.+)\/\z/ =~ pattern
|
95
|
-
pattern = Regexp.new($1)
|
96
|
-
end
|
97
|
-
tester.suite_pattern = pattern
|
98
|
-
end
|
99
|
-
|
100
|
-
parser
|
101
|
-
end
|
102
34
|
end
|
103
35
|
|
104
|
-
attr_accessor :port, :host, :tag, :fluentd, :fluentd_options
|
105
|
-
attr_accessor :test_pattern, :suite_pattern, :base_path, :config
|
106
|
-
|
107
36
|
def initialize
|
108
|
-
@
|
109
|
-
@host = "localhost"
|
110
|
-
@tag = "droonga"
|
111
|
-
@base_path = Pathname(Dir.pwd)
|
112
|
-
@config = "default"
|
113
|
-
@fluentd = "fluentd"
|
114
|
-
@fluentd_options = []
|
37
|
+
@config = Configuration.new
|
115
38
|
@test_pattern = nil
|
116
39
|
@suite_pattern = nil
|
117
40
|
end
|
118
41
|
|
42
|
+
def parse_command_line_options(command_line_options)
|
43
|
+
option_parser = create_option_parser
|
44
|
+
option_parser.parse!(command_line_options)
|
45
|
+
end
|
46
|
+
|
119
47
|
def run(*targets)
|
120
48
|
test_suites_result = TestSuitesResult.new
|
121
49
|
tests = load_tests(*targets)
|
122
50
|
tests.each do |test|
|
123
|
-
test_runner = TestRunner.new(
|
51
|
+
test_runner = TestRunner.new(@config, test)
|
124
52
|
test_suites_result.test_results << test_runner.run
|
125
53
|
end
|
126
54
|
|
@@ -140,8 +68,75 @@ module Drntest
|
|
140
68
|
test_suites_result.success?
|
141
69
|
end
|
142
70
|
|
71
|
+
private
|
72
|
+
def create_option_parser
|
73
|
+
parser = OptionParser.new
|
74
|
+
|
75
|
+
parser.banner += " TEST_FILE..."
|
76
|
+
|
77
|
+
parser.on("--port=PORT",
|
78
|
+
"Connect to fluent-plugin-droonga on PORT",
|
79
|
+
"(#{@config.port})") do |port|
|
80
|
+
@config.port = port
|
81
|
+
end
|
82
|
+
|
83
|
+
parser.on("--host=HOST",
|
84
|
+
"Connect to fluent-plugin-droonga on HOST",
|
85
|
+
"(#{@config.host})") do |host|
|
86
|
+
@config.host = host
|
87
|
+
end
|
88
|
+
|
89
|
+
parser.on("--tag=TAG",
|
90
|
+
"Send messages to fluent-plugin-droonga with TAG",
|
91
|
+
"(#{@config.tag})") do |tag|
|
92
|
+
@config.tag = tag
|
93
|
+
end
|
94
|
+
|
95
|
+
parser.on("--base-path=PATH",
|
96
|
+
"Path to the base directory including test suite, config and fixture",
|
97
|
+
"(#{@config.base_path})") do |base_path|
|
98
|
+
@config.base_path = Pathname(base_path).expand_path(Dir.pwd)
|
99
|
+
end
|
100
|
+
|
101
|
+
parser.on("--config=NAME",
|
102
|
+
"Name of the configuration directory for Droonga engine",
|
103
|
+
"(#{@config.engine_config})") do |config|
|
104
|
+
@config.engine_config = config
|
105
|
+
end
|
106
|
+
|
107
|
+
parser.on("--fluentd=PATH",
|
108
|
+
"Path to the fluentd executable",
|
109
|
+
"(#{@config.fluentd})") do |fluentd|
|
110
|
+
@config.fluentd = fluentd
|
111
|
+
end
|
112
|
+
|
113
|
+
parser.on("--fluentd-options=OPTIONS",
|
114
|
+
"Options for fluentd",
|
115
|
+
"You can specify this option multiple times") do |options|
|
116
|
+
@config.fluentd_options.concat(Shellwords.split(options))
|
117
|
+
end
|
118
|
+
|
119
|
+
parser.on("--test=PATTERN",
|
120
|
+
"Run only tests which have a name matched to the given PATTERN") do |pattern|
|
121
|
+
if /\A\/(.+)\/\z/ =~ pattern
|
122
|
+
pattern = Regexp.new($1)
|
123
|
+
end
|
124
|
+
@test_pattern = pattern
|
125
|
+
end
|
126
|
+
|
127
|
+
parser.on("--test-suite=PATTERN",
|
128
|
+
"Run only test suites which have a path matched to the given PATTERN") do |pattern|
|
129
|
+
if /\A\/(.+)\/\z/ =~ pattern
|
130
|
+
pattern = Regexp.new($1)
|
131
|
+
end
|
132
|
+
@suite_pattern = pattern
|
133
|
+
end
|
134
|
+
|
135
|
+
parser
|
136
|
+
end
|
137
|
+
|
143
138
|
def load_tests(*targets)
|
144
|
-
suite_path = @
|
139
|
+
suite_path = @config.suite_path
|
145
140
|
targets << suite_path if targets.empty?
|
146
141
|
|
147
142
|
tests = []
|
data/lib/drntest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drntest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Droonga Project
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.
|
47
|
+
version: 0.1.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.1.
|
54
|
+
version: 0.1.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: packnga
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: kramdown
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
83
111
|
description: ''
|
84
112
|
email:
|
85
113
|
- droonga@groonga.org
|
@@ -92,17 +120,18 @@ files:
|
|
92
120
|
- Rakefile
|
93
121
|
- Gemfile
|
94
122
|
- drntest.gemspec
|
95
|
-
- lib/drntest/test-
|
96
|
-
- lib/drntest/
|
123
|
+
- lib/drntest/test-runner.rb
|
124
|
+
- lib/drntest/tester.rb
|
97
125
|
- lib/drntest/directive.rb
|
98
|
-
- lib/drntest/
|
99
|
-
- lib/drntest/
|
126
|
+
- lib/drntest/version.rb
|
127
|
+
- lib/drntest/test-results.rb
|
100
128
|
- lib/drntest/test-loader.rb
|
101
|
-
- lib/drntest/
|
102
|
-
- lib/drntest/
|
103
|
-
- lib/drntest/
|
104
|
-
- lib/drntest/test-runner.rb
|
129
|
+
- lib/drntest/configuration.rb
|
130
|
+
- lib/drntest/json-loader.rb
|
131
|
+
- lib/drntest/test-suites-result.rb
|
105
132
|
- lib/drntest/test-executor.rb
|
133
|
+
- lib/drntest/response-normalizer.rb
|
134
|
+
- lib/drntest/engine.rb
|
106
135
|
- bin/drntest
|
107
136
|
homepage: https://github.com/droonga/drntest
|
108
137
|
licenses:
|