Skip to content

Commit 85a3c8a

Browse files
RakeshwarKRakeshwar Reddy Kambaiahgari
andauthored
Onboarding NCPS workload as CPS is being deprecated. (#625)
* Init Commit * Commit Changes * Update Docs * Update pkg ref * Update Tests * Addressing comments. * Format Profile. --------- Co-authored-by: Rakeshwar Reddy Kambaiahgari <rkambaiahgar@microsoft.com>
1 parent 1364dbf commit 85a3c8a

15 files changed

Lines changed: 1929 additions & 357 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
T(sec) N Pend Failed IOFail Conn/s Close/s RXkbyte/s TXkbyte/s RT/i c0/i c0rtt/i cR/i cRrtt/i
2+
1.001 0 1600 0 0 24152.0 22552.0 24151.0 24153.0 0 24152 10543 0 0
3+
2.001 0 1600 0 0 32069.0 32069.0 32069.0 32069.0 0 32069 9567 0 0
4+
3.002 10 1590 0 0 30695.7 30685.7 30695.7 30695.7 0 30695 8778 0 0
5+
4.002 4 1596 0 0 29827.0 29833.0 29827.0 29828.0 0 29827 8967 0 0
6+
5.003 6 1594 0 0 28873.6 28873.6 28873.6 28873.6 0 28873 10034 0 0
7+
6.003 8 1592 0 0 27841.0 27839.0 27841.0 27841.0 0 27841 9456 0 0
8+
7.003 7 1593 0 0 26934.0 26935.0 26934.0 26934.0 0 26934 10234 0 0
9+
8.003 0 1600 0 0 26123.0 26130.0 26123.0 26123.0 0 26123 11234 0 0
10+
9.003 5 1595 0 0 25389.0 25384.0 25389.0 25389.0 0 25389 11875 0 0
11+
10.004 0 1600 0 0 24720.9 24725.9 24720.9 24720.9 0 24720 13132 0 0
12+
13+
=== 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
14+
15+
=== VERSION 1.0
16+
17+
###RXGBPS 0.65
18+
###TXGBPS 0.65
19+
20+
=== Time (ms) to Nth connection establishment for first 1250000 connections:
21+
=== N T(ms) CPS
22+
=== 100000 3925 25477
23+
=== 200000 7901 25316
24+
=== 300000 11932 25142
25+
=== 400000 15987 25021
26+
=== 500000 20062 24922
27+
=== 600000 24161 24828
28+
=== 700000 28262 24775
29+
=== 800000 32401 24690
30+
=== 900000 36541 24631
31+
=== 1000000 40707 24566
32+
=== 1100000 44883 24509
33+
=== 1200000 49081 24448
34+
=== 1250000 51188 24416
35+
36+
###ENDCPS 24416
37+
38+
###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
39+
40+
=== SYN RTT (us) stats for first 1250000 connections:
41+
=== P25 Median Mean P75 P90 P95 P99 P99.9 P99.99
42+
=== 3424 6221 18737 10893 17628 24607 54222 2027000 4057000
43+
44+
###SYNRTT,25:3424,Median:6221,Mean:18737,75:10893,90:17628,95:24607,99:54222,99.9:2027000,99.99:4057000
45+
46+
=== Percentage of connections with retransmits in the first 1250000 connections: 3.2825%
47+
=== Average retransmit count per connection (excluding 0-retransmit cases): 1.1436
48+
49+
###REXMIT,rtconnpercentage:3.2825,rtperconn:1.1436
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
T(sec) N Pend Failed IOFail Conn/s Close/s RXkbyte/s TXkbyte/s RT/i c0/i c0rtt/i cR/i cRrtt/i
2+
1.002 7 1593 0 0 69065.9 69058.9 69062.9 69065.9 0 69204 12888 0 0
3+
2.002 14 1586 0 0 69987.0 69980.0 69978.0 69984.0 606 69381 12962 606 161224
4+
3.002 0 1600 0 0 67533.0 67547.0 67545.0 67536.0 618 66915 11499 618 434771
5+
4.002 8 1592 0 0 66157.0 66149.0 66149.0 66157.0 925 65332 12544 825 407273
6+
5.002 12 1588 0 0 64957.0 64953.0 64953.0 64956.0 711 64301 13859 656 524382
7+
6.003 23 1577 0 0 63437.6 63426.6 63430.6 63431.6 669 62916 14764 585 537452
8+
7.003 3 1597 0 0 54750.0 54770.0 54766.0 54757.0 727 54029 9112 721 419237
9+
8.003 6 1594 0 0 56852.0 56849.0 56849.0 56852.0 857 56003 10083 849 426095
10+
9.003 2 1598 0 0 55323.0 55327.0 55328.0 55322.0 1143 54181 9149 1142 261028
11+
10.003 0 1600 0 0 56011.0 56013.0 56012.0 56012.0 1197 54848 9935 1163 237388
12+
13+
=== CMDLINE: ./ncps -s -r 16 -bp 9800 -np 16 -t 300
14+
15+
=== VERSION 1.4
16+
17+
###RXGBPS 0.24
18+
###TXGBPS 0.24
19+
20+
=== Time (ms) to Nth connection establishment for first 556947 connections:
21+
=== N T(ms) CPS
22+
=== 100000 1678 59594
23+
=== 200000 3467 57686
24+
=== 300000 5248 57164
25+
=== 400000 7093 56393
26+
=== 500000 8919 56060
27+
=== 556947 10002 55683
28+
29+
###ENDCPS 55683
30+
31+
###CPS,100000:1678,200000:3467,300000:5248,400000:7093,500000:8919,556947:10002
32+
33+
=== SYN RTT (us) stats for first 556947 connections:
34+
=== P25 Median Mean P75 P90 P95 P99 P99.9 P99.99
35+
=== 2342 4441 15996 13249 24443 38198 79657 1038000 1057000
36+
37+
###SYNRTT,25:2342,Median:4441,Mean:15996,75:13249,90:24443,95:38198,99:79657,99.9:1038000,99.99:1057000
38+
39+
=== Percentage of connections with retransmits in the first 556947 connections: 1.7278%
40+
=== Average retransmit count per connection (excluding 0-retransmit cases): 1.0138
41+
42+
###REXMIT,rtconnpercentage:1.7278,rtperconn:1.0138
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
namespace VirtualClient.Actions
5+
{
6+
using Microsoft.Extensions.DependencyInjection;
7+
using Moq;
8+
using NUnit.Framework;
9+
using System;
10+
using System.Collections.Generic;
11+
using System.Threading;
12+
using System.Threading.Tasks;
13+
using VirtualClient.Actions.NetworkPerformance;
14+
using VirtualClient.Contracts;
15+
using Polly;
16+
using System.Net.Http;
17+
using System.Net;
18+
using System.IO;
19+
using System.Reflection;
20+
using VirtualClient.Common.Telemetry;
21+
using VirtualClient.Common.Contracts;
22+
23+
[TestFixture]
24+
[Category("Unit")]
25+
public class NCPSClientExecutorTests
26+
{
27+
private MockFixture mockFixture;
28+
private DependencyPath mockPath;
29+
private NetworkingWorkloadState networkingWorkloadState;
30+
31+
[SetUp]
32+
public void SetupTest()
33+
{
34+
this.mockFixture = new MockFixture();
35+
this.mockPath = new DependencyPath("NetworkingWorkload", this.mockFixture.PlatformSpecifics.GetPackagePath("networkingworkload"));
36+
this.mockFixture.PackageManager.OnGetPackage().ReturnsAsync(this.mockPath);
37+
38+
this.mockFixture.Directory.Setup(d => d.Exists(It.IsAny<string>()))
39+
.Returns(true);
40+
41+
this.mockFixture.File.Setup(f => f.Exists(It.IsAny<string>()))
42+
.Returns(true);
43+
44+
this.mockFixture.Parameters["PackageName"] = "Networking";
45+
this.mockFixture.Parameters["ThreadCount"] = "16";
46+
this.mockFixture.Parameters["TestDuration"] = "00:05:00";
47+
this.mockFixture.Parameters["WarmupTime"] = "00:00:30";
48+
this.mockFixture.Parameters["Delaytime"] = "00:00:00";
49+
this.mockFixture.Parameters["ConfidenceLevel"] = "99";
50+
51+
string currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
52+
string resultsPath = Path.Combine(currentDirectory, "Examples", "NCPS", "NCPS_Example_Results_Server.txt");
53+
string results = File.ReadAllText(resultsPath);
54+
55+
this.mockFixture.Process.StandardOutput.Append(results);
56+
57+
this.mockFixture.FileSystem.Setup(rt => rt.File.ReadAllTextAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()))
58+
.ReturnsAsync(results);
59+
60+
this.SetupNetworkingWorkloadState();
61+
}
62+
63+
[Test]
64+
public void NCPSClientExecutorThrowsOnUnsupportedOS()
65+
{
66+
this.mockFixture.SystemManagement.SetupGet(sm => sm.Platform).Returns(PlatformID.Other);
67+
TestNCPSClientExecutor component = new TestNCPSClientExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
68+
69+
Assert.ThrowsAsync<NotSupportedException>(() => component.ExecuteAsync(CancellationToken.None));
70+
}
71+
72+
[Test]
73+
public async Task NCPSClientExecutorExecutesAsExpected()
74+
{
75+
NetworkingWorkloadExecutorTests.TestNetworkingWorkloadExecutor networkingWorkloadExecutor = new NetworkingWorkloadExecutorTests.TestNetworkingWorkloadExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
76+
await networkingWorkloadExecutor.OnInitialize.Invoke(EventContext.None, CancellationToken.None);
77+
78+
int processExecuted = 0;
79+
this.mockFixture.ProcessManager.OnCreateProcess = (file, arguments, workingDirectory) =>
80+
{
81+
processExecuted++;
82+
this.networkingWorkloadState.ToolState = NetworkingWorkloadToolState.Stopped;
83+
var expectedStateItem = new Item<NetworkingWorkloadState>(nameof(NetworkingWorkloadState), this.networkingWorkloadState);
84+
85+
this.mockFixture.ApiClient.Setup(client => client.GetStateAsync(It.IsAny<string>(), It.IsAny<CancellationToken>(), It.IsAny<IAsyncPolicy<HttpResponseMessage>>()))
86+
.ReturnsAsync(this.mockFixture.CreateHttpResponse(HttpStatusCode.OK, expectedStateItem));
87+
88+
return this.mockFixture.Process;
89+
};
90+
91+
TestNCPSClientExecutor component = new TestNCPSClientExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
92+
93+
await component.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
94+
Assert.AreEqual(1, processExecuted);
95+
}
96+
97+
[Test]
98+
public async Task NCPSClientExecutorExecutesAsExpectedWithIntegerTimeParameters()
99+
{
100+
this.mockFixture.Parameters["TestDuration"] = 120;
101+
this.mockFixture.Parameters["WarmupTime"] = 30;
102+
this.mockFixture.Parameters["Delaytime"] = 15;
103+
104+
NetworkingWorkloadExecutorTests.TestNetworkingWorkloadExecutor networkingWorkloadExecutor = new NetworkingWorkloadExecutorTests.TestNetworkingWorkloadExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
105+
await networkingWorkloadExecutor.OnInitialize.Invoke(EventContext.None, CancellationToken.None);
106+
107+
int processExecuted = 0;
108+
this.mockFixture.ProcessManager.OnCreateProcess = (file, arguments, workingDirectory) =>
109+
{
110+
processExecuted++;
111+
this.networkingWorkloadState.ToolState = NetworkingWorkloadToolState.Stopped;
112+
var expectedStateItem = new Item<NetworkingWorkloadState>(nameof(NetworkingWorkloadState), this.networkingWorkloadState);
113+
114+
this.mockFixture.ApiClient.Setup(client => client.GetStateAsync(It.IsAny<string>(), It.IsAny<CancellationToken>(), It.IsAny<IAsyncPolicy<HttpResponseMessage>>()))
115+
.ReturnsAsync(this.mockFixture.CreateHttpResponse(HttpStatusCode.OK, expectedStateItem));
116+
117+
return this.mockFixture.Process;
118+
};
119+
120+
TestNCPSClientExecutor component = new TestNCPSClientExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
121+
122+
Assert.AreEqual(TimeSpan.FromSeconds(120), component.TestDuration);
123+
Assert.AreEqual(TimeSpan.FromSeconds(30), component.WarmupTime);
124+
Assert.AreEqual(TimeSpan.FromSeconds(15), component.DelayTime);
125+
126+
await component.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
127+
Assert.AreEqual(1, processExecuted);
128+
}
129+
130+
[Test]
131+
public void NCPSClientExecutorSupportsIntegerAndTimeSpanTimeFormats()
132+
{
133+
this.mockFixture.Parameters["TestDuration"] = 300;
134+
this.mockFixture.Parameters["WarmupTime"] = 60;
135+
this.mockFixture.Parameters["Delaytime"] = 30;
136+
137+
TestNCPSClientExecutor executor = new TestNCPSClientExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
138+
139+
Assert.AreEqual(TimeSpan.FromSeconds(300), executor.TestDuration);
140+
Assert.AreEqual(TimeSpan.FromSeconds(60), executor.WarmupTime);
141+
Assert.AreEqual(TimeSpan.FromSeconds(30), executor.DelayTime);
142+
143+
this.mockFixture.Parameters["TestDuration"] = "00:05:00";
144+
this.mockFixture.Parameters["WarmupTime"] = "00:01:00";
145+
this.mockFixture.Parameters["Delaytime"] = "00:00:30";
146+
147+
executor = new TestNCPSClientExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
148+
149+
Assert.AreEqual(TimeSpan.FromMinutes(5), executor.TestDuration);
150+
Assert.AreEqual(TimeSpan.FromMinutes(1), executor.WarmupTime);
151+
Assert.AreEqual(TimeSpan.FromSeconds(30), executor.DelayTime);
152+
153+
this.mockFixture.Parameters["TestDuration"] = 180;
154+
executor = new TestNCPSClientExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
155+
TimeSpan integerBasedDuration = executor.TestDuration;
156+
157+
this.mockFixture.Parameters["TestDuration"] = "00:03:00";
158+
executor = new TestNCPSClientExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters);
159+
TimeSpan timespanBasedDuration = executor.TestDuration;
160+
161+
Assert.AreEqual(integerBasedDuration, timespanBasedDuration);
162+
}
163+
164+
private void SetupNetworkingWorkloadState()
165+
{
166+
this.networkingWorkloadState = new NetworkingWorkloadState();
167+
this.networkingWorkloadState.Scenario = "AnyScenario";
168+
this.networkingWorkloadState.Tool = NetworkingWorkloadTool.NCPS;
169+
this.networkingWorkloadState.ToolState = NetworkingWorkloadToolState.Running;
170+
this.networkingWorkloadState.Protocol = "TCP";
171+
this.networkingWorkloadState.TestMode = "MockTestMode";
172+
173+
var expectedStateItem = new Item<NetworkingWorkloadState>(nameof(NetworkingWorkloadState), this.networkingWorkloadState);
174+
175+
this.mockFixture.ApiClient.Setup(client => client.GetStateAsync(It.IsAny<string>(), It.IsAny<CancellationToken>(), It.IsAny<IAsyncPolicy<HttpResponseMessage>>()))
176+
.ReturnsAsync(this.mockFixture.CreateHttpResponse(HttpStatusCode.OK, expectedStateItem));
177+
}
178+
179+
private class TestNCPSClientExecutor : NCPSClientExecutor
180+
{
181+
public TestNCPSClientExecutor(IServiceCollection dependencies, IDictionary<string, IConvertible> parameters)
182+
: base(dependencies, parameters)
183+
{
184+
}
185+
}
186+
}
187+
}

0 commit comments

Comments
 (0)