Navigation Menu

Skip to content

Commit

Permalink
Migrate to droonga-engine from fluent-plugin-droonga
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 17, 2014
1 parent 775794b commit d9c90e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 28 deletions.
6 changes: 3 additions & 3 deletions lib/drntest/configuration.rb
Expand Up @@ -17,7 +17,7 @@ module Drntest
class Configuration
attr_accessor :port, :host, :tag
attr_accessor :base_path, :engine_config
attr_accessor :fluentd, :fluentd_options
attr_accessor :droonga_engine, :droonga_engine_options
attr_accessor :catalog_version

def initialize
Expand All @@ -26,8 +26,8 @@ def initialize
@tag = "droonga"
@base_path = Pathname(Dir.pwd)
@engine_config = "default"
@fluentd = "fluentd"
@fluentd_options = []
@droonga_engine = "droonga-engine"
@droonga_engine_options = []
@catalog_version = "2"
end

Expand Down
23 changes: 5 additions & 18 deletions lib/drntest/engine.rb
Expand Up @@ -32,10 +32,6 @@ def stop
teardown
end

def config_file
@config.engine_config_path + "fluentd.conf"
end

def catalog_file
@config.engine_config_path + "catalog.json"
end
Expand Down Expand Up @@ -101,23 +97,20 @@ def extract_connection_info_catalog_v2(catalog_json)
end

def setup(target_path)
return unless temporary?

setup_temporary_dir

temporary_config = temporary_dir + "fluentd.conf"
FileUtils.cp(config_file, temporary_config)

catalog_json = load_catalog_json(target_path)
temporary_catalog = temporary_dir + "catalog.json"
temporary_catalog.open("w") do |output|
output.puts(JSON.pretty_generate(catalog_json))
end

command = [
@config.fluentd,
"--config", temporary_config.to_s,
*@config.fluentd_options,
@config.droonga_engine,
"--host", @config.host,
"--port", @config.port.to_s,
"--tag", @config.tag,
*@config.droonga_engine_options,
]
env = {
"DROONGA_CATALOG" => temporary_catalog.to_s,
Expand All @@ -134,8 +127,6 @@ def setup(target_path)
end

def teardown
return unless temporary?

Process.kill(:TERM, @pid)
Process.wait(@pid)

Expand Down Expand Up @@ -164,10 +155,6 @@ def temporary_dir
temporary_base_dir + "drntest"
end

def temporary?
@config.fluentd && config_file.exist?
end

def ready?
begin
socket = TCPSocket.new(@config.host, @config.port)
Expand Down
14 changes: 7 additions & 7 deletions lib/drntest/tester.rb
Expand Up @@ -95,16 +95,16 @@ def create_option_parser
@config.engine_config = config
end

parser.on("--fluentd=PATH",
"Path to the fluentd executable",
"(#{@config.fluentd})") do |fluentd|
@config.fluentd = fluentd
parser.on("--droonga-engine=PATH",
"Path to the droonga-engine executable",
"(#{@config.droonga_engine})") do |droonga_engine|
@config.droonga_engine = droonga_engine
end

parser.on("--fluentd-options=OPTIONS",
"Options for fluentd",
parser.on("--droonga-engine-options=OPTIONS",
"Options for droonga-engine",
"You can specify this option multiple times") do |options|
@config.fluentd_options.concat(Shellwords.split(options))
@config.droonga_engine_options.concat(Shellwords.split(options))
end

parser.on("--test=PATTERN",
Expand Down

0 comments on commit d9c90e4

Please sign in to comment.