Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEODE-8772: Pre-assign ports in the test JVM #6490

Closed

Conversation

demery-pivotal
Copy link
Contributor

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 and
AvailablePortHelper to honor these allocated port ranges.

This commit prepares for those changes.

Certain tests use ClusterStartupRule to start a member in a child VM
using 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 so
by creating the appropriate member starter rule (LocatorStarterRule or
ServerStarterRule) in the child VM. Depending on how this member
starter rule is configured, it may call AvailablePort in the child VM
to assign certain ports. The AvailablePort in the child VM is a prior
version 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 and
AvailablePortHelper, and so the tests will honor any port allocation
scheme defined in the latest implementation.

  • Change LocatorStarterRule, ServerStarterRule, and their common
    base class MemberStarterRule to pre-assign available ports in their
    constructors. They use AvailablePortHelper to assign the ports, and
    store the assigned port numbers as fields.
  • Change ClusterStartupRule to construct any required member starter
    rules in the test JVM instead of in the child VM. As a result, the
    member starter rules call AvailablePort and AvailablePortHelper
    only in the test JVM, where (eventually) the implementation will honor
    the range of ports allocated to the JVM.
  • When the ClusterStartupRule sends the member starter rule to the
    child 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.

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` and
`AvailablePortHelper` to honor these allocated port ranges.

This commit prepares for those changes.

Certain tests use `ClusterStartupRule` to start a member in a child VM
using 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 so
by creating the appropriate member starter rule (`LocatorStarterRule` or
`ServerStarterRule`) in the child VM. Depending on how this member
starter rule is configured, it may call `AvailablePort` in the child VM
to assign certain ports. The `AvailablePort` in the child VM is a prior
version 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` and
`AvailablePortHelper`, and so the tests  will honor any port allocation
scheme defined in the latest implementation.

- Change `LocatorStarterRule`, `ServerStarterRule`, and their common
  base class `MemberStarterRule` to pre-assign available ports in their
  constructors. They use `AvailablePortHelper` to assign the ports, and
  store the assigned port numbers as fields.
- Change `ClusterStartupRule` to construct any required member starter
  rules in the test JVM instead of in the child VM. As a result, the
  member starter rules call `AvailablePort` and `AvailablePortHelper`
  only in the test JVM, where (eventually) the implementation will honor
  the range of ports allocated to the JVM.
- When the `ClusterStartupRule` sends the member starter rule to the
  child 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant