feat(scripts): realign Test Run with runtime API, add anonymous-object calls and instance binding
The Test Run sandbox and Monaco analysis modelled a script API that had drifted from the site runtime's ScriptGlobals, so real scripts failed to compile in Test Run. Realign both to the runtime surface (Instance/Scripts/ExternalSystem/Attributes/Children/Parent) and drop the duplicate ScriptHost stub so the two cannot diverge again. - Script calls (Scripts.CallShared, Instance.CallScript, Route.To().Call) accept an anonymous object instead of a hand-built dictionary, via a shared ScriptArgs normalizer; existing dictionary calls still compile. - Test Run can optionally bind to a deployed instance, so Instance/ Attributes/CallScript route to it cross-site; adds site-side RouteToGetAttributes/RouteToSetAttributes handlers. - Adds Test Run panels to the API method and template script editors. - Fixes the TestDatabaseQuery seed script, which queried a table that never existed. Also commits unrelated in-progress work already in the tree: the health monitoring report loop, site streaming changes, and the Admin/Design data-connection and SMTP page reorganization.
This commit is contained in:
@@ -49,17 +49,25 @@ public class HealthReportSenderTests
|
||||
Assert.True(transport.SentReports.Count >= 2,
|
||||
$"Expected at least 2 reports, got {transport.SentReports.Count}");
|
||||
|
||||
// Verify monotonic sequence numbers starting at 1
|
||||
// Verify strictly-monotonic sequence numbers and matching site id
|
||||
for (int i = 0; i < transport.SentReports.Count; i++)
|
||||
{
|
||||
Assert.Equal(i + 1, transport.SentReports[i].SequenceNumber);
|
||||
if (i > 0)
|
||||
{
|
||||
Assert.True(
|
||||
transport.SentReports[i].SequenceNumber > transport.SentReports[i - 1].SequenceNumber,
|
||||
$"Sequence numbers not strictly increasing at index {i}");
|
||||
}
|
||||
Assert.Equal("site-A", transport.SentReports[i].SiteId);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SequenceNumberStartsAtOne()
|
||||
public async Task FirstReportSequenceExceedsStartupUnixMs()
|
||||
{
|
||||
// Reports are seeded with Unix-ms at construction so a freshly-active
|
||||
// node always sorts after the prior active. Verify the first emitted
|
||||
// sequence is at least the startup epoch.
|
||||
var transport = new FakeTransport();
|
||||
var collector = new SiteHealthCollector();
|
||||
collector.SetActiveNode(true);
|
||||
@@ -68,6 +76,7 @@ public class HealthReportSenderTests
|
||||
ReportInterval = TimeSpan.FromMilliseconds(50)
|
||||
});
|
||||
|
||||
var beforeCtor = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||
var sender = new HealthReportSender(
|
||||
collector,
|
||||
transport,
|
||||
@@ -85,7 +94,9 @@ public class HealthReportSenderTests
|
||||
catch (OperationCanceledException) { }
|
||||
|
||||
Assert.True(transport.SentReports.Count >= 1);
|
||||
Assert.Equal(1, transport.SentReports[0].SequenceNumber);
|
||||
Assert.True(
|
||||
transport.SentReports[0].SequenceNumber >= beforeCtor,
|
||||
$"First sequence {transport.SentReports[0].SequenceNumber} should be >= startup epoch {beforeCtor}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -126,19 +137,21 @@ public class HealthReportSenderTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InitialSequenceNumberIsZero()
|
||||
public void InitialSequenceNumberSeededWithUnixMs()
|
||||
{
|
||||
var transport = new FakeTransport();
|
||||
var collector = new SiteHealthCollector();
|
||||
var options = Options.Create(new HealthMonitoringOptions());
|
||||
|
||||
var beforeCtor = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||
var sender = new HealthReportSender(
|
||||
collector,
|
||||
transport,
|
||||
options,
|
||||
NullLogger<HealthReportSender>.Instance,
|
||||
new FakeSiteIdentityProvider());
|
||||
var afterCtor = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||
|
||||
Assert.Equal(0, sender.CurrentSequenceNumber);
|
||||
Assert.InRange(sender.CurrentSequenceNumber, beforeCtor, afterCtor);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user