Skip to content
Open
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
@@ -0,0 +1,49 @@
T(sec) N Pend Failed IOFail Conn/s Close/s RXkbyte/s TXkbyte/s RT/i c0/i c0rtt/i cR/i cRrtt/i
1.001 0 1600 0 0 24152.0 22552.0 24151.0 24153.0 0 24152 10543 0 0
2.001 0 1600 0 0 32069.0 32069.0 32069.0 32069.0 0 32069 9567 0 0
3.002 10 1590 0 0 30695.7 30685.7 30695.7 30695.7 0 30695 8778 0 0
4.002 4 1596 0 0 29827.0 29833.0 29827.0 29828.0 0 29827 8967 0 0
5.003 6 1594 0 0 28873.6 28873.6 28873.6 28873.6 0 28873 10034 0 0
6.003 8 1592 0 0 27841.0 27839.0 27841.0 27841.0 0 27841 9456 0 0
7.003 7 1593 0 0 26934.0 26935.0 26934.0 26934.0 0 26934 10234 0 0
8.003 0 1600 0 0 26123.0 26130.0 26123.0 26123.0 0 26123 11234 0 0
9.003 5 1595 0 0 25389.0 25384.0 25389.0 25389.0 0 25389 11875 0 0
10.004 0 1600 0 0 24720.9 24725.9 24720.9 24720.9 0 24720 13132 0 0

=== CMDLINE: ./ncps -c 10.1.0.5 -r 16 -bp 9800 -np 16 -N 1600 -P 1600 -D 0 -M 1 -i 1 -wt 30 -t 330

=== VERSION 1.0

###RXGBPS 0.65
###TXGBPS 0.65

=== Time (ms) to Nth connection establishment for first 1250000 connections:
=== N T(ms) CPS
=== 100000 3925 25477
=== 200000 7901 25316
=== 300000 11932 25142
=== 400000 15987 25021
=== 500000 20062 24922
=== 600000 24161 24828
=== 700000 28262 24775
=== 800000 32401 24690
=== 900000 36541 24631
=== 1000000 40707 24566
=== 1100000 44883 24509
=== 1200000 49081 24448
=== 1250000 51188 24416

###ENDCPS 24416

###CPS,100000:3925,200000:7901,300000:11932,400000:15987,500000:20062,600000:24161,700000:28262,800000:32401,900000:36541,1000000:40707,1100000:44883,1200000:49081,1250000:51188

=== SYN RTT (us) stats for first 1250000 connections:
=== P25 Median Mean P75 P90 P95 P99 P99.9 P99.99
=== 3424 6221 18737 10893 17628 24607 54222 2027000 4057000

###SYNRTT,25:3424,Median:6221,Mean:18737,75:10893,90:17628,95:24607,99:54222,99.9:2027000,99.99:4057000

=== Percentage of connections with retransmits in the first 1250000 connections: 3.2825%
=== Average retransmit count per connection (excluding 0-retransmit cases): 1.1436

###REXMIT,rtconnpercentage:3.2825,rtperconn:1.1436
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
T(sec) N Pend Failed IOFail Conn/s Close/s RXkbyte/s TXkbyte/s RT/i c0/i c0rtt/i cR/i cRrtt/i
1.002 7 1593 0 0 69065.9 69058.9 69062.9 69065.9 0 69204 12888 0 0
2.002 14 1586 0 0 69987.0 69980.0 69978.0 69984.0 606 69381 12962 606 161224
3.002 0 1600 0 0 67533.0 67547.0 67545.0 67536.0 618 66915 11499 618 434771
4.002 8 1592 0 0 66157.0 66149.0 66149.0 66157.0 925 65332 12544 825 407273
5.002 12 1588 0 0 64957.0 64953.0 64953.0 64956.0 711 64301 13859 656 524382
6.003 23 1577 0 0 63437.6 63426.6 63430.6 63431.6 669 62916 14764 585 537452
7.003 3 1597 0 0 54750.0 54770.0 54766.0 54757.0 727 54029 9112 721 419237
8.003 6 1594 0 0 56852.0 56849.0 56849.0 56852.0 857 56003 10083 849 426095
9.003 2 1598 0 0 55323.0 55327.0 55328.0 55322.0 1143 54181 9149 1142 261028
10.003 0 1600 0 0 56011.0 56013.0 56012.0 56012.0 1197 54848 9935 1163 237388

=== CMDLINE: ./ncps -s -r 16 -bp 9800 -np 16 -t 300

=== VERSION 1.4

###RXGBPS 0.24
###TXGBPS 0.24

=== Time (ms) to Nth connection establishment for first 556947 connections:
=== N T(ms) CPS
=== 100000 1678 59594
=== 200000 3467 57686
=== 300000 5248 57164
=== 400000 7093 56393
=== 500000 8919 56060
=== 556947 10002 55683

###ENDCPS 55683

###CPS,100000:1678,200000:3467,300000:5248,400000:7093,500000:8919,556947:10002

=== SYN RTT (us) stats for first 556947 connections:
=== P25 Median Mean P75 P90 P95 P99 P99.9 P99.99
=== 2342 4441 15996 13249 24443 38198 79657 1038000 1057000

###SYNRTT,25:2342,Median:4441,Mean:15996,75:13249,90:24443,95:38198,99:79657,99.9:1038000,99.99:1057000

=== Percentage of connections with retransmits in the first 556947 connections: 1.7278%
=== Average retransmit count per connection (excluding 0-retransmit cases): 1.0138

