forked from apache/geode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.gradle
265 lines (226 loc) · 9.51 KB
/
test.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
import org.apache.geode.gradle.TestPropertiesWriter
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
task combineReports(type: TestReport) {
description 'Combines the test reports.'
destinationDir = file "${rootProject.buildDir}/reports/combined"
doLast {
println "All test reports at ${rootProject.buildDir}/reports/combined"
}
}
gradle.taskGraph.whenReady({ graph ->
tasks.getByName('combineReports').reportOn rootProject.subprojects.collect{ it.tasks.withType(Test) }.flatten()
})
subprojects {
dependencies {
testCompile ('com.github.stefanbirkner:system-rules:' + project.'system-rules.version') {
exclude module: 'junit-dep'
}
testCompile 'com.google.code.tempus-fugit:tempus-fugit:' + project.'tempus-fugit.version'
testCompile 'com.jayway.awaitility:awaitility:' + project.'awaitility.version'
testCompile 'edu.umd.cs.mtc:multithreadedtc:' + project.'multithreadedtc.version'
testCompile 'eu.codearte.catch-exception:catch-exception:' + project.'catch-exception.version'
testCompile 'eu.codearte.catch-exception:catch-throwable:' + project.'catch-throwable.version'
testCompile 'junit:junit:' + project.'junit.version'
testCompile 'org.assertj:assertj-core:' + project.'assertj-core.version'
testCompile 'org.mockito:mockito-core:' + project.'mockito-core.version'
testCompile 'org.hamcrest:hamcrest-all:' + project.'hamcrest-all.version'
testCompile 'org.jmock:jmock-junit4:' + project.'jmock.version'
testCompile 'org.jmock:jmock-legacy:' + project.'jmock.version'
testCompile 'pl.pragmatists:JUnitParams:' + project.'JUnitParams.version'
testRuntime 'cglib:cglib:' + project.'cglib.version'
testRuntime 'org.ow2.asm:asm:' + project.'asm.version'
}
//This target does not run any tests. Rather, it validates that there are no
//tests that are missing a category annotation
task checkMissedTests(type: Test) {
include '**/*Test.class'
useJUnit {
excludeCategories 'org.apache.geode.test.junit.categories.UnitTest'
excludeCategories 'org.apache.geode.test.junit.categories.IntegrationTest'
excludeCategories 'org.apache.geode.test.junit.categories.DistributedTest'
excludeCategories 'org.apache.geode.test.junit.categories.PerformanceTest'
excludeCategories 'org.apache.geode.test.junit.categories.HydraTest'
excludeCategories 'org.apache.geode.test.junit.categories.ContainerTest'
excludeCategories 'org.apache.geode.test.junit.categories.UITest'
}
//Skip launching any DUnit VMs during this run. This will prevent
//junit from launching VMs while parsing categories
systemProperty 'gemfire.DUnitLauncher.LAUNCHED', 'true'
beforeTest { descriptor ->
throw new GradleException("The test " + descriptor.getClassName() + "." + descriptor.getName() + " does not include a junit category.");
}
}
test {
useJUnit {
includeCategories 'org.apache.geode.test.junit.categories.UnitTest'
excludeCategories 'org.apache.geode.test.junit.categories.FlakyTest'
}
doFirst {
TestPropertiesWriter.writeTestProperties(buildDir, name)
}
}
task integrationTest(type:Test) {
useJUnit {
includeCategories 'org.apache.geode.test.junit.categories.IntegrationTest'
excludeCategories 'org.apache.geode.test.junit.categories.FlakyTest'
}
forkEvery 1
doFirst {
TestPropertiesWriter.writeTestProperties(buildDir, name)
}
}
task distributedTest(type:Test) {
useJUnit {
includeCategories 'org.apache.geode.test.junit.categories.DistributedTest'
excludeCategories 'org.apache.geode.test.junit.categories.FlakyTest'
}
forkEvery 30
}
task flakyTest(type:Test) {
useJUnit {
includeCategories 'org.apache.geode.test.junit.categories.FlakyTest'
}
forkEvery 1
doFirst {
TestPropertiesWriter.writeTestProperties(buildDir, name)
}
reports.junitXml.destination = file "$buildDir/test-reports-flaky"
}
task securityTest(type:Test) {
useJUnit {
includeCategories 'org.apache.geode.test.junit.categories.SecurityTest'
}
forkEvery 1
doFirst {
TestPropertiesWriter.writeTestProperties(buildDir, name)
}
reports.junitXml.destination = file "$buildDir/test-reports-security"
}
task clientServerTest(type:Test) {
useJUnit {
includeCategories 'org.apache.geode.test.junit.categories.ClientServerTest'
}
doFirst {
TestPropertiesWriter.writeTestProperties(buildDir, name)
}
reports.junitXml.destination = file "$buildDir/test-reports-security"
}
task dlockTest(type:Test) {
useJUnit {
includeCategories 'org.apache.geode.test.junit.categories.DLockTest'
}
doFirst {
TestPropertiesWriter.writeTestProperties(buildDir, name)
}
reports.junitXml.destination = file "$buildDir/test-reports-dlock"
}
task membershipTest(type:Test) {
useJUnit {
includeCategories 'org.apache.geode.test.junit.categories.MembershipTest'
}
doFirst {
TestPropertiesWriter.writeTestProperties(buildDir, name)
}
reports.junitXml.destination = file "$buildDir/test-reports-membership"
}
task restAPITest(type:Test) {
useJUnit {
includeCategories 'org.apache.geode.test.junit.categories.RestAPITest'
}
doFirst {
TestPropertiesWriter.writeTestProperties(buildDir, name)
}
forkEvery 1
reports.junitXml.destination = file "$buildDir/test-reports-restAPI"
}
task serializationTest(type:Test) {
useJUnit {
includeCategories 'org.apache.geode.test.junit.categories.serializationTest'
}
doFirst {
TestPropertiesWriter.writeTestProperties(buildDir, name)
}
reports.junitXml.destination = file "$buildDir/test-reports-serialization"
}
// By proving a file with an arbitrary list of test classes, we can select only those
// tests to run. Activated using -Dcustom.tests=<file> customTest
def customTestList = []
def customTestFile = System.getProperty('custom.tests')
if (customTestFile != null) {
new File(customTestFile).eachLine { customTestList << it }
}
task customTest(type:Test) {
include { x ->
(x.isDirectory() || customTestList.any { y -> x.getName().contains(y) } ) ? true : false
}
forkEvery 30
}
// apply common test configuration
gradle.taskGraph.whenReady( { graph ->
tasks.withType(Test).each { test ->
check.dependsOn test
test.configure {
onlyIf { ! Boolean.getBoolean('skip.tests') }
//force tests to be run every time by
//saying the results are never up to date
outputs.upToDateWhen { false }
def resultsDir = TestPropertiesWriter.testResultsDir(buildDir, test.name)
workingDir resultsDir.absolutePath
reports.html.destination = file "$buildDir/reports/$name"
testLogging {
exceptionFormat = 'full'
}
maxHeapSize '768m'
// jvmArgs = ['-XX:+HeapDumpOnOutOfMemoryError', '-ea',"-XX:+PrintGC", "-XX:+PrintGCDetails","-XX:+PrintGCTimeStamps"]
jvmArgs = ['-XX:+HeapDumpOnOutOfMemoryError', '-ea']
systemProperty 'gemfire.DEFAULT_MAX_OPLOG_SIZE', '10'
systemProperty 'gemfire.disallowMcastDefaults', 'true'
systemProperty 'jline.terminal', 'jline.UnsupportedTerminal'
def logLevel = System.getProperty('logLevel')
if (logLevel != null) {
systemProperty 'logLevel', logLevel
}
def log4jLocation = System.getProperty('log4j.configurationFile')
if (log4jLocation != null) {
systemProperty 'log4j.configurationFile', log4jLocation
}
def eol = System.getProperty('line.separator')
def progress = new File(resultsDir, "$test.name-progress.txt")
beforeTest { desc ->
def now = new Date().format('yyyy-MM-dd HH:mm:ss.SSS Z')
progress << "$now Starting test $desc.className $desc.name$eol"
}
afterTest { desc, result ->
def now = new Date().format('yyyy-MM-dd HH:mm:ss.SSS Z')
progress << "$now Completed test $desc.className $desc.name with result: ${result.resultType}$eol"
}
doFirst {
resultsDir.deleteDir()
resultsDir.mkdirs()
}
}
}
})
// Make precheckin task run all validation tests for checking in code.
task precheckin (dependsOn: [ build, integrationTest, distributedTest, flakyTest ]) {
description 'Run this task before checking in code to validate changes. This task combines the following tasks: build, integrationTest, distributedTest, and flakyTest'
}
check.dependsOn checkMissedTests
combineReports.mustRunAfter check, test, integrationTest, distributedTest, flakyTest, checkMissedTests
[build, check, test, integrationTest, distributedTest, flakyTest, checkMissedTests].each {it.finalizedBy combineReports}
}