grntest 1.7.3 → 1.7.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: 4333e40f40a3b7f0d255906972e5c0d7ba7ca5c64dc9b25067aeb8229b65b621
4
- data.tar.gz: 10f51f45c7ef3502666222c5ae9208445a168e5daecf45f703ea7809e5a812b3
3
+ metadata.gz: b9cd8b74ac4dd886a08f1550309a467d95b39f1adc182a915ace5bb10f7c0f78
4
+ data.tar.gz: ba6b74681a3a7523d0d48ed298efffb4d4d0fede4c0869401fba949e617f02b4
5
5
  SHA512:
6
- metadata.gz: cc5a1b7ca28af7e531f488c6ebe95418e710badf657dc90167dc824b0f9c61a733ece7438c5fe819de818971c6320b806235f75e10ccc948c6d4e9c001a93899
7
- data.tar.gz: 30ba97c16f66bd5a1e6ce10a0af01fbd5fce26d3df872362097d815da45b16079a1c47d2a0c839b3cc36588fc9b8e44c8f7758f3dd6e1d47f69f57838c4bd30b
6
+ metadata.gz: d285a5183996b4390e93dac09e5416fd8f3e5decbadf4b8ed95458534e65cdd1d74b11efa6635d79e3687de7c7a09a83c1c2d2c6471b0455dfead94061158fdb
7
+ data.tar.gz: 2fbba81eeb21ebdfdebbcd51d758ad836b54f5017fb27b404025c4d0a930bbf686a71f397e73a0cb66de16c7d84e6231dc3662fc4cd907d201908281f0811494
data/doc/text/news.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # News
2
2
 
3
+ ## 1.7.5: 2024-04-12
4
+
5
+ ### Improvements
6
+
7
+ * `#@generate-series`: Improved performance.
8
+
9
+ * `#@require-env`: Added to run tests only when the given
10
+ environment variable is defined.
11
+
12
+ ## 1.7.4: 2024-04-05
13
+
14
+ ### Improvements
15
+
16
+ * http: Added support for canceled requests.
17
+
3
18
  ## 1.7.3: 2024-02-20
4
19
 
5
20
  ### Improvements
@@ -308,28 +308,43 @@ module Grntest
308
308
  @context.collect_query_log = (options[0] == "true")
309
309
  end
310
310
 
311
+ def each_generated_series_chunk(evaluator, start, stop)
312
+ max_chunk_size = 1 * 1024 * 1024 # 1MiB
313
+ chunk_size = 0
314
+ records = []
315
+ (Integer(start)..Integer(stop)).each do |i|
316
+ record = evaluator.evaluate(i: i).to_json
317
+ records << record
318
+ chunk_size += record.bytesize
319
+ if chunk_size > max_chunk_size
320
+ yield(records)
321
+ records.clear
322
+ chunk_size = 0
323
+ end
324
+ end
325
+ yield(records) unless records.empty?
326
+ end
327
+
311
328
  def execute_directive_generate_series(parser, line, content, options)
312
329
  start, stop, table, template, = options
313
330
  evaluator = TemplateEvaluator.new(template.force_encoding("UTF-8"))
314
- (Integer(start)..Integer(stop)).each_slice(1000) do |range|
315
- parser << "load --table #{table}\n"
316
- parser << "["
317
- first_record = true
318
- range.each do |i|
319
- record = ""
320
- if first_record
321
- first_record = false
322
- else
323
- record << ","
324
- end
325
- record << "\n"
326
- record << evaluator.evaluate(i: i).to_json
327
- before = Time.now
328
- parser << record
329
- elapsed = Time.now - before
330
- Thread.pass if elapsed > 1.0
331
+ each_generated_series_chunk(evaluator,
332
+ Integer(start),
333
+ Integer(stop)) do |records|
334
+ source = "load --table #{table}\n"
335
+ values_part_start_position = source.size
336
+ source << "["
337
+ records.each_with_index do |record, i|
338
+ source << "," unless i.zero?
339
+ source << "\n"
340
+ source << record
331
341
  end
332
- parser << "\n]\n"
342
+ source << "\n]"
343
+ values = source[values_part_start_position..-1]
344
+ command = Groonga::Command::Load.new(table: table, values: values)
345
+ command.original_source = source
346
+ execute_command(command)
347
+ Thread.pass
333
348
  end
334
349
  end
335
350
 
@@ -534,6 +549,19 @@ module Grntest
534
549
  @benchmark_result = @noop_benchmark_result
535
550
  end
536
551
 
552
+ def execute_directive_require_env(line, content, options)
553
+ env, = options
554
+ if env.start_with?("!")
555
+ if ENV[env[1..-1]]
556
+ omit("require env: #{env}")
557
+ end
558
+ else
559
+ unless ENV[env]
560
+ omit("require env: #{env}")
561
+ end
562
+ end
563
+ end
564
+
537
565
  def execute_directive(parser, line, content)
538
566
  command, *options = Shellwords.split(content)
539
567
  case command
@@ -597,6 +625,8 @@ module Grntest
597
625
  execute_directive_start_benchmark(line, content, options)
598
626
  when "finish-benchmark"
599
627
  execute_directive_finish_benchmark(line, content, options)
628
+ when "require-env"
629
+ execute_directive_require_env(line, content, options)
600
630
  else
601
631
  log_input(line)
602
632
  log_error("#|e| unknown directive: <#{command}>")
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2020 Sutou Kouhei <kou@clear-code.com>
1
+ # Copyright (C) 2012-2024 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
@@ -83,6 +83,8 @@ module Grntest
83
83
  when Net::HTTPBadRequest,
84
84
  Net::HTTPNotFound
85
85
  # Groonga returns them for an invalid request.
86
+ when Net::HTTPRequestTimeOut
87
+ # Groonga returns this for a canceled request.
86
88
  when Net::HTTPInternalServerError
87
89
  # Groonga returns this for an internal error.
88
90
  else
@@ -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.7.3"
17
+ VERSION = "1.7.5"
18
18
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grntest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.3
4
+ version: 1.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  - Haruka Yoshihara
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-02-19 00:00:00.000000000 Z
11
+ date: 2024-04-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: diff-lcs
@@ -270,7 +269,6 @@ homepage: https://github.com/groonga/grntest
270
269
  licenses:
271
270
  - GPL-3.0+
272
271
  metadata: {}
273
- post_install_message:
274
272
  rdoc_options: []
275
273
  require_paths:
276
274
  - lib
@@ -285,8 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
283
  - !ruby/object:Gem::Version
286
284
  version: '0'
287
285
  requirements: []
288
- rubygems_version: 3.5.1
289
- signing_key:
286
+ rubygems_version: 3.6.0.dev
290
287
  specification_version: 4
291
288
  summary: Grntest is a testing framework for Groonga. You can write a test for Groonga
292
289
  by writing Groonga commands and expected result.