Commit Graph

312 Commits

Author SHA1 Message Date
Steve Howell 5003283b64 Enforce 100% test coverage for lib/avatar.py. 2017-05-23 20:07:07 -07:00
Jason Michalski a22d6d2c2a test-backend: Enable test coverage in multi-process mode.
We enable data_suffix option when creating Coverage instances which
causes the output files to include the hostname, pid, and random id.
Before each run erase is called which clears all existing coverage data
files. And then at the end of the test run use the combine method which
merges the reports.

We collect coverage in the main process which collects data from
imports and also when running in single process mode. In the workers we
collect coverage in run_subsuite. This creates more stats files than
strictly required but I don't see a better place to save the stats when
stopping workers.

Note that this has the side effect of enabling parallel testing in
Travis CI.
2017-05-23 18:25:13 -07:00
Steve Howell ecdc500440 test-backend: Run only one process for --rerun option. 2017-05-23 16:59:22 -07:00
Umair Khan 286f9a40e7 push_notifications: Bring file to 100% coverage. 2017-05-16 12:26:55 -07:00
Tim Abbott 232592cc9f test_sessions: Extends tests to reach 100% coverage of sessions.py.
Fixes #3980.
2017-05-10 10:12:21 -07:00
Umair Khan 6b1c53059b testing: Run in parallel mode by default.
This commit changes the backend testing framework to run
in parallel mode which is same as --processes=4. If --coverage
is supplied, we enforce serial mode, --processes=1, because
coverage is not compatible with parallel mode at the moment.
2017-05-04 16:06:34 -07:00
K.Kanakhin e2cf6102fb test_tornado.py: Add websocket closing to tornado tests.
- Extend tornado tests with closing WebSocket connection
to avoid leakings warnings.
- Mark test_tornado as having 100% coverage.

Fixes #3942.
2017-04-27 12:05:56 -07:00
Ayush Jain 518d25a0cf Disable proxy setting for test-backend and test-js-with-casper.
This fixes the fact that our test suites would have trouble connecting
to the other parts of the Zulip service when run with a proxy
configuration (e.g. trying to send requests to localhost through the
proxy!).

Thanks for Vishnu Ks for his work on this.

Fixes #971.
2017-04-18 12:35:44 -07:00
Umair Khan bf713bcdfe testing: Don't create DB twice for backend.
In backend tests, only call generate-fixtures when --generate-fixtures
is explicitly passed or is_template_database_current() returns False.

We don't need to flush cache for backend tests because we bounce the key
prefix used to create cache keys before running every test
2017-04-14 10:23:16 +05:00
Adarsh S d54dea819d Add option for re-running failed tests.
This adds the option '--rerun' to the `test-backend` infrastructure.
It runs the tests that failed during the last 'test-backend' run.  It
works by stailing failed test info at var/last_test_failure.json

