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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@
<Content Include="..\VirtualClient.Main\profiles\PERF-MYSQL-OLTP-SYSBENCH.json" Link="Profiles\PERF-MYSQL-OLTP-SYSBENCH.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\VirtualClient.Main\profiles\PERF-MYSQL-TPCC-SYSBENCH.json" Link="Profiles\PERF-MYSQL-TPCC-SYSBENCH.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\VirtualClient.Main\profiles\PERF-NETWORK-DEATHSTARBENCH.json" Link="Profiles\PERF-NETWORK-DEATHSTARBENCH.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void SetupDefaultBehavior()

this.fixture.Parameters = new Dictionary<string, IConvertible>()
{
{ nameof(SysbenchClientExecutor.Benchmark), "OLTP" },
{ nameof(SysbenchClientExecutor.DatabaseName), "sbtest" },
{ nameof(SysbenchClientExecutor.Duration), "00:00:10" },
{ nameof(SysbenchClientExecutor.Workload), "oltp_read_write" },
Expand Down Expand Up @@ -87,7 +88,7 @@ public async Task SysbenchClientExecutorRunsTheExpectedWorkloadCommand()
{
SetupDefaultBehavior();

string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --workload oltp_read_write --threadCount 8 --tableCount 10 --recordCount 1000 --hostIpAddress 1.2.3.5 --durationSecs 10";
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --benchmark OLTP --workload oltp_read_write --threadCount 8 --tableCount 10 --recordCount 1000 --hostIpAddress 1.2.3.5 --durationSecs 10";
bool commandExecuted = false;

this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
Expand Down Expand Up @@ -131,9 +132,9 @@ public async Task SysbenchClientExecutorUsesDefinedParametersWhenRunningTheWorkl
this.fixture.Parameters[nameof(SysbenchClientExecutor.Threads)] = "64";
this.fixture.Parameters[nameof(SysbenchClientExecutor.RecordCount)] = "1000";
this.fixture.Parameters[nameof(SysbenchClientExecutor.TableCount)] = "40";
this.fixture.Parameters[nameof(SysbenchClientExecutor.Scenario)] = "Configure";
this.fixture.Parameters[nameof(SysbenchClientExecutor.DatabaseScenario)] = "Configure";

string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --workload oltp_read_write --threadCount 64 --tableCount 40 --recordCount 1000 --hostIpAddress 1.2.3.5 --durationSecs 10";
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --benchmark OLTP --workload oltp_read_write --threadCount 64 --tableCount 40 --recordCount 1000 --hostIpAddress 1.2.3.5 --durationSecs 10";
bool commandExecuted = false;

this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
Expand Down Expand Up @@ -176,7 +177,7 @@ public async Task SysbenchClientExecutorRunsTheExpectedBalancedScenario()

this.fixture.Parameters[nameof(SysbenchClientExecutor.DatabaseScenario)] = "Balanced";

string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --workload oltp_read_write --threadCount 8 --tableCount 10 --recordCount 1000 --hostIpAddress 1.2.3.5 --durationSecs 10";
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --benchmark OLTP --workload oltp_read_write --threadCount 8 --tableCount 10 --recordCount 1000 --hostIpAddress 1.2.3.5 --durationSecs 10";
bool commandExecuted = false;

this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
Expand Down Expand Up @@ -219,7 +220,7 @@ public async Task SysbenchClientExecutorRunsInMemoryScenario()

this.fixture.Parameters[nameof(SysbenchClientExecutor.DatabaseScenario)] = "InMemory";

string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --workload oltp_read_write --threadCount 8 --tableCount 10 --recordCount 1000 --hostIpAddress 1.2.3.5 --durationSecs 10";
string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --benchmark OLTP --workload oltp_read_write --threadCount 8 --tableCount 10 --recordCount 100000 --hostIpAddress 1.2.3.5 --durationSecs 10";
bool commandExecuted = false;

this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
Expand Down Expand Up @@ -255,6 +256,49 @@ public async Task SysbenchClientExecutorRunsInMemoryScenario()
}
}

[Test]
public async Task SysbenchClientExecutorRunsTheExpectedTPCCWorkloadCommand()
{
SetupDefaultBehavior();

this.fixture.Parameters[nameof(SysbenchClientExecutor.Benchmark)] = "TPCC";

string expectedCommand = $"python3 {this.mockPackagePath}/run-workload.py --dbName sbtest --benchmark TPCC --workload tpcc --threadCount 8 --tableCount 10 --warehouses 100 --hostIpAddress 1.2.3.5 --durationSecs 10";
bool commandExecuted = false;

this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
{
if (expectedCommand == $"{exe} {arguments}")
{
commandExecuted = true;
}

Assert.IsTrue(commandExecuted);

InMemoryProcess process = new InMemoryProcess
{
StartInfo = new ProcessStartInfo
{
FileName = exe,
Arguments = arguments
},
ExitCode = 0,
OnStart = () => true,
OnHasExited = () => true
};

string resultsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Examples", "Sysbench", "SysbenchExample.txt");
process.StandardOutput.Append(File.ReadAllText(resultsPath));

return process;
};

using (TestSysbenchClientExecutor SysbenchExecutor = new TestSysbenchClientExecutor(this.fixture.Dependencies, this.fixture.Parameters))
{
await SysbenchExecutor.ExecuteAsync(CancellationToken.None);
}
}

