NBomber.FSharp.Hopac 0.0.5

.NET Standard 2.0
NuGet\Install-Package NBomber.FSharp.Hopac -Version 0.0.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package NBomber.FSharp.Hopac --version 0.0.5
<PackageReference Include="NBomber.FSharp.Hopac" Version="0.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NBomber.FSharp.Hopac --version 0.0.5
#r "nuget: NBomber.FSharp.Hopac, 0.0.5"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install NBomber.FSharp.Hopac as a Cake Addin
#addin nuget:?package=NBomber.FSharp.Hopac&version=0.0.5

// Install NBomber.FSharp.Hopac as a Cake Tool
#tool nuget:?package=NBomber.FSharp.Hopac&version=0.0.5

NBomber.FSharp

F# Computation Expressions for NBomber API

Package Description Status
NBomber.FSharp CE for test runners, scenarios and steps NBomber.FSharp
NBomber.FSharp.Http CE for http calls steps, similar to NBomber.Plugins.Http NBomber.FSharp.Http
NBomber.FSharp.Hopac Hopac support for the above, depends on both NBomber.FSharp.Hopac

Build history

Scenario

<table> <tbody> <thead><tr><th>Fluent API</th><th>Computation Expression</th></tr></thead> <tr><td>

Scenario.create "test" [step]
|> Scenario.withWarmUp (seconds 10)
|> Scenario.withLoadSimulations [
    KeepConstant(copies = copiesCount, during = seconds 2)
]

</td><td>

scenario "test" {
    warmUp (seconds 10)
    load [
        KeepConstant(copies = copiesCount, during = seconds 2)
    ]
    init (fun _ -> Task.FromResult())
    clean (fun _ -> Task.FromResult())
    steps [myStep]
    // or if just one step
    myStep
}

</td></tr> </tbody></table>

Step

The overloads of step's custom operation execute accepts a function taking a step context and returning either Response or unit directly or wrapped in a task, async or even in a Hopac job <table> <tbody> <thead><tr><th>Fluent API</th><th>Computation Expression</th></tr></thead> <tr><td>

Step.create("step name",
    myWebsocketPool,
    myGuidFeed,
    (fun ctx -> task {
        let doSomethingWithSocket (_: Guid) (_: ClientWebSocket) =
            ""
        ctx.Logger.Information("Can take feed and client {Ret}",
            takeBoth ctx.FeedItem ctx.Client)
        return Response.Ok()
    }), true)

</td><td>

step "step name" {
    dataFeed myGuidFeed
    myWebsocketPool
    execute (fun ctx ->
        let doSomethingWithSocket (_: Guid) (_: ClientWebSocket) =
            ""
        ctx.Logger.Information("Can take feed and client {Ret}",
            takeBoth ctx.FeedItem ctx.Client) )
    doNotTrack
}

</td></tr> </tbody></table>

Client factory

Simplified construction of clients. Notable differences are:

  • connect and disconnect functions are more tolerant for missing type signatures and arguments
  • no need for cancellationToken argument if it is not used in connect or disconnect functions
  • disconnect can be omitted completely, if the type of created connection implements IDisposable or can be just disposed.
  • count of connections can be omitted too, it defaults to 1
  • even less verbose compared to the C# API

<table> <tbody> <thead><tr><th>Fluent API</th><th>Computation Expression</th></tr></thead> <tr><td>


let clientFactory =
    ClientFactory.create(
        name = "db connections",
        initClient = (fun i ctx -> task {
            let c = new NpgsqlConnection(connectionString)
            do! c.OpenAsync(ctx.CancellationToken)
            return c
        }),
        disposeClient = (fun (c:NpgsqlConnection, ctx) -> c.CloseAsync(ctx.CancellationToken)),
        clientCount = 100)

</td><td>

let clientFactory =
    clients "db connections" {
        count 100
        connect(fun i ctx -> task {
            let c = new NpgsqlConnection(connectionString)
            do! c.OpenAsync(ctx.CancellationToken)
            return c
        })
        disconnect(fun c ctx -> c.CloseAsync(ctx.CancellationToken))
    }

</td></tr> </tbody></table>

Reporter

Imagine you need just a html report. Then it is as short as

report { html }

<table> <tbody> <thead><tr><th>Fluent API</th><th>Computation Expression</th></tr></thead> <tr><td>

    NBomberRunner.withReportFormats [
        ReportFormat.Csv
        ReportFormat.Txt
        ReportFormat.Md
        ReportFormat.Html
    ]
    |> NBomberRunner.withReportingSinks
        [ influxdbSink
          customFormatSink ]
        (seconds 10)
    |> NBomberRunner.withReportFolder "reportsFolder"
    |> NBomberRunner.withReportFileName "reportFile"
    // or if none
    |> NBomberRunner.withoutReports
    ...

</td><td>

    testSuite "Suite name" {
        report {
            csv
            text
            markdown
            html
            sink influxdbSink
            sink customFormatSink
            interval (seconds 10)
            folderName "reportsFolder"
            fileName "reportFile"
        }
        // or if none
        noReports

        ...
    }

</td></tr> </tbody></table>

Other runner configuration

<table> <tbody> <thead><tr><th>Fluent API</th><th>Computation Expression</th></tr></thead> <tr><td>

NBomberRunner.registerScenarios []
|> NBomberRunner.withTestName "Test name"
|> NBomberRunner.withTestSuite "Suite name"
|> NBomberRunner.withoutReports
|> NBomberRunner.disableHintsAnalyzer
|> NBomberRunner.loadConfig "loadTestConfig.json"
|> NBomberRunner.loadInfraConfig "infrastructureConfig.json"
|> NBomberRunner.withWorkerPlugins []
|> NBomberRunner.withApplicationType ApplicationType.Console
// |> NBomberRunner.runWithArgs args
|> NBomberRunner.run
|> evaluateStatsFunction

</td><td>

testSuite "Suite name" {
    testName "Test name"
    noReports
    noHintsAnalyzer
    scenarios scenarioBuilderTest
    config "loadTestConfig.json"
    infraConfig "infrastructureConfig.json"
    plugins [ (* plugins list*) ]
    runConsole
    // runAsProcess
    // runWithArgs args
    // runWithExitCode
}

</td></tr> </tbody></table>

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.5 190 11/12/2021
0.0.4 241 5/28/2021
0.0.3 266 5/17/2021
0.0.3-b 174 3/8/2021
0.0.2 346 11/11/2020
0.0.1 302 11/8/2020

- update to NBomber 2.1.2