本文整理汇总了C#中Microsoft.Azure.Commands.Batch.Test.ScenarioTests.BatchController类的典型用法代码示例。如果您正苦于以下问题:C# BatchController类的具体用法?C# BatchController怎么用?C# BatchController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BatchController类属于Microsoft.Azure.Commands.Batch.Test.ScenarioTests命名空间,在下文中一共展示了BatchController类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetBatchAccountContextWithKeys
/// <summary>
/// Get Batch Context with keys
/// </summary>
public static BatchAccountContext GetBatchAccountContextWithKeys(BatchController controller, string accountName)
{
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
BatchAccountContext context = client.ListKeys(null, accountName);
return context;
}
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:10,代码来源:ScenarioTestHelpers.cs
示例2: CreateTestAccountAndResourceGroup
/// <summary>
/// Creates an account and resource group for use with the Scenario tests
/// </summary>
public static BatchAccountContext CreateTestAccountAndResourceGroup(BatchController controller, string resourceGroupName, string accountName, string location)
{
controller.ResourceManagementClient.ResourceGroups.CreateOrUpdate(resourceGroupName, new ResourceGroup() { Location = location });
BatchAccountCreateResponse createResponse = controller.BatchManagementClient.Accounts.Create(resourceGroupName, accountName, new BatchAccountCreateParameters() { Location = location });
BatchAccountContext context = BatchAccountContext.ConvertAccountResourceToNewAccountContext(createResponse.Resource);
BatchAccountListKeyResponse response = controller.BatchManagementClient.Accounts.ListKeys(resourceGroupName, accountName);
context.PrimaryAccountKey = response.PrimaryKey;
context.SecondaryAccountKey = response.SecondaryKey;
return context;
}
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:13,代码来源:ScenarioTestHelpers.cs
示例3: DeleteComputeNodeUser
/// <summary>
/// Deletes a compute node user for use in Scenario tests.
/// </summary>
public static void DeleteComputeNodeUser(BatchController controller, BatchAccountContext context, string poolId, string computeNodeId, string computeNodeUserName)
{
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
ComputeNodeUserOperationParameters parameters = new ComputeNodeUserOperationParameters(context, poolId, computeNodeId, computeNodeUserName);
client.DeleteComputeNodeUser(parameters);
}
开发者ID:kjohn-msft,项目名称:azure-powershell,代码行数:11,代码来源:ScenarioTestHelpers.cs
示例4: CleanupTestAccount
/// <summary>
/// Cleans up an account and resource group used in a Scenario test.
/// </summary>
public static void CleanupTestAccount(BatchController controller, string resourceGroupName, string accountName)
{
controller.BatchManagementClient.Accounts.Delete(resourceGroupName, accountName);
controller.ResourceManagementClient.ResourceGroups.Delete(resourceGroupName);
}
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:8,代码来源:ScenarioTestHelpers.cs
示例5: WaitForIdleComputeNode
/// <summary>
/// Waits for a compute node to get to the idle state
/// </summary>
public static void WaitForIdleComputeNode(BatchController controller, BatchAccountContext context, string poolId, string computeNodeId)
{
RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
ListComputeNodeOptions options = new ListComputeNodeOptions(context, poolId, null, behaviors)
{
ComputeNodeId = computeNodeId
};
DateTime timeout = DateTime.Now.AddMinutes(2);
PSComputeNode computeNode = client.ListComputeNodes(options).First();
if (computeNode.State != ComputeNodeState.Idle)
{
if (DateTime.Now > timeout)
{
throw new TimeoutException("Timed out waiting for idle compute node");
}
Sleep(5000);
computeNode = client.ListComputeNodes(options).First();
}
}
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:27,代码来源:ScenarioTestHelpers.cs
示例6: DeleteJob
/// <summary>
/// Deletes a job used in a Scenario test.
/// </summary>
public static void DeleteJob(BatchController controller, BatchAccountContext context, string jobId)
{
RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
client.DeleteJob(context, jobId, behaviors);
}
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:11,代码来源:ScenarioTestHelpers.cs
示例7: CreateTestTask
/// <summary>
/// Creates a test task for use in Scenario tests.
/// </summary>
public static void CreateTestTask(BatchController controller, BatchAccountContext context, string jobId, string taskId, string cmdLine = "cmd /c dir /s")
{
RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
NewTaskParameters parameters = new NewTaskParameters(context, jobId, null, taskId, behaviors)
{
CommandLine = cmdLine,
RunElevated = true
};
client.CreateTask(parameters);
}
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:17,代码来源:ScenarioTestHelpers.cs
示例8: CreateTestJob
/// <summary>
/// Creates a test job for use in Scenario tests.
/// </summary>
public static void CreateTestJob(BatchController controller, BatchAccountContext context, string jobId)
{
RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
PSPoolInformation poolInfo = new PSPoolInformation();
poolInfo.PoolId = SharedPool;
NewJobParameters parameters = new NewJobParameters(context, jobId, behaviors)
{
PoolInformation = poolInfo
};
client.CreateJob(parameters);
}
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:19,代码来源:ScenarioTestHelpers.cs
示例9: CreateTestUser
/// <summary>
/// Creates a test user for use in Scenario tests.
/// </summary>
public static void CreateTestUser(BatchController controller, BatchAccountContext context, string poolName, string vmName, string vmUserName)
{
YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
NewVMUserParameters parameters = new NewVMUserParameters(context, poolName, vmName, null, behaviors)
{
VMUserName = vmUserName,
Password = "Password1234!",
};
client.CreateVMUser(parameters);
}
开发者ID:shuainie,项目名称:azure-powershell,代码行数:17,代码来源:ScenarioTestHelpers.cs
示例10: DeleteWorkItem
/// <summary>
/// Deletes a workitem used in a Scenario test.
/// </summary>
public static void DeleteWorkItem(BatchController controller, BatchAccountContext context, string workItemName)
{
YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
client.DeleteWorkItem(context, workItemName, behaviors);
}
开发者ID:shuainie,项目名称:azure-powershell,代码行数:11,代码来源:ScenarioTestHelpers.cs
示例11: WaitForTaskCompletion
/// <summary>
/// Waits for the specified task to complete
/// </summary>
public static void WaitForTaskCompletion(BatchController controller, BatchAccountContext context, string workItemName, string jobName, string taskName)
{
YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
ListTaskOptions options = new ListTaskOptions(context, workItemName, jobName, null, behaviors)
{
TaskName = taskName
};
IEnumerable<PSCloudTask> tasks = client.ListTasks(options);
ITaskStateMonitor monitor = context.BatchOMClient.OpenToolbox().CreateTaskStateMonitor();
monitor.WaitAll(tasks.Select(t => t.omObject), TaskState.Completed, TimeSpan.FromMinutes(2), null, behaviors);
}
开发者ID:shuainie,项目名称:azure-powershell,代码行数:18,代码来源:ScenarioTestHelpers.cs
示例12: WaitForRecentJob
/// <summary>
/// Waits for a recent job on a workitem and returns its name. If a previous job is specified, this method waits until a new job is created.
/// </summary>
public static string WaitForRecentJob(BatchController controller, BatchAccountContext context, string workItemName, string previousJob = null)
{
DateTime timeout = DateTime.Now.AddMinutes(2);
YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
ListWorkItemOptions options = new ListWorkItemOptions(context, behaviors)
{
WorkItemName = workItemName,
Filter = null,
MaxCount = Constants.DefaultMaxCount
};
PSCloudWorkItem workItem = client.ListWorkItems(options).First();
while (workItem.ExecutionInformation.RecentJob == null || string.Equals(workItem.ExecutionInformation.RecentJob.Name, previousJob, StringComparison.OrdinalIgnoreCase))
{
if (DateTime.Now > timeout)
{
throw new TimeoutException("Timed out waiting for recent job");
}
Sleep(5000);
workItem = client.ListWorkItems(options).First();
}
return workItem.ExecutionInformation.RecentJob.Name;
}
开发者ID:shuainie,项目名称:azure-powershell,代码行数:30,代码来源:ScenarioTestHelpers.cs
示例13: CreateTestWorkItem
/// <summary>
/// Creates a test workitem for use in Scenario tests.
/// </summary>
public static void CreateTestWorkItem(BatchController controller, BatchAccountContext context, string workItemName)
{
CreateTestWorkItem(controller, context, workItemName, null);
}
开发者ID:shuainie,项目名称:azure-powershell,代码行数:7,代码来源:ScenarioTestHelpers.cs
示例14: AddTestCertificate
/// <summary>
/// Adds a test certificate for use in Scenario tests. Returns the thumbprint of the cert.
/// </summary>
public static string AddTestCertificate(BatchController controller, BatchAccountContext context, string filePath)
{
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
X509Certificate2 cert = new X509Certificate2(filePath);
ListCertificateOptions getParameters = new ListCertificateOptions(context)
{
ThumbprintAlgorithm = BatchTestHelpers.TestCertificateAlgorithm,
Thumbprint = cert.Thumbprint,
Select = "thumbprint,state"
};
try
{
PSCertificate existingCert = client.ListCertificates(getParameters).FirstOrDefault();
DateTime start = DateTime.Now;
DateTime end = start.AddMinutes(5);
// Cert might still be deleting from other tests, so we wait for the delete to finish.
while (existingCert != null && existingCert.State == CertificateState.Deleting)
{
if (DateTime.Now > end)
{
throw new TimeoutException("Timed out waiting for existing cert to be deleted.");
}
Sleep(5000);
existingCert = client.ListCertificates(getParameters).FirstOrDefault();
}
}
catch (AggregateException ex)
{
foreach (Exception inner in ex.InnerExceptions)
{
BatchException batchEx = inner as BatchException;
// When the cert doesn't exist, we get a 404 error. For all other errors, throw.
if (batchEx == null || !batchEx.Message.Contains("CertificateNotFound"))
{
throw;
}
}
}
NewCertificateParameters parameters = new NewCertificateParameters(context, null, cert.RawData);
client.AddCertificate(parameters);
return cert.Thumbprint;
}
开发者ID:kjohn-msft,项目名称:azure-powershell,代码行数:51,代码来源:ScenarioTestHelpers.cs
示例15: GetPoolCount
/// <summary>
/// Gets the number of pools under the specified account
/// </summary>
public static int GetPoolCount(BatchController controller, BatchAccountContext context)
{
RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
ListPoolOptions options = new ListPoolOptions(context, behaviors);
return client.ListPools(options).Count();
}
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:13,代码来源:ScenarioTestHelpers.cs
示例16: CreateTestJobSchedule
/// <summary>
/// Creates a test job schedule for use in Scenario tests.
/// </summary>
public static void CreateTestJobSchedule(BatchController controller, BatchAccountContext context, string jobScheduleId, TimeSpan? recurrenceInterval)
{
RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
PSJobSpecification jobSpecification = new PSJobSpecification();
jobSpecification.PoolInformation = new PSPoolInformation();
jobSpecification.PoolInformation.PoolId = SharedPool;
PSSchedule schedule = new PSSchedule();
if (recurrenceInterval != null)
{
schedule = new PSSchedule();
schedule.RecurrenceInterval = recurrenceInterval;
}
NewJobScheduleParameters parameters = new NewJobScheduleParameters(context, jobScheduleId, behaviors)
{
JobSpecification = jobSpecification,
Schedule = schedule
};
client.CreateJobSchedule(parameters);
}
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:27,代码来源:ScenarioTestHelpers.cs
示例17: DeleteUser
/// <summary>
/// Deletes a user used in a Scenario test.
/// </summary>
public static void DeleteUser(BatchController controller, BatchAccountContext context, string poolName, string vmName, string vmUserName)
{
YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
VMUserOperationParameters parameters = new VMUserOperationParameters(context, poolName, vmName, vmUserName, behaviors);
client.DeleteVMUser(parameters);
}
开发者ID:shuainie,项目名称:azure-powershell,代码行数:12,代码来源:ScenarioTestHelpers.cs
示例18: WaitForRecentJob
/// <summary>
/// Waits for a recent job on a job schedule and returns its id. If a previous job is specified, this method waits until a new job is created.
/// </summary>
public static string WaitForRecentJob(BatchController controller, BatchAccountContext context, string jobScheduleId, string previousJob = null)
{
DateTime timeout = DateTime.Now.AddMinutes(2);
RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
ListJobScheduleOptions options = new ListJobScheduleOptions(context, behaviors)
{
JobScheduleId = jobScheduleId,
Filter = null,
MaxCount = Constants.DefaultMaxCount
};
PSCloudJobSchedule jobSchedule = client.ListJobSchedules(options).First();
while (jobSchedule.ExecutionInformation.RecentJob == null || string.Equals(jobSchedule.ExecutionInformation.RecentJob.Id, previousJob, StringComparison.OrdinalIgnoreCase))
{
if (DateTime.Now > timeout)
{
throw new TimeoutException("Timed out waiting for recent job");
}
Sleep(5000);
jobSchedule = client.ListJobSchedules(options).First();
}
return jobSchedule.ExecutionInformation.RecentJob.Id;
}
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:29,代码来源:ScenarioTestHelpers.cs
示例19: CreateTestPool
/// <summary>
/// Creates a test pool for use in Scenario tests.
/// </summary>
public static void CreateTestPool(BatchController controller, BatchAccountContext context, string poolName)
{
YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
NewPoolParameters parameters = new NewPoolParameters(context, poolName, behaviors)
{
OSFamily = "4",
TargetOSVersion = "*",
TargetDedicated = 1
};
client.CreatePool(parameters);
}
开发者ID:shuainie,项目名称:azure-powershell,代码行数:18,代码来源:ScenarioTestHelpers.cs
示例20: WaitForTaskCompletion
/// <summary>
/// Waits for the specified task to complete
/// </summary>
public static void WaitForTaskCompletion(BatchController controller, BatchAccountContext context, string jobId, string taskId)
{
RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
ListTaskOptions options = new ListTaskOptions(context, jobId, null, behaviors)
{
TaskId = taskId
};
IEnumerable<PSCloudTask> tasks = client.ListTasks(options);
// Save time by not waiting during playback scenarios
if (HttpMockServer.Mode == HttpRecorderMode.Record)
{
TaskStateMonitor monitor = context.BatchOMClient.Utilities.CreateTaskStateMonitor();
monitor.WaitAll(tasks.Select(t => t.omObject), TaskState.Completed, TimeSpan.FromMinutes(2), null);
}
}
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:22,代码来源:ScenarioTestHelpers.cs
注:本文中的Microsoft.Azure.Commands.Batch.Test.ScenarioTests.BatchController类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论