Skip to content

Conversation

@dgorelik
Copy link
Contributor

@dgorelik dgorelik commented Feb 11, 2021

When running python setup.py test in the past, we've gotten the following message WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.. This PR listens to that advice and creates a tox environment for running tests :)

The nice thing about using tox for tests is we can integrate the setup of Spanner emulator into the tox command.

After a couple people confirm that tox runs for them successfully (i.e. by running tox -e py38), I will update the README to point users to run tests with tox.

Tested: ran tests successfully.

@google-cla google-cla bot added the cla: yes label Feb 11, 2021
Comment on lines +10 to +15
deps =
absl-py
google-api-core
google-cloud-spanner >= 1.17.1
frozendict
portpicker
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any way to keep this in sync with other places? E.g. could we put this in a requirements.txt or something, and reference that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While these can be put in a requirements.txt file, I don't think setup.py should be referencing that file, so there still would be duplication
https://stackoverflow.com/a/33685899

Copy link
Contributor

Choose a reason for hiding this comment

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

I ended up adding the below in a different PR because of the same issue with setup.py not referencing requirements.txt. Would it make sense to add requirements.txt here, and use it both for tox and the github workflow? Or would the github workflow use tox and not need to reference the dependencies explicitly anymore?

tox.ini Outdated
wget https://storage.googleapis.com/cloud-spanner-emulator/releases/{env:VERSION}/cloud-spanner-emulator_linux_amd64-{env:VERSION}.tar.gz -P /tmp/spanner_emulator/
tar zxvf /tmp/cloud-spanner-emulator_linux_amd64-{env:VERSION}.tar.gz -C /tmp/spanner_emulator/
chmod u+x /tmp/spanner_emulator/gateway_main /tmp/spanner_emulator/emulator_main
python setup.py test
Copy link
Contributor

Choose a reason for hiding this comment

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

The PR description mentions a warning about doing this. Should this be something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think doing that in a tox env is still OK, but just to be safe, I switched to pytest. It has a cleaner test output too!

tox.ini Outdated
Comment on lines 24 to 26
wget https://storage.googleapis.com/cloud-spanner-emulator/releases/{env:VERSION}/cloud-spanner-emulator_linux_amd64-{env:VERSION}.tar.gz -P /tmp/spanner_emulator/
tar zxvf /tmp/cloud-spanner-emulator_linux_amd64-{env:VERSION}.tar.gz -C /tmp/spanner_emulator/
chmod u+x /tmp/spanner_emulator/gateway_main /tmp/spanner_emulator/emulator_main
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this going to run every time we run tests? Is there any way to cache it? (Feel free to push this off to another PR.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm inclined to push this off for now. In practice (on my admittedly fast internet connection) this steps only takes a couple of seconds.

@dgorelik dgorelik requested a review from dseomn February 12, 2021 03:29
cloud-spanner-emulator*
emulator_main
gateway_main
.spanner_emulator/**
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) add / at the beginning of the line, so it only matches in this directory.

@supersam654 supersam654 removed their request for review February 17, 2021 14:22
Copy link
Contributor

@dseomn dseomn left a comment

Choose a reason for hiding this comment

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

Comment on lines +10 to +15
deps =
absl-py
google-api-core
google-cloud-spanner >= 1.17.1
frozendict
portpicker
Copy link
Contributor

Choose a reason for hiding this comment

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

I ended up adding the below in a different PR because of the same issue with setup.py not referencing requirements.txt. Would it make sense to add requirements.txt here, and use it both for tox and the github workflow? Or would the github workflow use tox and not need to reference the dependencies explicitly anymore?

absl-py
google-api-core
google-cloud-spanner >= 1.17.1
frozendict
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) This is out of date.

deps =
absl-py
google-api-core
google-cloud-spanner >= 1.17.1
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) This doesn't match the other places, but I don't know what it should be.

# and then run "tox" from this directory.

[tox]
envlist = py36, py37, py38
Copy link
Contributor

Choose a reason for hiding this comment

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

(nit) Remove 3.6, add 3.9.

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.

2 participants