Commit Graph

12560 Commits

Author SHA1 Message Date
Rishi Gupta 929b69397b analytics: Change string representation of BaseCount models.
Previously we showed both the value and the id of the BaseCount record,
which is confusing in a typical case where you only care about the value,
and both the value and id are smallish ints.
2016-10-09 16:09:04 -07:00
Rishi Gupta c6b611c8b9 analytics: Re-organize tests into higher level TestClasses.
Refactor the current analytics tests into the following classes:
* TestUpdateAnalyticsCounts, which will eventually test the management
  command, backfilling, what happens when new tests are added, etc.
* TestProcessCountStat, which tests the ins and outs of propagating the
  value of a single stat up through the various *Count tables.
* TestAggregates, which tests the do_aggregate_* methods.
* TestXByYQueries, which tests the count_X_by_Y_query SQL snippets.
* TestCountStats, which has tests for individual CountStats.

This commit does not change the name or contents of any individual test.
2016-10-09 16:09:04 -07:00
Rishi Gupta 795d10b9ad analytics: Refactor tests to simplify asserts of count values.
Many tests are structured to run some process, and then check a count in a
BaseCount record using default values for realm, property, interval, and
end_time. This commit adds a new assertCountEquals method to
AnalyticsTestCase, and simplifies other assert calls as appropriate.
2016-10-09 16:09:04 -07:00
Rishi Gupta 35cf9092d5 analytics: Canonicalize creation of model objects in tests.
Add a default_realm object to AnalyticsTestCase, created 2 days before
AnalyticsTestCase.TIME_ZERO.

Add lightweight create_user, create_stream, and create_message methods to
AnalyticsTestCase, with sensible defaults. In particular, all objects are by
default created at AnalyticsTestCase.TIME_LAST_HOUR, so that they are
included when running AnalyticsTestCase.process_last_hour.
2016-10-09 16:09:04 -07:00
Rishi Gupta 6996b21480 analytics: Change tests to use a fixed TIME_ZERO.
Previously, analytics tests used timezone.now or custom datetime objects
when creating new realms, users, and streams.

This commit adds a fixed TIME_ZERO and a process_last_hour helper function
in a new AnalyticsTestCase class, and modifies the existing tests to use
them.
2016-10-09 16:09:04 -07:00
Kouhei Sutou 638d9ee262 markdown: Make subscribe notification translator friendly.
Some languages such as Japanese use different word order with
English. If the stream name must be the last word, translating to these
languages is difficult.
2016-10-09 11:19:19 -07:00
sonali0901 5623fa9994 request docs: Fix typo in spelling of "parameter". 2016-10-09 11:13:49 -07:00
Katy310 5d0960ae04 Change color of inline code from red to black.
This makes inline code blocks look nicer.

Fixes #1223.
2016-10-09 11:02:18 -07:00
Steve Howell 0bdc9fef5c Upgrade caspersjs to version 1.1.3. (w/acrefoot)
(Most of this work was done by acrefoot in an earlier branch.
I took over the branch to fix casper tests that were broken during
the upgrade (which were fixed in a different commit).  I also
made most of the changes to run-casper.)

This also upgrades phantomjs to 2.1.7.

The huge structural change here is that we no longer vendor casperjs
or download phantomjs with our own script.  Instead, we just use
casperjs and phantomjs from npm, via package.json.

Another thing that we do now is run casperjs tests individually, so
that we don't get strange test flakes from test interactions.  (Tests
can still influence each other in terms of changing data, since we
don't yet have code to clear the test database in between tests.)

A lot of this diff is just removing files and obsolete configurations.

The main new piece is in package.json, which causes npm to install the
new version.

Also, run-casper now runs files individually, as mentioned above.

We had vendored casperjs in the past.  I didn't bring over any of our
changes.  Some of the changes were performance-related (primarily
5fd58cf249), so the upgraded version may
be slower in some instances.  (I didn't do much measurement of that,
since most of our slowness when running tests is about the setup
environment, not casper itself.)  Any bug fixes that we may have
implemented in the past were either magically fixed by changes to
casper itself or by improvements we have made in the tests themselves
over the years.

Tim tested the Casper suite on his machine and running the full Casper
test suite is faster than it was before this change (1m30 vs. 1m50),
so we're at least not regressing overall performance.
2016-10-08 12:08:43 -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
Rishi Gupta ea050d5fd8 test_runner: Fix error message for failed import.
Previously, we suggested running
`python -c import zerver.tests.test_mytest`
when importing test_mytest failed, which doesn't work.

