Various cleanups and test parallelization

- Fix a bunch of linter messages
- Document whitebox testing
- Fix race condition in deployment test with BYOND install
This commit is contained in:
Dominion
2023-04-16 23:28:18 -04:00
parent fce684f407
commit 9e72e47bbc
13 changed files with 140 additions and 113 deletions
+2
View File
@@ -107,7 +107,9 @@ namespace Tgstation.Server.Client
}
#pragma warning disable IDE0010 // Add missing cases
#pragma warning disable IDE0066 // Convert switch statement to expression
switch (response.StatusCode)
#pragma warning restore IDE0066 // Convert switch statement to expression
#pragma warning restore IDE0010 // Add missing cases
{
case HttpStatusCode.UpgradeRequired:
@@ -358,7 +358,7 @@ namespace Tgstation.Server.Host.Components.Deployment
// The difficulty with compile jobs is they have a two part commit
await databaseContext.Save(cancellationToken);
logger.LogTrace("Created CompileJob {0}", compileJob.Id);
logger.LogTrace("Created CompileJob {compileJobId}", compileJob.Id);
try
{
await compileJobConsumer.LoadCompileJob(compileJob, cancellationToken);
@@ -576,7 +576,7 @@ namespace Tgstation.Server.Host.Components.Deployment
CancellationToken cancellationToken)
{
var outputDirectory = job.DirectoryName.ToString();
logger.LogTrace("Compile output GUID: {0}", outputDirectory);
logger.LogTrace("Compile output GUID: {dirGuid}", outputDirectory);
try
{
@@ -624,7 +624,7 @@ namespace Tgstation.Server.Host.Components.Deployment
throw new JobException(ErrorCode.DreamMakerMissingDme);
}
logger.LogDebug("Selected {0}.dme for compilation!", job.DmeName);
logger.LogDebug("Selected {dmeName}.dme for compilation!", job.DmeName);
currentStage = "Modifying .dme";
await ModifyDme(job, cancellationToken);
@@ -727,7 +727,7 @@ namespace Tgstation.Server.Host.Components.Deployment
if (estimatedDuration.HasValue)
{
logger.LogDebug("Compile is expected to take: {0}", estimatedDuration);
logger.LogDebug("Compile is expected to take: {estimatedDuration}", estimatedDuration);
}
else
{
@@ -792,7 +792,7 @@ namespace Tgstation.Server.Host.Components.Deployment
bool logOutput,
CancellationToken cancellationToken)
{
logger.LogTrace("Verifying {0}DMAPI...", requireValidate ? "required " : String.Empty);
logger.LogTrace("Verifying {possiblyRequired}DMAPI...", requireValidate ? "required " : String.Empty);
var launchParameters = new DreamDaemonLaunchParameters
{
AllowWebClient = false,
@@ -827,7 +827,7 @@ namespace Tgstation.Server.Host.Components.Deployment
if (requireValidate && validationStatus == ApiValidationStatus.NeverValidated)
throw new JobException(ErrorCode.DreamMakerNeverValidated);
logger.LogTrace("API validation status: {0}", validationStatus);
logger.LogTrace("API validation status: {validationStatus}", validationStatus);
job.DMApiVersion = controller.DMApiVersion;
}
@@ -883,10 +883,10 @@ namespace Tgstation.Server.Host.Components.Deployment
exitCode = await dm.Lifetime;
cancellationToken.ThrowIfCancellationRequested();
logger.LogDebug("DreamMaker exit code: {0}", exitCode);
logger.LogDebug("DreamMaker exit code: {exitCode}", exitCode);
job.Output = await dm.GetCombinedOutput(cancellationToken);
currentDreamMakerOutput = job.Output;
logger.LogDebug("DreamMaker output: {0}{1}", Environment.NewLine, job.Output);
logger.LogDebug("DreamMaker output: {newLine}{output}", Environment.NewLine, job.Output);
return exitCode;
}
@@ -926,7 +926,7 @@ namespace Tgstation.Server.Host.Components.Deployment
{
var headIncludeLineNumber = dmeLineIndex + 1;
logger.LogDebug(
"Inserting HeadInclude.dm at line {0}: {1}",
"Inserting HeadInclude.dm at line {lineNumber}: {includeLine}",
headIncludeLineNumber,
dmeModifications.HeadIncludeLine);
dmeLines.Insert(headIncludeLineNumber, dmeModifications.HeadIncludeLine);
@@ -935,7 +935,7 @@ namespace Tgstation.Server.Host.Components.Deployment
else if (line.Contains("END_INCLUDE", StringComparison.Ordinal) && dmeModifications.TailIncludeLine != null)
{
logger.LogDebug(
"Inserting TailInclude.dm at line {0}: {1}",
"Inserting TailInclude.dm at line {lineNumber}: {includeLine}",
dmeLineIndex,
dmeModifications.TailIncludeLine);
dmeLines.Insert(dmeLineIndex, dmeModifications.TailIncludeLine);
@@ -968,7 +968,7 @@ namespace Tgstation.Server.Host.Components.Deployment
}
catch (Exception e)
{
logger.LogWarning(e, "Error cleaning up compile directory {0}!", ioManager.ResolvePath(jobPath));
logger.LogWarning(e, "Error cleaning up compile directory {path}!", ioManager.ResolvePath(jobPath));
}
}
@@ -33,7 +33,7 @@ namespace Tgstation.Server.Host.Components.Repository
/// <summary>
/// Template error message for when tracking of the most recent origin commit fails.
/// </summary>
public const string OriginTrackingErrorTemplate = "Unable to determine most recent origin commit of {0}. Marking it as an origin commit. This may result in invalid git metadata until the next hard reset to an origin reference.";
public const string OriginTrackingErrorTemplate = "Unable to determine most recent origin commit of {sha}. Marking it as an origin commit. This may result in invalid git metadata until the next hard reset to an origin reference.";
/// <summary>
/// The branch name used for publishing testmerge commits.
@@ -44,11 +44,11 @@ namespace Tgstation.Server.Host.System
foreach (ProcessThread thread in process.Threads)
{
var threadId = (uint)thread.Id;
logger.LogTrace("Suspending thread {0}...", threadId);
logger.LogTrace("Suspending thread {threadId}...", threadId);
var pOpenThread = NativeMethods.OpenThread(NativeMethods.ThreadAccess.SuspendResume, false, threadId);
if (pOpenThread == IntPtr.Zero)
{
logger.LogDebug(new Win32Exception(), "Failed to open thread {0}!", threadId);
logger.LogDebug(new Win32Exception(), "Failed to open thread {threadId}!", threadId);
continue;
}
@@ -74,11 +74,11 @@ namespace Tgstation.Server.Host.System
foreach (ProcessThread thread in process.Threads)
{
var threadId = (uint)thread.Id;
logger.LogTrace("Resuming thread {0}...", threadId);
logger.LogTrace("Resuming thread {threadId}...", threadId);
var pOpenThread = NativeMethods.OpenThread(NativeMethods.ThreadAccess.SuspendResume, false, threadId);
if (pOpenThread == IntPtr.Zero)
{
logger.LogDebug(new Win32Exception(), "Failed to open thread {0}!", threadId);
logger.LogDebug(new Win32Exception(), "Failed to open thread {threadId}!", threadId);
continue;
}
@@ -99,7 +99,7 @@ namespace Tgstation.Server.Host.System
{
string query = $"SELECT * FROM Win32_Process WHERE ProcessId = {process?.Id ?? throw new ArgumentNullException(nameof(process))}";
using var searcher = new ManagementObjectSearcher(query);
foreach (ManagementObject obj in searcher.Get())
foreach (var obj in searcher.Get().Cast<ManagementObject>())
{
var argList = new string[] { String.Empty, String.Empty };
var returnString = obj.InvokeMethod(