public void Bug1432987CloudTaskTaskConstraints()
        {
            using BatchClient batchCli = ClientUnitTestCommon.CreateDummyClient();
            CloudTask badTask = new CloudTask("bug1432987TaskConstraints", "hostname");

            TaskConstraints isThisBroken   = badTask.Constraints;
            TaskConstraints trySettingThem = new TaskConstraints(null, null, null);

            badTask.Constraints = trySettingThem;

            TaskConstraints readThemBack = badTask.Constraints;
        }
示例#2
0
        public void Bug1432987CloudTaskTaskConstraints()
        {
            using (BatchClient batchCli = BatchClient.Open(ClientUnitTestCommon.CreateDummySharedKeyCredential()))
            {
                CloudTask badTask = new CloudTask("bug1432987TaskConstraints", "hostname");

                TaskConstraints isThisBroken   = badTask.Constraints;
                TaskConstraints trySettingThem = new TaskConstraints(null, null, null);

                badTask.Constraints = trySettingThem;

                TaskConstraints readThemBack = badTask.Constraints;
            }
        }
        public static void DisplayJobScheduleLong(ITestOutputHelper testOutputHelper, CloudJobSchedule curWI)
        {
            // job schedule top level simple properties
            testOutputHelper.WriteLine("Id:  " + curWI.Id);
            testOutputHelper.WriteLine("       State: " + curWI.State.ToString());
            testOutputHelper.WriteLine("       " + "URL: " + curWI.Url);
            testOutputHelper.WriteLine("       " + "LastModified: " + (curWI.LastModified.HasValue ? curWI.LastModified.Value.ToLongDateString() : "<null>"));

            // execution INFO
            {
                JobScheduleExecutionInformation wiExInfo = curWI.ExecutionInformation;

                testOutputHelper.WriteLine("       ExeInfo:");
                testOutputHelper.WriteLine("               LastUpdateTime: " + (wiExInfo.EndTime.HasValue ? wiExInfo.EndTime.Value.ToLongDateString() : "<null>"));
                testOutputHelper.WriteLine("               NextRuntime: " + (wiExInfo.NextRunTime.HasValue ? wiExInfo.NextRunTime.Value.ToLongDateString() : "<null>"));
                testOutputHelper.WriteLine("               RecentJob:");

                // RecentJob
                RecentJob rj = wiExInfo.RecentJob;

                if (null == rj)
                {
                    testOutputHelper.WriteLine(" <null>");
                }
                else
                {
                    testOutputHelper.WriteLine("                         Id: " + rj.Id);
                    testOutputHelper.WriteLine("                         Url: " + rj.Url);
                }
            }

            // JobSpecification
            JobSpecification jobSpec = curWI.JobSpecification;

            testOutputHelper.WriteLine("       JobSpecification:");

            if (null == jobSpec)
            {
                testOutputHelper.WriteLine(" <null>");
            }
            else
            {
                testOutputHelper.WriteLine("");
                testOutputHelper.WriteLine("           Priority: " + (jobSpec.Priority.HasValue ? jobSpec.Priority.ToString() : "<null>"));

                JobConstraints jobCon = jobSpec.Constraints;

                testOutputHelper.WriteLine("           Constraints: ");

                if (null == jobCon)
                {
                    testOutputHelper.WriteLine("null");
                }
                else
                {
                    testOutputHelper.WriteLine("");
                    testOutputHelper.WriteLine("             MaxTaskRetryCount: " + (jobCon.MaxTaskRetryCount.HasValue ? jobSpec.Constraints.MaxTaskRetryCount.Value.ToString() : "<null>"));
                    testOutputHelper.WriteLine("             MaxWallClockTime: " + (jobCon.MaxWallClockTime.HasValue ? jobSpec.Constraints.MaxWallClockTime.Value.TotalMilliseconds.ToString() : "<null>"));
                }

                JobManagerTask ijm = jobSpec.JobManagerTask;

                if (null == ijm)
                {
                    testOutputHelper.WriteLine("<null>");
                }
                else
                {
                    testOutputHelper.WriteLine("           JobManagerTask:");
                    testOutputHelper.WriteLine("               CommandLine        : " + ijm.CommandLine);
                    testOutputHelper.WriteLine("               KillJobOnCompletion: " + (ijm.KillJobOnCompletion.HasValue ? ijm.KillJobOnCompletion.Value.ToString() : "<null>"));
                    testOutputHelper.WriteLine("               Id                 : " + ijm.Id);
                    testOutputHelper.WriteLine("               RunExclusive       : " + (ijm.RunExclusive.HasValue ? ijm.RunExclusive.Value.ToString() : "<null>"));

                    IEnumerable <EnvironmentSetting> envSettings = ijm.EnvironmentSettings;

                    if (null != envSettings)
                    {
                        List <EnvironmentSetting> envSettingsList = new List <EnvironmentSetting>(ijm.EnvironmentSettings);
                        testOutputHelper.WriteLine("               EnvironmentSettings.count:" + envSettingsList.Count);
                    }
                    else
                    {
                        testOutputHelper.WriteLine("               EnvironmentSettings: <null>");
                    }

                    IEnumerable <ResourceFile> resFilesProp = ijm.ResourceFiles;

                    if (null != resFilesProp)
                    {
                        List <ResourceFile> resFiles = new List <ResourceFile>();
                        testOutputHelper.WriteLine("               ResourceFiles.count:" + resFiles.Count);
                    }
                    else
                    {
                        testOutputHelper.WriteLine("               ResourceFiles: <null>");
                    }

                    TaskConstraints tc = ijm.Constraints;

                    if (null == tc)
                    {
                        testOutputHelper.WriteLine("               TaskConstraints: <null>");
                    }
                    else
                    {
                        testOutputHelper.WriteLine("               TaskConstraints: ");
                        testOutputHelper.WriteLine("                   MaxTaskRetryCount: " + (tc.MaxTaskRetryCount.HasValue ? tc.MaxTaskRetryCount.Value.ToString() : "<null>"));
                        testOutputHelper.WriteLine("                   MaxWallClockTime: " + (tc.MaxWallClockTime.HasValue ? tc.MaxWallClockTime.Value.TotalMilliseconds.ToString() : "<null>"));
                        testOutputHelper.WriteLine("                   RetentionTime: " + (tc.RetentionTime.HasValue ? tc.RetentionTime.Value.TotalMilliseconds.ToString() : "<null>"));
                    }

                    if (ijm.UserIdentity != null)
                    {
                        testOutputHelper.WriteLine("               UserIdentity: ");
                        testOutputHelper.WriteLine("                   UserName: "******"                   ElevationLevel: ", ijm.UserIdentity.AutoUser?.ElevationLevel);
                        testOutputHelper.WriteLine("                   Scope: ", ijm.UserIdentity.AutoUser?.Scope);
                    }
                }
            }


            // metadata
            {
                IEnumerable <MetadataItem> mdis = curWI.Metadata;

                testOutputHelper.WriteLine("       Metadata: ");

                if (null == mdis)
                {
                    testOutputHelper.WriteLine("<null>");
                }
                else
                {
                    List <MetadataItem> meta = new List <MetadataItem>(curWI.Metadata);

                    testOutputHelper.WriteLine(" count:" + meta.Count);
                }
            }

            // schedule
            Schedule sched = curWI.Schedule;

            if (null == sched)
            {
                testOutputHelper.WriteLine("       Schedule: <null>");
            }
            else
            {
                testOutputHelper.WriteLine("       Schedule:");
                testOutputHelper.WriteLine("           DoNotRunAfter:" + (sched.DoNotRunAfter.HasValue ? sched.DoNotRunAfter.Value.ToLongDateString() : "<null>"));
                testOutputHelper.WriteLine("           DoNotRunUntil: " + (sched.DoNotRunUntil.HasValue ? sched.DoNotRunUntil.Value.ToLongDateString() : "<null>"));
                testOutputHelper.WriteLine("           RecurrenceInterval: " + (sched.RecurrenceInterval.HasValue ? sched.RecurrenceInterval.Value.TotalMilliseconds.ToString() : "<null>"));
                testOutputHelper.WriteLine("           StartWindow       :" + (sched.StartWindow.HasValue ? sched.StartWindow.Value.TotalMilliseconds.ToString() : "<null>"));
            }

            // stats
            JobScheduleStatistics stats = curWI.Statistics;

            if (null == stats)
            {
                testOutputHelper.WriteLine("       Stats: <null>");
            }
            else
            {
                testOutputHelper.WriteLine("       Stats:");
                testOutputHelper.WriteLine("           LastUpdateTime: " + stats.LastUpdateTime.ToLongDateString());
                testOutputHelper.WriteLine("           KernelCPUTime: " + stats.KernelCpuTime.TotalMilliseconds.ToString());
                testOutputHelper.WriteLine("           NumFailedTasks: " + stats.FailedTaskCount.ToString());
                testOutputHelper.WriteLine("           NumTimesCalled    : " + stats.TaskRetryCount);
                testOutputHelper.WriteLine("           NumSucceededTasks: " + stats.SucceededTaskCount);
                testOutputHelper.WriteLine("           ReadIOGiB      : " + stats.ReadIOGiB);
                testOutputHelper.WriteLine("           ReadIOps         : " + stats.ReadIOps);
                testOutputHelper.WriteLine("           StartTime        : " + stats.StartTime.ToLongDateString());
                testOutputHelper.WriteLine("           Url              : " + stats.Url);
                testOutputHelper.WriteLine("           UserCpuTime      : " + stats.UserCpuTime.TotalMilliseconds.ToString());
                testOutputHelper.WriteLine("           WaitTime         : " + stats.WaitTime.TotalMilliseconds.ToString());
                testOutputHelper.WriteLine("           WallClockTime    : " + stats.WallClockTime.TotalMilliseconds.ToString());
                testOutputHelper.WriteLine("           WriteIOGiB     : " + stats.WriteIOGiB);
                testOutputHelper.WriteLine("           WriteIOps        : " + stats.WriteIOps);
            }
        }
 internal TaskUpdateParameter(TaskConstraints constraints)
 {
     Constraints = constraints;
 }
示例#5
0
 /// <summary>
 /// Updates the properties of the specified Task.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='jobId'>
 /// The ID of the Job containing the Task.
 /// </param>
 /// <param name='taskId'>
 /// The ID of the Task to update.
 /// </param>
 /// <param name='constraints'>
 /// Constraints that apply to this Task. If omitted, the Task is given the
 /// default constraints. For multi-instance Tasks, updating the retention time
 /// applies only to the primary Task and not subtasks.
 /// </param>
 /// <param name='taskUpdateOptions'>
 /// Additional parameters for the operation
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <TaskUpdateHeaders> UpdateAsync(this ITaskOperations operations, string jobId, string taskId, TaskConstraints constraints = default(TaskConstraints), TaskUpdateOptions taskUpdateOptions = default(TaskUpdateOptions), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdateWithHttpMessagesAsync(jobId, taskId, constraints, taskUpdateOptions, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Headers);
     }
 }
示例#6
0
 /// <summary>
 /// Updates the properties of the specified Task.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='jobId'>
 /// The ID of the Job containing the Task.
 /// </param>
 /// <param name='taskId'>
 /// The ID of the Task to update.
 /// </param>
 /// <param name='constraints'>
 /// Constraints that apply to this Task. If omitted, the Task is given the
 /// default constraints. For multi-instance Tasks, updating the retention time
 /// applies only to the primary Task and not subtasks.
 /// </param>
 /// <param name='taskUpdateOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static TaskUpdateHeaders Update(this ITaskOperations operations, string jobId, string taskId, TaskConstraints constraints = default(TaskConstraints), TaskUpdateOptions taskUpdateOptions = default(TaskUpdateOptions))
 {
     return(operations.UpdateAsync(jobId, taskId, constraints, taskUpdateOptions).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Updates the properties of the specified task.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='jobId'>
 /// The id of the job containing the task.
 /// </param>
 /// <param name='taskId'>
 /// The id of the task to update.
 /// </param>
 /// <param name='constraints'>
 /// Constraints that apply to this task. If omitted, the task is given the
 /// default constraints.
 /// </param>
 /// <param name='taskUpdateOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static TaskUpdateHeaders Update(this ITaskOperations operations, string jobId, string taskId, TaskConstraints constraints = default(TaskConstraints), TaskUpdateOptions taskUpdateOptions = default(TaskUpdateOptions))
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((ITaskOperations)s).UpdateAsync(jobId, taskId, constraints, taskUpdateOptions), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }