mirror of
https://github.com/corda/corda.git
synced 2025-06-01 15:10:54 +00:00
CORDA-2759: Use GlobalTestPortAllocation for Node's integration tests. (#4899)
This commit is contained in:
parent
a90f394d43
commit
1fc8e1d7ae
@ -209,6 +209,9 @@ tasks.withType(JavaCompile) {
|
|||||||
task integrationTest(type: Test) {
|
task integrationTest(type: Test) {
|
||||||
testClassesDirs = sourceSets.integrationTest.output.classesDirs
|
testClassesDirs = sourceSets.integrationTest.output.classesDirs
|
||||||
classpath = sourceSets.integrationTest.runtimeClasspath
|
classpath = sourceSets.integrationTest.runtimeClasspath
|
||||||
|
|
||||||
|
systemProperty 'testing.global.port.allocation.enabled', true
|
||||||
|
systemProperty 'testing.global.port.allocation.starting.port', 10000
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
@ -118,11 +118,24 @@ abstract class PortAllocation {
|
|||||||
/**
|
/**
|
||||||
* An implementation of [PortAllocation] which allocates ports sequentially
|
* An implementation of [PortAllocation] which allocates ports sequentially
|
||||||
*/
|
*/
|
||||||
open class Incremental(startingPort: Int) : PortAllocation() {
|
open class Incremental(private val startingPort: Int) : PortAllocation() {
|
||||||
|
private companion object {
|
||||||
|
private const val FIRST_EPHEMERAL_PORT = 49152
|
||||||
|
}
|
||||||
|
|
||||||
/** The backing [AtomicInteger] used to keep track of the currently allocated port */
|
/** The backing [AtomicInteger] used to keep track of the currently allocated port */
|
||||||
val portCounter = AtomicInteger(startingPort)
|
val portCounter = AtomicInteger(startingPort)
|
||||||
|
|
||||||
override fun nextPort() = portCounter.andIncrement
|
override fun nextPort(): Int {
|
||||||
|
return portCounter.getAndUpdate { i ->
|
||||||
|
val next = i + 1
|
||||||
|
if (next >= FIRST_EPHEMERAL_PORT) {
|
||||||
|
startingPort
|
||||||
|
} else {
|
||||||
|
next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@ fun incrementalPortAllocation(startingPortIfNoEnv: Int): PortAllocation {
|
|||||||
|
|
||||||
private object GlobalTestPortAllocation : PortAllocation.Incremental(startingPort = startingPort())
|
private object GlobalTestPortAllocation : PortAllocation.Incremental(startingPort = startingPort())
|
||||||
|
|
||||||
private const val enablingEnvVar = "CORDA_TEST_GLOBAL_PORT_ALLOCATION_ENABLED"
|
private const val enablingEnvVar = "TESTING_GLOBAL_PORT_ALLOCATION_ENABLED"
|
||||||
private const val startingPortEnvVariable = "CORDA_TEST_GLOBAL_PORT_ALLOCATION_STARTING_PORT"
|
private const val startingPortEnvVariable = "TESTING_GLOBAL_PORT_ALLOCATION_STARTING_PORT"
|
||||||
private val enablingSystemProperty = enablingEnvVar.toLowerCase().replace("_", ".")
|
private val enablingSystemProperty = enablingEnvVar.toLowerCase().replace("_", ".")
|
||||||
private val startingPortSystemProperty = startingPortEnvVariable.toLowerCase().replace("_", ".")
|
private val startingPortSystemProperty = startingPortEnvVariable.toLowerCase().replace("_", ".")
|
||||||
private const val startingPortDefaultValue = 5000
|
private const val startingPortDefaultValue = 5000
|
||||||
|
Loading…
x
Reference in New Issue
Block a user