Граф коммитов

73 Коммитов

Автор SHA1 Сообщение Дата
Ed Morley 07ea1c4db1 Bug 1285539 - Fix 'manage.py check --deploy' on Travis
The `manage.py check --deploy` command causes the Django models to be
initialised, which requires Elasticsearch to be accessible, if
`ELASTICSEARCH_URL` is set. The variable is set globally for the Travis
runs, however for the linters job (which is where `check --deploy` was
previously being run) Elasticsearch isn't actually installed.

Whilst we could have just unset `ELASTICSEARCH_URL` for the linters job,
it's best to move the test to the main Python job chunk, since:
* The command doesn't only hit Elasticsearch, but also the DB, and the
linters job is running the older mysql 5.5, rather than mysql 5.6.
* Whilst Elasticsearch isn't currently enabled for anywhere other than
the prototype Heroku instance, we'll soon be using it everywhere, so
should get `check --deploy` to actually test what we plan to deploy.

Note: The exception during `check --deploy` was not turning the Travis
run red, due to `check --deploy` being piped to awk. When we update to
Django 1.10 the awk workaround can be removed, however in the meantime
we can use the bash `pipefail` option to ensure the exit code from the
`manage.py` command propagates through to the one that Travis sees.
2016-07-11 16:04:15 +01:00
jgraham 52607c2a57 Bug 1268484 - Add elastic-search based matcher for test failure lines (#1488)
Add support for matching test failures where the test, subtest, status,
and expected status are all exact matches, but the message is not an
exact match. The matching uses ElasticSearch and is initially optimised
for cases where the messages differ only in numeric values since this is
a relatively common case.

This commit also adds ElasticSearch to the travis environment.
2016-06-29 11:25:38 +01:00
Ed Morley 7328cc20d8 Bug 1272207 - Update from nodejs 5.3.0 to 6.2.0 on Travis/Heroku
Since it includes improvements to npm as well as nodejs security fixes.
2016-05-26 15:47:12 +01:00
Ed Morley 7240adb939 Bug 1272207 - Travis: Split out webapp/ tests to their own job
Since they are now taking much longer than before (40% of the total
test suite runtime). Prior to this change, chunk A was taking ~9mins
and chunk B ~4 mins. After, the chunk times should be ~{4,4,6}.
2016-05-26 15:47:12 +01:00
Ed Morley 1137d1b229 Bug 1272207 - Travis: Use the APT addon rather than 'apt-get install'
Since it's now the recommended way to install mysql 5.6 (and Travis
maintain the options passed to apt-get install, so will pick the best
defaults):
https://docs.travis-ci.com/user/database-setup/#MySQL-5.6
2016-05-26 15:47:12 +01:00
Ed Morley 940c054c1a Bug 1272207 - Travis: Force virtualenv to use Python 2.7.11
Since if not specified it defaults to `/usr/bin/python`, which on
Travis Precise containers is 2.7.6 and Trusty GCE is 2.7.3, since the
Python 2.7.11 install they provide is not system-installed but instead
just placed on the `PATH`.

This means that until now we've not actually been testing using the
same version of Python as has been running in production :-/
2016-05-26 15:47:12 +01:00
Ed Morley 34b9c631cf Bug 1275796 - Travis: Revert change to apt-get command
One instance was fixed after review comments, this changes the other.
2016-05-26 15:31:31 +01:00
James Graham 18d0fdc8aa Bug 1275425 - Hacky workaround for issues storing astral characters.
Test names, messages, etc. may contain UTF8 characters from beyond the
Basic Multilingual Plane ("astral" characters). Unfortunately MySQL's
"utf8" character set is nothing of the sort and will only store a
maximum of three bytes per character, thus restricting it to BMP
characters. The correct fix to this is to switch to the utf8mb4
character set. Since such a change is somewhat involved, however, we
address the immediate problem with a hack.

When storing failure lines, if the operation fails for character set
related reasons, try again with any non-BMP characters replaced by a
marker of the form <U+codepoint> e.g. <U+10FFFF>.

