fix(IPC-36,IPC-37): guard secondary contracts
This commit is contained in:
@@ -14,6 +14,16 @@ public sealed class WorkerProcessLauncherTests
|
||||
private const string PipeName = "mxaccess-gateway-123-session-1";
|
||||
private const string Nonce = "super-secret-nonce";
|
||||
|
||||
private static readonly string[] RequiredLaunchEnvironmentVariables =
|
||||
[
|
||||
WorkerLaunchEnvironment.WorkerNonce,
|
||||
WorkerLaunchEnvironment.PipeConnectAttemptTimeoutMilliseconds,
|
||||
WorkerLaunchEnvironment.WriteCompletionWaitMilliseconds,
|
||||
WorkerLaunchEnvironment.EventQueueCapacity,
|
||||
WorkerLaunchEnvironment.AlarmPollIntervalMilliseconds,
|
||||
WorkerLaunchEnvironment.MaxAlarmsPerFetch,
|
||||
];
|
||||
|
||||
/// <summary>Verifies that a valid worker executable starts with correct bootstrap arguments and nonce environment variable.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
@@ -38,33 +48,38 @@ public sealed class WorkerProcessLauncherTests
|
||||
Assert.Equal(
|
||||
["--session-id", SessionId, "--pipe-name", PipeName, "--protocol-version", "1"],
|
||||
processFactory.LastStartInfo.ArgumentList);
|
||||
Assert.Equal(Nonce, processFactory.LastStartInfo.Environment[WorkerProcessLauncher.WorkerNonceEnvironmentVariableName]);
|
||||
Assert.Equal(Nonce, processFactory.LastStartInfo.Environment[WorkerLaunchEnvironment.WorkerNonce]);
|
||||
Assert.Equal(
|
||||
"2000",
|
||||
processFactory.LastStartInfo.Environment[
|
||||
WorkerProcessLauncher.WorkerPipeConnectAttemptTimeoutEnvironmentVariableName]);
|
||||
WorkerLaunchEnvironment.PipeConnectAttemptTimeoutMilliseconds]);
|
||||
Assert.Equal(
|
||||
"1500",
|
||||
processFactory.LastStartInfo.Environment[
|
||||
WorkerProcessLauncher.WorkerWriteCompletionWaitEnvironmentVariableName]);
|
||||
WorkerLaunchEnvironment.WriteCompletionWaitMilliseconds]);
|
||||
// The worker sizes its outbound event queue from the launch environment;
|
||||
// the queue has no drop policy, so this capacity is the session's burst
|
||||
// headroom rather than a throttle.
|
||||
Assert.Equal(
|
||||
"10000",
|
||||
processFactory.LastStartInfo.Environment[
|
||||
WorkerProcessLauncher.WorkerEventQueueCapacityEnvironmentVariableName]);
|
||||
WorkerLaunchEnvironment.EventQueueCapacity]);
|
||||
// MxGateway:Alarms defaults reach the worker's alarm poll loop and its
|
||||
// GetXmlCurrentAlarms2 cap (which is also its truncation threshold)
|
||||
// through the launch environment, not the command line.
|
||||
Assert.Equal(
|
||||
"500",
|
||||
processFactory.LastStartInfo.Environment[
|
||||
WorkerProcessLauncher.WorkerAlarmPollIntervalEnvironmentVariableName]);
|
||||
WorkerLaunchEnvironment.AlarmPollIntervalMilliseconds]);
|
||||
Assert.Equal(
|
||||
"1024",
|
||||
processFactory.LastStartInfo.Environment[
|
||||
WorkerProcessLauncher.WorkerMaxAlarmsPerFetchEnvironmentVariableName]);
|
||||
WorkerLaunchEnvironment.MaxAlarmsPerFetch]);
|
||||
Assert.All(
|
||||
RequiredLaunchEnvironmentVariables,
|
||||
variable => Assert.True(
|
||||
processFactory.LastStartInfo.Environment.ContainsKey(variable),
|
||||
$"Worker launch environment is missing required variable '{variable}'."));
|
||||
Assert.DoesNotContain(Nonce, handle.CommandLine.ToString(), StringComparison.Ordinal);
|
||||
Assert.DoesNotContain(Nonce, string.Join(" ", handle.CommandLine.Arguments), StringComparison.Ordinal);
|
||||
Assert.False(pipeReservation.DisposeCalled);
|
||||
@@ -94,7 +109,7 @@ public sealed class WorkerProcessLauncherTests
|
||||
Assert.Equal(
|
||||
"65536",
|
||||
processFactory.LastStartInfo.Environment[
|
||||
WorkerProcessLauncher.WorkerEventQueueCapacityEnvironmentVariableName]);
|
||||
WorkerLaunchEnvironment.EventQueueCapacity]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a failed startup probe kills and disposes the worker process.</summary>
|
||||
|
||||
Reference in New Issue
Block a user