@@ -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}
0 commit comments