-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Users/nmalkapuram/my sql compete recipe #403
base: main
Are you sure you want to change the base?
Changes from all commits
19de406
e7ef5e5
251ff33
6f30275
155312c
f03f24c
77a96c4
ef34e79
88a9c45
c15c2e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,12 @@ namespace VirtualClient.Actions | |
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Text.RegularExpressions; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using MathNet.Numerics; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Polly; | ||
using VirtualClient.Common; | ||
|
@@ -27,6 +29,8 @@ public class SysbenchClientExecutor : SysbenchExecutor | |
{ | ||
private string sysbenchExecutionArguments; | ||
private string sysbenchLoggingArguments; | ||
private string sysbenchPrepareArguments; | ||
private string packageDirectory; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SysbenchClientExecutor"/> class. | ||
|
@@ -169,7 +173,24 @@ private Task ExecuteWorkloadAsync(EventContext telemetryContext, CancellationTok | |
{ | ||
if (this.Benchmark == BenchmarkName.OLTP) | ||
{ | ||
await this.RunOLTPWorkloadAsync(telemetryContext, cancellationToken); | ||
if (this.Action == ClientAction.TruncateDatabase) | ||
{ | ||
DependencyPath workloadPackage = await this.GetPackageAsync(this.PackageName, cancellationToken).ConfigureAwait(false); | ||
nmalkapuram marked this conversation as resolved.
Show resolved
Hide resolved
|
||
workloadPackage.ThrowIfNull(this.PackageName); | ||
|
||
DependencyPath package = await this.GetPlatformSpecificPackageAsync(this.PackageName, cancellationToken); | ||
this.packageDirectory = package.Path; | ||
|
||
await this.TruncateMySQLDatabaseAsync(telemetryContext, cancellationToken).ConfigureAwait(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we doing this? The logic to create the database is already a part of the MySqlServerConfiguration and SysbenchConfiguration classes. We ARE NOT trying to support rebuilding the database on every round of processing. This is extremely inefficient. It may not be clear how we intend to support this database workload, so I will share the guidance given to Erica initially. The related profile should build the database out on a first run. It does this making no assumptions and will/should drop the database if it exists. The database should then be reused on each subsequent run. This means that the database must be a set size (e.g. #tables, records) for a given profile. If the user decides they want to operate against a database that is sized differently, they are expected to perform a "clean". This removes the state tracking and causes VC to behave like it is a first time run again thus dropping any existing DB and recreating it. I don't want to attempt to handle deep eccentricities with database workloads such as resizing an existing database in any other way other than dropping and recreating. |
||
} | ||
else if (this.Action == ClientAction.PopulateDatabase) | ||
{ | ||
await this.PrepareOLTPMySQLDatabase(telemetryContext, cancellationToken); | ||
} | ||
else | ||
{ | ||
await this.RunOLTPWorkloadAsync(telemetryContext, cancellationToken); | ||
} | ||
} | ||
else if (this.Benchmark == BenchmarkName.TPCC) | ||
{ | ||
|
@@ -194,11 +215,10 @@ private async Task RunOLTPWorkloadAsync(EventContext telemetryContext, Cancellat | |
this.sysbenchLoggingArguments = $"--dbName {this.DatabaseName} --databaseSystem {this.DatabaseSystem} --benchmark {this.Benchmark} --workload {this.Workload} --threadCount {threadCount} --tableCount {tableCount} --recordCount {recordCount} "; | ||
this.sysbenchExecutionArguments = this.sysbenchLoggingArguments + $"--hostIpAddress {this.ServerIpAddress} --durationSecs {this.Duration.TotalSeconds} --password {this.SuperUserPassword}"; | ||
|
||
string command = "python3"; | ||
string script = $"{this.SysbenchPackagePath}/run-workload.py "; | ||
|
||
using (IProcessProxy process = await this.ExecuteCommandAsync( | ||
command, | ||
SysbenchExecutor.PythonCommand, | ||
script + this.sysbenchExecutionArguments, | ||
this.SysbenchPackagePath, | ||
telemetryContext, | ||
|
@@ -223,11 +243,10 @@ private async Task RunTPCCWorkloadAsync(EventContext telemetryContext, Cancellat | |
this.sysbenchLoggingArguments = $"--dbName {this.DatabaseName} --databaseSystem {this.DatabaseSystem} --benchmark {this.Benchmark} --workload tpcc --threadCount {threadCount} --tableCount {tableCount} --warehouses {warehouseCount} "; | ||
this.sysbenchExecutionArguments = this.sysbenchLoggingArguments + $"--hostIpAddress {this.ServerIpAddress} --durationSecs {this.Duration.TotalSeconds} --password {this.SuperUserPassword}"; | ||
|
||
string command = "python3"; | ||
string script = $"{this.SysbenchPackagePath}/run-workload.py "; | ||
|
||
using (IProcessProxy process = await this.ExecuteCommandAsync( | ||
command, | ||
SysbenchExecutor.PythonCommand, | ||
script + this.sysbenchExecutionArguments, | ||
this.SysbenchPackagePath, | ||
telemetryContext, | ||
|
@@ -242,5 +261,69 @@ private async Task RunTPCCWorkloadAsync(EventContext telemetryContext, Cancellat | |
} | ||
} | ||
} | ||
|
||
private async Task TruncateMySQLDatabaseAsync(EventContext telemetryContext, CancellationToken cancellationToken) | ||
{ | ||
string arguments = $"{this.packageDirectory}/truncate-tables.py --dbName {this.DatabaseName}"; | ||
nmalkapuram marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
string serverIps = "localhost"; | ||
|
||
if (this.IsMultiRoleLayout()) | ||
{ | ||
ClientInstance instance = this.Layout.GetClientInstance(this.AgentId); | ||
serverIps = (instance.Role == ClientRole.Server) ? "localhost" : this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress; | ||
} | ||
|
||
arguments += $" --clientIps \"{serverIps}\""; | ||
|
||
using (IProcessProxy process = await this.ExecuteCommandAsync( | ||
SysbenchExecutor.PythonCommand, | ||
arguments, | ||
Environment.CurrentDirectory, | ||
telemetryContext, | ||
cancellationToken)) | ||
{ | ||
if (!cancellationToken.IsCancellationRequested) | ||
{ | ||
await this.LogProcessDetailsAsync(process, telemetryContext, "Sysbench", logToFile: true); | ||
process.ThrowIfDependencyInstallationFailed(process.StandardError.ToString()); | ||
} | ||
} | ||
} | ||
|
||
private async Task PrepareOLTPMySQLDatabase(EventContext telemetryContext, CancellationToken cancellationToken) | ||
{ | ||
int tableCount = GetTableCount(this.DatabaseScenario, this.TableCount, this.Workload); | ||
int threadCount = GetThreadCount(this.SystemManager, this.DatabaseScenario, this.Threads); | ||
int recordCount = GetRecordCount(this.SystemManager, this.DatabaseScenario, this.RecordCount); | ||
|
||
this.sysbenchPrepareArguments = $"--dbName {this.DatabaseName} --databaseSystem {this.DatabaseSystem} --benchmark {this.Benchmark} --tableCount {tableCount} --recordCount {recordCount} --threadCount {threadCount} --password {this.SuperUserPassword}"; | ||
|
||
string serverIp = "localhost"; | ||
|
||
if (this.IsMultiRoleLayout()) | ||
{ | ||
ClientInstance instance = this.Layout.GetClientInstance(this.AgentId); | ||
serverIp = (instance.Role == ClientRole.Server) ? "localhost" : this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress; | ||
} | ||
|
||
this.sysbenchPrepareArguments += $" --host \"{serverIp}\""; | ||
|
||
string arguments = $"{this.SysbenchPackagePath}/populate-database.py "; | ||
|
||
using (IProcessProxy process = await this.ExecuteCommandAsync( | ||
SysbenchExecutor.PythonCommand, | ||
arguments + this.sysbenchPrepareArguments, | ||
this.SysbenchPackagePath, | ||
telemetryContext, | ||
cancellationToken)) | ||
{ | ||
if (!cancellationToken.IsCancellationRequested) | ||
{ | ||
await this.LogProcessDetailsAsync(process, telemetryContext, "Sysbench", logToFile: true); | ||
process.ThrowIfErrored<WorkloadException>(process.StandardError.ToString(), ErrorReason.WorkloadUnexpectedAnomaly); | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ namespace VirtualClient.Actions | |
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
@@ -81,11 +84,20 @@ private async Task PrepareOLTPMySQLDatabase(EventContext telemetryContext, Cance | |
|
||
this.sysbenchPrepareArguments = $"--dbName {this.DatabaseName} --databaseSystem {this.DatabaseSystem} --benchmark {this.Benchmark} --tableCount {tableCount} --recordCount {recordCount} --threadCount {threadCount} --password {this.SuperUserPassword}"; | ||
|
||
string command = $"python3"; | ||
string serverIp = "localhost"; | ||
|
||
if (this.IsMultiRoleLayout()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed? The SysbenchConfiguration SHOULD be running on the Server role (database) system to begin with. |
||
{ | ||
ClientInstance instance = this.Layout.GetClientInstance(this.AgentId); | ||
serverIp = (instance.Role == ClientRole.Server) ? "localhost" : this.GetServerIpAddress(); | ||
} | ||
|
||
this.sysbenchPrepareArguments += $" --host \"{serverIp}\""; | ||
|
||
string arguments = $"{this.SysbenchPackagePath}/populate-database.py "; | ||
|
||
using (IProcessProxy process = await this.ExecuteCommandAsync( | ||
command, | ||
SysbenchExecutor.PythonCommand, | ||
arguments + this.sysbenchPrepareArguments, | ||
this.SysbenchPackagePath, | ||
telemetryContext, | ||
|
@@ -107,11 +119,10 @@ private async Task PrepareTPCCMySQLDatabase(EventContext telemetryContext, Cance | |
|
||
this.sysbenchPrepareArguments = $"--dbName {this.DatabaseName} --databaseSystem {this.DatabaseSystem} --benchmark {this.Benchmark} --tableCount {tableCount} --warehouses {warehouseCount} --threadCount {threadCount} --password {this.SuperUserPassword}"; | ||
|
||
string command = $"python3"; | ||
string arguments = $"{this.SysbenchPackagePath}/populate-database.py "; | ||
|
||
using (IProcessProxy process = await this.ExecuteCommandAsync( | ||
command, | ||
SysbenchExecutor.PythonCommand, | ||
arguments + this.sysbenchPrepareArguments, | ||
this.SysbenchPackagePath, | ||
telemetryContext, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in other comments, there is an extension method on the VirtualClientComponent class that can get instances by role. We don't need the GetServerIpAddress method.