groonga-query-log 1.5.5 → 1.5.6

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: 62d9d663acc92d9e648326faa03dfb49fab7e8a9363e3850925791dc8b306560
4
- data.tar.gz: a7ad80e766ab25620599580c99a873bb9494cb3bda1182846863d427088e5b92
3
+ metadata.gz: 5c477ce5c66bac482f0c94777fb0b5c2a6b6bf6c7ef3f84a6020ecff4d70c28d
4
+ data.tar.gz: 612d7313d065141312414bc7e1b932efb150fbfff136011d6847027050f0f2a2
5
5
  SHA512:
6
- metadata.gz: 5f0ccad0775f92a9eba4ff48f5a6ab6a111fca087b9e17adf04b89582d57cbe2d41e24bb65988cd4844013f8251e587e8898cdd6baa44050a68062ffbec191aa
7
- data.tar.gz: b55069b32eb97c1b8ee8132a5bf60b62200e7c95f2f630dc93c4e83d2d7052b64993ebb064ed8fdbf66aeddd8cf1d1e011b215b965b112e9744e82f421b1f139
6
+ metadata.gz: d3e9f5212cd1367c8db624aad41d29b8769f21704987cf32ebccf98f652515696244c1f199e48cf800c25f793e09a014d738e1ec63dc23ce59f86febfa3747b6
7
+ data.tar.gz: acab0c65ed1a853589479e189ae0271c7965ac31aee4bfb675091ceb9d97992d9cac65be60b21b6105a674a2eb5072a9c919740cf51998a48870e29a912adb08
@@ -1,16 +1,16 @@
1
1
  # News
2
2
 
3
- ## 1.5.5: 2019-10-24
3
+ ## 1.5.6: 2019-11-26
4
4
 
5
5
  ### Improvements
6
6
 
7
- * `run-regression-test`: Added `--performance-choose-strategy` option.
7
+ * `run-regression-test`: Outputted report to stdout by default.
8
8
 
9
- ### Improvements
9
+ ## 1.5.5: 2019-10-24
10
10
 
11
- * `run-regression-test`: Added `--mail-from` option.
11
+ ### Improvements
12
12
 
13
- * `format-regression-test-logs`: Added support for slow queries.
13
+ * `run-regression-test`: Added `--performance-choose-strategy` option.
14
14
 
15
15
  ## 1.5.4: 2019-10-23
16
16
 
@@ -80,7 +80,6 @@ module GroongaQueryLog
80
80
  smtp_auth_password: nil,
81
81
  smtp_starttls: false,
82
82
  smtp_port: 25,
83
- path: "#{@working_directory}/results",
84
83
  }
85
84
  end
86
85
 
@@ -95,12 +94,17 @@ module GroongaQueryLog
95
94
 
96
95
  notifier = MailNotifier.new(@notifier_options)
97
96
  notifier.notify_started
97
+
98
98
  start_time = Time.now
99
99
  tester = Tester.new(old_groonga_server,
100
100
  new_groonga_server,
101
101
  tester_options)
102
102
  success = tester.run
103
- notifier.notify_finished(success, Time.now - start_time)
103
+ elapsed_time = Time.now - start_time
104
+
105
+ report = format_report(success, elapsed_time)
106
+ notifier.notify_finished(success, report)
107
+ puts(report)
104
108
 
105
109
  success
106
110
  end
@@ -346,10 +350,15 @@ module GroongaQueryLog
346
350
  parser
347
351
  end
348
352
 
353
+ def results_directory
354
+ @working_directory + "results"
355
+ end
356
+
349
357
  def directory_options
350
358
  {
351
359
  :input_directory => @input_directory,
352
360
  :working_directory => @working_directory,
361
+ :results_directory => results_directory,
353
362
  }
354
363
  end
355
364
 
@@ -404,6 +413,34 @@ module GroongaQueryLog
404
413
  server_options)
405
414
  end
406
415
 
416
+ def format_report(success, elapsed_time)
417
+ formatted = format_elapsed_time(elapsed_time)
418
+ if success
419
+ formatted << "Success"
420
+ else
421
+ formatted << "Failure"
422
+ output = StringIO.new
423
+ formetter = FormatRegressionTestLogs.new(output: output)
424
+ formetter.run([results_directory])
425
+ formatted << "Report:\n"
426
+ formatted << output.string
427
+ end
428
+ formatted
429
+ end
430
+
431
+ def format_elapsed_time(elapsed_time)
432
+ elapsed_seconds = elapsed_time % 60
433
+ elapsed_minutes = elapsed_time / 60 % 60
434
+ elapsed_hours = elapsed_time / 60 / 60 % 24
435
+ elapsed_days = elapsed_time / 60 / 60 / 24
436
+ "Elapsed: %ddays %02d:%02d:%02d\n" % [
437
+ elapsed_days,
438
+ elapsed_hours,
439
+ elapsed_minutes,
440
+ elapsed_seconds
441
+ ]
442
+ end
443
+
407
444
  module Loggable
408
445
  def puts(*args)
409
446
  $stdout.puts(*args)
@@ -561,6 +598,8 @@ module GroongaQueryLog
561
598
  @new = new
562
599
  @input_directory = options[:input_directory] || Pathname.new(".")
563
600
  @working_directory = options[:working_directory] || Pathname.new(".")
601
+ @results_directory =
602
+ options[:results_directory] || (@working_directory + "results")
564
603
  @n_clients = options[:n_clients] || 1
565
604
  @stop_on_failure = options[:stop_on_failure]
566
605
  @options = options
@@ -708,7 +747,7 @@ module GroongaQueryLog
708
747
  end
709
748
 
710
749
  def test_log_path(query_log_path)
