Merge "Add NoteDb info to GetServerInfo"

This commit is contained in:
Dave Borowitz 2016-06-19 17:51:14 +00:00 committed by Gerrit Code Review
commit d06786334e
2 changed files with 25 additions and 6 deletions

View File

@ -75,7 +75,7 @@ public class ServerInfoIT extends AbstractDaemonTest {
}) })
public void serverConfig() throws Exception { public void serverConfig() throws Exception {
RestResponse r = adminRestSession.get("/config/server/info/"); RestResponse r = adminRestSession.get("/config/server/info/");
ServerInfo i = newGson().fromJson(r.getReader(), ServerInfo.class); ServerInfo i = getServerConfig();
// auth // auth
assertThat(i.auth.authType).isEqualTo(AuthType.HTTP); assertThat(i.auth.authType).isEqualTo(AuthType.HTTP);
@ -119,6 +119,12 @@ public class ServerInfoIT extends AbstractDaemonTest {
// user // user
assertThat(i.user.anonymousCowardName).isEqualTo("Unnamed User"); assertThat(i.user.anonymousCowardName).isEqualTo("Unnamed User");
// notedb
notesMigration.setReadChanges(true);
assertThat(getServerConfig().noteDbEnabled).isTrue();
notesMigration.setReadChanges(false);
assertThat(getServerConfig().noteDbEnabled).isFalse();
} }
@Test @Test
@ -129,8 +135,7 @@ public class ServerInfoIT extends AbstractDaemonTest {
Files.write(jsplugin, "Gerrit.install(function(self){});\n".getBytes(UTF_8)); Files.write(jsplugin, "Gerrit.install(function(self){});\n".getBytes(UTF_8));
adminSshSession.exec("gerrit plugin reload"); adminSshSession.exec("gerrit plugin reload");
RestResponse r = adminRestSession.get("/config/server/info/"); ServerInfo i = getServerConfig();
ServerInfo i = newGson().fromJson(r.getReader(), ServerInfo.class);
// plugin // plugin
assertThat(i.plugin.jsResourcePaths).hasSize(1); assertThat(i.plugin.jsResourcePaths).hasSize(1);
@ -138,8 +143,7 @@ public class ServerInfoIT extends AbstractDaemonTest {
@Test @Test
public void serverConfigWithDefaults() throws Exception { public void serverConfigWithDefaults() throws Exception {
RestResponse r = adminRestSession.get("/config/server/info/"); ServerInfo i = getServerConfig();
ServerInfo i = newGson().fromJson(r.getReader(), ServerInfo.class);
// auth // auth
assertThat(i.auth.authType).isEqualTo(AuthType.OPENID); assertThat(i.auth.authType).isEqualTo(AuthType.OPENID);
@ -185,4 +189,9 @@ public class ServerInfoIT extends AbstractDaemonTest {
// user // user
assertThat(i.user.anonymousCowardName).isEqualTo(AnonymousCowardNameProvider.DEFAULT); assertThat(i.user.anonymousCowardName).isEqualTo(AnonymousCowardNameProvider.DEFAULT);
} }
private ServerInfo getServerConfig() throws Exception {
RestResponse r = adminRestSession.get("/config/server/info/");
return newGson().fromJson(r.getReader(), ServerInfo.class);
}
} }

View File

@ -38,6 +38,7 @@ import com.google.gerrit.server.change.ArchiveFormat;
import com.google.gerrit.server.change.GetArchive; import com.google.gerrit.server.change.GetArchive;
import com.google.gerrit.server.change.Submit; import com.google.gerrit.server.change.Submit;
import com.google.gerrit.server.documentation.QueryDocumentationExecutor; import com.google.gerrit.server.documentation.QueryDocumentationExecutor;
import com.google.gerrit.server.notedb.NotesMigration;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config;
@ -68,6 +69,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
private final DynamicItem<AvatarProvider> avatar; private final DynamicItem<AvatarProvider> avatar;
private final boolean enableSignedPush; private final boolean enableSignedPush;
private final QueryDocumentationExecutor docSearcher; private final QueryDocumentationExecutor docSearcher;
private final NotesMigration migration;
@Inject @Inject
public GetServerInfo( public GetServerInfo(
@ -84,7 +86,8 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
@AnonymousCowardName String anonymousCowardName, @AnonymousCowardName String anonymousCowardName,
DynamicItem<AvatarProvider> avatar, DynamicItem<AvatarProvider> avatar,
@EnableSignedPush boolean enableSignedPush, @EnableSignedPush boolean enableSignedPush,
QueryDocumentationExecutor docSearcher) { QueryDocumentationExecutor docSearcher,
NotesMigration migration) {
this.config = config; this.config = config;
this.authConfig = authConfig; this.authConfig = authConfig;
this.realm = realm; this.realm = realm;
@ -99,6 +102,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
this.avatar = avatar; this.avatar = avatar;
this.enableSignedPush = enableSignedPush; this.enableSignedPush = enableSignedPush;
this.docSearcher = docSearcher; this.docSearcher = docSearcher;
this.migration = migration;
} }
@Override @Override
@ -110,6 +114,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
getDownloadInfo(downloadSchemes, downloadCommands, cloneCommands, getDownloadInfo(downloadSchemes, downloadCommands, cloneCommands,
archiveFormats); archiveFormats);
info.gerrit = getGerritInfo(config, allProjectsName, allUsersName); info.gerrit = getGerritInfo(config, allProjectsName, allUsersName);
info.noteDbEnabled = isNoteDbEnabled(config);
info.plugin = getPluginInfo(); info.plugin = getPluginInfo();
info.sshd = getSshdInfo(config); info.sshd = getSshdInfo(config);
info.suggest = getSuggestInfo(config); info.suggest = getSuggestInfo(config);
@ -258,6 +263,10 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
return CharMatcher.is('/').trimTrailingFrom(docUrl) + '/'; return CharMatcher.is('/').trimTrailingFrom(docUrl) + '/';
} }
private boolean isNoteDbEnabled(Config cfg) {
return migration.readChanges();
}
private PluginConfigInfo getPluginInfo() { private PluginConfigInfo getPluginInfo() {
PluginConfigInfo info = new PluginConfigInfo(); PluginConfigInfo info = new PluginConfigInfo();
info.hasAvatars = toBoolean(avatar.get() != null); info.hasAvatars = toBoolean(avatar.get() != null);
@ -320,6 +329,7 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
public ChangeConfigInfo change; public ChangeConfigInfo change;
public DownloadInfo download; public DownloadInfo download;
public GerritInfo gerrit; public GerritInfo gerrit;
public Boolean noteDbEnabled;
public PluginConfigInfo plugin; public PluginConfigInfo plugin;
public SshdInfo sshd; public SshdInfo sshd;
public SuggestInfo suggest; public SuggestInfo suggest;