Skip to content

Commit d791984

Browse files
committed
Adding command line
1 parent 7c4dc89 commit d791984

8 files changed

Lines changed: 483 additions & 297 deletions

File tree

src/VirtualClient/VirtualClient.Actions/Network/NetworkingWorkload/CPS/CPSClientExecutor.cs

Lines changed: 76 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,8 @@ public CPSClientExecutor(VirtualClientComponent component)
3333
public CPSClientExecutor(IServiceCollection dependencies, IDictionary<string, IConvertible> parameters)
3434
: base(dependencies, parameters)
3535
{
36-
}
37-
38-
/// <summary>
39-
/// Returns the CPS client-side command line arguments.
40-
/// </summary>
41-
protected override string GetCommandLineArguments()
42-
{
43-
string clientIPAddress = this.GetLayoutClientInstances(ClientRole.Client).First().IPAddress;
44-
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
45-
46-
return $"-c -r {this.Connections} " +
47-
$"{clientIPAddress},0,{serverIPAddress},{this.Port},{this.ConnectionsPerThread},{this.MaxPendingRequestsPerThread},{this.ConnectionDuration},{this.DataTransferMode} " +
48-
$"-i {this.DisplayInterval} -wt {this.WarmupTime.TotalSeconds} -t {this.TestDuration.TotalSeconds} " +
49-
$"{((this.DelayTime != TimeSpan.Zero) ? $"-ds {this.DelayTime.TotalSeconds}" : string.Empty)} " +
50-
$"{this.AdditionalParams}".Trim();
36+
this.InitializeWindowsClientCommandline();
37+
this.InitializeLinuxClientCommandline();
5138
}
5239

5340
private void InitializeWindowsClientCommandline()
@@ -125,5 +112,79 @@ private void InitializeWindowsClientCommandline()
125112
this.CommandLineWindowsClient = this.CommandLineWindowsClient.Trim();
126113
}
127114

115+
private void InitializeLinuxClientCommandline()
116+
{
117+
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
118+
string clientIPAddress = this.GetLayoutClientInstances(ClientRole.Client).First().IPAddress;
119+
120+
// Ensure base string isn't null.
121+
this.CommandLineLinuxClient ??= string.Empty;
122+
123+
// Normalize: keep a trailing space so appends don't glue together.
124+
if (this.CommandLineLinuxClient.Length > 0 && !char.IsWhiteSpace(this.CommandLineLinuxClient[^1]))
125+
{
126+
this.CommandLineLinuxClient += " ";
127+
}
128+
129+
// -c (client mode)
130+
if (!this.CommandLineLinuxClient.Contains("-c", StringComparison.OrdinalIgnoreCase))
131+
{
132+
this.CommandLineLinuxClient += " -c";
133+
}
134+
135+
// -r {Connections}
136+
// Your reference includes "-c -r {Connections}"
137+
if (!this.CommandLineLinuxClient.Contains("-r", StringComparison.OrdinalIgnoreCase))
138+
{
139+
this.CommandLineLinuxClient += $"-r {this.Connections} ";
140+
}
141+
142+
// Endpoint tuple:
143+
// {clientIPAddress},0,{serverIPAddress},{Port},{ConnectionsPerThread},{MaxPendingRequestsPerThread},{ConnectionDuration},{DataTransferMode}
144+
// Add it only if we don't already see the server IP (good heuristic to avoid duplication).
145+
if (!this.CommandLineLinuxClient.Contains(serverIPAddress, StringComparison.OrdinalIgnoreCase))
146+
{
147+
this.CommandLineLinuxClient +=
148+
$"{clientIPAddress},0,{serverIPAddress},{this.Port},{this.ConnectionsPerThread},{this.MaxPendingRequestsPerThread},{this.ConnectionDuration},{this.DataTransferMode} ";
149+
}
150+
151+
// -i {DisplayInterval}
152+
if (!this.CommandLineLinuxClient.Contains("-i", StringComparison.OrdinalIgnoreCase))
153+
{
154+
this.CommandLineLinuxClient += $"-i {this.DisplayInterval} ";
155+
}
156+
157+
// -wt {WarmupTime.TotalSeconds}
158+
if (!this.CommandLineLinuxClient.Contains("-wt", StringComparison.OrdinalIgnoreCase) && this.WarmupTime != null)
159+
{
160+
this.CommandLineLinuxClient += $"-wt {this.WarmupTime.TotalSeconds} ";
161+
}
162+
163+
// -t {TestDuration.TotalSeconds}
164+
if (!this.CommandLineLinuxClient.Contains("-t", StringComparison.OrdinalIgnoreCase) && this.TestDuration != null)
165+
{
166+
this.CommandLineLinuxClient += $"-t {this.TestDuration.TotalSeconds} ";
167+
}
168+
169+
// Optional: -ds {DelayTime.TotalSeconds} only if DelayTime != 0
170+
if (!this.CommandLineLinuxClient.Contains("-ds", StringComparison.OrdinalIgnoreCase) &&
171+
this.DelayTime != TimeSpan.Zero)
172+
{
173+
this.CommandLineLinuxClient += $"-ds {this.DelayTime.TotalSeconds} ";
174+
}
175+
176+
// Additional params (append once)
177+
if (!string.IsNullOrWhiteSpace(this.AdditionalParams))
178+
{
179+
// Optional: prevent double-appending if already present.
180+
// You can remove this block if AdditionalParams is expected to be dynamic.
181+
if (!this.CommandLineLinuxClient.Contains(this.AdditionalParams, StringComparison.OrdinalIgnoreCase))
182+
{
183+
this.CommandLineLinuxClient += $"{this.AdditionalParams} ";
184+
}
185+
}
186+
187+
this.CommandLineLinuxClient = this.CommandLineLinuxClient.Trim();
188+
}
128189
}
129190
}

