Skip to content

Commit 2ae4ce3

Browse files
ericavellaErica Vellanoweth
andauthored
adding tpcc workload to sysbench (#303)
* adding tpcc workload to sysbench * updating encodings * adjustments --------- Co-authored-by: Erica Vellanoweth <[email protected]>
1 parent 332b96a commit 2ae4ce3

File tree

17 files changed

+815
-173
lines changed

17 files changed

+815
-173
lines changed

src/VirtualClient/VirtualClient.Actions.FunctionalTests/SysbenchProfileTests.cs

Lines changed: 187 additions & 45 deletions
Large diffs are not rendered by default.

src/VirtualClient/VirtualClient.Actions.FunctionalTests/VirtualClient.Actions.FunctionalTests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@
205205
<Content Include="..\VirtualClient.Main\profiles\PERF-MYSQL-OLTP-SYSBENCH.json" Link="Profiles\PERF-MYSQL-OLTP-SYSBENCH.json">
206206
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
207207
</Content>
208+
<Content Include="..\VirtualClient.Main\profiles\PERF-MYSQL-TPCC-SYSBENCH.json" Link="Profiles\PERF-MYSQL-TPCC-SYSBENCH.json">
209+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
210+
</Content>
208211
<Content Include="..\VirtualClient.Main\profiles\PERF-NETWORK-DEATHSTARBENCH.json" Link="Profiles\PERF-NETWORK-DEATHSTARBENCH.json">
209212
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
210213
</Content>

src/VirtualClient/VirtualClient.Actions.UnitTests/Sysbench/SysbenchClientExecutorTests.cs

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public void SetupDefaultBehavior()
4646

4747
this.fixture.Parameters = new Dictionary<string, IConvertible>()
4848
{
49+
{ nameof(SysbenchClientExecutor.Benchmark), "OLTP" },
4950
{ nameof(SysbenchClientExecutor.DatabaseName), "sbtest" },
5051
{ nameof(SysbenchClientExecutor.Duration), "00:00:10" },
5152
{ nameof(SysbenchClientExecutor.Workload), "oltp_read_write" },
@@ -87,7 +88,7 @@ public async Task SysbenchClientExecutorRunsTheExpectedWorkloadCommand()
8788
{
8889
SetupDefaultBehavior();
8990

90-
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";
91+
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";
9192
bool commandExecuted = false;
9293

9394
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
@@ -131,9 +132,9 @@ public async Task SysbenchClientExecutorUsesDefinedParametersWhenRunningTheWorkl
131132
this.fixture.Parameters[nameof(SysbenchClientExecutor.Threads)] = "64";
132133
this.fixture.Parameters[nameof(SysbenchClientExecutor.RecordCount)] = "1000";
133134
this.fixture.Parameters[nameof(SysbenchClientExecutor.TableCount)] = "40";
134-
this.fixture.Parameters[nameof(SysbenchClientExecutor.Scenario)] = "Configure";
135+
this.fixture.Parameters[nameof(SysbenchClientExecutor.DatabaseScenario)] = "Configure";
135136

136-
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";
137+
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";
137138
bool commandExecuted = false;
138139

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

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

179-
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";
180+
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";
180181
bool commandExecuted = false;
181182

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

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

222-
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";
223+
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";
223224
bool commandExecuted = false;
224225

225226
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
@@ -255,6 +256,49 @@ public async Task SysbenchClientExecutorRunsInMemoryScenario()
255256
}
256257
}
257258

259+
[Test]
260+
public async Task SysbenchClientExecutorRunsTheExpectedTPCCWorkloadCommand()
261+
{
262+
SetupDefaultBehavior();
263+
264+
this.fixture.Parameters[nameof(SysbenchClientExecutor.Benchmark)] = "TPCC";
265+
266+
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";
267+
bool commandExecuted = false;
268+
269+
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
270+
{
271+
if (expectedCommand == $"{exe} {arguments}")
272+
{
273+
commandExecuted = true;
274+
}
275+
276+
Assert.IsTrue(commandExecuted);
277+
278+
InMemoryProcess process = new InMemoryProcess
279+
{
280+
StartInfo = new ProcessStartInfo
281+
{
282+
FileName = exe,
283+
Arguments = arguments
284+
},
285+
ExitCode = 0,
286+
OnStart = () => true,
287+
OnHasExited = () => true
288+
};
289+
290+
string resultsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Examples", "Sysbench", "SysbenchExample.txt");
291+
process.StandardOutput.Append(File.ReadAllText(resultsPath));
292+
293+
return process;
294+
};
295+
296+
using (TestSysbenchClientExecutor SysbenchExecutor = new TestSysbenchClientExecutor(this.fixture.Dependencies, this.fixture.Parameters))
297+
{
298+
await SysbenchExecutor.ExecuteAsync(CancellationToken.None);
299+
}
300+
}
301+
258302
private class TestSysbenchClientExecutor : SysbenchClientExecutor
259303
{
260304
public TestSysbenchClientExecutor(IServiceCollection services, IDictionary<string, IConvertible> parameters = null)

src/VirtualClient/VirtualClient.Actions.UnitTests/Sysbench/SysbenchConfigurationTests.cs

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public void SetupDefaultBehavior()
4747

4848
this.fixture.Parameters = new Dictionary<string, IConvertible>()
4949
{
50+
{ nameof(SysbenchConfiguration.Benchmark), "OLTP" },
5051
{ nameof(SysbenchConfiguration.DatabaseName), "sbtest" },
5152
{ nameof(SysbenchConfiguration.PackageName), "sysbench" },
5253
{ nameof(SysbenchConfiguration.Scenario), "populate_database" }
@@ -74,7 +75,7 @@ public async Task SysbenchConfigurationSkipsSysbenchInitialization()
7475

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

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

125126
int commandNumber = 0;
@@ -165,12 +166,12 @@ public async Task SysbenchConfigurationUsesDefinedParametersWhenRunningTheWorklo
165166
this.fixture.Parameters[nameof(SysbenchConfiguration.Threads)] = "16";
166167
this.fixture.Parameters[nameof(SysbenchConfiguration.RecordCount)] = "1000";
167168
this.fixture.Parameters[nameof(SysbenchConfiguration.TableCount)] = "40";
168-
this.fixture.Parameters[nameof(SysbenchClientExecutor.Scenario)] = "Configure";
169+
this.fixture.Parameters[nameof(SysbenchClientExecutor.DatabaseScenario)] = "Configure";
169170

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

176177
int commandNumber = 0;
@@ -259,6 +260,114 @@ public async Task SysbenchConfigurationSkipsDatabasePopulationWhenInitialized()
259260
}
260261
}
261262

263+
[Test]
264+
public async Task SysbenchConfigurationProperlyExecutesTPCCPreparation()
265+
{
266+
this.fixture.Parameters[nameof(SysbenchConfiguration.Benchmark)] = "TPCC";
267+
268+
this.fixture.StateManager.OnGetState().ReturnsAsync(JObject.FromObject(new SysbenchExecutor.SysbenchState()
269+
{
270+
SysbenchInitialized = true
271+
}));
272+
273+
string[] expectedCommands =
274+
{
275+
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --benchmark TPCC --tableCount 10 --warehouses 100 --threadCount 8"
276+
};
277+
278+
int commandNumber = 0;
279+
bool commandExecuted = false;
280+
281+
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
282+
{
283+
string expectedCommand = expectedCommands[commandNumber];
284+
285+
if (expectedCommand == $"{exe} {arguments}")
286+
{
287+
commandExecuted = true;
288+
}
289+
290+
Assert.IsTrue(commandExecuted);
291+
commandExecuted = false;
292+
commandNumber += 1;
293+
294+
InMemoryProcess process = new InMemoryProcess
295+
{
296+
StartInfo = new ProcessStartInfo
297+
{
298+
FileName = exe,
299+
Arguments = arguments
300+
},
301+
ExitCode = 0,
302+
OnStart = () => true,
303+
OnHasExited = () => true
304+
};
305+
306+
return process;
307+
};
308+
309+
using (TestSysbenchConfiguration SysbenchExecutor = new TestSysbenchConfiguration(this.fixture.Dependencies, this.fixture.Parameters))
310+
{
311+
await SysbenchExecutor.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
312+
}
313+
}
314+
315+
[Test]
316+
public async Task SysbenchConfigurationProperlyExecutesTPCCConfigurablePreparation()
317+
{
318+
this.fixture.Parameters[nameof(SysbenchConfiguration.Benchmark)] = "TPCC";
319+
this.fixture.Parameters[nameof(SysbenchConfiguration.Threads)] = "16";
320+
this.fixture.Parameters[nameof(SysbenchConfiguration.WarehouseCount)] = "1000";
321+
this.fixture.Parameters[nameof(SysbenchConfiguration.TableCount)] = "40";
322+
this.fixture.Parameters[nameof(SysbenchClientExecutor.DatabaseScenario)] = "Configure";
323+
324+
this.fixture.StateManager.OnGetState().ReturnsAsync(JObject.FromObject(new SysbenchExecutor.SysbenchState()
325+
{
326+
SysbenchInitialized = true
327+
}));
328+
329+
string[] expectedCommands =
330+
{
331+
$"python3 {this.mockPackagePath}/populate-database.py --dbName sbtest --benchmark TPCC --tableCount 40 --warehouses 1000 --threadCount 16"
332+
};
333+
334+
int commandNumber = 0;
335+
bool commandExecuted = false;
336+
337+
this.fixture.ProcessManager.OnCreateProcess = (exe, arguments, workingDir) =>
338+
{
339+
string expectedCommand = expectedCommands[commandNumber];
340+
341+
if (expectedCommand == $"{exe} {arguments}")
342+
{
343+
commandExecuted = true;
344+
}
345+
346+
Assert.IsTrue(commandExecuted);
347+
commandExecuted = false;
348+
commandNumber += 1;
349+
350+
InMemoryProcess process = new InMemoryProcess
351+
{
352+
StartInfo = new ProcessStartInfo
353+
{
354+
FileName = exe,
355+
Arguments = arguments
356+
},
357+
ExitCode = 0,
358+
OnStart = () => true,
359+
OnHasExited = () => true
360+
};
361+
362+
return process;
363+
};
364+
365+
using (TestSysbenchConfiguration SysbenchExecutor = new TestSysbenchConfiguration(this.fixture.Dependencies, this.fixture.Parameters))
366+
{
367+
await SysbenchExecutor.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
368+
}
369+
}
370+
262371
private class TestSysbenchConfiguration : SysbenchConfiguration
263372
{
264373
public TestSysbenchConfiguration(IServiceCollection services, IDictionary<string, IConvertible> parameters = null)

0 commit comments

Comments
 (0)