Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ public void NTttcpExecutorThrowsOnUnsupportedOS()
}

[Test]
public async Task NTttcpExecutorClientExecutesAsExpected()
[TestCase(null)]
[TestCase(true)]
[TestCase(false)]
public async Task NTttcpExecutorClientExecutesAsExpected(bool? noSyncEnabled)
{
this.SetupTest();

Expand Down Expand Up @@ -118,6 +121,11 @@ public async Task NTttcpExecutorClientExecutesAsExpected()
return process;
};

if (noSyncEnabled.HasValue)
{
this.mockFixture.Parameters["NoSyncEnabled"] = noSyncEnabled.Value;
}

TestNTttcpExecutor component = new TestNTttcpExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);

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

[Test]
[TestCase(null)]
[TestCase(true)]
[TestCase(false)]
public async Task NTttcpExecutorClientExecutesAsExpectedInWindows(bool? noSyncEnabled)
{
this.SetupTest();

NetworkingWorkloadExecutorTests.TestNetworkingWorkloadExecutor networkingWorkloadExecutor = new NetworkingWorkloadExecutorTests.TestNetworkingWorkloadExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
await networkingWorkloadExecutor.OnInitialize.Invoke(EventContext.None, CancellationToken.None);

int processExecuted = 0;
this.mockFixture.ProcessManager.OnCreateProcess = (file, arguments, workingDirectory) =>
{
InMemoryProcess process = new InMemoryProcess()
{
StartInfo = new System.Diagnostics.ProcessStartInfo()
{
FileName = file,
Arguments = arguments,
},
OnHasExited = () => true,
ExitCode = 0,
OnStart = () => true,
StandardOutput = new VirtualClient.Common.ConcurrentBuffer()
};

processExecuted++;
this.networkingWorkloadState.ToolState = NetworkingWorkloadToolState.Stopped;
var expectedStateItem = new Item<NetworkingWorkloadState>(nameof(NetworkingWorkloadState), this.networkingWorkloadState);

this.mockFixture.ApiClient.Setup(client => client.GetStateAsync(It.IsAny<string>(), It.IsAny<CancellationToken>(), It.IsAny<IAsyncPolicy<HttpResponseMessage>>()))
.ReturnsAsync(this.mockFixture.CreateHttpResponse(HttpStatusCode.OK, expectedStateItem));

return process;
};

if (noSyncEnabled.HasValue)
{
this.mockFixture.Parameters["NoSyncEnabled"] = noSyncEnabled.Value;
}

this.mockFixture.SystemManagement.SetupGet(sm => sm.Platform).Returns(PlatformID.Win32NT);

TestNTttcpExecutor component = new TestNTttcpExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);

await component.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);

//Process 1: Ntttcp, Process 2: Sysctl
Assert.AreEqual(1, processExecuted);
}

[Test]
public async Task NTttcpExecutorClientWillNotExitOnCancellationRequestUntilTheResultsAreCaptured()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ public void SetupTest(PlatformID platformID, NetworkingWorkloadTool tool)
}

[Test]
public void NetworkingWorkloadStateInstancesAreJsonSerializable()
[TestCase(null)]
[TestCase(true)]
[TestCase(false)]
public void NetworkingWorkloadStateInstancesAreJsonSerializable(bool? noSyncEnabled)
{
NetworkingWorkloadState state = new NetworkingWorkloadState(
"networking",
Expand Down Expand Up @@ -87,6 +90,7 @@ public void NetworkingWorkloadStateInstancesAreJsonSerializable()
"Profiling_Scenario_1",
"00:00:30",
"00:00:05",
noSyncEnabled,
Guid.NewGuid());

SerializationAssert.IsJsonSerializable(state);
Expand Down Expand Up @@ -122,6 +126,7 @@ public void NetworkingWorkloadStateInstancesAreJsonSerializable_2()
"Profiling_Scenario_1",
"00:00:30",
"00:00:05",
false,
Guid.NewGuid(),
//
// With Metadata
Expand Down Expand Up @@ -169,6 +174,7 @@ public void NetworkingWorkloadStateInstancesAreJsonSerializable_3()
"Profiling_Scenario_1",
"00:00:30",
"00:00:05",
false,
Guid.NewGuid(),
//
// With Metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,19 @@ public string Protocol
}
}

/// <summary>
/// NoSyncEnabled is only for client/sender role.
/// The NoSyncEnabled indicates that synchronization is disabled for the client.
/// </summary>
public bool? NoSyncEnabled
{
get
{
this.Parameters.TryGetValue(nameof(NetworkingWorkloadExecutor.NoSyncEnabled), out IConvertible noSyncEnabled);
return noSyncEnabled?.ToBoolean(CultureInfo.InvariantCulture);
}
}

