grntest 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e087007c74f9b61344ed535c71c018afa2ef0aa8bb10f6de910418b6ce1e794
4
- data.tar.gz: de8df8defdb777227644bcd539aa5bfbd855962bec50a1baf7ec3bf58d5cf315
3
+ metadata.gz: c74faa2722964ab0d9f2f78a7fea2e3e1275d28e0639c10f9bfaef7597d3e73f
4
+ data.tar.gz: b0462e4805ec8c3c04b81a3330be27ad8af703a1dbcdb95db08ef28e954f6a95
5
5
  SHA512:
6
- metadata.gz: 5c147cd30f72093e219d592a4db77f9f9675681987e1c3acb7561cf1c1a6cf8c41bf29fe008ab504505f4499c7c6643f7dbb5fabd7d37259f162f1748c891208
7
- data.tar.gz: 5c39f666cd0dc957523404aa3cb294a82a3ead1af84c0e37f395dbb6933983bc3468fb02254663398fc1fd6f569132e90db7b11975036ede974ff60e4690d99e
6
+ metadata.gz: 3d10fa6674ffa249bc0555fad4b460d48505b4cc8abdc640956ebd403b3784ac1bf80f52a5bd39e5956167904bd0eb4624e8b0dc3f3fe1cfc9c923bad88d9ad5
7
+ data.tar.gz: 60133bca88d982074f54cc3426298d692fb34c3432e800c1f1427c4de2af2ca158a28415456b670d81502f1fc87fc26cb5b7e11c09a1df4770dec34b44602ca1
data/doc/text/news.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # News
2
2
 
3
+ ## 1.3.5: 2020-03-02
4
+
5
+ ### Improvements
6
+
7
+ * Added support for Ruby 2.3 again.
8
+
9
+ * Changed to use `URI#open` to suppress a warning.
10
+
11
+ * Added support for Apache Arrow as load data format.
12
+
13
+ * Added `require-input-type` directive.
14
+
15
+ * Added `--use-http-post` option.
16
+
3
17
  ## 1.3.4: 2019-10-11
4
18
 
5
19
  ### Improvements
data/grntest.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- ruby -*-
2
2
  #
3
- # Copyright (C) 2012-2019 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2012-2020 Sutou Kouhei <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
@@ -44,11 +44,13 @@ Gem::Specification.new do |spec|
44
44
  end
45
45
 
46
46
  spec.add_runtime_dependency("diff-lcs")
47
+ spec.add_runtime_dependency("groonga-command", ">= 1.4.7")
47
48
  spec.add_runtime_dependency("groonga-command-parser")
48
49
  spec.add_runtime_dependency("groonga-log")
49
50
  spec.add_runtime_dependency("groonga-query-log", ">= 1.4.1")
50
51
  spec.add_runtime_dependency("json")
51
52
  spec.add_runtime_dependency("msgpack")
53
+ spec.add_runtime_dependency("rexml")
52
54
 
53
55
  spec.add_development_dependency("bundler")
54
56
  spec.add_development_dependency("rake")
@@ -21,6 +21,8 @@ module Grntest
21
21
  attr_accessor :plugin_extension
22
22
  attr_accessor :groonga_suggest_create_dataset
23
23
  attr_accessor :result
24
+ attr_writer :use_http_post
25
+ attr_accessor :input_type
24
26
  attr_accessor :output_type
25
27
  attr_accessor :on_error
26
28
  attr_accessor :abort_tag
@@ -42,6 +44,8 @@ module Grntest
42
44
  @groonga_suggest_create_dataset = "groonga-suggest-create-dataset"
43
45
  @n_nested = 0
44
46
  @result = []
47
+ @use_http_post = false
48
+ @input_type = "json"
45
49
  @output_type = "json"
46
50
  @log = nil
47
51
  @query_log = nil
@@ -62,6 +66,10 @@ module Grntest
62
66
  @logging
63
67
  end
64
68
 
69
+ def use_http_post?
70
+ @use_http_post
71
+ end
72
+
65
73
  def suppress_backtrace?
66
74
  @suppress_backtrace or debug?
67
75
  end
@@ -320,6 +320,13 @@ module Grntest
320
320
  parser << "#{expand_variables(groonga_command)}\n"
321
321
  end
322
322
 
323
+ def execute_directive_require_input_type(parser, line, content, options)
324
+ input_type, = options
325
+ unless @context.input_type == input_type
326
+ omit("require input type: #{input_type}")
327
+ end
328
+ end
329
+
323
330
  def execute_directive(parser, line, content)
324
331
  command, *options = Shellwords.split(content)
325
332
  case command
@@ -355,6 +362,8 @@ module Grntest
355
362
  execute_directive_generate_series(parser, line, content, options)
356
363
  when "eval"
357
364
  execute_directive_eval(parser, line, content, options)
365
+ when "require-input-type"
366
+ execute_directive_require_input_type(parser, line, content, options)
358
367
  else
359
368
  log_input(line)
360
369
  log_error("#|e| unknown directive: <#{command}>")
@@ -436,7 +445,7 @@ module Grntest
436
445
  unless lines.empty?
437
446
  timeout = Time.now + @context.read_timeout
438
447
  while Time.now < timeout
439
- break if /rc=-?\d+$/.match?(lines.last)
448
+ break if /rc=-?\d+$/ =~ lines.last
440
449
  additional_content = read_all_readable_content(context.query_log,
441
450
  first_timeout: 0)
442
451
  next if additional_content.empty?
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2012-2015 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2012-2020 Sutou Kouhei <kou@clear-code.com>
4
2
  #
5
3
  # This program is free software: you can redistribute it and/or modify
6
4
  # it under the terms of the GNU General Public License as published by
@@ -15,6 +13,7 @@
15
13
  # You should have received a copy of the GNU General Public License
16
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
15
 
16
+ require "net/http"
18
17
  require "open-uri"
19
18
 
20
19
  require "grntest/executors/base-executor"
@@ -60,18 +59,33 @@ module Grntest
60
59
  return send_normal_command(command)
61
60
  end
62
61
 
63
- values = command.arguments.delete(:values)
64
- if lines.size >= 2 and lines[1].start_with?("[")
65
- unless /\s--columns\s/ =~ lines.first
66
- command.arguments.delete(:columns)
62
+ case @context.input_type
63
+ when "apache-arrow"
64
+ command[:input_type] = "apache-arrow"
65
+ content_type = "application/x-apache-arrow-streaming"
66
+ arrow_table = command.build_arrow_table
67
+ if arrow_table
68
+ buffer = Arrow::ResizableBuffer.new(1024)
69
+ arrow_table.save(buffer, format: :stream)
70
+ body = buffer.data.to_s
71
+ else
72
+ body = ""
67
73
  end
68
- body = lines[1..-1].join
74
+ command.arguments.delete(:values)
69
75
  else
70
- body = values
76
+ content_type = "application/json; charset=UTF-8"
77
+ values = command.arguments.delete(:values)
78
+ if lines.size >= 2 and lines[1].start_with?("[")
79
+ unless /\s--columns\s/ =~ lines.first
80
+ command.arguments.delete(:columns)
81
+ end
82
+ body = lines[1..-1].join
83
+ else
84
+ body = values
85
+ end
71
86
  end
72
-
73
87
  request = Net::HTTP::Post.new(command.to_uri_format)
74
- request.content_type = "application/json; charset=UTF-8"
88
+ request.content_type = content_type
75
89
  request.body = body
76
90
  response = Net::HTTP.start(@host, @port) do |http|
77
91
  http.read_timeout = read_timeout
@@ -81,16 +95,25 @@ module Grntest
81
95
  end
82
96
 
83
97
  def send_normal_command(command)
84
- url = "http://#{@host}:#{@port}#{command.to_uri_format}"
98
+ path_with_query = command.to_uri_format
99
+ if @context.use_http_post?
100
+ path, query = path_with_query.split("?", 2)
101
+ request = Net::HTTP::Post.new(path)
102
+ request.content_type = "application/x-www-form-urlencoded"
103
+ request.body = query
104
+ else
105
+ request = Net::HTTP::Get.new(path_with_query)
106
+ end
107
+ url = "http://#{@host}:#{@port}#{path_with_query}"
85
108
  begin
86
- open(url, :read_timeout => read_timeout) do |response|
87
- normalize_response_data(command, response.read)
109
+ response = Net::HTTP.start(@host, @port) do |http|
110
+ http.read_timeout = read_timeout
111
+ http.request(request)
88
112
  end
113
+ normalize_response_data(command, response.body)
89
114
  rescue SystemCallError
90
115
  message = "failed to read response from Groonga: <#{url}>: #{$!}"
