Fix integration tests race condition.
This commit is contained in:
@@ -4,6 +4,7 @@ using Content.Client;
|
|||||||
using Content.Client.Interfaces.Parallax;
|
using Content.Client.Interfaces.Parallax;
|
||||||
using Content.Server;
|
using Content.Server;
|
||||||
using Content.Server.Interfaces.GameTicking;
|
using Content.Server.Interfaces.GameTicking;
|
||||||
|
using Content.Shared;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Robust.Server.Interfaces.Maps;
|
using Robust.Server.Interfaces.Maps;
|
||||||
using Robust.Server.Interfaces.Timing;
|
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);
|
return base.StartServer(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@@ -7,7 +6,10 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Content.Server.Preferences;
|
using Content.Server.Preferences;
|
||||||
using Content.Server.Utility;
|
using Content.Server.Utility;
|
||||||
|
using Content.Shared;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Robust.Shared.Interfaces.Configuration;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
@@ -32,7 +34,15 @@ namespace Content.Server.Database
|
|||||||
{
|
{
|
||||||
_prefsCtx = new SqliteServerDbContext(options);
|
_prefsCtx = new SqliteServerDbContext(options);
|
||||||
|
|
||||||
_dbReadyTask = Task.Run(() => _prefsCtx.Database.Migrate());
|
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)
|
public override async Task<ServerBanDef?> GetServerBanAsync(IPAddress? address, NetUserId? userId)
|
||||||
|
|||||||
@@ -142,6 +142,10 @@ namespace Content.Shared
|
|||||||
public static readonly CVarDef<string> DatabasePgPassword =
|
public static readonly CVarDef<string> DatabasePgPassword =
|
||||||
CVarDef.Create("database.pg_password", "", CVar.SERVERONLY);
|
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
|
* Outline
|
||||||
|
|||||||
Reference in New Issue
Block a user