grntest 1.8.4 → 1.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6455869776dca39246bac4338793e91579836a6762c20fb33a9710c01f38bfff
4
- data.tar.gz: 5e4f4186f61d6b0d7ba597fe59c0cfa886bd03d7f25227fe835502f801dd6be6
3
+ metadata.gz: e58246b338b34f388628f0a2762c405d01a2ec9e715d572a45402a09825717fe
4
+ data.tar.gz: 9d2dcfb7b76374143d26bca3981614b5e242afe5bd04119ce2e8a12a5461efa3
5
5
  SHA512:
6
- metadata.gz: 3c3c5cec9561a57952c72c4e3b2eea956328553308ff9fe84d2b828f142f1f8f0e57d491c4a326dc6cda7d7c95e56bacb497cad319ae4508a41a19e2df781a90
7
- data.tar.gz: 8ad7895b6201d721efaaab67141ac80af2c589f6f7883206350d3e7cda19470aeba8efa3c925b91689b945ac408c9097544c3b94dcd799a9bb730ba42639dcfa
6
+ metadata.gz: fcfd998dab94f51aaf683f5c9a5089bde2c9c91ad4f39fd3fe0a6803d77faa1bc9617034033d755bef21e191f90a310cb127456f80157e95d3b6e12096702ee1
7
+ data.tar.gz: bd7b3cc3eb63003ce7bdc1ed93df6caa98c0d5432e6bf9139c7d6a7c595e87ac1389e1e9bcbf657cdec9df0570501b909c59d57b169b91666e7d6cdea18a625d
data/README.md CHANGED
@@ -221,6 +221,7 @@ Here are available `NAME` s:
221
221
  * `remove-important-log-levels`
222
222
  * `sleep`
223
223
  * `collect-query-log`
224
+ * `sort-query-log-operations`
224
225
 
225
226
  `ARGUMENTS...` are depends on directive. A directive doesn't require
226
227
  any arguments but a directive requires arguments.
@@ -555,6 +556,34 @@ select Users --query _key:User1
555
556
  #@collect-query-log false
556
557
  ```
557
558
 
559
+ #### `sort-query-log-operations`
560
+
561
+ Usage:
562
+
563
+ ```
564
+ #@sort-query-log-operations [none|shard]
565
+ ```
566
+
567
+ It changes the order of operations in the collected query log. It
568
+ is useful with `collect-query-log` directive.
569
+
570
+ `none` is the default. Operations are printed in the executed order.
571
+
572
+ `shard` sorts sharded operations such as `select[...]` and
573
+ `filter[...]` by their names. Sharded operations may be executed in
574
+ parallel. So their order isn't stable. `shard` makes the order stable.
575
+ Non sharded operations keep the executed order.
576
+
577
+ Example:
578
+
579
+ ```
580
+ #@collect-query-log true
581
+ #@sort-query-log-operations shard
582
+ logical_select Logs --shard_key timestamp --query message:hello
583
+ #@sort-query-log-operations none
584
+ #@collect-query-log false
585
+ ```
586
+
558
587
  ## Options
559
588
 
560
589
  Grntest has many options. You don't need to specify many of them
data/doc/text/news.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # News
2
2
 
3
+ ## 1.8.6: 2026-09-05
4
+
5
+ ### Improvements
6
+
7
+ * `#@sort-query-log-operations`: Added for `logical_select`'s
8
+ `--n_workers` support.
9
+
10
+ ## 1.8.5: 2026-09-04
11
+
12
+ ### Improvements
13
+
14
+ * `#@generate-series`: Improved performance.
15
+
3
16
  ## 1.8.4: 2026-03-16
4
17
 
5
18
  ### Improvements
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2024 Sutou Kouhei <kou@clear-code.com>
1
+ # Copyright (C) 2012-2026 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
@@ -37,6 +37,7 @@ module Grntest
37
37
  attr_accessor :shutdown_wait_timeout
38
38
  attr_writer :suppress_backtrace
39
39
  attr_writer :collect_query_log
40
+ attr_accessor :sort_query_log_operations
40
41
  attr_writer :debug
41
42
  attr_accessor :platform
42
43
  attr_accessor :benchmarks
@@ -69,6 +70,7 @@ module Grntest
69
70
  @omitted = false
70
71
  @suppress_backtrace = true
71
72
  @collect_query_log = false
73
+ @sort_query_log_operations = "none"
72
74
  @debug = false
73
75
  @platform = guess_platform
74
76
  @benchmarks = []
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2024 Sutou Kouhei <kou@clear-code.com>
1
+ # Copyright (C) 2012-2026 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
@@ -308,12 +308,17 @@ 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)
311
+ def execute_directive_sort_query_log_operations(line, content, options)
312
+ @context.sort_query_log_operations = options[0]
313
+ end
314
+
315
+ def each_generated_series_chunk(template, start, stop)
316
+ evaluator = TemplateEvaluator.new(template, :i)
312
317
  max_chunk_size = 1 * 1024 * 1024 # 1MiB
313
318
  chunk_size = 0
314
319
  records = []
315
320
  (Integer(start)..Integer(stop)).each do |i|
316
- record = evaluator.evaluate(i: i).to_json
321
+ record = evaluator.evaluate(i).to_json
317
322
  records << record
318
323
  chunk_size += record.bytesize
319
324
  if chunk_size > max_chunk_size
@@ -327,8 +332,7 @@ module Grntest
327
332
 
