From 06d5515ebd6d02268aec90a4af8e574c9fe9cbe0 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Mon, 25 May 2020 12:27:25 -0400 Subject: [PATCH 01/25] Re-enable the disabled watchdog tests --- tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs index f7a8ed3e55..e21115618d 100644 --- a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs @@ -44,11 +44,8 @@ namespace Tgstation.Server.Tests.Instance await RunBasicTest(cancellationToken); - // await RunLongRunningTestThenUpdate(cancellationToken); - // await RunLongRunningTestThenUpdateWithByondVersionSwitch(cancellationToken); - - // Remove this deploy when the above tests are reenabled - await DeployTestDme("LongRunning/long_running_test", DreamDaemonSecurity.Trusted, cancellationToken); + await RunLongRunningTestThenUpdate(cancellationToken); + await RunLongRunningTestThenUpdateWithByondVersionSwitch(cancellationToken); await RunHeartbeatTest(cancellationToken); From 812e27574de3cdf7474451f6f6ced4bbc0aed2fd Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Mon, 25 May 2020 20:36:12 -0400 Subject: [PATCH 02/25] Is this the issue? --- tests/DMAPI/LongRunning/Test.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/DMAPI/LongRunning/Test.dm b/tests/DMAPI/LongRunning/Test.dm index 631dcfccae..341fbe260b 100644 --- a/tests/DMAPI/LongRunning/Test.dm +++ b/tests/DMAPI/LongRunning/Test.dm @@ -32,6 +32,7 @@ return "feck" /world/Reboot(reason) + world.sleep_offline = FALSE TgsChatBroadcast("World Rebooting") TgsReboot() From eefbb581ef59fb114da3ec818179e40c6925714a Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Mon, 25 May 2020 22:27:28 -0400 Subject: [PATCH 03/25] DisposeAndNullControllers from a locked context --- .../Components/Watchdog/BasicWatchdog.cs | 2 +- .../Components/Watchdog/ExperimentalWatchdog.cs | 6 ++---- .../Components/Watchdog/WatchdogBase.cs | 17 ++++++++++++++++- .../Components/Watchdog/WindowsWatchdog.cs | 4 ++-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs index 13c96f350a..e3e8968fd8 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs @@ -192,7 +192,7 @@ namespace Tgstation.Server.Host.Components.Watchdog }; /// - protected override void DisposeAndNullControllers() + protected override void DisposeAndNullControllersImpl() { Server?.Dispose(); Server = null; diff --git a/src/Tgstation.Server.Host/Components/Watchdog/ExperimentalWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/ExperimentalWatchdog.cs index 02daf7d157..6547ef6d62 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/ExperimentalWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/ExperimentalWatchdog.cs @@ -392,10 +392,8 @@ namespace Tgstation.Server.Host.Components.Watchdog } #pragma warning restore CA1502 - /// - /// Call on and and set them to - /// - protected override void DisposeAndNullControllers() + /// + protected override void DisposeAndNullControllersImpl() { alphaServer?.Dispose(); alphaServer = null; diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs index 74b3e06371..66837c302a 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs @@ -112,6 +112,11 @@ namespace Tgstation.Server.Host.Components.Watchdog /// readonly IRestartRegistration restartRegistration; + /// + /// used for . + /// + readonly object controllerDisposeLock; + /// /// If the should in /// @@ -201,6 +206,7 @@ namespace Tgstation.Server.Host.Components.Watchdog ActiveLaunchParameters = initialLaunchParameters; releaseServers = false; ActiveParametersUpdated = new TaskCompletionSource(); + controllerDisposeLock = new object(); restartRegistration = serverControl.RegisterForRestart(this); try @@ -463,7 +469,16 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// Call and null the fields for all s and set to . /// - protected abstract void DisposeAndNullControllers(); + protected abstract void DisposeAndNullControllersImpl(); + + /// + /// Wrapper for under a locked context. + /// + protected void DisposeAndNullControllers() + { + lock (controllerDisposeLock) + DisposeAndNullControllersImpl(); + } /// /// Get the active . diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs index 895347f4a6..730ced06b9 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs @@ -101,9 +101,9 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - protected override void DisposeAndNullControllers() + protected override void DisposeAndNullControllersImpl() { - base.DisposeAndNullControllers(); + base.DisposeAndNullControllersImpl(); // If we reach this point, we can guarantee PrepServerForLaunch will be called before starting again. activeSwappable = null; From 499172d26858d698142fb0484e6f19dd0b14c9b8 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Mon, 25 May 2020 22:47:55 -0400 Subject: [PATCH 04/25] Add some logging --- tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs index e21115618d..a1e4c45046 100644 --- a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs @@ -250,6 +250,7 @@ namespace Tgstation.Server.Tests.Instance try { + global::System.Console.WriteLine("TEST: Sending world reboot topic..."); var result = await bts.SendTopic(IPAddress.Loopback, "tgs_integration_test_special_tactics=1", 1337, cancellationToken); Assert.AreEqual("ack", result.StringData); From 2904f65b2d76fa51f45cdb39abafdd212d622739 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 27 May 2020 17:22:09 -0400 Subject: [PATCH 05/25] Log request completion --- .../Controllers/ApiController.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Controllers/ApiController.cs b/src/Tgstation.Server.Host/Controllers/ApiController.cs index c021746687..7892e34346 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiController.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiController.cs @@ -56,6 +56,11 @@ namespace Tgstation.Server.Host.Controllers /// readonly bool requireHeaders; + /// + /// Logging identifier for requests. + /// + ulong requestId; + /// /// Construct an /// @@ -163,7 +168,8 @@ namespace Tgstation.Server.Host.Controllers if (ApiHeaders != null) Logger.LogDebug( - "Request made by User ID {0}. Api version: {1}. User-Agent: {2}. Type: {3}. Route {4}{5} to Instance {6}", + "Request #{0} made by User ID {1}. Api version: {2}. User-Agent: {3}. Type: {4}. Route {5}{6} to Instance {7}", + ++requestId, AuthenticationContext?.User.Id.Value.ToString(CultureInfo.InvariantCulture), ApiHeaders.ApiVersion.Semver(), ApiHeaders.RawUserAgent, @@ -181,6 +187,11 @@ namespace Tgstation.Server.Host.Controllers Logger.LogDebug("Request cancelled! Exception: {0}", e); throw; } + finally + { + if (ApiHeaders != null) + Logger.LogTrace("Request #{0} completed", requestId); + } } #pragma warning restore CA1506 } From c4be9a8ef824475c68a9e20ec251caf464232f4b Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 27 May 2020 17:39:18 -0400 Subject: [PATCH 06/25] Remove the typeparam of DatabaseContext - Also rename the design-time helper function. --- .../Configuration/DatabaseConfiguration.cs | 2 +- src/Tgstation.Server.Host/Core/Application.cs | 2 +- .../Database/DatabaseContext.cs | 47 +++++++++---------- .../Database/DatabaseSeeder.cs | 4 +- .../DesignTimeDbContextFactoryHelpers.cs | 4 +- .../Design/MySqlDesignTimeDbContextFactory.cs | 2 +- .../PostgresSqlDesignTimeDbContextFactory.cs | 2 +- .../SqlServerDesignTimeDbContextFactory.cs | 2 +- .../SqliteDesignTimeDbContextFactory.cs | 2 +- .../Database/MySqlDatabaseContext.cs | 12 ++--- .../Database/PostgresSqlDatabaseContext.cs | 12 ++--- .../Database/SqlServerDatabaseContext.cs | 12 ++--- .../Database/SqliteDatabaseContext.cs | 12 ++--- 13 files changed, 57 insertions(+), 58 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/DatabaseConfiguration.cs b/src/Tgstation.Server.Host/Configuration/DatabaseConfiguration.cs index a02f70256e..abe1a6d5df 100644 --- a/src/Tgstation.Server.Host/Configuration/DatabaseConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/DatabaseConfiguration.cs @@ -4,7 +4,7 @@ using Newtonsoft.Json.Converters; namespace Tgstation.Server.Host.Configuration { /// - /// Configuration options for the + /// Configuration options for the /// sealed class DatabaseConfiguration { diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index ac58267bc1..7f486eeb43 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -202,7 +202,7 @@ namespace Tgstation.Server.Host.Core // CORS conditionally enabled later services.AddCors(); - void AddTypedContext() where TContext : DatabaseContext + void AddTypedContext() where TContext : DatabaseContext { services.AddDbContext(builder => { diff --git a/src/Tgstation.Server.Host/Database/DatabaseContext.cs b/src/Tgstation.Server.Host/Database/DatabaseContext.cs index 82a974a01c..10dddb039d 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseContext.cs @@ -18,95 +18,94 @@ namespace Tgstation.Server.Host.Database /// /// Backend abstract implementation of /// - /// The child used to implement a backend. #pragma warning disable CA1506 // TODO: Decomplexify - abstract class DatabaseContext : DbContext, IDatabaseContext where TParentContext : DbContext + abstract class DatabaseContext : DbContext, IDatabaseContext { /// public DatabaseType DatabaseType => DatabaseConfiguration.DatabaseType; /// - /// The s in the . + /// The s in the . /// public DbSet Users { get; set; } /// - /// The s in the . + /// The s in the . /// public DbSet Instances { get; set; } /// - /// The s in the . + /// The s in the . /// public DbSet CompileJobs { get; set; } /// - /// The s in the . + /// The s in the . /// public DbSet RevisionInformations { get; set; } /// - /// The in the . + /// The in the . /// public DbSet DreamMakerSettings { get; set; } /// - /// The s in the . + /// The s in the . /// public DbSet ChatBots { get; set; } /// - /// The in the . + /// The in the . /// public DbSet DreamDaemonSettings { get; set; } /// - /// The in the . + /// The in the . /// public DbSet RepositorySettings { get; set; } /// - /// The s in the . + /// The s in the . /// public DbSet InstanceUsers { get; set; } /// - /// The s in the . + /// The s in the . /// public DbSet ChatChannels { get; set; } /// - /// The s in the . + /// The s in the . /// public DbSet Jobs { get; set; } /// - /// The s in the . + /// The s in the . /// public DbSet ReattachInformations { get; set; } /// - /// The s in the . + /// The s in the . /// public DbSet WatchdogReattachInformations { get; set; } /// - /// The s in the + /// The s in the /// public DbSet TestMerges { get; set; } /// - /// The s om the + /// The s om the /// public DbSet RevInfoTestMerges { get; set; } /// - /// The for the + /// The for the /// protected ILogger Logger { get; } /// - /// The for the + /// The for the /// protected DatabaseConfiguration DatabaseConfiguration { get; } @@ -150,7 +149,7 @@ namespace Tgstation.Server.Host.Database IDatabaseCollection IDatabaseContext.WatchdogReattachInformations => watchdogReattachInformationsCollection; /// - /// The for the + /// The for the /// readonly IDatabaseSeeder databaseSeeder; @@ -220,13 +219,13 @@ namespace Tgstation.Server.Host.Database readonly IDatabaseCollection watchdogReattachInformationsCollection; /// - /// Construct a + /// Construct a /// - /// The for the + /// The for the . /// The containing the value of /// The value of /// The value of - public DatabaseContext(DbContextOptions dbContextOptions, IOptions databaseConfigurationOptions, IDatabaseSeeder databaseSeeder, ILogger logger) : base(dbContextOptions) + public DatabaseContext(DbContextOptions dbContextOptions, IOptions databaseConfigurationOptions, IDatabaseSeeder databaseSeeder, ILogger logger) : base(dbContextOptions) { DatabaseConfiguration = databaseConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(databaseConfigurationOptions)); this.databaseSeeder = databaseSeeder ?? throw new ArgumentNullException(nameof(databaseSeeder)); @@ -410,7 +409,7 @@ namespace Tgstation.Server.Host.Database } /// - /// Ensure the is correct for the . + /// Ensure the is correct for the . /// protected abstract void ValidateDatabaseType(); } diff --git a/src/Tgstation.Server.Host/Database/DatabaseSeeder.cs b/src/Tgstation.Server.Host/Database/DatabaseSeeder.cs index 7d13dfc80d..e7173b0067 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseSeeder.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseSeeder.cs @@ -14,12 +14,12 @@ namespace Tgstation.Server.Host.Database sealed class DatabaseSeeder : IDatabaseSeeder { /// - /// The for the + /// The for the /// readonly ICryptographySuite cryptographySuite; /// - /// The for the . + /// The for the . /// readonly IPlatformIdentifier platformIdentifier; diff --git a/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs b/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs index 9699c86a16..98f71aeaaf 100644 --- a/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs +++ b/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs @@ -4,7 +4,7 @@ using Tgstation.Server.Host.Configuration; namespace Tgstation.Server.Host.Database.Design { /// - /// Contains helpers for creating design time s + /// Contains helpers for creating design time s /// static class DesignTimeDbContextFactoryHelpers { @@ -14,7 +14,7 @@ namespace Tgstation.Server.Host.Database.Design /// The . /// The . /// The for the - public static IOptions GetDbContextOptions(DatabaseType databaseType, string connectionString) + public static IOptions GetDatabaseConfiguration(DatabaseType databaseType, string connectionString) { var dbConfig = new DatabaseConfiguration { diff --git a/src/Tgstation.Server.Host/Database/Design/MySqlDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/MySqlDesignTimeDbContextFactory.cs index 61f2cfd8df..5b39d9e63d 100644 --- a/src/Tgstation.Server.Host/Database/Design/MySqlDesignTimeDbContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/Design/MySqlDesignTimeDbContextFactory.cs @@ -20,7 +20,7 @@ namespace Tgstation.Server.Host.Database.Design using var loggerFactory = new LoggerFactory(); return new MySqlDatabaseContext( new DbContextOptions(), - DesignTimeDbContextFactoryHelpers.GetDbContextOptions( + DesignTimeDbContextFactoryHelpers.GetDatabaseConfiguration( DatabaseType.MariaDB, "Server=127.0.0.1;User Id=root;Password=fake;Database=TGS_Design"), new DatabaseSeeder( diff --git a/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs index 10963af511..2af7d7c939 100644 --- a/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs @@ -18,7 +18,7 @@ namespace Tgstation.Server.Host.Database.Design using var loggerFactory = new LoggerFactory(); return new PostgresSqlDatabaseContext( new DbContextOptions(), - DesignTimeDbContextFactoryHelpers.GetDbContextOptions( + DesignTimeDbContextFactoryHelpers.GetDatabaseConfiguration( DatabaseType.PostgresSql, "Application Name=tgstation-server;Host=127.0.0.1;Password=qCkWimNgLfWwpr7TnUHs;Username=postgres;Database=TGS_Design"), new DatabaseSeeder( diff --git a/src/Tgstation.Server.Host/Database/Design/SqlServerDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/SqlServerDesignTimeDbContextFactory.cs index 68cc43ed2f..427d84ba8a 100644 --- a/src/Tgstation.Server.Host/Database/Design/SqlServerDesignTimeDbContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/Design/SqlServerDesignTimeDbContextFactory.cs @@ -20,7 +20,7 @@ namespace Tgstation.Server.Host.Database.Design using var loggerFactory = new LoggerFactory(); return new SqlServerDatabaseContext( new DbContextOptions(), - DesignTimeDbContextFactoryHelpers.GetDbContextOptions( + DesignTimeDbContextFactoryHelpers.GetDatabaseConfiguration( DatabaseType.SqlServer, "Data Source=fake;Initial Catalog=TGS_Design;Integrated Security=True;Application Name=tgstation-server"), new DatabaseSeeder( diff --git a/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs index ba5690ec75..91de1284f2 100644 --- a/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs @@ -20,7 +20,7 @@ namespace Tgstation.Server.Host.Database.Design using var loggerFactory = new LoggerFactory(); return new SqliteDatabaseContext( new DbContextOptions(), - DesignTimeDbContextFactoryHelpers.GetDbContextOptions( + DesignTimeDbContextFactoryHelpers.GetDatabaseConfiguration( DatabaseType.Sqlite, "Data Source=tgs_design.sqlite3;Mode=ReadWriteCreate"), new DatabaseSeeder( diff --git a/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs b/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs index 009ab4463b..c18d4e723e 100644 --- a/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs @@ -9,17 +9,17 @@ using Tgstation.Server.Host.Configuration; namespace Tgstation.Server.Host.Database { /// - /// for MySQL + /// for MySQL /// - sealed class MySqlDatabaseContext : DatabaseContext + sealed class MySqlDatabaseContext : DatabaseContext { /// /// Construct a /// - /// The for the - /// The of for the - /// The for the - /// The for the + /// The for the + /// The of for the + /// The for the + /// The for the public MySqlDatabaseContext(DbContextOptions dbContextOptions, IOptions databaseConfiguration, IDatabaseSeeder databaseSeeder, ILogger logger) : base(dbContextOptions, databaseConfiguration, databaseSeeder, logger) { } diff --git a/src/Tgstation.Server.Host/Database/PostgresSqlDatabaseContext.cs b/src/Tgstation.Server.Host/Database/PostgresSqlDatabaseContext.cs index 4042b423ab..111f3918ed 100644 --- a/src/Tgstation.Server.Host/Database/PostgresSqlDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/PostgresSqlDatabaseContext.cs @@ -8,17 +8,17 @@ using Tgstation.Server.Host.Configuration; namespace Tgstation.Server.Host.Database { /// - /// for PostgresSQL. + /// for PostgresSQL. /// - sealed class PostgresSqlDatabaseContext : DatabaseContext + sealed class PostgresSqlDatabaseContext : DatabaseContext { /// /// Construct a /// - /// The for the - /// The of for the - /// The for the - /// The for the + /// The for the + /// The of for the + /// The for the + /// The for the public PostgresSqlDatabaseContext( DbContextOptions dbContextOptions, IOptions databaseConfiguration, diff --git a/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs b/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs index be2a4b4876..42c6aedc4e 100644 --- a/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs @@ -7,17 +7,17 @@ using Tgstation.Server.Host.Configuration; namespace Tgstation.Server.Host.Database { /// - /// for Sqlserver + /// for Sqlserver /// - sealed class SqlServerDatabaseContext : DatabaseContext + sealed class SqlServerDatabaseContext : DatabaseContext { /// /// Construct a /// - /// The for the - /// The of for the - /// The for the - /// The for the + /// The for the + /// The of for the + /// The for the + /// The for the public SqlServerDatabaseContext(DbContextOptions dbContextOptions, IOptions databaseConfiguration, IDatabaseSeeder databaseSeeder, ILogger logger) : base(dbContextOptions, databaseConfiguration, databaseSeeder, logger) { } diff --git a/src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs b/src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs index 2e71317a65..4d9fecf844 100644 --- a/src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs @@ -9,17 +9,17 @@ using Tgstation.Server.Host.Configuration; namespace Tgstation.Server.Host.Database { /// - /// for MySQL + /// for MySQL /// - sealed class SqliteDatabaseContext : DatabaseContext + sealed class SqliteDatabaseContext : DatabaseContext { /// /// Construct a /// - /// The for the - /// The of for the - /// The for the - /// The for the + /// The for the + /// The of for the + /// The for the + /// The for the public SqliteDatabaseContext(DbContextOptions dbContextOptions, IOptions databaseConfiguration, IDatabaseSeeder databaseSeeder, ILogger logger) : base(dbContextOptions, databaseConfiguration, databaseSeeder, logger) { } From 224429e9598a3de0da4d13044386dd215907f633 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 27 May 2020 17:54:16 -0400 Subject: [PATCH 07/25] Increase the time we give DD to reboot --- tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs index a1e4c45046..59066cfaf5 100644 --- a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs @@ -254,7 +254,7 @@ namespace Tgstation.Server.Tests.Instance var result = await bts.SendTopic(IPAddress.Loopback, "tgs_integration_test_special_tactics=1", 1337, cancellationToken); Assert.AreEqual("ack", result.StringData); - await Task.Delay(7000, cancellationToken); + await Task.Delay(10000, cancellationToken); } catch (OperationCanceledException) { From a4ce21eecf29e5a44a1420c6d588742e4134e07b Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 27 May 2020 19:17:34 -0400 Subject: [PATCH 08/25] Log exports in DMAPI tests --- tests/DMAPI/BasicOperation/Test.dm | 4 ++++ tests/DMAPI/LongRunning/Test.dm | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/DMAPI/BasicOperation/Test.dm b/tests/DMAPI/BasicOperation/Test.dm index 21ba9e6226..a603a099be 100644 --- a/tests/DMAPI/BasicOperation/Test.dm +++ b/tests/DMAPI/BasicOperation/Test.dm @@ -25,6 +25,10 @@ world.log << "You really shouldn't be able to read this" +/world/Export(url) + log << "Export: [url]" + return ..() + /world/Topic(T, Addr, Master, Keys) world.log << "Topic: [T]" . = HandleTopic(T) diff --git a/tests/DMAPI/LongRunning/Test.dm b/tests/DMAPI/LongRunning/Test.dm index 341fbe260b..f74dd265f3 100644 --- a/tests/DMAPI/LongRunning/Test.dm +++ b/tests/DMAPI/LongRunning/Test.dm @@ -12,9 +12,9 @@ world.TgsInitializationComplete() /world/Topic(T, Addr, Master, Keys) - world.log << "Topic: [T]" + log << "Topic: [T]" . = HandleTopic(T) - world.log << "Response: [.]" + log << "Response: [.]" /world/proc/HandleTopic(T) TGS_TOPIC @@ -41,6 +41,10 @@ world.TgsChatBroadcast("Recieved event: [json_encode(args)]") +/world/Export(url) + log << "Export: [url]" + return ..() + /proc/RebootAsync() set waitfor = FALSE world.sleep_offline = FALSE From 313119c9976586110734d7cc4388077f32deacd9 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 27 May 2020 19:30:50 -0400 Subject: [PATCH 09/25] Fix request counting --- .../Controllers/ApiController.cs | 13 +-------- src/Tgstation.Server.Host/Core/Application.cs | 2 ++ .../ApplicationBuilderExtensions.cs | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/ApiController.cs b/src/Tgstation.Server.Host/Controllers/ApiController.cs index 7892e34346..a60949643f 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiController.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiController.cs @@ -56,11 +56,6 @@ namespace Tgstation.Server.Host.Controllers /// readonly bool requireHeaders; - /// - /// Logging identifier for requests. - /// - ulong requestId; - /// /// Construct an /// @@ -168,8 +163,7 @@ namespace Tgstation.Server.Host.Controllers if (ApiHeaders != null) Logger.LogDebug( - "Request #{0} made by User ID {1}. Api version: {2}. User-Agent: {3}. Type: {4}. Route {5}{6} to Instance {7}", - ++requestId, + "Request details: User ID {0}. Api version: {1}. User-Agent: {2}. Type: {3}. Route {4}{5} to Instance {6}", AuthenticationContext?.User.Id.Value.ToString(CultureInfo.InvariantCulture), ApiHeaders.ApiVersion.Semver(), ApiHeaders.RawUserAgent, @@ -187,11 +181,6 @@ namespace Tgstation.Server.Host.Controllers Logger.LogDebug("Request cancelled! Exception: {0}", e); throw; } - finally - { - if (ApiHeaders != null) - Logger.LogTrace("Request #{0} completed", requestId); - } } #pragma warning restore CA1506 } diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index 7f486eeb43..c7ed253c9c 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -357,6 +357,8 @@ namespace Tgstation.Server.Host.Core // Final point where we wrap exceptions in a 500 (ErrorMessage) response applicationBuilder.UseServerErrorHandling(); + applicationBuilder.UseRequestCounting(); + // 503 requests made while the application is starting applicationBuilder.UseAsyncInitialization(async (cancellationToken) => { diff --git a/src/Tgstation.Server.Host/Extensions/ApplicationBuilderExtensions.cs b/src/Tgstation.Server.Host/Extensions/ApplicationBuilderExtensions.cs index f155aff190..2fe00098db 100644 --- a/src/Tgstation.Server.Host/Extensions/ApplicationBuilderExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ApplicationBuilderExtensions.cs @@ -107,5 +107,32 @@ namespace Tgstation.Server.Host.Extensions } }); } + + /// + /// Add middleware for logging the request number. + /// + /// The to configure. + public static void UseRequestCounting(this IApplicationBuilder applicationBuilder) + { + if (applicationBuilder == null) + throw new ArgumentNullException(nameof(applicationBuilder)); + + ulong requestCounter = 0; + + applicationBuilder.Use(async (context, next) => + { + var logger = GetLogger(context); + var requestNumber = ++requestCounter; + logger.LogTrace("Starting request #{0}...", requestNumber); + try + { + await next().ConfigureAwait(false); + } + finally + { + logger.LogTrace("Finished request #{0}", requestNumber); + } + }); + } } } From 9d1b6e16668f8a8e5222f22f792688ed64080f04 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 27 May 2020 19:43:19 -0400 Subject: [PATCH 10/25] Wtf is happening --- tests/DMAPI/LongRunning/Test.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/DMAPI/LongRunning/Test.dm b/tests/DMAPI/LongRunning/Test.dm index f74dd265f3..73b84e952b 100644 --- a/tests/DMAPI/LongRunning/Test.dm +++ b/tests/DMAPI/LongRunning/Test.dm @@ -49,5 +49,7 @@ set waitfor = FALSE world.sleep_offline = FALSE world.TgsChatBroadcast("Rebooting after 3 seconds"); + world.log << "About to sleep. sleep_offline: [world.sleep_offline]" sleep(30) + world.log << "Done sleep, calling Reboot" world.Reboot() From 4afa5e75b024d7343b4de1af1f03c3a743949f6c Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 27 May 2020 21:08:29 -0400 Subject: [PATCH 11/25] AHHHH WTFFF --- build/Version.props | 2 +- src/DMAPI/tgs/v4/api.dm | 4 +++- src/DMAPI/tgs/v5/api.dm | 2 ++ tests/DMAPI/LongRunning/Test.dm | 1 + tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs | 3 --- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/build/Version.props b/build/Version.props index a5d010ffb8..bda24b2315 100644 --- a/build/Version.props +++ b/build/Version.props @@ -5,7 +5,7 @@ 4.3.0 6.5.0 7.1.0 - 5.2.1 + 5.2.2 0.4.0 1.1.0 diff --git a/src/DMAPI/tgs/v4/api.dm b/src/DMAPI/tgs/v4/api.dm index 1dc98f811e..5e7f3c60be 100644 --- a/src/DMAPI/tgs/v4/api.dm +++ b/src/DMAPI/tgs/v4/api.dm @@ -114,12 +114,14 @@ /datum/tgs_api/v4/OnInitializationComplete() Export(TGS4_COMM_SERVER_PRIMED) - var/tgs4_secret_sleep_offline_sauce = 24051994 + var/tgs4_secret_sleep_offline_sauce = 29051994 var/old_sleep_offline = world.sleep_offline world.sleep_offline = tgs4_secret_sleep_offline_sauce sleep(1) if(world.sleep_offline == tgs4_secret_sleep_offline_sauce) //if not someone changed it world.sleep_offline = old_sleep_offline + else + TGS_WARNING_LOG("world.sleep_offline unexpectedly changed!") /datum/tgs_api/v4/OnTopic(T) var/list/params = params2list(T) diff --git a/src/DMAPI/tgs/v5/api.dm b/src/DMAPI/tgs/v5/api.dm index 8ca85faf05..9dab17c935 100644 --- a/src/DMAPI/tgs/v5/api.dm +++ b/src/DMAPI/tgs/v5/api.dm @@ -94,6 +94,8 @@ sleep(1) if(world.sleep_offline == tgs4_secret_sleep_offline_sauce) //if not someone changed it world.sleep_offline = old_sleep_offline + else + TGS_WARNING_LOG("world.sleep_offline unexpectedly changed!") /datum/tgs_api/v5/proc/TopicResponse(error_message = null) var/list/response = list() diff --git a/tests/DMAPI/LongRunning/Test.dm b/tests/DMAPI/LongRunning/Test.dm index 73b84e952b..ee7eaf56ea 100644 --- a/tests/DMAPI/LongRunning/Test.dm +++ b/tests/DMAPI/LongRunning/Test.dm @@ -1,4 +1,5 @@ /world/New() + log << "Initial value of sleep_offline: [sleep_offline]" TgsNew(new /datum/tgs_event_handler/impl, TGS_SECURITY_ULTRASAFE) StartAsync() diff --git a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs index 59066cfaf5..2bb6f3b260 100644 --- a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs @@ -260,9 +260,6 @@ namespace Tgstation.Server.Tests.Instance { throw; } - catch - { - } } async Task DeployTestDme(string dmeName, DreamDaemonSecurity deploymentSecurity, CancellationToken cancellationToken) From a6358d3f0580c26b7c11059dc5b0e81f94ca7846 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 27 May 2020 21:18:21 -0400 Subject: [PATCH 12/25] Could it really be that simple... --- tests/DMAPI/LongRunning/Test.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/DMAPI/LongRunning/Test.dm b/tests/DMAPI/LongRunning/Test.dm index ee7eaf56ea..125c749788 100644 --- a/tests/DMAPI/LongRunning/Test.dm +++ b/tests/DMAPI/LongRunning/Test.dm @@ -1,3 +1,6 @@ +/world + sleep_offline = FALSE + /world/New() log << "Initial value of sleep_offline: [sleep_offline]" TgsNew(new /datum/tgs_event_handler/impl, TGS_SECURITY_ULTRASAFE) From f73175f84656c8794e093199e4e59a1c11b1e051 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 27 May 2020 23:33:51 -0400 Subject: [PATCH 13/25] Fix DMAPI versions --- src/DMAPI/tgs.dm | 2 +- src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DMAPI/tgs.dm b/src/DMAPI/tgs.dm index 7c0811ec59..b4c1eb8cf4 100644 --- a/src/DMAPI/tgs.dm +++ b/src/DMAPI/tgs.dm @@ -1,6 +1,6 @@ // tgstation-server DMAPI -#define TGS_DMAPI_VERSION "5.2.1" +#define TGS_DMAPI_VERSION "5.2.2" // All functions and datums outside this document are subject to change with any version and should not be relied on. diff --git a/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs b/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs index 125938305b..d91d5bdbf7 100644 --- a/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs +++ b/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs @@ -33,7 +33,7 @@ namespace Tgstation.Server.Host.Components.Interop /// /// The DMAPI being used. /// - public static readonly Version Version = new Version(5, 2, 1); + public static readonly Version Version = new Version(5, 2, 2); /// /// for use when communicating with the DMAPI. From 9ef65721a0481848cda47a5d8584d876e1c4622c Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 27 May 2020 23:41:35 -0400 Subject: [PATCH 14/25] Another DMAPI version fix --- src/DMAPI/tgs/v5/api.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DMAPI/tgs/v5/api.dm b/src/DMAPI/tgs/v5/api.dm index 9dab17c935..3791cbde84 100644 --- a/src/DMAPI/tgs/v5/api.dm +++ b/src/DMAPI/tgs/v5/api.dm @@ -16,7 +16,7 @@ var/list/chat_channels /datum/tgs_api/v5/ApiVersion() - return new /datum/tgs_version("5.2.1") + return new /datum/tgs_version("5.2.2") /datum/tgs_api/v5/OnWorldNew(minimum_required_security_level) server_port = world.params[DMAPI5_PARAM_SERVER_PORT] From fa6d9a5606c495442d12d9d3b0cb42b08ccd6c40 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 28 May 2020 12:55:52 -0400 Subject: [PATCH 15/25] Fucking BYOND --- src/DMAPI/tgs.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DMAPI/tgs.dm b/src/DMAPI/tgs.dm index b4c1eb8cf4..4493aef72c 100644 --- a/src/DMAPI/tgs.dm +++ b/src/DMAPI/tgs.dm @@ -127,6 +127,7 @@ * Call this when your initializations are complete and your game is ready to play before any player interactions happen. * * This may use [/world/var/sleep_offline] to make this happen so ensure no changes are made to it while this call is running. + * Afterwards, consider explicitly setting it to what you want to avoid this BYOND bug: http://www.byond.com/forum/post/2575184 * Before this point, note that any static files or directories may be in use by another server. Your code should account for this. * This function should not be called before ..() in [/world/proc/New]. */ From c01256d9c88b625b897eacfc51bb49e352edc04c Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 28 May 2020 12:58:02 -0400 Subject: [PATCH 16/25] Rerererere --- tests/DMAPI/LongRunning/Test.dm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/DMAPI/LongRunning/Test.dm b/tests/DMAPI/LongRunning/Test.dm index 125c749788..f87eee7824 100644 --- a/tests/DMAPI/LongRunning/Test.dm +++ b/tests/DMAPI/LongRunning/Test.dm @@ -14,6 +14,7 @@ sleep(60) world.TgsChatBroadcast("World Initialized") world.TgsInitializationComplete() + world.sleep_offline = FALSE /world/Topic(T, Addr, Master, Keys) log << "Topic: [T]" @@ -38,11 +39,13 @@ /world/Reboot(reason) world.sleep_offline = FALSE TgsChatBroadcast("World Rebooting") + world.sleep_offline = FALSE TgsReboot() /datum/tgs_event_handler/impl/HandleEvent(event_code, ...) set waitfor = FALSE + world.sleep_offline = FALSE world.TgsChatBroadcast("Recieved event: [json_encode(args)]") /world/Export(url) @@ -54,6 +57,7 @@ world.sleep_offline = FALSE world.TgsChatBroadcast("Rebooting after 3 seconds"); world.log << "About to sleep. sleep_offline: [world.sleep_offline]" + world.sleep_offline = FALSE sleep(30) world.log << "Done sleep, calling Reboot" world.Reboot() From 3b6b7ec4be086b5a3dfe666cc5959cc9cd2987a6 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 28 May 2020 13:31:38 -0400 Subject: [PATCH 17/25] Please make the pain stop --- tests/DMAPI/LongRunning/Test.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/DMAPI/LongRunning/Test.dm b/tests/DMAPI/LongRunning/Test.dm index f87eee7824..56c7ff174f 100644 --- a/tests/DMAPI/LongRunning/Test.dm +++ b/tests/DMAPI/LongRunning/Test.dm @@ -30,9 +30,12 @@ var/list/data = params2list(T) var/special_tactics = data["tgs_integration_test_special_tactics"] if(special_tactics) + world.sleep_offline = FALSE RebootAsync() + world.sleep_offline = FALSE return "ack" + world.sleep_offline = FALSE TgsChatBroadcast("Not rebooting...") return "feck" From d53f6bfdb662a95a62c00f84a37f88ce7f9f6dbf Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 28 May 2020 13:36:55 -0400 Subject: [PATCH 18/25] Dox generation takes longer than DMAPI tests --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 25cb4a535a..b5de2be669 100644 --- a/.travis.yml +++ b/.travis.yml @@ -102,6 +102,14 @@ jobs: name: "Docker Build" services: - docker + - env: + - DoxGeneration=true + name: "Dox Generation" + addons: + apt: + packages: + - doxygen + - graphviz - env: - DoxGeneration=false - DockerBuild=false @@ -118,14 +126,6 @@ jobs: packages: - libc6-i386 - libstdc++6:i386 - - env: - - DoxGeneration=true - name: "Dox Generation" - addons: - apt: - packages: - - doxygen - - graphviz install: - if [ $DoxGeneration = false ] && [ $DockerBuild = false ] && [ $DMAPI = true ]; then build/install_byond.sh; fi From 5767c964eeebc5fd2f581ab876683505baf6e529 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 28 May 2020 13:42:29 -0400 Subject: [PATCH 19/25] Maybe get real time integration test logging --- appveyor.yml | 2 +- build/integration_test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3ba2f056f9..13d2da0ad0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -73,7 +73,7 @@ test_script: - OpenCover.Console.exe -returntargetcode -register:user -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -c %CONFIGURATION% --logger:trx;LogFileName=results.trx /p:DebugType=full tests/Tgstation.Server.Host.Watchdog.Tests/Tgstation.Server.Host.Watchdog.Tests.csproj" -filter:"+[Tgstation.Server*]* -[Tgstation.Server.Host.Watchdog.Tests*]*" -output:".\watchdog_coverage.xml" -oldstyle - ps: $wc = New-Object 'System.Net.WebClient' - ps: $wc.UploadFile("https://ci.appveyor.com/api/testresults/mstest/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\tests\Tgstation.Server.Host.Watchdog.Tests\TestResults\results.trx)) - - OpenCover.Console.exe -returntargetcode -register:user -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -c %CONFIGURATION% --logger:trx;LogFileName=results.trx /p:DebugType=full tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj" -filter:"+[Tgstation.Server*]* -[Tgstation.Server.Tests*]* -[Tgstation.Server.Host]Tgstation.Server.Host.Database.Migrations..*" -output:".\server_coverage.xml" -oldstyle + - OpenCover.Console.exe -returntargetcode -register:user -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -c %CONFIGURATION% --logger:trx;LogFileName=results.trx --logger:console;noprogress=true /p:DebugType=full tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj" -filter:"+[Tgstation.Server*]* -[Tgstation.Server.Tests*]* -[Tgstation.Server.Host]Tgstation.Server.Host.Database.Migrations..*" -output:".\server_coverage.xml" -oldstyle - ps: $wc = New-Object 'System.Net.WebClient' - ps: $wc.UploadFile("https://ci.appveyor.com/api/testresults/mstest/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\tests\Tgstation.Server.Tests\TestResults\results.trx)) - lint-openapi -p -c build/OpenApiValidationSettings.json C:/swagger.json diff --git a/build/integration_test.sh b/build/integration_test.sh index 55b7b792e4..8492301359 100755 --- a/build/integration_test.sh +++ b/build/integration_test.sh @@ -10,7 +10,7 @@ cd tests/Tgstation.Server.Tests dotnet build -c $CONFIG -$HOME/.dotnet/tools/coverlet bin/$CONFIG/netcoreapp3.1/Tgstation.Server.Tests.dll --target "dotnet" --targetargs "test -c $CONFIG --no-build" --format opencover --output "../../TestResults/integration_test.xml" --include "[Tgstation.Server*]*" --exclude "[Tgstation.Server.Tests*]*" --exclude "[Tgstation.Server.Host]Tgstation.Server.Host.Database.Migrations.*" +$HOME/.dotnet/tools/coverlet bin/$CONFIG/netcoreapp3.1/Tgstation.Server.Tests.dll --target "dotnet" --targetargs "test -c $CONFIG --no-build --logger:\"console;noprogress=true\"" --format opencover --output "../../TestResults/integration_test.xml" --include "[Tgstation.Server*]*" --exclude "[Tgstation.Server.Tests*]*" --exclude "[Tgstation.Server.Host]Tgstation.Server.Host.Database.Migrations.*" cd ../../TestResults From 935a2173c83c004d66cee7e91f735ce7c09cf6e8 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 28 May 2020 13:43:57 -0400 Subject: [PATCH 20/25] Fuck it, just don't call TgsInitializationComplete --- tests/DMAPI/LongRunning/Test.dm | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tests/DMAPI/LongRunning/Test.dm b/tests/DMAPI/LongRunning/Test.dm index 56c7ff174f..8930774de6 100644 --- a/tests/DMAPI/LongRunning/Test.dm +++ b/tests/DMAPI/LongRunning/Test.dm @@ -13,8 +13,7 @@ /proc/Run() sleep(60) world.TgsChatBroadcast("World Initialized") - world.TgsInitializationComplete() - world.sleep_offline = FALSE + // world.TgsInitializationComplete() /world/Topic(T, Addr, Master, Keys) log << "Topic: [T]" @@ -24,31 +23,24 @@ /world/proc/HandleTopic(T) TGS_TOPIC - world.sleep_offline = FALSE TgsChatBroadcast("Recieved non-tgs topic: [T]") var/list/data = params2list(T) var/special_tactics = data["tgs_integration_test_special_tactics"] if(special_tactics) - world.sleep_offline = FALSE RebootAsync() - world.sleep_offline = FALSE return "ack" - world.sleep_offline = FALSE TgsChatBroadcast("Not rebooting...") return "feck" /world/Reboot(reason) - world.sleep_offline = FALSE TgsChatBroadcast("World Rebooting") - world.sleep_offline = FALSE TgsReboot() /datum/tgs_event_handler/impl/HandleEvent(event_code, ...) set waitfor = FALSE - world.sleep_offline = FALSE world.TgsChatBroadcast("Recieved event: [json_encode(args)]") /world/Export(url) @@ -57,10 +49,8 @@ /proc/RebootAsync() set waitfor = FALSE - world.sleep_offline = FALSE world.TgsChatBroadcast("Rebooting after 3 seconds"); world.log << "About to sleep. sleep_offline: [world.sleep_offline]" - world.sleep_offline = FALSE sleep(30) world.log << "Done sleep, calling Reboot" world.Reboot() From 2701305a857aa0c41d244e24f303e42496c9230f Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 28 May 2020 14:05:45 -0400 Subject: [PATCH 21/25] Hmmmm --- tests/Tgstation.Server.Tests/IntegrationTest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Tgstation.Server.Tests/IntegrationTest.cs b/tests/Tgstation.Server.Tests/IntegrationTest.cs index 523b101a15..aeff0bfffa 100644 --- a/tests/Tgstation.Server.Tests/IntegrationTest.cs +++ b/tests/Tgstation.Server.Tests/IntegrationTest.cs @@ -118,7 +118,7 @@ namespace Tgstation.Server.Tests using var hardTimeoutCts = new CancellationTokenSource(); hardTimeoutCts.CancelAfter(new TimeSpan(0, 9, 45)); var hardTimeoutCancellationToken = hardTimeoutCts.Token; - hardTimeoutCancellationToken.Register(() => Console.WriteLine("TEST TIMEOUT HARD!")); + hardTimeoutCancellationToken.Register(() => Console.WriteLine($"[{DateTimeOffset.Now}] TEST TIMEOUT HARD!")); using var softTimeoutCts = CancellationTokenSource.CreateLinkedTokenSource(hardTimeoutCancellationToken); softTimeoutCts.CancelAfter(new TimeSpan(0, 9, 15)); @@ -127,7 +127,7 @@ namespace Tgstation.Server.Tests softTimeoutCancellationToken.Register(() => { if (!tooLateForSoftTimeout) - Console.WriteLine("TEST TIMEOUT SOFT!"); + Console.WriteLine($"[{DateTimeOffset.Now}] TEST TIMEOUT SOFT!"); }); using var serverCts = CancellationTokenSource.CreateLinkedTokenSource(softTimeoutCancellationToken); @@ -297,7 +297,7 @@ namespace Tgstation.Server.Tests } catch (Exception ex) { - Console.WriteLine($"TEST ERROR: {ex.GetType()} in flight!"); + Console.WriteLine($"[{DateTimeOffset.Now}] TEST ERROR: {ex}"); throw; } finally From f32be88910af4ef62678567619c1f048009800ef Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 28 May 2020 14:08:15 -0400 Subject: [PATCH 22/25] Logging for days --- tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs index 2bb6f3b260..965ca0e68a 100644 --- a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs @@ -29,6 +29,7 @@ namespace Tgstation.Server.Tests.Instance public async Task Run(CancellationToken cancellationToken) { + global::System.Console.WriteLine("TEST: START WATCHDOG TESTS"); // Increase startup timeout, disable heartbeats await instanceClient.DreamDaemon.Update(new DreamDaemon { @@ -50,10 +51,12 @@ namespace Tgstation.Server.Tests.Instance await RunHeartbeatTest(cancellationToken); await StartAndLeaveRunning(cancellationToken); + global::System.Console.WriteLine("TEST: END WATCHDOG TESTS"); } async Task RunBasicTest(CancellationToken cancellationToken) { + global::System.Console.WriteLine("TEST: WATCHDOG BASIC TEST"); var daemonStatus = await DeployTestDme("BasicOperation/basic_operation_test", DreamDaemonSecurity.Ultrasafe, cancellationToken); Assert.IsFalse(daemonStatus.Running.Value); @@ -81,6 +84,7 @@ namespace Tgstation.Server.Tests.Instance async Task RunHeartbeatTest(CancellationToken cancellationToken) { + global::System.Console.WriteLine("TEST: WATCHDOG HEARTBEAT TEST"); // enable heartbeats await instanceClient.DreamDaemon.Update(new DreamDaemon { @@ -141,6 +145,7 @@ namespace Tgstation.Server.Tests.Instance async Task RunLongRunningTestThenUpdate(CancellationToken cancellationToken) { + global::System.Console.WriteLine("TEST: WATCHDOG LONG RUNNING TEST"); const string DmeName = "LongRunning/long_running_test"; var daemonStatus = await DeployTestDme(DmeName, DreamDaemonSecurity.Trusted, cancellationToken); @@ -181,6 +186,7 @@ namespace Tgstation.Server.Tests.Instance async Task RunLongRunningTestThenUpdateWithByondVersionSwitch(CancellationToken cancellationToken) { + global::System.Console.WriteLine("TEST: WATCHDOG BYOND VERSION UPDATE TEST"); var versionToInstall = new Version(511, 1384, 0); var byondInstallJobTask = instanceClient.Byond.SetActiveVersion( new Api.Models.Byond @@ -229,6 +235,7 @@ namespace Tgstation.Server.Tests.Instance public async Task StartAndLeaveRunning(CancellationToken cancellationToken) { + global::System.Console.WriteLine("TEST: WATCHDOG ENDLESS TEST"); var dd = await instanceClient.DreamDaemon.Read(cancellationToken); if(dd.ActiveCompileJob == null) await DeployTestDme("LongRunning/long_running_test", DreamDaemonSecurity.Trusted, cancellationToken); From 28f96835539251377b0f3d0db202d4f0b3e48557 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 28 May 2020 17:25:24 -0400 Subject: [PATCH 23/25] Linux is the dumb --- tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs index 965ca0e68a..9955bc1af4 100644 --- a/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Instance/WatchdogTest.cs @@ -45,8 +45,10 @@ namespace Tgstation.Server.Tests.Instance await RunBasicTest(cancellationToken); - await RunLongRunningTestThenUpdate(cancellationToken); - await RunLongRunningTestThenUpdateWithByondVersionSwitch(cancellationToken); + // await RunLongRunningTestThenUpdate(cancellationToken); + // await RunLongRunningTestThenUpdateWithByondVersionSwitch(cancellationToken); + // Remove this deploy when the above tests are reenabled + await DeployTestDme("LongRunning/long_running_test", DreamDaemonSecurity.Trusted, cancellationToken); await RunHeartbeatTest(cancellationToken); From 556c6f5b1145cafccad2f125c4a29a49fb0b931e Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 28 May 2020 18:33:10 -0400 Subject: [PATCH 24/25] Increase default restart timeout --- src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs | 2 +- src/Tgstation.Server.Host/appsettings.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs index e20d5cb3df..39c4ac068c 100644 --- a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs @@ -42,7 +42,7 @@ namespace Tgstation.Server.Host.Configuration /// /// The default value for /// - const int DefaultRestartTimeout = 10000; + const int DefaultRestartTimeout = 60000; /// /// The port the TGS API listens on. diff --git a/src/Tgstation.Server.Host/appsettings.json b/src/Tgstation.Server.Host/appsettings.json index e7f47e59b1..55786ab050 100644 --- a/src/Tgstation.Server.Host/appsettings.json +++ b/src/Tgstation.Server.Host/appsettings.json @@ -5,7 +5,7 @@ "GitHubAccessToken": null, "SetupWizardMode": "AutoDetect", "ByondTopicTimeout": 5000, - "RestartTimeout": 10000, + "RestartTimeout": 60000, "UseExperimentalWatchdog": false, "UseBasicWatchdogOnWindows": false, "UserLimit": 100, From e0296080bdea274cc038712b4e1fddb31067a606 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 28 May 2020 18:43:24 -0400 Subject: [PATCH 25/25] Add a message when we hit the restart timeout --- src/Tgstation.Server.Host/Server.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Server.cs b/src/Tgstation.Server.Host/Server.cs index 5a8fd3ee84..45b824bd39 100644 --- a/src/Tgstation.Server.Host/Server.cs +++ b/src/Tgstation.Server.Host/Server.cs @@ -299,7 +299,10 @@ namespace Tgstation.Server.Host { await eventsTask.ConfigureAwait(false); } - catch (OperationCanceledException) { } + catch (OperationCanceledException) + { + logger.LogError("Restart timeout hit! Existing DreamDaemon processes will be lost and must be killed manually before being restarted with TGS!"); + } catch (Exception e) { logger.LogError("Restart handlers error! Exception: {0}", e);