-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
80 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using NBomber.CSharp; | ||
using NBomber.Data; | ||
using NBomber.Data.CSharp; | ||
// ReSharper disable CheckNamespace | ||
|
||
namespace CSharpProd.Features; | ||
|
||
public class User | ||
{ | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
} | ||
|
||
public class DataFeedExample | ||
{ | ||
public void Run() | ||
{ | ||
//-------- Load by file --------// | ||
|
||
//var data = new[] {1, 2, 3, 4, 5}; | ||
//var data = Data.LoadCsv<User>("./Features/DataFeed/users-feed-data.csv"); | ||
var data = Data.LoadJson<User[]>("./Features/DataFeed/users-feed-data.json"); | ||
|
||
//-------- Load by URL ---------// | ||
|
||
//var data = Data.LoadCsv<User>("https://raw.githubusercontent.com/PragmaticFlow/NBomber/e54c45912b1826f54376a8668da556aeb922b9d6/examples/CSharpProd/DataFeed/users-feed-data.csv"); | ||
//var data = Data.LoadJson<User[]>("https://raw.githubusercontent.com/PragmaticFlow/NBomber/e54c45912b1826f54376a8668da556aeb922b9d6/examples/CSharpProd/DataFeed/users-feed-data.json"); | ||
|
||
//var feed = DataFeed.Constant(data); | ||
//var feed = DataFeed.Random(data); | ||
var feed = DataFeed.Circular(data); | ||
|
||
var scenario = Scenario.Create("scenario", async context => | ||
{ | ||
var item = feed.GetNextItem(context.ScenarioInfo); | ||
context.Logger.Information("Data from feed: {0}", item.Name); | ||
await Task.Delay(1_000); | ||
return Response.Ok(); | ||
}) | ||
.WithoutWarmUp() | ||
.WithLoadSimulations(Simulation.KeepConstant(copies: 2, during: TimeSpan.FromSeconds(30))); | ||
|
||
NBomberRunner | ||
.RegisterScenarios(scenario) | ||
.Run(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Id,Name | ||
1,Test User 1 | ||
2,Test User 2 | ||
3,Test User 3 | ||
4,Test User 4 | ||
5,Test User 5 |
10 changes: 10 additions & 0 deletions
10
examples/CSharpProd/Features/DataFeed/users-feed-data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"Id": 1, | ||
"Name": "Test User 1" | ||
}, | ||
{ | ||
"Id": 2, | ||
"Name": "Test User 2" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters