From 6802dc2a8a282ba2e7c0370ff3dc17302a32be91 Mon Sep 17 00:00:00 2001 From: TAGOMORI Satoshi Date: Wed, 10 Feb 2016 00:40:24 +0900 Subject: [PATCH] Fix to do `require` for required files straightforward, per files * Currently, all required files are loaded by `lib/fluent/load.rb` even for tests * This file creates the implicit order of files to be loaded * There's no explicit dependency definition, and there are many circular dependencies * This situation is totally broken * Without this change, we can't run tests by `bundle exec rake test TEST=test/file.rb` * Running whole tests consumes long time, and it's not acceptable This change is to make straightforward dependency from all files to others. We can load any file in fluentd source code, make clean dependencies, and also can run each files itself to test it. --- lib/fluent/agent.rb | 9 ++-- lib/fluent/buffer.rb | 6 +++ lib/fluent/command/bundler_injection.rb | 3 ++ lib/fluent/command/cat.rb | 2 +- lib/fluent/command/debug.rb | 5 ++- lib/fluent/command/fluentd.rb | 3 +- lib/fluent/config.rb | 9 ++-- lib/fluent/config/basic_parser.rb | 7 ++- lib/fluent/config/configure_proxy.rb | 2 + lib/fluent/config/dsl.rb | 3 ++ lib/fluent/config/element.rb | 5 ++- lib/fluent/config/literal_parser.rb | 13 +++--- lib/fluent/config/parser.rb | 8 ++-- lib/fluent/config/section.rb | 6 +-- lib/fluent/config/types.rb | 7 ++- lib/fluent/config/v1_parser.rb | 14 +++--- lib/fluent/configurable.rb | 12 ++--- lib/fluent/engine.rb | 19 +++++--- lib/fluent/event.rb | 2 + lib/fluent/event_router.rb | 6 ++- lib/fluent/filter.rb | 6 +++ lib/fluent/formatter.rb | 6 ++- lib/fluent/input.rb | 5 +++ lib/fluent/label.rb | 4 +- lib/fluent/log.rb | 5 ++- lib/fluent/mixin.rb | 6 ++- lib/fluent/output.rb | 10 ++++- lib/fluent/parser.rb | 14 +++++- lib/fluent/plugin.rb | 6 +++ lib/fluent/plugin/buf_file.rb | 7 +++ lib/fluent/plugin/buf_memory.rb | 6 +++ lib/fluent/plugin/exec_util.rb | 9 +++- lib/fluent/plugin/filter_grep.rb | 3 ++ .../plugin/filter_record_transformer.rb | 12 ++--- lib/fluent/plugin/filter_stdout.rb | 3 ++ lib/fluent/plugin/in_debug_agent.rb | 2 + lib/fluent/plugin/in_dummy.rb | 5 +++ lib/fluent/plugin/in_exec.rb | 8 +++- lib/fluent/plugin/in_forward.rb | 7 +++ lib/fluent/plugin/in_gc_stat.rb | 4 ++ lib/fluent/plugin/in_http.rb | 11 ++++- lib/fluent/plugin/in_monitor_agent.rb | 17 ++++--- lib/fluent/plugin/in_object_space.rb | 5 +++ lib/fluent/plugin/in_stream.rb | 9 ++++ lib/fluent/plugin/in_syslog.rb | 8 +++- lib/fluent/plugin/in_tail.rb | 6 +++ lib/fluent/plugin/in_tcp.rb | 2 + lib/fluent/plugin/out_copy.rb | 4 ++ lib/fluent/plugin/out_exec.rb | 5 ++- lib/fluent/plugin/out_exec_filter.rb | 7 +++ lib/fluent/plugin/out_file.rb | 6 +++ lib/fluent/plugin/out_forward.rb | 12 +++-- lib/fluent/plugin/out_null.rb | 2 + lib/fluent/plugin/out_relabel.rb | 2 + lib/fluent/plugin/out_roundrobin.rb | 3 ++ lib/fluent/plugin/out_stdout.rb | 2 + lib/fluent/plugin/out_stream.rb | 12 ++--- lib/fluent/plugin/socket_util.rb | 6 ++- lib/fluent/process.rb | 6 +++ lib/fluent/registry.rb | 6 ++- lib/fluent/root_agent.rb | 13 +++--- lib/fluent/rpc.rb | 4 +- lib/fluent/supervisor.rb | 44 ++++--------------- lib/fluent/system_config.rb | 12 +++-- lib/fluent/test.rb | 2 +- lib/fluent/test/base.rb | 4 ++ lib/fluent/test/filter_test.rb | 3 ++ lib/fluent/test/formatter_test.rb | 5 ++- lib/fluent/test/input_test.rb | 5 +++ lib/fluent/test/output_test.rb | 4 ++ lib/fluent/test/parser_test.rb | 5 ++- lib/fluent/timezone.rb | 2 + test/plugin/test_in_forward.rb | 4 ++ test/test_event_router.rb | 1 + test/test_plugin_classes.rb | 3 ++ test/test_process.rb | 1 + test/test_root_agent.rb | 1 + 77 files changed, 371 insertions(+), 142 deletions(-) diff --git a/lib/fluent/agent.rb b/lib/fluent/agent.rb index 1c766fe197..9543b4a277 100644 --- a/lib/fluent/agent.rb +++ b/lib/fluent/agent.rb @@ -13,10 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # -module Fluent - require 'fluent/configurable' - require 'fluent/engine' +require 'fluent/configurable' +require 'fluent/engine' +require 'fluent/plugin' +require 'fluent/output' + +module Fluent # # Agent is a resource unit who manages emittable plugins # diff --git a/lib/fluent/buffer.rb b/lib/fluent/buffer.rb index 2187d835f1..d7327ddcbd 100644 --- a/lib/fluent/buffer.rb +++ b/lib/fluent/buffer.rb @@ -13,6 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # + +require 'monitor' +require 'fileutils' + +require 'fluent/configurable' + module Fluent class BufferError < StandardError end diff --git a/lib/fluent/command/bundler_injection.rb b/lib/fluent/command/bundler_injection.rb index 8e244f7ce5..5b90e0684b 100644 --- a/lib/fluent/command/bundler_injection.rb +++ b/lib/fluent/command/bundler_injection.rb @@ -14,6 +14,9 @@ # limitations under the License. # +require 'rbconfig' +require 'rubygems' + if ENV['BUNDLE_BIN_PATH'] puts 'error: You seem to use `bundle exec` already.' exit 1 diff --git a/lib/fluent/command/cat.rb b/lib/fluent/command/cat.rb index 8ec8a5e2c1..172a066c86 100644 --- a/lib/fluent/command/cat.rb +++ b/lib/fluent/command/cat.rb @@ -66,7 +66,7 @@ message_key = s } -(class< :tsv, 'json' => :json, diff --git a/lib/fluent/plugin/filter_grep.rb b/lib/fluent/plugin/filter_grep.rb index 95a21bcd3d..be8b61a2fa 100644 --- a/lib/fluent/plugin/filter_grep.rb +++ b/lib/fluent/plugin/filter_grep.rb @@ -14,6 +14,9 @@ # limitations under the License. # +require 'fluent/filter' +require 'fluent/config/error' + module Fluent class GrepFilter < Filter Fluent::Plugin.register_filter('grep', self) diff --git a/lib/fluent/plugin/filter_record_transformer.rb b/lib/fluent/plugin/filter_record_transformer.rb index 3838c23700..36293d7e7d 100644 --- a/lib/fluent/plugin/filter_record_transformer.rb +++ b/lib/fluent/plugin/filter_record_transformer.rb @@ -14,17 +14,19 @@ # limitations under the License. # +require 'socket' +require 'json' require 'ostruct' +require 'fluent/filter' +require 'fluent/config/error' +require 'fluent/event' +require 'fluent/time' + module Fluent class RecordTransformerFilter < Filter Fluent::Plugin.register_filter('record_transformer', self) - def initialize - require 'socket' - super - end - desc 'A comma-delimited list of keys to delete.' config_param :remove_keys, :string, default: nil desc 'A comma-delimited list of keys to keep.' diff --git a/lib/fluent/plugin/filter_stdout.rb b/lib/fluent/plugin/filter_stdout.rb index 5ab0290a99..4fc14d4c43 100644 --- a/lib/fluent/plugin/filter_stdout.rb +++ b/lib/fluent/plugin/filter_stdout.rb @@ -14,6 +14,9 @@ # limitations under the License. # +require 'fluent/filter' +require 'fluent/plugin' + module Fluent class StdoutFilter < Filter Plugin.register_filter('stdout', self) diff --git a/lib/fluent/plugin/in_debug_agent.rb b/lib/fluent/plugin/in_debug_agent.rb index 60a6ffea97..cfb196298b 100644 --- a/lib/fluent/plugin/in_debug_agent.rb +++ b/lib/fluent/plugin/in_debug_agent.rb @@ -14,6 +14,8 @@ # limitations under the License. # +require 'fluent/input' + module Fluent class DebugAgentInput < Input Plugin.register_input('debug_agent', self) diff --git a/lib/fluent/plugin/in_dummy.rb b/lib/fluent/plugin/in_dummy.rb index b436eb2210..365eb975f4 100644 --- a/lib/fluent/plugin/in_dummy.rb +++ b/lib/fluent/plugin/in_dummy.rb @@ -14,6 +14,11 @@ # limitations under the License. # +require 'json' + +require 'fluent/input' +require 'fluent/config/error' + module Fluent class DummyInput < Input Fluent::Plugin.register_input('dummy', self) diff --git a/lib/fluent/plugin/in_exec.rb b/lib/fluent/plugin/in_exec.rb index b5ea3e3e97..b9274400ca 100644 --- a/lib/fluent/plugin/in_exec.rb +++ b/lib/fluent/plugin/in_exec.rb @@ -14,6 +14,13 @@ # limitations under the License. # +require 'yajl' + +require 'fluent/input' +require 'fluent/time' +require 'fluent/timezone' +require 'fluent/config/error' + module Fluent class ExecInput < Input Plugin.register_input('exec', self) @@ -21,7 +28,6 @@ class ExecInput < Input def initialize super require 'fluent/plugin/exec_util' - require 'fluent/timezone' end desc 'The command (program) to execute.' diff --git a/lib/fluent/plugin/in_forward.rb b/lib/fluent/plugin/in_forward.rb index c9d6d51a20..7a4c2189ea 100644 --- a/lib/fluent/plugin/in_forward.rb +++ b/lib/fluent/plugin/in_forward.rb @@ -14,6 +14,13 @@ # limitations under the License. # +require 'fcntl' + +require 'cool.io' +require 'yajl' + +require 'fluent/input' + module Fluent class ForwardInput < Input Plugin.register_input('forward', self) diff --git a/lib/fluent/plugin/in_gc_stat.rb b/lib/fluent/plugin/in_gc_stat.rb index e0dbfdea41..22690f3e7e 100644 --- a/lib/fluent/plugin/in_gc_stat.rb +++ b/lib/fluent/plugin/in_gc_stat.rb @@ -14,6 +14,10 @@ # limitations under the License. # +require 'cool.io' + +require 'fluent/input' + module Fluent class GCStatInput < Input Plugin.register_input('gc_stat', self) diff --git a/lib/fluent/plugin/in_http.rb b/lib/fluent/plugin/in_http.rb index 255a5c5fe3..aee6c3a8fa 100644 --- a/lib/fluent/plugin/in_http.rb +++ b/lib/fluent/plugin/in_http.rb @@ -14,6 +14,16 @@ # limitations under the License. # +require 'uri' +require 'socket' +require 'json' + +require 'cool.io' + +require 'fluent/input' +require 'fluent/event' +require 'fluent/process' + module Fluent class HttpInput < Input Plugin.register_input('http', self) @@ -24,7 +34,6 @@ class HttpInput < Input def initialize require 'webrick/httputils' - require 'uri' super end diff --git a/lib/fluent/plugin/in_monitor_agent.rb b/lib/fluent/plugin/in_monitor_agent.rb index 9ec0a5a1d7..e4389fc4ba 100644 --- a/lib/fluent/plugin/in_monitor_agent.rb +++ b/lib/fluent/plugin/in_monitor_agent.rb @@ -14,17 +14,20 @@ # limitations under the License. # +require 'json' +require 'webrick' +require 'cgi' + +require 'cool.io' + +require 'fluent/input' +require 'fluent/output' +require 'fluent/filter' + module Fluent class MonitorAgentInput < Input Plugin.register_input('monitor_agent', self) - require 'webrick' - - def initialize - require 'cgi' - super - end - config_param :bind, :string, default: '0.0.0.0' config_param :port, :integer, default: 24220 config_param :tag, :string, default: nil diff --git a/lib/fluent/plugin/in_object_space.rb b/lib/fluent/plugin/in_object_space.rb index d29e90905d..e3c28399fb 100644 --- a/lib/fluent/plugin/in_object_space.rb +++ b/lib/fluent/plugin/in_object_space.rb @@ -14,6 +14,11 @@ # limitations under the License. # +require 'cool.io' +require 'yajl' + +require 'fluent/input' + module Fluent class ObjectSpaceInput < Input Plugin.register_input('object_space', self) diff --git a/lib/fluent/plugin/in_stream.rb b/lib/fluent/plugin/in_stream.rb index d2f9c030aa..3f2d1fcba4 100644 --- a/lib/fluent/plugin/in_stream.rb +++ b/lib/fluent/plugin/in_stream.rb @@ -14,6 +14,15 @@ # limitations under the License. # +require 'fileutils' +require 'socket' + +require 'cool.io' +require 'yajl' + +require 'fluent/input' +require 'fluent/event' + module Fluent # obsolete class StreamInput < Input diff --git a/lib/fluent/plugin/in_syslog.rb b/lib/fluent/plugin/in_syslog.rb index fc7d5e2b9d..0f4291fe65 100644 --- a/lib/fluent/plugin/in_syslog.rb +++ b/lib/fluent/plugin/in_syslog.rb @@ -14,6 +14,13 @@ # limitations under the License. # +require 'cool.io' +require 'yajl' + +require 'fluent/input' +require 'fluent/config/error' +require 'fluent/parser' + module Fluent class SyslogInput < Input Plugin.register_input('syslog', self) @@ -60,7 +67,6 @@ class SyslogInput < Input def initialize super - require 'cool.io' require 'fluent/plugin/socket_util' end diff --git a/lib/fluent/plugin/in_tail.rb b/lib/fluent/plugin/in_tail.rb index fc8c51ac47..b5fb28bf7d 100644 --- a/lib/fluent/plugin/in_tail.rb +++ b/lib/fluent/plugin/in_tail.rb @@ -14,6 +14,12 @@ # limitations under the License. # +require 'cool.io' + +require 'fluent/input' +require 'fluent/config/error' +require 'fluent/event' + module Fluent class NewTailInput < Input Plugin.register_input('tail', self) diff --git a/lib/fluent/plugin/in_tcp.rb b/lib/fluent/plugin/in_tcp.rb index df02c5ecbf..cfac648bf9 100644 --- a/lib/fluent/plugin/in_tcp.rb +++ b/lib/fluent/plugin/in_tcp.rb @@ -14,6 +14,8 @@ # limitations under the License. # +require 'cool.io' + require 'fluent/plugin/socket_util' module Fluent diff --git a/lib/fluent/plugin/out_copy.rb b/lib/fluent/plugin/out_copy.rb index de43630589..c26804b218 100644 --- a/lib/fluent/plugin/out_copy.rb +++ b/lib/fluent/plugin/out_copy.rb @@ -14,6 +14,10 @@ # limitations under the License. # +require 'fluent/output' +require 'fluent/config/error' +require 'fluent/event' + module Fluent class CopyOutput < MultiOutput Plugin.register_output('copy', self) diff --git a/lib/fluent/plugin/out_exec.rb b/lib/fluent/plugin/out_exec.rb index 2062afda51..653686bf3e 100644 --- a/lib/fluent/plugin/out_exec.rb +++ b/lib/fluent/plugin/out_exec.rb @@ -14,6 +14,10 @@ # limitations under the License. # +require 'tempfile' + +require 'fluent/output' +require 'fluent/config/error' require 'fluent/plugin/exec_util' module Fluent @@ -22,7 +26,6 @@ class ExecOutput < TimeSlicedOutput def initialize super - require 'tempfile' @localtime = false end diff --git a/lib/fluent/plugin/out_exec_filter.rb b/lib/fluent/plugin/out_exec_filter.rb index 46021c37bc..4e549a84fe 100644 --- a/lib/fluent/plugin/out_exec_filter.rb +++ b/lib/fluent/plugin/out_exec_filter.rb @@ -14,7 +14,14 @@ # limitations under the License. # +require 'yajl' + +require 'fluent/output' +require 'fluent/env' +require 'fluent/time' +require 'fluent/timezone' require 'fluent/plugin/exec_util' +require 'fluent/config/error' module Fluent class ExecFilterOutput < BufferedOutput diff --git a/lib/fluent/plugin/out_file.rb b/lib/fluent/plugin/out_file.rb index 08e355cd5c..d2d795acad 100644 --- a/lib/fluent/plugin/out_file.rb +++ b/lib/fluent/plugin/out_file.rb @@ -14,6 +14,12 @@ # limitations under the License. # +require 'fileutils' +require 'zlib' + +require 'fluent/output' +require 'fluent/config/error' + module Fluent class FileOutput < TimeSlicedOutput Plugin.register_output('file', self) diff --git a/lib/fluent/plugin/out_forward.rb b/lib/fluent/plugin/out_forward.rb index 3063b8caa6..57d747095a 100644 --- a/lib/fluent/plugin/out_forward.rb +++ b/lib/fluent/plugin/out_forward.rb @@ -14,6 +14,15 @@ # limitations under the License. # +require 'base64' +require 'socket' +require 'fileutils' + +require 'cool.io' + +require 'fluent/output' +require 'fluent/config/error' + module Fluent class ForwardOutputError < StandardError end @@ -29,9 +38,6 @@ class ForwardOutput < ObjectBufferedOutput def initialize super - require "base64" - require 'socket' - require 'fileutils' require 'fluent/plugin/socket_util' @nodes = [] #=> [Node] end diff --git a/lib/fluent/plugin/out_null.rb b/lib/fluent/plugin/out_null.rb index e60ab03af0..032f683a99 100644 --- a/lib/fluent/plugin/out_null.rb +++ b/lib/fluent/plugin/out_null.rb @@ -14,6 +14,8 @@ # limitations under the License. # +require 'fluent/output' + module Fluent class NullOutput < Output Plugin.register_output('null', self) diff --git a/lib/fluent/plugin/out_relabel.rb b/lib/fluent/plugin/out_relabel.rb index 82196b43f3..9622e66f29 100644 --- a/lib/fluent/plugin/out_relabel.rb +++ b/lib/fluent/plugin/out_relabel.rb @@ -14,6 +14,8 @@ # limitations under the License. # +require 'fluent/output' + module Fluent class RelabelOutput < Output Plugin.register_output('relabel', self) diff --git a/lib/fluent/plugin/out_roundrobin.rb b/lib/fluent/plugin/out_roundrobin.rb index 34212b4bc9..a17195ea21 100644 --- a/lib/fluent/plugin/out_roundrobin.rb +++ b/lib/fluent/plugin/out_roundrobin.rb @@ -14,6 +14,9 @@ # limitations under the License. # +require 'fluent/output' +require 'fluent/config/error' + module Fluent class RoundRobinOutput < MultiOutput Plugin.register_output('roundrobin', self) diff --git a/lib/fluent/plugin/out_stdout.rb b/lib/fluent/plugin/out_stdout.rb index fbaa700622..47968d3481 100644 --- a/lib/fluent/plugin/out_stdout.rb +++ b/lib/fluent/plugin/out_stdout.rb @@ -14,6 +14,8 @@ # limitations under the License. # +require 'fluent/output' + module Fluent class StdoutOutput < Output Plugin.register_output('stdout', self) diff --git a/lib/fluent/plugin/out_stream.rb b/lib/fluent/plugin/out_stream.rb index 2ee222010b..d66d2d53d2 100644 --- a/lib/fluent/plugin/out_stream.rb +++ b/lib/fluent/plugin/out_stream.rb @@ -14,15 +14,15 @@ # limitations under the License. # +require 'socket' +require 'fileutils' + +require 'fluent/output' +require 'fluent/event' + module Fluent # obsolete class StreamOutput < BufferedOutput - def initialize - require 'socket' - require 'fileutils' - super - end - config_param :send_timeout, :time, default: 60 def configure(conf) diff --git a/lib/fluent/plugin/socket_util.rb b/lib/fluent/plugin/socket_util.rb index 7b9829e879..c5fb7ad98c 100644 --- a/lib/fluent/plugin/socket_util.rb +++ b/lib/fluent/plugin/socket_util.rb @@ -14,13 +14,15 @@ # limitations under the License. # +require 'ipaddr' + require 'cool.io' +require 'fluent/plugin' + module Fluent module SocketUtil def create_udp_socket(host) - require 'ipaddr' - if IPAddr.new(IPSocket.getaddress(host)).ipv4? UDPSocket.new else diff --git a/lib/fluent/process.rb b/lib/fluent/process.rb index d2f87a0351..87151f8a48 100644 --- a/lib/fluent/process.rb +++ b/lib/fluent/process.rb @@ -14,6 +14,12 @@ # limitations under the License. # +require 'thread' + +require 'fluent/config' +require 'fluent/engine' +require 'fluent/event' + module Fluent class DetachProcessManager require 'singleton' diff --git a/lib/fluent/registry.rb b/lib/fluent/registry.rb index e5e1c87188..2500db891c 100644 --- a/lib/fluent/registry.rb +++ b/lib/fluent/registry.rb @@ -14,9 +14,11 @@ # limitations under the License. # -module Fluent - require 'fluent/config/error' +require 'rubygems' + +require 'fluent/config/error' +module Fluent class Registry def initialize(kind, search_prefix) @kind = kind diff --git a/lib/fluent/root_agent.rb b/lib/fluent/root_agent.rb index 147cea094b..35857652f8 100644 --- a/lib/fluent/root_agent.rb +++ b/lib/fluent/root_agent.rb @@ -13,14 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. # -module Fluent - require 'delegate' +require 'delegate' - require 'fluent/agent' - require 'fluent/label' - require 'fluent/system_config' +require 'fluent/config/error' +require 'fluent/agent' +require 'fluent/engine' +require 'fluent/label' +require 'fluent/plugin' +require 'fluent/system_config' +module Fluent # # Fluentd forms a tree structure to manage plugins: # diff --git a/lib/fluent/rpc.rb b/lib/fluent/rpc.rb index 2c7e70a16c..53b899ad81 100644 --- a/lib/fluent/rpc.rb +++ b/lib/fluent/rpc.rb @@ -14,10 +14,10 @@ # limitations under the License. # +require 'webrick' + module Fluent module RPC - require 'webrick' - class Server def initialize(endpoint, log) bind, port = endpoint.split(':') diff --git a/lib/fluent/supervisor.rb b/lib/fluent/supervisor.rb index d09883bc23..65712fa669 100644 --- a/lib/fluent/supervisor.rb +++ b/lib/fluent/supervisor.rb @@ -14,10 +14,16 @@ # limitations under the License. # -require 'fluent/load' -require 'fluent/system_config' require 'etc' +require 'fluent/config' +require 'fluent/env' +require 'fluent/engine' +require 'fluent/log' +require 'fluent/plugin' +require 'fluent/rpc' +require 'fluent/system_config' + module Fluent class Supervisor def self.get_etc_passwd(user) @@ -468,40 +474,6 @@ def read_config @conf = Fluent::Config.parse(@config_data, @config_fname, @config_basedir, @use_v1_config) end - class SystemConfig - include Configurable - - config_param :log_level, default: nil do |level| - Log.str_to_level(level) - end - config_param :suppress_repeated_stacktrace, :bool, default: nil - config_param :emit_error_log_interval, :time, default: nil - config_param :suppress_config_dump, :bool, default: nil - config_param :without_source, :bool, default: nil - config_param :rpc_endpoint, :string, default: nil - config_param :enable_get_dump, :bool, default: nil - config_param :process_name, default: nil - - def initialize(conf) - super() - configure(conf) - end - - def apply(supervisor) - system = self - supervisor.instance_eval { - @log.level = @log_level = system.log_level unless system.log_level.nil? - @suppress_interval = system.emit_error_log_interval unless system.emit_error_log_interval.nil? - @suppress_config_dump = system.suppress_config_dump unless system.suppress_config_dump.nil? - @suppress_repeated_stacktrace = system.suppress_repeated_stacktrace unless system.suppress_repeated_stacktrace.nil? - @without_source = system.without_source unless system.without_source.nil? - @rpc_endpoint = system.rpc_endpoint unless system.rpc_endpoint.nil? - @enable_get_dump = system.enable_get_dump unless system.enable_get_dump.nil? - @process_name = system.process_name unless system.process_name.nil? - } - end - end - def run_configure Fluent::Engine.run_configure(@conf) end diff --git a/lib/fluent/system_config.rb b/lib/fluent/system_config.rb index 4452e9dd86..e7d252c864 100644 --- a/lib/fluent/system_config.rb +++ b/lib/fluent/system_config.rb @@ -14,9 +14,10 @@ # limitations under the License. # -module Fluent - require 'fluent/configurable' +require 'fluent/configurable' +require 'fluent/config/element' +module Fluent module SystemConfigMixin def system_config @_system_config || Fluent::Engine.system_config @@ -56,8 +57,13 @@ def self.create(conf) SystemConfig.new(systems.first) end - def initialize(conf={}) + def self.blank_system_config + Fluent::Config::Element.new('', '', {}, []) + end + + def initialize(conf=nil) super() + conf ||= SystemConfig.blank_system_config configure(conf) end diff --git a/lib/fluent/test.rb b/lib/fluent/test.rb index f552f7a20d..d34b4442f7 100644 --- a/lib/fluent/test.rb +++ b/lib/fluent/test.rb @@ -15,7 +15,7 @@ # require 'test/unit' -require 'fluent/load' +require 'fluent/env' # for Fluent.windows? require 'fluent/test/base' require 'fluent/test/input_test' require 'fluent/test/output_test' diff --git a/lib/fluent/test/base.rb b/lib/fluent/test/base.rb index 8c40ac77ce..713a944ad3 100644 --- a/lib/fluent/test/base.rb +++ b/lib/fluent/test/base.rb @@ -14,6 +14,10 @@ # limitations under the License. # +require 'fluent/engine' +require 'fluent/system_config' +require 'fluent/config' + module Fluent module Test def self.setup diff --git a/lib/fluent/test/filter_test.rb b/lib/fluent/test/filter_test.rb index 2a55bee08a..88cca149d6 100644 --- a/lib/fluent/test/filter_test.rb +++ b/lib/fluent/test/filter_test.rb @@ -14,6 +14,9 @@ # limitations under the License. # +require 'fluent/test/base' +require 'fluent/event' + module Fluent module Test class FilterTestDriver < TestDriver diff --git a/lib/fluent/test/formatter_test.rb b/lib/fluent/test/formatter_test.rb index f840cebf52..d7bd2a888c 100644 --- a/lib/fluent/test/formatter_test.rb +++ b/lib/fluent/test/formatter_test.rb @@ -14,10 +14,11 @@ # limitations under the License. # +require 'fluent/formatter' +require 'fluent/config' + module Fluent module Test - require 'fluent/config' - class FormatterTestDriver def initialize(klass_or_str, proc=nil, &block) if klass_or_str.is_a?(Class) diff --git a/lib/fluent/test/input_test.rb b/lib/fluent/test/input_test.rb index 341211cd5f..f0c0c90bff 100644 --- a/lib/fluent/test/input_test.rb +++ b/lib/fluent/test/input_test.rb @@ -14,6 +14,11 @@ # limitations under the License. # +require 'fluent/buffer' +require 'fluent/engine' +require 'fluent/time' +require 'fluent/test/base' + module Fluent class FileBuffer < BasicBuffer def self.clear_buffer_paths diff --git a/lib/fluent/test/output_test.rb b/lib/fluent/test/output_test.rb index 83d749e94a..62b971a2f0 100644 --- a/lib/fluent/test/output_test.rb +++ b/lib/fluent/test/output_test.rb @@ -14,6 +14,10 @@ # limitations under the License. # +require 'fluent/engine' +require 'fluent/event' +require 'fluent/test/input_test' + module Fluent module Test class TestOutputChain diff --git a/lib/fluent/test/parser_test.rb b/lib/fluent/test/parser_test.rb index 7c6f6ddd6b..79706c192f 100644 --- a/lib/fluent/test/parser_test.rb +++ b/lib/fluent/test/parser_test.rb @@ -14,10 +14,11 @@ # limitations under the License. # +require 'fluent/parser' +require 'fluent/config' + module Fluent module Test - require 'fluent/config' - class ParserTestDriver def initialize(klass_or_str, format=nil, conf={}, &block) if klass_or_str.is_a?(Class) diff --git a/lib/fluent/timezone.rb b/lib/fluent/timezone.rb index 4320a728d0..f0383495be 100644 --- a/lib/fluent/timezone.rb +++ b/lib/fluent/timezone.rb @@ -16,6 +16,8 @@ require 'tzinfo' +require 'fluent/config/error' + module Fluent class Timezone # [+-]HH:MM, [+-]HHMM, [+-]HH diff --git a/test/plugin/test_in_forward.rb b/test/plugin/test_in_forward.rb index b103d8d3e7..c68a73a374 100644 --- a/test/plugin/test_in_forward.rb +++ b/test/plugin/test_in_forward.rb @@ -1,7 +1,11 @@ require_relative '../helper' + require 'fluent/test' require 'base64' +require 'fluent/env' +require 'fluent/plugin/in_forward' + class ForwardInputTest < Test::Unit::TestCase def setup Fluent::Test.setup diff --git a/test/test_event_router.rb b/test/test_event_router.rb index 3e2ff61f96..cc2bd88c45 100644 --- a/test/test_event_router.rb +++ b/test/test_event_router.rb @@ -1,3 +1,4 @@ +require_relative 'helper' require 'fluent/event_router' require_relative 'test_plugin_classes' diff --git a/test/test_plugin_classes.rb b/test/test_plugin_classes.rb index 77e8c39e30..70cc9416ac 100644 --- a/test/test_plugin_classes.rb +++ b/test/test_plugin_classes.rb @@ -1,4 +1,7 @@ require_relative 'helper' +require 'fluent/input' +require 'fluent/output' +require 'fluent/filter' module FluentTest class FluentTestInput < ::Fluent::Input diff --git a/test/test_process.rb b/test/test_process.rb index ae846c3529..7c8c2a072b 100644 --- a/test/test_process.rb +++ b/test/test_process.rb @@ -1,6 +1,7 @@ require_relative 'helper' require 'fluent/test' require 'fluent/event' +require 'fluent/process' require 'stringio' require 'msgpack' diff --git a/test/test_root_agent.rb b/test/test_root_agent.rb index 50ff51b55e..8357a683f7 100644 --- a/test/test_root_agent.rb +++ b/test/test_root_agent.rb @@ -1,3 +1,4 @@ +require_relative 'helper' require 'fluent/event_router' require 'fluent/system_config' require_relative 'test_plugin_classes'