From 317026df12badc878966cf4144a4c28aa5757052 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 5 Mar 2020 17:47:14 +0900 Subject: [PATCH 1/4] test: Fix expected position entries on Windows Signed-off-by: Hiroshi Hatake --- test/plugin/in_tail/test_position_file.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/plugin/in_tail/test_position_file.rb b/test/plugin/in_tail/test_position_file.rb index 6e31fa816b..00b5fac8a4 100644 --- a/test/plugin/in_tail/test_position_file.rb +++ b/test/plugin/in_tail/test_position_file.rb @@ -196,7 +196,11 @@ def build_files(file) @file.seek(0) lines = @file.readlines assert_equal 2, lines.size - assert_equal "valid_path\t000000000000000a\t000000000000000b\n", lines[0] + if Fluent.windows? + assert_equal "valid_path\t0000000000000000a\t000000000000000b\n", lines[0] + else + assert_equal "valid_path\t000000000000000a\t000000000000000b\n", lines[0] + end assert_equal "valid_path2\t0000000000000003\t0000000000000002\n", lines[1] end @@ -209,7 +213,11 @@ def build_files(file) @file.seek(0) lines = @file.readlines assert_equal 2, lines.size - assert_equal "valid_path\t000000000000000a\t0000000000000001\n", lines[0] + if Fluent.windows? + assert_equal "valid_path\t0000000000000000a0000000000000001\n", lines[0] + else + assert_equal "valid_path\t000000000000000a\t0000000000000001\n", lines[0] + end assert_equal "valid_path2\t0000000000000003\t0000000000000002\n", lines[1] end From 3088e49cf33924c048d5b50f15f751e19dccfe54 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 5 Mar 2020 18:19:52 +0900 Subject: [PATCH 2/4] test: Use correct error message on Windows Winsock generates the different error message than Linux's. Signed-off-by: Hiroshi Hatake --- test/plugin/test_out_forward.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/plugin/test_out_forward.rb b/test/plugin/test_out_forward.rb index 8d4d7fd437..746972ca58 100644 --- a/test/plugin/test_out_forward.rb +++ b/test/plugin/test_out_forward.rb @@ -997,7 +997,11 @@ def plugin_id_for_test? e = assert_raise Fluent::UnrecoverableError do d.instance_start end - assert_match(/Connection refused/, e.message) + if Fluent.windows? + assert_match(/No connection could be made because the target machine actively refused it/, e.message) + else + assert_match(/Connection refused/, e.message) + end d.instance_shutdown end From 53c6652ccf0290f95f179432fd5db63cf4b939ea Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 5 Mar 2020 19:13:30 +0900 Subject: [PATCH 3/4] test: Sort by tag instead of time Because these test cases should handle same timestamp. We should sort with another sortable key such as tag. Signed-off-by: Hiroshi Hatake --- test/plugin/test_in_forward.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/plugin/test_in_forward.rb b/test/plugin/test_in_forward.rb index 6723bdee56..a6386f0f04 100644 --- a/test/plugin/test_in_forward.rb +++ b/test/plugin/test_in_forward.rb @@ -218,7 +218,7 @@ def create_driver(conf=CONFIG) } end - assert_equal(records, d.events.sort_by {|a| a[1] }) + assert_equal(records, d.events.sort_by {|a| a[0] }) end test 'json_with_newline' do @@ -237,7 +237,7 @@ def create_driver(conf=CONFIG) } end - assert_equal(records, d.events.sort_by {|a| a[1] }) + assert_equal(records, d.events.sort_by {|a| a[0] }) end end From 7560a48fe6c136b950de44532f6ffe0d536edb9a Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Mon, 9 Mar 2020 19:01:49 +0900 Subject: [PATCH 4/4] test: Use binmode for Tempfile In Windows, writing 0 contained contents should be written as binmode. Otherwise, it will cause corrupted contents. Signed-off-by: Hiroshi Hatake --- test/plugin/in_tail/test_position_file.rb | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/test/plugin/in_tail/test_position_file.rb b/test/plugin/in_tail/test_position_file.rb index 00b5fac8a4..465b048403 100644 --- a/test/plugin/in_tail/test_position_file.rb +++ b/test/plugin/in_tail/test_position_file.rb @@ -6,7 +6,7 @@ class IntailPositionFileTest < Test::Unit::TestCase setup do - @file = Tempfile.new('intail_position_file_test') + @file = Tempfile.new('intail_position_file_test').binmode end teardown do @@ -196,11 +196,7 @@ def build_files(file) @file.seek(0) lines = @file.readlines assert_equal 2, lines.size - if Fluent.windows? - assert_equal "valid_path\t0000000000000000a\t000000000000000b\n", lines[0] - else - assert_equal "valid_path\t000000000000000a\t000000000000000b\n", lines[0] - end + assert_equal "valid_path\t000000000000000a\t000000000000000b\n", lines[0] assert_equal "valid_path2\t0000000000000003\t0000000000000002\n", lines[1] end @@ -213,11 +209,7 @@ def build_files(file) @file.seek(0) lines = @file.readlines assert_equal 2, lines.size - if Fluent.windows? - assert_equal "valid_path\t0000000000000000a0000000000000001\n", lines[0] - else - assert_equal "valid_path\t000000000000000a\t0000000000000001\n", lines[0] - end + assert_equal "valid_path\t000000000000000a\t0000000000000001\n", lines[0] assert_equal "valid_path2\t0000000000000003\t0000000000000002\n", lines[1] end