DotNetify.LoadTester
1.0.2
dotnet add package DotNetify.LoadTester --version 1.0.2
NuGet\Install-Package DotNetify.LoadTester -Version 1.0.2
<PackageReference Include="DotNetify.LoadTester" Version="1.0.2" />
paket add DotNetify.LoadTester --version 1.0.2
#r "nuget: DotNetify.LoadTester, 1.0.2"
// Install DotNetify.LoadTester as a Cake Addin #addin nuget:?package=DotNetify.LoadTester&version=1.0.2 // Install DotNetify.LoadTester as a Cake Tool #tool nuget:?package=DotNetify.LoadTester&version=1.0.2
<p align="center"><img width="350px" src="http://dotnetify.net/content/images/dotnetify-logo.png"></p>
DotNetify-LoadTester
DotNetify-LoadTester is a tool for authoring and running performance testing on your dotNetify application servers. It allows you to establish thousands of concurrent SignalR connections to your dotNetify hub and write tests that emulate how your application clients interact with the server-side view models.
Installation
Create a .NET Core test or console app project and add the following library from NuGet: DotNetify.LoadTester.
Basic Usage
Start by creating a new instance of LoadTestBuilder and configure the application server URL, the number of clients, and how each one will interact with your server-side view model:
var builder = new LoadTestBuilder("https://my-app.io")
.AddClient(5, (client, index) =>
{
client.Connect(nameof(HelloWorldVM));
});
The AddClient method allows to configure the behaviors of each client through the delegate argument of type ILoadTestClientBuilder
. In the above example, all clients will attempt to connect to the HelloWorldVM view model at the specified URL when the test commences. And just as the real API, you can pass connect options to the Connect method.
Run the load test by calling the RunAsync method with the run duration as its argument:
await builder.RunAsync(TimeSpan.FromMinutes(5));
You can configure how fast the clients get added or disposed with the SetRampUpPeriod and SetRampDownPeriod methods:
await builder
.SetRampUpPeriod(TimeSpan.FromSeconds(30))
.SetRampDownPeriod(TimeSpan.FromSeconds(30))
.RunAsync(TimeSpan.FromMinutes(5));
Without the configuration, the interval defaults to 100 milliseconds between clients.
Logging
It's always a good idea to pass a logger so you can access the information generated by the test runner such as when the clients are connecting, when they are being disposed, or if there are connection errors:
ILogger logger = LoggerFactory
.Create(builder => builder.AddConsole())
.CreateLogger("MyLoadTest");
await builder
.SetLogger(logger)
.RunAsync(TimeSpan.FromMinutes(5));
Client Dispatch
To get the clients to dispatch data following a successful connection, use the Dispatch method. You can specify the frequency, either once or repeating with time delay in milliseconds, and use the Wait method to add delay between different dispatches:
var builder = new LoadTestBuilder("https://my-app.io")
.AddClient(5, (client, index) =>
{
client
.Connect(nameof(HelloWorldVM))
.Dispatch(new { Greetings = "Hello" }).Once()
.Wait(5000)
.Dispatch(new { Greetings = "World" }).Repeat(3, 1000);
});
The Dispatch method has an overload that allows you to pass a callback function to build the dispatch payload at runtime:
client.Dispatch(_ => new { Time = DateTime.Now }).RepeatContinuosly(1000);
Handling Server Responses
When you want to inspect the responses a client receives, and perhaps perform dispatches according to those responses, use the OnServerResponse method:
client
.Connect(nameof(EchoVM))
.OnServerResponse((vm, response) =>
{
var deserializedResponse = response.As<EchoPing>();
vm.Dispatch(new { Pong = deserializedResponse.Ping.Time });
});
The method parameter is an action delegate which passes two arguments: an object of type IClientVM
that will allow you to perform a dispatch, and the server response itself, wrapped in an object of type ServerResponse
. You can access the raw data directly, or use a convenient As method to deserialize the data into a strongly-typed object.
Client Destroy
To remove a client's connection to the view model, use the Destroy method provided by both the ILoadTestClientBuilder
and the IClientVM
types.
To receive callback when the event occurs, use the OnDestroyed method of ILoadTestClientBuilder
.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- BouncyCastle.NetCore (>= 1.8.5)
- Microsoft.AspNetCore.SignalR.Client (>= 3.1.12)
- Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson (>= 3.1.12)
- Microsoft.CSharp (>= 4.5.0)
- Microsoft.Extensions.Logging.Abstractions (>= 5.0.0)
- Newtonsoft.Json (>= 12.0.3)
- System.Reactive (>= 5.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DotNetify.LoadTester:
Package | Downloads |
---|---|
DotNetify.LoadTester.Profiles
Workload profiles for running perfomance testing on dotNetify SignalR hub servers. |
GitHub repositories
This package is not used by any popular GitHub repositories.