diff --git a/src/Tgstation.Server.Host/Controllers/JobController.cs b/src/Tgstation.Server.Host/Controllers/JobController.cs index feb2ea4577..49613a329f 100644 --- a/src/Tgstation.Server.Host/Controllers/JobController.cs +++ b/src/Tgstation.Server.Host/Controllers/JobController.cs @@ -72,7 +72,7 @@ namespace Tgstation.Server.Host.Controllers .Include(x => x.CancelledBy) .Where(x => x.Instance.Id == Instance.Id && !x.StoppedAt.HasValue) .OrderByDescending(x => x.StartedAt))), - null, + AddJobProgressResponseTransformer, page, pageSize, cancellationToken); @@ -99,7 +99,7 @@ namespace Tgstation.Server.Host.Controllers .Include(x => x.CancelledBy) .Where(x => x.Instance.Id == Instance.Id) .OrderByDescending(x => x.StartedAt))), - null, + AddJobProgressResponseTransformer, page, pageSize, cancellationToken); @@ -168,5 +168,14 @@ namespace Tgstation.Server.Host.Controllers api.Progress = jobManager.JobProgress(job); return Json(api); } + + /// + /// Supplements s with their . + /// + /// The to augment. + private void AddJobProgressResponseTransformer(JobResponse jobResponse) + { + jobResponse.Progress = jobManager.JobProgress(jobResponse); + } } } diff --git a/src/Tgstation.Server.Host/Jobs/IJobManager.cs b/src/Tgstation.Server.Host/Jobs/IJobManager.cs index d0d53255a2..04e8079022 100644 --- a/src/Tgstation.Server.Host/Jobs/IJobManager.cs +++ b/src/Tgstation.Server.Host/Jobs/IJobManager.cs @@ -13,9 +13,9 @@ namespace Tgstation.Server.Host.Jobs /// /// Get the for a /// - /// The to get for + /// The to get for /// The of - int? JobProgress(Job job); + int? JobProgress(Api.Models.Internal.Job job); /// /// Registers a given and begins running it diff --git a/src/Tgstation.Server.Host/Jobs/JobManager.cs b/src/Tgstation.Server.Host/Jobs/JobManager.cs index b71e9bb140..52e068371e 100644 --- a/src/Tgstation.Server.Host/Jobs/JobManager.cs +++ b/src/Tgstation.Server.Host/Jobs/JobManager.cs @@ -303,7 +303,7 @@ namespace Tgstation.Server.Host.Jobs } /// - public int? JobProgress(Job job) + public int? JobProgress(Api.Models.Internal.Job job) { if (job == null) throw new ArgumentNullException(nameof(job)); diff --git a/tests/Tgstation.Server.Tests/Instance/RepositoryTest.cs b/tests/Tgstation.Server.Tests/Instance/RepositoryTest.cs index 2accf9c5ba..7ce4dac454 100644 --- a/tests/Tgstation.Server.Tests/Instance/RepositoryTest.cs +++ b/tests/Tgstation.Server.Tests/Instance/RepositoryTest.cs @@ -69,6 +69,16 @@ namespace Tgstation.Server.Tests.Instance clone = await repositoryClient.Clone(cloneRequest, cancellationToken).ConfigureAwait(false); + // throwing this small jobs consistency test in here + await Task.Delay(TimeSpan.FromSeconds(20), cancellationToken).ConfigureAwait(false); + var activeJobs = await JobsClient.ListActive(null, cancellationToken); + var allJobs = await JobsClient.List(null, cancellationToken).ConfigureAwait(false); + + Assert.IsTrue(activeJobs.Any(x => x.Id == clone.ActiveJob.Id)); + Assert.IsTrue(allJobs.Any(x => x.Id == clone.ActiveJob.Id)); + Assert.IsTrue(activeJobs.First(x => x.Id == clone.ActiveJob.Id).Progress.HasValue); + Assert.IsTrue(allJobs.First(x => x.Id == clone.ActiveJob.Id).Progress.HasValue); + await WaitForJob(clone.ActiveJob, 9000, false, null, cancellationToken).ConfigureAwait(false); var readAfterClone = await repositoryClient.Read(cancellationToken); diff --git a/tests/Tgstation.Server.Tests/TestingServer.cs b/tests/Tgstation.Server.Tests/TestingServer.cs index de938a16e0..b63a259fe3 100644 --- a/tests/Tgstation.Server.Tests/TestingServer.cs +++ b/tests/Tgstation.Server.Tests/TestingServer.cs @@ -111,6 +111,7 @@ namespace Tgstation.Server.Tests // SPECIFICALLY DELETE THE DEV APPSETTINGS, WE DON'T WANT IT IN THE WAY File.Delete("appsettings.Development.yml"); + File.Delete("appsettings.Development.json"); if (!String.IsNullOrEmpty(gitHubAccessToken)) args.Add(String.Format(CultureInfo.InvariantCulture, "General:GitHubAccessToken={0}", gitHubAccessToken));