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 @@ -8,6 +8,7 @@ namespace VirtualClient.Actions
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
Expand Down Expand Up @@ -36,7 +37,9 @@ public void SetupFixture()
new ClientInstance(this.clientAgentId, "1.2.3.4", "Client"),
new ClientInstance(this.serverAgentId, "1.2.3.5", "Server"));

this.mockFixture.SetupPackage("wget", expectedFiles: "linux-x64/wget2");
this.mockFixture.SetupPackage("wget", null, "linux-x64/wget2");
this.mockFixture.SetupPackage("redis", null, "src/redis-benchmark", "src/redis-server");
this.mockFixture.SetupPackage("memtier", null, "memtier_benchmark");
}

[Test]
Expand All @@ -53,46 +56,26 @@ public void RedisMemtierWorkloadProfileActionsWillNotBeExecutedIfTheClientWorklo
}

[Test]
[Ignore("We need to completely refactor the functional tests for Memcached and Redis to consolidate and cleanup.")]
[TestCase("PERF-REDIS.json")]
public async Task RedisMemtierWorkloadProfileExecutesTheWorkloadAsExpectedOfClientOnUnixPlatform(string profile)
{
IEnumerable<string> expectedCommands = new List<string>
{
$"--protocol redis --clients 1 --threads 4 --ratio 1:9 --data-size 32 --pipeline 32 --key-minimum 1 --key-maximum 10000000 --key-pattern R:R --run-count 1 --test-time 180 --print-percentile 50,90,95,99,99.9 --random-data",
$" -h 1.2.3.5 -p 6379 -c 1 -n 10000 -P 32 -q --csv\""
};

// Setup the expectations for the workload
// - Workload package is installed and exists.
// - Workload binaries/executables exist on the file system.
// - Expected processes are executed.
this.mockFixture.SetupFile(@"/home/user/tools/VirtualClient/scripts/Redis/RunClient.sh");
this.mockFixture.SetupFile(@"/home/user/tools/VirtualClient/packages/redis-6.2.1/src/redis-benchmark");
this.mockFixture
.TrackProcesses()
.SetupProcessOutput(
"memtier_benchmark.*--server",
TestDependencies.GetResourceFileContents("Results_RedisMemtier.txt"));

this.SetupApiClient(this.serverAgentId, serverIPAddress: "1.2.3.5");

this.mockFixture.ProcessManager.OnCreateProcess = (command, arguments, workingDir) =>
{
IProcessProxy process = this.mockFixture.CreateProcess(command, arguments, workingDir);

if (arguments.Contains("memtier_benchmark --server", StringComparison.OrdinalIgnoreCase))
{
process.StandardOutput.Append(TestDependencies.GetResourceFileContents("Results_RedisMemtier.txt"));
}
else if (arguments.Contains("redis-benchmark", StringComparison.OrdinalIgnoreCase))
{
process.StandardOutput.Append(TestDependencies.GetResourceFileContents("Results_RedisBenchmark.txt"));
}

return process;
};

using (ProfileExecutor executor = TestDependencies.CreateProfileExecutor(profile, this.mockFixture.Dependencies))
{
await executor.ExecuteAsync(ProfileTiming.OneIteration(), CancellationToken.None)
.ConfigureAwait(false);
WorkloadAssert.CommandsExecuted(this.mockFixture, expectedCommands.ToArray());

this.mockFixture.Tracking.AssertCommandsExecuted(
"sudo chmod \\+x.*memtier_benchmark",
"memtier_benchmark.*--server 1\\.2\\.3\\.5.*--port 6379.*--protocol redis",
"memtier_benchmark.*--server 1\\.2\\.3\\.5.*--port 6380.*--protocol redis");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace VirtualClient.Actions
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Moq;
Expand All @@ -35,7 +35,7 @@ public void SetupFixture()

ComponentTypeCache.Instance.LoadComponentTypes(TestDependencies.TestDirectory);

this.mockFixture.SetupPackage("wget", expectedFiles: "linux-x64/wget2");
this.mockFixture.SetupPackage("wget", null, "linux-x64/wget2");
this.mockFixture.SetupFile("redis", "redis-6.2.1/src/redis-server", new byte[0]);
this.mockFixture.SystemManagement.Setup(mgr => mgr.GetCpuInfoAsync(It.IsAny<CancellationToken>()))
.ReturnsAsync(new CpuInfo("AnyName", "AnyDescription", 1, 4, 1, 0, true));
Expand All @@ -45,48 +45,33 @@ public void SetupFixture()
[TestCase("PERF-REDIS.json")]
public async Task RedisMemtierWorkloadProfileInstallsTheExpectedDependenciesOfServerOnUnixPlatform(string profile)
{
using var memoryProcess = new InMemoryProcess
{
StandardOutput = new ConcurrentBuffer(
new StringBuilder("Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123")),
OnStart = () => true,
OnHasExited = () => true
};

this.mockFixture.ProcessManager.OnCreateProcess = (command, arguments, workingDir) =>
{
IProcessProxy process = this.mockFixture.CreateProcess(command, arguments, workingDir);
if (arguments?.Contains("redis-server") == true && arguments?.Contains("--version") == true)
{
return memoryProcess;
}
this.mockFixture
.TrackProcesses()
.SetupProcessOutput(
"redis-server.*--version",
"Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123");

return process;
};
using (ProfileExecutor executor = TestDependencies.CreateProfileExecutor(profile, this.mockFixture.Dependencies))
{
await executor.ExecuteAsync(ProfileTiming.OneIteration(), CancellationToken.None)
.ConfigureAwait(false);

// Workload dependency package expectations
WorkloadAssert.WorkloadPackageInstalled(this.mockFixture, "redis");

this.mockFixture.Tracking.AssertCommandsExecuted("redis-server.*--version");
}
}

[Test]
[TestCase("PERF-REDIS.json")]
public async Task RedisMemtierWorkloadProfileExecutesTheWorkloadAsExpectedOfServerOnUnixPlatformMultiVM(string profile)
{
List<string> expectedCommands = new List<string>();

int port = 6379;
Enumerable.Range(0, 4).ToList().ForEach(core =>
expectedCommands.Add($"sudo bash -c \"numactl -C {core} /.+/redis-server --port {port + core} --protected-mode no --io-threads 4 --maxmemory-policy noeviction --ignore-warnings ARM64-COW-BUG --save &\""));
this.mockFixture
.TrackProcesses()
.SetupProcessOutput(
"redis-server.*--version",
"Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123");

// Setup the expectations for the workload
// - Workload package is installed and exists.
// - Workload binaries/executables exist on the file system.
// - Expected processes are executed.
IPAddress.TryParse("1.2.3.5", out IPAddress ipAddress);
IApiClient apiClient = this.mockFixture.ApiClientManager.GetOrCreateApiClient("1.2.3.5", ipAddress);

Expand All @@ -105,29 +90,20 @@ public async Task RedisMemtierWorkloadProfileExecutesTheWorkloadAsExpectedOfServ
});

await apiClient.CreateStateAsync(nameof(ServerState), state, CancellationToken.None);
using var memoryProcess = new InMemoryProcess
{
StandardOutput = new ConcurrentBuffer(
new StringBuilder("Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123")),
OnStart = () => true,
OnHasExited = () => true
};

this.mockFixture.ProcessManager.OnCreateProcess = (command, arguments, workingDir) =>
{
IProcessProxy process = this.mockFixture.CreateProcess(command, arguments, workingDir);
if (arguments?.Contains("redis-server") == true && arguments?.Contains("--version") == true)
{
return memoryProcess;
}

return process;
};

using (ProfileExecutor executor = TestDependencies.CreateProfileExecutor(profile, this.mockFixture.Dependencies))
{
await executor.ExecuteAsync(ProfileTiming.OneIteration(), CancellationToken.None);
WorkloadAssert.CommandsExecuted(this.mockFixture, expectedCommands.ToArray());

this.mockFixture.Tracking.AssertCommandsExecuted(true,
$"sudo chmod \\+x.*redis-server",
$"sudo bash -c \\\"numactl -C 0.*redis-server --port 6379.*\\\"",
$"sudo bash -c \\\"numactl -C 1.*redis-server --port 6380.*\\\"",
$"sudo bash -c \\\"numactl -C 2.*redis-server --port 6381.*\\\"",
$"sudo bash -c \\\"numactl -C 3.*redis-server --port 6382.*\\\"");

this.mockFixture.Tracking.AssertCommandExecutedTimes("chmod.*redis-server", 1);
this.mockFixture.Tracking.AssertCommandExecutedTimes("numactl.*redis-server", 4);
}
}
}
Expand Down
Loading
Loading