Inconclusive map threads test until release.

Also fix lack of loggers in calls to InitializeByondVersion
This commit is contained in:
Jordan Dominion
2023-07-08 13:43:41 -04:00
parent 2b53227d1a
commit 93cfea62ac
2 changed files with 45 additions and 27 deletions
@@ -78,20 +78,21 @@ namespace Tgstation.Server.Tests
public static async ValueTask InitializeByondVersion(ILogger logger, Version version, bool windows, CancellationToken cancellationToken)
{
// actions is supposed to cache BYOND for us
if (!TestingUtils.RunningInGitHubActions)
return;
var url = new Uri(
$"https://www.byond.com/download/build/{version.Major}/{version.Major}.{version.Minor}_byond{(!windows ? "_linux" : string.Empty)}.zip");
$"https://www.byond.com/download/build/{version.Major}/{version.Major}.{version.Minor}_byond{(!windows ? "_linux" : string.Empty)}.zip");
string path = null;
if (TestingUtils.RunningInGitHubActions)
{
// actions is supposed to cache BYOND for us
var dir = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"byond-zips-cache",
windows ? "windows" : "linux");
var path = Path.Combine(
dir,
$"{version.Major}.{version.Minor}.zip");
var dir = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"byond-zips-cache",
windows ? "windows" : "linux");
path = Path.Combine(
dir,
$"{version.Major}.{version.Minor}.zip");
}
await (await CacheFile(logger, url, null, path, cancellationToken)).DisposeAsync();
}
+32 -15
View File
@@ -19,16 +19,15 @@ using Newtonsoft.Json.Linq;
using Tgstation.Server.Api;
using Tgstation.Server.Client;
using Tgstation.Server.Common.Http;
using Tgstation.Server.Common.Extensions;
using Tgstation.Server.Host;
using Tgstation.Server.Host.Components.Byond;
using Tgstation.Server.Host.Components.Interop;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.Database;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.IO;
using Tgstation.Server.Host.System;
using System.Net;
namespace Tgstation.Server.Tests
{
@@ -97,14 +96,21 @@ namespace Tgstation.Server.Tests
var mockSessionConfigurationOptions = new Mock<IOptions<SessionConfiguration>>();
mockSessionConfigurationOptions.SetupGet(x => x.Value).Returns(new SessionConfiguration());
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddConsole();
builder.SetMinimumLevel(LogLevel.Trace);
});
var logger = loggerFactory.CreateLogger<CachingFileDownloader>();
// windows only BYOND but can be checked on any system
var init1 = CachingFileDownloader.InitializeByondVersion(
null,
logger,
WindowsByondInstaller.DDExeVersion,
true,
CancellationToken.None);
await CachingFileDownloader.InitializeByondVersion(
null,
logger,
new Version(WindowsByondInstaller.DDExeVersion.Major, WindowsByondInstaller.DDExeVersion.Minor - 1),
true,
CancellationToken.None);
@@ -150,17 +156,26 @@ namespace Tgstation.Server.Tests
});
var platformIdentifier = new PlatformIdentifier();
var init1 = CachingFileDownloader.InitializeByondVersion(
null,
ByondInstallerBase.MapThreadsVersion,
platformIdentifier.IsWindows,
CancellationToken.None);
await CachingFileDownloader.InitializeByondVersion(
null,
new Version(ByondInstallerBase.MapThreadsVersion.Major, ByondInstallerBase.MapThreadsVersion.Minor - 1),
platformIdentifier.IsWindows,
CancellationToken.None);
await init1;
try
{
var logger = loggerFactory.CreateLogger<CachingFileDownloader>();
var init1 = CachingFileDownloader.InitializeByondVersion(
logger,
ByondInstallerBase.MapThreadsVersion,
platformIdentifier.IsWindows,
CancellationToken.None);
await CachingFileDownloader.InitializeByondVersion(
logger,
new Version(ByondInstallerBase.MapThreadsVersion.Major, ByondInstallerBase.MapThreadsVersion.Minor - 1),
platformIdentifier.IsWindows,
CancellationToken.None);
await init1;
}
catch (HttpRequestException ex) when (ex.StatusCode == HttpStatusCode.NotFound)
{
Assert.Inconclusive("-map-threads version appears to not have been released yet!");
}
var fileDownloader = new CachingFileDownloader(Mock.Of<ILogger<CachingFileDownloader>>());
IByondInstaller byondInstaller = platformIdentifier.IsWindows
@@ -216,6 +231,8 @@ namespace Tgstation.Server.Tests
{
await ioManager.DeleteDirectory(tempPath, default);
}
Assert.Fail("Test succeeded, but remove the 404 workaround!");
}
[ClassCleanup]