Add simple tests to launch Reindex

We currently have no tests for the Reindex injector stack, and it is
not uncommon for changes to break Reindex as contributors do not
always know or remember to run it.

Add tests that run the Reindex program directly via GerritLauncher,
using a real injector stack on a newly created site.

Eventually we may want to reindex a site with changes in it, wiring up
GerritServer, which is beyond the scope of this test.

Change-Id: Ic6f32ee4d24395be74b3ea60b9084c79531c6a4a
This commit is contained in:
Dave Borowitz 2014-04-15 07:12:47 -06:00
parent dcbb89ae6f
commit dc80fddce0
4 changed files with 78 additions and 2 deletions

View File

@ -0,0 +1,9 @@
include_defs('//gerrit-acceptance-tests/tests.defs')
acceptance_tests(
srcs = glob(['*IT.java']),
deps = [
'//gerrit-acceptance-tests:lib',
],
source_under_test = ['//gerrit-pgm:pgm'],
)

View File

@ -0,0 +1,66 @@
// Copyright (C) 2014 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.acceptance.pgm;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.TempFileUtil;
import com.google.gerrit.launcher.GerritLauncher;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
public class ReindexIT {
private File sitePath;
@Before
public void createTempDirectory() throws Exception {
sitePath = TempFileUtil.createTempDirectory();
}
@After
public void destroySite() throws Exception {
if (sitePath != null) {
TempFileUtil.recursivelyDelete(sitePath);
}
}
@Test
public void reindexEmptySite() throws Exception {
initSite();
runGerrit("reindex", "-d", sitePath.getPath(),
"--show-stack-trace");
}
@Test
public void reindexEmptySiteWithRecheckMergeable() throws Exception {
initSite();
runGerrit("reindex", "-d", sitePath.getPath(),
"--show-stack-trace",
"--recheck-mergeable");
}
private void initSite() throws Exception {
runGerrit("init", "-d", sitePath.getPath(),
"--batch", "--no-auto-start", "--skip-plugins", "--show-stack-trace");
}
private static void runGerrit(String... args) throws Exception {
assertEquals(0, GerritLauncher.mainImpl(args));
}
}

View File

@ -1,6 +1,7 @@
def acceptance_tests(
srcs,
deps = [],
source_under_test = [],
vm_args = ['-Xmx256m']):
for j in srcs:
java_test(
@ -11,7 +12,7 @@ def acceptance_tests(
'//gerrit-httpd:httpd',
'//gerrit-sshd:sshd',
'//gerrit-server:server',
],
] + source_under_test,
labels = [
'acceptance',
'slow',

View File

@ -50,7 +50,7 @@ public final class GerritLauncher {
System.exit(mainImpl(argv));
}
private static int mainImpl(final String argv[]) throws Exception {
public static int mainImpl(final String argv[]) throws Exception {
if (argv.length == 0) {
File me;
try {