The avocado.utils.network.find_free_port() will by default attempt
to return the first port given in the range, if it seems to be
available.

Let's reduce the probability of collisions by picking a random port
by default.

As a side note, this behavior has changed in a recent Avocado version,
and the default use will then be equivalent to this proposed change.

Reference: 
https://avocado-framework.readthedocs.io/en/68.0/api/utils/avocado.utils.html#avocado.utils.network.find_free_port
Reference: 
https://github.com/avocado-framework/avocado/commit/f232e4505f7cfefc513449e0b97790b517275da7
Signed-off-by: Cleber Rosa <cr...@redhat.com>
---
 tests/acceptance/migration.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/acceptance/migration.py b/tests/acceptance/migration.py
index a44c1ae58f..b2a5767348 100644
--- a/tests/acceptance/migration.py
+++ b/tests/acceptance/migration.py
@@ -25,7 +25,7 @@ class Migration(Test):
         return vm.command('query-migrate')['status'] in ('completed', 'failed')
 
     def _get_free_port(self):
-        port = network.find_free_port()
+        port = network.find_free_port(sequent=False)
         if port is None:
             self.cancel('Failed to find a free port')
         return port
-- 
2.21.0


Reply via email to