src/VirtualClient/VirtualClient.Actions/Network/NetworkingWorkload/CPS/CPSServerExecutor.cs

Lines changed: 124 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,132 @@ public CPSServerExecutor(IServiceCollection dependencies, IDictionary<string, IC
3535
{
3636
}
3737

38-
/// <summary>
39-
/// Returns the CPS client-side command line arguments.
40-
/// </summary>
41-
protected override string GetCommandLineArguments()
38+
private void InitializeLinuxServerCommandline()
39+
{
40+
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
41+
string clientIPAddress = this.GetLayoutClientInstances(ClientRole.Client).First().IPAddress;
42+
43+
// Ensure base string isn't null.
44+
this.CommandLineLinuxServer ??= string.Empty;
45+
46+
// Normalize: keep a trailing space so appends don't glue together.
47+
if (this.CommandLineLinuxServer.Length > 0 && !char.IsWhiteSpace(this.CommandLineLinuxServer[^1]))
48+
{
49+
this.CommandLineLinuxServer += " ";
50+
}
51+
52+
// -c (client mode)
53+
if (!this.CommandLineLinuxServer.Contains("-s", StringComparison.OrdinalIgnoreCase))
54+
{
55+
this.CommandLineLinuxServer += " -s";
56+
}
57+
58+
// -r {Connections}
59+
// Your reference includes "-c -r {Connections}"
60+
if (!this.CommandLineLinuxServer.Contains("-r", StringComparison.OrdinalIgnoreCase))
61+
{
62+
this.CommandLineLinuxServer += $" -r {this.Connections} ";
63+
}
64+
65+
// Endpoint tuple:
66+
// {clientIPAddress},0,{serverIPAddress},{Port},{ConnectionsPerThread},{MaxPendingRequestsPerThread},{ConnectionDuration},{DataTransferMode}
67+
// Add it only if we don't already see the server IP (good heuristic to avoid duplication).
68+
if (!this.CommandLineLinuxServer.Contains(serverIPAddress, StringComparison.OrdinalIgnoreCase))
69+
{
70+
this.CommandLineLinuxServer +=
71+
$"{serverIPAddress},{this.Port} ";
72+
}
73+
74+
// -i {DisplayInterval}
75+
if (!this.CommandLineLinuxServer.Contains("-i", StringComparison.OrdinalIgnoreCase))
76+
{
77+
this.CommandLineLinuxServer += $" -i {this.DisplayInterval} ";
78+
}
79+
80+
// -wt {WarmupTime.TotalSeconds}
81+
if (!this.CommandLineLinuxServer.Contains("-wt", StringComparison.OrdinalIgnoreCase) && this.WarmupTime != null)
82+
{
83+
this.CommandLineLinuxServer += $" -wt {this.WarmupTime.TotalSeconds} ";
84+
}
85+
86+
// -t {TestDuration.TotalSeconds}
87+
if (!this.CommandLineLinuxServer.Contains("-t", StringComparison.OrdinalIgnoreCase) && this.TestDuration != null)
88+
{
89+
this.CommandLineLinuxServer += $" -t {this.TestDuration.TotalSeconds} ";
90+
}
91+
92+
// Optional: -ds {DelayTime.TotalSeconds} only if DelayTime != 0
93+
if (!this.CommandLineLinuxServer.Contains("-ds", StringComparison.OrdinalIgnoreCase) &&
94+
this.DelayTime != TimeSpan.Zero)
95+
{
96+
this.CommandLineLinuxServer += $" -ds {this.DelayTime.TotalSeconds} ";
97+
}
98+
99+
this.CommandLineLinuxServer = this.CommandLineLinuxServer.Trim();
100+
}
101+
102+
private void InitializeWindowsServerCommandline()
42103
{
43104
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
44-
return $"-s -r {this.Connections} {serverIPAddress},{this.Port} -i {this.DisplayInterval} -wt {this.WarmupTime.TotalSeconds} -t {this.TestDuration.TotalSeconds} " +
45-
$"{((this.DelayTime != TimeSpan.Zero) ? $"-ds {this.DelayTime.TotalSeconds}" : string.Empty)} ";
105+
string clientIPAddress = this.GetLayoutClientInstances(ClientRole.Client).First().IPAddress;
106+
107+
// Ensure base string isn't null.
108+
this.CommandLineWindowsServer ??= string.Empty;
109+
110+
// Normalize: keep a trailing space so appends don't glue together.
111+
if (this.CommandLineWindowsServer.Length > 0 && !char.IsWhiteSpace(this.CommandLineWindowsServer[^1]))
112+
{
113+
this.CommandLineWindowsServer += " ";
114+
}
115+
116+
// -c (client mode)
117+
if (!this.CommandLineWindowsServer.Contains("-s", StringComparison.OrdinalIgnoreCase))
118+
{
119+
this.CommandLineWindowsServer += " -s";
120+
}
121+
122+
// -r {Connections}
123+
// Your reference includes "-c -r {Connections}"
124+
if (!this.CommandLineWindowsServer.Contains("-r", StringComparison.OrdinalIgnoreCase))
125+
{
126+
this.CommandLineWindowsServer += $" -r {this.Connections} ";
127+
}
128+
129+
// Endpoint tuple:
130+
// {clientIPAddress},0,{serverIPAddress},{Port},{ConnectionsPerThread},{MaxPendingRequestsPerThread},{ConnectionDuration},{DataTransferMode}
131+
// Add it only if we don't already see the server IP (good heuristic to avoid duplication).
132+
if (!this.CommandLineWindowsServer.Contains(serverIPAddress, StringComparison.OrdinalIgnoreCase))
133+
{
134+
this.CommandLineWindowsServer +=
135+
$"{serverIPAddress},{this.Port} ";
136+
}
137+
138+
// -i {DisplayInterval}
139+
if (!this.CommandLineWindowsServer.Contains("-i", StringComparison.OrdinalIgnoreCase))
140+
{
141+
this.CommandLineWindowsServer += $" -i {this.DisplayInterval} ";
142+
}
143+
144+
// -wt {WarmupTime.TotalSeconds}
145+
if (!this.CommandLineWindowsServer.Contains("-wt", StringComparison.OrdinalIgnoreCase) && this.WarmupTime != null)
146+
{
147+
this.CommandLineWindowsServer += $" -wt {this.WarmupTime.TotalSeconds} ";
148+
}
149+
150+
// -t {TestDuration.TotalSeconds}
151+
if (!this.CommandLineWindowsServer.Contains("-t", StringComparison.OrdinalIgnoreCase) && this.TestDuration != null)
152+
{
153+
this.CommandLineWindowsServer += $" -t {this.TestDuration.TotalSeconds} ";
154+
}
155+
156+
// Optional: -ds {DelayTime.TotalSeconds} only if DelayTime != 0
157+
if (!this.CommandLineWindowsServer.Contains("-ds", StringComparison.OrdinalIgnoreCase) &&
158+
this.DelayTime != TimeSpan.Zero)
159+
{
160+
this.CommandLineWindowsServer += $" -ds {this.DelayTime.TotalSeconds} ";
161+
}
162+
163+
this.CommandLineWindowsServer = this.CommandLineWindowsServer.Trim();
46164
}
47165
}
48166
}

