|
@@ -24,6 +24,7 @@ import static org.junit.Assert.fail;
|
|
|
import static org.mockito.Matchers.any;
|
|
|
import static org.mockito.Mockito.doAnswer;
|
|
|
import static org.mockito.Mockito.doReturn;
|
|
|
+import static org.mockito.Mockito.doThrow;
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
import static org.mockito.Mockito.when;
|
|
|
|
|
@@ -673,7 +674,40 @@ public class TestDelegationTokenRenewer {
|
|
|
Thread.sleep(200);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Test(timeout=20000)
|
|
|
+ public void testDTRonAppSubmission()
|
|
|
+ throws IOException, InterruptedException, BrokenBarrierException {
|
|
|
+ final Credentials credsx = new Credentials();
|
|
|
+ final Token<?> tokenx = mock(Token.class);
|
|
|
+ credsx.addToken(new Text("token"), tokenx);
|
|
|
+ doReturn(true).when(tokenx).isManaged();
|
|
|
+ doThrow(new IOException("boom"))
|
|
|
+ .when(tokenx).renew(any(Configuration.class));
|
|
|
+ // fire up the renewer
|
|
|
+ final DelegationTokenRenewer dtr =
|
|
|
+ createNewDelegationTokenRenewer(conf, counter);
|
|
|
+ RMContext mockContext = mock(RMContext.class);
|
|
|
+ ClientRMService mockClientRMService = mock(ClientRMService.class);
|
|
|
+ when(mockContext.getClientRMService()).thenReturn(mockClientRMService);
|
|
|
+ InetSocketAddress sockAddr =
|
|
|
+ InetSocketAddress.createUnresolved("localhost", 1234);
|
|
|
+ when(mockClientRMService.getBindAddress()).thenReturn(sockAddr);
|
|
|
+ dtr.setRMContext(mockContext);
|
|
|
+ when(mockContext.getDelegationTokenRenewer()).thenReturn(dtr);
|
|
|
+ dtr.init(conf);
|
|
|
+ dtr.start();
|
|
|
+
|
|
|
+ try {
|
|
|
+ dtr.addApplicationSync(mock(ApplicationId.class), credsx, false);
|
|
|
+ fail("Catch IOException on app submission");
|
|
|
+ } catch (IOException e){
|
|
|
+ Assert.assertTrue(e.getMessage().contains(tokenx.toString()));
|
|
|
+ Assert.assertTrue(e.getCause().toString().contains("boom"));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Test(timeout=20000)
|
|
|
public void testConcurrentAddApplication()
|
|
|
throws IOException, InterruptedException, BrokenBarrierException {
|