mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-15 17:51:06 +00:00
5c9c9255d2
* Move to its own file * Unify self.args and self.params.args earlier so it can be inspected.
30 lines
901 B
Python
30 lines
901 B
Python
import pytest
|
|
|
|
|
|
def dfly_args(*args):
|
|
"""Used to define a singular set of arguments for dragonfly test"""
|
|
return pytest.mark.parametrize("df_factory", args, indirect=True)
|
|
|
|
|
|
def dfly_multi_test_args(*args):
|
|
"""Used to define multiple sets of arguments to test multiple dragonfly configurations"""
|
|
return pytest.mark.parametrize("df_factory", args, indirect=True)
|
|
|
|
|
|
class PortPicker:
|
|
"""A simple port manager to allocate available ports for tests"""
|
|
|
|
def __init__(self):
|
|
self.next_port = 5555
|
|
|
|
def get_available_port(self):
|
|
while not self.is_port_available(self.next_port):
|
|
self.next_port += 1
|
|
self.next_port += 1
|
|
return self.next_port - 1
|
|
|
|
def is_port_available(self, port):
|
|
import socket
|
|
|
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
return s.connect_ex(("localhost", port)) != 0
|