Note further that whether or not MySQL fails here or silently replaces
each byte of the original character with a U+FFFD replacement character
depends on the value of the sql_mode setting. If this is set to
STRICT_ALL_TABLES, we get an error, otherwise silent data
loss. Therefore it is important this setting is consistent across all
environments.
2016-05-26 14:30:58 +01:00
Ed Morley 9e20b7934d Bug 1247344 - Enable Django system checks during testing and deployment
`manage.py check --deploy` is now run during Travis testing and as part
of stage/prod/Heroku deployment. It checks for a number of common
configuration mistakes & ensures security best practices are being
followed:
https://docs.djangoproject.com/en/1.8/ref/checks/
2016-05-06 16:09:11 +01:00
Ed Morley bf1696eec9 Bug 1247344 - Make the Django secret key longer for testing/development
The Django deploy checks output errors if the secret key is shorter than
50 characters, and we're about to enable it on Travis and in runtest.sh:
https://docs.djangoproject.com/en/1.8/ref/django-admin/#cmdoption-check--deploy
2016-05-06 14:21:54 +01:00
Ed Morley 82373329ca Bug 1270182 - Travis: Enabling caching for the Ubuntu trusty jobs
Since it's now supported:
https://blog.travis-ci.com/2016-05-03-caches-are-coming-to-everyone

This will reduce the job runtime by 60-80s.

Similar to the container job (job chunk 1), since we're now caching the
virtualenv, we have to workaround the default virtualenv being polluted
with existing packages (by creating a clean one in another directory),
to avoid constant cache churn.
2016-05-05 09:32:23 +01:00
Ed Morley fcec28129a Bug 1270182 - Travis: Improve file comments 2016-05-05 09:32:23 +01:00
Ed Morley 531b253528 Bug 1270182 - Travis: Add missing `--disable-pip-version-check`s
Makes all `pip install` invocations consistent.
2016-05-05 09:32:23 +01:00
Ed Morley a1fb2a52e8 Bug 1258676 - Update to pip 8.1.1
https://pip.pypa.io/en/stable/news/
https://github.com/pypa/pip/compare/8.1.0...8.1.1
2016-03-22 12:39:52 +00:00
James Graham 5ff72285c4 Bug 1255087 - Create a lint for ensuring that the heroku Procfile contains the same queues as CELERY_QUEUES in the settings file 2016-03-16 17:46:16 +00:00
Ed Morley fd76450879 Bug 1254961 - Update to pip 8.1.0
To pick up require-hashes improvements, amongst other things:
https://pip.pypa.io/en/stable/news/
https://github.com/pypa/pip/compare/8.0.2...8.1.0

The Vagrant environment's virtualenv has been updated to 15.0.0, since
that includes pip 8.1.0:
https://virtualenv.pypa.io/en/latest/changes.html
https://github.com/pypa/virtualenv/compare/14.0.1...15.0.0
2016-03-09 18:04:54 +00:00
Ed Morley a83f930296 Bug 1213230 - Use pip 8's require-hashes feature instead of peep
As of pip 8, peep has now been integrated into pip.

Migrating from peep to this native feature has several advantages:
* It avoids the complexity/learning curve of using a wrapper around pip.
* It means we do not need to fork the official Heroku Python buildpack
  (which handles pip installation of requirements files) in order to use
  hash verification on Heroku. (Once the buildpack updates to pip 8.)
* Omitted sub-dependencies result in install-time errors rather than
  the user discovering omissions at run-time.
* pip's native caching is used, and all packages are installed in one
  pip invocation, so it's significantly faster.
* It has better handling of errors and corner cases.

Key facts about the native feature:
* hash-checking mode is enabled if at least one hash is found in the
  requirements files passed to pip, or can be force enabled by passing
  `--requires-hashes` when running `pip install`.
* Once enabled, hash-checking mode enforces that all packages:
  - are pinned to a specific version
  - have hashes listed
  - have all sub-dependencies specified
* Older versions of pip will error out if either `--require-hashes` or
  the requirements file `--hash` syntax is used, meaning it's not
  possible to accidentally lose hash-checking protection if the pip used
  is older than expected.

For more details, see:
https://pip.pypa.io/en/stable/user_guide/#hash-checking-mode
https://pip.pypa.io/en/stable/reference/pip_install/#hash-checking-mode

The pip version on Travis and in the Vagrant virtualenv has been updated
to 8.0.2 in bug 1241144, and the stage/prod virtualenv in bug 1241519.
The Heroku Python buildpack pip was updated in bug 1241909.

The requirements files hashes were ported using `peep port`, and then
comments/URLs re-added by hand.
2016-02-15 12:06:17 +00:00
Ed Morley 6382279b98 Bug 1241144 - Travis: Update pip from 8.0.0 to 8.0.2
https://pip.pypa.io/en/stable/news/
2016-01-22 11:58:31 +00:00
Ed Morley e8de12c253 Bug 1241144 - Travis: Update pip from v7.1.2 to v8.0.0
So that we can confirm that peep still operates under pip v8, prior to
the transition from peep to pip v8's new hashing feature.

