private async Task InsertJob(Guid jobId) { IEnumerable <string> assert(Job a, Job b) { yield return(AssertProperty("FinishedAt", (r) => r.FinishedAt, a, b)); yield return(AssertProperty("Job name", (r) => r.JobName, a, b)); yield return(AssertProperty("status", (r) => r.JobStatus, a, b)); yield return(AssertProperty("Language", (r) => r.Language, a, b)); //yield return AssertProperty("Owner", (r) => r.Owner, a, b); // removed due to utc f**k up //yield return AssertProperty("StartedAt", (r) => r.StartedAt, a, b); yield return(AssertProperty("Topic query", (r) => r.TopicQuery, a, b)); } var newJob = new Job { FinishedAt = null, JobName = "test_job_jk", JobStatus = JobStatus.Running, JobId = jobId, Owner = "admin", TopicQuery = "some topic", StartedAt = DateTime.Now, }; await _jobStorage.InsertNewJobAsync(newJob); var retrievedJob = await _jobStorage.GetJobAsync(jobId); var errors = assert(newJob, retrievedJob).Where(r => !(r is null)); AssertErrors("Job insert", errors); var toBeUpdatedJob = new Job { FinishedAt = null, JobName = "test_job_jk_foo_x", JobStatus = JobStatus.Stopped, JobId = jobId, Owner = "admin", TopicQuery = "some topic", StartedAt = DateTime.Now, }; await _jobStorage.InsertNewJobAsync(toBeUpdatedJob); var updatedJob = await _jobStorage.GetJobAsync(jobId); var errorsAfterUpdate = assert(toBeUpdatedJob, updatedJob); AssertErrors("JobUpdate", errors); }
public async Task <JobConfigUpdateResult> StartJobAsync( JobConfigUpdateCommand jobConfigUpdateCommand) { var storage = _componentRegistry.GetRegisteredStorage(); if (storage == null) { _logger.TrackError( "StartJob", "No storage component was registered"); return(JobConfigUpdateResult.Failed("No storage is present. Job can't be done")); } var job = new Job { FinishedAt = null, JobName = jobConfigUpdateCommand.JobName, JobStatus = JobStatus.Running, JobId = jobConfigUpdateCommand.JobId, Owner = "admin", TopicQuery = jobConfigUpdateCommand.TopicQuery, StartedAt = DateTime.Now, }; var analysers = await PushAnalyserJobConfig( storage.AnalysedDataInputChannel, jobConfigUpdateCommand); var analysersInputs = analysers.Select(r => r.InputChannelName).ToArray(); await PushNetworkDataAcquisitionJobConfig( storage.AcquiredDataInputChannel, analysersInputs, jobConfigUpdateCommand); await _jobStorage.InsertNewJobAsync(job); return(JobConfigUpdateResult.Successfull( jobConfigUpdateCommand.JobId, JobStatus.Running)); }