|
@@ -42,7 +42,7 @@ import org.junit.*;
|
|
|
* failure.
|
|
|
*/
|
|
|
|
|
|
-public class TestRecoveryManager extends TestCase {
|
|
|
+public class TestRecoveryManager {
|
|
|
private static final Log LOG =
|
|
|
LogFactory.getLog(TestRecoveryManager.class);
|
|
|
private static final Path TEST_DIR =
|
|
@@ -52,7 +52,8 @@ public class TestRecoveryManager extends TestCase {
|
|
|
private JobConf conf;
|
|
|
private MiniMRCluster mr;
|
|
|
|
|
|
- protected void setUp() {
|
|
|
+ @Before
|
|
|
+ public void setUp() {
|
|
|
JobConf conf = new JobConf();
|
|
|
try {
|
|
|
fs = FileSystem.get(new Configuration());
|
|
@@ -65,7 +66,8 @@ public class TestRecoveryManager extends TestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- protected void tearDown() {
|
|
|
+ @After
|
|
|
+ public void tearDown() {
|
|
|
ClusterStatus status = mr.getJobTrackerRunner().getJobTracker()
|
|
|
.getClusterStatus(false);
|
|
|
if (status.getJobTrackerState() == JobTracker.State.RUNNING) {
|
|
@@ -82,6 +84,8 @@ public class TestRecoveryManager extends TestCase {
|
|
|
* - restarts the jobtracker
|
|
|
* - checks if the jobtraker starts normally
|
|
|
*/
|
|
|
+ @Test
|
|
|
+ @Ignore
|
|
|
public void testJobTrackerRestartsWithMissingJobFile() throws Exception {
|
|
|
LOG.info("Testing jobtracker restart with faulty job");
|
|
|
String signalFile = new Path(TEST_DIR, "signal").toString();
|
|
@@ -142,7 +146,7 @@ public class TestRecoveryManager extends TestCase {
|
|
|
mr.getJobTrackerRunner().getJobTracker().getClusterStatus(false);
|
|
|
|
|
|
// check if the jobtracker came up or not
|
|
|
- assertEquals("JobTracker crashed!",
|
|
|
+ Assert.assertEquals("JobTracker crashed!",
|
|
|
JobTracker.State.RUNNING, status.getJobTrackerState());
|
|
|
}
|
|
|
|
|
@@ -152,7 +156,8 @@ public class TestRecoveryManager extends TestCase {
|
|
|
* - kills the jobtracker
|
|
|
* - checks if the jobtraker starts normally and job is recovered while
|
|
|
*/
|
|
|
-
|
|
|
+ @Test
|
|
|
+ @Ignore
|
|
|
public void testJobResubmission() throws Exception {
|
|
|
LOG.info("Testing Job Resubmission");
|
|
|
String signalFile = new Path(TEST_DIR, "signal").toString();
|
|
@@ -189,7 +194,8 @@ public class TestRecoveryManager extends TestCase {
|
|
|
jobtracker = mr.getJobTrackerRunner().getJobTracker();
|
|
|
|
|
|
// assert that job is recovered by the jobtracker
|
|
|
- assertEquals("Resubmission failed ", 1, jobtracker.getAllJobs().length);
|
|
|
+ Assert.assertEquals("Resubmission failed ", 1,
|
|
|
+ jobtracker.getAllJobs().length);
|
|
|
JobInProgress jip = jobtracker.getJob(rJob1.getID());
|
|
|
while (!jip.isComplete()) {
|
|
|
LOG.info("Waiting for job " + rJob1.getID() + " to be successful");
|
|
@@ -197,7 +203,7 @@ public class TestRecoveryManager extends TestCase {
|
|
|
fs.create(new Path(TEST_DIR, "signal"));
|
|
|
UtilsForTests.waitFor(100);
|
|
|
}
|
|
|
- assertTrue("Task should be successful", rJob1.isSuccessful());
|
|
|
+ Assert.assertTrue("Task should be successful", rJob1.isSuccessful());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -212,6 +218,8 @@ public class TestRecoveryManager extends TestCase {
|
|
|
* - checks if the jobtraker starts normally and job#2 is recovered while
|
|
|
* job#1 is failed.
|
|
|
*/
|
|
|
+ @Test
|
|
|
+ @Ignore
|
|
|
public void testJobTrackerRestartWithBadJobs() throws Exception {
|
|
|
LOG.info("Testing recovery-manager");
|
|
|
String signalFile = new Path(TEST_DIR, "signal").toString();
|
|
@@ -306,18 +314,18 @@ public class TestRecoveryManager extends TestCase {
|
|
|
jobtracker = mr.getJobTrackerRunner().getJobTracker();
|
|
|
|
|
|
// assert that job2 is recovered by the jobtracker as job1 would fail
|
|
|
- assertEquals("Recovery manager failed to tolerate job failures", 1,
|
|
|
+ Assert.assertEquals("Recovery manager failed to tolerate job failures", 1,
|
|
|
jobtracker.getAllJobs().length);
|
|
|
|
|
|
// check if the job#1 has failed
|
|
|
JobStatus status = jobtracker.getJobStatus(rJob1.getID());
|
|
|
- assertNull("Faulty job should not be resubmitted", status);
|
|
|
+ Assert.assertNull("Faulty job should not be resubmitted", status);
|
|
|
|
|
|
jip = jobtracker.getJob(rJob2.getID());
|
|
|
- assertFalse("Job should be running", jip.isComplete());
|
|
|
+ Assert.assertFalse("Job should be running", jip.isComplete());
|
|
|
|
|
|
status = jobtracker.getJobStatus(rJob3.getID());
|
|
|
- assertNull("Job should be missing because of ACL changed", status);
|
|
|
+ Assert.assertNull("Job should be missing because of ACL changed", status);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -333,6 +341,7 @@ public class TestRecoveryManager extends TestCase {
|
|
|
* - garble the jobtracker.info file and restart he jobtracker, the
|
|
|
* jobtracker should crash.
|
|
|
*/
|
|
|
+ @Test
|
|
|
public void testRestartCount() throws Exception {
|
|
|
LOG.info("Testing Job Restart Count");
|
|
|
String signalFile = new Path(TEST_DIR, "signal").toString();
|
|
@@ -376,8 +385,8 @@ public class TestRecoveryManager extends TestCase {
|
|
|
|
|
|
// assert if restart count is correct
|
|
|
// It should always be 0 now as its resubmit everytime then restart.
|
|
|
- assertEquals("Recovery manager failed to recover restart count", 0, jip
|
|
|
- .getNumRestarts());
|
|
|
+ Assert.assertEquals("Recovery manager failed to recover restart count",
|
|
|
+ 0, jip.getNumRestarts());
|
|
|
}
|
|
|
|
|
|
// kill the old job
|
|
@@ -396,7 +405,7 @@ public class TestRecoveryManager extends TestCase {
|
|
|
|
|
|
// assert if restart count is correct
|
|
|
jip = jobtracker.getJob(rJob2.getID());
|
|
|
- assertEquals("Restart count for new job is incorrect", 0, jip
|
|
|
+ Assert.assertEquals("Restart count for new job is incorrect", 0, jip
|
|
|
.getNumRestarts());
|
|
|
|
|
|
LOG.info("Stopping jobtracker for testing the fs errors");
|
|
@@ -413,7 +422,7 @@ public class TestRecoveryManager extends TestCase {
|
|
|
LOG.info("Starting jobtracker with fs errors");
|
|
|
mr.startJobTracker();
|
|
|
JobTrackerRunner runner = mr.getJobTrackerRunner();
|
|
|
- assertFalse("JobTracker is still alive", runner.isActive());
|
|
|
+ Assert.assertFalse("JobTracker is still alive", runner.isActive());
|
|
|
|
|
|
}
|
|
|
|
|
@@ -421,6 +430,7 @@ public class TestRecoveryManager extends TestCase {
|
|
|
* Test if the jobtracker waits for the info file to be created before
|
|
|
* starting.
|
|
|
*/
|
|
|
+ @Test
|
|
|
public void testJobTrackerInfoCreation() throws Exception {
|
|
|
LOG.info("Testing jobtracker.info file");
|
|
|
MiniDFSCluster dfs = new MiniDFSCluster(new Configuration(), 1, true, null);
|
|
@@ -436,6 +446,10 @@ public class TestRecoveryManager extends TestCase {
|
|
|
conf.set("mapred.job.tracker.http.address", "127.0.0.1:0");
|
|
|
|
|
|
JobTracker jobtracker = new JobTracker(conf);
|
|
|
+ jobtracker.setSafeModeInternal(JobTracker.SafeModeAction.SAFEMODE_ENTER);
|
|
|
+ jobtracker.initializeFilesystem();
|
|
|
+ jobtracker.setSafeModeInternal(JobTracker.SafeModeAction.SAFEMODE_LEAVE);
|
|
|
+ jobtracker.initialize();
|
|
|
|
|
|
// now check if the update restart count works fine or not
|
|
|
boolean failed = false;
|
|
@@ -444,14 +458,15 @@ public class TestRecoveryManager extends TestCase {
|
|
|
} catch (IOException ioe) {
|
|
|
failed = true;
|
|
|
}
|
|
|
- assertTrue("JobTracker created info files without datanodes!!!", failed);
|
|
|
+ Assert.assertTrue("JobTracker created info files without datanodes!!!",
|
|
|
+ failed);
|
|
|
|
|
|
Path restartFile = jobtracker.recoveryManager.getRestartCountFile();
|
|
|
Path tmpRestartFile = jobtracker.recoveryManager.getTempRestartCountFile();
|
|
|
FileSystem fs = dfs.getFileSystem();
|
|
|
- assertFalse("Info file exists after update failure",
|
|
|
+ Assert.assertFalse("Info file exists after update failure",
|
|
|
fs.exists(restartFile));
|
|
|
- assertFalse("Temporary restart-file exists after update failure",
|
|
|
+ Assert.assertFalse("Temporary restart-file exists after update failure",
|
|
|
fs.exists(restartFile));
|
|
|
|
|
|
// start 1 data node
|
|
@@ -464,6 +479,7 @@ public class TestRecoveryManager extends TestCase {
|
|
|
} catch (IOException ioe) {
|
|
|
failed = true;
|
|
|
}
|
|
|
- assertFalse("JobTracker failed to create info files with datanodes!!!", failed);
|
|
|
+ Assert.assertFalse("JobTracker failed to create info files with datanodes!",
|
|
|
+ failed);
|
|
|
}
|
|
|
}
|