|
14 | 14 |
|
15 | 15 | package org.apache.tez.dag.app; |
16 | 16 |
|
17 | | -import org.apache.hadoop.yarn.util.MonotonicClock; |
18 | | -import org.apache.tez.dag.app.dag.DAGState; |
19 | | -import org.apache.tez.dag.app.dag.Vertex; |
20 | | -import org.apache.tez.dag.records.TezVertexID; |
21 | | -import static org.junit.Assert.assertEquals; |
22 | | -import static org.junit.Assert.assertNotNull; |
23 | | -import static org.junit.Assert.assertNull; |
24 | | -import static org.junit.Assert.assertTrue; |
25 | | -import static org.mockito.Mockito.mock; |
26 | | -import static org.mockito.Mockito.spy; |
27 | | -import static org.mockito.Mockito.verify; |
28 | | -import static org.mockito.Mockito.when; |
29 | | - |
30 | | -import java.io.ByteArrayInputStream; |
31 | | -import java.io.DataInput; |
32 | | -import java.io.DataInputStream; |
33 | | -import java.io.DataOutput; |
34 | | -import java.io.File; |
35 | | -import java.io.FileOutputStream; |
36 | | -import java.io.IOException; |
37 | | -import java.nio.ByteBuffer; |
38 | | -import java.util.HashMap; |
39 | | -import java.util.LinkedList; |
40 | | -import java.util.List; |
41 | | -import java.util.Map; |
42 | | - |
43 | | -import org.apache.tez.common.Preconditions; |
44 | 17 | import com.google.common.collect.BiMap; |
45 | 18 | import com.google.common.collect.HashBiMap; |
46 | 19 | import com.google.common.collect.Lists; |
47 | 20 | import com.google.protobuf.ByteString; |
48 | | - |
49 | 21 | import org.apache.hadoop.conf.Configuration; |
| 22 | +import org.apache.hadoop.fs.FSDataInputStream; |
50 | 23 | import org.apache.hadoop.fs.FSDataOutputStream; |
| 24 | +import org.apache.hadoop.fs.FileStatus; |
51 | 25 | import org.apache.hadoop.fs.FileSystem; |
52 | 26 | import org.apache.hadoop.fs.FileUtil; |
53 | 27 | import org.apache.hadoop.fs.Path; |
| 28 | +import org.apache.hadoop.fs.permission.FsPermission; |
54 | 29 | import org.apache.hadoop.io.Text; |
55 | 30 | import org.apache.hadoop.security.Credentials; |
56 | 31 | import org.apache.hadoop.security.UserGroupInformation; |
57 | 32 | import org.apache.hadoop.security.token.SecretManager; |
58 | 33 | import org.apache.hadoop.security.token.Token; |
59 | 34 | import org.apache.hadoop.security.token.TokenIdentifier; |
| 35 | +import org.apache.hadoop.util.Progressable; |
60 | 36 | import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; |
61 | 37 | import org.apache.hadoop.yarn.api.records.ApplicationId; |
62 | 38 | import org.apache.hadoop.yarn.api.records.ContainerId; |
| 39 | +import org.apache.hadoop.yarn.util.MonotonicClock; |
63 | 40 | import org.apache.hadoop.yarn.util.SystemClock; |
64 | 41 | import org.apache.tez.client.TezApiVersionInfo; |
| 42 | +import org.apache.tez.common.Preconditions; |
65 | 43 | import org.apache.tez.common.TezCommonUtils; |
66 | 44 | import org.apache.tez.common.TezUtils; |
67 | 45 | import org.apache.tez.common.security.JobTokenIdentifier; |
|
78 | 56 | import org.apache.tez.dag.api.records.DAGProtos.PlanLocalResourcesProto; |
79 | 57 | import org.apache.tez.dag.api.records.DAGProtos.TezNamedEntityDescriptorProto; |
80 | 58 | import org.apache.tez.dag.api.records.DAGProtos.TezUserPayloadProto; |
| 59 | +import org.apache.tez.dag.app.dag.DAGState; |
| 60 | +import org.apache.tez.dag.app.dag.Vertex; |
81 | 61 | import org.apache.tez.dag.app.dag.impl.DAGImpl; |
82 | 62 | import org.apache.tez.dag.app.rm.TaskSchedulerManager; |
83 | 63 | import org.apache.tez.dag.records.TezDAGID; |
| 64 | +import org.apache.tez.dag.records.TezVertexID; |
84 | 65 | import org.junit.After; |
85 | 66 | import org.junit.Assert; |
86 | 67 | import org.junit.Before; |
87 | 68 | import org.junit.Test; |
88 | 69 |
|
| 70 | +import java.io.ByteArrayInputStream; |
| 71 | +import java.io.DataInput; |
| 72 | +import java.io.DataInputStream; |
| 73 | +import java.io.DataOutput; |
| 74 | +import java.io.File; |
| 75 | +import java.io.FileNotFoundException; |
| 76 | +import java.io.FileOutputStream; |
| 77 | +import java.io.IOException; |
| 78 | +import java.lang.reflect.Field; |
| 79 | +import java.net.URI; |
| 80 | +import java.nio.ByteBuffer; |
| 81 | +import java.util.HashMap; |
| 82 | +import java.util.LinkedList; |
| 83 | +import java.util.List; |
| 84 | +import java.util.Map; |
| 85 | + |
| 86 | +import static org.junit.Assert.assertEquals; |
| 87 | +import static org.junit.Assert.assertNotNull; |
| 88 | +import static org.junit.Assert.assertNull; |
| 89 | +import static org.junit.Assert.assertTrue; |
| 90 | +import static org.mockito.ArgumentMatchers.any; |
| 91 | +import static org.mockito.Mockito.mock; |
| 92 | +import static org.mockito.Mockito.spy; |
| 93 | +import static org.mockito.Mockito.verify; |
| 94 | +import static org.mockito.Mockito.when; |
| 95 | + |
89 | 96 | public class TestDAGAppMaster { |
90 | 97 |
|
91 | 98 | private static final String TEST_KEY = "TEST_KEY"; |
@@ -332,6 +339,90 @@ public void testParseAllPluginsCustomAndYarnSpecified() throws IOException { |
332 | 339 | assertEquals(TC_NAME + CLASS_SUFFIX, tcDescriptors.get(1).getClassName()); |
333 | 340 | } |
334 | 341 |
|
| 342 | + @Test |
| 343 | + public void testShutdownTezAMWithMissingRecovery() throws Exception { |
| 344 | + |
| 345 | + TezConfiguration conf = new TezConfiguration(); |
| 346 | + conf.setBoolean(TezConfiguration.TEZ_AM_CREDENTIALS_MERGE, true); |
| 347 | + conf.setBoolean(TezConfiguration.TEZ_LOCAL_MODE, true); |
| 348 | + conf.set(TezConfiguration.TEZ_AM_STAGING_DIR, TEST_DIR.toString()); |
| 349 | + conf.setBoolean(TezConfiguration.TEZ_AM_FAILURE_ON_MISSING_RECOVERY, true); |
| 350 | + conf.setBoolean(TezConfiguration.DAG_RECOVERY_ENABLED, true); |
| 351 | + ApplicationId appId = ApplicationId.newInstance(1, 1); |
| 352 | + ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 2); |
| 353 | + |
| 354 | + FileSystem spyRecoveryFs = spy(new FileSystem() { |
| 355 | + @Override |
| 356 | + public URI getUri() { |
| 357 | + return null; |
| 358 | + } |
| 359 | + |
| 360 | + @Override |
| 361 | + public FSDataInputStream open(Path path, int i) throws IOException { |
| 362 | + return null; |
| 363 | + } |
| 364 | + |
| 365 | + @Override |
| 366 | + public FSDataOutputStream create(Path path, FsPermission fsPermission, boolean b, int i, short i1, long l, Progressable progressable) throws IOException { |
| 367 | + return null; |
| 368 | + } |
| 369 | + |
| 370 | + @Override |
| 371 | + public FSDataOutputStream append(Path path, int i, Progressable progressable) throws IOException { |
| 372 | + return null; |
| 373 | + } |
| 374 | + |
| 375 | + @Override |
| 376 | + public boolean rename(Path path, Path path1) throws IOException { |
| 377 | + return false; |
| 378 | + } |
| 379 | + |
| 380 | + @Override |
| 381 | + public boolean delete(Path path, boolean b) throws IOException { |
| 382 | + return false; |
| 383 | + } |
| 384 | + |
| 385 | + @Override |
| 386 | + public FileStatus[] listStatus(Path path) throws FileNotFoundException, IOException { |
| 387 | + return new FileStatus[0]; |
| 388 | + } |
| 389 | + |
| 390 | + @Override |
| 391 | + public void setWorkingDirectory(Path path) { |
| 392 | + |
| 393 | + } |
| 394 | + |
| 395 | + @Override |
| 396 | + public Path getWorkingDirectory() { |
| 397 | + return null; |
| 398 | + } |
| 399 | + |
| 400 | + @Override |
| 401 | + public boolean mkdirs(Path path, FsPermission fsPermission) throws IOException { |
| 402 | + return false; |
| 403 | + } |
| 404 | + |
| 405 | + @Override |
| 406 | + public FileStatus getFileStatus(Path path) throws IOException { |
| 407 | + return null; |
| 408 | + } |
| 409 | + }); |
| 410 | + when(spyRecoveryFs.exists(any())).thenReturn(false); |
| 411 | + |
| 412 | + DAGAppMasterForTest dam = new DAGAppMasterForTest(attemptId, true); |
| 413 | + dam.init(conf); |
| 414 | + dam.start(); |
| 415 | + |
| 416 | + Field field = DAGAppMasterForTest.class.getSuperclass().getDeclaredField("recoveryFS"); |
| 417 | + field.setAccessible(true); |
| 418 | + field.set(dam, spyRecoveryFs); |
| 419 | + |
| 420 | + verify(dam.mockScheduler).setShouldUnregisterFlag(); |
| 421 | + verify(dam.mockShutdown).shutdown(); |
| 422 | + |
| 423 | + assertEquals(DAGAppMasterState.ERROR, dam.getState()); |
| 424 | + } |
| 425 | + |
335 | 426 | private void verifyDescAndMap(List<NamedEntityDescriptor> descriptors, BiMap<String, Integer> map, |
336 | 427 | int numExpected, boolean verifyPayload, |
337 | 428 | String... expectedNames) throws |
|
0 commit comments