Cleaned up by Umair Khan and Tim Abbott.
2017-04-12 11:35:31 -07:00
Tim Abbott 36bb2bf54a AdminZulipHandler: Bring logging_handlers.py to 100% test coverage.
This involved fixing some unupdated code in one code path.
2017-03-26 13:10:43 -07:00
Elliott Jin 98ddb4453e test-backend: Raise zerver/views/home.py test coverage to 100%. 2017-03-25 18:16:16 -07:00
Elliott Jin 1c0d58f897 test-backend: Raise zerver/views/auth.py test coverage to 100%. 2017-03-25 18:16:16 -07:00
Tim Abbott a6ae546f59 test_events: Bring zerver/lib/events.py to 100% coverage. 2017-03-23 22:43:10 -07:00
Umair Khan 2d4a1f93ff testing: Bring zproject.backends coverage to 100%. 2017-03-23 17:12:58 -07:00
Tim Abbott 06492738b5 dev: Expose coverage and built documentation to web.
This makes it much more convenient for developers to access coverage
and built developer documentation.
2017-03-23 13:10:06 -07:00
Umair Khan 0fc946aef4 testing: Add reverse option to test runner. 2017-03-22 12:07:21 -07:00
Umair Khan 2f243d8808 testing: Control parallelism through cmd args. 2017-03-22 11:59:30 -07:00
Umair Khan a2aeddba6b testing: Add infrastructure for running backend tests in parallel.
This doesn't yet provide an option to actually run the backend tests
parallelized yet.
2017-03-21 10:59:12 -07:00
Elliott Jin 1138057209 test-backend: Raise zerver/views/registration.py test coverage to 100%. 2017-03-18 18:11:59 -07:00
Tim Abbott e7b3ea8fab coverage: Require 100% coverage in analytics. 2017-03-14 17:11:25 -07:00
Umair Khan cdb07c7005 Fix test_get_old_messages_with_narrow_pm_with.
Fixes #3940.
2017-03-14 09:38:24 -07:00
Umair Khan 32849b80ad Django 1.10: Url pattern doesn't use _callback_str.
Fixes #3941
2017-03-09 00:50:12 -08:00
Elliott Jin 8d936601d3 test-backend: Raise zerver/views/test_upload.py test coverage to 100%. 2017-03-08 11:42:25 -08:00
Elliott Jin 3127ebfa3b test-backend: Raise zerver/views/events_register.py test coverage to 100%. 2017-03-07 19:47:16 -08:00
Tim Abbott b6f53d6c14 coverage: bring zerver/lib/validator.py to 100% coverage. 2017-03-05 00:53:27 -08:00
Tim Abbott e95f139308 coverage: bring zerver/lib/response.py to 100% coverage. 2017-03-05 00:53:26 -08:00
Tim Abbott 89decf6ded coverage: bring zerver/lib/request.py to 100% coverage. 2017-03-05 00:53:26 -08:00
Tim Abbott e7ff3415ab coverage: bring test_helpers.py to 100% coverage. 2017-03-05 00:53:26 -08:00
Tim Abbott 546fb9199d coverage: bring test_classes.py to 100% coverage. 2017-03-05 00:53:26 -08:00
Tim Abbott e3cfb256dd coverage: Bring zerver.lib.narrow.py to 100% coverage. 2017-03-05 00:53:26 -08:00
Tim Abbott 56b1f79fe3 integrations: Fix email integration being listed unconditionally. 2017-03-05 00:53:26 -08:00
Tim Abbott 5050e42212 test-backend: Document # nocoverage comments. 2017-03-04 23:47:16 -08:00
Tim Abbott e7389b4162 test-backend: Require 100% coverage on tests by default. 2017-03-04 23:39:34 -08:00
Tim Abbott 6c12a49d04 test_auth_backends: Remove now-unnecessary compatibility code.
This code was added as part of the Django 1.10 migration to make our
tests work with both Django 1.8 and 1.10.  Now that we're on 1.10,
it's no longer required.
2017-03-04 23:38:46 -08:00
Tim Abbott 39704bac6c test_bugdown: Remove unused common_bugdown_test. 2017-03-04 23:35:46 -08:00
Tim Abbott 1a8bc5f383 coverage: Bring test_decorators to 100% coverage. 2017-03-04 23:34:28 -08:00
Tim Abbott c73c3c52f8 test_email_mirror: Fix TestCommandMTA.
The test didn't actually use the mock, due to an incorrect import
path.
2017-03-04 23:28:48 -08:00
Tim Abbott 6ea3a9cb1d coverage: Bring test_templates.py to 100% coverage. 2017-03-04 23:28:48 -08:00
Tim Abbott d8171b2efc coverage: Bring tests.py to 100% coverage. 2017-03-04 23:17:36 -08:00
Tim Abbott 768307d921 coverage: Bring test_events to 100% coverage. 2017-03-04 23:12:32 -08:00
Tim Abbott 538570b7c1 test_subs: Bring to 100% test coverage. 2017-03-04 23:07:56 -08:00
Tim Abbott 065651b4fe coverage: Exclude uncovered lines in test_signup. 2017-03-04 23:01:50 -08:00
Tim Abbott bc0cd7eb90 coverage: Move coverage config to tools/coveragerc. 2017-03-04 22:48:05 -08:00
Tim Abbott 63664264b8 test-backend: Disable verbose coverage display. 2017-03-04 22:48:05 -08:00
Tim Abbott d90f7c72a3 zephyr: Fix broken postgres regular expression logic and add tests.
Like many rare-case code with new tests, it turns out that the logic
for handling null characters in our Zephyr postgres query escaping
never worked, in multiple ways.  First, it always changed the second
character in s, not the current one being inspected, and second, the
value it replaced it with was no the correct postgres escape of the
null byte.  We fix this and add tests.