This commit adds the missing quotes, making it
`python -c 'import zerver.tests.test_mytest'`
2016-10-08 11:51:53 -07:00
Eklavya Sharma 4b1a2adca5 provision.py: Don't create py2 venv in py3 mode.
When running tools/provision.py in python3 mode, we used to create
a python2 venv called zulip-py2-twisted-venv. This was needed because
Zulip couldn't run tools/run-dev.py in python3. So we switched to
this virtualenv when running tools/run-dev.py.

Now that Zulip can run tools/run-dev.py in python3, we don't need
to create this virtualenv anymore.
2016-10-07 13:39:37 -07:00
Steve Howell 4400cb3735 casper: Prepare 11-mention.js for upgrade.
Use common.turn_off_press_enter_to_send() and look at the
correct element for visibility.
2016-10-07 13:30:11 -07:00
Steve Howell b5fed72dd7 casper: Use better messages in 10-admin.js. 2016-10-07 13:30:11 -07:00
Steve Howell 384dd23058 casper: Rewrite 09-navigation.js. 2016-10-07 13:30:11 -07:00
Steve Howell 52659ccae4 casper: Improve 06-settings.js.
Use higher level selectors to detect visibility of key components.

Also click through the menu more explicitly.
2016-10-07 13:30:11 -07:00
Steve Howell a8821b3057 casper: Click through menu in 05-subscriptions.js. 2016-10-07 13:30:11 -07:00
Steve Howell 49724d1ac3 casper: Use better selectors in 04-compose.js. 2016-10-07 13:30:11 -07:00
Steve Howell 0ded74e9de casper: Use then_log_out() in 01-login.js 2016-10-07 13:30:11 -07:00
Steve Howell 69694b77fb casper: Improve common.js.
These changes prepare us for the casperjs upgrade:

    Extract init_viewport().
    Have then_log_out() do more explicit waiting.
    Add turn_off_press_enter_to_send().
2016-10-07 13:30:11 -07:00
Tim Abbott a4b2a6b6d4 puppet: Fix missing dependency for supervisor enabling.
You can't run `systemctl enable` on a service before the package
containing the service is installed.
2016-10-06 21:44:10 -07:00
K.Kanakhin 06e70e1fbd run-dev-proxy: Fix twisted py3 compatibility.
- All necessary strings was converted to bytestring
 - Added twisted as py3 dependency
 - Change type annotation for method getchild of class Resource
 - Remove activating python2 env section from run-dev.py script

Fixes #1256
2016-10-06 20:21:25 -07:00
umkay 78477ea071 Reorder the columns in analytics tables inherited from BaseCount.
This is primarily implemented through altering the migration file in
order to move the columns, but also we try to make the defaults a
little better for future tables inherited from BaseCount.
2016-10-06 17:51:01 -07:00
Diptanshu8 d7253b144c generate-secrets: Refactor to make development/production explicit.
generate-secrets.py now requires --development for development environment
setup or --production for production environment setup (and one of these
options is mandatory).

This solves the problem that it was somewhat easy to accidentally run
generate-secrets.py without the `-d` option while doing manual development
environment setup.

Fixes: #1911.
2016-10-06 17:12:49 -07:00
umkay 01324f2afe Fix aggregation to analytics summary tables.
There are a number of different stats that need to be propagated from
UserCount and StreamCount to RealmCount, and from RealmCount to
InstallationCount. Stats with hour intervals also need to have their day
values propagated. This commit fixes a bug in the summary table aggregation
logic so that for a given interval on a CountStat object we pull the correct
counts for the interval as well as do the day aggregation if required. We Also
ensure that any aggregation then done from the realmcount
table to the installationcount table follows the same aggregation logic
for intervals.
2016-10-06 08:46:33 -07:00
Rishi Gupta ff4d059595 Message editing: add explanation when past message edit deadline.
Adds "Topic editing only" along with the tooltip explanation to lower right
of message editing box when it's past the message content editing deadline.
2016-10-05 22:42:56 -07:00
Brock Whittaker cc8b8c1614 Separate default streams list from admin_tab template.
This separates default streams list settings into its own template in
the templates/settings folder.
2016-10-05 22:27:15 -07:00
Brock Whittaker 7be19dd860 Separate streams list from admin_tab template.
This separates streams list settings into its own template in the
templates/settings folder.
2016-10-05 22:27:15 -07:00
Brock Whittaker b196fb9798 Separate bot list from admin_tab template.
This separates bot list settings into its own template in the
templates/settings folder.
2016-10-05 22:27:15 -07:00
Brock Whittaker a56379e4d7 Separate deactivated user list from admin_tab template.
This separates deactivated user list settings into its own template in
the
templates/settings folder.
2016-10-05 22:27:15 -07:00
Brock Whittaker ecb6c7df40 Separate user list from admin_tab template.
This separates user list settings into its own template in the
templates/settings folder.
2016-10-05 22:27:15 -07:00
Brock Whittaker d2f3e9eb7f Separate emoji settings from admin_tab template.
This separates emoji settings into its own template in the
templates/settings folder.
2016-10-05 22:27:15 -07:00
Brock Whittaker 403c6322ae Separate organization settings from admin_tab template.
This separates organization settings into its own template in the
templates/settings folder.
2016-10-05 22:27:15 -07:00
Brock Whittaker b81967d6ef Separate account settings from settings_tab template.
This separates account settings into its own template in the
templates/settings folder.
2016-10-05 22:27:15 -07:00
Brock Whittaker 26fda72157 Separate UI settings from settings_tab template.
This separates UI settings into its own template in the
templates/settings folder.
2016-10-05 22:27:15 -07:00
Brock Whittaker 330edddeff Separate alert word settings from settings_tab template.
This separates alert word settings into its own template in the
templates/settings folder.
2016-10-05 22:27:15 -07:00
Brock Whittaker 68b8a7b40d Separate bot settings from settings_tab template.
This separates bot settings into its own template in the
templates/settings folder.
2016-10-05 22:27:14 -07:00
Brock Whittaker aca78df56f Separate notification settings from settings_tab template.
This separates notification settings into its own template in the
templates/settings folder.
2016-10-05 22:27:14 -07:00
Brock Whittaker ff3d5ca4db Separate display settings from settings_tab.handlebars.
This separates the display settings module from the
settings_table.handlebars template.

