We are draining dispatcher just before the new assertions but that does not guarantee that scheduler event is processed as scheduler events go into another queue. IIUC, sandflee was attempting to solve this in
YARN-5375 because currently there is no mechanism to wait till ensure scheduler event is processed. This leads to random test failures for several test cases. We can just wait on an event expected to be sent to RMApp or attempt, which wont be the case here.
As of now to fix this, we can simply loop over the condition and sleep till a certain timeout.