|
|
5a151b |
From fbe970add68e6d9d998fb7f78377368c403e200d Mon Sep 17 00:00:00 2001
|
|
|
5a151b |
From: Tomas Bzatek <tbzatek@redhat.com>
|
|
|
5a151b |
Date: Mon, 31 Oct 2022 15:15:31 +0100
|
|
|
5a151b |
Subject: [PATCH] tests: Restart iscsid on every InitiatorName change
|
|
|
5a151b |
|
|
|
5a151b |
The test LIO target config expects a specific initiator name as set
|
|
|
5a151b |
by the ACLs. However the iscsid daemon only seems to be reading
|
|
|
5a151b |
the InitiatorName string on startup and in case the service is running
|
|
|
5a151b |
with a different name, the auth tests will fail.
|
|
|
5a151b |
|
|
|
5a151b |
As a workaround, restart the iscsid service after each change.
|
|
|
5a151b |
A proper way through libiscsi or libopeniscsiusr would be nice -> TODO.
|
|
|
5a151b |
---
|
|
|
5a151b |
src/tests/dbus-tests/test_30_iscsi.py | 12 ++++++++++++
|
|
|
5a151b |
1 file changed, 12 insertions(+)
|
|
|
5a151b |
|
|
|
5a151b |
diff --git a/src/tests/dbus-tests/test_30_iscsi.py b/src/tests/dbus-tests/test_30_iscsi.py
|
|
|
5a151b |
index f2594d992..09e975f30 100644
|
|
|
5a151b |
--- a/src/tests/dbus-tests/test_30_iscsi.py
|
|
|
5a151b |
+++ b/src/tests/dbus-tests/test_30_iscsi.py
|
|
|
5a151b |
@@ -48,9 +48,21 @@ def _force_lougout(self, target):
|
|
|
5a151b |
def _set_initiator_name(self):
|
|
|
5a151b |
manager = self.get_object('/Manager')
|
|
|
5a151b |
|
|
|
5a151b |
+ # make backup of INITIATOR_FILE and restore it at the end
|
|
|
5a151b |
+ try:
|
|
|
5a151b |
+ initiatorname_backup = self.read_file(INITIATOR_FILE)
|
|
|
5a151b |
+ self.addCleanup(self.write_file, INITIATOR_FILE, initiatorname_backup)
|
|
|
5a151b |
+ except FileNotFoundError as e:
|
|
|
5a151b |
+ # no existing file, simply remove it once finished
|
|
|
5a151b |
+ self.addCleanup(self.remove_file, INITIATOR_FILE, True)
|
|
|
5a151b |
+
|
|
|
5a151b |
manager.SetInitiatorName(self.initiator, self.no_options,
|
|
|
5a151b |
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator')
|
|
|
5a151b |
|
|
|
5a151b |
+ # running iscsid needs to be restarted to reflect the change
|
|
|
5a151b |
+ self.run_command('systemctl try-reload-or-restart iscsid.service')
|
|
|
5a151b |
+ # ignore the return code in case of non-systemd distros
|
|
|
5a151b |
+
|
|
|
5a151b |
init = manager.GetInitiatorName(self.no_options,
|
|
|
5a151b |
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator')
|
|
|
5a151b |
self.assertEqual(init, self.initiator)
|