diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/BUCK b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/BUCK new file mode 100644 index 0000000000..217af2f893 --- /dev/null +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/BUCK @@ -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'], +) diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/ReindexIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/ReindexIT.java new file mode 100644 index 0000000000..5778b19929 --- /dev/null +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/pgm/ReindexIT.java @@ -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)); + } +} diff --git a/gerrit-acceptance-tests/tests.defs b/gerrit-acceptance-tests/tests.defs index 3c8b4d5484..6c5a08766c 100644 --- a/gerrit-acceptance-tests/tests.defs +++ b/gerrit-acceptance-tests/tests.defs @@ -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', diff --git a/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java b/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java index 33a35348d1..6c39743e3e 100644 --- a/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java +++ b/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java @@ -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 {