Skip to content

Commit

Permalink
Fix binding a socket to all network interfaces #270
Browse files Browse the repository at this point in the history
  • Loading branch information
giffels committed Nov 10, 2023
1 parent 7cb93e3 commit e6efd36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions tests/plugins_t/test_prometheusmonitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ def tearDownClass(cls):

@patch("tardis.plugins.prometheusmonitoring.logging", Mock())
def setUp(self):
ip = "127.0.0.1"
self.config = self.mock_config.return_value
self.config.Plugins.PrometheusMonitoring.addr = "127.0.0.1"
self.config.Plugins.PrometheusMonitoring.port = get_free_port()
self.config.Plugins.PrometheusMonitoring.addr = ip
self.config.Plugins.PrometheusMonitoring.port = get_free_port(ip)

self.plugin = PrometheusMonitoring()

Expand Down
4 changes: 2 additions & 2 deletions tests/utilities/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ def async_return(*args, return_value=None, **kwargs):
return f


def get_free_port(): # from https://gist.github.com/dbrgn/3979133
def get_free_port(ip: str): # from https://gist.github.com/dbrgn/3979133
s = socket.socket()
s.bind(("", 0))
s.bind((ip, 0))
port = s.getsockname()[1]
s.close()
return port
Expand Down

0 comments on commit e6efd36

Please sign in to comment.