[Groonga-commit] groonga/grntest [master] Create a temporary config file for HTTP tests with groonga-httpd

Back to archive index

null+****@clear***** null+****@clear*****
2012年 6月 11日 (月) 15:26:27 JST


Haruka Yoshihara	2012-06-11 15:26:27 +0900 (Mon, 11 Jun 2012)

  New Revision: 8d3b0963eb1131cf09b1f2b8b13cb32bbef1f9a8

  Log:
    Create a temporary config file for HTTP tests with groonga-httpd

  Modified files:
    lib/groonga/tester.rb

  Modified: lib/groonga/tester.rb (+26 -5)
===================================================================
--- lib/groonga/tester.rb    2012-06-08 18:14:32 +0900 (1857fd9)
+++ lib/groonga/tester.rb    2012-06-11 15:26:27 +0900 (aa21efe)
@@ -318,15 +318,18 @@ module Groonga
       def run_groonga_http(context)
         host = "127.0.0.1"
         port = 50041
+        pid_file = Tempfile.new("groonga.pid")
 
         if /groonga-httpd$/ =~ @tester.groonga
           db_path = context.db_path
-          config_file = create_temporary_config_file(host, port, db_path)
+          config_file =
+            create_temporary_config_file(host, port, db_path, pid_file)
           groonga_options = [
             "-c", config_file.path,
           ]
         else
           groonga_options = [
+            "--pid-path", pid_file.path,
             "--bind-address", host,
             "--port", port.to_s,
             "--protocol", @tester.protocol.to_s,
@@ -335,10 +338,8 @@ module Groonga
           ]
         end
 
-        pid_file = Tempfile.new("groonga.pid")
         command_line = [
           @tester.groonga,
-          "--pid-path", pid_file.path,
         ]
         command_line.concat(groonga_options)
         system(*command_line)
@@ -362,8 +363,28 @@ module Groonga
         end
       end
 
-      def create_temporary_config_file(host, port, db_path)
-        Tempfile.new("test-httpd.conf")
+      def create_temporary_config_file(host, port, db_path, pid_file)
+        config_file = Tempfile.new("test-httpd.conf")
+        config_file.puts <<EOF
+worker_processes 1;
+pid #{pid_file.path};
+events {
+     worker_connections 1024;
+}
+
+http {
+     server {
+             listen #{port};
+             server_name #{host};
+             location /d/ {
+                     groonga_database #{db_path};
+                     groonga;
+            }
+     }
+}
+EOF
+        config_file.close
+        config_file
       end
 
       def normalize_result(result)




Groonga-commit メーリングリストの案内
Back to archive index