Skip to content

Commit

Permalink
Used deployment version
Browse files Browse the repository at this point in the history
  • Loading branch information
mudiagaobrikisil committed Oct 23, 2024
1 parent 00a6d3f commit 2cc125b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Serval/src/Serval.Client/Client.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9816,8 +9816,8 @@ public partial class TranslationBuild
[Newtonsoft.Json.JsonProperty("options", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public object? Options { get; set; } = default!;

[Newtonsoft.Json.JsonProperty("servalVersion", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string? ServalVersion { get; set; } = default!;
[Newtonsoft.Json.JsonProperty("deploymentVersion", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string? DeploymentVersion { get; set; } = default!;

}

Expand Down
1 change: 0 additions & 1 deletion src/Serval/src/Serval.Shared/Configuration/ApiOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ public class ApiOptions

public TimeSpan DefaultHttpRequestTimeout { get; set; } = TimeSpan.FromSeconds(58); // must be less than 60 seconds Cloudflare timeout
public TimeSpan LongPollTimeout { get; set; } = TimeSpan.FromSeconds(40); // must be less than DefaultHttpRequestTimeout
public string ServalVersion { get; set; } = "1.0.0"; // Default value
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ public record TranslationBuildDto
/// }
/// </example>
public object? Options { get; init; }
public string? ServalVersion { get; init; }
public string? DeploymentVersion { get; init; }
// public string? ServalVersion { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class TranslationEnginesController(
IBuildService buildService,
IPretranslationService pretranslationService,
IOptionsMonitor<ApiOptions> apiOptions,
IConfiguration configuration,
IUrlService urlService,
ILogger<TranslationEnginesController> logger
) : ServalControllerBase(authService)
Expand All @@ -22,6 +23,7 @@ ILogger<TranslationEnginesController> logger
private readonly IOptionsMonitor<ApiOptions> _apiOptions = apiOptions;
private readonly IUrlService _urlService = urlService;
private readonly ILogger<TranslationEnginesController> _logger = logger;
private readonly IConfiguration _configuration = configuration;

// private readonly ServalSettings _servalSettings = apiOptions.Value;

Expand Down Expand Up @@ -1508,7 +1510,8 @@ private TranslationBuildDto Map(Build source)
State = source.State,
DateFinished = source.DateFinished,
Options = source.Options,
ServalVersion = _apiOptions.CurrentValue.ServalVersion
// ServalVersion = _apiOptions.CurrentValue.ServalVersion
DeploymentVersion = _configuration.GetValue<string>("DeploymentVersion")
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/Serval/src/Serval.Translation/Models/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ public record Build : IEntity
public JobState State { get; init; } = JobState.Pending;
public DateTime? DateFinished { get; init; }
public IReadOnlyDictionary<string, object>? Options { get; init; }
public string? ServalVersion { get; set; }
public string? DeploymentVersion { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -1392,9 +1392,11 @@ public async Task StartBuildForEngineByIdAsync(IEnumerable<string> scope, int ex
build = await client.GetCurrentBuildAsync(engineId);
Assert.That(build, Is.Not.Null);

Assert.That(build.DeploymentVersion, Is.EqualTo("1.6.3")); // Replace with actual expected version

Check failure on line 1395 in src/Serval/test/Serval.ApiServer.IntegrationTests/TranslationEngineTests.cs

View workflow job for this annotation

GitHub Actions / NUnit Tests

Serval.ApiServer.TranslationEngineTests ► StartBuildForEngineByIdAsync(["update:translation_engines", "create:translation_engines", "read:translation_engines"],201,"e00000000000000000000001")

Failed test found in: src/Serval/test/Serval.ApiServer.IntegrationTests/TestResults/test-results.trx Error: Assert.That(build.DeploymentVersion, Is.EqualTo("1.6.3")) Expected: "1.6.3" But was: null
Raw output
  Assert.That(build.DeploymentVersion, Is.EqualTo("1.6.3"))
  Expected: "1.6.3"
  But was:  null

   at Serval.ApiServer.TranslationEngineTests.StartBuildForEngineByIdAsync(IEnumerable`1 scope, Int32 expectedStatusCode, String engineId) in /home/runner/work/serval/serval/src/Serval/test/Serval.ApiServer.IntegrationTests/TranslationEngineTests.cs:line 1395
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await[TResult](Func`1 invoke)
   at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.<>c__DisplayClass1_0.<Execute>b__0()
   at NUnit.Framework.Internal.Commands.DelegatingTestCommand.RunTestMethodInThreadAbortSafeZone(TestExecutionContext context, Action action)

1)    at Serval.ApiServer.TranslationEngineTests.StartBuildForEngineByIdAsync(IEnumerable`1 scope, Int32 expectedStatusCode, String engineId) in /home/runner/work/serval/serval/src/Serval/test/Serval.ApiServer.IntegrationTests/TranslationEngineTests.cs:line 1395


// Fetch and assert ServalVersion from ApiOptions
// ApiOptions apiOptions = _env.GetRequiredService<IOptionsMonitor<ApiOptions>>().CurrentValue;
Assert.That(_env.ApiOptions.CurrentValue.ServalVersion, Is.Not.Null);
// Assert.That(_env.ApiOptions.CurrentValue.ServalVersion, Is.Not.Null);
// Assert.That(apiOptions.ServalVersion, Is.EqualTo("expected_version")); // Replace with the actual expected version

break;
Expand Down

0 comments on commit 2cc125b

Please sign in to comment.