GEODE-8772: Pre-assign ports in the test JVM #6490
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change
ClusterStartupRule
to assign ports only in the test JVM.As part of my project to allow Geode tests to run in parallel outside of
Docker, I am changing our build system to allocate a distinct range of
ports to each test JVM, and changing
AvailablePort
andAvailablePortHelper
to honor these allocated port ranges.This commit prepares for those changes.
Certain tests use
ClusterStartupRule
to start a member in a child VMusing a prior version of Geode. When such tests run in parallel outside
of Docker, the child VM can attempt to bind to ports that are in use by
tests in other JVMs.
When the
ClusterStartupRule
starts a member in a child VM, it does soby creating the appropriate member starter rule (
LocatorStarterRule
orServerStarterRule
) in the child VM. Depending on how this memberstarter rule is configured, it may call
AvailablePort
in the child VMto assign certain ports. The
AvailablePort
in the child VM is a priorversion that knows nothing of the port partitioning scheme I’m currently
adding, and so may assign ports from outside of the range of ports
allocated to test. These ports may conflict with ports already in use by
tests in other JVMs, or ports that are "reserved" by those tests.
Make tests assign ports only in the test JVM. The test JVM always
includes the latest implementations of
AvailablePort
andAvailablePortHelper
, and so the tests will honor any port allocationscheme defined in the latest implementation.
LocatorStarterRule
,ServerStarterRule
, and their commonbase class
MemberStarterRule
to pre-assign available ports in theirconstructors. They use
AvailablePortHelper
to assign the ports, andstore the assigned port numbers as fields.
ClusterStartupRule
to construct any required member starterrules in the test JVM instead of in the child VM. As a result, the
member starter rules call
AvailablePort
andAvailablePortHelper
only in the test JVM, where (eventually) the implementation will honor
the range of ports allocated to the JVM.
ClusterStartupRule
sends the member starter rule to thechild VM, the member starter rule is deserialized in the child VM with
the pre-assigned port numbers. If the member starter rule is
configured to assign a port, it uses the one that was pre-assigned in
the test JVM.