Merge pull request #1209 from tgstation/FixesFixesFixes

v4.8.2
This commit is contained in:
Jordan Brown
2021-01-27 13:48:53 -05:00
committed by GitHub
9 changed files with 87 additions and 28 deletions
+2 -2
View File
@@ -31,7 +31,7 @@ jobs:
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y libc6-i386 libstdc++6:i386
sudo apt-get install -y -o APT::Immediate-Configure=0 libc6-i386 libstdc++6:i386
- name: Install BYOND
if: steps.cache-byond.outputs.cache-hit != 'true'
@@ -315,7 +315,7 @@ jobs:
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y libc6-i386 libstdc++6:i386 gdb
sudo apt-get install -y -o APT::Immediate-Configure=0 libc6-i386 libstdc++6:i386 gdb
- name: Install Node 12.X
uses: actions/setup-node@v1
+1 -1
View File
@@ -452,7 +452,7 @@ Should you end up with a lost database for some reason or want to reattach a det
## Troubleshooting
Feel free to ask for help at the coderbus discord in \#hosting-questions: https://discord.gg/Vh8TJp9. Cyberboss#0016 can answer most questions.
Feel free to ask for help [on the discussions page](https://github.com/tgstation/tgstation-server/discussions).
## Contributing
+1 -1
View File
@@ -3,7 +3,7 @@
<!-- Integration tests will ensure they match across the board -->
<Import Project="ControlPanelVersion.props" />
<PropertyGroup>
<TgsCoreVersion>4.8.1</TgsCoreVersion>
<TgsCoreVersion>4.8.2</TgsCoreVersion>
<TgsConfigVersion>2.3.0</TgsConfigVersion>
<TgsApiVersion>8.3.0</TgsApiVersion>
<TgsClientVersion>9.2.0</TgsClientVersion>
@@ -235,7 +235,7 @@ namespace Tgstation.Server.Host.Controllers
return;
}
logger.LogDebug("Starting swarm request processing...");
logger.LogTrace("Starting swarm request processing...");
await base.OnActionExecutionAsync(context, next).ConfigureAwait(false);
}
}
@@ -1,5 +1,7 @@
using System;
using Microsoft.Extensions.Options;
using Octokit;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.System;
namespace Tgstation.Server.Host.Core
@@ -12,35 +14,43 @@ namespace Tgstation.Server.Host.Core
/// </summary>
readonly IAssemblyInformationProvider assemblyInformationProvider;
/// <summary>
/// The <see cref="GeneralConfiguration"/> for the <see cref="GitHubClientFactory"/>.
/// </summary>
readonly GeneralConfiguration generalConfiguration;
/// <summary>
/// Construct a <see cref="GitHubClientFactory"/>
/// </summary>
/// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/></param>
public GitHubClientFactory(IAssemblyInformationProvider assemblyInformationProvider)
/// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/>.</param>
/// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param>
public GitHubClientFactory(IAssemblyInformationProvider assemblyInformationProvider, IOptions<GeneralConfiguration> generalConfigurationOptions)
{
this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
}
/// <summary>
/// Create a <see cref="GitHubClient"/>
/// Create a <see cref="GitHubClient"/>.
/// </summary>
/// <param name="accessToken">Optional access token to use as credentials.</param>
/// <returns>A new <see cref="GitHubClient"/></returns>
GitHubClient CreateBaseClient() => new GitHubClient(
new ProductHeaderValue(
assemblyInformationProvider.ProductInfoHeaderValue.Product.Name,
assemblyInformationProvider.ProductInfoHeaderValue.Product.Version));
/// <inheritdoc />
public IGitHubClient CreateClient() => CreateBaseClient();
/// <inheritdoc />
public IGitHubClient CreateClient(string accessToken)
GitHubClient CreateClientImpl(string accessToken)
{
if (accessToken == null)
throw new ArgumentNullException(nameof(accessToken));
var result = CreateBaseClient();
result.Credentials = new Credentials(accessToken);
return result;
var client = new GitHubClient(
new ProductHeaderValue(
assemblyInformationProvider.ProductInfoHeaderValue.Product.Name,
assemblyInformationProvider.ProductInfoHeaderValue.Product.Version));
if (accessToken != null)
client.Credentials = new Credentials(accessToken);
return client;
}
/// <inheritdoc />
public IGitHubClient CreateClient() => CreateClientImpl(generalConfiguration.GitHubAccessToken);
/// <inheritdoc />
public IGitHubClient CreateClient(string accessToken) => CreateClientImpl(accessToken ?? throw new ArgumentNullException(nameof(accessToken)));
}
}
@@ -8,7 +8,7 @@ namespace Tgstation.Server.Host.Core
public interface IGitHubClientFactory
{
/// <summary>
/// Create a client with anonymous authentication or general authentica. Low rate limit. Attempts to use the server's token to bypass this.
/// Create a <see cref="IGitHubClient"/> client. Low rate limit unless the server's GitHubAccessToken is set to bypass it.
/// </summary>
/// <returns>A new <see cref="IGitHubClient"/>.</returns>
IGitHubClient CreateClient();
@@ -535,6 +535,11 @@ namespace Tgstation.Server.Host.Swarm
return false;
}
}
else
{
logger.LogTrace("No need to re-initiate update as it originated here on the swarm controller");
updateCommitTcs = new TaskCompletionSource<bool>();
}
logger.LogDebug("Prepared for update to version {0}", version);
}
@@ -1,9 +1,11 @@
using Microsoft.Extensions.Options;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Octokit;
using System;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.System;
namespace Tgstation.Server.Host.Core.Tests
@@ -12,7 +14,11 @@ namespace Tgstation.Server.Host.Core.Tests
public sealed class TestGitHubClientFactory
{
[TestMethod]
public void TestContruction() => Assert.ThrowsException<ArgumentNullException>(() => new GitHubClientFactory(null));
public void TestContruction()
{
Assert.ThrowsException<ArgumentNullException>(() => new GitHubClientFactory(Mock.Of<IAssemblyInformationProvider>(), null));
Assert.ThrowsException<ArgumentNullException>(() => new GitHubClientFactory(null, null));
}
[TestMethod]
public async Task TestCreateBasicClient()
@@ -20,7 +26,12 @@ namespace Tgstation.Server.Host.Core.Tests
var mockApp = new Mock<IAssemblyInformationProvider>();
mockApp.SetupGet(x => x.ProductInfoHeaderValue).Returns(new ProductInfoHeaderValue("TGSTests", "1.2.3")).Verifiable();
var factory = new GitHubClientFactory(mockApp.Object);
var mockOptions = new Mock<IOptions<GeneralConfiguration>>();
var gc = new GeneralConfiguration();
Assert.IsNull(gc.GitHubAccessToken);
mockOptions.SetupGet(x => x.Value).Returns(gc);
var factory = new GitHubClientFactory(mockApp.Object, mockOptions.Object);
var client = factory.CreateClient();
Assert.IsNotNull(client);
@@ -28,6 +39,12 @@ namespace Tgstation.Server.Host.Core.Tests
Assert.AreEqual(AuthenticationType.Anonymous, credentials.AuthenticationType);
gc.GitHubAccessToken = "asdfasdfasdfasdfasdfasdf";
client = factory.CreateClient();
Assert.IsNotNull(client);
credentials = await client.Connection.CredentialStore.GetCredentials().ConfigureAwait(false);
Assert.AreEqual(AuthenticationType.Oauth, credentials.AuthenticationType);
mockApp.VerifyAll();
}
@@ -38,7 +55,9 @@ namespace Tgstation.Server.Host.Core.Tests
var mockApp = new Mock<IAssemblyInformationProvider>();
mockApp.SetupGet(x => x.ProductInfoHeaderValue).Returns(new ProductInfoHeaderValue("TGSTests", "1.2.3")).Verifiable();
var factory = new GitHubClientFactory(mockApp.Object);
var mockOptions = new Mock<IOptions<GeneralConfiguration>>();
mockOptions.SetupGet(x => x.Value).Returns(new GeneralConfiguration());
var factory = new GitHubClientFactory(mockApp.Object, mockOptions.Object);
Assert.ThrowsException<ArgumentNullException>(() => factory.CreateClient(null));
@@ -257,7 +257,7 @@ namespace Tgstation.Server.Tests
await Assert.ThrowsExceptionAsync<ConflictException>(() => node1Client.Instances.GetId(controllerInstance, cancellationToken));
// test update
var testUpdateVersion = new Version(4, 6, 2);
var testUpdateVersion = new Version(4, 8, 1);
await node1Client.Administration.Update(
new Administration
{
@@ -276,11 +276,36 @@ namespace Tgstation.Server.Tests
var updatedAssemblyVersion = FileVersionInfo.GetVersionInfo(updatedAssemblyPath);
Assert.AreEqual(testUpdateVersion, Version.Parse(updatedAssemblyVersion.FileVersion).Semver());
Directory.Delete(server.UpdatePath, true);
}
CheckServerUpdated(controller);
CheckServerUpdated(node1);
CheckServerUpdated(node2);
// regression: test it also works from the controller
serverTask = Task.WhenAll(
node1.Run(cancellationToken),
node2.Run(cancellationToken),
controller.Run(cancellationToken));
using var controllerClient2 = await CreateAdminClient(controller.Url, cancellationToken);
using var node1Client2 = await CreateAdminClient(node1.Url, cancellationToken);
using var node2Client2 = await CreateAdminClient(node2.Url, cancellationToken);
await controllerClient2.Administration.Update(
new Administration
{
NewVersion = testUpdateVersion
},
cancellationToken);
await Task.WhenAny(Task.Delay(TimeSpan.FromMinutes(2)), serverTask);
Assert.IsTrue(serverTask.IsCompleted);
CheckServerUpdated(controller);
CheckServerUpdated(node1);
CheckServerUpdated(node2);
}
finally
{