Skip to content
This repository was archived by the owner on Dec 16, 2024. It is now read-only.

Use UTC timezone - #569

Merged
bors-servo merged 1 commit into
servo:masterfrom
charlesvdv:utc
Jan 7, 2017
Merged

bors-servo merged 1 commit into
servo:masterfrom
charlesvdv:utc

Conversation

@charlesvdv

@charlesvdv charlesvdv commented Dec 30, 2016 •

Copy link
Copy Markdown
Contributor

Fix the issue #303 and follow up of #439 PR.

I'm not sure about the spot to put the sls.common tests.


This change is Reviewable

@highfive

Copy link
Copy Markdown

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @aneeshusa (or someone else) soon.

@charlesvdv

Copy link
Copy Markdown
Contributor Author

Looks like timezone is not supported for macOS : saltstack/salt#31345

@aneeshusa aneeshusa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks pretty good! Another change - in .travis.yml, each builder that invokes the test suite should get language: python and python: 3.5.

Comment thread .travis/dispatch.sh Outdated
if [[ "${SALT_NODE_ID}" == "servo-master1" ]]; then
./test.py sls.buildbot.master sls.homu sls.nginx
fi
./test.py sls.common

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should only run this on the non-macOS machines for now, so we can check the ${SALT_NODE_ID} isn't a macOS node; easiest way is probably using the =~ bash operator.

Comment thread common/init.sls
- shell: /bin/bash
- home: {{ common.servo_home }}

UTC:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use Jinja to render this state conditionally, only on non-macOS, using an {% if ... %} block.

Comment thread tests/sls/common/timezone.py Outdated

def run():
command = 'date'
ret = subprocess.run(command,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Inline the command and pass as an array so we control word-splitting, etc.

subprocess.run(['date'], ...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, prefer to use block indent:

ret = subprocess.run(
    ['date'],
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE
)

@aneeshusa aneeshusa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One last nit, everything else LGTM, so go ahead and squash while addressing this last comment.

Comment thread .travis/dispatch.sh Outdated

# Salt doesn't support timezone.system on OSX
# See https://github.com/saltstack/salt/issues/31345
if [[ "${TRAVIS_OS_NAME}" != "osx" ]]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the future the list of tests to run will be auto-generated from the Salt top file, so I'd prefer to check ${SALT_NODE_ID} instead of ${TRAVIS_OS_NAME}. You can use e.g.

if [[ ! "${SALT_NODE_ID}" =~ servo-mac* ]]; then
   ...
fi

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry about that. I thought it would be less error-prone (because the servo-mac* could change at some point) but if it needs to be travis independant I totally get that.

@aneeshusa aneeshusa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thought of an optional enhancement for bonus points, or else you can squash the current commits which LGTM.

stdout = ret.stdout.decode('utf-8')

if ret.returncode == 0 and 'UTC' in stdout:
return Success('Date is in UTC')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was reading an article about testing yesterday which reminded me of expected-failure tests, which is IMO a nicer way to handle the macOS situtation. Roughly, instead of just returning Success here, use sys.platform to check if we're on macOS, and if so, return Failure in that case with an appropriate message; and vice-versa for the Failure. This inverts the expectations and lets us run the sls.common test unconditionally.

Note that in the .travis.yml file, I believe python isn't supported on macOS, so don't update those entries to add the python3.5 spec. However, we may need to install Python 3.5 manually with brew on the OS X builders; make a separate commit and see if it's necessary before adding that.

It may be a little tricky to add so I'll make it optional, for bonus points :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should I put the brew python install inside a saltscript or inside the .travis/install...sh ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's not add the brew install unless the test suite fails to run on macOS on Travis (i.e. check first), but if we need it I'd probably put it in the dispatch script before we print the Python version.

@aneeshusa

Copy link
Copy Markdown
Contributor

If you go for the bonus points, in the .travis/dispatch.sh script please also print the Python3 version unconditionally before running the test suite instead of just for the test node.

@aneeshusa

Copy link
Copy Markdown
Contributor

I believe installing Python 3.5 on the Mac builders actually takes a bit of time, so let's skip the xfail stuff for now. Everything else looked good, so discard the last commit and squash the first five, and we'll get this landed.

@aneeshusa

Copy link
Copy Markdown
Contributor

Also, please rebase on top of the latest master to pull in #573.

@aneeshusa

Copy link
Copy Markdown
Contributor

Thanks for the patch @charlesvdv! @bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 751f12e has been approved by aneeshusa

@bors-servo

Copy link
Copy Markdown
Contributor

⚡ Test exempted - status

@bors-servo
bors-servo merged commit 751f12e into servo:master Jan 7, 2017
bors-servo pushed a commit that referenced this pull request Jan 7, 2017
Use UTC timezone

Fix the issue #303 and follow up of #439 PR.

I'm not sure about the spot to put the ```sls.common``` tests.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/saltfs/569)
<!-- Reviewable:end -->
@jdm jdm mentioned this pull request Jan 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants