You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "David Handermann (Jira)" <ji...@apache.org> on 2023/06/01 18:36:00 UTC

[jira] [Updated] (NIFI-11603) Refactor Unstable Socket-based Tests

     [ https://issues.apache.org/jira/browse/NIFI-11603?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Handermann updated NIFI-11603:
------------------------------------
    Fix Version/s: 2.0.0
                   1.22.0
                       (was: 1.latest)
                       (was: 2.latest)
       Resolution: Fixed
           Status: Resolved  (was: Patch Available)

> Refactor Unstable Socket-based Tests
> ------------------------------------
>
>                 Key: NIFI-11603
>                 URL: https://issues.apache.org/jira/browse/NIFI-11603
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Extensions
>            Reporter: Mark Payne
>            Assignee: Mark Payne
>            Priority: Major
>             Fix For: 2.0.0, 1.22.0
>
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> We have many tests throughout the codebase that use NetworkUtils.getAvailablePort / getAvailableTcpPort / getAvailableUdpPort.
> These util methods need to be removed and not used. They are a very bad practice that result in intermittent failures. These methods work by creating a ServerSocket using Port 0, starting it, then determining the port that it's listening on. Then the ServerSocket is closed and the port it was listening on was returned so that it can be used for another server to be started.
> This is problematic for two reasons. Firstly, there's no reason to think that the port will be available when the next server is started - there are all sorts of OS settings for how long the sockets are kept alive, etc.
> Secondly, another process, or another unit test using the same mechanism may well start as soon as the ServerSocket is closed and before the second server is started.
> Either of these conditions will cause a BindException, which we see frequently in failed unit tests.
> The proper mechanism to handle this is to start the desired server using port 0 to begin with, and then asking the server which port it's listening on once it's started.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)