Expand test for Reindex program
Change-Id: I4caa8047e80150bfc76c76a6b5ed2a96f9176692
This commit is contained in:
@@ -14,14 +14,45 @@
|
|||||||
|
|
||||||
package com.google.gerrit.acceptance.pgm;
|
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.NoHttpd;
|
||||||
import com.google.gerrit.acceptance.StandaloneSiteTest;
|
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;
|
import org.junit.Test;
|
||||||
|
|
||||||
@NoHttpd
|
@NoHttpd
|
||||||
public class ReindexIT extends StandaloneSiteTest {
|
public class ReindexIT extends StandaloneSiteTest {
|
||||||
@Test
|
@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");
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user