328
333
  def execute_directive_generate_series(parser, line, content, options)
329
334
  start, stop, table, template, = options
330
- evaluator = TemplateEvaluator.new(template.force_encoding("UTF-8"))
331
- each_generated_series_chunk(evaluator,
335
+ each_generated_series_chunk(template.force_encoding("UTF-8"),
332
336
  Integer(start),
333
337
  Integer(stop)) do |records|
334
338
  source = "load --table #{table}\n"
@@ -502,7 +506,7 @@ module Grntest
502
506
  return input if @substitutions.empty?
503
507
  @substitutions.each_value do |pattern, substituted_evaluator, _|
504
508
  input = input.gsub(pattern) do
505
- substituted_evaluator.evaluate(match_data: Regexp.last_match)
509
+ substituted_evaluator.evaluate(Regexp.last_match)
506
510
  end
507
511
  end
508
512
  input
@@ -512,7 +516,7 @@ module Grntest
512
516
  return input if @substitutions.empty?
513
517
  @substitutions.each_value do |pattern, _, normalized_evaluator|
514
518
  input = input.gsub(pattern) do
515
- normalized_evaluator.evaluate(match_data: Regexp.last_match)
519
+ normalized_evaluator.evaluate(Regexp.last_match)
516
520
  end
517
521
  end
518
522
  input
@@ -524,9 +528,11 @@ module Grntest
524
528
  substituted.force_encoding("UTF-8")
525
529
  normalized.force_encoding("UTF-8")
526
530
  substituted_evaluator =
527
- TemplateEvaluator.new("<<STRING.chomp\n#{substituted}\nSTRING")
531
+ TemplateEvaluator.new("<<STRING.chomp\n#{substituted}\nSTRING",
532
+ :match_data)
528
533
  normalized_evaluator =
529
- TemplateEvaluator.new("<<STRING.chomp\n#{normalized}\nSTRING")
534
+ TemplateEvaluator.new("<<STRING.chomp\n#{normalized}\nSTRING",
535
+ :match_data)
530
536
  @substitutions[pattern] = [
531
537
  compile_pattern(pattern),
532
538
  substituted_evaluator,
@@ -629,6 +635,8 @@ module Grntest
629
635
  execute_directive_sleep(line, content, options)
630
636
  when "collect-query-log"
631
637
  execute_directive_collect_query_log(line, content, options)
638
+ when "sort-query-log-operations"
639
+ execute_directive_sort_query_log_operations(line, content, options)
632
640
  when "generate-series"
633
641
  execute_directive_generate_series(parser, line, content, options)
634
642
  when "eval"
@@ -948,7 +956,8 @@ module Grntest
948
956
  command[:output_type] = nil if command.output_type == :json
949
957
  log_query("\#>#{command.to_command_format}")
950
958
  end
951
- statistic.each_operation do |operation|
959
+ sorted_operations = sort_operations(statistic)
960
+ sorted_operations.each do |operation|
952
961
  message = operation[:raw_message]
953
962
  case operation[:name]
954
963
  when "cache"
@@ -962,6 +971,32 @@ module Grntest
962
971
  end
963
972
  end
964
973
 
974
+ def sort_operations(statistic)
975
+ sort_key = @context.sort_query_log_operations
976
+ case sort_key
977
+ when "shard"
978
+ first_shard_select_index = nil
979
+ first_shard_filter_index = nil
980
+ statistic.each_operation.sort_by do |operation|
981
+ i = operation[:i]
982
+ name = operation[:name]
983
+ if name.start_with?("select[")
984
+ first_shard_select_index ||= i
985
+ [first_shard_select_index, name]
986
+ elsif name.start_with?("filter[")
987
+ first_shard_filter_index ||= i
988
+ [first_shard_filter_index, name]
989
+ else
990
+ [i]
991
+ end
992
+ end
993
+ when "none"
994
+ statistic.each_operation
995
+ else
996
+ raise Error.nw("unsupported sort-query-log-operations: #{sort_key}")
997
+ end
998
+ end
999
+
965
1000
  def debug_input(input)
966
1001
  return unless @context.debug?
967
1002
  $stderr.puts("> #{input}")
@@ -15,16 +15,17 @@
15
15
 
16
16
  module Grntest
17
17
  class TemplateEvaluator
18
- def initialize(template)
18
+ def initialize(template, *variable_names)
19
19
  @template = template
20
+ @compiled = eval(<<-TEMPLATE)
21
+ lambda do |#{variable_names.join(", ")}|
22
+ #{@template}
23
+ end
24
+ TEMPLATE
20
25
  end
21
26
 
22
- def evaluate(**local_variables)
23
- _binding = binding
24
- local_variables.each do |name, value|
25
- _binding.local_variable_set(name, value)
26
- end
27
- _binding.eval(@template)
27
+ def evaluate(*values)
28
+ @compiled.call(*values)
28
29
  end
29
30
  end
30
31
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2025 Sutou Kouhei <kou@clear-code.com>
1
+ # Copyright (C) 2012-2026 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.8.4"
17
+ VERSION = "1.8.6"
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.8.4
4
+ version: 1.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -283,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
283
283
  - !ruby/object:Gem::Version
284
284
  version: '0'
285
285
  requirements: []
286
- rubygems_version: 4.0.3
286
+ rubygems_version: 4.0.16
287
287
  specification_version: 4
288
288
  summary: Grntest is a testing framework for Groonga. You can write a test for Groonga
289
289
  by writing Groonga commands and expected result.