]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: retry test_rbd_wnbd.py fs operations 49618/head
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Tue, 3 Jan 2023 09:56:30 +0000 (11:56 +0200)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Wed, 4 Jan 2023 05:08:39 +0000 (07:08 +0200)
Certain FS related operations can fail, especially under load
(e.g. initializing partitions, volume formatting, etc).

For this reason, we're going to introduce some retries.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
qa/workunits/windows/test_rbd_wnbd.py

index 33572bd81473c72bb3476ef6e2acc87bdfc3f031..bca76c564ccd8d7c56634e26559ec7f094859364 100644 (file)
@@ -374,18 +374,33 @@ class RbdImage(object):
             self.remove()
 
     @Tracer.trace
-    def init_fs(self):
-        if not self.mapped:
-            raise CephTestException("Unable to create fs, image not mapped.")
+    @retry_decorator()
+    def _init_disk(self):
+        cmd = ("powershell.exe", "-command",
+               f"Get-Disk -Number {self.disk_number} | "
+               "Initialize-Disk")
+        execute(*cmd)
 
+    @Tracer.trace
+    @retry_decorator()
+    def _create_partition(self):
         cmd = ("powershell.exe", "-command",
                f"Get-Disk -Number {self.disk_number} | "
-               "Initialize-Disk -PassThru | "
-               "New-Partition -AssignDriveLetter -UseMaximumSize | "
-               "Format-Volume -Force -Confirm:$false")
+               "New-Partition -AssignDriveLetter -UseMaximumSize")
         execute(*cmd)
 
-        # Retrieve the drive letter.
+    @Tracer.trace
+    @retry_decorator()
+    def _format_volume(self):
+        cmd = (
+            "powershell.exe", "-command",
+             f"(Get-Partition -DiskNumber {self.disk_number}"
+             " | ? { $_.DriveLetter }) | Format-Volume -Force -Confirm:$false")
+        execute(*cmd)
+
+    @Tracer.trace
+    @retry_decorator()
+    def _get_drive_letter(self):
         cmd = (
             "powershell.exe", "-command",
             f"(Get-Partition -DiskNumber {self.disk_number}"
@@ -399,6 +414,16 @@ class RbdImage(object):
             raise CephTestException(
                 "Invalid drive letter received: %s" % self.drive_letter)
 
+    @Tracer.trace
+    def init_fs(self):
+        if not self.mapped:
+            raise CephTestException("Unable to create fs, image not mapped.")
+
+        self._init_disk()
+        self._create_partition()
+        self._format_volume()
+        self._get_drive_letter()
+
     @Tracer.trace
     def get_fs_capacity(self):
         if not self.drive_letter: