demery-pivotal opened a new pull request #6491: URL: https://github.com/apache/geode/pull/6491
Change `ClusterStartupRule` to assign ports only in the test JVM. BACKGROUND ========== 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. PROBLEM ======= 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. CAUSE ===== 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. GENERAL SOLUTION ================ 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. THIS COMMIT =========== - 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. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org