treeherder/tests
Cameron Dawson 19cddb7b1d
Bug 1612224 - Give access to parent of Push Health commit (#5902)
2020-02-07 14:40:56 -08:00
..
autoclassify Bug 1599526 - Push Health handle tasks with timout errors (#5723) 2019-12-12 12:24:22 -08:00
client Bug 1530267 - Remove __future_ imports 2019-02-25 20:39:03 +00:00
e2e Bug 1528811 - Remove job-collection related classes from thclient (#4661) 2019-02-20 06:49:54 +00:00
etl Bug 1587393 - Provide backend support for tagging performance signatures (#5532) 2019-11-15 08:43:58 -05:00
extract Bug 1610347 - Extract jobs/perf/alert to BigQuery (#5839) 2020-02-06 13:16:26 -05:00
intermittents_commenter Bug 1526764 - Make test_intermittents_commenter pass under Python 3 (#4615) 2019-02-11 17:51:15 +00:00
log_parser Support test environment outside of Docker container (#5716) 2020-02-05 14:55:03 -05:00
model Bug 1597368 - faster cycle data (#5724) 2019-12-12 19:17:42 -05:00
perfalert Bug 1571369 - Store backfill reports per alert summary (#5539) 2019-11-14 08:29:55 -05:00
push_health Bug 1612224 - Give access to parent of Push Health commit (#5902) 2020-02-07 14:40:56 -08:00
sample_data Bug 1574651 - ingest from multiple rabbitmq servers (#5399) 2019-10-10 16:53:18 -07:00
selenium Bug 1580893 - Support filtering tasks by test path (#5794) 2020-01-24 15:29:57 -05:00
services Support test environment outside of Docker container (#5716) 2020-02-05 14:55:03 -05:00
seta Bug 1547238 - SETA - mark new jobs as low priority. r=camd (#4917) 2019-04-26 09:06:35 -07:00
test_worker Bug 1574651 - ingest from multiple rabbitmq servers (#5399) 2019-10-10 16:53:18 -07:00
ui Bug 1612224 - Give access to parent of Push Health commit (#5902) 2020-02-07 14:40:56 -08:00
utils Add chunked_qs_reverse function 2018-05-04 08:57:50 +01:00
webapp Support test environment outside of Docker container (#5716) 2020-02-05 14:55:03 -05:00
README.md Support test environment outside of Docker container (#5716) 2020-02-05 14:55:03 -05:00
__init__.py fix RefDataManager and add firts working test on it 2013-04-17 17:13:24 +01:00
conftest.py Support test environment outside of Docker container (#5716) 2020-02-05 14:55:03 -05:00
env.bat Bug 1610347 - Extract jobs/perf/alert to BigQuery (#5839) 2020-02-06 13:16:26 -05:00
env.sh Bug 1610347 - Extract jobs/perf/alert to BigQuery (#5839) 2020-02-06 13:16:26 -05:00
sample_data_generator.py Bug 1530267 - Remove __future_ imports 2019-02-25 20:39:03 +00:00
sampledata.py Bug 1395254 - Consume Taskcluster Pulse messages from standard queue exchanges 2019-07-29 09:42:57 -04:00
settings.py Bug 1337717 - Update to newer Celery, Kombu, py-amqp and billiard (#4722) 2019-02-28 19:52:22 +00:00
test_middleware.py Bug 1530602 - Adjust Content-Security-Policy to fix ajv.compile() (#4703) 2019-02-26 08:04:53 +00:00
test_setup.py Update pytest to 4.1.0 (#4427) 2019-01-08 11:04:57 +00:00
test_utils.py Bug 1295997 - Skip parsing logs whose compressed size exceeds 5MB (#4700) 2019-02-25 19:04:38 +00:00

README.md

Backend development

The backend test suite can be run outside the Docker container.

Start the services

We need all but the main backend service running. Since multiple backend instances are allowed, we will simply start everything up

# ENSURE THE IMAGES ARE CLEAN
docker-compose down
docker volume rm treeherder_mysql_data 

# SETUP ALL IMAGES
docker-compose up --build

Install into virtual environment

Treeherder requires specific library versions that will likely interfere with what you have installed. It is best to setup a virtual environment to contain the quirks it introduces.

Be sure you are in the treeherder main directory

pip install virtualenv
virtualenv .venv                   # IMPORTANT: Notice the dot in the name
source .venv/bin/activate
python -m pip install -r requirements/common.txt
python -m pip install -r requirements/dev.txt

...or Windows...

pip install virtualenv
rem IMPORTANT: Notice the dot in `.venv`
virtualenv .venv             
.venv\Scripts\activate
python -m pip install -r requirements\common.txt
python -m pip install -r requirements\dev.txt

Set environment variables

Treeherder requires a number of environment variables that point to the services. In our case, those services are in local docker containers.

./tests/env.sh     # env.bat for Windows

If you plan to use an IDE, here is the same, as a very long line

BROKER_URL=localhost//guest:guest@rabbitmq//;DATABASE_URL=mysql://root@localhost:3306/treeherder;REDIS_URL=redis://localhost:6379;SITE_URL=http://backend:8000/;TREEHERDER_DEBUG=True;TREEHERDER_DJANGO_SECRET_KEY=secret-key-of-at-least-50-characters-to-pass-check-deploy;NEW_RELIC_DEVELOPER_MODE=True

Ensure everything is working

Django can perform a number of checks to ensure you are configured correctly

python manage.py check

Run the tests

Be sure docker-compose is up, you are in the treeherder main directory, your virtual environment is activated, and your environment variables are set:

source .venv/bin/activate
./tests/env.sh
pytest tests

Pre commit checks

If you made some changes, and want to submit a pull request; run the ./runtests.sh script (found in the main directory). It will run some linters to check your submission.

For Windows, you can run the checks in a container (see below)

Using containers

After docker-compose up, you may spin up any number of backend containers. You may want to run ingestion tasks, or go exploring.

docker-compose exec backend bash

docker-compose has three execution modes

  • exec - run just the service, and assume the others are running
  • run - run all the services, but do not open their ports
  • up - run all the services with ports open

More can be read here: docker-composes up vs run vs exec