-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathtesting-base.gradle.kts
More file actions
116 lines (104 loc) · 4.36 KB
/
testing-base.gradle.kts
File metadata and controls
116 lines (104 loc) · 4.36 KB
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
/*
* Copyright 2008-present MongoDB, Inc.
*
* 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 conventions
import com.adarshr.gradle.testlogger.theme.ThemeType
import libs
import project.DEFAULT_JAVA_VERSION
// Default test configuration for projects
//
// Utilizes the test-logger plugin:
// https://plugins.gradle.org/plugin/com.adarshr.test-logger
plugins {
id("java-library")
alias(libs.plugins.test.logger)
}
tasks.withType<Test> {
maxHeapSize = "4g"
maxParallelForks = 1
useJUnitPlatform()
jvmArgs.add("-Dio.netty.leakDetection.level=paranoid")
// deliberately small stack size to trigger StackOverflowErrors in tests that
// silently pass because of the default large stack size on x64 machines
// see JAVA-6071 for details
jvmArgs.add("-Xss512k")
// Pass any `org.mongodb.*` system settings
systemProperties =
System.getProperties()
.map { (key, value) -> Pair(key.toString(), value) }
.filter { it.first.startsWith("org.mongodb.") }
.toMap()
// Convert any ssl based properties
if (project.buildingWith("ssl.enabled")) {
if (project.hasProperty("ssl.keyStoreType")) {
systemProperties(
mapOf(
"javax.net.ssl.keyStoreType" to project.property("ssl.keyStoreType"),
"javax.net.ssl.keyStore" to project.property("ssl.keyStore"),
"javax.net.ssl.keyStorePassword" to project.property("ssl.keyStorePassword")))
}
if (project.hasProperty("ssl.trustStoreType")) {
systemProperties(
mapOf(
"javax.net.ssl.trustStoreType" to project.property("ssl.trustStoreType"),
"javax.net.ssl.trustStore" to project.property("ssl.trustStore"),
"javax.net.ssl.trustStorePassword" to project.property("ssl.trustStorePassword")))
}
if (project.hasProperty("ocsp.property")) {
systemProperties(
mapOf(
"org.mongodb.test.ocsp.tls.should.succeed" to project.property("ocsp.tls.should.succeed"),
"java.security.properties" to file(project.property("ocsp.property").toString()),
"com.sun.net.ssl.checkRevocation" to project.property("ssl.checkRevocation"),
"jdk.tls.client.enableStatusRequestExtension" to
project.property("client.enableStatusRequestExtension"),
"jdk.tls.client.protocols" to project.property("client.protocols")))
}
}
// Convert gssapi properties
if (project.buildingWith("gssapi.enabled")) {
systemProperties(
mapOf(
"sun.security.krb5.debug" to project.property("sun.security.krb5.debug"),
"javax.security.auth.useSubjectCredsOnly" to "false",
"java.security.krb5.kdc" to project.property("krb5.kdc"),
"java.security.krb5.realm" to project.property("krb5.realm"),
"java.security.auth.login.config" to project.property("auth.login.config"),
))
}
// Allow testing with an alternative JDK version
val testJavaVersion: Int = findProperty("javaVersion")?.toString()?.toInt() ?: DEFAULT_JAVA_VERSION
javaLauncher.set(javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(testJavaVersion) })
}
// Pretty test output
testlogger {
theme = ThemeType.STANDARD
showExceptions = true
showStackTraces = true
showFullStackTraces = false
showCauses = true
slowThreshold = 2000
showSummary = true
showSimpleNames = false
showPassed = true
showSkipped = true
showFailed = true
showOnlySlow = false
showStandardStreams = false
showPassedStandardStreams = true
showSkippedStandardStreams = true
showFailedStandardStreams = true
logLevel = LogLevel.LIFECYCLE
}