[ 
https://issues.apache.org/jira/browse/GEODE-8772?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17347833#comment-17347833
 ] 

ASF subversion and git services commented on GEODE-8772:
--------------------------------------------------------

Commit a0dc407e77fedd07a15c66b3088092ac309a47da in geode's branch 
refs/heads/develop from Dale Emery
[ https://gitbox.apache.org/repos/asf?p=geode.git;h=a0dc407 ]

GEODE-8772: Pre-assign ports in the test JVM (#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.

> Make tests assign necessary ports in test JVM [PERMANENT]
> ---------------------------------------------------------
>
>                 Key: GEODE-8772
>                 URL: https://issues.apache.org/jira/browse/GEODE-8772
>             Project: Geode
>          Issue Type: Test
>          Components: tests
>    Affects Versions: 1.14.0
>            Reporter: Dale Emery
>            Assignee: Dale Emery
>            Priority: Major
>              Labels: GeodeOperationAPI, pull-request-available
>
> *Make tests assign all necessary ports.* Many distributed tests and upgrade 
> tests (and sometimes others) launch members with default ports, especially 
> for JMX (1099) and HTTP service (7070). When run in parallel outside of 
> docker, these tests often fail because the default port is already in use in 
> another test.
> Except when specifically testing the product's use of the defaults, every 
> test should assign ports from a pool of ports known to be available. For many 
> tests, we can accomplish this by changing the test framework to assign 
> available ports. Other tests may require changes in the test code.
> *Assign ports only in test JVMs, and not in child VMs.* The 
> {{AvailablePortHelper}} class occasionally gains new features to improve its 
> assignment of ports when tests run in parallel. For these improvements to 
> work, each test must use the latest {{AvailablePortHelper}} implementation 
> for all port assignments. Child VMs that run older versions of Geode may not 
> include the latest implementation of {{AvailablePortHelper}}. For this 
> reason, tests should invoke {{AvailablePortHelper}} only in the test JVM and 
> not in child VMs.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to