test/plugin/test_out_tdlog.rb in fluent-plugin-td-1.1.0 vs test/plugin/test_out_tdlog.rb in fluent-plugin-td-1.2.0

- old
+ new

@@ -1,9 +1,9 @@ require 'fluent/test' require 'fluent/test/driver/output' require 'fluent/plugin/out_tdlog' -require 'test_helper.rb' +require 'test_helper' class TreasureDataLogOutputTest < Test::Unit::TestCase TMP_DIR = File.dirname(__FILE__) + "/tmp" def setup @@ -142,11 +142,11 @@ d.feed(test_time, record) } } end - def test_emit_with_time_symbole + def test_emit_with_time_symbol d = create_driver time, records = stub_seed_values database, table = d.instance.instance_variable_get(:@key).split(".", 2) stub_td_table_create_request(database, table) stub_td_import_request(stub_request_body(records, time), database, table) @@ -188,17 +188,49 @@ assert_equal 0, d.events.size assert_equal 1, d.error_events.size end + def test_write_with_client_error + d = create_driver(DEFAULT_CONFIG) + time, records = stub_seed_values + database, table = d.instance.instance_variable_get(:@key).split(".", 2) + stub_td_table_create_request(database, table) + stub_td_import_request(stub_request_body(records, time), database, table, status: 400) + + assert_nothing_raised(Fluent::UnrecoverableError) do + d.run(default_tag: 'test') { + records.each { |record| + d.feed(time, record) + } + } + end + end + + def test_write_retry_if_too_many_requests + d = create_driver(DEFAULT_CONFIG) + time, records = stub_seed_values + database, table = d.instance.instance_variable_get(:@key).split(".", 2) + stub_td_table_create_request(database, table) + stub_td_import_request(stub_request_body(records, time), database, table, status: 429) + + assert_raise(TreasureData::TooManyRequestsError) do + d.run(default_tag: 'test') { + records.each { |record| + d.feed(time, record) + } + } + end + end + sub_test_case 'tag splitting for database and table' do def create_driver(conf = %[auto_create_table true]) config = BASE_CONFIG + conf Fluent::Test::Driver::Output.new(Fluent::Plugin::TreasureDataLogOutput).configure(config) end - data('evet_time' => 'event_time', 'int_time' => 'int') + data('event_time' => 'event_time', 'int_time' => 'int') def test_tag_split(time_class) d = create_driver time, records = stub_seed_values(time_class) database = 'db1'