-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider timezone when calculate timekey #2054
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6921b47
Consider timezone when calculate timekey
okkez a5cf3b0
Use with_timezone to set proper timezone during test
okkez 34fb65a
Set proper value "Asia/Tokyo" to TZ
okkez 92225ca
Set TZ properly on Windows
okkez 1e9d52d
Use instance variables instead of `@buffer_config` instance methods
okkez 72339a2
Use Fluent::Timezone.utc_offset to consider `@buffer_config.timekey_z…
okkez f178b87
Add test case when machine timezone and timekey_zone is different
okkez 54bda48
Add cache for calculating timezone offset
okkez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -557,6 +557,79 @@ def parse_system(text) | |
check_gzipped_result(path, formatted_lines * 3) | ||
end | ||
|
||
test 'append when JST' do | ||
with_timezone(Fluent.windows? ? "JST-9" : "Asia/Tokyo") do | ||
time = event_time("2011-01-02 03:14:15+09:00") | ||
formatted_lines = %[2011-01-02T03:14:15+09:00\ttest\t{"a":1}\n] + %[2011-01-02T03:14:15+09:00\ttest\t{"a":2}\n] | ||
|
||
write_once = ->(){ | ||
d = create_driver %[ | ||
path #{TMP_DIR}/out_file_test | ||
compress gz | ||
append true | ||
<buffer> | ||
timekey_use_utc false | ||
timekey_zone Asia/Tokyo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use "+0900" like value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just commit the fix :) |
||
</buffer> | ||
] | ||
d.run(default_tag: 'test'){ | ||
d.feed(time, {"a"=>1}) | ||
d.feed(time, {"a"=>2}) | ||
} | ||
d.instance.last_written_path | ||
} | ||
|
||
path = write_once.call | ||
assert_equal "#{TMP_DIR}/out_file_test.20110102.log.gz", path | ||
check_gzipped_result(path, formatted_lines) | ||
|
||
path = write_once.call | ||
assert_equal "#{TMP_DIR}/out_file_test.20110102.log.gz", path | ||
check_gzipped_result(path, formatted_lines * 2) | ||
|
||
path = write_once.call | ||
assert_equal "#{TMP_DIR}/out_file_test.20110102.log.gz", path | ||
check_gzipped_result(path, formatted_lines * 3) | ||
end | ||
end | ||
|
||
test 'append when UTC-02 but timekey_zone is +0900' do | ||
with_timezone("UTC-02") do # +0200 | ||
time = event_time("2011-01-02 17:14:15+02:00") | ||
formatted_lines = %[2011-01-02T17:14:15+02:00\ttest\t{"a":1}\n] + %[2011-01-02T17:14:15+02:00\ttest\t{"a":2}\n] | ||
|
||
write_once = ->(){ | ||
d = create_driver %[ | ||
path #{TMP_DIR}/out_file_test | ||
compress gz | ||
append true | ||
<buffer> | ||
timekey_use_utc false | ||
timekey_zone +0900 | ||
</buffer> | ||
] | ||
d.run(default_tag: 'test'){ | ||
d.feed(time, {"a"=>1}) | ||
d.feed(time, {"a"=>2}) | ||
} | ||
d.instance.last_written_path | ||
} | ||
|
||
path = write_once.call | ||
# Rotated at 2011-01-02 17:00:00+02:00 | ||
assert_equal "#{TMP_DIR}/out_file_test.20110103.log.gz", path | ||
check_gzipped_result(path, formatted_lines) | ||
|
||
path = write_once.call | ||
assert_equal "#{TMP_DIR}/out_file_test.20110103.log.gz", path | ||
check_gzipped_result(path, formatted_lines * 2) | ||
|
||
path = write_once.call | ||
assert_equal "#{TMP_DIR}/out_file_test.20110103.log.gz", path | ||
check_gzipped_result(path, formatted_lines * 3) | ||
end | ||
end | ||
|
||
test '${chunk_id}' do | ||
time = event_time("2011-01-02 13:14:15 UTC") | ||
formatted_lines = %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n] | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add more test with different time and timezone, e.g.
timekey_zone
is+09:00
and actual time is+02:00
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will add more test.