From 2e7dfe6103d89e9b541c17216dd060bf08daa5c6 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 6 May 2020 16:35:54 -0400 Subject: [PATCH] Change how we restart during integration tests --- tests/DMAPI/LongRunning/Test.dm | 18 ++++------ .../Instance/WatchdogTest.cs | 34 +++++++------------ 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/tests/DMAPI/LongRunning/Test.dm b/tests/DMAPI/LongRunning/Test.dm index 39e2cb9e6c..595c7a8c46 100644 --- a/tests/DMAPI/LongRunning/Test.dm +++ b/tests/DMAPI/LongRunning/Test.dm @@ -14,6 +14,13 @@ /world/Topic(T, Addr, Master, Keys) TGS_TOPIC + var/list/data = params2list(T) + var/special_tactics = data["tgs_integration_test_special_tactics"] + if(special_tactics) + RebootAsync() + return "ack" + return "feck" + /world/Reboot(reason) TgsChatBroadcast("World Rebooting") TgsReboot() @@ -23,17 +30,6 @@ world.TgsChatBroadcast("Recieved event: [json_encode(args)]") - if(event_code != TGS_EVENT_REBOOT_MODE_CHANGE) - world.TgsChatBroadcast("Not rebooting, wrong event"); - return - - if(args[3] != TGS_REBOOT_MODE_RESTART) - world.TgsChatBroadcast("Not rebooting, wrong reboot mode"); - return - - RebootAsync() - - /proc/RebootAsync() set waitfor = FALSE world.TgsChatBroadcast("Rebooting after 3 seconds"); diff --git a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs index c266fc7e93..2213041816 100644 --- a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Net; using System.Threading; using System.Threading.Tasks; using Tgstation.Server.Api.Models; @@ -56,7 +57,7 @@ namespace Tgstation.Server.Tests.Instance var startJob = await instanceClient.DreamDaemon.Start(cancellationToken).ConfigureAwait(false); await WaitForJob(startJob, 10, false, cancellationToken); - await Task.Delay(TimeSpan.FromSeconds(1)); + daemonStatus = await instanceClient.DreamDaemon.Read(cancellationToken); Assert.IsTrue(daemonStatus.Running.Value); Assert.AreEqual(false, daemonStatus.SoftRestart); @@ -89,21 +90,13 @@ namespace Tgstation.Server.Tests.Instance daemonStatus = await DeployTestDme(DmeName, DreamDaemonSecurity.Safe, cancellationToken); - await Task.Delay(TimeSpan.FromSeconds(3), cancellationToken); - Assert.IsTrue(daemonStatus.Running.Value); - if (new PlatformIdentifier().IsWindows) - { - // basic watchdog won't do this because it reboots instantly - Assert.AreEqual(initialCompileJob.Id, daemonStatus.ActiveCompileJob.Id); - Assert.AreNotEqual(initialCompileJob.Id, daemonStatus.StagedCompileJob.Id); - Assert.AreEqual(DreamDaemonSecurity.Ultrasafe, daemonStatus.StagedCompileJob.MinimumSecurityLevel); + Assert.AreEqual(initialCompileJob.Id, daemonStatus.ActiveCompileJob.Id); + Assert.AreNotEqual(initialCompileJob.Id, daemonStatus.StagedCompileJob.Id); + Assert.AreEqual(DreamDaemonSecurity.Ultrasafe, daemonStatus.StagedCompileJob.MinimumSecurityLevel); - await TellWorldToReboot(cancellationToken); - } - - await Task.Delay(10000, cancellationToken); + await TellWorldToReboot(cancellationToken); daemonStatus = await instanceClient.DreamDaemon.Read(cancellationToken); Assert.AreNotEqual(initialCompileJob.Id, daemonStatus.ActiveCompileJob.Id); @@ -177,12 +170,14 @@ namespace Tgstation.Server.Tests.Instance async Task TellWorldToReboot(CancellationToken cancellationToken) { - //we've wired long_running_test to reboot if its reboot mode is changed TO normal - - await instanceClient.DreamDaemon.Update(new DreamDaemon + IByondTopicSender bts = new ByondTopicSender { - SoftRestart = true - }, cancellationToken); + SendTimeout = 5000, + ReceiveTimeout = 5000 + }; + + var result = await bts.SendTopic(IPAddress.Loopback, "tgs_integration_test_special_tactics=1", 1337, cancellationToken); + Assert.AreEqual("ack", result); await Task.Delay(6000, cancellationToken); } @@ -199,9 +194,6 @@ namespace Tgstation.Server.Tests.Instance await WaitForJob(compileJobJob, 90, false, cancellationToken); - // Compile job isn't loaded until after the job completes - await Task.Delay(TimeSpan.FromSeconds(3)); - return await instanceClient.DreamDaemon.Read(cancellationToken); }