curator
curator copied to clipboard
CURATOR-535: Fix client port conflict due to untrustworthy random port allocation
This commit tries to solve port conflict for TestingServer if port is unspecified(aka. port <= 0):
- Set
InstanceSpec.portto 0 if port is unspecified. - Save OS chosen bind port after started to maintain same port across restart.
Ideally, it should be possible to bootstrap TestingCluster(with unspecified ports) too with help from reconfig. But there are difficulties since election port, quorum port were not designed to be bound to 0 in ZooKeeper. TestingServer should be enough for most cases.
Users should resort to other solutions(eg. container) if they got bored by port conflict due to usages of TestingCluster and TestingServer.restart.