7eabb82287
PerSiteStatus carries one serialized SiteArtifactResult per site (~155 chars for a clean site, more with error text). The 4000-char cap made Deploy Artifacts over ~25 sites throw on the final save, after every site had applied, so no site was stamped and every retry failed the same way. Mapping is now nvarchar(max); the migration + SQL script follow in their own commit.
48 lines
1.9 KiB
C#
48 lines
1.9 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Deployment;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Tests.Configurations;
|
|
|
|
/// <summary>
|
|
/// DEP-3 (WP2 task 2.9): <c>SystemArtifactDeploymentRecord.PerSiteStatus</c> holds one
|
|
/// serialized result per site (~155 chars for a clean site, far more with error text), so a
|
|
/// 4000-character cap made Deploy Artifacts over ~25 sites fail AFTER every site had applied,
|
|
/// with nothing stamped. The column is unbounded (<c>nvarchar(max)</c>).
|
|
/// </summary>
|
|
public class SystemArtifactDeploymentRecordConfigurationTests : IDisposable
|
|
{
|
|
private readonly ScadaBridgeDbContext _context = SqliteTestHelper.CreateInMemoryContext();
|
|
|
|
/// <summary>Releases the resources held by this test class.</summary>
|
|
public void Dispose()
|
|
{
|
|
_context.Database.CloseConnection();
|
|
_context.Dispose();
|
|
}
|
|
|
|
/// <summary>The PerSiteStatus property has no maximum length.</summary>
|
|
[Fact]
|
|
public void PerSiteStatus_IsUnbounded()
|
|
{
|
|
var property = _context.Model.FindEntityType(typeof(SystemArtifactDeploymentRecord))!
|
|
.FindProperty(nameof(SystemArtifactDeploymentRecord.PerSiteStatus))!;
|
|
|
|
Assert.Null(property.GetMaxLength());
|
|
}
|
|
|
|
/// <summary>A status payload well past the old 4000-character cap round-trips intact.</summary>
|
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
|
[Fact]
|
|
public async Task PerSiteStatus_LargePayload_RoundTrips()
|
|
{
|
|
var status = new string('x', 20_000);
|
|
var record = new SystemArtifactDeploymentRecord("Artifacts", "alice") { PerSiteStatus = status };
|
|
_context.SystemArtifactDeploymentRecords.Add(record);
|
|
await _context.SaveChangesAsync();
|
|
_context.ChangeTracker.Clear();
|
|
|
|
var loaded = await _context.SystemArtifactDeploymentRecords.FindAsync(record.Id);
|
|
Assert.Equal(status, loaded!.PerSiteStatus);
|
|
}
|
|
}
|