Skip to content

Commit 434a418

Browse files
ericavellaErica Vellanoweth
andauthored
- avoids the parsing error that frequently comes up (#189)
- automates checking records & table count - cleaning up parameters, helps w user experience - unit tests updated accordingly Co-authored-by: Erica Vellanoweth <[email protected]>
1 parent b18063d commit 434a418

File tree

9 files changed

+388
-206
lines changed

9 files changed

+388
-206
lines changed

src/VirtualClient/VirtualClient.Actions.FunctionalTests/SysbenchOLTP/SysbenchOLTPClientProfileTests.cs

Lines changed: 94 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ namespace VirtualClient.Actions
1010
using System.Runtime.InteropServices;
1111
using System.Threading;
1212
using System.Threading.Tasks;
13-
using Microsoft.CodeAnalysis.Scripting;
1413
using Moq;
1514
using NUnit.Framework;
1615
using VirtualClient.Common;
16+
using VirtualClient.Common.Contracts;
1717
using VirtualClient.Contracts;
18+
using static VirtualClient.Actions.SysbenchOLTPExecutor;
1819

1920
[TestFixture]
2021
[Category("Functional")]
@@ -54,8 +55,13 @@ public void SysbenchOLTPWorkloadProfileActionsWillNotBeExecutedIfTheWorkloadPack
5455
[TestCase("PERF-MYSQL-SYSBENCH-OLTP.json", PlatformID.Unix, Architecture.X64)]
5556
public async Task SysbenchOLTPWorkloadProfileExecutesTheExpectedWorkloadsOnUnixPlatform(string profile, PlatformID platform, Architecture architecture)
5657
{
57-
IEnumerable<string> expectedCommands = this.GetProfileExpectedCommands(platform, architecture);
58+
IEnumerable<string> expectedCommands = this.GetProfileExpectedCommands(singleVM: false);
5859
this.SetupDefaultMockBehaviors(platform, architecture);
60+
61+
this.mockFixture.Setup(PlatformID.Unix, architecture, this.clientAgentId).SetupLayout(
62+
new ClientInstance(this.clientAgentId, "1.2.3.4", "Client"),
63+
new ClientInstance(this.serverAgentId, "1.2.3.5", "Server"));
64+
5965
this.SetupApiClient(this.serverAgentId, serverIPAddress: "1.2.3.5");
6066

6167
string scriptPath = this.mockFixture.PlatformSpecifics.GetScriptPath("sysbencholtp");
@@ -86,44 +92,106 @@ public async Task SysbenchOLTPWorkloadProfileExecutesTheExpectedWorkloadsOnUnixP
8692
}
8793
}
8894

