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

Dockerize #1365

Merged
merged 70 commits into from
Jul 20, 2020
Merged

Dockerize #1365

merged 70 commits into from
Jul 20, 2020

Conversation

abrookins
Copy link
Contributor

@abrookins abrookins commented Jul 8, 2020

Pull Request check-list

Please make sure to review and check all of these items:

  • Does $ tox pass with this change (including linting)?
  • Does travis tests pass with this change (enable it first in your forked repo and wait for the travis build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

Move from using Vagrant to build and run a dev environment and tests to using Docker.

@abrookins abrookins marked this pull request as draft July 8, 2020 19:09
@codecov-commenter
Copy link

codecov-commenter commented Jul 8, 2020

Codecov Report

Merging #1365 into master will decrease coverage by 7.32%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1365      +/-   ##
==========================================
- Coverage   92.76%   85.43%   -7.33%     
==========================================
  Files          20        7      -13     
  Lines        6581     3008    -3573     
==========================================
- Hits         6105     2570    -3535     
+ Misses        476      438      -38     
Impacted Files Coverage Δ
redis/connection.py 81.40% <0.00%> (-0.35%) ⬇️
redis/client.py 85.92% <0.00%> (-0.16%) ⬇️
redis/_compat.py 86.99% <0.00%> (-0.11%) ⬇️
redis/lock.py 100.00% <0.00%> (ø)
redis/exceptions.py 100.00% <0.00%> (ø)
tests/test_scripting.py
tests/test_commands.py
tests/test_connection.py
redis/__init__.py
tests/test_monitor.py
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 10fb0c5...4565195. Read the comment docs.

@abrookins
Copy link
Contributor Author

@RoeyPrat Do you anticipate wanting a "debug" or "test" type of container that has the redis-py code -- for manual or automated testing purposes? In my local testing with this setup, I've been running tox outside of a container, and the tests communicate with the different redis nodes that are running in containers.

@andymccurdy
Copy link
Contributor

I think it would be nice to provide a container that executes the tox suite. If a contributor only needs docker installed to execute the full test suite, that seems like a significant improvement.

@andymccurdy
Copy link
Contributor

Also, it would be really nice if we can specify the source Redis docker image in a single location. Perhaps we could have a multistage build with a single Dockerfile that references the official Redis docker image. All the other Dockerfiles that you have now can be based on the intermediate one. This way if we want to upgrade to Redis 6.1, we would only need to change a that one intermediate file.

@abrookins
Copy link
Contributor Author

abrookins commented Jul 9, 2020 via email

@abrookins
Copy link
Contributor Author

@andymccurdy Hey, Andy! I read through the docs on multi-stage builds, and they all seemed to refer to situations a little different from this one. In the end I took the approach of building a base image that all the Dockerfiles use, pointed at the "latest" tag. So we would bump the base build and then rebuild the other images, which would pull the new base image.

What do you think about that? I also made some test changes to handle the fact that, in a mult-container setup, each container has its own hostname and IP.

Some of these commands get pretty complex, so I added a Makefile to contain them.

Makefile Outdated

build:
docker build -t redis-py-base docker/base
docker-compose down
Copy link
Contributor Author

@abrookins abrookins Jul 9, 2020

Choose a reason for hiding this comment

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

Not sure this line is really necessary.

Copy link
Contributor

@andymccurdy andymccurdy left a comment

Choose a reason for hiding this comment

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

Thanks, this is shaping up nicely. Using the intermediate build with the ':latest' tag is exactly what I was referring to.

I added a few comments below.

action="store",
help="Redis connection string,"
" defaults to `%(default)s`")
parser.addoption('--redis-master-host', default=DEFAULT_REDIS_MASTER_HOST,
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 ever a reason where redis-master-host would not point to the same host that's defined in the redis-url? I can't think of one.

Assuming there isn't a valid reason, we should infer the master hostname from the redis-url argument rather than introducing a new setting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably not. Fixed!

@@ -156,6 +161,11 @@ def mock_cluster_resp_slaves(request, **kwargs):
return _gen_cluster_mock_resp(r, response)


@pytest.fixture(scope="module")
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the master_host value ever change from module to module? If not, scoping this to 'session' seems more appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't, no - updated!

@abrookins
Copy link
Contributor Author

@andymccurdy What do you think about me adding a CONTRIBUTING.rst file, or a new section to README.rst, with a walk-through of how to set up your dev environment and run the tests?

@andymccurdy
Copy link
Contributor

@abrookins That would be great. CONTRIBUTING sounds like the appropriate place. We can add a link in the README to the CONTRIBUTING page.

@abrookins
Copy link
Contributor Author

Last remaining problem here is getting codecov to work -- I'm not sure what the right environment variable it's looking for is, and @andymccurdy had some ideas to make this work.

docker-entry.sh Outdated
@@ -0,0 +1,17 @@
#!/bin/sh

# This is the entrypoint for "make clean". It invokes Tox. If running
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Small nit - it's "make test" right?

@abrookins
Copy link
Contributor Author

abrookins commented Jul 17, 2020

It looks like coverage reduced partially because this test doesn't run: https://github.com/andymccurdy/redis-py/blob/master/tests/test_connection.py#L9

@pytest.mark.skipif(HIREDIS_AVAILABLE, reason='PythonParser only')

Hmm.

@abrookins
Copy link
Contributor Author

abrookins commented Jul 17, 2020

codecov from tox seems to work! 🥳

I'm a little confused about how running coverage with multiple environments interacts with the "coverage" file. I'm trying some options to make sure that we're combining the output of all the runs when we eventually run codecov.

@abrookins
Copy link
Contributor Author

abrookins commented Jul 17, 2020

Ok, this is better. Now we get a text-based coverage report when we run tests, and we produce the XML that codecov can then use. Also, the coverage is taken separately by interpreter and then merged into a single coverage file, which should give a better representation.

We'll always produce the text report, so we can see it either on the terminal or in build output, but we'll only run codecov via CI.

@andymccurdy andymccurdy merged commit 75a2cfe into redis:master Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants