neil / rpms / udisks2

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