Class: Groonga::QueryLog::Command::RunRegressionTest::GroongaServer

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga/query-log/command/run-regression-test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(groonga, database_path, options) ⇒ GroongaServer

Returns a new instance of GroongaServer.



164
165
166
167
168
169
170
171
172
# File 'lib/groonga/query-log/command/run-regression-test.rb', line 164

def initialize(groonga, database_path, options)
  @input_directory = options[:input_directory] || Pathname.new(".")
  @working_directory = options[:working_directory] || Pathname.new(".")
  @groonga = groonga
  @database_path = @working_directory + database_path
  @host = "127.0.0.1"
  @port = find_unused_port
  @options = options
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



163
164
165
# File 'lib/groonga/query-log/command/run-regression-test.rb', line 163

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



163
164
165
# File 'lib/groonga/query-log/command/run-regression-test.rb', line 163

def port
  @port
end

Instance Method Details

#runObject



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/groonga/query-log/command/run-regression-test.rb', line 174

def run
  ensure_database
  return unless @options[:run_queries]

  @pid = spawn(@groonga,
               "--bind-address", @host,
               "--port", @port.to_s,
               "--log-path", log_path.to_s,
               "--query-log-path", query_log_path.to_s,
               "--protocol", "http",
               "-s",
               @database_path.to_s)

  n_retries = 10
  begin
    send_command("status")
  rescue SystemCallError
    sleep(1)
    n_retries -= 1
    raise if n_retries.zero?
    retry
  end

  yield
end

#shutdownObject



200
201
202
203
204
205
206
# File 'lib/groonga/query-log/command/run-regression-test.rb', line 200

def shutdown
  begin
    send_command("shutdown")
  rescue SystemCallError
  end
  Process.waitpid(@pid)
end