mirror of
https://github.com/corda/corda.git
synced 2025-06-05 00:50:52 +00:00
Enabled system property / env variable cascade for global test port allocation toggles. (#4336)
This commit is contained in:
parent
27a80900bd
commit
38438eadcd
@ -1,11 +1,15 @@
|
|||||||
package net.corda.testing.driver.internal
|
package net.corda.testing.driver.internal
|
||||||
|
|
||||||
import net.corda.testing.driver.PortAllocation
|
import net.corda.testing.driver.PortAllocation
|
||||||
|
import net.corda.testing.driver.internal.GlobalTestPortAllocation.enablingEnvVar
|
||||||
|
import net.corda.testing.driver.internal.GlobalTestPortAllocation.enablingSystemProperty
|
||||||
|
import net.corda.testing.driver.internal.GlobalTestPortAllocation.startingPortEnvVariable
|
||||||
|
import net.corda.testing.driver.internal.GlobalTestPortAllocation.startingPortSystemProperty
|
||||||
|
|
||||||
fun incrementalPortAllocation(startingPortIfNoEnv: Int): PortAllocation {
|
fun incrementalPortAllocation(startingPortIfNoEnv: Int): PortAllocation {
|
||||||
|
|
||||||
return when {
|
return when {
|
||||||
System.getenv(GlobalTestPortAllocation.enablingEnvVar)?.toBoolean() == true -> GlobalTestPortAllocation
|
System.getProperty(enablingSystemProperty)?.toBoolean() ?: System.getenv(enablingEnvVar)?.toBoolean() == true -> GlobalTestPortAllocation
|
||||||
else -> PortAllocation.Incremental(startingPortIfNoEnv)
|
else -> PortAllocation.Incremental(startingPortIfNoEnv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14,7 +18,9 @@ private object GlobalTestPortAllocation : PortAllocation.Incremental(startingPor
|
|||||||
|
|
||||||
const val enablingEnvVar = "CORDA_TEST_GLOBAL_PORT_ALLOCATION_ENABLED"
|
const val enablingEnvVar = "CORDA_TEST_GLOBAL_PORT_ALLOCATION_ENABLED"
|
||||||
const val startingPortEnvVariable = "CORDA_TEST_GLOBAL_PORT_ALLOCATION_STARTING_PORT"
|
const val startingPortEnvVariable = "CORDA_TEST_GLOBAL_PORT_ALLOCATION_STARTING_PORT"
|
||||||
|
val enablingSystemProperty = enablingEnvVar.toLowerCase().replace("_", ".")
|
||||||
|
val startingPortSystemProperty = startingPortEnvVariable.toLowerCase().replace("_", ".")
|
||||||
const val startingPortDefaultValue = 5000
|
const val startingPortDefaultValue = 5000
|
||||||
}
|
}
|
||||||
|
|
||||||
private val startingPort: Int = System.getenv(GlobalTestPortAllocation.startingPortEnvVariable)?.toIntOrNull() ?: GlobalTestPortAllocation.startingPortDefaultValue
|
private val startingPort: Int = System.getProperty(startingPortSystemProperty)?.toIntOrNull() ?: System.getenv(startingPortEnvVariable)?.toIntOrNull() ?: GlobalTestPortAllocation.startingPortDefaultValue
|
Loading…
x
Reference in New Issue
Block a user