91
116
  raise Error.new(message)
92
- rescue OpenURI::HTTPError
93
- $!.io.read
94
117
  rescue Net::HTTPBadResponse
95
118
  message = "bad response from Groonga: <#{url}>: "
96
119
  message << "#{$!.class}: #{$!.message}"
@@ -137,6 +137,8 @@ module Grntest
137
137
  context.plugins_directory = @tester.plugins_directory.expand_path
138
138
  context.groonga_suggest_create_dataset =
139
139
  @tester.groonga_suggest_create_dataset
140
+ context.use_http_post = @tester.use_http_post?
141
+ context.input_type = @tester.input_type
140
142
  context.output_type = @tester.output_type
141
143
  context.timeout = @tester.timeout
142
144
  context.timeout = 0 if @tester.gdb
@@ -65,6 +65,21 @@ module Grntest
65
65
  tester.interface = interface
66
66
  end
67
67
 
68
+ parser.on("--[no-]use-http-post",
69
+ "Use POST to send command by HTTP",
70
+ "(#{tester.use_http_post?})") do |boolean|
71
+ tester.use_http_post = boolean
72
+ end
73
+
74
+ available_input_types = ["json", "apache-arrow"]
75
+ available_input_type_labels = available_input_types.join(", ")
76
+ parser.on("--input-type=TYPE", available_input_types,
77
+ "Use TYPE as the input type on load",
78
+ "[#{available_input_type_labels}]",
79
+ "(#{tester.input_type})") do |type|
80
+ tester.input_type = type
81
+ end
82
+
68
83
  available_output_types = ["json", "msgpack"]
69
84
  available_output_type_labels = available_output_types.join(", ")
70
85
  parser.on("--output-type=TYPE", available_output_types,
@@ -277,7 +292,11 @@ module Grntest
277
292
  end
278
293
 
279
294
  attr_accessor :groonga, :groonga_httpd, :groonga_suggest_create_dataset
280
- attr_accessor :interface, :output_type, :testee
295
+ attr_accessor :interface
296
+ attr_writer :use_http_post
297
+ attr_accessor :input_type
298
+ attr_accessor :output_type
299
+ attr_accessor :testee
281
300
  attr_accessor :base_directory, :database_path, :diff, :diff_options
282
301
  attr_accessor :n_workers
283
302
  attr_accessor :output
@@ -303,6 +322,8 @@ module Grntest
303
322
  @groonga_suggest_create_dataset = nil
304
323
  end
305
324
  @interface = :stdio
325
+ @use_http_post = false
326
+ @input_type = "json"
306
327
  @output_type = "json"
307
328
  @testee = "groonga"
308
329
  @base_directory = Pathname(".")
@@ -349,6 +370,10 @@ module Grntest
349
370
  end
350
371
  end
351
372
 
373
+ def use_http_post?
374
+ @use_http_post
375
+ end
376
+
352
377
  def keep_database?
353
378
  @keep_database
354
379
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2019 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2012-2020 Sutou Kouhei <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
@@ -14,5 +14,5 @@
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  module Grntest
17
- VERSION = "1.3.4"
17
+ VERSION = "1.3.5"
18
18
  end
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
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-10-11 00:00:00.000000000 Z
12
+ date: 2020-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: diff-lcs
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: groonga-command
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 1.4.7
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 1.4.7
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: groonga-command-parser
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -95,6 +109,20 @@ dependencies:
95
109
  - - ">="
96
110
  - !ruby/object:Gem::Version
97
111
  version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rexml
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
98
126
  - !ruby/object:Gem::Dependency
99
127
  name: bundler
100
128
  requirement: !ruby/object:Gem::Requirement
@@ -241,13 +269,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
269
  - !ruby/object:Gem::Version
242
270
  version: '0'
243
271
  requirements: []
244
- rubyforge_project:
245
- rubygems_version: 2.7.6.2
272
+ rubygems_version: 3.2.0.pre1
246
273
  signing_key:
247
274
  specification_version: 4
248
275
  summary: Grntest is a testing framework for Groonga. You can write a test for Groonga
249
276
  by writing Groonga commands and expected result.
250
277
  test_files:
251
- - test/run-test.rb
252
278
  - test/executors/test-base-executor.rb
253
279
  - test/executors/test-standard-io-executor.rb
280
+ - test/run-test.rb