Skip to content
Draft
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public void NetworkingWorkloadStateInstancesAreJsonSerializable(bool? noSyncEnab
"Profiling_Scenario_1",
"00:00:30",
"00:00:05",
1,
noSyncEnabled,
Guid.NewGuid());

Expand Down Expand Up @@ -126,6 +127,7 @@ public void NetworkingWorkloadStateInstancesAreJsonSerializable_2()
"Profiling_Scenario_1",
"00:00:30",
"00:00:05",
1,
false,
Guid.NewGuid(),
//
Expand Down Expand Up @@ -174,6 +176,7 @@ public void NetworkingWorkloadStateInstancesAreJsonSerializable_3()
"Profiling_Scenario_1",
"00:00:30",
"00:00:05",
1,
false,
Guid.NewGuid(),
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,158 @@ public CPSClientExecutor(VirtualClientComponent component)
public CPSClientExecutor(IServiceCollection dependencies, IDictionary<string, IConvertible> parameters)
: base(dependencies, parameters)
{
this.InitializeWindowsClientCommandline();
this.InitializeLinuxClientCommandline();
}

/// <summary>
/// Returns the CPS client-side command line arguments.
/// </summary>
protected override string GetCommandLineArguments()

private void InitializeWindowsClientCommandline()
{
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
string clientIPAddress = this.GetLayoutClientInstances(ClientRole.Client).First().IPAddress;

// Ensure base string isn't null.
this.CommandLineWindowsClient ??= string.Empty;

// Normalize: keep a trailing space so appends don't glue together.
if (this.CommandLineWindowsClient.Length > 0 && !char.IsWhiteSpace(this.CommandLineWindowsClient[^1]))
{
this.CommandLineWindowsClient += " ";
}

// -c (client mode)
if (!this.CommandLineWindowsClient.Contains("-c", StringComparison.OrdinalIgnoreCase))
{
this.CommandLineWindowsClient += " -c";
}

// -r {Connections}
// Your reference includes "-c -r {Connections}"
if (!this.CommandLineWindowsClient.Contains("-r", StringComparison.OrdinalIgnoreCase))
{
this.CommandLineWindowsClient += $"-r {this.Connections} ";
}

// Endpoint tuple:
// {clientIPAddress},0,{serverIPAddress},{Port},{ConnectionsPerThread},{MaxPendingRequestsPerThread},{ConnectionDuration},{DataTransferMode}
// Add it only if we don't already see the server IP (good heuristic to avoid duplication).
if (!this.CommandLineWindowsClient.Contains(serverIPAddress, StringComparison.OrdinalIgnoreCase))
{
this.CommandLineWindowsClient +=
$"{clientIPAddress},0,{serverIPAddress},{this.Port},{this.ConnectionsPerThread},{this.MaxPendingRequestsPerThread},{this.ConnectionDuration},{this.DataTransferMode} ";
}

// -i {DisplayInterval}
if (!this.CommandLineWindowsClient.Contains("-i", StringComparison.OrdinalIgnoreCase))
{
this.CommandLineWindowsClient += $"-i {this.DisplayInterval} ";
}

// -wt {WarmupTime.TotalSeconds}
if (!this.CommandLineWindowsClient.Contains("-wt", StringComparison.OrdinalIgnoreCase) && this.WarmupTime != null)
{
this.CommandLineWindowsClient += $"-wt {this.WarmupTime.TotalSeconds} ";
}

// -t {TestDuration.TotalSeconds}
if (!this.CommandLineWindowsClient.Contains("-t", StringComparison.OrdinalIgnoreCase) && this.TestDuration != null)
{
this.CommandLineWindowsClient += $"-t {this.TestDuration.TotalSeconds} ";
}

// Optional: -ds {DelayTime.TotalSeconds} only if DelayTime != 0
if (!this.CommandLineWindowsClient.Contains("-ds", StringComparison.OrdinalIgnoreCase) &&
this.DelayTime != TimeSpan.Zero)
{
this.CommandLineWindowsClient += $"-ds {this.DelayTime.TotalSeconds} ";
}

// Additional params (append once)
if (!string.IsNullOrWhiteSpace(this.AdditionalParams))
{
// Optional: prevent double-appending if already present.
// You can remove this block if AdditionalParams is expected to be dynamic.
if (!this.CommandLineWindowsClient.Contains(this.AdditionalParams, StringComparison.OrdinalIgnoreCase))
{
this.CommandLineWindowsClient += $"{this.AdditionalParams} ";
}
}

this.CommandLineWindowsClient = this.CommandLineWindowsClient.Trim();
}

private void InitializeLinuxClientCommandline()
{
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
string clientIPAddress = this.GetLayoutClientInstances(ClientRole.Client).First().IPAddress;

// Ensure base string isn't null.
this.CommandLineLinuxClient ??= string.Empty;

// Normalize: keep a trailing space so appends don't glue together.
if (this.CommandLineLinuxClient.Length > 0 && !char.IsWhiteSpace(this.CommandLineLinuxClient[^1]))
{
this.CommandLineLinuxClient += " ";
}

// -c (client mode)
if (!this.CommandLineLinuxClient.Contains("-c", StringComparison.OrdinalIgnoreCase))
{
this.CommandLineLinuxClient += " -c";
}

// -r {Connections}
// Your reference includes "-c -r {Connections}"
if (!this.CommandLineLinuxClient.Contains("-r", StringComparison.OrdinalIgnoreCase))
{
this.CommandLineLinuxClient += $"-r {this.Connections} ";
}

// Endpoint tuple:
// {clientIPAddress},0,{serverIPAddress},{Port},{ConnectionsPerThread},{MaxPendingRequestsPerThread},{ConnectionDuration},{DataTransferMode}
// Add it only if we don't already see the server IP (good heuristic to avoid duplication).
if (!this.CommandLineLinuxClient.Contains(serverIPAddress, StringComparison.OrdinalIgnoreCase))
{
this.CommandLineLinuxClient +=
$"{clientIPAddress},0,{serverIPAddress},{this.Port},{this.ConnectionsPerThread},{this.MaxPendingRequestsPerThread},{this.ConnectionDuration},{this.DataTransferMode} ";
}

// -i {DisplayInterval}
if (!this.CommandLineLinuxClient.Contains("-i", StringComparison.OrdinalIgnoreCase))
{
this.CommandLineLinuxClient += $"-i {this.DisplayInterval} ";
}

// -wt {WarmupTime.TotalSeconds}
if (!this.CommandLineLinuxClient.Contains("-wt", StringComparison.OrdinalIgnoreCase) && this.WarmupTime != null)
{
this.CommandLineLinuxClient += $"-wt {this.WarmupTime.TotalSeconds} ";
}

// -t {TestDuration.TotalSeconds}
if (!this.CommandLineLinuxClient.Contains("-t", StringComparison.OrdinalIgnoreCase) && this.TestDuration != null)
{
this.CommandLineLinuxClient += $"-t {this.TestDuration.TotalSeconds} ";
}

// Optional: -ds {DelayTime.TotalSeconds} only if DelayTime != 0
if (!this.CommandLineLinuxClient.Contains("-ds", StringComparison.OrdinalIgnoreCase) &&
this.DelayTime != TimeSpan.Zero)
{
this.CommandLineLinuxClient += $"-ds {this.DelayTime.TotalSeconds} ";
}

// Additional params (append once)
if (!string.IsNullOrWhiteSpace(this.AdditionalParams))
{
// Optional: prevent double-appending if already present.
// You can remove this block if AdditionalParams is expected to be dynamic.
if (!this.CommandLineLinuxClient.Contains(this.AdditionalParams, StringComparison.OrdinalIgnoreCase))
{
this.CommandLineLinuxClient += $"{this.AdditionalParams} ";
}
}

return $"-c -r {this.Connections} " +
$"{clientIPAddress},0,{serverIPAddress},{this.Port},{this.ConnectionsPerThread},{this.MaxPendingRequestsPerThread},{this.ConnectionDuration},{this.DataTransferMode} " +
$"-i {this.DisplayInterval} -wt {this.WarmupTime.TotalSeconds} -t {this.TestDuration.TotalSeconds} " +
$"{((this.DelayTime != TimeSpan.Zero) ? $"-ds {this.DelayTime.TotalSeconds}" : string.Empty)} " +
$"{this.AdditionalParams}".Trim();
this.CommandLineLinuxClient = this.CommandLineLinuxClient.Trim();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,132 @@ public CPSServerExecutor(IServiceCollection dependencies, IDictionary<string, IC
{
}

/// <summary>
/// Returns the CPS client-side command line arguments.
/// </summary>
protected override string GetCommandLineArguments()
private void InitializeLinuxServerCommandline()
{
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
string clientIPAddress = this.GetLayoutClientInstances(ClientRole.Client).First().IPAddress;

// Ensure base string isn't null.
this.CommandLineLinuxServer ??= string.Empty;

// Normalize: keep a trailing space so appends don't glue together.
if (this.CommandLineLinuxServer.Length > 0 && !char.IsWhiteSpace(this.CommandLineLinuxServer[^1]))
{
this.CommandLineLinuxServer += " ";
}

// -c (client mode)
if (!this.CommandLineLinuxServer.Contains("-s", StringComparison.OrdinalIgnoreCase))
{
this.CommandLineLinuxServer += " -s";
}

// -r {Connections}
// Your reference includes "-c -r {Connections}"
if (!this.CommandLineLinuxServer.Contains("-r", StringComparison.OrdinalIgnoreCase))
{
this.CommandLineLinuxServer += $" -r {this.Connections} ";
}

// Endpoint tuple:
// {clientIPAddress},0,{serverIPAddress},{Port},{ConnectionsPerThread},{MaxPendingRequestsPerThread},{ConnectionDuration},{DataTransferMode}
// Add it only if we don't already see the server IP (good heuristic to avoid duplication).
if (!this.CommandLineLinuxServer.Contains(serverIPAddress, StringComparison.OrdinalIgnoreCase))
{
this.CommandLineLinuxServer +=
$"{serverIPAddress},{this.Port} ";
}

// -i {DisplayInterval}
if (!this.CommandLineLinuxServer.Contains("-i", StringComparison.OrdinalIgnoreCase))
{
this.CommandLineLinuxServer += $" -i {this.DisplayInterval} ";
}

// -wt {WarmupTime.TotalSeconds}
if (!this.CommandLineLinuxServer.Contains("-wt", StringComparison.OrdinalIgnoreCase) && this.WarmupTime != null)
{
this.CommandLineLinuxServer += $" -wt {this.WarmupTime.TotalSeconds} ";
}

// -t {TestDuration.TotalSeconds}
if (!this.CommandLineLinuxServer.Contains("-t", StringComparison.OrdinalIgnoreCase) && this.TestDuration != null)
{
this.CommandLineLinuxServer += $" -t {this.TestDuration.TotalSeconds} ";
}

// Optional: -ds {DelayTime.TotalSeconds} only if DelayTime != 0
if (!this.CommandLineLinuxServer.Contains("-ds", StringComparison.OrdinalIgnoreCase) &&
this.DelayTime != TimeSpan.Zero)
{
this.CommandLineLinuxServer += $" -ds {this.DelayTime.TotalSeconds} ";
}

this.CommandLineLinuxServer = this.CommandLineLinuxServer.Trim();
}

private void InitializeWindowsServerCommandline()
{
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
return $"-s -r {this.Connections} {serverIPAddress},{this.Port} -i {this.DisplayInterval} -wt {this.WarmupTime.TotalSeconds} -t {this.TestDuration.TotalSeconds} " +
$"{((this.DelayTime != TimeSpan.Zero) ? $"-ds {this.DelayTime.TotalSeconds}" : string.Empty)} ";
string clientIPAddress = this.GetLayoutClientInstances(ClientRole.Client).First().IPAddress;

// Ensure base string isn't null.
this.CommandLineWindowsServer ??= string.Empty;

// Normalize: keep a trailing space so appends don't glue together.
if (this.CommandLineWindowsServer.Length > 0 && !char.IsWhiteSpace(this.CommandLineWindowsServer[^1]))
{
this.CommandLineWindowsServer += " ";
}

// -c (client mode)
if (!this.CommandLineWindowsServer.Contains("-s", StringComparison.OrdinalIgnoreCase))
{
this.CommandLineWindowsServer += " -s";
}

// -r {Connections}
// Your reference includes "-c -r {Connections}"
if (!this.CommandLineWindowsServer.Contains("-r", StringComparison.OrdinalIgnoreCase))
{
this.CommandLineWindowsServer += $" -r {this.Connections} ";
}

// Endpoint tuple:
// {clientIPAddress},0,{serverIPAddress},{Port},{ConnectionsPerThread},{MaxPendingRequestsPerThread},{ConnectionDuration},{DataTransferMode}
// Add it only if we don't already see the server IP (good heuristic to avoid duplication).
if (!this.CommandLineWindowsServer.Contains(serverIPAddress, StringComparison.OrdinalIgnoreCase))
{
this.CommandLineWindowsServer +=
$"{serverIPAddress},{this.Port} ";
}

// -i {DisplayInterval}
if (!this.CommandLineWindowsServer.Contains("-i", StringComparison.OrdinalIgnoreCase))
{
this.CommandLineWindowsServer += $" -i {this.DisplayInterval} ";
}

// -wt {WarmupTime.TotalSeconds}
if (!this.CommandLineWindowsServer.Contains("-wt", StringComparison.OrdinalIgnoreCase) && this.WarmupTime != null)
{
this.CommandLineWindowsServer += $" -wt {this.WarmupTime.TotalSeconds} ";
}

// -t {TestDuration.TotalSeconds}
if (!this.CommandLineWindowsServer.Contains("-t", StringComparison.OrdinalIgnoreCase) && this.TestDuration != null)
{
this.CommandLineWindowsServer += $" -t {this.TestDuration.TotalSeconds} ";
}

// Optional: -ds {DelayTime.TotalSeconds} only if DelayTime != 0
if (!this.CommandLineWindowsServer.Contains("-ds", StringComparison.OrdinalIgnoreCase) &&
this.DelayTime != TimeSpan.Zero)
{
this.CommandLineWindowsServer += $" -ds {this.DelayTime.TotalSeconds} ";
}

this.CommandLineWindowsServer = this.CommandLineWindowsServer.Trim();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public LatteClientExecutor(VirtualClientComponent component)
public LatteClientExecutor(IServiceCollection dependencies, IDictionary<string, IConvertible> parameters)
: base(dependencies, parameters)
{
this.InitializeWindowsClientCommandline();
}

/// <inheritdoc/>
Expand Down Expand Up @@ -140,5 +141,34 @@ protected override void CaptureMetrics(string results, string commandArguments,
results);
}
}

private void InitializeWindowsClientCommandline()
{
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;

this.CommandLineWindowsClient ??= string.Empty;

if (this.CommandLineWindowsClient.Length > 0 && !char.IsWhiteSpace(this.CommandLineWindowsClient[^1]))
{
this.CommandLineWindowsClient += " ";
}

if (!this.CommandLineWindowsClient.Contains("--tcp", StringComparison.OrdinalIgnoreCase))
{
this.CommandLineWindowsClient += this.Protocol.ToLowerInvariant() == "tcp" ? " --tcp" : string.Empty;
}

if (!this.CommandLineWindowsClient.Contains("-riopoll", StringComparison.OrdinalIgnoreCase) && this.RioPoll != 0)
{
this.CommandLineWindowsClient += $" -riopoll {this.RioPoll}";
}

if (this.Protocol != null && !this.CommandLineWindowsClient.Contains($"-{this.Protocol.ToString().ToLowerInvariant()}"))
{
this.CommandLineWindowsClient += $" -{this.Protocol.ToString().ToLowerInvariant()}";
}

this.CommandLineWindowsClient = this.CommandLineWindowsClient.Trim();
}
}
}
Loading