Skip to content

Commit

Permalink
updating host inputs for scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
nmalkapuram committed Jan 6, 2025
1 parent 88a9c45 commit c15c2e6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace VirtualClient.Actions
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using MathNet.Numerics;
using Microsoft.Extensions.DependencyInjection;
using Polly;
using VirtualClient.Common;
Expand All @@ -26,7 +27,6 @@ namespace VirtualClient.Actions
/// </summary>
public class SysbenchClientExecutor : SysbenchExecutor
{
private const string PythonCommand = "python3";
private string sysbenchExecutionArguments;
private string sysbenchLoggingArguments;
private string sysbenchPrepareArguments;
Expand Down Expand Up @@ -218,7 +218,7 @@ private async Task RunOLTPWorkloadAsync(EventContext telemetryContext, Cancellat
string script = $"{this.SysbenchPackagePath}/run-workload.py ";

using (IProcessProxy process = await this.ExecuteCommandAsync(
SysbenchClientExecutor.PythonCommand,
SysbenchExecutor.PythonCommand,
script + this.sysbenchExecutionArguments,
this.SysbenchPackagePath,
telemetryContext,
Expand Down Expand Up @@ -246,7 +246,7 @@ private async Task RunTPCCWorkloadAsync(EventContext telemetryContext, Cancellat
string script = $"{this.SysbenchPackagePath}/run-workload.py ";

using (IProcessProxy process = await this.ExecuteCommandAsync(
SysbenchClientExecutor.PythonCommand,
SysbenchExecutor.PythonCommand,
script + this.sysbenchExecutionArguments,
this.SysbenchPackagePath,
telemetryContext,
Expand All @@ -266,15 +266,18 @@ private async Task TruncateMySQLDatabaseAsync(EventContext telemetryContext, Can
{
string arguments = $"{this.packageDirectory}/truncate-tables.py --dbName {this.DatabaseName}";

string serverIps = "localhost";

if (this.IsMultiRoleLayout())
{
ClientInstance instance = this.Layout.GetClientInstance(this.AgentId);
string serverIps = (instance.Role == ClientRole.Server) ? "localhost" : this.GetServerIpAddress();
arguments += $" --clientIps \"{serverIps}\"";
serverIps = (instance.Role == ClientRole.Server) ? "localhost" : this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
}

arguments += $" --clientIps \"{serverIps}\"";

using (IProcessProxy process = await this.ExecuteCommandAsync(
SysbenchClientExecutor.PythonCommand,
SysbenchExecutor.PythonCommand,
arguments,
Environment.CurrentDirectory,
telemetryContext,
Expand All @@ -296,17 +299,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 serverIp = "localhost";

if (this.IsMultiRoleLayout())
{
ClientInstance instance = this.Layout.GetClientInstance(this.AgentId);
string serverIp = (instance.Role == ClientRole.Server) ? "localhost" : this.GetServerIpAddress();
this.sysbenchPrepareArguments += $" --host \"{serverIp}\"";
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(
SysbenchClientExecutor.PythonCommand,
SysbenchExecutor.PythonCommand,
arguments + this.sysbenchPrepareArguments,
this.SysbenchPackagePath,
telemetryContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +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 serverIp = "localhost";

if (this.IsMultiRoleLayout())
{
ClientInstance instance = this.Layout.GetClientInstance(this.AgentId);
string serverIp = (instance.Role == ClientRole.Server) ? "localhost" : this.GetServerIpAddress();
this.sysbenchPrepareArguments += $" --host \"{serverIp}\"";
serverIp = (instance.Role == ClientRole.Server) ? "localhost" : this.GetServerIpAddress();
}

string command = $"python3";
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,
Expand All @@ -117,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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public class SysbenchExecutor : VirtualClientComponent
/// </summary>
public const int SelectWorkloadDefaultTableCount = 1;

/// <summary>
/// const for python command.
/// </summary>
protected const string PythonCommand = "python3";

private readonly IStateManager stateManager;
private static readonly string[] SelectWorkloads =
{
Expand Down

0 comments on commit c15c2e6

Please sign in to comment.