private class TestSysbenchClientExecutor : SysbenchClientExecutor
{
public TestSysbenchClientExecutor(IServiceCollection services, IDictionary<string, IConvertible> parameters = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void SetupDefaultBehavior()

this.fixture.Parameters = new Dictionary<string, IConvertible>()
{
{ nameof(SysbenchConfiguration.Benchmark), "OLTP" },
{ nameof(SysbenchConfiguration.DatabaseName), "sbtest" },
{ nameof(SysbenchConfiguration.PackageName), "sysbench" },
{ nameof(SysbenchConfiguration.Scenario), "populate_database" }
Expand Down Expand Up @@ -74,7 +75,7 @@ public async Task SysbenchConfigurationSkipsSysbenchInitialization()

string[] expectedCommands =
{
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --tableCount 10 --recordCount 1000 --threadCount 8",
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --benchmark OLTP --tableCount 10 --recordCount 1000 --threadCount 8",
};

int commandNumber = 0;
Expand Down Expand Up @@ -119,7 +120,7 @@ public async Task SysbenchConfigurationPreparesDatabase()
string[] expectedCommands =
{
$"python3 {this.mockPackagePath}/configure-workload-generator.py --distro Ubuntu --packagePath {this.mockPackagePath}",
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --tableCount 10 --recordCount 1000 --threadCount 8",
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --benchmark OLTP --tableCount 10 --recordCount 1000 --threadCount 8",
};

int commandNumber = 0;
Expand Down Expand Up @@ -165,12 +166,12 @@ public async Task SysbenchConfigurationUsesDefinedParametersWhenRunningTheWorklo
this.fixture.Parameters[nameof(SysbenchConfiguration.Threads)] = "16";
this.fixture.Parameters[nameof(SysbenchConfiguration.RecordCount)] = "1000";
this.fixture.Parameters[nameof(SysbenchConfiguration.TableCount)] = "40";
this.fixture.Parameters[nameof(SysbenchClientExecutor.Scenario)] = "Configure";
this.fixture.Parameters[nameof(SysbenchClientExecutor.DatabaseScenario)] = "Configure";

string[] expectedCommands =
{
$"python3 {this.mockPackagePath}/configure-workload-generator.py --distro Ubuntu --packagePath {this.mockPackagePath}",
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --tableCount 40 --recordCount 1000 --threadCount 16",
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --benchmark OLTP --tableCount 40 --recordCount 1000 --threadCount 16",
};

int commandNumber = 0;
Expand Down Expand Up @@ -259,6 +260,114 @@ public async Task SysbenchConfigurationSkipsDatabasePopulationWhenInitialized()
}
}

[Test]
public async Task SysbenchConfigurationProperlyExecutesTPCCPreparation()
{
this.fixture.Parameters[nameof(SysbenchConfiguration.Benchmark)] = "TPCC";

this.fixture.StateManager.OnGetState().ReturnsAsync(JObject.FromObject(new SysbenchExecutor.SysbenchState()
{
SysbenchInitialized = true
}));

string[] expectedCommands =
{
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --benchmark TPCC --tableCount 10 --warehouses 100 --threadCount 8"
};

int commandNumber = 0;
bool commandExecuted = false;

this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
{
string expectedCommand = expectedCommands[commandNumber];

if (expectedCommand == $"{exe} {arguments}")
{
commandExecuted = true;
}

Assert.IsTrue(commandExecuted);
commandExecuted = false;
commandNumber += 1;

InMemoryProcess process = new InMemoryProcess
{
StartInfo = new ProcessStartInfo
{
FileName = exe,
Arguments = arguments
},
ExitCode = 0,
OnStart = () => true,
OnHasExited = () => true
};

return process;
};

using (TestSysbenchConfiguration SysbenchExecutor = new TestSysbenchConfiguration(this.fixture.Dependencies, this.fixture.Parameters))
{
await SysbenchExecutor.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
}
}

[Test]
public async Task SysbenchConfigurationProperlyExecutesTPCCConfigurablePreparation()
{
this.fixture.Parameters[nameof(SysbenchConfiguration.Benchmark)] = "TPCC";
this.fixture.Parameters[nameof(SysbenchConfiguration.Threads)] = "16";
this.fixture.Parameters[nameof(SysbenchConfiguration.WarehouseCount)] = "1000";
this.fixture.Parameters[nameof(SysbenchConfiguration.TableCount)] = "40";
this.fixture.Parameters[nameof(SysbenchClientExecutor.DatabaseScenario)] = "Configure";

this.fixture.StateManager.OnGetState().ReturnsAsync(JObject.FromObject(new SysbenchExecutor.SysbenchState()
{
SysbenchInitialized = true
}));

string[] expectedCommands =
{
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --benchmark TPCC --tableCount 40 --warehouses 1000 --threadCount 16"
};

int commandNumber = 0;
bool commandExecuted = false;

this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
{
string expectedCommand = expectedCommands[commandNumber];

if (expectedCommand == $"{exe} {arguments}")
{
commandExecuted = true;
}

Assert.IsTrue(commandExecuted);
commandExecuted = false;
commandNumber += 1;

InMemoryProcess process = new InMemoryProcess
{
StartInfo = new ProcessStartInfo
{
FileName = exe,
Arguments = arguments
},
ExitCode = 0,
OnStart = () => true,
OnHasExited = () => true
};

return process;
};

using (TestSysbenchConfiguration SysbenchExecutor = new TestSysbenchConfiguration(this.fixture.Dependencies, this.fixture.Parameters))
{
await SysbenchExecutor.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
}
}

private class TestSysbenchConfiguration : SysbenchConfiguration
{
public TestSysbenchConfiguration(IServiceCollection services, IDictionary<string, IConvertible> parameters = null)
Expand Down
Loading