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

Lines changed: 6 additions & 18 deletions
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

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/CSharpDev/Program.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
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+
}
Lines changed: 22 additions & 0 deletions
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+
}
Lines changed: 9 additions & 0 deletions
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 renamed to examples/Demo/DB/LiteDB/InitDBScenario.cs

Lines changed: 1 addition & 1 deletion
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 renamed to examples/Demo/DB/LiteDB/LiteDBExample.cs

Lines changed: 1 addition & 1 deletion
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
{
Lines changed: 1 addition & 1 deletion
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
{

0 commit comments

Comments
 (0)