Skip to content

Commit 4200e76

Browse files
Add NoSync parameter to NTTTCP executor (#584)
* Add NoSync parameter to NTTTCP executor * fix ntttcp unit test setup for windows * fix unit test intermittent failures * a better approach to avoid intermittent failures by unit test * removed 500 scenario from unstable unit test by reviewer recommendation. --------- Co-authored-by: Rakesh <153008248+RakeshwarK@users.noreply.github.com>
1 parent 8096859 commit 4200e76

6 files changed

Lines changed: 116 additions & 3 deletions

File tree

src/VirtualClient/VirtualClient.Actions.UnitTests/Network/NTttcp/NTttcpExecutorTests.cs

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ public void NTttcpExecutorThrowsOnUnsupportedOS()
7474
}
7575

7676
[Test]
77-
public async Task NTttcpExecutorClientExecutesAsExpected()
77+
[TestCase(null)]
78+
[TestCase(true)]
79+
[TestCase(false)]
80+
public async Task NTttcpExecutorClientExecutesAsExpected(bool? noSyncEnabled)
7881
{
7982
this.SetupTest();
8083

@@ -118,6 +121,11 @@ public async Task NTttcpExecutorClientExecutesAsExpected()
118121
return process;
119122
};
120123

124+
if (noSyncEnabled.HasValue)
125+
{
126+
this.mockFixture.Parameters["NoSyncEnabled"] = noSyncEnabled.Value;
127+
}
128+
121129
TestNTttcpExecutor component = new TestNTttcpExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
122130

123131
await component.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
@@ -126,6 +134,58 @@ public async Task NTttcpExecutorClientExecutesAsExpected()
126134
Assert.AreEqual(2, processExecuted);
127135
}
128136

137+
[Test]
138+
[TestCase(null)]
139+
[TestCase(true)]
140+
[TestCase(false)]
141+
public async Task NTttcpExecutorClientExecutesAsExpectedInWindows(bool? noSyncEnabled)
142+
{
143+
this.SetupTest();
144+
145+
NetworkingWorkloadExecutorTests.TestNetworkingWorkloadExecutor networkingWorkloadExecutor = new NetworkingWorkloadExecutorTests.TestNetworkingWorkloadExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
146+
await networkingWorkloadExecutor.OnInitialize.Invoke(EventContext.None, CancellationToken.None);
147+
148+
int processExecuted = 0;
149+
this.mockFixture.ProcessManager.OnCreateProcess = (file, arguments, workingDirectory) =>
150+
{
151+
InMemoryProcess process = new InMemoryProcess()
152+
{
153+
StartInfo = new System.Diagnostics.ProcessStartInfo()
154+
{
155+
FileName = file,
156+
Arguments = arguments,
157+
},
158+
OnHasExited = () => true,
159+
ExitCode = 0,
160+
OnStart = () => true,
161+
StandardOutput = new VirtualClient.Common.ConcurrentBuffer()
162+
};
163+
164+
processExecuted++;
165+
this.networkingWorkloadState.ToolState = NetworkingWorkloadToolState.Stopped;
166+
var expectedStateItem = new Item<NetworkingWorkloadState>(nameof(NetworkingWorkloadState), this.networkingWorkloadState);
167+
168+
this.mockFixture.ApiClient.Setup(client => client.GetStateAsync(It.IsAny<string>(), It.IsAny<CancellationToken>(), It.IsAny<IAsyncPolicy<HttpResponseMessage>>()))
169+
.ReturnsAsync(this.mockFixture.CreateHttpResponse(HttpStatusCode.OK, expectedStateItem));
170+
171+
return process;
172+
};
173+
174+
if (noSyncEnabled.HasValue)
175+
{
176+
this.mockFixture.Parameters["NoSyncEnabled"] = noSyncEnabled.Value;
177+
}
178+
179+
this.mockFixture.SystemManagement.SetupGet(sm => sm.Platform).Returns(PlatformID.Win32NT);
180+
181+
TestNTttcpExecutor component = new TestNTttcpExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
182+
183+
await component.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
184+
185+
//Process 1: Ntttcp, Process 2: Sysctl
186+
Assert.AreEqual(1, processExecuted);
187+
}
188+
129189
[Test]
130190
public async Task NTttcpExecutorClientWillNotExitOnCancellationRequestUntilTheResultsAreCaptured()
131191
{

src/VirtualClient/VirtualClient.Actions.UnitTests/Network/NetworkingWorkloadExecutorTests.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ public void SetupTest(PlatformID platformID, NetworkingWorkloadTool tool)
5858
}
5959

6060
[Test]
61-
public void NetworkingWorkloadStateInstancesAreJsonSerializable()
61+
[TestCase(null)]
62+
[TestCase(true)]
63+
[TestCase(false)]
64+
public void NetworkingWorkloadStateInstancesAreJsonSerializable(bool? noSyncEnabled)
6265
{
6366
NetworkingWorkloadState state = new NetworkingWorkloadState(
6467
"networking",
@@ -87,6 +90,7 @@ public void NetworkingWorkloadStateInstancesAreJsonSerializable()
8790
"Profiling_Scenario_1",
8891
"00:00:30",
8992
"00:00:05",
93+
noSyncEnabled,
9094
Guid.NewGuid());
9195

9296
SerializationAssert.IsJsonSerializable(state);
@@ -122,6 +126,7 @@ public void NetworkingWorkloadStateInstancesAreJsonSerializable_2()
122126
"Profiling_Scenario_1",
123127
"00:00:30",
124128
"00:00:05",
129+
false,
125130
Guid.NewGuid(),
126131
//
127132
// With Metadata
@@ -169,6 +174,7 @@ public void NetworkingWorkloadStateInstancesAreJsonSerializable_3()
169174
"Profiling_Scenario_1",
170175
"00:00:30",
171176
"00:00:05",
177+
false,
172178
Guid.NewGuid(),
173179
//
174180
// With Metadata

src/VirtualClient/VirtualClient.Actions/Network/NetworkingWorkload/NTttcp/NTttcpExecutor.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,19 @@ public string Protocol
185185
}
186186
}
187187

188+
/// <summary>
189+
/// NoSyncEnabled is only for client/sender role.
190+
/// The NoSyncEnabled indicates that synchronization is disabled for the client.
191+
/// </summary>
192+
public bool? NoSyncEnabled
193+
{
194+
get
195+
{
196+
this.Parameters.TryGetValue(nameof(NetworkingWorkloadExecutor.NoSyncEnabled), out IConvertible noSyncEnabled);
197+
return noSyncEnabled?.ToBoolean(CultureInfo.InvariantCulture);
198+
}
199+
}
200+
188201
/// <summary>
189202
/// The retry policy to apply to the startup of the NTttcp workload to handle
190203
/// transient issues.
@@ -441,6 +454,7 @@ private string GetWindowsSpecificCommandLine()
441454
$"-p {this.Port} " +
442455
$"-xml {this.ResultsPath} " +
443456
$"{(this.Protocol.ToLowerInvariant() == "udp" ? "-u" : string.Empty)} " +
457+
$"{((this.IsInClientRole && this.NoSyncEnabled == true) ? "-ns" : string.Empty)} " +
444458
$"{(this.IsInClientRole ? $"-nic {clientIPAddress}" : string.Empty)}".Trim();
445459
}
446460

@@ -461,6 +475,7 @@ private string GetLinuxSpecificCommandLine()
461475
$"{((this.IsInServerRole && this.ReceiverMultiClientMode == true) ? "-M" : string.Empty)} " +
462476
$"{((this.IsInClientRole && this.ThreadsPerServerPort != null) ? $"-n {this.ThreadsPerServerPort}" : string.Empty)} " +
463477
$"{((this.IsInClientRole && this.ConnectionsPerThread != null) ? $"-l {this.ConnectionsPerThread}" : string.Empty)} " +
478+
$"{((this.IsInClientRole && this.NoSyncEnabled == true) ? "-N" : string.Empty)} " +
464479
$"{((this.DevInterruptsDifferentiator != null) ? $"--show-dev-interrupts {this.DevInterruptsDifferentiator}" : string.Empty)}".Trim();
465480
}
466481
}

