Skip to content
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

Avoid seasonal clock changes issues in specs #4208

Merged
merged 1 commit into from
Oct 22, 2020
Merged

Avoid seasonal clock changes issues in specs #4208

merged 1 commit into from
Oct 22, 2020

Conversation

javierm
Copy link
Member

@javierm javierm commented Oct 22, 2020

References

Background

Using travel we go to Time.now + interval. If the application's time zone changes due to seasonal clock changes during that interval, we might travel to a time which is not the time we intended to travel to.

Example:

On a system using the UTC time zone, it's 9AM on October 25 (Friday). Since by default CONSUL uses the Madrid time zone, it means the application's time is 11AM.

We use travel to advance three days. That means we go to 9AM UTC on October 28 (Monday). The application's time will be 10AM due to the seasonal clock change, so we haven't fully traveled three days in application's time.

To reproduce locally, run:

TZ=UTC rspec spec/system/proposal_notifications_spec.rb:410

Objectives

Using travel_to with 3.days.from_now, which uses the application's time zone and so it will travel to October 28 at 11AM, solves the problem.

Using `travel` we go to `Time.now + interval`. If the application's time
zone changes due to seasonal clock changes during that interval, we
might travel to a time which is not the time we intended to travel to.

Example:

On a system using the UTC time zone, it's 9AM on October 25 (Friday).
Since by default CONSUL uses the Madrid time zone, it means the
application's time is 11AM.

We use `travel` to advance three days. That means we go to 9AM UTC on
October 28 (Monday). The application's time will be 10AM due to the
seasonal clock change, so we haven't fully traveled three days in
application's time.

To reproduce locally, run:

```
TZ=UTC rspec spec/system/proposal_notifications_spec.rb:410
```

Using `travel_to` with `3.days.from_now`, which uses the application's
time zone and so it will travel to October 28 at 11AM, solves the
problem.
@javierm javierm added the Specs label Oct 22, 2020
@javierm javierm self-assigned this Oct 22, 2020
@javierm javierm added this to Reviewing in Consul Democracy via automation Oct 22, 2020
Copy link
Member

@Senen Senen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! 👏

Consul Democracy automation moved this from Reviewing to Testing Oct 22, 2020
@javierm javierm merged commit b1be0ca into master Oct 22, 2020
Consul Democracy automation moved this from Testing to Release 1.3.0 Oct 22, 2020
@javierm javierm deleted the travel_spec branch October 22, 2020 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants