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

Add new Makefile target to run it tests inside Docker #487

Merged

Conversation

dliappis
Copy link
Contributor

it tests and tox relying on a number of Python 3 versions via
pyenv are a good candidate for running through Docker, as setting up
pyenv and the needed Python versions (as well as required
JAVA_HOME/RUNTIME_JAVA_HOME) can be fiddly.

This is an easier task than #484
as it doesn't rely on passing ssh credentials via the ssh-agent. Only
issue is that on operating systems where Docker runs as a VM (macOS,
Windows) the default configured memory will not to be increased in
order to run the entirety of the integration tests, as Rally uses the
4GB car for Elasticsearch (on top of additional tasks). However, this
target is especially suitable for running integration tests inside a
powerful server/workstation Linux environment without having to worry
about configuring all the dependencies.

`it` tests and `tox` relying on a number of Python 3 versions via
pyenv are a good candidate for running through Docker, as setting up
pyenv and the needed Python versions (as well as required
JAVA_HOME/RUNTIME_JAVA_HOME) can be fiddly.

This is an easier task than elastic#484
as it doesn't rely on passing ssh credentials via the ssh-agent. Only
issue is that on operating systems where Docker runs as a VM (macOS,
Windows) the default configured memory will not to be increased in
order to run the entirety of the integration tests, as Rally uses the
4GB car for Elasticsearch (on top of additional tasks). However, this
target is especially suitable for running integration tests inside a
powerful server/workstation Linux environment without having to worry
about configuring all the dependencies.
@dliappis dliappis added :Usability Makes Rally easier to use idea labels Apr 30, 2018
@dliappis dliappis added this to the 0.11.0 milestone Apr 30, 2018
Under certain conditions (and Makefile versions) it's not sufficient
to just export UID for Docker/docker-compose to consume (Ubuntu)
whereas in other cases
(RedHat) setting UID makes the shell complain about setting a
read-only variable.

Be more resilient about ensuring UID is present as an environment
variable when spawning (Docker) processes through the Makefile.
Copy link
Member

@danielmitterdorfer danielmitterdorfer left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I left some comments.

Dockerfile Outdated
openjdk-8-jdk

RUN pip3 install tox virtualenvwrapper twine sphinx sphinx_rtd_theme wheel
RUN pip3 install --pre github3.py
Copy link
Member

Choose a reason for hiding this comment

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

I think this is not needed to run integration tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No I thought we might keep it in case we give another try at #484 in the future with the same image. But I guess it makes sense to keep it clean for now.

volumes:
- $HOME/.gitconfig:/home/${USER}/.gitconfig
- $HOME/.github:/home/${USER}/.github
- $HOME/.gnupg:/home/${USER}/.gnupg
Copy link
Member

Choose a reason for hiding this comment

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

Is it required to mount these directories?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this was left over with the same idea as before, i.e. maybe we could use this for another attempt at #484 in the future. I'll remove it for now.

@@ -34,4 +43,11 @@ release-checks:
release: release-checks clean docs it
./release.sh $(release_version) $(next_version)

.PHONY: clean docs test it it34 it35 it36 benchmark coverage release release-checks
docker-it: nondocs-clean python-caches-clean
@if ! export | grep UID; then export UID=$(shell id -u); fi ; \
Copy link
Member

Choose a reason for hiding this comment

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

I am not familiar with this syntax. Why is there an @ in the first line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ causes make to suppress echoing: https://www.gnu.org/software/make/manual/make.html#Echoing

less junk on the output esp. with if's that can confuse the user.

Copy link
Member

Choose a reason for hiding this comment

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

Didn't know about that. I also saw now that this is actually just one long line separated by \, i.e. all output from this target will get suppressed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a small correction not all output will get suppressed (e.g. the output generated from the commands themselves e.g. make it output will get displayed as expected).

e.g. if you have a Makefile target called:

testme:
    @ls

this will display the ls output normally but not the ls command itself, which would be the case without @.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I should have said "echoing" instead of "output". Thanks for the explanation.

@@ -1,7 +1,16 @@
clean:
clean: nondocs-clean docs-clean
Copy link
Member

Choose a reason for hiding this comment

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

I wonder whether clean should clean everything (including Python caches).

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 am ambivalent about this one because it you don't use docker it will introduce some slowness every time you run make docs or make it as I've noticed some downloads happening. At the same time it ensures consistency.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, it does not make sense to clean Python caches for make docs. However, I think for make it would make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it would make sense for make it. I think we should add it to the individual it34/35/36 targets too?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please.

cd docs && $(MAKE) clean

# Avoid conflicts between .pyc/pycache related files created by local Python interpreters and other interpreters in Docker
python-caches-clean:
Copy link
Member

Choose a reason for hiding this comment

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

If I type make python-caches-clean locally (on MacOS), I get:

(.venv) daniel@io:Projects/rally ‹pr/487›$ make python-caches-clean
find ./ -name "__pycache__" -exec rm -rf -- \{\} \;
find: .//.venv/lib/python3.6/__pycache__: No such file or directory
[...]
find: .//tests/utils/__pycache__: No such file or directory
make: [python-caches-clean] Error 1 (ignored)
find ./ -name ".pyc" -exec rm -rf -- \{\} \;

Copy link
Contributor Author

@dliappis dliappis May 2, 2018

Choose a reason for hiding this comment

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

As discussed, this is harmless and should always return exit 0 due to the - prefix in the command.

Consecutive slashes will get collapsed as per the Single Unix Specification.

Seems that using . instead of ./ makes the output look saner on macOS so I'll push this plus an @ to suppress output echoing altogether.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. Makes sense.

@danielmitterdorfer danielmitterdorfer added enhancement Improves the status quo and removed idea labels May 2, 2018
@dliappis
Copy link
Contributor Author

dliappis commented May 2, 2018

@danielmitterdorfer I've addressed your comments, could have another pass at the PR?

Copy link
Member

@danielmitterdorfer danielmitterdorfer left a comment

Choose a reason for hiding this comment

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

I left two more comments.

Makefile Outdated
tox -e py34

it35:
it35: python-caches-clean
tox -e py35

it36:
Copy link
Member

Choose a reason for hiding this comment

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

Should also need python-caches-clean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks forgot this one! Addressed it now.

@@ -8,9 +8,6 @@ services:
- NEW_USER=${USER}
container_name: rally-tests
volumes:
- $HOME/.gitconfig:/home/${USER}/.gitconfig
- $HOME/.github:/home/${USER}/.github
- $HOME/.gnupg:/home/${USER}/.gnupg
- ${PWD}/.:/home/${USER}/rally
Copy link
Member

Choose a reason for hiding this comment

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

I missed this in my first pass. Doesn't this assume that the user's Rally project directory is available in ~/rally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. The CWD is changed here: https://github.com/dliappis/rally/blob/79c6ab8fad02f6509bb510c116c8d3de8b6b0cc0/docker-compose.yml#L14 .

The reason it's done this way is that any dot files created under /home/$USER inside the docker container shouldn't interfere with the dot files (e.g. ~/.rally) of the host system.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, you're right. This is the path in the container, not on the host.

@dliappis
Copy link
Contributor Author

dliappis commented May 2, 2018

@dm can you have another look now?

@danielmitterdorfer
Copy link
Member

Thanks. LGTM! :)

@dliappis dliappis merged commit 4805941 into elastic:master May 2, 2018
@dliappis dliappis deleted the add-target-to-run-it-tests-in-docker branch May 2, 2018 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves the status quo :Usability Makes Rally easier to use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants