Watchdog tests improvements

- Reorganize Watchdog Tests slightly
- Add test for chat overloading
- Add additional error logging
This commit is contained in:
Dominion
2023-04-16 19:23:10 -04:00
parent 9e6c043383
commit 4926fef98a
2 changed files with 45 additions and 26 deletions
+11 -5
View File
@@ -46,7 +46,7 @@
/proc/Run()
sleep(60)
world.TgsChatBroadcast("World Initialized")
world.TgsChatBroadcast(new /datum/tgs_message_content("World Initialized"))
var/datum/tgs_message_content/response = new("Embed support test1")
response.embed = new()
response.embed.description = "desc"
@@ -124,6 +124,12 @@ var/run_bridge_test
var/payload = create_payload(size)
return payload
// Chat overload
var/tactics5 = data["tgs_integration_test_tactics5"]
if(tactics5)
TgsChatBroadcast(new /datum/tgs_message_content(create_payload(3000)))
return "sent"
TgsChatBroadcast(new /datum/tgs_message_content("Recieved non-tgs topic: `[T]`"))
return "feck"
@@ -232,9 +238,9 @@ var/lastTgsError
var/list/result = BridgeWithoutChunking(0, list("chatMessage" = list("text" = "payload:[payload]")))
if(!result || lastTgsError || result["integrationHack"] != "ok")
lastTgsError = null
if(i == lastI + 1)
break
lastTgsError = null
i = lastI
base = lastI
nextPow = 0
@@ -246,9 +252,9 @@ var/lastTgsError
// DMAPI5_BRIDGE_REQUEST_LIMIT
var/limit = 8198
var/finalResult = api.Bridge(0, list("chatMessage" = list("text" = "done:[create_payload(limit * 3)]")))
if(!finalResult || lastTgsError || finalResult["integrationHack"] != "ok")
text2file("Failed to end bridge limit test!", "test_fail_reason.txt")
var/list/final_result = api.Bridge(0, list("chatMessage" = list("text" = "done:[create_payload(limit * 3)]")))
if(!final_result || lastTgsError || final_result["integrationHack"] != "ok")
text2file("Failed to end bridge limit test! [(istype(final_result) ? json_encode(final_result): (final_result || "null"))]", "test_fail_reason.txt")
del(world)
api.access_identifier = old_ai
@@ -79,22 +79,45 @@ namespace Tgstation.Server.Tests.Instance
await RunLongRunningTestThenUpdate(cancellationToken);
await GhettoChatCommandTest(cancellationToken);
await GhettoValidateDMApiLimits(cancellationToken);
await RunLongRunningTestThenUpdateWithNewDme(cancellationToken);
await RunLongRunningTestThenUpdateWithByondVersionSwitch(cancellationToken);
await RunHeartbeatTest(true, cancellationToken);
await RunHeartbeatTest(false, cancellationToken);
await StartAndLeaveRunning(cancellationToken);
await DumpTests(cancellationToken);
await InteropTestsForLongRunningDme(cancellationToken);
System.Console.WriteLine("TEST: END WATCHDOG TESTS");
}
async Task InteropTestsForLongRunningDme(CancellationToken cancellationToken)
{
await StartAndLeaveRunning(cancellationToken);
await Task.WhenAll(
WhiteBoxChatCommandTest(cancellationToken),
SendChatOverloadCommand(cancellationToken));
// This one fucks with the access_identifer, run it in isolation
await WhiteBoxValidateDMApiLimits(cancellationToken);
// And this freezes DD
await DumpTests(cancellationToken);
}
async Task SendChatOverloadCommand(CancellationToken cancellationToken)
{
// for the code coverage really...
var topicRequestResult = await topicClient.SendTopic(
IPAddress.Loopback,
$"tgs_integration_test_tactics5=1",
IntegrationTest.DDPort,
cancellationToken);
Assert.IsNotNull(topicRequestResult);
Assert.AreEqual("sent", topicRequestResult.StringData);
}
async Task DumpTests(CancellationToken cancellationToken)
{
System.Console.WriteLine("TEST: WATCHDOG DUMP TESTS");
@@ -340,12 +363,8 @@ namespace Tgstation.Server.Tests.Instance
public string Payload { get; set; }
}
async Task GhettoValidateDMApiLimits(CancellationToken cancellationToken)
async Task WhiteBoxValidateDMApiLimits(CancellationToken cancellationToken)
{
var startJob = await StartDD(cancellationToken);
await WaitForJob(startJob, 40, false, null, cancellationToken);
// first check the bridge limits
var bridgeTestsTcs = new TaskCompletionSource();
BridgeController.LogContent = false;
@@ -465,15 +484,13 @@ namespace Tgstation.Server.Tests.Instance
cancellationToken.ThrowIfCancellationRequested();
Assert.AreEqual(DMApiConstants.MaximumTopicResponseLength, (uint)lastSize);
await instanceClient.DreamDaemon.Shutdown(cancellationToken);
var ddInfo = await instanceClient.DreamDaemon.Read(cancellationToken);
await CheckDMApiFail(ddInfo.ActiveCompileJob, cancellationToken);
}
async Task GhettoChatCommandTest(CancellationToken cancellationToken)
async Task WhiteBoxChatCommandTest(CancellationToken cancellationToken)
{
var startJob = await StartDD(cancellationToken);
await WaitForJob(startJob, 40, false, null, cancellationToken);
// oh god, oh fuck, blackbox testing
MessageContent embedsResponse, overloadResponse, overloadResponse2, embedsResponse2;
var startTime = DateTimeOffset.UtcNow - TimeSpan.FromSeconds(5);
@@ -527,8 +544,6 @@ namespace Tgstation.Server.Tests.Instance
var endTime = DateTimeOffset.UtcNow + TimeSpan.FromSeconds(5);
var shutdownTask = instanceClient.DreamDaemon.Shutdown(cancellationToken);
var ddInfo = await instanceClient.DreamDaemon.Read(cancellationToken);
await CheckDMApiFail(ddInfo.ActiveCompileJob, cancellationToken);
@@ -540,8 +555,6 @@ namespace Tgstation.Server.Tests.Instance
Assert.AreEqual(expectedString, overloadResponse.Text);
Assert.IsNotNull(overloadResponse2);
Assert.AreEqual(expectedString, overloadResponse2.Text);
await shutdownTask;
}
void CheckEmbedsTest(MessageContent embedsResponse, DateTimeOffset startTime, DateTimeOffset endTime)