|
32 | 32 | import org.apache.hadoop.security.token.SecretManager; |
33 | 33 | import org.apache.hadoop.security.token.Token; |
34 | 34 | import org.apache.hadoop.security.token.TokenIdentifier; |
35 | | -import org.apache.hadoop.util.Progressable; |
| 35 | +import org.apache.hadoop.test.LambdaTestUtils; |
| 36 | +import org.apache.hadoop.util.Time; |
36 | 37 | import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; |
37 | 38 | import org.apache.hadoop.yarn.api.records.ApplicationId; |
38 | 39 | import org.apache.hadoop.yarn.api.records.ContainerId; |
|
49 | 50 | import org.apache.tez.dag.api.NamedEntityDescriptor; |
50 | 51 | import org.apache.tez.dag.api.TezConfiguration; |
51 | 52 | import org.apache.tez.dag.api.TezConstants; |
| 53 | +import org.apache.tez.dag.api.TezUncheckedException; |
52 | 54 | import org.apache.tez.dag.api.UserPayload; |
53 | 55 | import org.apache.tez.dag.api.records.DAGProtos; |
54 | 56 | import org.apache.tez.dag.api.records.DAGProtos.AMPluginDescriptorProto; |
|
67 | 69 | import org.junit.Before; |
68 | 70 | import org.junit.Test; |
69 | 71 | import org.mockito.ArgumentCaptor; |
| 72 | +import org.mockito.Mockito; |
70 | 73 |
|
71 | 74 | import java.io.ByteArrayInputStream; |
72 | 75 | import java.io.DataInput; |
73 | 76 | import java.io.DataInputStream; |
74 | 77 | import java.io.DataOutput; |
75 | 78 | import java.io.File; |
76 | | -import java.io.FileNotFoundException; |
77 | 79 | import java.io.FileOutputStream; |
78 | 80 | import java.io.IOException; |
79 | 81 | import java.lang.reflect.Field; |
80 | | -import java.net.URI; |
81 | 82 | import java.nio.ByteBuffer; |
| 83 | +import java.time.Instant; |
| 84 | +import java.util.Date; |
82 | 85 | import java.util.HashMap; |
83 | 86 | import java.util.LinkedList; |
84 | 87 | import java.util.List; |
@@ -493,6 +496,26 @@ public void testDagCredentialsWithMerge() throws Exception { |
493 | 496 | testDagCredentials(true); |
494 | 497 | } |
495 | 498 |
|
| 499 | + @Test |
| 500 | + public void testGetACLFailure() throws Exception { |
| 501 | + ApplicationId appId = ApplicationId.newInstance(1, 1); |
| 502 | + ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 2); |
| 503 | + DAGAppMasterForTest dam = new DAGAppMasterForTest(attemptId, true); |
| 504 | + TezConfiguration conf = new TezConfiguration(false); |
| 505 | + conf.setBoolean(TezConfiguration.DAG_RECOVERY_ENABLED, false); |
| 506 | + dam.init(conf); |
| 507 | + LambdaTestUtils.intercept(TezUncheckedException.class, |
| 508 | + "Cannot get ApplicationACLs before all services have started, The current service state is INITED", |
| 509 | + () -> dam.getContext().getApplicationACLs()); |
| 510 | + dam.start(); |
| 511 | + dam.stop(); |
| 512 | + Mockito.when(dam.mockShutdown.getShutdownTime()).thenReturn(Date.from(Instant.ofEpochMilli(Time.now()))); |
| 513 | + LambdaTestUtils.intercept(TezUncheckedException.class, |
| 514 | + " Cannot get ApplicationACLs before all services have started, " |
| 515 | + + "The current service state is STOPPED. The shutdown hook started at " |
| 516 | + + dam.mockShutdown.getShutdownTime(), () -> dam.getContext().getApplicationACLs()); |
| 517 | + } |
| 518 | + |
496 | 519 | @Test |
497 | 520 | public void testBadProgress() throws Exception { |
498 | 521 | TezConfiguration conf = new TezConfiguration(); |
|
0 commit comments