Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace VirtualClient.Actions
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -24,6 +25,41 @@ public void SetupFixture()
ComponentTypeCache.Instance.LoadComponentTypes(MockFixture.TestAssemblyDirectory);
}

[Test]
public void AspNetBombardierProfilePreservesDefaultFailurePolicy()
{
this.mockFixture.Setup(PlatformID.Win32NT);
using (ProfileExecutor executor = TestProfileResources.CreateProfileExecutor(
"PERF-WEB-ASPNET-BOMBARDIER.json",
this.mockFixture.Dependencies))
{
WorkloadAssert.ParameterReferencesInlined(executor.Profile);
Assert.That(executor.Profile.Actions[0].Parameters.ContainsKey("FailFast"), Is.False);
Assert.That(executor.Profile.Actions[1].Parameters["ServerPort"].ToString(), Is.EqualTo("9876"));
}
}

[Test]
[TestCase("9876")]
[TestCase("9800")]
public async Task AspNetBombardierProfileResolvesTheConfiguredPortForBothActions(string port)
{
this.mockFixture.Setup(PlatformID.Win32NT);
using (ProfileExecutor executor = TestProfileResources.CreateProfileExecutor(
"PERF-WEB-ASPNET-BOMBARDIER.json",
this.mockFixture.Dependencies,
parameterOverrides: new Dictionary<string, IConvertible> { ["ServerPort"] = port }))
{
var serverParameters = executor.Profile.Actions[0].Parameters;
var clientParameters = executor.Profile.Actions[1].Parameters;
Assert.That(clientParameters.ContainsKey("ServerPort"), Is.True);
await ProfileExpressionEvaluator.Instance.EvaluateAsync(this.mockFixture.Dependencies, clientParameters, CancellationToken.None);
Assert.That(serverParameters["ServerPort"].ToString(), Is.EqualTo(port));
Assert.That(clientParameters["CommandArguments"].ToString(), Does.Contain($":{port}/json"));
Assert.That(clientParameters["CommandArguments"].ToString(), Does.Not.Contain("{ServerPort}"));
}
}

[Test]
[TestCase("EXAMPLE-WORKLOAD.json")]
public async Task ParametersAndMetadataArePassedToTheVirtualClientComponentOnExecution(string profile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ public async Task AspNetOrchardServerExecutorRunsTheExpectedWorkloadCommandInLin
await executor.ExecuteAsync(CancellationToken.None);

this.mockFixture.Tracking.AssertCommandsExecuted(true,
"pkill OrchardCore",
"fuser -n tcp -k 5014",
$"{Regex.Escape(this.mockDotNetPackage.Path)}/dotnet publish -c Release --sc -f net9\\.0 {Regex.Escape(this.mockOrchardCorePackage.Path)}/src/OrchardCore\\.Cms\\.Web/OrchardCore\\.Cms\\.Web\\.csproj",
$"nohup {Regex.Escape(this.mockOrchardCorePackage.Path)}/src/OrchardCore\\.Cms\\.Web/bin/Release/net9\\.0/linux-x64/publish/OrchardCore\\.Cms\\.Web --urls http://\\*:5014"
$"{Regex.Escape(this.mockOrchardCorePackage.Path)}/src/OrchardCore\\.Cms\\.Web/bin/Release/net9\\.0/linux-x64/publish/OrchardCore\\.Cms\\.Web --urls http://\\*:5014"
);

this.mockFixture.Tracking.AssertCommandExecutedTimes("pkill", 1);
this.mockFixture.Tracking.AssertCommandExecutedTimes("fuser", 1);
this.mockFixture.Tracking.AssertCommandExecutedTimes("pkill", 0);
this.mockFixture.Tracking.AssertCommandExecutedTimes("fuser", 0);
}
}

Expand All @@ -86,13 +84,12 @@ public async Task AspNetOrchardServerExecutorRunsTheExpectedWorkloadCommandInWin
await executor.ExecuteAsync(CancellationToken.None);

this.mockFixture.Tracking.AssertCommandsExecuted(true,
"taskkill /F /IM OrchardCore\\.Cms\\.Web\\.exe",
$"{Regex.Escape(this.mockDotNetPackage.Path)}\\\\dotnet\\.exe publish -c Release --sc -f net9\\.0 {Regex.Escape(this.mockOrchardCorePackage.Path)}\\\\src\\\\OrchardCore\\.Cms\\.Web\\\\OrchardCore\\.Cms\\.Web\\.csproj",
$"{Regex.Escape(this.mockOrchardCorePackage.Path)}\\\\src\\\\OrchardCore\\.Cms\\.Web\\\\bin\\\\Release\\\\net9\\.0\\\\win-x64\\\\publish\\\\OrchardCore\\.Cms\\.Web\\.exe --urls http://\\*:5014"
);

// On Windows the Linux-only 'pkill'/'fuser'/'nohup' commands must NOT be used.
this.mockFixture.Tracking.AssertCommandExecutedTimes("taskkill", 1);
this.mockFixture.Tracking.AssertCommandExecutedTimes("taskkill", 0);
this.mockFixture.Tracking.AssertCommandExecutedTimes("pkill", 0);
this.mockFixture.Tracking.AssertCommandExecutedTimes("fuser", 0);
this.mockFixture.Tracking.AssertCommandExecutedTimes("nohup", 0);
Expand Down Expand Up @@ -159,10 +156,7 @@ public async Task AspNetOrchardServerExecutorExecutesWithCoreAffinityOnLinux()
await executor.ExecuteAsync(CancellationToken.None);

// Verify numactl was used with correct core affinity
// Actual format: /bin/bash -c "numactl -C 0-3 nohup ..."
this.mockFixture.Tracking.AssertCommandsExecuted(true,
"pkill OrchardCore",
"fuser -n tcp -k 5014",
$"{Regex.Escape(this.mockDotNetPackage.Path)}/dotnet publish -c Release --sc -f net9\\.0 {Regex.Escape(this.mockOrchardCorePackage.Path)}/src/OrchardCore\\.Cms\\.Web/OrchardCore\\.Cms\\.Web\\.csproj",
"/bin/bash -c \\\"numactl -C 0-3 .*"
);
Expand Down Expand Up @@ -240,6 +234,14 @@ private void SetupDefaultMockBehaviors(PlatformID platform)
this.mockFixture.Directory.Setup(f => f.Exists(It.IsAny<string>()))
.Returns(true);
this.mockFixture.FileSystem.SetupGet(fs => fs.File).Returns(this.mockFixture.File.Object);
this.mockFixture.Layout = new EnvironmentLayout(new[]
{
new ClientInstance(Environment.MachineName, "127.0.0.1", ClientRole.Client)
});
this.mockFixture.ProcessManager.OnCreateProcess = (command, arguments, directory) =>
arguments?.Contains("--urls") == true
? new AspNetServerLifecycleTests.ServerProcess { StartInfo = new System.Diagnostics.ProcessStartInfo(command, arguments) }
: new InMemoryProcess { StartInfo = new System.Diagnostics.ProcessStartInfo(command, arguments ?? string.Empty) };

this.mockFixture.Parameters = new Dictionary<string, IConvertible>()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ public async Task AspNetServerExecutorRunsTheExpectedWorkloadCommandInLinux()
await executor.ExecuteAsync(CancellationToken.None);

this.mockFixture.Tracking.AssertCommandsExecuted(true,
"pkill dotnet",
"fuser -n tcp -k 9876",
$"{Regex.Escape(this.mockDotNetPackage.Path)}/dotnet build -c Release -p:BenchmarksTargetFramework=net8\\.0",
$"{Regex.Escape(this.mockDotNetPackage.Path)}/dotnet {Regex.Escape(this.mockAspNetBenchPackage.Path)}/src/Benchmarks/bin/Release/net8\\.0/Benchmarks\\.dll --nonInteractive true --scenarios json --urls http://\\*:9876 --server Kestrel --kestrelTransport Sockets --protocol http --header \\\"Accept: application/json,text/html;q=0\\.9,application/xhtml\\+xml;q=0\\.9,application/xml;q=0\\.8,\\*/\\*;q=0\\.7\\\" --header \\\"Connection: keep-alive\\\""
);

