-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathbuild.gradle
More file actions
150 lines (126 loc) · 4.98 KB
/
build.gradle
File metadata and controls
150 lines (126 loc) · 4.98 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
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
plugins {
id 'java-library'
}
repositories {
mavenCentral()
}
dependencies {
// client
implementation project(':client')
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.13.0'
// https://github.com/netty/netty/wiki/Native-transports
// At the moment, Windows is not supported
implementation group: 'io.netty', name: 'netty-transport-native-epoll', version: '4.1.100.Final', classifier: 'linux-x86_64'
implementation group: 'io.netty', name: 'netty-transport-native-kqueue', version: '4.1.100.Final', classifier: 'osx-x86_64'
implementation group: 'io.netty', name: 'netty-transport-native-kqueue', version: '4.1.100.Final', classifier: 'osx-aarch_64'
// junit
testImplementation 'org.mockito:mockito-junit-jupiter:3.12.4'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.10.2'
// semver4j for semantic versioning
implementation 'com.vdurmont:semver4j:3.1.0'
//lombok
testCompileOnly 'org.projectlombok:lombok:1.18.32'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.32'
}
def standaloneHosts = ''
def clusterHosts = ''
ext {
extractAddressesFromClusterManagerOutput = { String output ->
for (def line : output.split("\n")) {
if (!line.startsWith("CLUSTER_NODES="))
continue
return line.split("=")[1]
}
return ''
}
}
tasks.register('stopAllAfterTests', Exec) {
workingDir "${project.rootDir}/../utils"
commandLine 'python3', 'cluster_manager.py', 'stop', '--prefix', 'redis-cluster', '--keep-folder'
}
// We need to call for stop before and after the test, but gradle doesn't support executing a task
// twice. So there are two identical tasks with different names.
// We need to call for stop in case if previous test run was interrupted/crashed and didn't stop.
tasks.register('stopAllBeforeTests', Exec) {
workingDir "${project.rootDir}/../utils"
commandLine 'python3', 'cluster_manager.py', 'stop', '--prefix', 'redis-cluster'
ignoreExitValue true // ignore fail if servers are stopped before
}
// delete dirs if stop failed due to https://github.com/valkey-io/valkey-glide/issues/849
tasks.register('clearDirs', Delete) {
delete "${project.rootDir}/../utils/clusters"
}
tasks.register('startCluster') {
doLast {
if (System.getProperty("cluster-endpoints") == null) {
new ByteArrayOutputStream().withStream { os ->
exec {
workingDir "${project.rootDir}/../utils"
def args = ['python3', 'cluster_manager.py', 'start', '--cluster-mode']
if (System.getProperty("tls") == 'true') args.add(2, '--tls')
commandLine args
standardOutput = os
}
clusterHosts = extractAddressesFromClusterManagerOutput(os.toString())
}
} else {
clusterHosts = System.getProperty("cluster-endpoints")
}
}
}
tasks.register('startStandalone') {
doLast {
if (System.getProperty("standalone-endpoints") == null) {
new ByteArrayOutputStream().withStream { os ->
exec {
workingDir "${project.rootDir}/../utils"
def args = ['python3', 'cluster_manager.py', 'start', '-r', '0']
if (System.getProperty("tls") == 'true') args.add(2, '--tls')
commandLine args
standardOutput = os
}
standaloneHosts = extractAddressesFromClusterManagerOutput(os.toString())
}
} else {
standaloneHosts = System.getProperty("standalone-endpoints")
}
}
}
test.dependsOn 'stopAllBeforeTests'
stopAllBeforeTests.finalizedBy 'clearDirs'
clearDirs.finalizedBy 'startStandalone'
clearDirs.finalizedBy 'startCluster'
test.finalizedBy 'stopAllAfterTests'
test.dependsOn ':client:buildRustRelease'
tasks.withType(Test) {
doFirst {
println "Cluster hosts = ${clusterHosts}"
println "Standalone hosts = ${standaloneHosts}"
systemProperty 'test.server.standalone', standaloneHosts
systemProperty 'test.server.cluster', clusterHosts
systemProperty 'test.server.tls', System.getProperty("tls")
}
testLogging {
exceptionFormat "full"
events "started", "skipped", "passed", "failed"
showStandardStreams true
}
minHeapSize = "2048m" // Initial heap size. Needed for max size tests.
maxHeapSize = "2048m" // Maximum heap size. Needed for max size tests.
afterTest { desc, result ->
logger.quiet "${desc.className}.${desc.name}: ${result.resultType} ${(result.getEndTime() - result.getStartTime())/1000}s"
}
}
test {
filter {
excludeTestsMatching 'glide.modules.*'
}
}
tasks.register('modulesTest', Test) {
doFirst {
clusterHosts = System.getProperty("cluster-endpoints")
}
filter {
includeTestsMatching 'glide.modules.*'
}
}