711
- @working_directory + "results" + "#{query_log_path.basename}.log"
750
+ @results_directory + "#{query_log_path.basename}.log"
712
751
  end
713
752
 
714
753
  def use_persistent_cache?
@@ -719,7 +758,6 @@ module GroongaQueryLog
719
758
  class MailNotifier
720
759
  def initialize(options)
721
760
  @options = options
722
- @path = @options[:path] || "results"
723
761
  end
724
762
 
725
763
  def notify_started
@@ -729,39 +767,18 @@ module GroongaQueryLog
729
767
  send_mail(subject, "")
730
768
  end
731
769
 
732
- def notify_finished(success, elapsed_time)
770
+ def notify_finished(success, report)
733
771
  return unless @options[:mail_to]
734
772
 
735
- output = StringIO.new
736
- formetter = FormatRegressionTestLogs.new(output: output)
737
- formetter.run([@path])
738
- formatted_log = output.string
739
-
740
- content = format_elapsed_time(elapsed_time)
741
773
  if success
742
774
  subject = @options[:mail_subject_on_success]
743
775
  else
744
776
  subject = @options[:mail_subject_on_failure]
745
- content << "Report:\n"
746
- content << formatted_log
747
777
  end
748
- send_mail(subject, content)
778
+ send_mail(subject, report)
749
779
  end
750
780
 
751
781
  private
752
- def format_elapsed_time(elapsed_time)
753
- elapsed_seconds = elapsed_time % 60
754
- elapsed_minutes = elapsed_time / 60 % 60
755
- elapsed_hours = elapsed_time / 60 / 60 % 24
756
- elapsed_days = elapsed_time / 60 / 60 / 24
757
- "Elapsed: %ddays %02d:%02d:%02d\n" % [
758
- elapsed_days,
759
- elapsed_hours,
760
- elapsed_minutes,
761
- elapsed_seconds
762
- ]
763
- end
764
-
765
782
  def send_mail(subject, content)
766
783
  header = <<-HEADER
767
784
  MIME-Version: 1.0
@@ -15,5 +15,5 @@
15
15
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
  module GroongaQueryLog
18
- VERSION = "1.5.5"
18
+ VERSION = "1.5.6"
19
19
  end
@@ -83,6 +83,13 @@ class RunRegressionTestCommandTest < Test::Unit::TestCase
83
83
  "Date: #{@now}\r\n")
84
84
  end
85
85
 
86
+ def normalize_output(output)
87
+ output
88
+ .gsub(/^\[.*\n/, "")
89
+ .gsub(/^Running.*\n/, "")
90
+ .gsub(/^Elapsed: \d+days \d{2}:\d{2}:\d{2}$/, "Elapsed: 0days 00:00:00")
91
+ end
92
+
86
93
  def fixture_path(*components)
87
94
  super("run-regression-test", *components)
88
95
  end
@@ -93,6 +100,16 @@ class RunRegressionTestCommandTest < Test::Unit::TestCase
93
100
  end
94
101
  end
95
102
 
103
+ def test_success
104
+ success, output = run_command([])
105
+ assert_equal([
106
+ true,
107
+ "Elapsed: 0days 00:00:00\n" +
108
+ "Success\n"
109
+ ],
110
+ [success, normalize_output(output)])
111
+ end
112
+
96
113
  def test_mail_from
97
114
  success, _output = run_command(["--smtp-server", @smtp_host,
98
115
  "--smtp-port", @smtp_port.to_s,
@@ -156,7 +173,7 @@ QUIT
156
173
  :path => fixture_path("mail-notifier/success.log"),
157
174
  }
158
175
  notifier = MailNotifier.new(options)
159
- notifier.notify_finished(true, 3000)
176
+ notifier.notify_finished(true, "report")
160
177
  assert_equal(<<-REQUEST.gsub(/\n/, "\r\n").b, normalized_smtp_request)
161
178
  EHLO 127.0.0.1
162
179
  MAIL FROM:<#{options[:mail_from]}>
@@ -172,8 +189,7 @@ To: #{options[:mail_to]}
172
189
  Subject: Success
173
190
  Date: #{@now}
174
191
 
175
- Elapsed: 0days 00:50:00
176
-
192
+ report
177
193
  .
178
194
  QUIT
179
195
  REQUEST
@@ -190,7 +206,7 @@ QUIT
190
206
  :path => fixture_path("mail-notifier/failure.log"),
191
207
  }
192
208
  notifier = MailNotifier.new(options)
193
- notifier.notify_finished(false, 3000)
209
+ notifier.notify_finished(false, "report")
194
210
  assert_equal(<<-REQUEST.gsub(/\n/, "\r\n").b, normalized_smtp_request)
195
211
  EHLO 127.0.0.1
196
212
  MAIL FROM:<#{options[:mail_from]}>
@@ -206,24 +222,7 @@ To: #{options[:mail_to]}
206
222
  Subject: Failure
207
223
  Date: #{@now}
208
224
 
209
- Elapsed: 0days 00:50:00
210
- Report:
211
- Command:
212
- /d/select?table=Logs&match_columns=message&query=%E7%84%BC%E8%82%89
213
- Name: select
214
- Arguments:
215
- match_columns: message
216
- query: 焼肉
217
- table: Logs
218
- --- old
219
- +++ new
220
- @@ -1,5 +1,5 @@
221
- [[[2],
222
- [["_id", "UInt32"], ["message", "Text"]],
223
- [1, "log message1: 焼肉"],
224
- - [2, "log message2: 焼肉"]]]
225
- + [3, "log message3: 焼肉"]]]
226
-
225
+ report
227
226
  .
228
227
  QUIT
229
228
  REQUEST
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groonga-query-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-24 00:00:00.000000000 Z
11
+ date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: charty