diff --git a/build/Version.props b/build/Version.props index 37e57bc4ff..5acebbddfb 100644 --- a/build/Version.props +++ b/build/Version.props @@ -9,7 +9,7 @@ 7.0.0 11.1.2 13.0.0 - 6.6.0 + 6.6.1 5.6.2 1.4.0 1.2.1 diff --git a/src/DMAPI/tgs.dm b/src/DMAPI/tgs.dm index 9825cd118b..d468d60441 100644 --- a/src/DMAPI/tgs.dm +++ b/src/DMAPI/tgs.dm @@ -1,6 +1,6 @@ // tgstation-server DMAPI -#define TGS_DMAPI_VERSION "6.6.0" +#define TGS_DMAPI_VERSION "6.6.1" // All functions and datums outside this document are subject to change with any version and should not be relied on. diff --git a/src/DMAPI/tgs/core/datum.dm b/src/DMAPI/tgs/core/datum.dm index 93377079aa..de420a2a32 100644 --- a/src/DMAPI/tgs/core/datum.dm +++ b/src/DMAPI/tgs/core/datum.dm @@ -11,6 +11,10 @@ TGS_DEFINE_AND_SET_GLOBAL(tgs, null) src.event_handler = event_handler src.version = version +/datum/tgs_api/proc/TerminateWorld() + del(world) + sleep(1) // https://www.byond.com/forum/post/2894866 + /datum/tgs_api/latest parent_type = /datum/tgs_api/v5 diff --git a/src/DMAPI/tgs/v4/api.dm b/src/DMAPI/tgs/v4/api.dm index b9a75c4abb..945e2e4117 100644 --- a/src/DMAPI/tgs/v4/api.dm +++ b/src/DMAPI/tgs/v4/api.dm @@ -73,7 +73,7 @@ if(cached_json["apiValidateOnly"]) TGS_INFO_LOG("Validating API and exiting...") Export(TGS4_COMM_VALIDATE, list(TGS4_PARAMETER_DATA = "[minimum_required_security_level]")) - del(world) + TerminateWorld() security_level = cached_json["securityLevel"] chat_channels_json_path = cached_json["chatChannelsJson"] @@ -188,7 +188,7 @@ requesting_new_port = TRUE if(!world.OpenPort(0)) //open any port TGS_ERROR_LOG("Unable to open random port to retrieve new port![TGS4_PORT_CRITFAIL_MESSAGE]") - del(world) + TerminateWorld() //request a new port export_lock = FALSE @@ -196,16 +196,16 @@ if(!new_port_json) TGS_ERROR_LOG("No new port response from server![TGS4_PORT_CRITFAIL_MESSAGE]") - del(world) + TerminateWorld() var/new_port = new_port_json[TGS4_PARAMETER_DATA] if(!isnum(new_port) || new_port <= 0) TGS_ERROR_LOG("Malformed new port json ([json_encode(new_port_json)])![TGS4_PORT_CRITFAIL_MESSAGE]") - del(world) + TerminateWorld() if(new_port != world.port && !world.OpenPort(new_port)) TGS_ERROR_LOG("Unable to open port [new_port]![TGS4_PORT_CRITFAIL_MESSAGE]") - del(world) + TerminateWorld() requesting_new_port = FALSE while(export_lock) diff --git a/src/DMAPI/tgs/v5/api.dm b/src/DMAPI/tgs/v5/api.dm index 45250efc46..7226f29bba 100644 --- a/src/DMAPI/tgs/v5/api.dm +++ b/src/DMAPI/tgs/v5/api.dm @@ -51,7 +51,7 @@ if(runtime_information[DMAPI5_RUNTIME_INFORMATION_API_VALIDATE_ONLY]) TGS_INFO_LOG("DMAPI validation, exiting...") - del(world) + TerminateWorld() version = new /datum/tgs_version(runtime_information[DMAPI5_RUNTIME_INFORMATION_SERVER_VERSION]) security_level = runtime_information[DMAPI5_RUNTIME_INFORMATION_SECURITY_LEVEL] diff --git a/src/Tgstation.Server.Host/Components/Session/SessionController.cs b/src/Tgstation.Server.Host/Components/Session/SessionController.cs index 78160b352d..01ddcea2d4 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionController.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionController.cs @@ -784,8 +784,6 @@ namespace Tgstation.Server.Host.Components.Session case BridgeCommandType.Startup: apiValidationStatus = ApiValidationStatus.BadValidationRequest; - // This business is is cancelled until this BYOND bug is resolved: https://www.byond.com/forum/post/2894866 -#if FALSE if (apiValidationSession) { var proceedTcs = new TaskCompletionSource(); @@ -795,9 +793,6 @@ namespace Tgstation.Server.Host.Components.Session if (!firstValidationRequest) return BridgeError("Startup bridge request was repeated!"); } -#else - postValidationShutdownTask = Task.CompletedTask; -#endif if (parameters.Version == null) return BridgeError("Missing dmApiVersion field!"); diff --git a/tests/DMAPI/LongRunning/PreCompile-GenerateRandomResource.bat b/tests/DMAPI/LongRunning/PreCompile-GenerateRandomResource.bat new file mode 100644 index 0000000000..9dc4ff9975 --- /dev/null +++ b/tests/DMAPI/LongRunning/PreCompile-GenerateRandomResource.bat @@ -0,0 +1,4 @@ +cd /D "%~dp0" +cd %1 +cd tests\DMAPI\LongRunning +C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "(New-Guid).Guid | Out-File resource.txt; Add-Content -Path resource.txt -Value 'aljsdhfjahsfkjnsalkjdfhskljdackmcnvxkljhvkjsdanv,jdshlkufhklasjeFDhfjkalhdkjlfhalksfdjh'" diff --git a/tests/DMAPI/LongRunning/PreCompile-GenerateRandomResource.sh b/tests/DMAPI/LongRunning/PreCompile-GenerateRandomResource.sh new file mode 100644 index 0000000000..a22163f76f --- /dev/null +++ b/tests/DMAPI/LongRunning/PreCompile-GenerateRandomResource.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +cd "$1/tests/DMAPI/LongRunning" + +tr -dc A-Za-z0-9 resource.txt +echo -e '\naljsdhfjahsfkjnsalkjdfhskljdackmcnvxkljhvkjsdanv,jdshlkufhklasjeFDhfjkalhdkjlfhalksfdjh\n' >> resource.txt diff --git a/tests/DMAPI/LongRunning/Test.dm b/tests/DMAPI/LongRunning/Test.dm index 1d008a3de9..c2e274f4d4 100644 --- a/tests/DMAPI/LongRunning/Test.dm +++ b/tests/DMAPI/LongRunning/Test.dm @@ -28,11 +28,13 @@ if(!length(channels)) FailTest("Expected some chat channels!") - var/test_str = "aljsdhfjahsfkjnsalkjdfhskljdackmcnvxkljhvkjsdanv,jdshlkufhklasjeFDhfjkalhdkjlfhalksfdjh" - var/res_contents = file2text('resource.txt') // we need a .rsc to be generated + var/res = file('resource.txt') + if(!res) + FailTest("Failed to resource!") - if(!findtext(res_contents, test_str)) - FailTest("Failed to resource? Did not find magic: [res_contents]") + var/res_contents = file2text(res) // we need a .rsc to be generated + if(!res_contents) + FailTest("Failed to resource? No contents!") if(!fexists("[DME_NAME].rsc")) FailTest("Failed to create .rsc!") diff --git a/tests/DMAPI/LongRunning/resource.txt b/tests/DMAPI/LongRunning/resource.txt deleted file mode 100644 index 94b848fe2a..0000000000 --- a/tests/DMAPI/LongRunning/resource.txt +++ /dev/null @@ -1,8 +0,0 @@ - - if(!length(channels)) - FailTest("Expected some chat channels!") - - var/test_str = "aljsdhfjahsfkjnsalkjdfhskljdackmcnvxkljhvkjsdanv,jdshlkufhklasjeFDhfjkalhdkjlfhalksfdjh" - var/self_contents = file2text(file('Test.dm')) // we need a .rsc to be generated - - if(!(test_str in self_contents)) diff --git a/tests/DMAPI/test_setup.dm b/tests/DMAPI/test_setup.dm index 250f80fe54..56f4c03eb8 100644 --- a/tests/DMAPI/test_setup.dm +++ b/tests/DMAPI/test_setup.dm @@ -32,3 +32,4 @@ text2file(reason, "test_fail_reason.txt") world.log << "Terminating..." del(world) + sleep(1) // https://www.byond.com/forum/post/2894866 diff --git a/tests/Tgstation.Server.Tests/Live/Instance/ConfigurationTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/ConfigurationTest.cs index 333b2489d7..73c658487b 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/ConfigurationTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/ConfigurationTest.cs @@ -13,6 +13,7 @@ using Tgstation.Server.Client; using Tgstation.Server.Client.Components; using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host.IO; +using Tgstation.Server.Host.System; namespace Tgstation.Server.Tests.Live.Instance { @@ -116,6 +117,19 @@ namespace Tgstation.Server.Tests.Live.Instance await using var memoryStream2 = new MemoryStream(Encoding.UTF8.GetBytes("bbb")); await configurationClient.Write(staticFile2, memoryStream2, cancellationToken); + + var shellScriptExtension = new PlatformIdentifier().IsWindows ? ".bat" : ".sh"; + var scriptName = $"PreCompile-GenerateRandomResource{shellScriptExtension}"; + var resourcingScript = new ConfigurationFileRequest + { + Path = $"/EventScripts/{scriptName}" + }; + + await using var readStream = ioManager.GetFileStream($"../../../../DMAPI/LongRunning/{scriptName}", false); + await configurationClient.Write( + resourcingScript, + readStream, + cancellationToken); } return ValueTaskExtensions.WhenAll( diff --git a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs index 7da4e2bbe4..0a67dc8c02 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs @@ -394,13 +394,17 @@ namespace Tgstation.Server.Tests.Live.Instance KillDD(true); var jobTcs = new TaskCompletionSource(); var killTaskStarted = new TaskCompletionSource(); - var killTask = Task.Run(() => + var killThread = new Thread(() => { killTaskStarted.SetResult(); while (!jobTcs.Task.IsCompleted) KillDD(false); - }, cancellationToken); + }) + { + Priority = ThreadPriority.AboveNormal + }; + killThread.Start(); try { await killTaskStarted.Task; @@ -410,7 +414,7 @@ namespace Tgstation.Server.Tests.Live.Instance finally { jobTcs.SetResult(); - await killTask; + killThread.Join(); } // these can also happen @@ -1133,9 +1137,11 @@ namespace Tgstation.Server.Tests.Live.Instance Assert.AreEqual(ddPort, daemonStatus.CurrentPort); // Try killing the DD process to ensure it gets set to the restoring state + bool firstTime = true; do { - KillDD(true); + KillDD(firstTime); + firstTime = false; await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken); daemonStatus = await instanceClient.DreamDaemon.Read(cancellationToken); } diff --git a/tgstation-server.sln b/tgstation-server.sln index c1cde46821..36d9027e9d 100644 --- a/tgstation-server.sln +++ b/tgstation-server.sln @@ -158,7 +158,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LongRunning", "LongRunning" tests\DMAPI\LongRunning\long_running_test.dme = tests\DMAPI\LongRunning\long_running_test.dme tests\DMAPI\LongRunning\long_running_test_copy.dme = tests\DMAPI\LongRunning\long_running_test_copy.dme tests\DMAPI\LongRunning\long_running_test_rooted.dme = tests\DMAPI\LongRunning\long_running_test_rooted.dme - tests\DMAPI\LongRunning\resource.txt = tests\DMAPI\LongRunning\resource.txt + tests\DMAPI\LongRunning\PreCompile-GenerateRandomResource.bat = tests\DMAPI\LongRunning\PreCompile-GenerateRandomResource.bat + tests\DMAPI\LongRunning\PreCompile-GenerateRandomResource.sh = tests\DMAPI\LongRunning\PreCompile-GenerateRandomResource.sh tests\DMAPI\LongRunning\Test.dm = tests\DMAPI\LongRunning\Test.dm EndProjectSection EndProject