drntest 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/drntest.gemspec +1 -1
- data/lib/drntest/configuration.rb +3 -3
- data/lib/drntest/engine.rb +7 -20
- data/lib/drntest/response-normalizer.rb +40 -7
- data/lib/drntest/test-runner.rb +3 -2
- data/lib/drntest/tester.rb +7 -7
- data/lib/drntest/version.rb +1 -1
- metadata +16 -16
data/drntest.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- mode: ruby; coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013
|
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,7 +17,7 @@ module Drntest
|
|
17
17
|
class Configuration
|
18
18
|
attr_accessor :port, :host, :tag
|
19
19
|
attr_accessor :base_path, :engine_config
|
20
|
-
attr_accessor :
|
20
|
+
attr_accessor :droonga_engine, :droonga_engine_options
|
21
21
|
attr_accessor :catalog_version
|
22
22
|
|
23
23
|
def initialize
|
@@ -26,8 +26,8 @@ module Drntest
|
|
26
26
|
@tag = "droonga"
|
27
27
|
@base_path = Pathname(Dir.pwd)
|
28
28
|
@engine_config = "default"
|
29
|
-
@
|
30
|
-
@
|
29
|
+
@droonga_engine = "droonga-engine"
|
30
|
+
@droonga_engine_options = []
|
31
31
|
@catalog_version = "2"
|
32
32
|
end
|
33
33
|
|
data/lib/drntest/engine.rb
CHANGED
@@ -32,10 +32,6 @@ module Drntest
|
|
32
32
|
teardown
|
33
33
|
end
|
34
34
|
|
35
|
-
def config_file
|
36
|
-
@config.engine_config_path + "fluentd.conf"
|
37
|
-
end
|
38
|
-
|
39
35
|
def catalog_file
|
40
36
|
@config.engine_config_path + "catalog.json"
|
41
37
|
end
|
@@ -61,7 +57,7 @@ module Drntest
|
|
61
57
|
def extract_connection_info_catalog_v1(catalog_json)
|
62
58
|
zone = catalog_json["zones"].first
|
63
59
|
/\A([^:]+):(\d+)\/(.+)\z/ =~ zone
|
64
|
-
@config.host =
|
60
|
+
@config.host = $1
|
65
61
|
@config.port = $2.to_i
|
66
62
|
@config.tag = $3
|
67
63
|
end
|
@@ -90,7 +86,7 @@ module Drntest
|
|
90
86
|
dataset["replicas"].each do |replica|
|
91
87
|
replica["slices"].each do |slice|
|
92
88
|
if /\A([^:]+):(\d+)\/([^.]+)/ =~ slice["volume"]["address"]
|
93
|
-
@config.host =
|
89
|
+
@config.host = $1
|
94
90
|
@config.port = $2.to_i
|
95
91
|
@config.tag = $3
|
96
92
|
return
|
@@ -101,13 +97,8 @@ module Drntest
|
|
101
97
|
end
|
102
98
|
|
103
99
|
def setup(target_path)
|
104
|
-
return unless temporary?
|
105
|
-
|
106
100
|
setup_temporary_dir
|
107
101
|
|
108
|
-
temporary_config = temporary_dir + "fluentd.conf"
|
109
|
-
FileUtils.cp(config_file, temporary_config)
|
110
|
-
|
111
102
|
catalog_json = load_catalog_json(target_path)
|
112
103
|
temporary_catalog = temporary_dir + "catalog.json"
|
113
104
|
temporary_catalog.open("w") do |output|
|
@@ -115,9 +106,11 @@ module Drntest
|
|
115
106
|
end
|
116
107
|
|
117
108
|
command = [
|
118
|
-
@config.
|
119
|
-
"--
|
120
|
-
|
109
|
+
@config.droonga_engine,
|
110
|
+
"--host", @config.host,
|
111
|
+
"--port", @config.port.to_s,
|
112
|
+
"--tag", @config.tag,
|
113
|
+
*@config.droonga_engine_options,
|
121
114
|
]
|
122
115
|
env = {
|
123
116
|
"DROONGA_CATALOG" => temporary_catalog.to_s,
|
@@ -134,8 +127,6 @@ module Drntest
|
|
134
127
|
end
|
135
128
|
|
136
129
|
def teardown
|
137
|
-
return unless temporary?
|
138
|
-
|
139
130
|
Process.kill(:TERM, @pid)
|
140
131
|
Process.wait(@pid)
|
141
132
|
|
@@ -164,10 +155,6 @@ module Drntest
|
|
164
155
|
temporary_base_dir + "drntest"
|
165
156
|
end
|
166
157
|
|
167
|
-
def temporary?
|
168
|
-
@config.fluentd && config_file.exist?
|
169
|
-
end
|
170
|
-
|
171
158
|
def ready?
|
172
159
|
begin
|
173
160
|
socket = TCPSocket.new(@config.host, @config.port)
|
@@ -24,17 +24,11 @@ module Drntest
|
|
24
24
|
return @response if @response.nil?
|
25
25
|
|
26
26
|
normalized_response = @response.dup
|
27
|
-
|
28
|
-
normalize_droonga_message!(normalized_response[2])
|
27
|
+
normalize_droonga_message!(normalized_response)
|
29
28
|
normalized_response
|
30
29
|
end
|
31
30
|
|
32
31
|
private
|
33
|
-
def normalize_fluent_message!(fluent_message)
|
34
|
-
normalized_start_time = 0
|
35
|
-
fluent_message[1] = normalized_start_time
|
36
|
-
end
|
37
|
-
|
38
32
|
def normalize_droonga_message!(droonga_message)
|
39
33
|
normalize_droonga_message_envelope!(droonga_message)
|
40
34
|
normalize_droonga_message_body!(droonga_message["body"])
|
@@ -51,8 +45,13 @@ module Drntest
|
|
51
45
|
GROONGA_COMMANDS = [
|
52
46
|
"table_create",
|
53
47
|
"table_remove",
|
48
|
+
"table_list",
|
54
49
|
"column_create",
|
50
|
+
"column_remove",
|
51
|
+
"column_rename",
|
52
|
+
"column_list",
|
55
53
|
"select",
|
54
|
+
"delete",
|
56
55
|
]
|
57
56
|
def groonga_command?
|
58
57
|
GROONGA_COMMANDS.include?(@request["type"])
|
@@ -82,6 +81,7 @@ module Drntest
|
|
82
81
|
|
83
82
|
def normalize_groonga_command_response!(response)
|
84
83
|
normalize_groonga_command_header!(response[0])
|
84
|
+
normalize_groonga_command_body!(response[1..-1])
|
85
85
|
end
|
86
86
|
|
87
87
|
def normalized_start_time
|
@@ -98,6 +98,39 @@ module Drntest
|
|
98
98
|
header[2] = normalized_elapsed if valid_elapsed?(header[2])
|
99
99
|
end
|
100
100
|
|
101
|
+
def normalize_groonga_command_body!(body)
|
102
|
+
return if not body.is_a?(Array) or body.empty?
|
103
|
+
|
104
|
+
case @request["type"]
|
105
|
+
when "table_list"
|
106
|
+
normalize_groonga_table_list_command_body!(body)
|
107
|
+
when "column_list"
|
108
|
+
normalize_groonga_column_list_command_body!(body)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
TABLE_PATH_COLUMN_INDEX = 2
|
113
|
+
def normalize_groonga_table_list_command_body!(body)
|
114
|
+
tables = body[0][1..-1]
|
115
|
+
return unless tables.is_a?(Array)
|
116
|
+
tables.each do |table|
|
117
|
+
if table[TABLE_PATH_COLUMN_INDEX].is_a?(String)
|
118
|
+
table[TABLE_PATH_COLUMN_INDEX] = "/path/to/table"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
COLUMN_PATH_COLUMN_INDEX = 2
|
124
|
+
def normalize_groonga_column_list_command_body!(body)
|
125
|
+
columns = body[0][1..-1]
|
126
|
+
return unless columns.is_a?(Array)
|
127
|
+
columns.each do |column|
|
128
|
+
if column[COLUMN_PATH_COLUMN_INDEX].is_a?(String)
|
129
|
+
column[COLUMN_PATH_COLUMN_INDEX] = "/path/to/column"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
101
134
|
def normalize_search_command_response!(response)
|
102
135
|
response.each do |query_name, result|
|
103
136
|
if valid_elapsed?(result["elapsedTime"])
|
data/lib/drntest/test-runner.rb
CHANGED
@@ -29,12 +29,13 @@ module Drntest
|
|
29
29
|
class TestRunner
|
30
30
|
def initialize(config, target)
|
31
31
|
@config = config
|
32
|
-
@target_path = Pathname(target)
|
32
|
+
@target_path = Pathname(target).expand_path
|
33
33
|
@engine = Engine.new(@config)
|
34
34
|
end
|
35
35
|
|
36
36
|
def run
|
37
|
-
|
37
|
+
relative_target_path = @target_path.relative_path_from(@config.suite_path)
|
38
|
+
print "#{relative_target_path}: "
|
38
39
|
@engine.start(@target_path)
|
39
40
|
begin
|
40
41
|
results = process_requests
|
data/lib/drntest/tester.rb
CHANGED
@@ -95,16 +95,16 @@ module Drntest
|
|
95
95
|
@config.engine_config = config
|
96
96
|
end
|
97
97
|
|
98
|
-
parser.on("--
|
99
|
-
"Path to the
|
100
|
-
"(#{@config.
|
101
|
-
@config.
|
98
|
+
parser.on("--droonga-engine=PATH",
|
99
|
+
"Path to the droonga-engine executable",
|
100
|
+
"(#{@config.droonga_engine})") do |droonga_engine|
|
101
|
+
@config.droonga_engine = droonga_engine
|
102
102
|
end
|
103
103
|
|
104
|
-
parser.on("--
|
105
|
-
"Options for
|
104
|
+
parser.on("--droonga-engine-options=OPTIONS",
|
105
|
+
"Options for droonga-engine",
|
106
106
|
"You can specify this option multiple times") do |options|
|
107
|
-
@config.
|
107
|
+
@config.droonga_engine_options.concat(Shellwords.split(options))
|
108
108
|
end
|
109
109
|
|
110
110
|
parser.on("--test=PATTERN",
|
data/lib/drntest/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &72113610 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *72113610
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: yajl-ruby
|
27
|
-
requirement: &
|
27
|
+
requirement: &72113400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *72113400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: droonga-client
|
38
|
-
requirement: &
|
38
|
+
requirement: &72113150 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.1.1
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *72113150
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &72112940 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *72112940
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &72112710 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *72112710
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: packnga
|
71
|
-
requirement: &
|
71
|
+
requirement: &72112500 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *72112500
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: kramdown
|
82
|
-
requirement: &
|
82
|
+
requirement: &72112290 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *72112290
|
91
91
|
description: ''
|
92
92
|
email:
|
93
93
|
- droonga@groonga.org
|