Skip to content

Commit c43b827

Browse files
committed
HTTP example improvements
1 parent 3d26d3d commit c43b827

File tree

10 files changed

+31
-23
lines changed

10 files changed

+31
-23
lines changed

examples/Demo/DB/Redis/RedisExample.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ public class RedisExample
66
{
77
public void Run()
88
{
9-
NBomberRunner.RegisterScenarios(
10-
new RedisInitScenario().Create(),
11-
new RedisReadScenario().Create(),
12-
new RedisWriteScenario().Create()
13-
)
14-
.LoadConfig("./DB/Redis/config.json")
15-
.Run();
9+
var scn1 = new RedisInitScenario().Create();
10+
var scn2 = new RedisReadScenario().Create();
11+
var scn3 = new RedisWriteScenario().Create();
12+
13+
NBomberRunner.RegisterScenarios(scn1, scn2, scn3)
14+
.LoadConfig("./DB/Redis/config.json")
15+
.Run();
1616
}
1717
}

examples/Demo/Demo.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
7474
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
7575
</Content>
76-
<Content Include="HTTP\WebAppSimulator\config.json">
76+
<Content Include="HTTP\HttpApiSimulator\config.json">
7777
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
7878
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
7979
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>

examples/Demo/HTTP/WebAppSimulator/WebAppSimulatorExample.cs renamed to examples/Demo/HTTP/HttpApiSimulator/HttpApiSimulatorExample.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
using NBomber.CSharp;
2+
using NBomber.Http;
23

3-
namespace Demo.HTTP.WebAppSimulator
4+
namespace Demo.HTTP.HttpApiSimulator
45
{
5-
public class WebAppSimulatorExample
6+
public class HttpApiSimulatorExample
67
{
7-
public void RunHttpUserExample()
8+
public void Run()
89
{
910
// For this example, you'll need to start the HttpApiSimulator, which is located in the examples/simulators solution folder.
1011
// Make sure it’s running before executing the client tests to ensure proper communication.
@@ -15,7 +16,8 @@ public void RunHttpUserExample()
1516
new ReadHttpScenario().Create(),
1617
new WriteHttpScenario().Create()
1718
)
18-
.LoadConfig("./HTTP/WebAppSimulator/config.json")
19+
.WithWorkerPlugins(new HttpMetricsPlugin([HttpVersion.Version1]))
20+
.LoadConfig("./HTTP/HttpApiSimulator/config.json")
1921
.Run();
2022
}
2123
}

examples/Demo/HTTP/WebAppSimulator/InitHttpScenario.cs renamed to examples/Demo/HTTP/HttpApiSimulator/InitHttpScenario.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
using System.Text;
2+
using Bogus;
3+
using Microsoft.Extensions.Configuration;
14
using NBomber.Contracts;
25
using NBomber.CSharp;
36
using NBomber.Http.CSharp;
4-
using Bogus;
5-
using Microsoft.Extensions.Configuration;
67
using Newtonsoft.Json;
7-
using System.Text;
88

9-
namespace Demo.HTTP.WebAppSimulator;
9+
namespace Demo.HTTP.HttpApiSimulator;
1010

1111
public class GlobalCustomSettings
1212
{

examples/Demo/HTTP/WebAppSimulator/ReadHttpScenario.cs renamed to examples/Demo/HTTP/HttpApiSimulator/ReadHttpScenario.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using NBomber.CSharp;
44
using NBomber.Http.CSharp;
55

6-
namespace Demo.HTTP.WebAppSimulator
6+
namespace Demo.HTTP.HttpApiSimulator
77
{
88
public class ReadHttpScenario
99
{

examples/Demo/HTTP/WebAppSimulator/User.cs renamed to examples/Demo/HTTP/HttpApiSimulator/User.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Demo.HTTP.WebAppSimulator
1+
namespace Demo.HTTP.HttpApiSimulator
22
{
33
public class User
44
{

examples/Demo/HTTP/WebAppSimulator/WriteHttpScenario.cs renamed to examples/Demo/HTTP/HttpApiSimulator/WriteHttpScenario.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
using System.Text;
12
using Bogus;
23
using Microsoft.Extensions.Configuration;
34
using NBomber.Contracts;
45
using NBomber.CSharp;
5-
using Newtonsoft.Json;
66
using NBomber.Http.CSharp;
7-
using System.Text;
7+
using Newtonsoft.Json;
88

9-
namespace Demo.HTTP.WebAppSimulator
9+
namespace Demo.HTTP.HttpApiSimulator
1010
{
1111
public class WriteHttpScenario
1212
{
File renamed without changes.

examples/Demo/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
using Demo.HelloWorld;
2020
using Demo.HelloWorld.LoadSimulation;
2121
using Demo.HTTP;
22-
using Demo.HTTP.WebAppSimulator;
2322
using Demo.HTTP.SimpleBookstore;
2423
using Demo.MQTT;
2524
using Demo.MQTT.ClientPool;
@@ -35,6 +34,7 @@
3534
using Demo.AMQP.IndependentActors;
3635
using Demo.Features.RealtimeReporting.Datadog;
3736
using Demo.Features.Timeouts;
37+
using Demo.HTTP.HttpApiSimulator;
3838
using Demo.HTTP.RestSharpDemo;
3939

4040
// -------------------------------
@@ -104,7 +104,7 @@
104104
// new HttpResponseValidation().Run();
105105
// new HttpSendJsonExample().Run();
106106
// new HttpClientArgsExample().Run();
107-
// new WebAppSimulatorExample().RunHttpUserExample();
107+
// new HttpApiSimulatorExample().Run();
108108
// new ExampleSimpleBookstore().Run();
109109
// new HttpRequestTracing().Run();
110110
// new CookiesManagementExample().Run();

examples/HttpApiSimulator/Controllers/UsersController.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public async Task<IResult> Get(int id)
2424
: Results.Ok(user);
2525
}
2626

27+
[HttpPost]
28+
public async Task<bool> Post([FromBody] User user)
29+
{
30+
return await _repository.Update(user);
31+
}
32+
2733
[HttpPut("{id}")]
2834
public async Task<bool> Put(int id, [FromBody] UpdateUserReq request)
2935
{

0 commit comments

Comments
 (0)