Split acceptance tests into one target per test
Buck runs tests in parallel based on the targets declared in BUCK files. Making each test its own target allows the tests to run in parallel in separate JVMs. Parallel execution enables slow acceptance tests to take less wall clock time when multiple cores are available. Acceptance tests leak an entire server environment for every @Test method run. Fragmenting the tests into units allows them to be garbage collected by the operating system when the test JVM dies. This avoids stressing the Java GC with lots of garbage as more tests pile into the finite heap space. With this change and the newer version of buck, a clean build and execution of all tests takes my laptop only 1m25s to execute when running on battery. Change-Id: Ia3f689a9e6ca6c620026cc720ccca924387e1363
This commit is contained in:
parent
11d27c8ee8
commit
b46c76ea89
@ -1,18 +1,17 @@
|
||||
TEST = [
|
||||
'//gerrit-httpd:httpd',
|
||||
'//gerrit-sshd:sshd',
|
||||
'//gerrit-server:server',
|
||||
]
|
||||
include_defs('//gerrit-acceptance-tests/DEFS')
|
||||
|
||||
java_test(
|
||||
name = 'acceptance_tests',
|
||||
srcs = glob(['src/test/java/**/*.java']),
|
||||
deps = TEST + [
|
||||
java_library(
|
||||
name = 'lib',
|
||||
srcs = glob(['src/test/java/com/google/gerrit/acceptance/*.java']),
|
||||
deps = [
|
||||
'//gerrit-common:server',
|
||||
'//gerrit-extension-api:api',
|
||||
'//gerrit-launcher:launcher',
|
||||
'//gerrit-httpd:httpd',
|
||||
'//gerrit-pgm:pgm',
|
||||
'//gerrit-reviewdb:server',
|
||||
'//gerrit-server:server',
|
||||
'//gerrit-sshd:sshd',
|
||||
|
||||
'//lib:args4j',
|
||||
'//lib:gson',
|
||||
@ -32,7 +31,9 @@ java_test(
|
||||
'//lib/jgit:jgit',
|
||||
'//lib/jgit:junit',
|
||||
],
|
||||
source_under_test = TEST,
|
||||
labels = ['slow'],
|
||||
visibility = ['//tools/eclipse:classpath'],
|
||||
export_deps = True,
|
||||
visibility = [
|
||||
'//tools/eclipse:classpath',
|
||||
'//gerrit-acceptance-tests/...',
|
||||
],
|
||||
)
|
||||
|
20
gerrit-acceptance-tests/DEFS
Normal file
20
gerrit-acceptance-tests/DEFS
Normal file
@ -0,0 +1,20 @@
|
||||
def acceptance_tests(
|
||||
srcs,
|
||||
deps = [],
|
||||
vm_args = []):
|
||||
for j in srcs:
|
||||
java_test(
|
||||
name = j[:-len('.java')],
|
||||
srcs = [j],
|
||||
deps = ['//gerrit-acceptance-tests:lib'] + deps,
|
||||
source_under_test = [
|
||||
'//gerrit-httpd:httpd',
|
||||
'//gerrit-sshd:sshd',
|
||||
'//gerrit-server:server',
|
||||
],
|
||||
labels = [
|
||||
'acceptance',
|
||||
'slow',
|
||||
],
|
||||
vm_args = vm_args,
|
||||
)
|
@ -0,0 +1,22 @@
|
||||
include_defs('//gerrit-acceptance-tests/DEFS')
|
||||
|
||||
acceptance_tests(
|
||||
srcs = glob(['*IT.java']),
|
||||
deps = [':util'],
|
||||
vm_args = ['-Xmx512m'],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = 'util',
|
||||
srcs = ['GitUtil.java', 'PushOneCommit.java'],
|
||||
deps = [
|
||||
'//gerrit-acceptance-tests:lib',
|
||||
'//gerrit-reviewdb:server',
|
||||
'//lib:guava',
|
||||
'//lib:gwtorm',
|
||||
'//lib:jsch',
|
||||
'//lib/jgit:jgit',
|
||||
'//lib:junit',
|
||||
],
|
||||
visibility = ['//gerrit-acceptance-tests/...'],
|
||||
)
|
@ -0,0 +1,18 @@
|
||||
include_defs('//gerrit-acceptance-tests/DEFS')
|
||||
|
||||
acceptance_tests(
|
||||
srcs = glob(['*IT.java']),
|
||||
deps = [':util'],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = 'util',
|
||||
srcs = ['AccountAssert.java', 'AccountInfo.java'],
|
||||
deps = [
|
||||
'//gerrit-acceptance-tests:lib',
|
||||
'//gerrit-reviewdb:server',
|
||||
'//lib:gwtorm',
|
||||
'//lib:junit',
|
||||
],
|
||||
visibility = ['//gerrit-acceptance-tests/...'],
|
||||
)
|
@ -0,0 +1,14 @@
|
||||
include_defs('//gerrit-acceptance-tests/DEFS')
|
||||
|
||||
acceptance_tests(
|
||||
srcs = glob(['*IT.java']),
|
||||
deps = [
|
||||
':util',
|
||||
'//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:util',
|
||||
],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = 'util',
|
||||
srcs = ['ChangeInfo.java', 'ChangeMessageInfo.java'],
|
||||
)
|
@ -0,0 +1,27 @@
|
||||
include_defs('//gerrit-acceptance-tests/DEFS')
|
||||
|
||||
acceptance_tests(
|
||||
srcs = glob(['*IT.java']),
|
||||
deps = [
|
||||
':util',
|
||||
'//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/account:util',
|
||||
],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = 'util',
|
||||
srcs = [
|
||||
'GroupAssert.java',
|
||||
'GroupInfo.java',
|
||||
'GroupInput.java',
|
||||
'GroupOptionsInfo.java',
|
||||
'GroupsInput.java',
|
||||
'MembersInput.java',
|
||||
],
|
||||
deps = [
|
||||
'//gerrit-extension-api:api',
|
||||
'//gerrit-reviewdb:server',
|
||||
'//lib:gwtorm',
|
||||
'//lib:junit',
|
||||
],
|
||||
)
|
@ -12,12 +12,17 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.acceptance;
|
||||
package com.google.gerrit.acceptance.rest.group;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.acceptance.rest.group.GroupInfo;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.AccountCreator;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.RestSession;
|
||||
import com.google.gerrit.acceptance.SshSession;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gson.Gson;
|
@ -0,0 +1,38 @@
|
||||
include_defs('//gerrit-acceptance-tests/DEFS')
|
||||
|
||||
acceptance_tests(
|
||||
srcs = glob(['*IT.java']),
|
||||
deps = [
|
||||
':branch',
|
||||
':project',
|
||||
'//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:util',
|
||||
],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = 'branch',
|
||||
srcs = [
|
||||
'BranchAssert.java',
|
||||
'BranchInfo.java',
|
||||
],
|
||||
deps = [
|
||||
'//lib:guava',
|
||||
'//lib:junit',
|
||||
],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = 'project',
|
||||
srcs = [
|
||||
'ProjectAssert.java',
|
||||
'ProjectInfo.java',
|
||||
],
|
||||
deps = [
|
||||
'//gerrit-extension-api:api',
|
||||
'//gerrit-reviewdb:server',
|
||||
'//gerrit-server:server',
|
||||
'//lib:gwtorm',
|
||||
'//lib:guava',
|
||||
'//lib:junit',
|
||||
],
|
||||
)
|
@ -0,0 +1,6 @@
|
||||
include_defs('//gerrit-acceptance-tests/DEFS')
|
||||
|
||||
acceptance_tests(
|
||||
srcs = glob(['*IT.java']),
|
||||
deps = ['//gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:util'],
|
||||
)
|
@ -2,7 +2,7 @@ java_library(
|
||||
name = 'launcher',
|
||||
srcs = glob(['src/main/java/**/*.java']),
|
||||
visibility = [
|
||||
'//gerrit-acceptance-tests:',
|
||||
'//gerrit-acceptance-tests/...',
|
||||
'//gerrit-main:main_lib',
|
||||
'//gerrit-pgm:',
|
||||
],
|
||||
|
@ -39,7 +39,7 @@ java_library2(
|
||||
compile_deps = ['//gerrit-launcher:launcher'],
|
||||
visibility = [
|
||||
'//:',
|
||||
'//gerrit-acceptance-tests:',
|
||||
'//gerrit-acceptance-tests/...',
|
||||
'//tools/eclipse:classpath',
|
||||
'//Documentation:licenses.txt',
|
||||
],
|
||||
|
@ -25,7 +25,7 @@ genrule(
|
||||
java_library(
|
||||
name = 'classpath',
|
||||
deps = LIBS + PGMLIBS + [
|
||||
'//gerrit-acceptance-tests:acceptance_tests',
|
||||
'//gerrit-acceptance-tests:lib',
|
||||
'//gerrit-gwtdebug:gwtdebug',
|
||||
'//gerrit-gwtui:ui_module',
|
||||
'//gerrit-gwtui:ui_tests',
|
||||
|
Loading…
Reference in New Issue
Block a user