From 7eddd601e5763bf086a2dc5572716015a39ac85e Mon Sep 17 00:00:00 2001 From: Dominion Date: Sun, 4 Jun 2023 10:09:36 -0400 Subject: [PATCH] Test health check event handler --- tests/DMAPI/LongRunning/Test.dm | 13 ++++++++++++- .../Live/Instance/WatchdogTest.cs | 12 ++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/DMAPI/LongRunning/Test.dm b/tests/DMAPI/LongRunning/Test.dm index de5cd5831d..e2a8175fb3 100644 --- a/tests/DMAPI/LongRunning/Test.dm +++ b/tests/DMAPI/LongRunning/Test.dm @@ -128,6 +128,10 @@ var/run_bridge_test var/list/channels = TgsChatChannelInfo() return "[length(channels)]" + var/tactics8 = data["tgs_integration_test_tactics8"] + if(tactics8) + return received_health_check ? "received health check" : "did not receive health check" + TgsChatBroadcast(new /datum/tgs_message_content("Recieved non-tgs topic: `[T]`")) return "feck" @@ -151,10 +155,17 @@ var/run_bridge_test TgsChatBroadcast("World Rebooting") TgsReboot() +var/received_health_check = FALSE + +/datum/tgs_event_handler/impl + receive_health_checks = TRUE + /datum/tgs_event_handler/impl/HandleEvent(event_code, ...) set waitfor = FALSE - if(event_code == TGS_EVENT_WATCHDOG_DETACH) + if(event_code == TGS_EVENT_HEALTH_CHECK) + received_health_check = TRUE + else if(event_code == TGS_EVENT_WATCHDOG_DETACH) // hack hack, calling world.TgsChatChannelInfo() will try to delay until the channels come back var/datum/tgs_api/v5/api = TGS_READ_GLOBAL(tgs) if(length(api.chat_channels)) diff --git a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs index 32e109d624..f827548214 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs @@ -386,6 +386,18 @@ namespace Tgstation.Server.Tests.Live.Instance await Task.WhenAny(Task.Delay(20000, cancellationToken), ourProcessHandler.Lifetime); Assert.IsFalse(ddProc.HasExited); + // check DD agrees + var topicRequestResult = await TopicClient.SendTopic( + IPAddress.Loopback, + $"tgs_integration_test_tactics8=1", + TestLiveServer.DDPort, + cancellationToken); + + Assert.IsNotNull(topicRequestResult); + Assert.AreEqual(TopicResponseType.StringResponse, topicRequestResult.ResponseType); + Assert.IsNotNull(topicRequestResult.StringData); + Assert.AreEqual(topicRequestResult.StringData, "received health check"); + await instanceClient.DreamDaemon.Update(new DreamDaemonRequest { SoftShutdown = true