src/VirtualClient/VirtualClient.Actions/Network/NetworkingWorkload/Latte/LatteClientExecutor.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,39 @@ protected override void CaptureMetrics(string results, string commandArguments,
140140
results);
141141
}
142142
}
143+
144+
private void InitializeWindowsClientCommandline()
145+
{
146+
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
147+
148+
this.CommandLineWindowsClient ??= string.Empty;
149+
150+
if (this.CommandLineWindowsClient.Length > 0 && !char.IsWhiteSpace(this.CommandLineWindowsClient[^1]))
151+
{
152+
this.CommandLineWindowsClient += " ";
153+
}
154+
155+
if (!this.CommandLineWindowsClient.Contains("--tcp", StringComparison.OrdinalIgnoreCase))
156+
{
157+
this.CommandLineWindowsClient += this.Protocol.ToLowerInvariant() == "tcp" ? " --tcp" : string.Empty;
158+
}
159+
160+
if (!this.CommandLineWindowsClient.Contains("-i", StringComparison.OrdinalIgnoreCase) && this.Iterations != 0)
161+
{
162+
this.CommandLineWindowsClient += $" -i {this.Iterations} ";
163+
}
164+
165+
if (!this.CommandLineWindowsClient.Contains("-riopoll", StringComparison.OrdinalIgnoreCase) && this.RioPoll != 0)
166+
{
167+
this.CommandLineWindowsClient += $" -riopoll {this.RioPoll}";
168+
}
169+
170+
if (this.Protocol != null && !this.CommandLineWindowsClient.Contains($"-{this.Protocol.ToString().ToLowerInvariant()}"))
171+
{
172+
this.CommandLineWindowsClient += $" -{this.Protocol.ToString().ToLowerInvariant()}";
173+
}
174+
175+
this.CommandLineWindowsClient = this.CommandLineWindowsClient.Trim();
176+
}
143177
}
144178
}