This completes the effort to get zerver/views/messages.py to 100%
test coverage.

Fixes #1006.
2017-03-01 10:38:48 -08:00
Elliott Jin 7ed10da4ad test-backend: Raise zerver/views/report.py test coverage to 100%. 2017-02-28 20:06:00 -08:00
Elliott Jin 11ba94f11a test-backend: Raise zerver/views/integrations.py test coverage to 100%. 2017-02-28 09:31:06 -08:00
Elliott Jin 6bdefb92e9 test-backend: Raise zerver/views/zephyr.py test coverage to 100%. 2017-02-26 20:54:25 -08:00
Elliott Jin f3cd3e8b8d test-backend: Raise zerver/views/invite.py test coverage to 100%. 2017-02-26 16:15:25 -08:00
Elliott Jin cebc67f9b0 test-backend: Raise zerver/views/unsubscribe.py test coverage to 100%. 2017-02-26 16:13:35 -08:00
K.Kanakhin 257bb40698 realm-icon: Add realm icon feature.
- Add realm icon fields to realm model.
- Add migration for new realm model's field.
- Add views for icon uploading and deleting.
- Add routes for realm icons views.
- Add JS widget for realm icon upload setting.
- Add realm icon upload to administration
  organization setting.
- Add tests for realm icons.

