public Task RunCompose(StartJobRequest request, int jobId) { JobDescription jobDescription = CreateJobDescription(request, jobId); return(Task.Run(() => { using (IServiceScope scope = _serviceProvider.CreateScope()) { List <Task <HttpResponseMessage> > calls = new List <Task <HttpResponseMessage> >(); foreach (Endpoint endpoint in _composerSettings.Value.Endpoints) { for (int i = 0; i < endpoint.Concurrency; i++) { calls.Add(CallEndpoint(endpoint, jobDescription)); } Task.WaitAll(calls.ToArray()); IJobService jobService = scope.ServiceProvider.GetService <IJobService>(); // Set the entire job as completed jobService.MarkJobAsComplete(jobId); IQueues queues = scope.ServiceProvider.GetService <IQueues>(); queues.DeleteQueue(jobId); } } })); }
internal virtual StartJobResponse StartJob(StartJobRequest request) { var marshaller = StartJobRequestMarshaller.Instance; var unmarshaller = StartJobResponseUnmarshaller.Instance; return(Invoke <StartJobRequest, StartJobResponse>(request, marshaller, unmarshaller)); }
public virtual async Task <StartJobResponse> StartJobAsync([FromBody] StartJobRequest request) { if (request == null) { throw new InvalidOperationException("request can't be empty"); } if (string.IsNullOrEmpty(request.JobClassName) == true) { throw new ArgumentNullException("request.JobClassName"); } var job = GetJobByClassName(request.JobClassName); if (job == null) { throw new InvalidOperationException($"Can't find job by name = {request.JobClassName}"); } var isStarted = job.IsRunning == false; await job.StartAsync(new CancellationToken()); return(new StartJobResponse { IsStarted = isStarted }); }
public ActionResult <string> InitiateJob([FromBody] StartJobRequest request) { if (request == null) { throw new ArgumentException("Invalid request"); } // Get a list of tests //List<TestInfo> tests = await _testListService.ListTests(new TestRequestDescription { TestRunCommand = request.TestRunCommand, TestRunImage = request.TestRunImage}); List <TestInfo> tests = new List <TestInfo> { new TestInfo { FullName = "WebTests.NavigateFeature.NavigateToSpecflow" } }; // Create the job Job job = _jobService.CreateJob("NONE", tests); // Enqueue the tests _queues.EnqueueTests(job); // Call the compose endpoints #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed _composerService.RunCompose(request, job.JobId).ConfigureAwait(false); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed // Return the polling url return(PollUrl(job.JobId, 0)); }
/// <summary> /// Initiates the asynchronous execution of the StartJob operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the StartJob operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/amplify-2017-07-25/StartJob">REST API Reference for StartJob Operation</seealso> public virtual Task <StartJobResponse> StartJobAsync(StartJobRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = StartJobRequestMarshaller.Instance; var unmarshaller = StartJobResponseUnmarshaller.Instance; return(InvokeAsync <StartJobRequest, StartJobResponse>(request, marshaller, unmarshaller, cancellationToken)); }
/// <summary> /// Initiates the asynchronous execution of the StartJob operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the StartJob operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/amplify-2017-07-25/StartJob">REST API Reference for StartJob Operation</seealso> public virtual Task <StartJobResponse> StartJobAsync(StartJobRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = StartJobRequestMarshaller.Instance; options.ResponseUnmarshaller = StartJobResponseUnmarshaller.Instance; return(InvokeAsync <StartJobResponse>(request, options, cancellationToken)); }
internal virtual StartJobResponse StartJob(StartJobRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = StartJobRequestMarshaller.Instance; options.ResponseUnmarshaller = StartJobResponseUnmarshaller.Instance; return(Invoke <StartJobResponse>(request, options)); }
/// <summary> /// Starts the given job on the service instance /// </summary> /// <param name="scenario">Name of the test scenario</param> /// <param name="parameters">Test parameters in key-value pairs</param> /// <returns>async task</returns> public override async Task <Empty> StartJob(StartJobRequest request, ServerCallContext context) { if (this.jobState != null && !this.jobState.Completed) { return(new Empty()); } this.jobState = new JobState { Scenario = request.Scenario, }; this.cancellationSource = new CancellationTokenSource(); var paramString = string.Join(", ", request.Parameters.Select(kv => string.Concat(kv.Key, "=", kv.Value))); VegaDistTestEventSource.Log.StartJob(request.Scenario, paramString); try { var job = await TestJobFactory.Create(request.Scenario, GrpcHelper.GetJobParametersFromRepeatedField(request.Parameters), this.serviceContext).ConfigureAwait(false); var unused = Task.Run( async() => { try { this.jobMetrics = null; await job.Start(this.jobState, this.cancellationSource.Token).ConfigureAwait(false); this.jobMetrics = job.GetJobMetrics(); } catch (TaskCanceledException) { VegaDistTestEventSource.Log.StartJobCancelled(request.Scenario); this.jobState.Status += "Task cancelled"; } catch (Exception ex) { VegaDistTestEventSource.Log.StartJobFailed(request.Scenario, ex.ToString()); this.jobState.Status += ex.ToString(); } this.jobState.Completed = true; }); } catch (Exception ex) { VegaDistTestEventSource.Log.ScheduleJobFailed(request.Scenario, ex.ToString()); this.jobState.Completed = true; this.jobState.Status = ex.ToString(); } VegaDistTestEventSource.Log.JobScheduled(request.Scenario); return(new Empty()); }
/// <summary> /// Starts the given job on the service instance /// </summary> /// <param name="request">The request.</param> /// <param name="context">The context.</param> /// <returns>async task</returns> public override async Task <Empty> StartJob(StartJobRequest request, ServerCallContext context) { await this.RunOnAllClients( async (c) => { var startJobRequest = new JobRunnerProto.StartJobRequest() { Scenario = request.Scenario, }; startJobRequest.Parameters.AddRange(request.Parameters); await c.StartJobAsync(startJobRequest); return(0); }) .ConfigureAwait(false); return(new Empty()); }
private JobDescription CreateJobDescription(StartJobRequest request, int jobId) { return(new JobDescription { StartJobRequest = new StartJobRequest { TestRunImage = request.TestRunImage, TestRunCommand = request.TestRunCommand, Yaml = request.Yaml }, EnvironmentVariables = new Dictionary <string, string> { { "TESTER_SERVER", _queueSettings.Value.Server }, { "TESTER_VHOST", _queueSettings.Value.Vhost }, { "TESTER_USERNAME", _queueSettings.Value.Username }, { "TESTER_PASSWORD", _queueSettings.Value.Password }, { "TESTER_REQUEST_QUEUE", jobId.ToString() }, { "TESTER_RESPONSE_QUEUE", QueueSubscriberService.RESPONSE_QUEUE_NAME }, } }); }
/// <summary> /// 根据id启动一个编译任务 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public async Task <StartJobResponse> StartJob(StartJobRequest request) { return(await new StartJobExecutor().Client(this).Execute <StartJobResponse, StartJobResult, StartJobRequest>(request).ConfigureAwait(false)); }
/// <summary> /// 根据id启动一个编译任务 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public StartJobResponse StartJob(StartJobRequest request) { return(new StartJobExecutor().Client(this).Execute <StartJobResponse, StartJobResult, StartJobRequest>(request)); }