File tree Expand file tree Collapse file tree
integration-test/src/test/java/org/apache/hadoop/ozone/om
ozone-manager/src/main/java/org/apache/hadoop/ozone/om Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -876,8 +876,13 @@ public void testInstallSnapshotWithClientRead() throws Exception {
876876 long leaderOMSnapshotTermIndex = leaderOMTermIndex .getTerm ();
877877
878878 // Start the inactive OM. Checkpoint installation will happen spontaneously.
879+ OzoneManager .setTestInstallSnapshot (true );
879880 cluster .startInactiveOM (followerNodeId );
880881 LogCapturer logCapture = LogCapturer .captureLogs (OzoneManager .class );
882+ assertLogCapture (logCapture , "OzoneManager is not in running state" );
883+ assertLogCapture (logCapture , "Abort install snapshot from Leader" );
884+ GenericTestUtils .waitFor (followerOM ::isRunning , 100 , 30_000 );
885+ OzoneManager .setTestInstallSnapshot (false );
881886
882887 // Continuously read keys
883888 ExecutorService executor = Executors .newFixedThreadPool (1 );
Original file line number Diff line number Diff line change @@ -488,6 +488,7 @@ public final class OzoneManager extends ServiceRuntimeInfoImpl
488488 private static boolean testReloadConfigFlag = false ;
489489 private static boolean testSecureOmFlag = false ;
490490 private static UserGroupInformation testUgi ;
491+ private static boolean testInstallSnapshot = false ;
491492
492493 private final OzoneLockProvider ozoneLockProvider ;
493494 private final OMPerformanceMetrics perfMetrics ;
@@ -4063,6 +4064,12 @@ public List<OzoneAcl> getAcl(OzoneObj obj) throws IOException {
40634064 * @throws IOException if download or cleanup fails
40644065 */
40654066 public synchronized TermIndex installSnapshotFromLeader (String leaderId ) throws IOException {
4067+ if (!isRunning () || testInstallSnapshot ) {
4068+ LOG .warn ("OzoneManager is not in running state, state {}. Abort install snapshot from Leader." ,
4069+ omState );
4070+ return null ;
4071+ }
4072+
40664073 if (omRatisSnapshotProvider == null ) {
40674074 LOG .error ("OM Snapshot Provider is not configured as there are no peer " +
40684075 "nodes." );
@@ -4511,6 +4518,10 @@ public static void setTestReloadConfigFlag(boolean testReloadConfigFlag) {
45114518 OzoneManager .testReloadConfigFlag = testReloadConfigFlag ;
45124519 }
45134520
4521+ public static void setTestInstallSnapshot (boolean testInstallSnapshot ) {
4522+ OzoneManager .testInstallSnapshot = testInstallSnapshot ;
4523+ }
4524+
45144525 public static void setTestSecureOmFlag (boolean testSecureOmFlag ) {
45154526 OzoneManager .testSecureOmFlag = testSecureOmFlag ;
45164527 }
You can’t perform that action at this time.
0 commit comments