this.mockFixture.Tracking.AssertCommandExecutedTimes("pkill", 1);
this.mockFixture.Tracking.AssertCommandExecutedTimes("fuser", 1);
this.mockFixture.Tracking.AssertCommandExecutedTimes("pkill", 0);
this.mockFixture.Tracking.AssertCommandExecutedTimes("fuser", 0);
}
}

Expand All @@ -101,13 +99,11 @@ public async Task AspNetServerExecutorRunsTheExpectedWorkloadCommandInWindows()
await executor.ExecuteAsync(CancellationToken.None);

this.mockFixture.Tracking.AssertCommandsExecuted(true,
"taskkill /F /IM dotnet\\.exe",
$"{Regex.Escape(this.mockDotNetPackage.Path)}\\\\dotnet\\.exe build -c Release -p:BenchmarksTargetFramework=net8\\.0",
$"{Regex.Escape(this.mockDotNetPackage.Path)}\\\\dotnet\\.exe {Regex.Escape(this.mockAspNetBenchPackage.Path)}\\\\src\\\\Benchmarks\\\\bin\\\\Release\\\\net8\\.0\\\\Benchmarks\\.dll --nonInteractive true --scenarios json --urls http://\\*:9876 --server Kestrel --kestrelTransport Sockets --protocol http --header \\\"Accept: application/json,text/html;q=0\\.9,application/xhtml\\+xml;q=0\\.9,application/xml;q=0\\.8,\\*/\\*;q=0\\.7\\\" --header \\\"Connection: keep-alive\\\""
);

// On Windows the Linux-only 'pkill'/'fuser' commands must NOT be used; 'taskkill' is used instead.
this.mockFixture.Tracking.AssertCommandExecutedTimes("taskkill", 1);
this.mockFixture.Tracking.AssertCommandExecutedTimes("taskkill", 0);
this.mockFixture.Tracking.AssertCommandExecutedTimes("pkill", 0);
this.mockFixture.Tracking.AssertCommandExecutedTimes("fuser", 0);
}
Expand Down Expand Up @@ -181,8 +177,6 @@ public async Task AspNetServerExecutorExecutesWithCoreAffinityOnLinux()
// Verify numactl was used with correct core affinity
// The actual command format is: /bin/bash -c "numactl -C 0-7 /path/to/dotnet /path/to/dll ..."
this.mockFixture.Tracking.AssertCommandsExecuted(true,
"pkill dotnet",
"fuser -n tcp -k 9876",
$"{Regex.Escape(this.mockDotNetPackage.Path)}/dotnet build -c Release -p:BenchmarksTargetFramework=net8\\.0",
"/bin/bash -c \\\"numactl -C 0-7 .*"
);
Expand Down Expand Up @@ -275,6 +269,14 @@ private void SetupDefaultMockBehaviors(PlatformID platform)
this.mockFixture.Directory.Setup(f => f.Exists(It.IsAny<string>()))
.Returns(true);
this.mockFixture.FileSystem.SetupGet(fs => fs.File).Returns(this.mockFixture.File.Object);
this.mockFixture.Layout = new EnvironmentLayout(new[]
{
new ClientInstance(Environment.MachineName, "127.0.0.1", ClientRole.Client)
});
this.mockFixture.ProcessManager.OnCreateProcess = (command, arguments, directory) =>
arguments?.Contains("Benchmarks.dll") == true
? new AspNetServerLifecycleTests.ServerProcess { StartInfo = new ProcessStartInfo(command, arguments) }
: new InMemoryProcess { StartInfo = new ProcessStartInfo(command, arguments ?? string.Empty) };

this.mockFixture.Parameters = new Dictionary<string, IConvertible>()
{
Expand Down
Loading
Loading