Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Trax.Core.Exceptions;
using Trax.Effect.Utils;
using Trax.Mediator.Services.TrainExecution;
using Trax.Mediator.Services.TrustedExecution;
using Trax.Scheduler.Services.JobSubmitter;
using Trax.Scheduler.Services.RunExecutor;
using Trax.Scheduler.Trains.JobRunner;
Expand All @@ -16,6 +17,7 @@ namespace Trax.Scheduler.Services.RequestHandler;
internal class TraxRequestHandler(
IJobRunnerTrain jobRunnerTrain,
ITrainExecutionService executionService,
ITrustedExecutionScope trustedScope,
ILogger<TraxRequestHandler> logger
) : ITraxRequestHandler
{
Expand Down Expand Up @@ -51,6 +53,10 @@ public async Task<RemoteRunResponse> RunTrainAsync(
{
try
{
// Remote job submissions were already authorized at the original API
// submission point. Mark this execution as trusted so the mediator's
// authorization service skips the per-train check.
using var _ = trustedScope.BeginTrusted("scheduler.remote-run");
var result = await executionService.RunAsync(request.TrainName, request.InputJson, ct);

string? outputJson = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ public async Task RunAsync_UnknownTrain_ThrowsInvalidOperationException()

var act = async () => await executionService.RunAsync("NonExistent.Train", "{}");

await act.Should().ThrowAsync<InvalidOperationException>().WithMessage("*No train found*");
await act.Should()
.ThrowAsync<InvalidOperationException>()
.WithMessage("*requested train was not found*");
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Trax.Effect.Models.Metadata;
using Trax.Effect.Utils;
using Trax.Mediator.Services.TrainExecution;
using Trax.Mediator.Services.TrustedExecution;
using Trax.Scheduler.Services.JobSubmitter;
using Trax.Scheduler.Services.RequestHandler;
using Trax.Scheduler.Services.RunExecutor;
Expand Down Expand Up @@ -302,6 +303,7 @@ private static TraxRequestHandler CreateHandler(
return new TraxRequestHandler(
jobRunner ?? new FakeJobRunnerTrain(),
executionService ?? new FakeTrainExecutionService(),
new TrustedExecutionScope(),
NullLogger<TraxRequestHandler>.Instance
);
}
Expand Down
Loading