/// <summary>
/// The retry policy to apply to the startup of the NTttcp workload to handle
/// transient issues.
Expand Down Expand Up @@ -441,6 +454,7 @@ private string GetWindowsSpecificCommandLine()
$"-p {this.Port} " +
$"-xml {this.ResultsPath} " +
$"{(this.Protocol.ToLowerInvariant() == "udp" ? "-u" : string.Empty)} " +
$"{((this.IsInClientRole && this.NoSyncEnabled == true) ? "-ns" : string.Empty)} " +
$"{(this.IsInClientRole ? $"-nic {clientIPAddress}" : string.Empty)}".Trim();
}

Expand All @@ -461,6 +475,7 @@ private string GetLinuxSpecificCommandLine()
$"{((this.IsInServerRole && this.ReceiverMultiClientMode == true) ? "-M" : string.Empty)} " +
$"{((this.IsInClientRole && this.ThreadsPerServerPort != null) ? $"-n {this.ThreadsPerServerPort}" : string.Empty)} " +
$"{((this.IsInClientRole && this.ConnectionsPerThread != null) ? $"-l {this.ConnectionsPerThread}" : string.Empty)} " +
$"{((this.IsInClientRole && this.NoSyncEnabled == true) ? "-N" : string.Empty)} " +
$"{((this.DevInterruptsDifferentiator != null) ? $"--show-dev-interrupts {this.DevInterruptsDifferentiator}" : string.Empty)}".Trim();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,23 @@ public double? ConfidenceLevel
}
}

/// <summary>
/// Parameter indicates that synchronization is disabled for the client.
/// </summary>
public bool? NoSyncEnabled
{
get
{
this.Parameters.TryGetValue(nameof(NetworkingWorkloadExecutor.NoSyncEnabled), out IConvertible noSyncEnabled);
return noSyncEnabled?.ToBoolean(CultureInfo.InvariantCulture);
}

set
{
this.Parameters[nameof(NetworkingWorkloadExecutor.NoSyncEnabled)] = value;
}
}

/// <summary>
/// Cancellation Token Source for Server.
/// </summary>
Expand Down Expand Up @@ -785,6 +802,7 @@ protected void OnInstructionsReceived(object sender, JObject instructions)
this.ProfilingScenario = serverInstructions.ProfilingScenario;
this.ProfilingPeriod = serverInstructions.ProfilingPeriod;
this.ProfilingWarmUpPeriod = serverInstructions.ProfilingWarmUpPeriod;
this.NoSyncEnabled = serverInstructions.NoSyncEnabled;

if (serverInstructions.Metadata?.Any() == true)
{
Expand Down Expand Up @@ -948,6 +966,7 @@ await this.ClientExecutionRetryPolicy.ExecuteAsync(async () =>
this.ProfilingScenario,
this.ProfilingPeriod.ToString(),
this.ProfilingWarmUpPeriod.ToString(),
this.NoSyncEnabled,
requestId);

Item<State> instructions = new Item<State>(nameof(NetworkingWorkloadState), workloadInstructions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public NetworkingWorkloadState(
string profilingScenario = null,
string profilingPeriod = null,
string profilingWarmUpPeriod = null,
bool? noSyncEnabled = null,
Guid? clientRequestId = null,
IDictionary<string, IConvertible> metadata = null)
{
Expand Down Expand Up @@ -163,6 +164,7 @@ public NetworkingWorkloadState(
this.Properties[nameof(this.ProfilingScenario)] = profilingScenario;
this.Properties[nameof(this.ProfilingPeriod)] = profilingPeriod;
this.Properties[nameof(this.ProfilingWarmUpPeriod)] = profilingWarmUpPeriod;
this.Properties[nameof(this.NoSyncEnabled)] = noSyncEnabled;
this.ClientRequestId = clientRequestId;

this.Metadata = new Dictionary<string, IConvertible>(StringComparer.OrdinalIgnoreCase);
Expand Down Expand Up @@ -492,6 +494,18 @@ public string DevInterruptsDifferentiator
}
}

/// <summary>
/// Parameter indicates that synchronization is disabled for the client (Parameter for Tools: NTttcp)
/// </summary>
public bool? NoSyncEnabled
{
get
{
this.Properties.TryGetValue(nameof(this.NoSyncEnabled), out IConvertible noSyncEnabled);
return noSyncEnabled?.ToBoolean(CultureInfo.InvariantCulture);
}
}

/// <summary>
/// Number of Messages-Per-Second (Parameter for Tools: SockPerf).
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public void SetupTest()
[Test]
[TestCase(10)]
[TestCase(100)]
[TestCase(500)]
public async Task VirtualClientControllerComponentSupportsConcurrentSshClientOperations(int concurrentExecutions)
{
List<ISshClientProxy> targetAgents = new List<ISshClientProxy>();
Expand Down
Loading