89-
private IEnumerable<string> GetProfileExpectedCommands(PlatformID platform, Architecture architecture)
95+
[Test]
96+
[TestCase("PERF-MYSQL-SYSBENCH-OLTP.json", PlatformID.Unix, Architecture.X64)]
97+
public async Task SysbenchOLTPWorkloadProfileExecutesTheExpectedWorkloadsOnSingleVMUnixPlatform(string profile, PlatformID platform, Architecture architecture)
9098
{
91-
return new List<string>()
99+
IEnumerable<string> expectedCommands = this.GetProfileExpectedCommands(singleVM: true);
100+
this.SetupDefaultMockBehaviors(platform, architecture);
101+
102+
this.mockFixture.Setup(PlatformID.Unix, architecture, this.clientAgentId).SetupLayout(
103+
new ClientInstance(this.serverAgentId, "1.2.3.5", "Server"));
104+
105+
this.SetupApiClient(this.serverAgentId, serverIPAddress: "1.2.3.5");
106+
107+
string scriptPath = this.mockFixture.PlatformSpecifics.GetScriptPath("sysbencholtp");
108+
109+
string balancedClientScript = this.mockFixture.PlatformSpecifics.Combine(scriptPath, "balanced-client.sh");
110+
string balancedServerScript = this.mockFixture.PlatformSpecifics.Combine(scriptPath, "balanced-server.sh");
111+
string inMemoryScript = this.mockFixture.PlatformSpecifics.Combine(scriptPath, "in-memory.sh");
112+
113+
this.mockFixture.SetupFile(balancedServerScript);
114+
this.mockFixture.SetupFile(balancedClientScript);
115+
this.mockFixture.SetupFile(inMemoryScript);
116+
117+
this.mockFixture.ProcessManager.OnCreateProcess = (command, arguments, workingDir) =>
92118
{
93-
"git clone https://github.com/akopytov/sysbench.git /home/user/tools/VirtualClient/packages/sysbench",
94-
95-
"sudo ./autogen.sh",
96-
"sudo ./configure",
97-
"sudo make -j",
98-
"sudo make install",
99-
100-
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_write --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 cleanup",
101-
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_common --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 prepare",
102-
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_write --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
103-
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_only --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
104-
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_delete --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
105-
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_insert --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
106-
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_update_index --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
107-
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_update_non_index --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
108-
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench select_random_points --threads=64 --tables=1 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
109-
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench select_random_ranges --threads=64 --tables=1 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run"
119+
IProcessProxy process = this.mockFixture.CreateProcess(command, arguments, workingDir);
120+
if (arguments.Contains("run", StringComparison.OrdinalIgnoreCase))
121+
{
122+
process.StandardOutput.Append(TestDependencies.GetResourceFileContents("Results_SysbenchOLTP.txt"));
123+
}
124+
125+
return process;
110126
};
127+
128+
using (ProfileExecutor executor = TestDependencies.CreateProfileExecutor(profile, this.mockFixture.Dependencies))
129+
{
130+
await executor.ExecuteAsync(ProfileTiming.OneIteration(), CancellationToken.None).ConfigureAwait(false);
131+
WorkloadAssert.CommandsExecuted(this.mockFixture, expectedCommands.ToArray());
132+
}
133+
}
134+
135+
private IEnumerable<string> GetProfileExpectedCommands(bool singleVM)
136+
{
137+
if (singleVM)
138+
{
139+
return new List<string>()
140+
{
141+
"git clone https://github.com/akopytov/sysbench.git /home/user/tools/VirtualClient/packages/sysbench",
142+
143+
"sudo ./autogen.sh",
144+
"sudo ./configure",
145+
"sudo make -j",
146+
"sudo make install",
147+
148+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_write --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 cleanup",
149+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_common --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 prepare",
150+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_write --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
151+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_only --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
152+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_delete --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
153+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_insert --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
154+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_update_index --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
155+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_update_non_index --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
156+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench select_random_points --threads=64 --tables=1 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
157+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench select_random_ranges --threads=64 --tables=1 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run"
158+
};
159+
}
160+
else
161+
{
162+
return new List<string>()
163+
{
164+
"git clone https://github.com/akopytov/sysbench.git /home/user/tools/VirtualClient/packages/sysbench",
165+
166+
"sudo ./autogen.sh",
167+
"sudo ./configure",
168+
"sudo make -j",
169+
"sudo make install",
170+
171+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_write --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 cleanup",
172+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_common --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 prepare",
173+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_write --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
174+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_only --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
175+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_delete --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
176+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_insert --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
177+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_update_index --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
178+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_update_non_index --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
179+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench select_random_points --threads=64 --tables=1 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
180+
$"sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench select_random_ranges --threads=64 --tables=1 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run"
181+
};
182+
}
111183
}
112184

113185
private void SetupApiClient(string serverName, string serverIPAddress)
114186
{
115187
IPAddress.TryParse(serverIPAddress, out IPAddress ipAddress);
116-
IApiClient apiClient = this.mockFixture.ApiClientManager.GetOrCreateApiClient(serverName, ipAddress);
188+
IApiClient apiClient = this.mockFixture.ApiClientManager.GetOrCreateApiClient(serverIPAddress, ipAddress);
117189
}
118190

119191
private void SetupDefaultMockBehaviors(PlatformID platform, Architecture architecture)
120192
{
121193
this.mockFixture.Setup(platform, architecture);
122194
this.mockFixture.SetupWorkloadPackage("sysbench", expectedFiles: "sysbench");
123-
this.mockFixture.Setup(PlatformID.Unix, architecture, this.clientAgentId).SetupLayout(
124-
new ClientInstance(this.clientAgentId, "1.2.3.4", "Client"),
125-
new ClientInstance(this.serverAgentId, "1.2.3.5", "Server"));
126-
127195
this.mockFixture.SystemManagement.Setup(mgr => mgr.GetCpuInfoAsync(It.IsAny<CancellationToken>()))
128196
.ReturnsAsync(new CpuInfo("cpu", "description", 4, 8, 4, 4, false));
129197
}

0 commit comments

Comments
 (0)