I can verify that the test fails with trunk code. Thanks for the report.
However, I don't think startActiveServices() should check safe mode explicitly in the finally block. 1) The block manager safe mode is a state machine and once the NN leaves it, it should never enter again (unless requested by user). 2) The block manager safe mode should maintain the state machine automatically when loading edit logs. That's why we made the BlockManager.checkSafeMode() package local, instead of public. If there is any bug, we should fix it there.
So my gut feeling is that in BlockManagerSafeMode#checkSafeMode(), we wrongly bypass the internal state change if namesystem.inTransitionToActive() is true. Obviously this is related to
HDFS-7046. I'll debug the code for a fix.