Merge "Merge branch 'stable-2.15'"

This commit is contained in:
David Pursehouse 2018-08-20 06:08:18 +00:00 committed by Gerrit Code Review
commit 3aa1e6cc0b
24 changed files with 277 additions and 92 deletions

View File

@ -144,9 +144,12 @@ objects which are too large to Gerrit. This setting can also be set in
`gerrit.config` globally (link:config-gerrit.html#receive.maxObjectSizeLimit[
receive.maxObjectSizeLimit]).
+
The project specific setting in `project.config` is only honored when it
further reduces the global limit. The setting is not inherited from the
parent project; it must be explicitly set per project.
The project specific setting in `project.config` may not set a value higher
than the global limit (if configured). In other words, it is only honored when
it further reduces the global limit.
+
The setting is not inherited from the parent project; it must be explicitly
set per project.
+
Default is zero.
+

View File

@ -3278,7 +3278,8 @@ formatted string. +
Not set if there is no limit for the object size configured on project
level.
|`inherited_value` |optional|
The max object size limit that is inherited as a formatted string. +
The max object size limit that is inherited from the global config as a
formatted string. +
Not set if there is no global limit for the object size.
|===============================

View File

@ -861,8 +861,8 @@ maven_jar(
maven_jar(
name = "postgresql",
artifact = "org.postgresql:postgresql:9.4.1211",
sha1 = "721e3017fab68db9f0b08537ec91b8d757973ca8",
artifact = "org.postgresql:postgresql:42.2.4",
sha1 = "dff98730c28a4b3a3263f0cf4abb9a3392f815a7",
)
maven_jar(

View File

@ -512,6 +512,9 @@ public class ProjectInfoScreen extends ProjectScreen {
textBox.setValue(param.value());
addWidget(g, textBox, param);
}
if (textBox.getValue().length() > textBox.getVisibleLength()) {
textBox.setVisibleLength(textBox.getValue().length());
}
saveEnabler.listenTo(textBox);
return textBox;
}

View File

@ -137,6 +137,10 @@ public class EventRecorder {
return events;
}
public void assertNoRefUpdatedEvents(String project, String branch) throws Exception {
getRefUpdatedEvents(project, branch, 0);
}
public void assertRefUpdatedEvents(String project, String branch, String... expected)
throws Exception {
ImmutableList<RefUpdatedEvent> events =

View File

@ -14,6 +14,7 @@
package com.google.gerrit.extensions.api.projects;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.client.InheritableBoolean;
import com.google.gerrit.extensions.client.ProjectState;
import com.google.gerrit.extensions.client.SubmitType;
@ -58,9 +59,14 @@ public class ConfigInfo {
}
public static class MaxObjectSizeLimitInfo {
public String value;
public String configuredValue;
public String inheritedValue;
/* The effective value. Null if not set. */
@Nullable public String value;
/* The value configured on the project. Null if not set. */
@Nullable public String configuredValue;
/* The value configured globally. Null if not set. */
@Nullable public String inheritedValue;
}
public static class ConfigParameterInfo {

View File

@ -15,7 +15,7 @@
package com.google.gerrit.extensions.events;
public interface PrivateStateChangedListener {
interface Event extends ChangeEvent {}
interface Event extends RevisionEvent {}
void onPrivateStateChanged(Event event);
}

View File

@ -15,7 +15,7 @@
package com.google.gerrit.extensions.events;
public interface WorkInProgressStateChangedListener {
interface Event extends ChangeEvent {}
interface Event extends RevisionEvent {}
void onWorkInProgressStateChanged(Event event);
}

View File

@ -64,6 +64,8 @@ import org.eclipse.jgit.lib.Config;
import org.kohsuke.args4j.Option;
public abstract class SiteProgram extends AbstractProgram {
private static final String CONNECTION_ERROR = "Cannot connect to SQL database";
@Option(
name = "--site-path",
aliases = {"-d"},
@ -106,14 +108,13 @@ public abstract class SiteProgram extends AbstractProgram {
/** @return provides database connectivity and site path. */
protected Injector createDbInjector(boolean enableMetrics, DataSourceProvider.Context context) {
Path sitePath = getSitePath();
List<Module> modules = new ArrayList<>();
Module sitePathModule =
new AbstractModule() {
@Override
protected void configure() {
bind(Path.class).annotatedWith(SitePath.class).toInstance(sitePath);
bind(Path.class).annotatedWith(SitePath.class).toInstance(getSitePath());
bind(String.class)
.annotatedWith(SecureStoreClassName.class)
.toProvider(Providers.of(getConfiguredSecureStoreClass()));
@ -198,16 +199,16 @@ public abstract class SiteProgram extends AbstractProgram {
Throwable why = first.getCause();
if (why instanceof SQLException) {
throw die("Cannot connect to SQL database", why);
throw die(CONNECTION_ERROR, why);
}
if (why instanceof OrmException
&& why.getCause() != null
&& "Unable to determine driver URL".equals(why.getMessage())) {
why = why.getCause();
if (isCannotCreatePoolException(why)) {
throw die("Cannot connect to SQL database", why.getCause());
throw die(CONNECTION_ERROR, why.getCause());
}
throw die("Cannot connect to SQL database", why);
throw die(CONNECTION_ERROR, why);
}
StringBuilder buf = new StringBuilder();
@ -259,8 +260,9 @@ public abstract class SiteProgram extends AbstractProgram {
for (Binding<DataSourceType> binding : dsTypeBindings) {
Annotation annotation = binding.getKey().getAnnotation();
if (annotation instanceof Named) {
if (((Named) annotation).value().toLowerCase().contains(dbProductName)) {
return ((Named) annotation).value();
Named named = (Named) annotation;
if (named.value().toLowerCase().contains(dbProductName)) {
return named.value();
}
}
}

View File

@ -125,7 +125,7 @@ public class WorkInProgressOp implements BatchUpdateOp {
@Override
public void postUpdate(Context ctx) {
stateChanged.fire(change, ctx.getAccount(), ctx.getWhen());
stateChanged.fire(change, ps, ctx.getAccount(), ctx.getWhen());
if (workInProgress || notify.ordinal() < NotifyHandling.OWNER_REVIEWERS.ordinal()) {
return;
}

View File

@ -18,7 +18,7 @@ import com.google.common.base.Supplier;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.data.AccountAttribute;
public class PrivateStateChangedEvent extends ChangeEvent {
public class PrivateStateChangedEvent extends PatchSetEvent {
static final String TYPE = "private-state-changed";
public Supplier<AccountAttribute> changer;

View File

@ -472,10 +472,12 @@ public class StreamEventsApiListener
try {
ChangeNotes notes = getNotes(ev.getChange());
Change change = notes.getChange();
PatchSet patchSet = getPatchSet(notes, ev.getRevision());
WorkInProgressStateChangedEvent event = new WorkInProgressStateChangedEvent(change);
event.change = changeAttributeSupplier(change, notes);
event.changer = accountAttributeSupplier(ev.getWho());
event.patchSet = patchSetAttributeSupplier(change, patchSet);
dispatcher.get().postEvent(change, event);
} catch (OrmException | PermissionBackendException e) {
@ -488,10 +490,12 @@ public class StreamEventsApiListener
try {
ChangeNotes notes = getNotes(ev.getChange());
Change change = notes.getChange();
PatchSet patchSet = getPatchSet(notes, ev.getRevision());
PrivateStateChangedEvent event = new PrivateStateChangedEvent(change);
event.change = changeAttributeSupplier(change, notes);
event.changer = accountAttributeSupplier(ev.getWho());
event.patchSet = patchSetAttributeSupplier(change, patchSet);
dispatcher.get().postEvent(change, event);
} catch (OrmException | PermissionBackendException e) {

View File

@ -18,7 +18,7 @@ import com.google.common.base.Supplier;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.data.AccountAttribute;
public class WorkInProgressStateChangedEvent extends ChangeEvent {
public class WorkInProgressStateChangedEvent extends PatchSetEvent {
static final String TYPE = "wip-state-changed";
public Supplier<AccountAttribute> changer;

View File

@ -18,13 +18,19 @@ import com.google.common.flogger.FluentLogger;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.RevisionInfo;
import com.google.gerrit.extensions.events.PrivateStateChangedListener;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.GpgException;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.IOException;
import java.sql.Timestamp;
@Singleton
@ -40,12 +46,17 @@ public class PrivateStateChanged {
this.util = util;
}
public void fire(Change change, AccountState account, Timestamp when) {
public void fire(Change change, PatchSet patchSet, AccountState account, Timestamp when) {
if (!listeners.iterator().hasNext()) {
return;
}
try {
Event event = new Event(util.changeInfo(change), util.accountInfo(account), when);
Event event =
new Event(
util.changeInfo(change),
util.revisionInfo(change.getProject(), patchSet),
util.accountInfo(account),
when);
for (PrivateStateChangedListener l : listeners) {
try {
l.onPrivateStateChanged(event);
@ -53,16 +64,20 @@ public class PrivateStateChanged {
util.logEventListenerError(event, l, e);
}
}
} catch (OrmException e) {
} catch (OrmException
| PatchListNotAvailableException
| GpgException
| IOException
| PermissionBackendException e) {
logger.atSevere().withCause(e).log("Couldn't fire event");
}
}
private static class Event extends AbstractChangeEvent
private static class Event extends AbstractRevisionEvent
implements PrivateStateChangedListener.Event {
protected Event(ChangeInfo change, AccountInfo who, Timestamp when) {
super(change, who, when, NotifyHandling.ALL);
protected Event(ChangeInfo change, RevisionInfo revision, AccountInfo who, Timestamp when) {
super(change, revision, who, when, NotifyHandling.ALL);
}
}
}

View File

@ -18,13 +18,19 @@ import com.google.common.flogger.FluentLogger;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.RevisionInfo;
import com.google.gerrit.extensions.events.WorkInProgressStateChangedListener;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.GpgException;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.patch.PatchListNotAvailableException;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.IOException;
import java.sql.Timestamp;
@Singleton
@ -41,12 +47,17 @@ public class WorkInProgressStateChanged {
this.util = util;
}
public void fire(Change change, AccountState account, Timestamp when) {
public void fire(Change change, PatchSet patchSet, AccountState account, Timestamp when) {
if (!listeners.iterator().hasNext()) {
return;
}
try {
Event event = new Event(util.changeInfo(change), util.accountInfo(account), when);
Event event =
new Event(
util.changeInfo(change),
util.revisionInfo(change.getProject(), patchSet),
util.accountInfo(account),
when);
for (WorkInProgressStateChangedListener l : listeners) {
try {
l.onWorkInProgressStateChanged(event);
@ -54,16 +65,20 @@ public class WorkInProgressStateChanged {
util.logEventListenerError(event, l, e);
}
}
} catch (OrmException e) {
} catch (OrmException
| PatchListNotAvailableException
| GpgException
| IOException
| PermissionBackendException e) {
logger.atSevere().withCause(e).log("Couldn't fire event");
}
}
private static class Event extends AbstractChangeEvent
private static class Event extends AbstractRevisionEvent
implements WorkInProgressStateChangedListener.Event {
protected Event(ChangeInfo change, AccountInfo who, Timestamp when) {
super(change, who, when, NotifyHandling.ALL);
protected Event(ChangeInfo change, RevisionInfo revision, AccountInfo who, Timestamp when) {
super(change, revision, who, when, NotifyHandling.ALL);
}
}
}

View File

@ -107,14 +107,14 @@ public class ProjectState {
@Inject
public ProjectState(
final SitePaths sitePaths,
final ProjectCache projectCache,
final AllProjectsName allProjectsName,
final AllUsersName allUsersName,
final GitRepositoryManager gitMgr,
final List<CommentLinkInfo> commentLinks,
final CapabilityCollection.Factory limitsFactory,
@Assisted final ProjectConfig config) {
SitePaths sitePaths,
ProjectCache projectCache,
AllProjectsName allProjectsName,
AllUsersName allUsersName,
GitRepositoryManager gitMgr,
List<CommentLinkInfo> commentLinks,
CapabilityCollection.Factory limitsFactory,
@Assisted ProjectConfig config) {
this.sitePaths = sitePaths;
this.projectCache = projectCache;
this.isAllProjects = config.getProject().getNameKey().equals(allProjectsName);

View File

@ -18,8 +18,11 @@ import com.google.common.base.Strings;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.ChangeMessage;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.ChangeMessagesUtil;
import com.google.gerrit.server.PatchSetUtil;
import com.google.gerrit.server.extensions.events.PrivateStateChanged;
import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.notedb.ChangeUpdate;
import com.google.gerrit.server.update.BatchUpdateOp;
import com.google.gerrit.server.update.ChangeContext;
@ -44,19 +47,23 @@ public class SetPrivateOp implements BatchUpdateOp {
}
private final ChangeMessagesUtil cmUtil;
private final PatchSetUtil psUtil;
private final boolean isPrivate;
private final Input input;
private final PrivateStateChanged privateStateChanged;
private Change change;
private PatchSet ps;
@Inject
SetPrivateOp(
PrivateStateChanged privateStateChanged,
PatchSetUtil psUtil,
@Assisted ChangeMessagesUtil cmUtil,
@Assisted boolean isPrivate,
@Assisted Input input) {
this.cmUtil = cmUtil;
this.psUtil = psUtil;
this.isPrivate = isPrivate;
this.input = input;
this.privateStateChanged = privateStateChanged;
@ -65,6 +72,8 @@ public class SetPrivateOp implements BatchUpdateOp {
@Override
public boolean updateChange(ChangeContext ctx) throws ResourceConflictException, OrmException {
change = ctx.getChange();
ChangeNotes notes = ctx.getNotes();
ps = psUtil.get(ctx.getDb(), notes, change.currentPatchSetId());
ChangeUpdate update = ctx.getUpdate(change.currentPatchSetId());
change.setPrivate(isPrivate);
change.setLastUpdatedOn(ctx.getWhen());
@ -75,7 +84,7 @@ public class SetPrivateOp implements BatchUpdateOp {
@Override
public void postUpdate(Context ctx) {
privateStateChanged.fire(change, ctx.getAccount(), ctx.getWhen());
privateStateChanged.fire(change, ps, ctx.getAccount(), ctx.getWhen());
}
private void addMessage(ChangeContext ctx, ChangeUpdate update) throws OrmException {

View File

@ -48,7 +48,7 @@ public class ConfigInfoImpl extends ConfigInfo {
boolean serverEnableSignedPush,
ProjectState projectState,
CurrentUser user,
TransferConfig config,
TransferConfig transferConfig,
DynamicMap<ProjectConfigEntry> pluginConfigEntries,
PluginConfigFactory cfgFactory,
AllProjectsName allProjects,
@ -72,14 +72,7 @@ public class ConfigInfoImpl extends ConfigInfo {
this.requireSignedPush = null;
}
MaxObjectSizeLimitInfo maxObjectSizeLimit = new MaxObjectSizeLimitInfo();
maxObjectSizeLimit.value =
config.getEffectiveMaxObjectSizeLimit(projectState) == config.getMaxObjectSizeLimit()
? config.getFormattedMaxObjectSizeLimit()
: p.getMaxObjectSizeLimit();
maxObjectSizeLimit.configuredValue = p.getMaxObjectSizeLimit();
maxObjectSizeLimit.inheritedValue = config.getFormattedMaxObjectSizeLimit();
this.maxObjectSizeLimit = maxObjectSizeLimit;
this.maxObjectSizeLimit = getMaxObjectSizeLimit(projectState, transferConfig, p);
this.defaultSubmitType = new SubmitTypeInfo();
this.defaultSubmitType.value = projectState.getSubmitType();
@ -114,6 +107,19 @@ public class ConfigInfoImpl extends ConfigInfo {
this.extensionPanelNames = projectState.getConfig().getExtensionPanelSections();
}
private MaxObjectSizeLimitInfo getMaxObjectSizeLimit(
ProjectState projectState, TransferConfig transferConfig, Project p) {
MaxObjectSizeLimitInfo info = new MaxObjectSizeLimitInfo();
info.value =
transferConfig.getEffectiveMaxObjectSizeLimit(projectState)
== transferConfig.getMaxObjectSizeLimit()
? transferConfig.getFormattedMaxObjectSizeLimit()
: p.getMaxObjectSizeLimit();
info.configuredValue = p.getMaxObjectSizeLimit();
info.inheritedValue = transferConfig.getFormattedMaxObjectSizeLimit();
return info;
}
private Map<String, Map<String, ConfigParameterInfo>> getPluginConfig(
ProjectState project,
DynamicMap<ProjectConfigEntry> pluginConfigEntries,

View File

@ -31,7 +31,7 @@ import com.google.inject.Singleton;
@Singleton
public class GetConfig implements RestReadView<ProjectResource> {
private final boolean serverEnableSignedPush;
private final TransferConfig config;
private final TransferConfig transferConfig;
private final DynamicMap<ProjectConfigEntry> pluginConfigEntries;
private final PluginConfigFactory cfgFactory;
private final AllProjectsName allProjects;
@ -41,14 +41,14 @@ public class GetConfig implements RestReadView<ProjectResource> {
@Inject
public GetConfig(
@EnableSignedPush boolean serverEnableSignedPush,
TransferConfig config,
TransferConfig transferConfig,
DynamicMap<ProjectConfigEntry> pluginConfigEntries,
PluginConfigFactory cfgFactory,
AllProjectsName allProjects,
UiActions uiActions,
DynamicMap<RestView<ProjectResource>> views) {
this.serverEnableSignedPush = serverEnableSignedPush;
this.config = config;
this.transferConfig = transferConfig;
this.pluginConfigEntries = pluginConfigEntries;
this.allProjects = allProjects;
this.cfgFactory = cfgFactory;
@ -62,7 +62,7 @@ public class GetConfig implements RestReadView<ProjectResource> {
serverEnableSignedPush,
resource.getProjectState(),
resource.getUser(),
config,
transferConfig,
pluginConfigEntries,
cfgFactory,
allProjects,

View File

@ -71,7 +71,7 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
private final Provider<MetaDataUpdate.User> metaDataUpdateFactory;
private final ProjectCache projectCache;
private final ProjectState.Factory projectStateFactory;
private final TransferConfig config;
private final TransferConfig transferConfig;
private final DynamicMap<ProjectConfigEntry> pluginConfigEntries;
private final PluginConfigFactory cfgFactory;
private final AllProjectsName allProjects;
@ -86,7 +86,7 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
Provider<MetaDataUpdate.User> metaDataUpdateFactory,
ProjectCache projectCache,
ProjectState.Factory projectStateFactory,
TransferConfig config,
TransferConfig transferConfig,
DynamicMap<ProjectConfigEntry> pluginConfigEntries,
PluginConfigFactory cfgFactory,
AllProjectsName allProjects,
@ -98,7 +98,7 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
this.metaDataUpdateFactory = metaDataUpdateFactory;
this.projectCache = projectCache;
this.projectStateFactory = projectStateFactory;
this.config = config;
this.transferConfig = transferConfig;
this.pluginConfigEntries = pluginConfigEntries;
this.cfgFactory = cfgFactory;
this.allProjects = allProjects;
@ -168,12 +168,12 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
throw new ResourceConflictException("Cannot update " + projectName);
}
ProjectState state = projectStateFactory.create(projectConfig);
ProjectState state = projectStateFactory.create(ProjectConfig.read(md));
return new ConfigInfoImpl(
serverEnableSignedPush,
state,
user.get(),
config,
transferConfig,
pluginConfigEntries,
cfgFactory,
allProjects,

View File

@ -44,6 +44,8 @@ import org.eclipse.jgit.lib.Config;
/** Provides access to the DataSource. */
@Singleton
public class DataSourceProvider implements Provider<DataSource>, LifecycleListener {
private static final String DATABASE_KEY = "database";
private final Config cfg;
private final MetricMaker metrics;
private final Context ctx;
@ -93,7 +95,7 @@ public class DataSourceProvider implements Provider<DataSource>, LifecycleListen
}
private DataSource open(Config cfg, Context context, DataSourceType dst) {
ConfigSection dbs = new ConfigSection(cfg, "database");
ConfigSection dbs = new ConfigSection(cfg, DATABASE_KEY);
String driver = dbs.optional("driver");
if (Strings.isNullOrEmpty(driver)) {
driver = dst.getDriver();
@ -112,41 +114,41 @@ public class DataSourceProvider implements Provider<DataSource>, LifecycleListen
if (context == Context.SINGLE_USER) {
usePool = false;
} else {
usePool = cfg.getBoolean("database", "connectionpool", dst.usePool());
usePool = cfg.getBoolean(DATABASE_KEY, "connectionpool", dst.usePool());
}
if (usePool) {
final BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName(driver);
ds.setUrl(url);
final BasicDataSource lds = new BasicDataSource();
lds.setDriverClassName(driver);
lds.setUrl(url);
if (username != null && !username.isEmpty()) {
ds.setUsername(username);
lds.setUsername(username);
}
if (password != null && !password.isEmpty()) {
ds.setPassword(password);
lds.setPassword(password);
}
int poolLimit = threadSettingsConfig.getDatabasePoolLimit();
ds.setMaxActive(poolLimit);
ds.setMinIdle(cfg.getInt("database", "poolminidle", 4));
ds.setMaxIdle(cfg.getInt("database", "poolmaxidle", Math.min(poolLimit, 16)));
ds.setMaxWait(
lds.setMaxActive(poolLimit);
lds.setMinIdle(cfg.getInt(DATABASE_KEY, "poolminidle", 4));
lds.setMaxIdle(cfg.getInt(DATABASE_KEY, "poolmaxidle", Math.min(poolLimit, 16)));
lds.setMaxWait(
ConfigUtil.getTimeUnit(
cfg,
"database",
DATABASE_KEY,
null,
"poolmaxwait",
MILLISECONDS.convert(30, SECONDS),
MILLISECONDS));
ds.setInitialSize(ds.getMinIdle());
lds.setInitialSize(lds.getMinIdle());
long evictIdleTimeMs = 1000L * 60;
ds.setMinEvictableIdleTimeMillis(evictIdleTimeMs);
ds.setTimeBetweenEvictionRunsMillis(evictIdleTimeMs / 2);
ds.setTestOnBorrow(true);
ds.setTestOnReturn(true);
ds.setValidationQuery(dst.getValidationQuery());
ds.setValidationQueryTimeout(5);
exportPoolMetrics(ds);
return intercept(interceptor, ds);
lds.setMinEvictableIdleTimeMillis(evictIdleTimeMs);
lds.setTimeBetweenEvictionRunsMillis(evictIdleTimeMs / 2);
lds.setTestOnBorrow(true);
lds.setTestOnReturn(true);
lds.setValidationQuery(dst.getValidationQuery());
lds.setValidationQueryTimeout(5);
exportPoolMetrics(lds);
return intercept(interceptor, lds);
}
// Don't use the connection pool.
//

View File

@ -213,16 +213,6 @@ public class ChangeIT extends AbstractDaemonTest {
}
}
@Test
public void reflog() throws Exception {
// Tests are using DfsRepository which does not implement getReflogReader,
// so this will always fail.
// TODO: change this if/when DfsRepository#getReflogReader is implemented.
exception.expect(MethodNotAllowedException.class);
exception.expectMessage("reflog not supported");
gApi.projects().name(project.get()).branch("master").reflog();
}
@Test
public void get() throws Exception {
PushOneCommit.Result r = createChange();

View File

@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.AtomicLongMap;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.GerritConfig;
import com.google.gerrit.acceptance.GitUtil;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.acceptance.PushOneCommit;
@ -410,6 +411,104 @@ public class ProjectIT extends AbstractDaemonTest {
ImmutableMap.of(project.get(), 1L, middle.get(), 1L, leave.get(), 1L));
}
@Test
public void maxObjectSizeIsNotSetByDefault() throws Exception {
ConfigInfo info = getConfig();
assertThat(info.maxObjectSizeLimit.value).isNull();
assertThat(info.maxObjectSizeLimit.configuredValue).isNull();
assertThat(info.maxObjectSizeLimit.inheritedValue).isNull();
}
@Test
public void maxObjectSizeCanBeSetAndCleared() throws Exception {
// Set a value
ConfigInput input = new ConfigInput();
input.maxObjectSizeLimit = "100k";
ConfigInfo info = setConfig(input);
assertThat(info.maxObjectSizeLimit.value).isEqualTo("100k");
assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k");
assertThat(info.maxObjectSizeLimit.inheritedValue).isNull();
// Clear the value
input.maxObjectSizeLimit = "0";
info = setConfig(input);
assertThat(info.maxObjectSizeLimit.value).isNull();
assertThat(info.maxObjectSizeLimit.configuredValue).isNull();
assertThat(info.maxObjectSizeLimit.inheritedValue).isNull();
}
@Test
public void maxObjectSizeIsNotInheritedFromParentProject() throws Exception {
Project.NameKey child = createProject(name("child"), project);
ConfigInput input = new ConfigInput();
input.maxObjectSizeLimit = "100k";
ConfigInfo info = setConfig(input);
assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k");
assertThat(info.maxObjectSizeLimit.inheritedValue).isNull();
info = getConfig(child);
assertThat(info.maxObjectSizeLimit.value).isNull();
assertThat(info.maxObjectSizeLimit.configuredValue).isNull();
assertThat(info.maxObjectSizeLimit.inheritedValue).isNull();
}
@Test
@GerritConfig(name = "receive.maxObjectSizeLimit", value = "200k")
public void maxObjectSizeIsInheritedFromGlobalConfig() throws Exception {
ConfigInfo info = getConfig();
assertThat(info.maxObjectSizeLimit.value).isEqualTo("200k");
assertThat(info.maxObjectSizeLimit.configuredValue).isNull();
assertThat(info.maxObjectSizeLimit.inheritedValue).isEqualTo("200k");
}
@Test
@GerritConfig(name = "receive.maxObjectSizeLimit", value = "200k")
public void maxObjectSizeOverridesGlobalConfigWhenLower() throws Exception {
ConfigInput input = new ConfigInput();
input.maxObjectSizeLimit = "100k";
ConfigInfo info = setConfig(input);
assertThat(info.maxObjectSizeLimit.value).isEqualTo("100k");
assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k");
assertThat(info.maxObjectSizeLimit.inheritedValue).isEqualTo("200k");
}
@Test
@GerritConfig(name = "receive.maxObjectSizeLimit", value = "200k")
public void maxObjectSizeDoesNotOverrideGlobalConfigWhenHigher() throws Exception {
ConfigInput input = new ConfigInput();
input.maxObjectSizeLimit = "300k";
ConfigInfo info = setConfig(input);
assertThat(info.maxObjectSizeLimit.value).isEqualTo("200k");
assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("300k");
assertThat(info.maxObjectSizeLimit.inheritedValue).isEqualTo("200k");
}
@Test
public void invalidMaxObjectSizeIsRejected() throws Exception {
ConfigInput input = new ConfigInput();
input.maxObjectSizeLimit = "100 foo";
exception.expect(ResourceConflictException.class);
exception.expectMessage("100 foo");
setConfig(input);
}
private ConfigInfo setConfig(Project.NameKey name, ConfigInput input) throws Exception {
return gApi.projects().name(name.get()).config(input);
}
private ConfigInfo setConfig(ConfigInput input) throws Exception {
return setConfig(project, input);
}
private ConfigInfo getConfig(Project.NameKey name) throws Exception {
return gApi.projects().name(name.get()).config();
}
private ConfigInfo getConfig() throws Exception {
return getConfig(project);
}
private ConfigInput createTestConfigInput() {
ConfigInput input = new ConfigInput();
input.description = "some description";

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.acceptance.server.notedb;
package com.google.gerrit.acceptance.server.project;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
@ -21,8 +21,12 @@ import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.UseLocalDisk;
import com.google.gerrit.extensions.api.changes.ReviewInput;
import com.google.gerrit.extensions.api.projects.BranchApi;
import com.google.gerrit.extensions.api.projects.ReflogEntryInfo;
import com.google.gerrit.reviewdb.client.Change;
import java.io.File;
import java.util.List;
import org.eclipse.jgit.lib.ReflogEntry;
import org.eclipse.jgit.lib.Repository;
import org.junit.Test;
@ -48,4 +52,26 @@ public class ReflogIT extends AbstractDaemonTest {
assertThat(last.getComment()).isEqualTo("restapi.change.PutTopic");
}
}
@Test
public void reflogUpdatedBySubmittingChange() throws Exception {
BranchApi branchApi = gApi.projects().name(project.get()).branch("master");
List<ReflogEntryInfo> reflog = branchApi.reflog();
assertThat(reflog).isNotEmpty();
// Current number of entries in the reflog
int refLogLen = reflog.size();
// Create and submit a change
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
String revision = r.getCommit().name();
ReviewInput in = ReviewInput.approve();
gApi.changes().id(changeId).revision(revision).review(in);
gApi.changes().id(changeId).revision(revision).submit();
// Submitting the change causes a new entry in the reflog
reflog = branchApi.reflog();
assertThat(reflog).hasSize(refLogLen + 1);
}
}