internal static string ToSerializedValue(this OnAllTasksComplete value) { switch (value) { case OnAllTasksComplete.NoAction: return("noaction"); case OnAllTasksComplete.TerminateJob: return("terminatejob"); } return(null); }
public void Bug1433069TestBoundJobCommit() { void test() { using BatchClient batchCli = TestUtilities.OpenBatchClient(TestUtilities.GetCredentialsFromEnvironment()); string jobId = Constants.DefaultConveniencePrefix + TestUtilities.GetMyName() + "-TestBoundJobCommit"; try { // // Create the job // CloudJob cloudJob = batchCli.JobOperations.CreateJob(jobId, new PoolInformation()); cloudJob.PoolInformation = new PoolInformation() { PoolId = poolFixture.PoolId }; testOutputHelper.WriteLine("Initial job schedule commit()"); cloudJob.Commit(); //Get the job CloudJob refreshableJob = batchCli.JobOperations.GetJob(jobId); //Update the bound job priority const int newJobPriority = 5; OnAllTasksComplete newOnAllTasksComplete = OnAllTasksComplete.NoAction; testOutputHelper.WriteLine("Job priority is: {0}", refreshableJob.Priority); refreshableJob.Priority = newJobPriority; refreshableJob.OnAllTasksComplete = newOnAllTasksComplete; refreshableJob.Commit(); AssertJobCorrectness(batchCli.JobOperations, jobId, ref refreshableJob, poolFixture.PoolId, newJobPriority, null); //Update the bound job pool name //Must disable the job first before updating its pool refreshableJob.Disable(DisableJobOption.Terminate); //Wait for job to reach disabled state (could go to Disabling for a bit) //TODO: Use a uBtilities wait helper here DateTime jobDisabledStateWaitStartTime = DateTime.UtcNow; TimeSpan jobDisabledTimeout = TimeSpan.FromSeconds(120); while (refreshableJob.State != JobState.Disabled) { testOutputHelper.WriteLine("Bug1433069TestBoundJobCommit: sleeping for (refreshableJob.State != JobState.Disabled)"); Thread.Sleep(TimeSpan.FromSeconds(10)); refreshableJob = batchCli.JobOperations.GetJob(jobId); if (DateTime.UtcNow > jobDisabledStateWaitStartTime.Add(jobDisabledTimeout)) { Assert.False(true, "Timed out waiting for job to go to disabled state"); } } const string newPoolId = "testPool"; refreshableJob.PoolInformation.PoolId = newPoolId; refreshableJob.Commit(); AssertJobCorrectness(batchCli.JobOperations, jobId, ref refreshableJob, newPoolId, newJobPriority, null); //Enable the job again refreshableJob.Enable(); //Update the bound job constraints JobConstraints newJobConstraints = new JobConstraints(TimeSpan.FromSeconds(200), 19); refreshableJob.Constraints = newJobConstraints; refreshableJob.Commit(); AssertJobCorrectness(batchCli.JobOperations, jobId, ref refreshableJob, newPoolId, newJobPriority, newJobConstraints); } finally { batchCli.JobOperations.DeleteJob(jobId); } } SynchronizationContextHelper.RunTest(test, TestTimeout); }
private static void AssertPatchableJobPropertiesCanBeWritten(CloudJob boundJob, int priority, MetadataItem metadataItem, OnAllTasksComplete onAllTasksComplete) { boundJob.Priority = priority + 1; Assert.Equal(priority + 1, boundJob.Priority); const string osFamily = "2"; const string virtualMachineSize = "4"; const string displayName = "Testing-pool"; boundJob.PoolInformation = new PoolInformation { AutoPoolSpecification = new AutoPoolSpecification { KeepAlive = false, PoolSpecification = new PoolSpecification { CloudServiceConfiguration = new CloudServiceConfiguration(osFamily), VirtualMachineSize = virtualMachineSize, DisplayName = displayName, } } }; Assert.Equal(false, boundJob.PoolInformation.AutoPoolSpecification.KeepAlive); Assert.Equal(osFamily, boundJob.PoolInformation.AutoPoolSpecification.PoolSpecification.CloudServiceConfiguration.OSFamily); Assert.Equal(virtualMachineSize, boundJob.PoolInformation.AutoPoolSpecification.PoolSpecification.VirtualMachineSize); Assert.Equal(displayName, boundJob.PoolInformation.AutoPoolSpecification.PoolSpecification.DisplayName); TimeSpan maxWallClockTime = new TimeSpan(0, 0, 0); boundJob.Constraints = new JobConstraints(maxWallClockTime, 2); Assert.Equal(2, boundJob.Constraints.MaxTaskRetryCount); Assert.Equal(maxWallClockTime, boundJob.Constraints.MaxWallClockTime); // Swap the value with the name and the name with the value. boundJob.Metadata = new[] { new MetadataItem(metadataItem.Value, metadataItem.Name) }; Assert.Equal(metadataItem.Name, boundJob.Metadata.First().Value); Assert.Equal(metadataItem.Value, boundJob.Metadata.First().Name); boundJob.OnAllTasksComplete = OnAllTasksComplete.TerminateJob; Assert.Equal(OnAllTasksComplete.TerminateJob, boundJob.OnAllTasksComplete); }
public static string ToSerialString(this OnAllTasksComplete value) => value switch {