treeherder/tests
Cameron Dawson bfdd99d9b9 Bug 1618751 - Push Health show trunk parent and commits 2020-03-04 14:48:24 -08:00
..
autoclassify Bug 1599526 - Push Health handle tasks with timout errors (#5723) 2019-12-12 12:24:22 -08:00
client
e2e
etl Bug 1509181 - Fix ingestion of GitHub pushes (#6065) 2020-02-28 09:10:52 -05:00
extract Bug 1617674 - BigQuery Extraction - include commits in push (#6093) 2020-03-03 17:30:18 -05:00
intermittents_commenter
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 1618751 - Push Health show trunk parent and commits 2020-03-04 14:48:24 -08:00
sample_data Bug 1509181 - Fix ingestion of GitHub pushes (#6065) 2020-02-28 09:10:52 -05:00
selenium Bug 1614039 - Re-write pin jobs tests (#5962) 2020-02-10 14:32:42 -08:00
services Support test environment outside of Docker container (#5716) 2020-02-05 14:55:03 -05:00
seta SETA improvements (#6002) 2020-02-18 11:51:53 -05:00
test_worker Bug 1574651 - ingest from multiple rabbitmq servers (#5399) 2019-10-10 16:53:18 -07:00
ui Bug 1618751 - Push Health show trunk parent and commits 2020-03-04 14:48:24 -08:00
utils
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
conftest.py Bug 1452238 - remove job_id from generate_enough_perf_datum (#5956) 2020-02-10 09:38:31 -05:00
env.bat Bug 1610347 - Extract jobs/perf/alert to BigQuery (#5839) 2020-02-06 13:16:26 -05:00
env.sh SETA improvements (#6002) 2020-02-18 11:51:53 -05:00
sample_data_generator.py
sampledata.py Bug 1395254 - Consume Taskcluster Pulse messages from standard queue exchanges 2019-07-29 09:42:57 -04:00
settings.py
test_middleware.py
test_setup.py
test_utils.py

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