]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/mgr/test_progress: fix bug 48217 38107/head
authorKamoltat <ksirivad@redhat.com>
Mon, 16 Nov 2020 08:52:12 +0000 (08:52 +0000)
committerKamoltat <ksirivad@redhat.com>
Tue, 17 Nov 2020 07:54:35 +0000 (07:54 +0000)
Fixes a failing test case regarding osd coming back
after being marked out. The old test case wasn't accounting
for a specific event, therefore this resulted in the failure.
The fix basically accounts for a specific event of osd being
marked in/out.

Fixes: https://tracker.ceph.com/issues/48217
Signed-off-by: Kamoltat <ksirivad@redhat.com>
qa/tasks/mgr/test_progress.py

index fa73b951096c4b31c4e6c63f6d1ecc28f3cc596e..7f841e7fd8f6b96fccf9e530a4f52dec7d831986 100644 (file)
@@ -58,6 +58,29 @@ class TestProgress(MgrTestCase):
     def is_osd_marked_in(self, ev):
         return ev['message'].endswith('marked in')
 
+    def _get_osd_in_out_events(self, marked='both'):
+        """
+        Return the event that deals with OSDs being
+        marked in, out or both
+        """
+
+        marked_in_events = []
+        marked_out_events = []
+
+        events_in_progress = self._events_in_progress()
+        for ev in events_in_progress:
+            if self.is_osd_marked_out(ev):
+                marked_out_events.append(ev)
+            elif self.is_osd_marked_in(ev):
+                marked_in_events.append(ev)
+
+        if marked == 'both':
+            return [marked_in_events] + [marked_out_events]
+        elif marked == 'in':
+            return marked_in_events
+        else:
+            return marked_out_events
+
     def _osd_in_out_events_count(self, marked='both'):
         """
         Count the number of on going recovery events that deals with
@@ -164,9 +187,10 @@ class TestProgress(MgrTestCase):
                 'osd', 'out', str(osd_id))
 
         # Wait for a progress event to pop up
-        self.wait_until_equal(lambda: len(self._all_events()), 1,
-                              timeout=self.EVENT_CREATION_PERIOD)
-        ev = self._all_events()[0]
+        self.wait_until_equal(lambda: self._osd_in_out_events_count('out'), 1,
+                              timeout=self.EVENT_CREATION_PERIOD*2,
+                              period=1)
+        ev = self._get_osd_in_out_events('out')[0]
         log.info(json.dumps(ev, indent=1))
         self.assertIn("Rebalancing after osd.0 marked out", ev['message'])
         return ev
@@ -181,8 +205,9 @@ class TestProgress(MgrTestCase):
                              timeout=self.EVENT_CREATION_PERIOD)
         try:
             # Wait for progress event marked in to pop up
-            self.wait_until_equal(lambda: len(self._events_in_progress()), 1,
-                                  timeout=self.EVENT_CREATION_PERIOD)
+            self.wait_until_equal(lambda: self._osd_in_out_events_count('in'), 1,
+                                  timeout=self.EVENT_CREATION_PERIOD*2,
+                                  period=1)
         except RuntimeError as ex:
             if not "Timed out after" in str(ex):
                 raise ex
@@ -190,7 +215,7 @@ class TestProgress(MgrTestCase):
             log.info("There was no PGs affected by osd being marked in")
             return None
 
-        new_event = self._events_in_progress()[0]
+        new_event = self._get_osd_in_out_events('in')[0]
         return new_event
 
     def _is_quiet(self):