zulip/zerver/tests
Steve Howell d723be125a Optimize get_recipient_info() for sending messages.
This commit makes get_recipient_info() faster by never creating
Django ORM objects.  We use the ORM to create a values query
instead, and then we iterate over the rows to create various
collections of ids.

In order to avoid lots of code duplication, this commit unifies
how we query UserProfile for PMs and streams.  Prior to this
commit we were getting "wide" UserProfile objects out of
our memcached cache.  Now we just go to the database with our
list of userids.  The new approach at worst adds one hop to the
database for PMs, which aren't really a performance bottleneck
(compared to streams).  And the new approach actually saves a
hop when both partners aren't in cache (plus we don't pay the
penalty of hitting the cache itself).

The performance improvement here is easy to measure for messages
to streams with many users, even with all the other activity
that goes on inside do_send_messages().  I took test_performance()
in test_messages.py, set num_extra_users to 3000, and consistently
measured a ~20% speedup in do_send_messages().

This commit also eliminates fetching of emails.  We probably
could have done that in a prior commit, but in this commit it
is very explicit that we don't need it.  While removing email
from the query is a no-brainer, it actually had a negigible
impact on performance.  Almost all the savings here comes from
not create UserProfile objects.
2017-09-12 04:22:55 -07:00
..
images
__init__.py
test_alert_words.py test_alert_words: Upgrade to HttpResponse.json(). 2017-08-16 07:06:58 -07:00
test_attachments.py tests: Remove unused ujson imports. 2017-08-17 09:05:52 -07:00
test_audit_log.py actions: Start logging subscription activities in RealmAuditLog. 2017-07-17 17:23:41 -07:00
test_auth_backends.py tests: Make requests use the "zulip" subdomain by default. 2017-08-25 15:42:49 -07:00
test_bots.py test_classes: Clean up API for unsubscribing. 2017-08-24 21:37:57 -07:00
test_bugdown.py Use user_ids, not full objects, in render path. 2017-09-12 04:22:55 -07:00
test_compatibility.py mobile: Add an endpoint for checking compatibility. 2017-02-03 09:55:34 -08:00
test_custom_profile_data.py api: Fix caps in JSON validation error message. 2017-06-27 08:33:56 -04:00
test_decorators.py test_decorator: Add explicit subdomains in tests. 2017-08-28 22:51:57 -07:00
test_docs.py landing: Add /plans/ describing ways to use Zulip. 2017-08-30 07:56:22 -07:00
test_email_change.py Fix changing email addresses back after email change. 2017-08-05 10:49:44 -07:00
test_email_mirror.py digest emails: Add unit tests for digest email management. 2017-08-27 13:10:14 -07:00
test_events.py Exclude muted topics from unread count. 2017-09-07 07:06:03 -07:00
test_export.py tests: Replaced @zulip.com references with self.example_ functions. 2017-05-23 20:59:50 -07:00
test_external.py tests: Remove unused ujson imports. 2017-08-17 09:05:52 -07:00
test_home.py settings: Rename SERVER_URI to ROOT_DOMAIN_URI. 2017-08-28 14:09:28 -07:00
test_hotspots.py hotspots: Refactor backend for hotspots v2. 2017-07-28 16:34:13 -07:00
test_i18n.py invites: Migrate to non-legacy API format. 2017-07-31 13:08:06 -07:00
test_link_embed.py preview.py: Fix error raised on uploading file with unicode filename. 2017-06-19 14:58:44 -04:00
test_logging_handlers.py mypy: Pass empty dict to makeRecord for args, instead of None. 2017-08-09 18:04:21 -07:00
test_management_commands.py backend-tests: Add tests for get_users with all-users argument enabled. 2017-08-27 12:34:23 -07:00
test_messages.py Take user_ids in get_userids_for_missed_messages(). 2017-09-12 04:22:55 -07:00
test_middleware.py tests: Extract zerver/tests/test_middleware.py. 2017-03-08 03:57:37 -08:00
test_muting.py Add MutedTopic model. 2017-09-02 09:19:51 -07:00
test_narrow.py Add MutedTopic model. 2017-09-02 09:19:51 -07:00
test_new_users.py Update "MacOS" text to "macOS" 2017-08-26 09:00:42 -07:00
test_notifications.py Use user_ids, not full objects, in render path. 2017-09-12 04:22:55 -07:00
test_outgoing_webhook_interfaces.py outgoing webhooks: Remove process_failure interface method. 2017-07-24 14:10:14 -07:00
test_outgoing_webhook_system.py outgoing webhooks: Remove process_failure interface method. 2017-07-24 14:10:14 -07:00
test_presence.py Fix bug where we hard code realm for PushDeviceToken. 2017-09-08 12:32:17 -07:00
test_push_notifications.py APNs: Handle HTTP connection errors, and retry. 2017-08-29 15:27:41 -07:00
test_queue_worker.py tests: Replaced @zulip.com references with self.example_ functions. 2017-05-23 20:59:50 -07:00
test_reactions.py tests: Add and use new self.subscribe. 2017-08-24 21:37:57 -07:00
test_realm.py models: Create get_notifications_stream method in class Realm. 2017-08-23 17:50:34 -07:00
test_realm_domains.py do_create_realm: Remove unnecessary second return value. 2017-08-23 20:07:17 -07:00
test_realm_emoji.py tests: Remove unused ujson imports. 2017-08-17 09:05:52 -07:00
test_realm_filters.py tests: Remove unused ujson imports. 2017-08-17 09:05:52 -07:00
test_report.py tests: Replaced @zulip.com references with self.example_ functions. 2017-05-23 20:59:50 -07:00
test_retention.py messages: Add support for admins deleting messages. 2017-05-29 21:59:38 -07:00
test_service_bot_system.py tests: Add and use new self.subscribe. 2017-08-24 21:37:57 -07:00
test_sessions.py tests: Fix str/Text mypy issues in various tests. 2017-05-24 15:19:38 -07:00
test_settings.py result.json: Upgrade test_settings. 2017-08-17 09:03:35 -07:00
test_signup.py Optimize get_recipient_info() for sending messages. 2017-09-12 04:22:55 -07:00
test_soft_deactivation.py softdeactivation/management: Make specifying realm an optional arg. 2017-08-27 11:33:06 -07:00
test_subs.py Calculate idle users more efficiently when sending messages. 2017-09-07 06:59:44 -07:00
test_templates.py Deduplicate header markup for portico and portico-help templates. 2017-08-15 12:15:21 -07:00
test_timestamp.py Replace timezone.utc with timezone_utc. 2017-04-16 12:28:56 -07:00
test_tornado.py tornado: Add support for testing with subdomains. 2017-08-25 15:42:58 -07:00
test_tutorial.py api: Fix caps in JSON validation error message. 2017-06-27 08:33:56 -04:00
test_type_debug.py mypy: Remove type: ignores not needed in Python 3. 2017-08-25 11:04:20 -07:00
test_typing.py mypy: Amend tornado_redirected_to_list calls to use Mapping. 2017-08-05 12:08:59 -07:00
test_unread.py fix_unreads: Remove commit() call in fix(). 2017-09-07 07:06:03 -07:00
test_upload.py test_upload: Explicitly declare subdomains. 2017-08-26 13:45:27 -07:00
test_urls.py api: Allow incoming webhook bots to use the send_message API. 2017-08-22 10:06:34 -07:00
test_users.py result.json: Upgrade test_users. 2017-08-17 09:03:35 -07:00
test_zephyr.py test_zephyr: Explictly declare subdomain in requests. 2017-08-25 15:42:50 -07:00
tests.py retention-period: Add retention period to front-end admin organization settings. 2017-03-25 17:57:18 -07:00