Additionally, it fixes the node tests to search in the
static/templates/settings directory and initialize any templates in there
while running tests on the settings templates.
2016-10-05 22:26:40 -07:00
Brock Whittaker 3efe3601b8 Allow for templates/settings to be read and compiled.
This allows for the handlebars templates in the template/settings
subdirectory to be found and compiled.
2016-10-05 22:24:22 -07:00
Tim Abbott 82764d0215 run-dev: Display the port 9991 warning in colored text. 2016-10-05 22:07:46 -07:00
Feorlen e09c27f1ae run-dev.py: Log what service is being started on which port.
The new messages make it more obvious which services are started
from run-dev.py, and explicitly call out where to access the web
proxy to reach the Zulip web UI. This is a common confusion for
new administrators/developers. Messages are output before the
processes are launched, as run-dev.py does not currently have a
way to know if they started successfully.

Example output:

Starting Zulip services on ports:  web proxy: 9991, Django: 9992, Tornado: 9993, webpack: 9994
Note: only port 9991 is exposed to the host in a Vagrant environment.

Alternate behavior for automated testing:

If run-dev.py is invoked with --test, don't include the webpack
port as it isn't used.

Tested on Ubuntu 14.04, by running run-dev.py at a shell prompt and
via the test-all script.

Fixes #1861
2016-10-05 22:07:46 -07:00
Tim Abbott d0f295c77f docs: Clarify commit message portion of version control docs. 2016-10-05 19:28:21 -07:00
Rishi Gupta d387012bc6 Fix EXTERNAL_HOST computations in test_settings.py.
test_settings.py was setting EXTERNAL_HOST after importing settings.py,
which has several variables (like SERVER_URI) that are computed from
EXTERNAL_HOST.

[tweaked by tabbott to add comments explaining the story here].
2016-10-05 19:04:55 -07:00
Tim Abbott 5357b286b2 docs: Fix typo in spelling of generate_secrets. 2016-10-05 17:47:14 -07:00
Tim Abbott 273c17a072 update_analytics_counts: Add missing future imports. 2016-10-05 17:13:46 -07:00
umkay 5d0bed8673 Add script to clear analytics tables. 2016-10-05 17:11:13 -07:00
Rishi Gupta 777fcaa6a0 Add new organization type field to Realm objects.
Adds a new field org_type to Realm.  Defaults for restricted_to_domain
and invite_required are now controlled by org_type at time of realm
creation (see zerver.lib.actions.do_create_realm), rather than at the
database level.  Note that the backend defaults are all
org_type=corporate, since that matches the current assumptions in the
codebase, whereas the frontend default is org_type=community, since if
a user isn't sure they probably want community.

Since we will likely in the future enable/disable various
administrative features based on whether an organization is corporate
or community, we discuss those issues in the realm creation form.
Before we actually implement any such features, we'll want to make
sure users understand what type of organization they are a member of.

Choice of org_type (via radio button) has been added to the realm
creation flow and the realm creation management command, and the
open-realm option removed.

The database defaults have not been changed, which allows our testing code
to work unchanged.

[includes some HTML/CSS work by Brock Whittaker to make it look nice]
2016-10-05 17:01:46 -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
Tim Abbott 498317d533 Fix renaming streams on web to use new API.
In 142dce2cd4, we replaced the API for
renaming a stream, but failed to actually update the javascript to use
the new API.
2016-10-04 21:48:38 -07:00