Skip to content

Commit 4ca4c86

Browse files
committed
added AutoCluster example
1 parent 72a6d30 commit 4ca4c86

File tree

73 files changed

+160
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+160
-132
lines changed

NBomber.sln

+6-18
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "NBomber.IntegrationTests",
99
EndProject
1010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{10398A75-959D-4271-913A-BE99E4ED5744}"
1111
EndProject
12-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpDev", "examples\CSharpDev\CSharpDev.csproj", "{EF73804A-06F8-4E67-AEB5-F85F44AFC51A}"
13-
EndProject
14-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpProd", "examples\CSharpProd\CSharpProd.csproj", "{657861BD-19DA-4B93-937D-88B5C25E6D87}"
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo", "examples\Demo\Demo.csproj", "{657861BD-19DA-4B93-937D-88B5C25E6D87}"
1513
EndProject
1614
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "xUnitExample", "examples\xUnitExample\xUnitExample.csproj", "{062DD1FF-B466-4F40-BE1F-8D85EA3BDB6A}"
1715
EndProject
1816
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebAppSimulator", "examples\WebAppSimulator\WebAppSimulator.csproj", "{37D936ED-619C-47F8-95BD-63B966590A15}"
1917
EndProject
2018
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookstoreSimulator", "examples\BookstoreSimulator\BookstoreSimulator.csproj", "{9BC9E01E-C12A-45D6-9910-B0642F36338B}"
2119
EndProject
20+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "simulators", "simulators", "{B20C9B19-52F5-4AF1-B41D-D01294BEC6C9}"
21+
EndProject
2222
Global
2323
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2424
Debug|Any CPU = Debug|Any CPU
@@ -53,18 +53,6 @@ Global
5353
{1CD9AA0E-5EF7-45E9-8987-4A6279DC2693}.Release|x64.Build.0 = Release|Any CPU
5454
{1CD9AA0E-5EF7-45E9-8987-4A6279DC2693}.Release|x86.ActiveCfg = Release|Any CPU
5555
{1CD9AA0E-5EF7-45E9-8987-4A6279DC2693}.Release|x86.Build.0 = Release|Any CPU
56-
{EF73804A-06F8-4E67-AEB5-F85F44AFC51A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57-
{EF73804A-06F8-4E67-AEB5-F85F44AFC51A}.Debug|Any CPU.Build.0 = Debug|Any CPU
58-
{EF73804A-06F8-4E67-AEB5-F85F44AFC51A}.Debug|x64.ActiveCfg = Debug|Any CPU
59-
{EF73804A-06F8-4E67-AEB5-F85F44AFC51A}.Debug|x64.Build.0 = Debug|Any CPU
60-
{EF73804A-06F8-4E67-AEB5-F85F44AFC51A}.Debug|x86.ActiveCfg = Debug|Any CPU
61-
{EF73804A-06F8-4E67-AEB5-F85F44AFC51A}.Debug|x86.Build.0 = Debug|Any CPU
62-
{EF73804A-06F8-4E67-AEB5-F85F44AFC51A}.Release|Any CPU.ActiveCfg = Release|Any CPU
63-
{EF73804A-06F8-4E67-AEB5-F85F44AFC51A}.Release|Any CPU.Build.0 = Release|Any CPU
64-
{EF73804A-06F8-4E67-AEB5-F85F44AFC51A}.Release|x64.ActiveCfg = Release|Any CPU
65-
{EF73804A-06F8-4E67-AEB5-F85F44AFC51A}.Release|x64.Build.0 = Release|Any CPU
66-
{EF73804A-06F8-4E67-AEB5-F85F44AFC51A}.Release|x86.ActiveCfg = Release|Any CPU
67-
{EF73804A-06F8-4E67-AEB5-F85F44AFC51A}.Release|x86.Build.0 = Release|Any CPU
6856
{657861BD-19DA-4B93-937D-88B5C25E6D87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
6957
{657861BD-19DA-4B93-937D-88B5C25E6D87}.Debug|Any CPU.Build.0 = Debug|Any CPU
7058
{657861BD-19DA-4B93-937D-88B5C25E6D87}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -118,11 +106,11 @@ Global
118106
HideSolutionNode = FALSE
119107
EndGlobalSection
120108
GlobalSection(NestedProjects) = preSolution
121-
{EF73804A-06F8-4E67-AEB5-F85F44AFC51A} = {10398A75-959D-4271-913A-BE99E4ED5744}
122109
{657861BD-19DA-4B93-937D-88B5C25E6D87} = {10398A75-959D-4271-913A-BE99E4ED5744}
123110
{062DD1FF-B466-4F40-BE1F-8D85EA3BDB6A} = {10398A75-959D-4271-913A-BE99E4ED5744}
124-
{37D936ED-619C-47F8-95BD-63B966590A15} = {10398A75-959D-4271-913A-BE99E4ED5744}
125-
{9BC9E01E-C12A-45D6-9910-B0642F36338B} = {10398A75-959D-4271-913A-BE99E4ED5744}
111+
{B20C9B19-52F5-4AF1-B41D-D01294BEC6C9} = {10398A75-959D-4271-913A-BE99E4ED5744}
112+
{9BC9E01E-C12A-45D6-9910-B0642F36338B} = {B20C9B19-52F5-4AF1-B41D-D01294BEC6C9}
113+
{37D936ED-619C-47F8-95BD-63B966590A15} = {B20C9B19-52F5-4AF1-B41D-D01294BEC6C9}
126114
EndGlobalSection
127115
GlobalSection(ExtensibilityGlobals) = postSolution
128116
SolutionGuid = {C7E9329B-84FE-436E-8A44-26D8176C5C6F}

examples/CSharpDev/CSharpDev.csproj

-15
This file was deleted.

examples/CSharpDev/Program.cs

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using NBomber.CSharp;
2+
using NBomber.Http;
3+
using NBomber.Http.CSharp;
4+
using NBomber.Plugins.Network.Ping;
5+
6+
namespace Demo.Cluster.AutoCluster;
7+
8+
public class AutoClusterExample
9+
{
10+
public void Run()
11+
{
12+
using var httpClient = new HttpClient();
13+
14+
var scenario = Scenario.Create("http_scenario", async context =>
15+
{
16+
var request =
17+
Http.CreateRequest("GET", "https://nbomber.com")
18+
.WithHeader("Content-Type", "application/json");
19+
// .WithBody(new StringContent("{ some JSON }", Encoding.UTF8, "application/json"));
20+
21+
var response = await Http.Send(httpClient, request);
22+
23+
return response;
24+
})
25+
.WithoutWarmUp()
26+
.WithLoadSimulations(Simulation.Inject(rate: 10, interval: TimeSpan.FromSeconds(1), during: TimeSpan.FromSeconds(30)));
27+
28+
NBomberRunner
29+
.RegisterScenarios(scenario)
30+
.WithWorkerPlugins(
31+
new PingPlugin(PingPluginConfig.CreateDefault("nbomber.com")),
32+
new HttpMetricsPlugin(new [] { HttpVersion.Version1 })
33+
)
34+
.LoadConfig("Cluster/AutoCluster/autocluster-config.json")
35+
.EnableLocalDevCluster(true)
36+
.Run();
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"TestSuite": "my test suite",
3+
"TestName": "my test",
4+
5+
"ClusterSettings": {
6+
7+
"AutoCluster": {
8+
"ClusterId": "test_cluster",
9+
"NATSServerURL": "nats://localhost",
10+
11+
"Coordinator": {
12+
"TargetScenarios": ["http_scenario"]
13+
},
14+
15+
"Agent": {
16+
"TargetScenarios": ["http_scenario"],
17+
"AgentsCount": 1
18+
}
19+
}
20+
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: "3.4"
2+
services:
3+
4+
nats:
5+
image: "nats:2.9.6"
6+
command: --js
7+
ports:
8+
- "8222:8222"
9+
- "4222:4222"

examples/CSharpProd/DB/LiteDB/InitDBScenario.cs examples/Demo/DB/LiteDB/InitDBScenario.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using NBomber.Contracts;
55
using NBomber.CSharp;
66

7-
namespace CSharpProd.DB.LiteDB
7+
namespace Demo.DB.LiteDB
88
{
99
public class LiteDBCustomSettings
1010
{

examples/CSharpProd/DB/LiteDB/LiteDBExample.cs examples/Demo/DB/LiteDB/LiteDBExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using LiteDB;
33
using NBomber.CSharp;
44

5-
namespace CSharpProd.DB.LiteDB
5+
namespace Demo.DB.LiteDB
66
{
77
public class LiteDBExample
88
{

examples/CSharpProd/DB/LiteDB/User.cs examples/Demo/DB/LiteDB/User.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace CSharpProd.DB.LiteDB
1+
namespace Demo.DB.LiteDB
22
{
33
public enum Gender
44
{
File renamed without changes.

examples/CSharpProd/DB/Redis/RedisExample.cs examples/Demo/DB/Redis/RedisExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using NBomber.CSharp;
22

3-
namespace CSharpProd.DB.Redis;
3+
namespace Demo.DB.Redis;
44

55
public class RedisExample
66
{

examples/CSharpProd/DB/Redis/RedisInitScenario.cs examples/Demo/DB/Redis/RedisInitScenario.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using NBomber.Data;
55
using StackExchange.Redis;
66

7-
namespace CSharpProd.DB.Redis;
7+
namespace Demo.DB.Redis;
88

99
public class RedisDbConfig
1010
{

examples/CSharpProd/DB/Redis/RedisReadScenario.cs examples/Demo/DB/Redis/RedisReadScenario.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using NBomber.CSharp;
44
using StackExchange.Redis;
55

6-
namespace CSharpProd.DB.Redis;
6+
namespace Demo.DB.Redis;
77

88
public class RedisReadScenario
99
{

examples/CSharpProd/DB/Redis/RedisWriteScenario.cs examples/Demo/DB/Redis/RedisWriteScenario.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using NBomber.Data;
55
using StackExchange.Redis;
66

7-
namespace CSharpProd.DB.Redis;
7+
namespace Demo.DB.Redis;
88

99
public class RedisWriteScenario
1010
{
File renamed without changes.

examples/CSharpProd/DB/SQLiteDB/InitDBScenario.cs examples/Demo/DB/SQLiteDB/InitDBScenario.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Data.SQLite;
66
using Dapper.Contrib.Extensions;
77

8-
namespace CSharpProd.DB.SQLiteDB
8+
namespace Demo.DB.SQLiteDB
99
{
1010
public class SQLiteDBCustomSettings
1111
{

examples/CSharpProd/DB/SQLiteDB/SQLiteDBExample.cs examples/Demo/DB/SQLiteDB/SQLiteDBExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using NBomber;
66
using NBomber.CSharp;
77

8-
namespace CSharpProd.DB.SQLiteDB
8+
namespace Demo.DB.SQLiteDB
99
{
1010
public class SQLiteDBExample
1111
{

examples/CSharpProd/DB/SQLiteDB/User.cs examples/Demo/DB/SQLiteDB/User.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace CSharpProd.DB.SQLiteDB
1+
namespace Demo.DB.SQLiteDB
22
{
33
public enum Gender
44
{

examples/CSharpProd/CSharpProd.csproj examples/Demo/Demo.csproj

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<ItemGroup>
1010
<None Remove="HTTP\SimpleBookstore\config.json" />
1111
<None Remove="HTTP\WebAppSimulator\config.json" />
12+
<None Update="Cluster\AutoCluster\autocluster-config.json">
13+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
14+
</None>
1215
</ItemGroup>
1316

1417
<ItemGroup>
@@ -28,7 +31,7 @@
2831
<PackageReference Include="Bogus" Version="34.0.2" />
2932
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
3033
<PackageReference Include="LiteDB" Version="5.0.15" />
31-
<PackageReference Include="NBomber" Version="5.1.2" />
34+
<PackageReference Include="NBomber" Version="5.2.0" />
3235
<PackageReference Include="NBomber.Data" Version="5.0.0" />
3336
<PackageReference Include="NBomber.Http" Version="5.0.0" />
3437
<PackageReference Include="NBomber.Sinks.InfluxDB" Version="5.0.0" />

examples/CSharpProd/Features/CliArgs/CliArgsExample.cs examples/Demo/Features/CliArgs/CliArgsExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using NBomber.CSharp;
22

3-
namespace CSharpProd.Features.CliArgs;
3+
namespace Demo.Features.CliArgs;
44

55
public class CliArgsExample
66
{

examples/CSharpProd/Features/ClientPool/ClientPoolMqttExample.cs examples/Demo/Features/ClientPool/ClientPoolMqttExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using NBomber.Data;
1010
// ReSharper disable CheckNamespace
1111

12-
namespace CSharpProd.Features;
12+
namespace Demo.Features;
1313

1414
public class CustomScenarioSettings
1515
{

examples/CSharpProd/Features/CustomSettings/CustomSettingsExample.cs examples/Demo/Features/CustomSettings/CustomSettingsExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using NBomber.Contracts.Stats;
44
using NBomber.CSharp;
55

6-
namespace CSharpProd.Features.CustomSettings;
6+
namespace Demo.Features.CustomSettings;
77

88
public class CustomScenarioSettings
99
{

examples/CSharpProd/Features/DataFeed/DataFeedExample.cs examples/Demo/Features/DataFeed/DataFeedExample.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using NBomber.Data.CSharp;
44
// ReSharper disable CheckNamespace
55

6-
namespace CSharpProd.Features;
6+
namespace Demo.Features;
77

88
public class User
99
{
@@ -23,8 +23,8 @@ public void Run()
2323

2424
//-------- Load by URL ---------//
2525

26-
//var data = Data.LoadCsv<User>("https://raw.githubusercontent.com/PragmaticFlow/NBomber/e54c45912b1826f54376a8668da556aeb922b9d6/examples/CSharpProd/DataFeed/users-feed-data.csv");
27-
//var data = Data.LoadJson<User[]>("https://raw.githubusercontent.com/PragmaticFlow/NBomber/e54c45912b1826f54376a8668da556aeb922b9d6/examples/CSharpProd/DataFeed/users-feed-data.json");
26+
//var data = Data.LoadCsv<User>("https://raw.githubusercontent.com/PragmaticFlow/NBomber/e54c45912b1826f54376a8668da556aeb922b9d6/examples/Demo/DataFeed/users-feed-data.csv");
27+
//var data = Data.LoadJson<User[]>("https://raw.githubusercontent.com/PragmaticFlow/NBomber/e54c45912b1826f54376a8668da556aeb922b9d6/examples/Demo/DataFeed/users-feed-data.json");
2828

2929
//var feed = DataFeed.Constant(data);
3030
//var feed = DataFeed.Random(data);

examples/CSharpProd/Features/ElasticsearchLogger/ElasticsearchExample.cs examples/Demo/Features/ElasticsearchLogger/ElasticsearchExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using NBomber.CSharp;
22
using Serilog;
33

4-
namespace CSharpProd.Features.ElasticsearchLogger;
4+
namespace Demo.Features.ElasticsearchLogger;
55

66
public class ElasticsearchExample
77
{

examples/CSharpProd/Features/RealtimeReporting/CustomReportingSink/CustomReportingSink.cs examples/Demo/Features/RealtimeReporting/CustomReportingSink/CustomReportingSink.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using NBomber.CSharp;
55
using Serilog;
66

7-
namespace CSharpProd.Features.RealtimeReporting.CustomReportingSink;
7+
namespace Demo.Features.RealtimeReporting.CustomReportingSink;
88

99
class CustomReportingSink : IReportingSink
1010
{

examples/CSharpProd/Features/RealtimeReporting/InfluxDB/InfluxDBReportingExample.cs examples/Demo/Features/RealtimeReporting/InfluxDB/InfluxDBReportingExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using NBomber.CSharp;
33
using NBomber.Sinks.InfluxDB;
44

5-
namespace CSharpProd.Features.RealtimeReporting.InfluxDB;
5+
namespace Demo.Features.RealtimeReporting.InfluxDB;
66

77
public class InfluxDBReportingExample
88
{

examples/CSharpProd/HTTP/HttpClientArgsExample.cs examples/Demo/HTTP/HttpClientArgsExample.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using NBomber.Http.CSharp;
44
using NBomber.Plugins.Network.Ping;
55

6-
namespace CSharpProd.HTTP;
6+
namespace Demo.HTTP;
77

88
public class HttpClientArgsExample
99
{
@@ -15,7 +15,7 @@ public void Run()
1515
{
1616
var request =
1717
Http.CreateRequest("GET", "https://nbomber.com")
18-
.WithHeader("Accept", "text/html");
18+
.WithHeader("Content-Type", "application/json");
1919
//.WithBody(new StringContent("{ some JSON }", Encoding.UTF8, "application/json"));
2020

2121
// HttpCompletionOption: https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcompletionoption?view=net-7.0

examples/CSharpProd/HTTP/HttpResponseValidation.cs examples/Demo/HTTP/HttpResponseValidation.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using NBomber.Http.CSharp;
55
using NBomber.Plugins.Network.Ping;
66

7-
namespace CSharpProd.HTTP;
7+
namespace Demo.HTTP;
88

99
public class JsonResponse
1010
{

examples/CSharpProd/HTTP/SequentialHttpSteps.cs examples/Demo/HTTP/SequentialHttpSteps.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using NBomber.Http.CSharp;
44
using NBomber.Plugins.Network.Ping;
55

6-
namespace CSharpProd.HTTP;
6+
namespace Demo.HTTP;
77

88
public class SequentialHttpSteps
99
{
@@ -17,8 +17,8 @@ public void Run()
1717
{
1818
var request =
1919
Http.CreateRequest("GET", "https://nbomber.com")
20-
.WithHeader("Accept", "text/html");
21-
//.WithBody(new StringContent("{ some JSON }", Encoding.UTF8, "application/json"));
20+
.WithHeader("Content-Type", "application/json");
21+
//.WithBody(new StringContent("{ some JSON }", Encoding.UTF8, "application/json"));
2222

2323
var response = await Http.Send(httpClient, request);
2424

@@ -29,7 +29,7 @@ public void Run()
2929
{
3030
var request =
3131
Http.CreateRequest("GET", "https://nbomber.com")
32-
.WithHeader("Accept", "text/html");
32+
.WithHeader("Content-Type", "application/json");
3333
//.WithBody(new StringContent("{ some JSON }", Encoding.UTF8, "application/json"));
3434

3535
var response = await Http.Send(httpClient, request);

0 commit comments

Comments
 (0)