mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 22:48:20 +01:00
Clean up points where we TellWorldToReboot()
Making sure we allow `WatchdogStatus.Restoring` where possible.
This commit is contained in:
@@ -304,7 +304,7 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
var expectedStaged = currentStatus.StagedCompileJob;
|
||||
Assert.AreNotEqual(expectedStaged.Id, currentStatus.ActiveCompileJob.Id);
|
||||
|
||||
await TellWorldToReboot(cancellationToken);
|
||||
await TellWorldToReboot(false, cancellationToken);
|
||||
|
||||
currentStatus = await instanceClient.DreamDaemon.Read(cancellationToken);
|
||||
Assert.AreEqual(expectedStaged.Id, currentStatus.ActiveCompileJob.Id);
|
||||
@@ -330,17 +330,7 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
expectedStaged = currentStatus.StagedCompileJob;
|
||||
Assert.AreNotEqual(expectedStaged.Id, currentStatus.ActiveCompileJob.Id);
|
||||
|
||||
await TellWorldToReboot(cancellationToken);
|
||||
|
||||
if (testVersion.Engine == EngineType.OpenDream)
|
||||
do
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
|
||||
currentStatus = await instanceClient.DreamDaemon.Read(cancellationToken);
|
||||
}
|
||||
while (currentStatus.Status == WatchdogStatus.Restoring);
|
||||
else
|
||||
currentStatus = await instanceClient.DreamDaemon.Read(cancellationToken);
|
||||
currentStatus = await TellWorldToReboot(false, cancellationToken);
|
||||
|
||||
Assert.AreEqual(WatchdogStatus.Online, currentStatus.Status);
|
||||
Assert.IsNull(currentStatus.StagedCompileJob);
|
||||
@@ -1111,7 +1101,7 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
Assert.AreEqual(DreamDaemonSecurity.Safe, newerCompileJob.MinimumSecurityLevel);
|
||||
|
||||
await CheckDMApiFail(daemonStatus.ActiveCompileJob, cancellationToken);
|
||||
daemonStatus = await TellWorldToReboot(cancellationToken);
|
||||
daemonStatus = await TellWorldToReboot(false, cancellationToken);
|
||||
|
||||
Assert.AreNotEqual(initialCompileJob.Id, daemonStatus.ActiveCompileJob.Id);
|
||||
Assert.IsNull(daemonStatus.StagedCompileJob);
|
||||
@@ -1156,7 +1146,7 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
Assert.AreEqual(DreamDaemonSecurity.Safe, newerCompileJob.MinimumSecurityLevel);
|
||||
|
||||
await CheckDMApiFail(daemonStatus.ActiveCompileJob, cancellationToken);
|
||||
daemonStatus = await TellWorldToReboot(cancellationToken);
|
||||
daemonStatus = await TellWorldToReboot(true, cancellationToken);
|
||||
|
||||
Assert.AreNotEqual(initialCompileJob.Id, daemonStatus.ActiveCompileJob.Id);
|
||||
Assert.IsNull(daemonStatus.StagedCompileJob);
|
||||
@@ -1220,7 +1210,7 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
Assert.AreEqual(true, daemonStatus.SoftRestart);
|
||||
|
||||
await CheckDMApiFail(daemonStatus.ActiveCompileJob, cancellationToken);
|
||||
daemonStatus = await TellWorldToReboot(cancellationToken);
|
||||
daemonStatus = await TellWorldToReboot(true, cancellationToken);
|
||||
|
||||
Assert.AreEqual(versionToInstall, daemonStatus.ActiveCompileJob.EngineVersion);
|
||||
Assert.IsNull(daemonStatus.StagedCompileJob);
|
||||
@@ -1290,8 +1280,9 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
return ddProc != null;
|
||||
}
|
||||
|
||||
public Task<DreamDaemonResponse> TellWorldToReboot(CancellationToken cancellationToken) => TellWorldToReboot2(instanceClient, topicClient, FindTopicPort(), cancellationToken);
|
||||
public static async Task<DreamDaemonResponse> TellWorldToReboot2(IInstanceClient instanceClient, ITopicClient topicClient, ushort topicPort, CancellationToken cancellationToken)
|
||||
public Task<DreamDaemonResponse> TellWorldToReboot(bool allowRestoring, CancellationToken cancellationToken)
|
||||
=> TellWorldToReboot2(instanceClient, topicClient, FindTopicPort(), allowRestoring ? true : testVersion.Engine.Value == EngineType.OpenDream, cancellationToken);
|
||||
public static async Task<DreamDaemonResponse> TellWorldToReboot2(IInstanceClient instanceClient, ITopicClient topicClient, ushort topicPort, bool allowRestoring, CancellationToken cancellationToken)
|
||||
{
|
||||
var daemonStatus = await instanceClient.DreamDaemon.Read(cancellationToken);
|
||||
Assert.IsNotNull(daemonStatus.StagedCompileJob);
|
||||
@@ -1318,6 +1309,16 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
|
||||
await Task.Delay(TimeSpan.FromSeconds(3), cancellationToken);
|
||||
|
||||
if (allowRestoring && daemonStatus.Status == WatchdogStatus.Restoring)
|
||||
{
|
||||
do
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(1), tempToken);
|
||||
daemonStatus = await instanceClient.DreamDaemon.Read(tempToken);
|
||||
}
|
||||
while (daemonStatus.Status == WatchdogStatus.Restoring);
|
||||
}
|
||||
|
||||
return daemonStatus;
|
||||
}
|
||||
|
||||
|
||||
@@ -1583,9 +1583,8 @@ namespace Tgstation.Server.Tests.Live
|
||||
|
||||
Assert.AreEqual(connectedChannelCount, channelsPresent);
|
||||
|
||||
await WatchdogTest.TellWorldToReboot2(instanceClient, WatchdogTest.StaticTopicClient, mainDDPort, cancellationToken);
|
||||
dd = await WatchdogTest.TellWorldToReboot2(instanceClient, WatchdogTest.StaticTopicClient, mainDDPort, false, cancellationToken);
|
||||
|
||||
dd = await instanceClient.DreamDaemon.Read(cancellationToken);
|
||||
Assert.AreEqual(WatchdogStatus.Online, dd.Status.Value); // if this assert fails, you likely have to crack open the debugger and read test_fail_reason.txt manually
|
||||
Assert.IsNull(dd.StagedCompileJob);
|
||||
Assert.AreEqual(initialStaged, dd.ActiveCompileJob.Id);
|
||||
@@ -1653,13 +1652,7 @@ namespace Tgstation.Server.Tests.Live
|
||||
Assert.AreEqual(dd.StagedCompileJob.Job.Id, compileJob.Id);
|
||||
|
||||
expectedCompileJobId = compileJob.Id.Value;
|
||||
dd = await wdt.TellWorldToReboot(cancellationToken);
|
||||
|
||||
while (dd.Status.Value == WatchdogStatus.Restoring)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
|
||||
dd = await instanceClient.DreamDaemon.Read(cancellationToken);
|
||||
}
|
||||
dd = await wdt.TellWorldToReboot(false, cancellationToken);
|
||||
|
||||
Assert.AreEqual(dd.ActiveCompileJob.Job.Id, expectedCompileJobId);
|
||||
Assert.AreEqual(WatchdogStatus.Online, dd.Status.Value);
|
||||
@@ -1696,7 +1689,7 @@ namespace Tgstation.Server.Tests.Live
|
||||
Assert.AreEqual(expectedStaged, currentDD.StagedCompileJob.Job.Id.Value);
|
||||
|
||||
var wdt = new WatchdogTest(edgeVersion, instanceClient, GetInstanceManager(), (ushort)server.ApiUrl.Port, server.HighPriorityDreamDaemon, mainDDPort, server.UsingBasicWatchdog);
|
||||
currentDD = await wdt.TellWorldToReboot(cancellationToken);
|
||||
currentDD = await wdt.TellWorldToReboot(true, cancellationToken);
|
||||
Assert.AreEqual(expectedStaged, currentDD.ActiveCompileJob.Job.Id.Value);
|
||||
Assert.IsNull(currentDD.StagedCompileJob);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user