[Groonga-commit] groonga/grntest at ed0dc4d [master] Fix wrong Executor#shutdown result usage

Back to archive index
Kouhei Sutou null+****@clear*****
Mon Nov 19 11:50:07 JST 2018


Kouhei Sutou	2018-11-19 11:50:07 +0900 (Mon, 19 Nov 2018)

  Revision: ed0dc4d82b2b0de766a5f851c916b06dba457484
  https://github.com/groonga/grntest/commit/ed0dc4d82b2b0de766a5f851c916b06dba457484

  Message:
    Fix wrong Executor#shutdown result usage

  Modified files:
    lib/grntest/execution-context.rb
    lib/grntest/executors/base-executor.rb
    lib/grntest/test-runner.rb

  Modified: lib/grntest/execution-context.rb (+2 -0)
===================================================================
--- lib/grntest/execution-context.rb    2018-11-19 11:15:58 +0900 (e3445a4)
+++ lib/grntest/execution-context.rb    2018-11-19 11:50:07 +0900 (968ef99)
@@ -26,6 +26,7 @@ module Grntest
     attr_accessor :read_timeout
     attr_accessor :default_timeout
     attr_accessor :default_read_timeout
+    attr_accessor :shutdown_wait_timeout
     attr_writer :suppress_backtrace
     attr_writer :collect_query_log
     attr_writer :debug
@@ -46,6 +47,7 @@ module Grntest
       @read_timeout = 3
       @default_timeout = @timeout
       @default_read_timeout = @read_timeout
+      @shutdown_wait_timeout = 5
       @omitted = false
       @suppress_backtrace = true
       @collect_query_log = false

  Modified: lib/grntest/executors/base-executor.rb (+1 -2)
===================================================================
--- lib/grntest/executors/base-executor.rb    2018-11-19 11:15:58 +0900 (e8481f4)
+++ lib/grntest/executors/base-executor.rb    2018-11-19 11:50:07 +0900 (014a38e)
@@ -83,7 +83,6 @@ module Grntest
         end
 
         status = nil
-        timeout = 1
         total_sleep_time = 0
         sleep_time = 0.05
         loop do
@@ -91,7 +90,7 @@ module Grntest
           break if status
           sleep(sleep_time)
           total_sleep_time += sleep_time
-          return false if total_sleep_time > timeout
+          return false if total_sleep_time > context.shutdown_wait_timeout
         end
 
         log_error(read_all_log) unless status.success?

  Modified: lib/grntest/test-runner.rb (+5 -6)
===================================================================
--- lib/grntest/test-runner.rb    2018-11-19 11:15:58 +0900 (7344b3e)
+++ lib/grntest/test-runner.rb    2018-11-19 11:50:07 +0900 (e3bf8ed)
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2015  Kouhei Sutou <kou****@clear*****>
+# Copyright (C) 2012-2018  Kouhei Sutou <kou****@clear*****>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -142,6 +142,7 @@ module Grntest
         context.read_timeout =****@teste*****_timeout
         context.default_timeout = context.timeout
         context.default_read_timeout = context.read_timeout
+        context.shutdown_wait_timeout =****@teste*****_wait_timeout
         context.suppress_backtrace =****@teste*****_backtrace?
         context.debug =****@teste*****?
         run_groonga(context) do |executor|
@@ -379,6 +380,8 @@ call chdir("#{context.temporary_directory_path}")
           yield(executor)
         ensure
           if executor.shutdown(pid)
+            pid = nil
+          else
             wait_groonga_http_shutdown(pid_file_path)
             pid = nil if wait_pid(pid)
           end
@@ -427,11 +430,7 @@ call chdir("#{context.temporary_directory_path}")
       total_sleep_time = 0
       sleep_time = 0.1
       loop do
-        begin
-          return true if Process.waitpid(pid, Process::WNOHANG)
-        rescue SystemCallError
-          return true
-        end
+        return true if Process.waitpid(pid, Process::WNOHANG)
         sleep(sleep_time)
         total_sleep_time += sleep_time
         return false if total_sleep_time > @tester.shutdown_wait_timeout
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20181119/a889673a/attachment-0001.html>


More information about the Groonga-commit mailing list
Back to archive index