This repository was archived by the owner on Mar 4, 2021. It is now read-only.
Fixing DST cutover bug in test cases #119
Merged
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.
I encountered a bug when running the tests very close to the spring DST cutover.
Six tests failed because they were comparing the number of days between now and the expected termination date, using miliseconds and long datatypes. Due to the "spring ahead" effect of the DST cutover, the actual difference was not a full 4 days, but rather 3.95 (4 days minus 1 hour), so the tests failed, as the fractional portion was dropped from the long number, and 3 != 4.
I modified the tests to allow for a one-hour buffer on either side.
More (unnecessarily complicated) logic could be added to determine if the test will collide with the DST cutover at execution time, and adjust only in that case, but that seems excessive.
Alternately, this failure raises the question about whether the volume tagging and termination policies are correct. Currently, this means that if a policy is set to terminate an AWS Resource in a set number of days, it may actually do too early (by one hour, in the fall) or too late (by one hour, in the spring).
If the current behavior with a small margin of error two times a year is ok, we can leave it. Otherwise, we should retool to make it "clock-accurate" (and this raises further questions of making it user-configurable, ignoring this margin of error in states that do not observe DST, etc.).
My recommendation is that we just go with the fix to the unit tests, now that they correctly implement the "roughly" logic that is called out in the test case javadoc.