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
'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
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
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):