You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/11/30 23:30:53 UTC

[GitHub] iilyak commented on a change in pull request #1774: Support for more than 3 nodes dev cluster

iilyak commented on a change in pull request #1774: Support for more than 3 nodes dev cluster
URL: https://github.com/apache/couchdb/pull/1774#discussion_r238033187
 
 

 ##########
 File path: dev/run
 ##########
 @@ -217,9 +249,42 @@ def apply_config_overrides(ctx, content):
     return content
 
 
-def get_ports(idnode):
+def get_ports(ctx, idnode):
     assert idnode
-    return ((10000 * idnode) + 5984, (10000 * idnode) + 5986)
+    if idnode <= 5 and not ctx['random_ports']:
+        return ((10000 * idnode) + 5984, (10000 * idnode) + 5986)
+    else:
+        return tuple(get_random_ports(2))
+
+
+def get_random_ports(num):
+    ports = []
+    while len(ports) < num:
+        with contextlib.closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as soc:
+            soc.bind(('localhost', 0))
+            _, port = soc.getsockname()
+            if port not in ports:
 
 Review comment:
   Don't want it to be not answered. This is run inside `while len(ports) < num:` loop. Which means we try to get port until we get `num` unique ports.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services