|
Tomas Bzatek |
6c6835 |
commit 68115b16181db7a38f852b101ec965b9fc3e59cb
|
|
Tomas Bzatek |
6c6835 |
Author: Tomas Bzatek <tbzatek@redhat.com>
|
|
Tomas Bzatek |
6c6835 |
Date: Thu Oct 20 17:32:29 2022 +0200
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
tests: Clean the discovered test target iscsid node cache
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
After each DiscoverSendTargets() and Login() calls iscsid caches
|
|
Tomas Bzatek |
6c6835 |
the node info in /var/lib/iscsi/nodes. That includes auth info and
|
|
Tomas Bzatek |
6c6835 |
passwords in plaintext. This might potentially lead to lingering
|
|
Tomas Bzatek |
6c6835 |
attributes sneaking into subsequent tests, affecting the results.
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
Let's clean that after each test run.
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
diff --git a/src/tests/dbus-tests/test_30_iscsi.py b/src/tests/dbus-tests/test_30_iscsi.py
|
|
Tomas Bzatek |
6c6835 |
index 6ac8386b..2b75462a 100644
|
|
Tomas Bzatek |
6c6835 |
--- a/src/tests/dbus-tests/test_30_iscsi.py
|
|
Tomas Bzatek |
6c6835 |
+++ b/src/tests/dbus-tests/test_30_iscsi.py
|
|
Tomas Bzatek |
6c6835 |
@@ -6,6 +6,7 @@ import os
|
|
Tomas Bzatek |
6c6835 |
import re
|
|
Tomas Bzatek |
6c6835 |
import six
|
|
Tomas Bzatek |
6c6835 |
import time
|
|
Tomas Bzatek |
6c6835 |
+import shutil
|
|
Tomas Bzatek |
6c6835 |
import unittest
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
@@ -26,6 +27,7 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
6c6835 |
chap_iqn = 'iqn.2003-01.udisks.test:iscsi-test-chap'
|
|
Tomas Bzatek |
6c6835 |
mutual_iqn = 'iqn.2003-01.udisks.test:iscsi-test-mutual'
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
+
|
|
Tomas Bzatek |
6c6835 |
# Define common D-Bus method call timeout that needs to be slightly longer
|
|
Tomas Bzatek |
6c6835 |
# than the corresponding timeout defined in libiscsi:
|
|
Tomas Bzatek |
6c6835 |
# #define ISCSID_REQ_TIMEOUT 1000
|
|
Tomas Bzatek |
6c6835 |
@@ -61,6 +63,10 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
6c6835 |
initiator = bytearray(data)
|
|
Tomas Bzatek |
6c6835 |
return initiator.strip().split(b"InitiatorName=")[1]
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
+ def _clean_iscsid_node_dir(self):
|
|
Tomas Bzatek |
6c6835 |
+ for iqn in [self.noauth_iqn, self.chap_iqn, self.mutual_iqn]:
|
|
Tomas Bzatek |
6c6835 |
+ shutil.rmtree(os.path.join('/var/lib/iscsi/nodes/', iqn), ignore_errors=True)
|
|
Tomas Bzatek |
6c6835 |
+
|
|
Tomas Bzatek |
6c6835 |
def test__manager_interface(self):
|
|
Tomas Bzatek |
6c6835 |
'''Test for module D-Bus Manager interface presence'''
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
@@ -86,6 +92,7 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
6c6835 |
nodes, _ = manager.DiscoverSendTargets(self.address, self.port, self.no_options,
|
|
Tomas Bzatek |
6c6835 |
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
|
Tomas Bzatek |
6c6835 |
timeout=self.iscsi_timeout)
|
|
Tomas Bzatek |
6c6835 |
+ self.addCleanup(self._clean_iscsid_node_dir)
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
node = next((node for node in nodes if node[0] == self.noauth_iqn), None)
|
|
Tomas Bzatek |
6c6835 |
self.assertIsNotNone(node)
|
|
Tomas Bzatek |
6c6835 |
@@ -131,6 +138,7 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
6c6835 |
nodes, _ = manager.DiscoverSendTargets(self.address, self.port, self.no_options,
|
|
Tomas Bzatek |
6c6835 |
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
|
Tomas Bzatek |
6c6835 |
timeout=self.iscsi_timeout)
|
|
Tomas Bzatek |
6c6835 |
+ self.addCleanup(self._clean_iscsid_node_dir)
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
node = next((node for node in nodes if node[0] == self.chap_iqn), None)
|
|
Tomas Bzatek |
6c6835 |
self.assertIsNotNone(node)
|
|
Tomas Bzatek |
6c6835 |
@@ -190,6 +198,7 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
6c6835 |
nodes, _ = manager.DiscoverSendTargets(self.address, self.port, self.no_options,
|
|
Tomas Bzatek |
6c6835 |
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
|
Tomas Bzatek |
6c6835 |
timeout=self.iscsi_timeout)
|
|
Tomas Bzatek |
6c6835 |
+ self.addCleanup(self._clean_iscsid_node_dir)
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
node = next((node for node in nodes if node[0] == self.mutual_iqn), None)
|
|
Tomas Bzatek |
6c6835 |
self.assertIsNotNone(node)
|
|
Tomas Bzatek |
6c6835 |
@@ -246,6 +255,7 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
6c6835 |
nodes, _ = manager.DiscoverSendTargets(self.address, self.port, self.no_options,
|
|
Tomas Bzatek |
6c6835 |
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
|
Tomas Bzatek |
6c6835 |
timeout=self.iscsi_timeout)
|
|
Tomas Bzatek |
6c6835 |
+ self.addCleanup(self._clean_iscsid_node_dir)
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
node = next((node for node in nodes if node[0] == self.noauth_iqn), None)
|
|
Tomas Bzatek |
6c6835 |
self.assertIsNotNone(node)
|
|
Tomas Bzatek |
6c6835 |
@@ -293,6 +303,7 @@ class UdisksISCSITest(udiskstestcase.UdisksTestCase):
|
|
Tomas Bzatek |
6c6835 |
nodes, _ = manager.DiscoverSendTargets(self.address, self.port, self.no_options,
|
|
Tomas Bzatek |
6c6835 |
dbus_interface=self.iface_prefix + '.Manager.ISCSI.Initiator',
|
|
Tomas Bzatek |
6c6835 |
timeout=self.iscsi_timeout)
|
|
Tomas Bzatek |
6c6835 |
+ self.addCleanup(self._clean_iscsid_node_dir)
|
|
Tomas Bzatek |
6c6835 |
|
|
Tomas Bzatek |
6c6835 |
node = next((node for node in nodes if node[0] == self.noauth_iqn), None)
|
|
Tomas Bzatek |
6c6835 |
self.assertIsNotNone(node)
|