/// <exception cref="System.IO.IOException"/> public virtual bool KillJob(JobID oldJobID) { JobId jobId = TypeConverter.ToYarn(oldJobID); KillJobRequest killRequest = recordFactory.NewRecordInstance <KillJobRequest>(); killRequest.SetJobId(jobId); Invoke("killJob", typeof(KillJobRequest), killRequest); return(true); }
public virtual void TestViewAclOnlyCannotModify() { TestMRClientService.MRAppWithClientService app = new TestMRClientService.MRAppWithClientService (this, 1, 0, false); Configuration conf = new Configuration(); conf.SetBoolean(MRConfig.MrAclsEnabled, true); conf.Set(MRJobConfig.JobAclViewJob, "viewonlyuser"); Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.Submit(conf); app.WaitForState(job, JobState.Running); NUnit.Framework.Assert.AreEqual("Num tasks not correct", 1, job.GetTasks().Count); IEnumerator <Task> it = job.GetTasks().Values.GetEnumerator(); Task task = it.Next(); app.WaitForState(task, TaskState.Running); TaskAttempt attempt = task.GetAttempts().Values.GetEnumerator().Next(); app.WaitForState(attempt, TaskAttemptState.Running); UserGroupInformation viewOnlyUser = UserGroupInformation.CreateUserForTesting("viewonlyuser" , new string[] { }); NUnit.Framework.Assert.IsTrue("viewonlyuser cannot view job", job.CheckAccess(viewOnlyUser , JobACL.ViewJob)); NUnit.Framework.Assert.IsFalse("viewonlyuser can modify job", job.CheckAccess(viewOnlyUser , JobACL.ModifyJob)); MRClientProtocol client = viewOnlyUser.DoAs(new _PrivilegedExceptionAction_223(conf , app)); KillJobRequest killJobRequest = recordFactory.NewRecordInstance <KillJobRequest>(); killJobRequest.SetJobId(app.GetJobId()); try { client.KillJob(killJobRequest); NUnit.Framework.Assert.Fail("viewonlyuser killed job"); } catch (AccessControlException) { } // pass KillTaskRequest killTaskRequest = recordFactory.NewRecordInstance <KillTaskRequest >(); killTaskRequest.SetTaskId(task.GetID()); try { client.KillTask(killTaskRequest); NUnit.Framework.Assert.Fail("viewonlyuser killed task"); } catch (AccessControlException) { } // pass KillTaskAttemptRequest killTaskAttemptRequest = recordFactory.NewRecordInstance <KillTaskAttemptRequest >(); killTaskAttemptRequest.SetTaskAttemptId(attempt.GetID()); try { client.KillTaskAttempt(killTaskAttemptRequest); NUnit.Framework.Assert.Fail("viewonlyuser killed task attempt"); } catch (AccessControlException) { } // pass FailTaskAttemptRequest failTaskAttemptRequest = recordFactory.NewRecordInstance <FailTaskAttemptRequest >(); failTaskAttemptRequest.SetTaskAttemptId(attempt.GetID()); try { client.FailTaskAttempt(failTaskAttemptRequest); NUnit.Framework.Assert.Fail("viewonlyuser killed task attempt"); } catch (AccessControlException) { } }