###REXMIT,rtconnpercentage:1.7278,rtperconn:1.0138
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace VirtualClient.Actions
{
using Microsoft.Extensions.DependencyInjection;
using Moq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using VirtualClient.Actions.NetworkPerformance;
using VirtualClient.Contracts;
using Polly;
using System.Net.Http;
using System.Net;
using System.IO;
using System.Reflection;
using VirtualClient.Common.Telemetry;
using VirtualClient.Common.Contracts;

[TestFixture]
[Category("Unit")]
public class NCPSClientExecutorTests
{
private MockFixture mockFixture;
private DependencyPath mockPath;
private NetworkingWorkloadState networkingWorkloadState;

[SetUp]
public void SetupTest()
{
this.mockFixture = new MockFixture();
this.mockPath = new DependencyPath("NetworkingWorkload", this.mockFixture.PlatformSpecifics.GetPackagePath("networkingworkload"));
this.mockFixture.PackageManager.OnGetPackage().ReturnsAsync(this.mockPath);

this.mockFixture.Directory.Setup(d => d.Exists(It.IsAny<string>()))
.Returns(true);

this.mockFixture.File.Setup(f => f.Exists(It.IsAny<string>()))
.Returns(true);

this.mockFixture.Parameters["PackageName"] = "Networking";
this.mockFixture.Parameters["ThreadCount"] = "16";
this.mockFixture.Parameters["TestDuration"] = "00:05:00";
this.mockFixture.Parameters["WarmupTime"] = "00:00:30";
this.mockFixture.Parameters["Delaytime"] = "00:00:00";
this.mockFixture.Parameters["ConfidenceLevel"] = "99";

string currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string resultsPath = Path.Combine(currentDirectory, "Examples", "NCPS", "NCPS_Example_Results_Server.txt");
string results = File.ReadAllText(resultsPath);

this.mockFixture.Process.StandardOutput.Append(results);

this.mockFixture.FileSystem.Setup(rt => rt.File.ReadAllTextAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(results);

this.SetupNetworkingWorkloadState();
}

[Test]
public void NCPSClientExecutorThrowsOnUnsupportedOS()
{
this.mockFixture.SystemManagement.SetupGet(sm => sm.Platform).Returns(PlatformID.Other);
TestNCPSClientExecutor component = new TestNCPSClientExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);

Assert.ThrowsAsync<NotSupportedException>(() => component.ExecuteAsync(CancellationToken.None));
}

[Test]
public async Task NCPSClientExecutorExecutesAsExpected()
{
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) =>
{
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 this.mockFixture.Process;
};

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

await component.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
Assert.AreEqual(1, processExecuted);
}

[Test]
public async Task NCPSClientExecutorExecutesAsExpectedWithIntegerTimeParameters()
{
this.mockFixture.Parameters["TestDuration"] = 120;
this.mockFixture.Parameters["WarmupTime"] = 30;
this.mockFixture.Parameters["Delaytime"] = 15;

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) =>
{
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 this.mockFixture.Process;
};

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

Assert.AreEqual(TimeSpan.FromSeconds(120), component.TestDuration);
Assert.AreEqual(TimeSpan.FromSeconds(30), component.WarmupTime);
Assert.AreEqual(TimeSpan.FromSeconds(15), component.DelayTime);

await component.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
Assert.AreEqual(1, processExecuted);
}

[Test]
public void NCPSClientExecutorSupportsIntegerAndTimeSpanTimeFormats()
{
this.mockFixture.Parameters["TestDuration"] = 300;
this.mockFixture.Parameters["WarmupTime"] = 60;
this.mockFixture.Parameters["Delaytime"] = 30;

TestNCPSClientExecutor executor = new TestNCPSClientExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);

Assert.AreEqual(TimeSpan.FromSeconds(300), executor.TestDuration);
Assert.AreEqual(TimeSpan.FromSeconds(60), executor.WarmupTime);
Assert.AreEqual(TimeSpan.FromSeconds(30), executor.DelayTime);

this.mockFixture.Parameters["TestDuration"] = "00:05:00";
this.mockFixture.Parameters["WarmupTime"] = "00:01:00";
this.mockFixture.Parameters["Delaytime"] = "00:00:30";

executor = new TestNCPSClientExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);

Assert.AreEqual(TimeSpan.FromMinutes(5), executor.TestDuration);
Assert.AreEqual(TimeSpan.FromMinutes(1), executor.WarmupTime);
Assert.AreEqual(TimeSpan.FromSeconds(30), executor.DelayTime);

this.mockFixture.Parameters["TestDuration"] = 180;
executor = new TestNCPSClientExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
TimeSpan integerBasedDuration = executor.TestDuration;

this.mockFixture.Parameters["TestDuration"] = "00:03:00";
executor = new TestNCPSClientExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
TimeSpan timespanBasedDuration = executor.TestDuration;

Assert.AreEqual(integerBasedDuration, timespanBasedDuration);
}

private void SetupNetworkingWorkloadState()
{
this.networkingWorkloadState = new NetworkingWorkloadState();
this.networkingWorkloadState.Scenario = "AnyScenario";
this.networkingWorkloadState.Tool = NetworkingWorkloadTool.NCPS;
this.networkingWorkloadState.ToolState = NetworkingWorkloadToolState.Running;
this.networkingWorkloadState.Protocol = "TCP";
this.networkingWorkloadState.TestMode = "MockTestMode";

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));
}

private class TestNCPSClientExecutor : NCPSClientExecutor
{
public TestNCPSClientExecutor(IServiceCollection dependencies, IDictionary<string, IConvertible> parameters)
: base(dependencies, parameters)
{
}
}
}
}
Loading
Loading