Expand test for Reindex program

Change-Id: I4caa8047e80150bfc76c76a6b5ed2a96f9176692
This commit is contained in:
Dave Borowitz 2017-06-23 13:54:32 -04:00 committed by Hugo Arès
parent e5fcd0b087
commit c7bdc5b485
1 changed files with 32 additions and 1 deletions

View File

@ -14,14 +14,45 @@
package com.google.gerrit.acceptance.pgm;
import static com.google.common.truth.Truth8.assertThat;
import com.google.common.io.MoreFiles;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.acceptance.StandaloneSiteTest;
import com.google.gerrit.extensions.api.GerritApi;
import com.google.gerrit.extensions.common.ChangeInput;
import com.google.gerrit.reviewdb.client.Project;
import java.nio.file.Files;
import org.junit.Test;
@NoHttpd
public class ReindexIT extends StandaloneSiteTest {
@Test
public void reindexEmptySite() throws Exception {
public void reindexFromScratch() throws Exception {
Project.NameKey project = new Project.NameKey("project");
String changeId;
try (ServerContext ctx = startServer()) {
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
gApi.projects().create("project");
ChangeInput in = new ChangeInput();
in.project = project.get();
in.branch = "master";
in.subject = "Test change";
in.newBranch = true;
changeId = gApi.changes().create(in).info().changeId;
}
MoreFiles.deleteRecursively(sitePaths.index_dir);
Files.createDirectory(sitePaths.index_dir);
assertServerStartupFails();
runGerrit("reindex", "-d", sitePaths.site_path.toString(), "--show-stack-trace");
try (ServerContext ctx = startServer()) {
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
assertThat(gApi.changes().query("message:Test").get().stream().map(c -> c.changeId))
.containsExactly(changeId);
}
}
}