src/VirtualClient/VirtualClient.Actions/Network/NetworkingWorkload/Latte/LatteServerExecutor.cs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,33 @@ await this.ProcessStartRetryPolicy.ExecuteAsync(async () =>
102102
});
103103
}
104104

105-
/// <summary>
106-
/// Produces powershell script parameters using the workload parameters provided.
107-
/// </summary>
108-
/// <returns>Powershell script parameters as a string.</returns>
109-
protected override string GetCommandLineArguments()
105+
private void InitializeWindowsServerCommandline()
110106
{
111107
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
112-
return $"-a {serverIPAddress}:{this.Port} -t {this.TestDuration.TotalSeconds} -rio -riopoll {this.RioPoll} -{this.Protocol.ToLowerInvariant()}";
108+
109+
this.CommandLineWindowsServer ??= string.Empty;
110+
111+
if (this.CommandLineWindowsServer.Length > 0 && !char.IsWhiteSpace(this.CommandLineWindowsServer[^1]))
112+
{
113+
this.CommandLineWindowsServer += " ";
114+
}
115+
116+
if (!this.CommandLineWindowsServer.Contains("-i", StringComparison.OrdinalIgnoreCase) && this.Iterations != 0)
117+
{
118+
this.CommandLineWindowsServer += $" -i {this.Iterations} ";
119+
}
120+
121+
if (!this.CommandLineWindowsServer.Contains("-riopoll", StringComparison.OrdinalIgnoreCase) && this.RioPoll != 0)
122+
{
123+
this.CommandLineWindowsServer += $" -riopoll {this.RioPoll}";
124+
}
125+
126+
if (this.Protocol != null && !this.CommandLineWindowsServer.Contains($"-{this.Protocol.ToString().ToLowerInvariant()}"))
127+
{
128+
this.CommandLineWindowsServer += $" -{this.Protocol.ToString().ToLowerInvariant()}";
129+
}
130+
131+
this.CommandLineWindowsServer = this.CommandLineWindowsServer.Trim();
113132
}
114133
}
115134
}

0 commit comments

Comments
 (0)