Fix integration tests race condition.
This commit is contained in:
@@ -4,6 +4,7 @@ using Content.Client;
|
||||
using Content.Client.Interfaces.Parallax;
|
||||
using Content.Server;
|
||||
using Content.Server.Interfaces.GameTicking;
|
||||
using Content.Shared;
|
||||
using NUnit.Framework;
|
||||
using Robust.Server.Interfaces.Maps;
|
||||
using Robust.Server.Interfaces.Timing;
|
||||
@@ -76,6 +77,9 @@ namespace Content.IntegrationTests
|
||||
});
|
||||
};
|
||||
|
||||
// Avoid funny race conditions with the database.
|
||||
options.CVarOverrides[CCVars.DatabaseSynchronous.Name] = "true";
|
||||
|
||||
return base.StartServer(options);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@@ -7,7 +6,10 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Preferences;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Robust.Shared.Interfaces.Configuration;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
#nullable enable
|
||||
@@ -32,8 +34,16 @@ namespace Content.Server.Database
|
||||
{
|
||||
_prefsCtx = new SqliteServerDbContext(options);
|
||||
|
||||
if (IoCManager.Resolve<IConfigurationManager>().GetCVar(CCVars.DatabaseSynchronous))
|
||||
{
|
||||
_prefsCtx.Database.Migrate();
|
||||
_dbReadyTask = Task.CompletedTask;
|
||||
}
|
||||
else
|
||||
{
|
||||
_dbReadyTask = Task.Run(() => _prefsCtx.Database.Migrate());
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task<ServerBanDef?> GetServerBanAsync(IPAddress? address, NetUserId? userId)
|
||||
{
|
||||
|
||||
@@ -142,6 +142,10 @@ namespace Content.Shared
|
||||
public static readonly CVarDef<string> DatabasePgPassword =
|
||||
CVarDef.Create("database.pg_password", "", CVar.SERVERONLY);
|
||||
|
||||
// Basically only exists for integration tests to avoid race conditions.
|
||||
public static readonly CVarDef<bool> DatabaseSynchronous =
|
||||
CVarDef.Create("database.sync", false, CVar.SERVERONLY);
|
||||
|
||||
|
||||
/*
|
||||
* Outline
|
||||
|
||||
Reference in New Issue
Block a user