Browse Source

Merge "Decouple NVMe tests from os-brick"

changes/10/680810/1
Zuul 1 week ago
parent
commit
c51187ab5b
1 changed files with 11 additions and 5 deletions
  1. 11
    5
      nova/tests/unit/virt/libvirt/volume/test_nvme.py

+ 11
- 5
nova/tests/unit/virt/libvirt/volume/test_nvme.py View File

@@ -15,16 +15,22 @@ import mock
15 15
 from nova.tests.unit.virt.libvirt.volume import test_volume
16 16
 from nova.virt.libvirt.volume import nvme
17 17
 
18
-from os_brick.initiator import connector
18
+from os_brick import initiator
19 19
 
20 20
 
21 21
 class LibvirtNVMEVolumeDriverTestCase(test_volume.LibvirtVolumeBaseTestCase):
22 22
 
23 23
     @mock.patch('os.path.exists', return_value=True)
24
-    def test_libvirt_nvme_driver(self, exists):
25
-        libvirt_driver = nvme.LibvirtNVMEVolumeDriver(self.fake_host)
26
-        self.assertIsInstance(libvirt_driver.connector,
27
-                              connector.NVMeConnector)
24
+    @mock.patch('nova.utils.get_root_helper')
25
+    @mock.patch('os_brick.initiator.connector.InitiatorConnector.factory')
26
+    def test_libvirt_nvme_driver(self, mock_factory, mock_helper, exists):
27
+        self.flags(num_nvme_discover_tries=3, group='libvirt')
28
+        mock_helper.return_value = 'sudo'
29
+
30
+        nvme.LibvirtNVMEVolumeDriver(self.fake_host)
31
+        mock_factory.assert_called_once_with(
32
+            initiator.NVME, 'sudo',
33
+            device_scan_attempts=3)
28 34
 
29 35
     def test_libvirt_nvme_driver_connect(self):
30 36
         nvme_driver = nvme.LibvirtNVMEVolumeDriver(self.fake_host)

Loading…
Cancel
Save