Convert most NotesMigration#enabled() calls to #readChanges()

Most of the time this is used to avoid codepaths that shouldn't be
enabled unless *both* NoteDb reads and writes are enabled.

Change-Id: I75958e79e20199f3b19a539bf22b7c3b49a066ee
This commit is contained in:
Dave Borowitz
2016-05-17 15:56:08 -04:00
parent 251443314d
commit a0a85fe7ed
6 changed files with 9 additions and 9 deletions

View File

@@ -1090,7 +1090,7 @@ public class ChangeIT extends AbstractDaemonTest {
@Test @Test
public void noteDbCommitsOnPatchSetCreation() throws Exception { public void noteDbCommitsOnPatchSetCreation() throws Exception {
assume().that(notesMigration.enabled()).isTrue(); assume().that(notesMigration.readChanges()).isTrue();
PushOneCommit.Result r = createChange(); PushOneCommit.Result r = createChange();
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,

View File

@@ -456,8 +456,8 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
@Test @Test
public void testPushForMasterWithHashtagsNoteDbDisabled() throws Exception { public void testPushForMasterWithHashtagsNoteDbDisabled() throws Exception {
// push with hashtags should fail when noteDb is disabled // Push with hashtags should fail when reading from NoteDb is disabled.
assume().that(notesMigration.enabled()).isFalse(); assume().that(notesMigration.readChanges()).isFalse();
PushOneCommit.Result r = pushTo("refs/for/master%hashtag=tag1"); PushOneCommit.Result r = pushTo("refs/for/master%hashtag=tag1");
r.assertErrorStatus("cannot add hashtags; noteDb is disabled"); r.assertErrorStatus("cannot add hashtags; noteDb is disabled");
} }

View File

@@ -116,7 +116,7 @@ public class CreateChangeIT extends AbstractDaemonTest {
@Test @Test
public void noteDbCommit() throws Exception { public void noteDbCommit() throws Exception {
assume().that(notesMigration.enabled()).isTrue(); assume().that(notesMigration.readChanges()).isTrue();
ChangeInfo c = assertCreateSucceeds(newChangeInput(ChangeStatus.NEW)); ChangeInfo c = assertCreateSucceeds(newChangeInput(ChangeStatus.NEW));
try (Repository repo = repoManager.openRepository(project); try (Repository repo = repoManager.openRepository(project);

View File

@@ -114,7 +114,7 @@ public class HostPageServlet extends HttpServlet {
site = sp; site = sp;
refreshHeaderFooter = cfg.getBoolean("site", "refreshHeaderFooter", true); refreshHeaderFooter = cfg.getBoolean("site", "refreshHeaderFooter", true);
staticServlet = ss; staticServlet = ss;
isNoteDbEnabled = migration.enabled(); isNoteDbEnabled = migration.readChanges();
pluginsLoadTimeout = getPluginsLoadTimeout(cfg); pluginsLoadTimeout = getPluginsLoadTimeout(cfg);
getDiff = diffPref; getDiff = diffPref;

View File

@@ -1208,7 +1208,7 @@ public class ReceiveCommits {
@Option(name = "--hashtag", aliases = {"-t"}, metaVar = "HASHTAG", @Option(name = "--hashtag", aliases = {"-t"}, metaVar = "HASHTAG",
usage = "add hashtag to changes") usage = "add hashtag to changes")
void addHashtag(String token) throws CmdLineException { void addHashtag(String token) throws CmdLineException {
if (!notesMigration.enabled()) { if (!notesMigration.readChanges()) {
throw clp.reject("cannot add hashtags; noteDb is disabled"); throw clp.reject("cannot add hashtags; noteDb is disabled");
} }
String hashtag = cleanupHashtag(token); String hashtag = cleanupHashtag(token);

View File

@@ -1087,7 +1087,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
@Test @Test
public void byHashtagWithoutNoteDb() throws Exception { public void byHashtagWithoutNoteDb() throws Exception {
assume().that(notesMigration.enabled()).isFalse(); assume().that(notesMigration.readChanges()).isFalse();
setUpHashtagChanges(); setUpHashtagChanges();
assertQuery("hashtag:foo"); assertQuery("hashtag:foo");
assertQuery("hashtag:bar"); assertQuery("hashtag:bar");
@@ -1415,7 +1415,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
@Test @Test
public void prepopulatedFields() throws Exception { public void prepopulatedFields() throws Exception {
assume().that(notesMigration.enabled()).isFalse(); assume().that(notesMigration.readChanges()).isFalse();
TestRepository<Repo> repo = createProject("repo"); TestRepository<Repo> repo = createProject("repo");
Change change = insert(repo, newChange(repo)); Change change = insert(repo, newChange(repo));
@@ -1444,7 +1444,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
@Test @Test
public void prepopulateOnlyRequestedFields() throws Exception { public void prepopulateOnlyRequestedFields() throws Exception {
assume().that(notesMigration.enabled()).isFalse(); assume().that(notesMigration.readChanges()).isFalse();
TestRepository<Repo> repo = createProject("repo"); TestRepository<Repo> repo = createProject("repo");
Change change = insert(repo, newChange(repo)); Change change = insert(repo, newChange(repo));