-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Ensure timezone tests reset system timezone to UTC #39326
Conversation
- block: | ||
- name: set timezone to Etc/UTC | ||
timezone: | ||
name: Etc/UTC |
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.
Register the result of this change so the test knows what the original timezone was.
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.
Done
always: | ||
- name: Return timezone to UTC | ||
timezone: | ||
name: Etc/UTC |
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.
Restore the timezone to the original value registered at the start of the test.
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.
Done
ec20ae4
to
d1c284a
Compare
timezone: | ||
name: Etc/UTC | ||
- block: | ||
- name: Set timezone to Etc/UTC |
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.
This task should be outside the block. That will avoid potential errors if the task were to fail and the always block tried to restore a previous timezone which hadn't yet been determined.
(cherry picked from commit fda67ba)
SUMMARY
The
timezone
tests changes the system timezone and does not set it back to UTC. Since the test instances are long-lived, this could cause problems for subsequent tests.This change puts the test inside a block to ensure the timezone is always reset even if the
timezone
test fails.ISSUE TYPE
COMPONENT NAME
/test/integration/targets/timezone/tasks/main.yml
ANSIBLE VERSION