test: replace final fixed-delay oracles

This commit is contained in:
Erik 2026-08-18 13:12:26 +02:00
parent ad7ebe9425
commit 79a4489e03
6 changed files with 101 additions and 21 deletions

View file

@ -340,6 +340,10 @@ public sealed class LauncherInstallerTests : IDisposable
_bakeExecutable,
recordStore: new LauncherInstallRecordStore(_paths),
processRunner: runnerB);
var leaseContended = new TaskCompletionSource(
TaskCreationOptions.RunContinuationsAsynchronously);
installerB.TransactionLeaseContentionObservedForTest =
() => leaseContended.TrySetResult();
Task<LauncherInstallResult> operationA =
installerA.InstallAsync(_dats, 1);
@ -351,7 +355,8 @@ public sealed class LauncherInstallerTests : IDisposable
_dats,
1,
cancellationToken: cancellationB.Token);
await Task.Delay(150);
await leaseContended.Task.WaitAsync(TimeSpan.FromSeconds(5));
Assert.False(operationB.IsCompleted);
cancellationB.Cancel();
await Assert.ThrowsAnyAsync<OperationCanceledException>(() => operationB);
@ -537,6 +542,7 @@ public sealed class LauncherInstallerTests : IDisposable
orphanPid = int.Parse(
await File.ReadAllTextAsync(childPid),
System.Globalization.CultureInfo.InvariantCulture);
using Process orphan = Process.GetProcessById(orphanPid);
Assert.True(File.Exists(
LauncherInstallRecordStore.GetBackupPath(
store.PreparedAssetPath)));
@ -551,12 +557,16 @@ public sealed class LauncherInstallerTests : IDisposable
_paths,
_bakeExecutable,
recordStore: new LauncherInstallRecordStore(_paths));
var publicationContended = new TaskCompletionSource(
TaskCreationOptions.RunContinuationsAsynchronously);
restarted.PublicationLeaseContentionObservedForTest =
() => publicationContended.TrySetResult();
Task<InstallRecordVerification> recovery =
restarted.LoadExistingAsync();
InstallRecordVerification recovered;
if (schedule == "holds")
{
await Task.Delay(200);
await publicationContended.Task.WaitAsync(TimeSpan.FromSeconds(5));
Assert.False(recovery.IsCompleted);
File.WriteAllText(release, "release");
recovered = await recovery.WaitAsync(TimeSpan.FromSeconds(15));
@ -593,7 +603,7 @@ public sealed class LauncherInstallerTests : IDisposable
await File.ReadAllTextAsync(childExit + ".error"),
StringComparison.OrdinalIgnoreCase);
}
await Task.Delay(200);
await orphan.WaitForExitAsync().WaitAsync(TimeSpan.FromSeconds(15));
Assert.Equal(
canonicalAfterRecovery,