feat: expose mapped raw and uns data through grpc adapters
This commit is contained in:
@@ -47,6 +47,35 @@ public sealed class ScriptRunGuardTests
|
||||
ScriptEvaluator<FakeScriptContext, int> evaluator, TimeSpan? timeout = null, CancellationToken ct = default, FakeScriptContext? context = null) =>
|
||||
guard.RunAsync(key, source, evaluator, context ?? new FakeScriptContext(), timeout ?? TimeSpan.FromSeconds(5), ct);
|
||||
|
||||
[Fact]
|
||||
public async Task Physical_lease_stays_held_after_observer_timeout_until_evaluator_really_finishes()
|
||||
{
|
||||
var guard = new ScriptRunGuard(); using var evaluator = Compile(BriefSpinScript);
|
||||
var context = new FakeScriptContext(); var held = new PhysicalLease();
|
||||
try
|
||||
{
|
||||
await Should.ThrowAsync<ScriptTimeoutException>(() => guard.RunAsync("physical", BriefSpinScript, evaluator,
|
||||
context, ShortTimeout, TestContext.Current.CancellationToken, physicalLease: held));
|
||||
held.Disposals.ShouldBe(0);
|
||||
var refused = new PhysicalLease();
|
||||
await Should.ThrowAsync<ScriptRunRefusedException>(() => guard.RunAsync("physical", BriefSpinScript, evaluator,
|
||||
new FakeScriptContext(), ShortTimeout, TestContext.Current.CancellationToken, physicalLease: refused));
|
||||
refused.Disposals.ShouldBe(1); held.Disposals.ShouldBe(0);
|
||||
}
|
||||
finally { context.Released = true; }
|
||||
await SpinWaitAsync(() => held.Disposals == 1);
|
||||
}
|
||||
private static async Task SpinWaitAsync(Func<bool> done)
|
||||
{
|
||||
using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(5));
|
||||
while (!done()) await Task.Delay(10, timeout.Token);
|
||||
}
|
||||
private sealed class PhysicalLease : IDisposable
|
||||
{
|
||||
private int _disposals; public int Disposals => Volatile.Read(ref _disposals);
|
||||
public void Dispose() => Interlocked.Increment(ref _disposals);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Completed_run_returns_the_value_and_releases_the_in_flight_slot()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user