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:
@@ -233,12 +233,22 @@ public abstract class AbstractDaemonTest {
|
|||||||
return cfg.getBoolean("change", null, "submitWholeTopic", false);
|
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 {
|
protected void beforeTest(Description description) throws Exception {
|
||||||
GerritServer.Description classDesc =
|
GerritServer.Description classDesc =
|
||||||
GerritServer.Description.forTestClass(description, configName);
|
GerritServer.Description.forTestClass(description, configName);
|
||||||
GerritServer.Description methodDesc =
|
GerritServer.Description methodDesc =
|
||||||
GerritServer.Description.forTestMethod(description, configName);
|
GerritServer.Description.forTestMethod(description, configName);
|
||||||
|
|
||||||
|
if (isNoteDbTestEnabled()) {
|
||||||
|
NotesMigration.setAllEnabledConfig(baseConfig);
|
||||||
|
}
|
||||||
baseConfig.setString("gerrit", null, "tempSiteDir",
|
baseConfig.setString("gerrit", null, "tempSiteDir",
|
||||||
tempSiteDir.getRoot().getPath());
|
tempSiteDir.getRoot().getPath());
|
||||||
if (classDesc.equals(methodDesc)) {
|
if (classDesc.equals(methodDesc)) {
|
||||||
|
@@ -31,10 +31,7 @@ import com.google.gerrit.extensions.common.ChangeInfo;
|
|||||||
import com.google.gerrit.extensions.common.EditInfo;
|
import com.google.gerrit.extensions.common.EditInfo;
|
||||||
import com.google.gerrit.extensions.common.LabelInfo;
|
import com.google.gerrit.extensions.common.LabelInfo;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
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.eclipse.jgit.revwalk.RevCommit;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.DateTimeUtils;
|
import org.joda.time.DateTimeUtils;
|
||||||
@@ -48,11 +45,6 @@ import java.util.Set;
|
|||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
||||||
@ConfigSuite.Config
|
|
||||||
public static Config noteDbEnabled() {
|
|
||||||
return NotesMigration.allEnabledConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected enum Protocol {
|
protected enum Protocol {
|
||||||
// TODO(dborowitz): TEST.
|
// TODO(dborowitz): TEST.
|
||||||
SSH, HTTP
|
SSH, HTTP
|
||||||
|
@@ -35,30 +35,19 @@ import com.google.gerrit.reviewdb.client.RefNames;
|
|||||||
import com.google.gerrit.server.edit.ChangeEditModifier;
|
import com.google.gerrit.server.edit.ChangeEditModifier;
|
||||||
import com.google.gerrit.server.git.ProjectConfig;
|
import com.google.gerrit.server.git.ProjectConfig;
|
||||||
import com.google.gerrit.server.project.Util;
|
import com.google.gerrit.server.project.Util;
|
||||||
import com.google.gerrit.testutil.ConfigSuite;
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Config;
|
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
import org.eclipse.jgit.lib.RefUpdate;
|
import org.eclipse.jgit.lib.RefUpdate;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(ConfigSuite.class)
|
|
||||||
@NoHttpd
|
@NoHttpd
|
||||||
public class VisibleRefFilterIT extends AbstractDaemonTest {
|
public class VisibleRefFilterIT extends AbstractDaemonTest {
|
||||||
@ConfigSuite.Config
|
|
||||||
public static Config noteDbWriteEnabled() {
|
|
||||||
Config cfg = new Config();
|
|
||||||
cfg.setBoolean("notedb", "changes", "write", true);
|
|
||||||
return cfg;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ChangeEditModifier editModifier;
|
private ChangeEditModifier editModifier;
|
||||||
|
|
||||||
|
@@ -22,10 +22,8 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
|||||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||||
import com.google.gerrit.extensions.common.ChangeMessageInfo;
|
import com.google.gerrit.extensions.common.ChangeMessageInfo;
|
||||||
import com.google.gerrit.server.notedb.NotesMigration;
|
|
||||||
import com.google.gerrit.testutil.ConfigSuite;
|
import com.google.gerrit.testutil.ConfigSuite;
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Config;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.DateTimeUtils;
|
import org.joda.time.DateTimeUtils;
|
||||||
import org.joda.time.DateTimeUtils.MillisProvider;
|
import org.joda.time.DateTimeUtils.MillisProvider;
|
||||||
@@ -42,11 +40,6 @@ public class ChangeMessagesIT extends AbstractDaemonTest {
|
|||||||
private String systemTimeZone;
|
private String systemTimeZone;
|
||||||
private volatile long clockStepMs;
|
private volatile long clockStepMs;
|
||||||
|
|
||||||
@ConfigSuite.Config
|
|
||||||
public static Config noteDbEnabled() {
|
|
||||||
return NotesMigration.allEnabledConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setTimeForTesting() {
|
public void setTimeForTesting() {
|
||||||
systemTimeZone = System.setProperty("user.timezone", "US/Eastern");
|
systemTimeZone = System.setProperty("user.timezone", "US/Eastern");
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.acceptance.rest.change;
|
package com.google.gerrit.acceptance.rest.change;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
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.collect.Sets;
|
||||||
import com.google.common.truth.IterableSubject;
|
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.NoHttpd;
|
||||||
import com.google.gerrit.acceptance.PushOneCommit;
|
import com.google.gerrit.acceptance.PushOneCommit;
|
||||||
import com.google.gerrit.extensions.api.changes.HashtagsInput;
|
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;
|
import org.junit.Test;
|
||||||
|
|
||||||
@NoHttpd
|
@NoHttpd
|
||||||
public class HashtagsIT extends AbstractDaemonTest {
|
public class HashtagsIT extends AbstractDaemonTest {
|
||||||
@ConfigSuite.Default
|
@Before
|
||||||
public static Config defaultConfig() {
|
public void before() {
|
||||||
return NotesMigration.allEnabledConfig();
|
assume().that(notesMigration.enabled()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -39,14 +39,11 @@ import com.google.gerrit.server.change.ChangesCollection;
|
|||||||
import com.google.gerrit.server.change.PostReview;
|
import com.google.gerrit.server.change.PostReview;
|
||||||
import com.google.gerrit.server.change.RevisionResource;
|
import com.google.gerrit.server.change.RevisionResource;
|
||||||
import com.google.gerrit.server.change.Revisions;
|
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;
|
||||||
import com.google.gerrit.testutil.FakeEmailSender.Message;
|
import com.google.gerrit.testutil.FakeEmailSender.Message;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Config;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -57,11 +54,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
@NoHttpd
|
@NoHttpd
|
||||||
public class CommentsIT extends AbstractDaemonTest {
|
public class CommentsIT extends AbstractDaemonTest {
|
||||||
@ConfigSuite.Config
|
|
||||||
public static Config noteDbEnabled() {
|
|
||||||
return NotesMigration.allEnabledConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Provider<ChangesCollection> changes;
|
private Provider<ChangesCollection> changes;
|
||||||
|
|
||||||
|
@@ -26,22 +26,14 @@ import com.google.gerrit.extensions.common.ChangeInfo;
|
|||||||
import com.google.gerrit.extensions.common.LabelInfo;
|
import com.google.gerrit.extensions.common.LabelInfo;
|
||||||
import com.google.gerrit.server.git.MetaDataUpdate;
|
import com.google.gerrit.server.git.MetaDataUpdate;
|
||||||
import com.google.gerrit.server.git.ProjectConfig;
|
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.server.project.Util;
|
||||||
import com.google.gerrit.testutil.ConfigSuite;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Config;
|
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@NoHttpd
|
@NoHttpd
|
||||||
public class LabelTypeIT extends AbstractDaemonTest {
|
public class LabelTypeIT extends AbstractDaemonTest {
|
||||||
@ConfigSuite.Config
|
|
||||||
public static Config noteDbEnabled() {
|
|
||||||
return NotesMigration.allEnabledConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
private LabelType codeReview;
|
private LabelType codeReview;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@@ -84,11 +84,15 @@ public class NotesMigration {
|
|||||||
|
|
||||||
public static Config allEnabledConfig() {
|
public static Config allEnabledConfig() {
|
||||||
Config cfg = new Config();
|
Config cfg = new Config();
|
||||||
|
setAllEnabledConfig(cfg);
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setAllEnabledConfig(Config cfg) {
|
||||||
for (Table t : Table.values()) {
|
for (Table t : Table.values()) {
|
||||||
cfg.setBoolean(NOTEDB, t.key(), WRITE, true);
|
cfg.setBoolean(NOTEDB, t.key(), WRITE, true);
|
||||||
cfg.setBoolean(NOTEDB, t.key(), READ, true);
|
cfg.setBoolean(NOTEDB, t.key(), READ, true);
|
||||||
}
|
}
|
||||||
return cfg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final boolean writeChanges;
|
private final boolean writeChanges;
|
||||||
|
Reference in New Issue
Block a user