public void TestContainerTask() { void test() { using BatchClient client = TestUtilities.OpenBatchClient(TestUtilities.GetCredentialsFromEnvironment()); string jobId = "ContainerJob" + TestUtilities.GetMyName(); try { CloudJob job = client.JobOperations.CreateJob(jobId, new PoolInformation { PoolId = poolFixture.PoolId }); job.Commit(); CloudTask newTask = new CloudTask("a", "cat /etc/centos-release") { ContainerSettings = new TaskContainerSettings("centos") }; client.JobOperations.AddTask(jobId, newTask); IPagedEnumerable <CloudTask> tasks = client.JobOperations.ListTasks(jobId); TaskStateMonitor monitor = client.Utilities.CreateTaskStateMonitor(); monitor.WaitAll(tasks, TaskState.Completed, TimeSpan.FromMinutes(7)); CloudTask task = tasks.Single(); task.Refresh(); Assert.Equal("ContainerPoolNotSupported", task.ExecutionInformation.FailureInformation.Code); } finally { TestUtilities.DeleteJobIfExistsAsync(client, jobId).Wait(); } } SynchronizationContextHelper.RunTest(test, TimeSpan.FromMinutes(10)); }
public void Bug1996130_JobTaskVerbsFailAfterDoubleRefresh() { void test() { using BatchClient batchCli = TestUtilities.OpenBatchClient(TestUtilities.GetCredentialsFromEnvironment()); string jobId = "Bug1996130Job-" + TestUtilities.GetMyName(); try { // get a job/task to test. use workflow CloudJob boundJob = null; { // need a bound job/task for the tests so set one up CloudJob tsh = batchCli.JobOperations.CreateJob(jobId, new PoolInformation()); tsh.PoolInformation.PoolId = poolFixture.PoolId; tsh.Commit(); boundJob = batchCli.JobOperations.GetJob(jobId); boundJob.AddTask(new CloudTask("Bug1996130_task", "cmd /c hostname")); } // test task double refresh { // get the task CloudTask boundTask = batchCli.JobOperations.ListTasks(jobId).First(); // double refresh boundTask.Refresh(); boundTask.Refresh(); // this branch of the bug actually fixed in the other doublerefesh checkin by matthchr // do verbs boundTask.Refresh(); boundTask.Delete(); Thread.Sleep(5000); // give server time to do its deed List <CloudTask> tasks = batchCli.JobOperations.ListTasks(jobId).ToList(); // confirm delete suceeded Assert.Empty(tasks); } // test job double refresh and verbs { boundJob = batchCli.JobOperations.GetJob(jobId); // double refresh to taint the instance... lost path variable boundJob.Refresh(); boundJob.Refresh(); // this used to fail/throw boundJob.Refresh(); // this should fail but does not boundJob.Delete(); // yet another verb that suceeds CloudJob job = batchCli.JobOperations.ListJobs().ToList().FirstOrDefault(j => j.Id == jobId); // confirm job delete suceeded Assert.True(job == null || (JobState.Deleting == job.State)); } } finally { TestUtilities.DeleteJobIfExistsAsync(batchCli, jobId).Wait(); } } SynchronizationContextHelper.RunTest(test, TestTimeout); }