Allow to enable note DB for all integration tests

So far only a subset of the tests have a configuration where the
note DB is enabled.

Remove the configuration from these tests, and instead allow the note
DB configuration to be enabled for all tests by setting an environment
variable, GERRIT_ENABLE_NOTEDB:

 GERRIT_ENABLE_NOTEDB=TRUE buck test --no-results-cache

When the variable is set and has a value "TRUE", "YES" or "Y" (case
insensitive), the note DB is enabled for all integration tests.

Note that when switching between enabled and disabled note DB, the
--no-results-cache option must be specified, otherwise buck will not
actually run the tests again with the different setting.

Enabling the note DB exposes a number of failures in tests that were
not previously being run with note DB:

FAIL com.google.gerrit.acceptance.api.change.ChangeIT
FAIL com.google.gerrit.acceptance.api.change.CheckIT
FAIL com.google.gerrit.acceptance.api.revision.RevisionIT
FAIL com.google.gerrit.acceptance.git.SubmitOnPushIT
FAIL com.google.gerrit.acceptance.rest.change.SubmitByCherryPickIT
FAIL com.google.gerrit.acceptance.rest.change.SubmitByFastForwardIT
FAIL com.google.gerrit.acceptance.rest.change.SubmitByMergeAlwaysIT
FAIL com.google.gerrit.acceptance.rest.change.SubmitByMergeIfNecessaryIT
FAIL com.google.gerrit.acceptance.rest.change.SubmitByRebaseIfNecessaryIT
FAIL com.google.gerrit.acceptance.server.project.CustomLabelIT

This commit does not fix any of these failures; they will be addressed
separately in followup commits.

Change-Id: I09f513c352ba6b37b415ad804ad0a7c0a5cc3c6d
This commit is contained in:
David Pursehouse
2015-10-22 17:40:34 +09:00
parent 7722378708
commit 39db6c73e6
8 changed files with 20 additions and 49 deletions

View File

@@ -233,12 +233,22 @@ public abstract class AbstractDaemonTest {
return cfg.getBoolean("change", null, "submitWholeTopic", false);
}
private static boolean isNoteDbTestEnabled() {
final String[] RUN_FLAGS = {"yes", "y", "true"};
String value = System.getenv("GERRIT_ENABLE_NOTEDB");
return value != null &&
Arrays.asList(RUN_FLAGS).contains(value.toLowerCase());
}
protected void beforeTest(Description description) throws Exception {
GerritServer.Description classDesc =
GerritServer.Description.forTestClass(description, configName);
GerritServer.Description methodDesc =
GerritServer.Description.forTestMethod(description, configName);
if (isNoteDbTestEnabled()) {
NotesMigration.setAllEnabledConfig(baseConfig);
}
baseConfig.setString("gerrit", null, "tempSiteDir",
tempSiteDir.getRoot().getPath());
if (classDesc.equals(methodDesc)) {

View File

@@ -31,10 +31,7 @@ import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.LabelInfo;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.notedb.NotesMigration;
import com.google.gerrit.testutil.ConfigSuite;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.revwalk.RevCommit;
import org.joda.time.DateTime;
import org.joda.time.DateTimeUtils;
@@ -48,11 +45,6 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
public abstract class AbstractPushForReview extends AbstractDaemonTest {
@ConfigSuite.Config
public static Config noteDbEnabled() {
return NotesMigration.allEnabledConfig();
}
protected enum Protocol {
// TODO(dborowitz): TEST.
SSH, HTTP

View File

@@ -35,30 +35,19 @@ import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.edit.ChangeEditModifier;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.project.Util;
import com.google.gerrit.testutil.ConfigSuite;
import com.google.inject.Inject;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.List;
@RunWith(ConfigSuite.class)
@NoHttpd
public class VisibleRefFilterIT extends AbstractDaemonTest {
@ConfigSuite.Config
public static Config noteDbWriteEnabled() {
Config cfg = new Config();
cfg.setBoolean("notedb", "changes", "write", true);
return cfg;
}
@Inject
private ChangeEditModifier editModifier;

View File

@@ -22,10 +22,8 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.extensions.api.changes.ReviewInput;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.ChangeMessageInfo;
import com.google.gerrit.server.notedb.NotesMigration;
import com.google.gerrit.testutil.ConfigSuite;
import org.eclipse.jgit.lib.Config;
import org.joda.time.DateTime;
import org.joda.time.DateTimeUtils;
import org.joda.time.DateTimeUtils.MillisProvider;
@@ -42,11 +40,6 @@ public class ChangeMessagesIT extends AbstractDaemonTest {
private String systemTimeZone;
private volatile long clockStepMs;
@ConfigSuite.Config
public static Config noteDbEnabled() {
return NotesMigration.allEnabledConfig();
}
@Before
public void setTimeForTesting() {
systemTimeZone = System.setProperty("user.timezone", "US/Eastern");

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
import com.google.common.collect.Sets;
import com.google.common.truth.IterableSubject;
@@ -22,17 +23,15 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.extensions.api.changes.HashtagsInput;
import com.google.gerrit.server.notedb.NotesMigration;
import com.google.gerrit.testutil.ConfigSuite;
import org.eclipse.jgit.lib.Config;
import org.junit.Before;
import org.junit.Test;
@NoHttpd
public class HashtagsIT extends AbstractDaemonTest {
@ConfigSuite.Default
public static Config defaultConfig() {
return NotesMigration.allEnabledConfig();
@Before
public void before() {
assume().that(notesMigration.enabled()).isTrue();
}
@Test

View File

@@ -39,14 +39,11 @@ import com.google.gerrit.server.change.ChangesCollection;
import com.google.gerrit.server.change.PostReview;
import com.google.gerrit.server.change.RevisionResource;
import com.google.gerrit.server.change.Revisions;
import com.google.gerrit.server.notedb.NotesMigration;
import com.google.gerrit.testutil.ConfigSuite;
import com.google.gerrit.testutil.FakeEmailSender;
import com.google.gerrit.testutil.FakeEmailSender.Message;
import com.google.inject.Inject;
import com.google.inject.Provider;
import org.eclipse.jgit.lib.Config;
import org.junit.Before;
import org.junit.Test;
@@ -57,11 +54,6 @@ import java.util.Map;
@NoHttpd
public class CommentsIT extends AbstractDaemonTest {
@ConfigSuite.Config
public static Config noteDbEnabled() {
return NotesMigration.allEnabledConfig();
}
@Inject
private Provider<ChangesCollection> changes;

View File

@@ -26,22 +26,14 @@ import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.LabelInfo;
import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.notedb.NotesMigration;
import com.google.gerrit.server.project.Util;
import com.google.gerrit.testutil.ConfigSuite;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.Repository;
import org.junit.Before;
import org.junit.Test;
@NoHttpd
public class LabelTypeIT extends AbstractDaemonTest {
@ConfigSuite.Config
public static Config noteDbEnabled() {
return NotesMigration.allEnabledConfig();
}
private LabelType codeReview;
@Before

View File

@@ -84,11 +84,15 @@ public class NotesMigration {
public static Config allEnabledConfig() {
Config cfg = new Config();
setAllEnabledConfig(cfg);
return cfg;
}
public static void setAllEnabledConfig(Config cfg) {
for (Table t : Table.values()) {
cfg.setBoolean(NOTEDB, t.key(), WRITE, true);
cfg.setBoolean(NOTEDB, t.key(), READ, true);
}
return cfg;
}
private final boolean writeChanges;