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

Ensure timezone tests reset system timezone to UTC #39326

Merged
merged 2 commits into from
Apr 25, 2018

Conversation

samdoran
Copy link
Contributor

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
  • Bugfix Pull Request
COMPONENT NAME

/test/integration/targets/timezone/tasks/main.yml

ANSIBLE VERSION
2.6

- block:
- name: set timezone to Etc/UTC
timezone:
name: Etc/UTC
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@ansibot
Copy link
Contributor

ansibot commented Apr 25, 2018

@ansibot ansibot added bug This issue/PR relates to a bug. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests. labels Apr 25, 2018
@samdoran samdoran changed the title Ensure timezone tests resets system timezone to UTC Ensure timezone tests reset system timezone to UTC Apr 25, 2018
timezone:
name: Etc/UTC
- block:
- name: Set timezone to Etc/UTC
Copy link
Member

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.

@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Apr 25, 2018
@samdoran samdoran merged commit fda67ba into ansible:devel Apr 25, 2018
@samdoran samdoran deleted the timezone-tests branch April 25, 2018 20:30
mattclay pushed a commit to mattclay/ansible that referenced this pull request May 9, 2018
mattclay pushed a commit that referenced this pull request May 9, 2018
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 12, 2018
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 14, 2018
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 14, 2018
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 15, 2018
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 15, 2018
ilicmilan pushed a commit to ilicmilan/ansible that referenced this pull request Nov 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants