Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

bug 1352232: Remove Ansible from py27 build #4239

Merged
merged 4 commits into from May 19, 2017
Merged

Conversation

jwhitlock
Copy link
Contributor

@jwhitlock jwhitlock commented May 16, 2017

Don't use Ansible to install MySQL and ElasticSearch. Instead:

  • Use TravisCI's MySQL, without the custom collation or migrations. Docker continues to test w/ utf8_distinct_ci and migrations.
  • Install ElasticSearch as suggested by TravisCI docs
  • Install node packages needed by Django pipeline, so that make build-static will work for tests.
  • Rewrite scripts/travis_install to use env variables like INSTALL_ELASTICSEARCH=1, instead of targeting on TOXENV, to make it easier to combine and customize.

All of these changes makes the py27 target faster to build (8 minutes vs 11 min 30 seconds, 30% faster), and easier to customize. I've added the first customization for bug 1352232, where tests fail if PYTHONHASHSEED is random, which affects our readiness for Python 3.

@jgmize this might be an easy 馃憤, requesting your review if you can get to it by next Monday.

@codecov-io
Copy link

codecov-io commented May 16, 2017

Codecov Report

Merging #4239 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4239      +/-   ##
==========================================
+ Coverage   86.57%   86.58%   +0.01%     
==========================================
  Files         148      150       +2     
  Lines        9048     9065      +17     
  Branches     1199     1198       -1     
==========================================
+ Hits         7833     7849      +16     
- Misses        988      989       +1     
  Partials      227      227
Impacted Files Coverage 螖
kuma/core/utils.py 55.25% <0%> (-0.39%) 猬囷笍
kuma/users/views.py 96.42% <0%> (-0.33%) 猬囷笍
kuma/wiki/models.py 89.27% <0%> (-0.23%) 猬囷笍
kuma/urls.py 80.76% <0%> (酶) 猬嗭笍
kuma/health/urls.py 100% <0%> (酶)
kuma/health/views.py 100% <0%> (酶)
kuma/settings/common.py 94.28% <0%> (+0.95%) 猬嗭笍
kuma/wiki/views/list.py 70.7% <0%> (+1.01%) 猬嗭笍

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 b44af16...c0e6ec2. Read the comment docs.

@jwhitlock jwhitlock force-pushed the no-ansible-1352232 branch 2 times, most recently from 31e8376 to ae5f594 Compare May 17, 2017 15:23
Switch to TravisCI-provided MySQL without custom collation. This
requires running tests with --no-migrations. The Docker build
continues to use MySQL with the custom collation utf8_distinct_ci and
migraations.

Switch to the TravicCI-recommended method for installing and running
ElasticSearch.

Update caching so that node installed and downloaded (ElasticSearch
and docker-compose) are fast when the version doesn't change.

Move configuration environment variables to global, and use additional
variables to control what gets installed (rather than TOXENV):

* CREATE_DB=dbname - Runs MySQL database creation for Django tests
* INSTALL_DOCKER_COMPOSE - Replaces docker_compose with the specific
  version.
* INSTALL_ELASTICSEARCH=1 - Downloads and runs ElasticSearch, and
  ensures it is ready before starting tests
* INSTALL_PIPELINE=1 - Installs node packages used by django-pipeline,
  so that "make build-static" will run successfully
Drop PYTHONPATH, CFLAGS, and DEBIAN_FRONTED from the environment overrides.
Add a build (allowed to fail) that tests Kuma with a random
PYTHONHASHSEED.
@jwhitlock jwhitlock changed the title bug 1352232 (WIP): Remove Ansible from py27 build bug 1352232: Remove Ansible from py27 build May 17, 2017
@jwhitlock jwhitlock requested a review from jgmize May 17, 2017 17:23
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib
mkdir -p downloads
wget -q -O downloads/elasticsearch-$ES_VERSION.tar.gz $ES_DOWNLOAD_URL
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you build the url here?
Rather than passing the url in environment parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.travis.yml Outdated
# Wait for ElasticSearch to be ready
- if [ ${INSTALL_ELASTICSEARCH:-0} -ne 0 ]; then wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200; fi;
script:
if [[ "${PYTHONHASHSEED:-}" == "0" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

${PYTHONHASHSEED:-} seems redundant, I think the simpler ${PYTHONHASHSEED} would be equivalent.

https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m`
fi
chmod +x $DOCKER_COMPOSE_FILE
sudo cp $DOCKER_COMPOSE_FILE /usr/local/bin/docker-compose
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we cache this path and check if the version matches with the provided one?

INSTALLED_DOCER_COMPOSE_VERSION=$(docker-compose -v | grep -o '[0-9]\?[0-9].[0-9]\?[0-9].\?[0-9]')
if ! [ INSTALLED_DOCER_COMPOSE_VERSION == DOCKER_COMPOSE_VERSION];
then
    # Download and install
fi

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, that will never ever happen. The VM is reset each time, so the version will be 1.8.1 until TravisCI updates their VM image. When they do that, the new default may be later than 1.9.0, and we can stop installing our own docker-compose. Until then, the download folder is cached, so we don't download the file unless we change DOCKER_COMPOSE_VERSION.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jwhitlock We can add /usr/local/bin/docker-compose to cache config to keep the docker-compose

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can cache directories but not files. I think it would be a mistake to cache /usr/local/bin, so I think we're OK caching the file in downloads and copying it each time.

Copy link
Contributor

Choose a reason for hiding this comment

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

the docker-compose file is already in the downloads dir, which is in the cache due to https://github.com/mozilla/kuma/pull/4239/files#diff-354f30a63fb0907d4ad57269548329e3R9

Use simple bash tests in .travis.yml
Use set -u in scripts/travis-install, instead of checking that the right
environment variables are set.
install:
- pip install -r requirements/travis.txt
- if [[ $TOXENV == 'py27' ]]; then ansible-playbook -vvv --tags=mysql,pipeline --connection=local --inventory-file=provisioning/inventory provisioning/travis.yml; fi
- nvm install 6
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we include all the installs in scripts/travis-install?
We dont need to install pip and other thing in docker testing environment. So it will faster the build

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This might be a good follow-on PR. requirements/travis.txt includes coveralls, which is called at the end of each test, so you'd need to ensure coveralls is not called for the targets that generate coverage data. Which maybe should include the docker target, but currently doesn't. But it could be skipped for the linter tasks.

That's also a lot of work to save at most 10s per build.

PYTHONHASHSEED = 0
passenv=DJANGO_SETTINGS_MODULE DEBIAN_FRONTEND CFLAGS
make compilejsi18n collectstatic clean
py.test --no-migrations --cov=kuma kuma
Copy link
Contributor

Choose a reason for hiding this comment

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

If new migration is added, will it fail?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not here, since we aren't running them due to --no-migrations.

- TOXENV=docker DOCKER_COMPOSE_VERSION=1.9.0 UID=0
- TOXENV=locales
INSTALL_DOCKER_COMPOSE=1
- TOXENV=docker
Copy link
Contributor

Choose a reason for hiding this comment

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

Keeping it in single line seems more readable to me TOXENV=docker INSTALL_DOCKER_COMPOSE=1 UID=0

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer the new multi-line approach.

Copy link
Contributor

@jgmize jgmize left a comment

Choose a reason for hiding this comment

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

Nice work @jwhitlock

@jgmize
Copy link
Contributor

jgmize commented May 19, 2017

Thanks for your thorough review and questions @safwanrahman. I think they've all been addressed and this is good to merge.

@jgmize jgmize merged commit 46e9ab9 into master May 19, 2017
@jgmize jgmize deleted the no-ansible-1352232 branch May 19, 2017 19:26
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.

None yet

4 participants