Skip to content

Commit 2b4ade4

Browse files
committed
Adding CPS command line
1 parent 5666e0c commit 2b4ade4

3 files changed

Lines changed: 429 additions & 15 deletions

File tree

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,81 @@ protected override string GetCommandLineArguments()
4747
$"{((this.DelayTime != TimeSpan.Zero) ? $"-ds {this.DelayTime.TotalSeconds}" : string.Empty)} " +
4848
$"{this.AdditionalParams}".Trim();
4949
}
50+
51+
private void InitializeWindowsClientCommandline()
52+
{
53+
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
54+
string clientIPAddress = this.GetLayoutClientInstances(ClientRole.Client).First().IPAddress;
55+
56+
// Ensure base string isn't null.
57+
this.CommandLineWindowsClient ??= string.Empty;
58+
59+
// Normalize: keep a trailing space so appends don't glue together.
60+
if (this.CommandLineWindowsClient.Length > 0 && !char.IsWhiteSpace(this.CommandLineWindowsClient[^1]))
61+
{
62+
this.CommandLineWindowsClient += " ";
63+
}
64+
65+
// -c (client mode)
66+
if (!this.CommandLineWindowsClient.Contains("-c", StringComparison.OrdinalIgnoreCase))
67+
{
68+
this.CommandLineWindowsClient += "-c ";
69+
}
70+
71+
// -r {Connections}
72+
// Your reference includes "-c -r {Connections}"
73+
if (!this.CommandLineWindowsClient.Contains("-r", StringComparison.OrdinalIgnoreCase) && this.Connections != null)
74+
{
75+
this.CommandLineWindowsClient += $"-r {this.Connections} ";
76+
}
77+
78+
// Endpoint tuple:
79+
// {clientIPAddress},0,{serverIPAddress},{Port},{ConnectionsPerThread},{MaxPendingRequestsPerThread},{ConnectionDuration},{DataTransferMode}
80+
// Add it only if we don't already see the server IP (good heuristic to avoid duplication).
81+
if (!this.CommandLineWindowsClient.Contains(serverIPAddress, StringComparison.OrdinalIgnoreCase))
82+
{
83+
this.CommandLineWindowsClient +=
84+
$"{clientIPAddress},0,{serverIPAddress},{this.Port},{this.ConnectionsPerThread},{this.MaxPendingRequestsPerThread},{this.ConnectionDuration},{this.DataTransferMode} ";
85+
}
86+
87+
// -i {DisplayInterval}
88+
if (!this.CommandLineWindowsClient.Contains("-i", StringComparison.OrdinalIgnoreCase) && this.DisplayInterval != null)
89+
{
90+
this.CommandLineWindowsClient += $"-i {this.DisplayInterval} ";
91+
}
92+
93+
// -wt {WarmupTime.TotalSeconds}
94+
if (!this.CommandLineWindowsClient.Contains("-wt", StringComparison.OrdinalIgnoreCase) && this.WarmupTime != null)
95+
{
96+
this.CommandLineWindowsClient += $"-wt {this.WarmupTime.TotalSeconds} ";
97+
}
98+
99+
// -t {TestDuration.TotalSeconds}
100+
if (!this.CommandLineWindowsClient.Contains("-t", StringComparison.OrdinalIgnoreCase) && this.TestDuration != null)
101+
{
102+
this.CommandLineWindowsClient += $"-t {this.TestDuration.TotalSeconds} ";
103+
}
104+
105+
// Optional: -ds {DelayTime.TotalSeconds} only if DelayTime != 0
106+
if (!this.CommandLineWindowsClient.Contains("-ds", StringComparison.OrdinalIgnoreCase) &&
107+
this.DelayTime != TimeSpan.Zero)
108+
{
109+
this.CommandLineWindowsClient += $"-ds {this.DelayTime.TotalSeconds} ";
110+
}
111+
112+
// Additional params (append once)
113+
if (!string.IsNullOrWhiteSpace(this.AdditionalParams))
114+
{
115+
// Optional: prevent double-appending if already present.
116+
// You can remove this block if AdditionalParams is expected to be dynamic.
117+
if (!this.CommandLineWindowsClient.Contains(this.AdditionalParams, StringComparison.OrdinalIgnoreCase))
118+
{
119+
this.CommandLineWindowsClient += $"{this.AdditionalParams} ";
120+
}
121+
}
122+
123+
this.CommandLineWindowsClient = this.CommandLineWindowsClient.Trim();
124+
}
125+
50126
}
51127
}

0 commit comments

Comments
 (0)