Corda's node-driver contains a PortAllocation class that provides a new port number atomically from a given starting port number. There is also a GlobalTestPortAllocation variant which is intended to be used across a suite of tests running in the same JVM.
The GlobalTestPortAllocation class is enabled and configured by these two system properties:
Unfortunately, Corda's net.corda.node.services.config.ConfigHelper object assumes that every system property starting with corda. is intended to configure the Node, so enabling the GlobalTestPortAllocation breaks node-driver.
I will rename these system properties as follows, so as not to conflict with ConfigHelper:
I will also ensure that PortAllocation wraps back to its startingPort when it reaches 49152, because ports 49152-65535 are designated as "ephemeral ports" by TCP/IP.
Finally, I will enabled GlobalTestPortAllocation for Node's integration tests.