Fixes #3660.
2017-02-26 12:16:07 -08:00
Elliott Jin f038cd47d9 test-backend: Raise zerver/views/realm.py test coverage to 100%. 2017-02-25 18:18:29 -08:00
Umair Khan 128beb910b testing: Use TestResult in run_test.
Internally, Django uses TestResult to gather results from testcases.
This commit upgrades the run_test function to use TestResult to compile
result.
2017-02-19 21:04:06 -08:00
Tim Abbott 9ac66b0121 test-backend: Update blacklist of covered files based on CI.
After accidentally merging ecadb33fbc
before I go CI input, I discovered that coverage in my development
environment differs from that in CI :(.
2017-02-18 18:52:59 -08:00
Tim Abbott ecadb33fbc test-backend: Add 100% test coverage assertions.
This adds an assertion, when `test-backend` is run with `--coverage`,
that we have 100% test coverage on a list of files that we expect to.
There's a whitelist/blacklist, managed in tools/test-backend.

Fixes #3363.
2017-02-18 16:34:40 -08:00
Umair Khan e5a16ceb0a testing: Use failfast instead of fatal_errors.
`failfast` has the same meaning as `fatal_errors` in Django's test
runner.
2017-02-10 16:01:43 -08:00
sinwar eab355b0cd tools: Create more consistent checks for venv.
This helps make the Zulip development environment somewhat more robust
to new contributors, since it will give them a nice warning if they
try running any of our development tools outside the Zulip virtualenv.

Fixes #3468.
2017-02-06 21:50:32 -08:00
Tomasz Kolek 7de45951e2 Make webhooks as separate modules with view and tests.
Create python packege for every webhook with view.py and tests.py
2017-01-25 23:14:19 -08:00
Tim Abbott aadf621466 test-backend: Only check for unrendered templates if tests passed. 2017-01-20 10:56:03 -08:00
reallyly 94b28e0afb pep8: Fix E128 violations.
With some line-wrapping tweaks by tabbott.
2016-12-13 10:50:14 -08:00
Adarsh S 31be2534b3 Fix Error: templates have no tests! while running TemplateTestCase.
We need to test all the templates only when we are running the full
 test suite. While running just the Test Class we need not check all
 the templates.
2016-12-09 12:09:55 -08:00
Tim Abbott fd81cc1d93 test-backend: Clarify missing template tests error message. 2016-12-01 10:12:38 -08:00
Tim Abbott e73ee5a4c4 test-backend: Fix count for templates without tests. 2016-11-30 15:38:19 -08:00
Tim Abbott 4f6a075331 test-backend: Fix missing output for untested templates.
Our enforcement logic for untested templates unfortunately did not
give a clear error message unless you passed the --verbose option.
2016-11-29 16:38:18 -08:00
Steve Howell 5f5e6b6d83 tests: Enforce 100% URL coverage.
We now instrument URL coverage whenever you run the back end tests,
and if you run the full suite and fail to test all endpoints, we
exit with a non-zero exit code and report failures to you.

If you are running just a subset of the test suite, you'll still
be able to see var/url_coverage.txt, which has some useful info.

With some tweaks to the output from tabbott.

Fixes #1441.
2016-11-18 18:10:29 -08:00
paxapy 012ec2beda test-backend: Use a fixed whitelist of shallow-tested templates.
This enforces the requirement that all templates not on this list are
tested.  Part of #1677.
2016-11-17 11:34:50 -08:00
Tim Abbott 44767c59a2 Coverage: Exclude migrations and management commands.
These are not particularly interesting to measure test coverage for,
since migrations are not run as the part of the test suite by
construction, and management commands aren't being tested by this test
suite.
2016-11-06 18:34:23 -08:00
sonali0901 df4b777b35 tests: Fix handling of subdirs and backup files in test-backend.
Fixes #1950.
2016-11-04 21:49:23 -07:00
Steve Howell 6e628e23aa Add --force option to test-backend. 2016-10-16 14:52:14 -07:00
Steve Howell 10667b3cdb Check provisioning status in tools/test-backend. 2016-10-16 14:52:14 -07:00
Tim Abbott 75daba345a Finish annotating test-backend. 2016-10-15 22:36:10 -07:00
Rishi Gupta 7707d2a005 test-backend: remove trailing forward slash from test suite names.
Previously, running `tools/test-backend analytics/` (or any other test suite
name ending with a '/') would give a cryptic error about modules not
importing properly. This commit rstrip's the trailing slash from test suite
names given on the command line.
2016-10-08 11:52:55 -07:00
Tomasz Kolek dbeab6aa6f Optimize checks of test database state by moving into Python.
Previously, the generate-fixtures shell script by called into Django
multiple times in order to check whether the database was in a
reasonable state.  Since there's a lot of overhead to starting up
Django, this resulted in `test-backend` and `test-js-with-casper`
being quite slow to run a single small test (2.8s or so) even on my
very fast laptop.

We fix this is by moving the checks into a new Python library, so that
we can avoid paying the Django startup overhead 3 times unnecessarily.
The result saves about 1.2s (~40%) from the time required to run a
single backend test.

Fixes #1221.
2016-10-05 10:40:19 -07:00
umkay d260a22637 Add a new statistics/analytics framework.
This is a first pass at building a framework for collecting various
stats about realms, users, streams, etc. Includes:
* New analytics tables for storing counts data
* Raw SQL queries for pulling data from zerver/models.py tables
* Aggregation functions for aggregating hourly stats into daily stats, and
  aggregating user/stream level stats into realm level stats
* A management command for pulling the data

Note that counts.py was added to the linter exclude list due to errors
around %%s.
2016-10-04 17:18:54 -07:00
Tim Abbott 5ed37beb02 test-backend: Simplify argument rewriting logic. 2016-09-28 11:52:05 -07:00
sonali0901 4869e1b0b2 test-backend: Add convenience arguments to run subsets of the tests.
This optimizes the process of running individual or small groups of
backend tests (./tools/test-backend
zerver.tests.test_bugdown.FencedBlockPreprocessorTest.test_simple_quoting)
to allow the following syntaxes:

    ./tools/test-backend zerver/tests/test_bugdown.py
    ./tools/test-backend zerver.tests.test_bugdown.py
    ./tools/test-backend zerver/tests/test_bugdown
    ./tools/test-backend zerver.tests.test_bugdown
    ./tools/test-backend test_bugdown.py
    ./tools/test-backend test_bugdown
    ./tools/test-backend FencedBlockPreprocessorTest
    ./tools/test-backend FencedBlockPreprocessorTest.test_simple_quoting

Fixes #1670.
2016-09-28 11:52:05 -07:00
Steve Howell 21f83afe3a Add --url-coverage option to ./tools/test-backend. 2016-07-29 21:23:33 -07:00
Steve Howell 4556bf528f Add --report-slow-tests option to tools/test-backend. 2016-07-29 16:41:20 -07:00
Taranjeet Singh 9db457e8fa provision.py: Create var/coverage directory to store coverage data.
test-backend: Update coverage directory to var/coverage.

This commit updates the coverage directory to var/coverage as a part
of Issue 1132.
2016-07-13 18:58:00 -07:00
Tim Abbott 497142d7b1 Fix running test-backend from any working directory. 2016-07-12 10:39:33 -07:00
Eklavya Sharma 0de3b17f19 tools/test-backend: Add option to skip generate-fixtures.
Not calling generate-fixtures can reduce running time, which is
especially helpful when running a single test.
2016-07-12 09:34:37 +05:30
Tim Abbott c8aae360be test-backend: Fix spelling of an example in usage text. 2016-06-28 16:24:58 -07:00
Aakash Tyagi 9154d93669 Added help text for running single backend tests. 2016-06-27 14:15:30 -07:00
Alex Wilson f68a392250 Run django.setup() after coverage.start() in tests to fix coverage report.
Fixes #1007.
2016-06-21 10:37:45 -07:00
Tim Abbott 39a8c82957 travis: Remove verbose coverage report from end of build output. 2016-06-15 15:05:38 -07:00
Tim Abbott be53c9e39e tests: Check for presence of typing in venv guard.
Since relatively few systems have the typing module, this makes the
checks for whether the user is properly running our test scripts in
the virtualenv more likely to trigger well.
2016-06-06 13:41:34 -07:00
Ernesto Vargas ffb2f9e84b lint/tests: Give nice error message for common import failures.
This should make users much more likely to be able to debug issues
where they ran Zulip outside the Vagrant environment or virtualenv.

[error messages tweaked by tabbott]
2016-06-06 13:39:26 -07:00
Umair Khan c884559ec6 Show templates rendered report.
Add two options to the `test-backend` script:

1. verbose
    If given the `test-backend` script will give detailed output.
2. no-shallow
    Default value is False. If given the `test-backend` script will
    fail if it finds a template which is shallow tested.
2016-05-31 16:46:11 +05:00
Eklavya Sharma 149938d468 Change shebangs from python2.7 to python. 2016-05-29 05:03:08 -07:00
Umair Khan d425e05a02 Move tools/generate-fixtures to tools/setup/. 2016-05-26 17:54:32 +05:00
Tim Abbott cadbe64265 Fix venv files being included in coverage reports in CI.
e4707af2e2 didn't correctly deal with
the different path for the venv cache in Travis CI.
2016-05-19 10:25:56 -07:00
Tim Abbott e4707af2e2 test-backend: Fix venv files being included in coverage reports. 2016-05-19 09:36:53 -07:00
Tim Abbott be96cf809d Move Zulip backend tests to zerver.tests. 2016-04-11 22:16:09 -07:00
Eklavya Sharma 3ab567db98 Add call to generate-fixtures in test-backend.
Add call to tools/generate-fixtures in tools/test-backend before
starting the tests.  Previously, test-backend could fail if called
after tools/test-js-with-casper had failed.

Fixes #501.
2016-03-12 09:24:32 -08:00
Eklavya Sharma c59185e119 Apply Python 3 futurize transform libfuturize.fixes.fix_print_with_import
Refer #256
2016-03-10 22:02:17 -08:00
Tim Abbott a5d4d0aae0 test_backend: Add option to profile the backend test suite. 2016-01-26 20:41:01 -08:00
Tim Abbott f9791558e9 test_runner: Support continuing running tests after a failure. 2016-01-26 20:41:01 -08:00
Tim Abbott b43aadad8b test-backend: Rewrite in python to support computing test coverage.
The code for doing test coverage is just a lot cleaner this way over
adding it to the shell script version.

Based on the basic test runner code here:
https://docs.djangoproject.com/en/1.9/topics/testing/advanced/
2016-01-26 20:41:01 -08:00
Vladislav Manchev dfbea01c8f Add support for running OpenBSD in development environment. 2016-01-21 22:33:55 -08:00
Tim Abbott 7395003e6a Fix buggy #! lines using "/usr/bin/env python2.7 -u".
The #! line processing interpreted the argument to pass to `env` as
"python2.7 -u", which obviously isn't a real program.

We fix this by setting the PYTHONUNBUFFERED environment variable
inside the program, which has the same effect.

Thanks to Dan Fedele for the bug report and suggested solution!
2015-11-16 08:46:48 -08:00
Steven Oud d5435fad1d Consistently use /usr/bin/env python2.7 in shebangs and commands. 2015-10-21 22:58:21 +00:00
Tim Abbott 602077f75b We're no longer using the review script.
(imported from commit 9840ebdfdacee6e3cb32934b81502c70c133e2b0)
2015-09-20 00:10:54 -07:00
Tim Abbott 9181c7c75b Move generate-fixtures to tools/.
(imported from commit 3d452b17e315ba9adf91e33408a7711d16b069a2)
2013-08-08 10:22:32 -04:00
Tim Abbott 7b9305b06f Rename Django project to zproject.
This includes a hack to preserve humbug/backends.py as a symlink, so
that we don't need to regenerate all our old sessions.

(imported from commit b7918988b31c71ec01bbdc270db7017d4069221d)
2013-08-07 11:04:03 -04:00
Tim Abbott e111a2f9a5 [manual] Rename Django app from zephyr to zerver.
This needs to be deployed to both staging and prod at the same
off-peak time (and the schema migration run).

At the time it is deployed, we need to make a few changes directly in
the database:

(1) UPDATE django_content_type set app_label='zerver' where app_label='zephyr';
(2) UPDATE south_migrationhistory set app_name='zerver' where app_name='zephyr';

(imported from commit eb3fd719571740189514ef0b884738cb30df1320)
2013-08-06 07:39:36 -04:00
acrefoot 0972c1e677 [manual] Modify review to allow testing+review in the background
Does a test-all using /tmp.
Not safe to run with other tests simultaneously.

You use it just like tools/review, and on a successful test-all
it will submit the code review, without tying up your git working directory.

It depends on new patches to the acrefoot-bulk_create_with_id-1.5.1 branch of
django. Updating this is the [manual] step required. Since test-all doesn't happen
on staging or prod, this is not required for this commit to be deployed, but other
django patches will help with the SSL connection errors we've been seeing.

(imported from commit 3fd3ff00240a2d648c4c54748a8a70616067ef7d)
2013-06-06 17:36:02 -04:00
acrefoot 94c61f5507 [manual] Humbug testing databases now backed by postgres
Currently our test database is backed by sqlite; this commit moves
us to using postgres for our all database needs. This, in conjunction
with the patched django on github, allow us to have fewer hacks and
more true-to-life tests. It also sets the stage for testing the bulk_create
and schema search_path patches made to django.

Developers will need to run:
./tools/postgres-init-test-db
./tools/do-destroy-rebuild-test-database

this is assuming that they have already run:
./tools/postgres-init-db
./tools/do-destroy-rebuild-database

at some point on this pg_cluster. (The ordering is important; it will other-
wise complain about the south_migration table).

(imported from commit c56c6f27e13df7ae10b2e643e65d669dde61af3d)
2013-05-20 23:55:03 -04:00
Tim Abbott a095666770 test-backend: Don't pass --skip-generate to testing system by default.
It doesn't save much time (maybe 0.5s out of 12+s).

I'm leaving the option in because I think it is still useful for
iteratively testing a single test case.

(imported from commit a0ac43f4c48eec101f05d731740394b30a15773b)
2013-04-02 16:27:12 -04:00
Keegan McAllister 1622f53cb1 test-backend: Allow running a subset of tests
This now allows e.g.

    ./tools/test-backend zephyr.BugdownTest

or

    ./tools/test-backend zephyr.BugdownTest --verbosity=2

but unfortunately not

    ./tools/test-backend --verbosity=2 zephyr.BugdownTest

(imported from commit 95302db3efe45182d789c40c2a2899230a06b091)
2013-02-01 15:38:56 -05:00
Keegan McAllister 27b82c205f test-backend: Allow passing command arguments to manage.py test
This allows e.g.

    ./tools/test-backend --verbosity=2

(imported from commit 68979731e6d4ddba2bda62daa5f3206e633b54da)
2013-02-01 15:33:24 -05:00
Tim Abbott af88c10c5e Add tools/test-backend script to run backend tests.
(imported from commit fde4c7deb1e64e8cca9d62cda905f13d90392961)
2013-01-10 16:59:36 -05:00