Improve performance of notification sender tests

Creating all the StagedUsers accounts is expensive. This change makes it
possible to reuse these test accounts across test methods within the
same class, saving about 10% of test execution time.

This change also saves a little time by adding reviewers to staged
changes in a single batch operation, rather than one API call at a time.
Other slight gains were achieved by having watchers watch All-Projects,
instead of watching a new project for every test method.

Change-Id: I413c8f98338be30dcf926a724333feb401c9aa52
This commit is contained in:
Logan Hanks
2017-05-28 12:45:44 -07:00
parent 659bea9a9e
commit af6146c03b
5 changed files with 143 additions and 90 deletions

View File

@@ -60,6 +60,7 @@ import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.RecipientType;
import com.google.gerrit.extensions.api.changes.SubmitInput;
import com.google.gerrit.extensions.api.projects.ProjectConfigEntryType;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.registration.DynamicMap.Entry;
import com.google.gerrit.extensions.registration.DynamicSet;
@@ -1358,8 +1359,12 @@ public class ReceiveCommits {
this.draft = cmd.getRefName().startsWith(MagicBranch.NEW_DRAFT_CHANGE);
this.labelTypes = labelTypes;
this.notesMigration = notesMigration;
GeneralPreferencesInfo prefs = user.getAccount().getGeneralPreferencesInfo();
this.defaultPublishComments =
firstNonNull(user.getAccount().getGeneralPreferencesInfo().publishCommentsOnPush, false);
prefs != null
? firstNonNull(
user.getAccount().getGeneralPreferencesInfo().publishCommentsOnPush, false)
: false;
}
MailRecipients getMailRecipients() {