|
@@ -48,6 +48,7 @@ import org.apache.hadoop.mapreduce.v2.api.records.Counters;
|
|
|
import org.apache.hadoop.mapreduce.v2.api.records.JobReport;
|
|
|
import org.apache.hadoop.mapreduce.v2.api.records.JobState;
|
|
|
import org.apache.hadoop.mapreduce.v2.util.MRBuilderUtils;
|
|
|
+import org.apache.hadoop.security.authorize.AuthorizationException;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationReport;
|
|
@@ -182,6 +183,49 @@ public class TestClientServiceDelegate {
|
|
|
verify(amProxy, times(5)).getJobReport(any(GetJobReportRequest.class));
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testNoRetryOnAMAuthorizationException() throws Exception {
|
|
|
+ if (!isAMReachableFromClient) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ResourceMgrDelegate rm = mock(ResourceMgrDelegate.class);
|
|
|
+ when(rm.getApplicationReport(TypeConverter.toYarn(oldJobId).getAppId()))
|
|
|
+ .thenReturn(getRunningApplicationReport("am1", 78));
|
|
|
+
|
|
|
+ // throw authorization exception on first invocation
|
|
|
+ final MRClientProtocol amProxy = mock(MRClientProtocol.class);
|
|
|
+ when(amProxy.getJobReport(any(GetJobReportRequest.class)))
|
|
|
+ .thenThrow(new AuthorizationException("Denied"));
|
|
|
+ Configuration conf = new YarnConfiguration();
|
|
|
+ conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME);
|
|
|
+ conf.setBoolean(MRJobConfig.JOB_AM_ACCESS_DISABLED,
|
|
|
+ !isAMReachableFromClient);
|
|
|
+ ClientServiceDelegate clientServiceDelegate =
|
|
|
+ new ClientServiceDelegate(conf, rm, oldJobId, null) {
|
|
|
+ @Override
|
|
|
+ MRClientProtocol instantiateAMProxy(
|
|
|
+ final InetSocketAddress serviceAddr) throws IOException {
|
|
|
+ super.instantiateAMProxy(serviceAddr);
|
|
|
+ return amProxy;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ try {
|
|
|
+ clientServiceDelegate.getJobStatus(oldJobId);
|
|
|
+ Assert.fail("Exception should be thrown upon AuthorizationException");
|
|
|
+ } catch (IOException e) {
|
|
|
+ Assert.assertEquals(AuthorizationException.class.getName() + ": Denied",
|
|
|
+ e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // assert maxClientRetry is not decremented.
|
|
|
+ Assert.assertEquals(conf.getInt(MRJobConfig.MR_CLIENT_MAX_RETRIES,
|
|
|
+ MRJobConfig.DEFAULT_MR_CLIENT_MAX_RETRIES), clientServiceDelegate
|
|
|
+ .getMaxClientRetry());
|
|
|
+ verify(amProxy, times(1)).getJobReport(any(GetJobReportRequest.class));
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testHistoryServerNotConfigured() throws Exception {
|
|
|
//RM doesn't have app report and job History Server is not configured
|