test: preserve bounded cleanup on close control failures
This commit is contained in:
+30
-3
@@ -89,6 +89,7 @@ public sealed partial class Sdk2LifecycleSoakTests
|
||||
};
|
||||
ApplicationInstance? application = new(telemetry) { ApplicationConfiguration = config };
|
||||
ServerEventRig? rig = null;
|
||||
Exception? originalFailure = null;
|
||||
try
|
||||
{
|
||||
await config.ValidateAsync(ApplicationType.Client, ct);
|
||||
@@ -130,11 +131,37 @@ public sealed partial class Sdk2LifecycleSoakTests
|
||||
WriteCloseControl("sdk2-disposal-proofs", new { managersDisposed = 2, cachedStores = 0, pkiDescriptors = 0 });
|
||||
return stoppedTargets.ToArray();
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
originalFailure = error;
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (rig is not null) await rig.DisposeAsync().AsTask().WaitAsync(TimeSpan.FromSeconds(20), ct);
|
||||
if (application is not null) await application.DisposeAsync().AsTask().WaitAsync(TimeSpan.FromSeconds(20), ct);
|
||||
if (Directory.Exists(clientRoot)) Directory.Delete(clientRoot, true);
|
||||
var cleanupFailures = new List<Exception>();
|
||||
try
|
||||
{
|
||||
try { if (rig is not null) await rig.DisposeAsync().AsTask().WaitAsync(TimeSpan.FromSeconds(20)); }
|
||||
catch (Exception error) { cleanupFailures.Add(error); }
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
try { if (application is not null) await application.DisposeAsync().AsTask().WaitAsync(TimeSpan.FromSeconds(20)); }
|
||||
catch (Exception error) { cleanupFailures.Add(error); }
|
||||
}
|
||||
finally
|
||||
{
|
||||
try { if (Directory.Exists(clientRoot)) Directory.Delete(clientRoot, true); }
|
||||
catch (Exception error) { cleanupFailures.Add(error); }
|
||||
}
|
||||
}
|
||||
if (cleanupFailures.Count > 0)
|
||||
{
|
||||
if (originalFailure is not null) cleanupFailures.Insert(0, originalFailure);
|
||||
throw new AggregateException("Close-control cleanup failed; original failure retained when present.", cleanupFailures);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user