src/VirtualClient/VirtualClient.Actions/Network/NetworkingWorkload/NetworkingWorkloadExecutor.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,23 @@ public double? ConfidenceLevel
399399
}
400400
}
401401

402+
/// <summary>
403+
/// Parameter indicates that synchronization is disabled for the client.
404+
/// </summary>
405+
public bool? NoSyncEnabled
406+
{
407+
get
408+
{
409+
this.Parameters.TryGetValue(nameof(NetworkingWorkloadExecutor.NoSyncEnabled), out IConvertible noSyncEnabled);
410+
return noSyncEnabled?.ToBoolean(CultureInfo.InvariantCulture);
411+
}
412+
413+
set
414+
{
415+
this.Parameters[nameof(NetworkingWorkloadExecutor.NoSyncEnabled)] = value;
416+
}
417+
}
418+
402419
/// <summary>
403420
/// Cancellation Token Source for Server.
404421
/// </summary>
@@ -785,6 +802,7 @@ protected void OnInstructionsReceived(object sender, JObject instructions)
785802
this.ProfilingScenario = serverInstructions.ProfilingScenario;
786803
this.ProfilingPeriod = serverInstructions.ProfilingPeriod;
787804
this.ProfilingWarmUpPeriod = serverInstructions.ProfilingWarmUpPeriod;
805+
this.NoSyncEnabled = serverInstructions.NoSyncEnabled;
788806

789807
if (serverInstructions.Metadata?.Any() == true)
790808
{
@@ -948,6 +966,7 @@ await this.ClientExecutionRetryPolicy.ExecuteAsync(async () =>
948966
this.ProfilingScenario,
949967
this.ProfilingPeriod.ToString(),
950968
this.ProfilingWarmUpPeriod.ToString(),
969+
this.NoSyncEnabled,
951970
requestId);
952971

953972
Item<State> instructions = new Item<State>(nameof(NetworkingWorkloadState), workloadInstructions);

src/VirtualClient/VirtualClient.Actions/Network/NetworkingWorkload/NetworkingWorkloadState.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public NetworkingWorkloadState(
129129
string profilingScenario = null,
130130
string profilingPeriod = null,
131131
string profilingWarmUpPeriod = null,
132+
bool? noSyncEnabled = null,
132133
Guid? clientRequestId = null,
133134
IDictionary<string, IConvertible> metadata = null)
134135
{
@@ -163,6 +164,7 @@ public NetworkingWorkloadState(
163164
this.Properties[nameof(this.ProfilingScenario)] = profilingScenario;
164165
this.Properties[nameof(this.ProfilingPeriod)] = profilingPeriod;
165166
this.Properties[nameof(this.ProfilingWarmUpPeriod)] = profilingWarmUpPeriod;
167+
this.Properties[nameof(this.NoSyncEnabled)] = noSyncEnabled;
166168
this.ClientRequestId = clientRequestId;
167169

168170
this.Metadata = new Dictionary<string, IConvertible>(StringComparer.OrdinalIgnoreCase);
@@ -492,6 +494,18 @@ public string DevInterruptsDifferentiator
492494
}
493495
}
494496

497+
/// <summary>
498+
/// Parameter indicates that synchronization is disabled for the client (Parameter for Tools: NTttcp)
499+
/// </summary>
500+
public bool? NoSyncEnabled
501+
{
502+
get
503+
{
504+
this.Properties.TryGetValue(nameof(this.NoSyncEnabled), out IConvertible noSyncEnabled);
505+
return noSyncEnabled?.ToBoolean(CultureInfo.InvariantCulture);
506+
}
507+
}
508+
495509
/// <summary>
496510
/// Number of Messages-Per-Second (Parameter for Tools: SockPerf).
497511
/// </summary>

src/VirtualClient/VirtualClient.Controller.UnitTests/VirtualClientControllerComponentTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public void SetupTest()
3030
[Test]
3131
[TestCase(10)]
3232
[TestCase(100)]
33-
[TestCase(500)]
3433
public async Task VirtualClientControllerComponentSupportsConcurrentSshClientOperations(int concurrentExecutions)
3534
{
3635
List<ISshClientProxy> targetAgents = new List<ISshClientProxy>();

0 commit comments

Comments
 (0)