Gemfire Boot Sample uses Random Port
Previously, the Gemfire Boot Sample didn't select a random port for Tomcat to run on. Issue gh-496
This commit is contained in:
@@ -43,18 +43,11 @@ springBoot {
|
||||
mainClass = 'sample.client.Application'
|
||||
}
|
||||
|
||||
def port
|
||||
def process
|
||||
|
||||
task availablePort() << {
|
||||
def serverSocket = new ServerSocket(0)
|
||||
port = serverSocket.localPort
|
||||
serverSocket.close()
|
||||
}
|
||||
|
||||
task runGemFireServer(dependsOn: availablePort) << {
|
||||
task runGemFireServer() << {
|
||||
println 'STARTING GEMFIRE SERVER...'
|
||||
|
||||
ext.port = reservePort()
|
||||
|
||||
String classpath = sourceSets.main.runtimeClasspath.collect { it }.join(File.pathSeparator)
|
||||
|
||||
String[] commandLine = ['java', '-server', '-ea', '-classpath', classpath,
|
||||
@@ -64,7 +57,7 @@ task runGemFireServer(dependsOn: availablePort) << {
|
||||
|
||||
//println commandLine
|
||||
|
||||
process = commandLine.execute()
|
||||
ext.process = commandLine.execute()
|
||||
process.in.close()
|
||||
process.out.close()
|
||||
process.err.close()
|
||||
@@ -74,13 +67,24 @@ task runGemFireServer(dependsOn: availablePort) << {
|
||||
integrationTest {
|
||||
dependsOn runGemFireServer
|
||||
doFirst {
|
||||
def hostPort = 'localhost:8080'
|
||||
systemProperties['geb.build.baseUrl'] = 'http://' + hostPort + '/'
|
||||
def port = reservePort()
|
||||
def host = 'localhost:' + port
|
||||
systemProperties['server.port'] = port
|
||||
systemProperties['management.port'] = 0
|
||||
systemProperties['geb.build.baseUrl'] = 'http://'+host+'/'
|
||||
systemProperties['geb.build.reportsDir'] = 'build/geb-reports'
|
||||
systemProperties['gemfire.cache.server.port'] = port
|
||||
systemProperties['gemfire.cache.server.port'] = runGemFireServer.port
|
||||
}
|
||||
doLast {
|
||||
println 'STOPPING GEMFIRE SERVER...'
|
||||
process?.destroyForcibly()
|
||||
runGemFireServer.process?.destroyForcibly()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def reservePort() {
|
||||
def socket = new ServerSocket(0)
|
||||
def result = socket.localPort
|
||||
socket.close()
|
||||
result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user