drntest 1.1.5 → 1.1.6
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/lib/drntest/engine.rb +9 -18
- data/lib/drntest/responses-normalizer.rb +61 -0
- data/lib/drntest/test-executor.rb +25 -13
- data/lib/drntest/version.rb +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2936c362e9ba9d86818f05359e6265230e09cdc3
|
4
|
+
data.tar.gz: 7909f8e3228fea4d10983ed32b1def6ff1c8cdae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9f83ca9ac5d0810d8f09f33764db71b09b5c4274d9fcef508e9c27ceda6f0db24b6a0c64e50fe5768fc258af5c88c224fd12c44ca82dbfb1227494ec0f1710f
|
7
|
+
data.tar.gz: f8aa0578d3992c89604ff37649ffb0cce4ae6381cbacc1e9d7bdfbe1f2ed7098eda84bf680bb1efa0225097c89accea77b96f74a08aefd925d181be7bdc44447
|
data/lib/drntest/engine.rb
CHANGED
@@ -105,25 +105,28 @@ module Drntest
|
|
105
105
|
output.puts(JSON.pretty_generate(catalog_json))
|
106
106
|
end
|
107
107
|
|
108
|
+
ready_notify_in, ready_notify_out = IO.pipe
|
108
109
|
command = [
|
109
110
|
@config.droonga_engine,
|
110
111
|
"--host", @config.host,
|
111
112
|
"--port", @config.port.to_s,
|
112
113
|
"--tag", @config.tag,
|
114
|
+
"--base-dir", temporary_dir.to_s,
|
115
|
+
"--ready-notify-fd", ready_notify_out.fileno.to_s,
|
113
116
|
*@config.droonga_engine_options,
|
114
117
|
]
|
115
118
|
env = {
|
116
|
-
"DROONGA_BASE_DIR" => temporary_dir.to_s,
|
117
119
|
}
|
118
120
|
options = {
|
119
|
-
:chdir => temporary_dir.to_s,
|
120
121
|
:err => :out,
|
122
|
+
ready_notify_out => ready_notify_out,
|
121
123
|
}
|
122
124
|
arguments = [env, *command]
|
123
125
|
arguments << options
|
124
126
|
@pid = Process.spawn(*arguments)
|
125
|
-
|
126
|
-
wait_until_ready
|
127
|
+
ready_notify_out.close
|
128
|
+
wait_until_ready(ready_notify_in)
|
129
|
+
ready_notify_in.close
|
127
130
|
end
|
128
131
|
|
129
132
|
def teardown
|
@@ -162,20 +165,8 @@ module Drntest
|
|
162
165
|
temporary_base_dir + "drntest"
|
163
166
|
end
|
164
167
|
|
165
|
-
def
|
166
|
-
|
167
|
-
socket = TCPSocket.new(@config.host, @config.port)
|
168
|
-
socket.close
|
169
|
-
true
|
170
|
-
rescue Errno::ECONNREFUSED
|
171
|
-
false
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
def wait_until_ready
|
176
|
-
until ready?
|
177
|
-
sleep 1
|
178
|
-
end
|
168
|
+
def wait_until_ready(ready_notify_in)
|
169
|
+
ready_notify_in.gets
|
179
170
|
end
|
180
171
|
end
|
181
172
|
end
|
@@ -0,0 +1,61 @@
|
|
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
|
+
module Drntest
|
17
|
+
class ResponsesNormalizer
|
18
|
+
def initialize(request, responses)
|
19
|
+
@request = request
|
20
|
+
@responses = responses
|
21
|
+
end
|
22
|
+
|
23
|
+
def normalize
|
24
|
+
return @responses unless dump_command?
|
25
|
+
|
26
|
+
normalize_dump_responses
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def dump_command?
|
31
|
+
@request["type"] == "dump"
|
32
|
+
end
|
33
|
+
|
34
|
+
DUMP_TYPE_ORDER = [
|
35
|
+
"dump.start",
|
36
|
+
"dump.result",
|
37
|
+
"dump.table",
|
38
|
+
"dump.column",
|
39
|
+
"dump.record",
|
40
|
+
"dump.end",
|
41
|
+
]
|
42
|
+
def normalize_dump_responses
|
43
|
+
@responses.sort_by do |response|
|
44
|
+
type = response["type"]
|
45
|
+
type_order = DUMP_TYPE_ORDER.index(type)
|
46
|
+
body = response["body"]
|
47
|
+
case type
|
48
|
+
when "dump.table"
|
49
|
+
body_order = body["name"]
|
50
|
+
when "dump.column"
|
51
|
+
body_order = "#{body['table']}.#{body['name']}"
|
52
|
+
when "dump.record"
|
53
|
+
body_order = "#{body['table']}.#{body['key']}"
|
54
|
+
else
|
55
|
+
body_order = ""
|
56
|
+
end
|
57
|
+
[type_order, body_order]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -17,6 +17,7 @@ require "droonga/client"
|
|
17
17
|
|
18
18
|
require "drntest/test-loader"
|
19
19
|
require "drntest/response-normalizer"
|
20
|
+
require "drntest/responses-normalizer"
|
20
21
|
|
21
22
|
module Drntest
|
22
23
|
class TestExecutor
|
@@ -102,27 +103,33 @@ module Drntest
|
|
102
103
|
|
103
104
|
def execute_request(request)
|
104
105
|
if @logging
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
rescue
|
109
|
-
@responses << {
|
110
|
-
"error" => {
|
111
|
-
"message" => "failed to normalize response",
|
112
|
-
"detail" => "#{$!.message} (#{$!.class})",
|
113
|
-
"backtrace" => $!.backtrace,
|
114
|
-
"response" => response,
|
115
|
-
},
|
116
|
-
}
|
117
|
-
end
|
106
|
+
responses = []
|
107
|
+
request_process = @client.request(request) do |raw_response|
|
108
|
+
responses << clean_response(request, raw_response)
|
118
109
|
end
|
119
110
|
request_process.wait
|
111
|
+
@responses.concat(normalize_responses(request, responses))
|
120
112
|
else
|
121
113
|
@requests << @client.request(request) do
|
122
114
|
end
|
123
115
|
end
|
124
116
|
end
|
125
117
|
|
118
|
+
def clean_response(request, raw_response)
|
119
|
+
begin
|
120
|
+
normalize_response(request, raw_response)
|
121
|
+
rescue
|
122
|
+
{
|
123
|
+
"error" => {
|
124
|
+
"message" => "failed to normalize response",
|
125
|
+
"detail" => "#{$!.message} (#{$!.class})",
|
126
|
+
"backtrace" => $!.backtrace,
|
127
|
+
"response" => raw_response,
|
128
|
+
},
|
129
|
+
}
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
126
133
|
def consume_requests
|
127
134
|
@requests.each do |request|
|
128
135
|
request.wait
|
@@ -135,6 +142,11 @@ module Drntest
|
|
135
142
|
normalizer.normalize
|
136
143
|
end
|
137
144
|
|
145
|
+
def normalize_responses(request, responses)
|
146
|
+
normalizer = ResponsesNormalizer.new(request, responses)
|
147
|
+
normalizer.normalize
|
148
|
+
end
|
149
|
+
|
138
150
|
def abort_execution
|
139
151
|
throw(@abort_tag)
|
140
152
|
end
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Droonga Project
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -116,24 +116,25 @@ executables:
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
+
- Gemfile
|
119
120
|
- README.md
|
120
121
|
- Rakefile
|
121
|
-
-
|
122
|
+
- bin/drntest
|
122
123
|
- drntest.gemspec
|
123
|
-
- lib/drntest/
|
124
|
-
- lib/drntest/json-loader.rb
|
125
|
-
- lib/drntest/test-results.rb
|
124
|
+
- lib/drntest/configuration.rb
|
126
125
|
- lib/drntest/directive.rb
|
127
|
-
- lib/drntest/input-error.rb
|
128
|
-
- lib/drntest/tester.rb
|
129
126
|
- lib/drntest/engine.rb
|
130
|
-
- lib/drntest/
|
131
|
-
- lib/drntest/
|
132
|
-
- lib/drntest/
|
127
|
+
- lib/drntest/input-error.rb
|
128
|
+
- lib/drntest/json-loader.rb
|
129
|
+
- lib/drntest/response-normalizer.rb
|
130
|
+
- lib/drntest/responses-normalizer.rb
|
133
131
|
- lib/drntest/test-executor.rb
|
132
|
+
- lib/drntest/test-loader.rb
|
133
|
+
- lib/drntest/test-results.rb
|
134
|
+
- lib/drntest/test-runner.rb
|
134
135
|
- lib/drntest/test-suites-result.rb
|
135
|
-
- lib/drntest/
|
136
|
-
-
|
136
|
+
- lib/drntest/tester.rb
|
137
|
+
- lib/drntest/version.rb
|
137
138
|
homepage: https://github.com/droonga/drntest
|
138
139
|
licenses:
|
139
140
|
- GPLv3 or later
|
@@ -154,10 +155,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
155
|
version: '0'
|
155
156
|
requirements: []
|
156
157
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.4.1
|
158
159
|
signing_key:
|
159
160
|
specification_version: 4
|
160
161
|
summary: Drntest is a testing framework for Droonga. You can write a test for Droonga
|
161
162
|
by writing Droonga commands and expected result.
|
162
163
|
test_files: []
|
163
|
-
has_rdoc:
|