Skip to content

Commit

Permalink
tests: avoid empty socket
Browse files Browse the repository at this point in the history
A recent change in cpython broke autobind of abstract
unix socket in linux, causing bind calls with an
empty string to be bound to '\0' instead of a
random address (expected). This results in an
'address already in use' error when consecutive empty
string binding is used in the tests.

While this issue may get solved eventually, we
can change the test strategy and use the random
unique addresses in the abstract space, to create
unique sockets per test so that they do not collide,
and do not depend on the empty socket feature.

Related: python/cpython#94821
Signed-off-by: Albert Esteve <aesteve@redhat.com>
  • Loading branch information
aesteve-rh committed Jul 14, 2022
1 parent e189066 commit eef5c90
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion test/admin_tool_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
import subprocess
import time
import uuid

import pytest

Expand All @@ -31,7 +32,7 @@
port = 0
[local]
socket =
socket = {local_socket}
[control]
transport = {control_transport}
Expand All @@ -58,6 +59,7 @@ def srv(request, tmpdir_factory):

conf = DAEMON_CONF.format(
run_dir=str(tmp_dir),
local_socket=f"\0/org/ovirt/imageio/{uuid.uuid4()}",
control_transport=request.param,
control_port=random_port)
conf_file.write(conf)
Expand Down
3 changes: 0 additions & 3 deletions test/conf/daemon.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ buffer_size = 131072
[remote]
port = 0

[local]
socket =

[control]
transport = unix
socket = test/daemon.sock
Expand Down
4 changes: 3 additions & 1 deletion test/server_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os
import pwd
import subprocess
import uuid

import pytest

Expand Down Expand Up @@ -39,7 +40,7 @@
port = 0
[local]
socket =
socket = {local_socket}
[control]
transport = unix
Expand Down Expand Up @@ -202,6 +203,7 @@ def prepare_config(tmpdir, drop_privileges="true"):
drop_priv=drop_privileges,
user_name="nobody",
group_name="nobody",
local_socket=f"\0/org/ovirt/imageio/{uuid.uuid4()}",
)
tmpdir.join("conf", "conf.d", "daemon.conf").write(daemon_conf)

Expand Down

0 comments on commit eef5c90

Please sign in to comment.