https://pip.readthedocs.org/en/stable/news/
2016-01-21 11:12:06 +00:00
Ed Morley 9c80f8b885 Bug 1234897 - Use nodejs v5.3.0 on Travis for parity with Heroku 2015-12-23 19:39:11 +00:00
Ed Morley 24de0871f4 Bug 1233091 - Update to Python 2.7.11 on Heroku/Travis 2015-12-21 15:28:57 +00:00
Ed Morley cd353f5e3c Bug 1160561 - Add support for setting BROKER_URL via the environment
The individual RABBITMQ_* variables are never used on their own, so it
makes more sense to switch to a URL variable that combines all of them.

Travis/Vagrant have also had BROKER URL explicitly set, since we're
generally moving away from having testing defaults set in settings.py.

Once stage/prod have BROKER_URL set, we can remove the fallback to the
old variable names, and also remove defaults entirely, making missing
settings fail fast.
2015-11-25 21:48:15 +00:00
Ed Morley 4d7d9f3d3b Bug 1223739 - Travis: Put etl tests in the 2nd chunk to balance runtimes
Previously the python chunks were approx 3m55s and 2m55s respectively,
since we couldn't move one of the largest running directories (etl) to
the second chunk, since the tests would fail due to bug 1219922.

After this change the python chunk runtimes are 3m15s and 3m25s.
2015-11-11 13:07:08 +00:00
Ed Morley 6c5721cee0 Bug 1219889 - Travis: Split the log parser/E2E tests into their own job
Since they take approx 35% of the py.test run time. Ideally we'd move
the ETL tests instead of the E2E ones to this separate job (since they
are more related to the log parsing tests than some of the others, and
would make the split more even), but they currently break when run
standalone, so we'll do that once bug 1219922 is fixed.
2015-10-29 22:11:13 +00:00
Ed Morley 7eb602e41a Bug 1219889 - Travis: Misc command syntax cleanup 2015-10-29 21:51:52 +00:00
Ed Morley 2bde0993db Bug 1219889 - Travis: Use pip rather than peep for the python-tests job
The python-tests job is run on non-container infra so can't use caching.
Peep install takes 60s compared to 30s for pip (part hashing cost, part
peep's unavoidable design inefficiencies due to not being built into
pip), which is painful given that we do a fully install every time due
to lack of caching.

The linters step (which can use caching) is already testing the peep
install works, so we can fall back to plain pip for this job part to
save an extra 30s from the runtime.

This also adds the `language: python` key which was the missing
ingredient to getting a virtualenv set up for us. Now that we're not
using peep, it doesn't matter that the provided virtualenv is using
pip v7.x (which is incompatible with peep).
2015-10-29 21:51:51 +00:00
Ed Morley 99fd1617ec Bug 1219889 - Travis: Break out the JS tests to their own job
Move the JS karma tests and the grunt build smoketest to their own job,
that runs on the container infra. The results are now available after
~50s rather than ~4mins previously. Ad added advantage is that since
we can now use `language: node_js`, we can pin to a specific version,
reducing the chance of breakage.

