Jordan Dominion
2023-10-21 09:40:43 -04:00
parent 63f08431bf
commit ba5823c631
4 changed files with 86 additions and 46 deletions
@@ -634,5 +634,11 @@ namespace Tgstation.Server.Api.Models
/// </summary>
[Description("OpenDream could not be compiled due to being unable to locate the dotnet executable!")]
OpenDreamCantFindDotnet,
/// <summary>
/// Could not install OpenDream due to it not meeting the minimum version requirements.
/// </summary>
[Description("The specified OpenDream version is too old!")]
OpenDreamTooOld,
}
}
@@ -152,6 +152,9 @@ namespace Tgstation.Server.Host.Components.Engine
progressSection2,
cancellationToken);
if (!await repo.ShaIsParent("fab769776dada6b9bcad546094d78c604049e0e9", cancellationToken))
throw new JobException(ErrorCode.OpenDreamTooOld);
return new RepositoryEngineInstallationData(IOManager, repo, InstallationSourceSubDirectory);
}
catch
@@ -84,6 +84,55 @@ namespace Tgstation.Server.Tests.Live.Instance
.Run(cancellationToken);
}
public static async ValueTask<IEngineInstallationData> DownloadEngineVersion(
EngineVersion compatVersion,
IInstanceClient instanceClient,
IFileDownloader fileDownloader,
CancellationToken cancellationToken)
{
var odRepoDir = Path.GetFullPath(Path.Combine(instanceClient.Metadata.Path, "..", "OpenDreamRepo"));
var tmpIOManager = new ResolvingIOManager(new DefaultIOManager(), odRepoDir);
var mockOptions = new Mock<IOptions<GeneralConfiguration>>();
mockOptions.SetupGet(x => x.Value).Returns(new GeneralConfiguration());
IEngineInstaller byondInstaller =
compatVersion.Engine == EngineType.OpenDream
? new OpenDreamInstaller(
new DefaultIOManager(),
Mock.Of<ILogger<OpenDreamInstaller>>(),
new PlatformIdentifier(),
Mock.Of<IProcessExecutor>(),
new RepositoryManager(
new LibGit2RepositoryFactory(
Mock.Of<ILogger<LibGit2RepositoryFactory>>()),
new LibGit2Commands(),
tmpIOManager,
new NoopEventConsumer(),
Mock.Of<IPostWriteHandler>(),
Mock.Of<IGitRemoteFeaturesFactory>(),
Mock.Of<ILogger<Repository>>(),
Mock.Of<ILogger<RepositoryManager>>(),
new GeneralConfiguration()),
mockOptions.Object)
: new PlatformIdentifier().IsWindows
? new WindowsByondInstaller(
Mock.Of<IProcessExecutor>(),
Mock.Of<IIOManager>(),
fileDownloader,
Options.Create(new GeneralConfiguration()),
Mock.Of<ILogger<WindowsByondInstaller>>())
: new PosixByondInstaller(
Mock.Of<IPostWriteHandler>(),
Mock.Of<IIOManager>(),
fileDownloader,
Mock.Of<ILogger<PosixByondInstaller>>());
using var windowsByondInstaller = byondInstaller as WindowsByondInstaller;
// get the bytes for stable
return await byondInstaller.DownloadVersion(compatVersion, null, cancellationToken);
}
public async Task RunCompatTests(
EngineVersion compatVersion,
IInstanceClient instanceClient,
@@ -147,49 +196,10 @@ namespace Tgstation.Server.Tests.Live.Instance
var jrt = new JobsRequiredTest(instanceClient.Jobs);
var odRepoDir = Path.GetFullPath(Path.Combine(instanceClient.Metadata.Path, "..", "OpenDreamRepo"));
var tmpIOManager = new ResolvingIOManager(new DefaultIOManager(), odRepoDir);
var mockOptions = new Mock<IOptions<GeneralConfiguration>>();
mockOptions.SetupGet(x => x.Value).Returns(new GeneralConfiguration());
IEngineInstaller byondInstaller =
compatVersion.Engine == EngineType.OpenDream
? new OpenDreamInstaller(
new DefaultIOManager(),
Mock.Of<ILogger<OpenDreamInstaller>>(),
new PlatformIdentifier(),
Mock.Of<IProcessExecutor>(),
new RepositoryManager(
new LibGit2RepositoryFactory(
Mock.Of<ILogger<LibGit2RepositoryFactory>>()),
new LibGit2Commands(),
tmpIOManager,
new NoopEventConsumer(),
Mock.Of<IPostWriteHandler>(),
Mock.Of<IGitRemoteFeaturesFactory>(),
Mock.Of<ILogger<Repository>>(),
Mock.Of<ILogger<RepositoryManager>>(),
new GeneralConfiguration()),
mockOptions.Object)
: new PlatformIdentifier().IsWindows
? new WindowsByondInstaller(
Mock.Of<IProcessExecutor>(),
Mock.Of<IIOManager>(),
fileDownloader,
Options.Create(new GeneralConfiguration()),
Mock.Of<ILogger<WindowsByondInstaller>>())
: new PosixByondInstaller(
Mock.Of<IPostWriteHandler>(),
Mock.Of<IIOManager>(),
fileDownloader,
Mock.Of<ILogger<PosixByondInstaller>>());
using var windowsByondInstaller = byondInstaller as WindowsByondInstaller;
// get the bytes for stable
EngineInstallResponse installJob2;
await using (var stableBytesMs = await TestingUtils.ExtractMemoryStreamFromInstallationData(await byondInstaller.DownloadVersion(compatVersion, null, cancellationToken), cancellationToken))
await using (var stableBytesMs = await TestingUtils.ExtractMemoryStreamFromInstallationData(
await DownloadEngineVersion(compatVersion, instanceClient, fileDownloader, cancellationToken),
cancellationToken))
{
installJob2 = await instanceClient.Engine.SetActiveVersion(new EngineVersionRequest
{
@@ -40,6 +40,7 @@ using Tgstation.Server.Host.Components;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.Database;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.Jobs;
using Tgstation.Server.Host.System;
using Tgstation.Server.Tests.Live.Instance;
@@ -1385,15 +1386,35 @@ namespace Tgstation.Server.Tests.Live
if (TestingUtils.RunningInGitHubActions) // they only have 2 cores, can't handle intense parallelization
await byondApiCompatTests;
var odCompatTests = FailFast(
instanceTest
async Task ODCompatTests()
{
var edgeODVersionTask = EngineTest.GetEdgeVersion(EngineType.OpenDream, fileDownloader, cancellationToken);
;
var ex = await Assert.ThrowsExceptionAsync<JobException>(
() => InstanceTest.DownloadEngineVersion(
new EngineVersion
{
Engine = EngineType.OpenDream,
SourceSHA = "f1dc153caf9d84cd1d0056e52286cc0163e3f4d3", // 1b4 verified version
},
instanceClient,
fileDownloader,
cancellationToken).AsTask());
Assert.AreEqual(ErrorCode.OpenDreamTooOld, ex.ErrorCode);
await instanceTest
.RunCompatTests(
await EngineTest.GetEdgeVersion(EngineType.OpenDream, fileDownloader, cancellationToken),
await edgeODVersionTask,
adminClient.Instances.CreateClient(odInstance),
odDMPort,
odDDPort,
server.HighPriorityDreamDaemon,
cancellationToken));
cancellationToken);
}
var odCompatTests = FailFast(ODCompatTests());
if (TestingUtils.RunningInGitHubActions) // they only have 2 cores, can't handle intense parallelization
await odCompatTests;