In addition, the python test run now no longer needs to npm install
(which isn't cacheable) and doesn't have the JS test/grunt build
runtime, saving ~120s.
2015-10-29 21:51:47 +00:00
Ed Morley cfdd90efeb Bug 1219889 - Travis: Break out the linter steps to their own job
Since this job sets `sudo: false`, it will run on the container infra,
so be able to use caching. The `env: linters` is so that a nice label
appears in the Travis sub-job UI, eg see:
https://travis-ci.org/mozilla/treeherder/builds/87763293

We install the full set of node and python dependencies, since
hardcoding just the packages we need here could lead to the versions
getting out of sync with package.json/the pip requirements files. In
addition isort requires a populated virtualenv, and npm sucks if
passing package names directly (it reinstalls them even if installed).
It's worth noting that with the cache, full dependency installation
only takes 2.5s, so this is all moot.

This job (once it has populated the cache) now only takes 24s
end-to-end, whereas previously it would have been ~3.5 mins before the
linters steps had completed.
2015-10-29 20:26:58 +00:00
Ed Morley 19a87884b3 Bug 1219889 - Travis: Move the job config under matrix.include
So that in a later commit we can split it into several jobs. See:
http://docs.travis-ci.com/user/customizing-the-build/#Explicity-Including-Builds

This is a no-op, done to make later commit diffs clearer.
2015-10-29 20:26:57 +00:00
Mauro Doglio 160be6af71 Bug 1193836 - let django create the test db on travis
Now that we have better integration between  pytest and django we don't
need to create the test db upfront. The test db will be created on the
first test that requiring it,
2015-10-27 11:19:18 +00:00
Mauro Doglio 5930b4f4c1 Bug 1193836 - Use pytest-django to run tests
pytest-django doesn't setup a test database for every single test, but
only for those tests that actually require a db. Tests that require a db
need to either be marked with `@pytest.mark.django_db` or use a fixture
that has a dependency on `db` or `transactional_db`.
Using a non transactional db would make tests execution much faster, but
unfortunately it doesn't play well with the treeherder datasource
creation so I used a transactional_db.

pytest-django also allows you to specify a settings file to use for
tests in a pytest.ini file, which is nicer than monkeypatch the original
settings file in the pytest session start function 😃.
2015-10-27 11:19:13 +00:00
Mauro Doglio d5f847e559 Bug 1193836 - Decouple the jobs and reference databases for test
We were previously using the same database (test_treeherder) for both the
jobs and reference data model. I centralized the new db name in the test
settings file. All the test requiring the jobs db or its repository counterpart
can now access it using the `test_project` fixture, while utility functions use
directly the metioned setting. Where the project name is hardcoded in a static
file, I just replaced it with the new name `test_treeherder_jobs`
2015-10-27 11:18:29 +00:00
Mauro Doglio 247cc3de64 Bug 1193836 - Use a dedicated settings file for testing 2015-10-27 11:18:19 +00:00
Ed Morley f0aac8884a Bug 1205316 - Travis: Use the beta Trusty infra & update to mysql 5.6
Stage/production/Vagrant/Heroku's RDS all use mysql 5.6, however Travis
is currently running v5.5. Installing mysql 5.6 manually on the Travis
container infra is currently broken:
https://github.com/travis-ci/apt-package-whitelist/issues/1206#issuecomment-149884653

To use sudo (for apt-get) we either have to fall back to the legacy
non-container infra, or else use the new Trusty beta infra:
http://blog.travis-ci.com/2015-10-14-opening-up-ubuntu-trusty-beta/
http://docs.travis-ci.com/user/trusty-ci-environment/#Runtimes

The Trusty beta infra is also non-container, but at least isn't EOL.
Unfortunately similar to the legacy non-container infra, it doesn't
offer caching, so incurs a setup time penalty of approx 3 minutes
(including the mysql 5.6 install, npm install and peep install). See:
https://github.com/travis-ci/travis-ci/issues/4997

If/when the container infra uses mysql 5.6 by default, or the bug
preventing installing it using the apt travis.yml option is fixed, we
should switch back to the container infra, to speed up the Travis run.

In this commit, we use `--user` with the peep install, since the
non-container infra doesn't set up a virtualenv, and we cannot use sudo
due to:
https://github.com/travis-ci/travis-ci/issues/4989

In addition, the current user ("travis") now doesn't have permissions to
create the Treeherder DB, so we have to use `-u root` (the password is
blank).

The new infra is running Python 2.7.10 (rather than the v2.7.9 of the
container infra) which now matches what runs in the Vagrant environment.
In future bugs we should update stage/prod and Heroku to 2.7.10 too.
2015-10-22 15:36:18 +01:00
Ed Morley c554745a2c Bug 1192957 - Add isort to the Travis run
Any import style deviations will cause the Travis run to fail, with the
diff output to the Travis log.
2015-10-02 17:55:29 +01:00
Ed Morley 47f807375f Bug 1210546 - Run `grunt build` on Travis
To ensure build script/parsing breakage is detected early.
2015-10-01 21:43:49 +01:00
Ed Morley ad3dc73715 Bug 1199179 - Remove default Django SECRET_KEY
Previously if TREEHERDER_DJANGO_SECRET_KEY was not set, we'd silently
fall back to a default value for SECRET_KEY, meaning we wouldn't realise
we were using an insecure key on a live deployment instance.

With this change, TREEHERDER_DJANGO_SECRET_KEY being missing from the
environment is fatal, resulting in:
"ImproperlyConfigured: The SECRET_KEY setting must not be empty."
2015-08-28 10:03:15 +01:00
Ed Morley 90ba77e596 Bug 1192801 - Remove per-file MPL boilerplate since it's unnecessary
The MPL 2.0 terms state that as long as a LICENSE file is present, the
per-file header text is not required. See "Exhibit A" at the end of:
https://www.mozilla.org/MPL/2.0/
2015-08-18 23:32:11 +01:00
Ed Morley 1af312e0cc Bug 1175432 - Use dj-database-url to simplify DB environment variables
dj-database-url extracts DB host, port, username, password and database
name from the env variable 'DATABASE_URL' (unless another env variable
name is specified). If the env variable is not defined, it falls back to
the default passed to dj_database_url.config().

This means for Heroku and similar we can replace the multiple DB env
variables with just one URL for default & one for read_only.

This also effectively makes the setting of the read only DB variable
mandatory for stage/production/heroku, since DEFAULT_DATABASE_URL won't
be valid for them - so prevents us inadvertently not using the read only
DB.

The deployment script also had to be updated, so that we set the
prod/stage-specific environment variables before using manage.py, since
dj-database-url cannot rely on what's in the stage/prod local.py config
(which isn't a bad thing, since we're deprecating that file).
2015-07-15 14:58:46 +01:00
William Lachance 658927bdf7 Bug 1183367 - Add a grunt target to run eslint on JS frontend 2015-07-14 13:40:18 -04:00
Ed Morley 9371347bc2 Revert "Bug 1175432 - Use dj-database-url to simplify DB environment variables"
This reverts commit 3330b3c567.
2015-07-09 23:05:49 +01:00
Ed Morley 3330b3c567 Bug 1175432 - Use dj-database-url to simplify DB environment variables
dj-database-url extracts DB host, port, username, password and database
name from the env variable 'DATABASE_URL' (unless another env variable
name is specified). If the env variable is not defined, it falls back to
the default passed to dj_database_url.config().

This means for Heroku and similar we can replace the multiple DB env
variables with just one URL for default & one for read_only.

This also effectively makes the setting of the read only DB variable
mandatory for stage/production/heroku, since DEFAULT_DATABASE_URL won't
be valid for them - so prevents us inadvertently not using the read only
DB.

Before this is deployed, we'll need to update the stage/prod puppet
configs & Heroku settings to add the new environment variable.
2015-07-09 17:54:29 +01:00
Ed Morley 58813b0c51 Bug 1169916 - Stop using Cython to build the log parser
Since it only speeds up parsing by a few percent of total runtime, and
is therefore not worth the added complexity for deployment and local
hack-test-debug cycles when working on the log parser.

The .gitignore and update.py entries will be removed in a later commit,
once the stage/prod src directories have been cleaned up.
2015-06-30 14:51:57 +01:00
Ed Morley 82de9c16fd Bug 1160561 - Consolidate rabbitmq prefs
Sets the default values (and now also those used by Vagrant) to the same
as those used by Travis, so we can avoid specifying different values all
over the place.
2015-05-28 16:09:48 +01:00
Ed Morley b10646e74e Bug 1160561 - Consolidate memcached prefs 2015-05-28 16:09:47 +01:00
Ed Morley dec412e12d Bug 1160561 - Consolidate DB prefs
Sets the default values to something sensible, to reduce the number of
prefs we have to set in the environment everywhere.
2015-05-28 16:09:46 +01:00
Ed Morley 27d8f69dee Bug 1169178 - Consolidate peep invocations
There's no need to make multiple calls to peep - we can just combine
them into one. Not changing the puppet instances for Vagrant, since the
calls are made in two separate puppet modules and so would require a bit
of refactoring, which is going to occur in bug 1074151 and friends.
2015-05-28 09:40:20 +01:00
Ed Morley 5ca4afd464 Bug 1166901 - Get the UI tests running as part of the travis run
This merges the service and UI Travis configs, to get the Karma UI tests
running on Travis in the new repo. We can only set 'language' to one
value, however that doesn't matter, since nodejs is installed by default
and all the 'language: node_js' did was set a few default build cycle
steps - and we can define those ourselves manually.

We install the deps using npm install, ensure they are cached by adding
the node_modules directory to the cache list, get xvfb running for Karma
(see http://docs.travis-ci.com/user/gui-and-headless-browsers/) and use
|npm test| to run Karma using karma.conf.js.

The end to end tests (karma-e2e.conf.js) are not currently running, same
as before the repo merge.
2015-05-27 22:18:25 +01:00
Ed Morley 8e67030a35 Bug 1143350 - Use peep instead of pip locally, on Travis & in Docker
We want to start using peep in production, to alleviate security
concerns with the idea of auto-updating packages from PyPI on deploy.
As a first step, we switch to using peep in the Vagrant environment,
on Travis and in the Docker build - so we can confirm the hashes are
correct.

Close bug 1143350.
2015-03-19 12:26:07 +00:00
Ed Morley 25db851ee4 Bug 1143086 - Travis: Run flake8 first & end the job early if it fails
Steps in before_script (and any other part of the build lifecycle apart
from 'script') terminate the run immediately on failure. This means in
the case of flake8 failures, the job changes from "in progress" to
"errored" virtually immediately (with the virtualenv caching changes) so
the user can see the problem and re-push straight away. See:
http://docs.travis-ci.com/user/build-lifecycle/
2015-03-16 12:16:16 +00:00