PragmaticFlow / NBomber

Modern and flexible load testing framework for Pull and Push scenarios, designed to test any system regardless a protocol (HTTP/WebSockets/AMQP etc) or a semantic model (Pull/Push).
https://nbomber.com
Other
2.08k stars 128 forks source link

Init scenario error: 'System.TypeLoadException: Could not load type 'FsToolkit.ErrorHandling.TaskResultCE' #591

Closed anpin closed 1 year ago

anpin commented 1 year ago

Hi, I'm unable to run NBomber in NUnit F# project if it has dependency on FsToolkit.ErrorHandling.TaskResult package. The error message is:

18:18:22 [ERR] Init scenario error: 'System.TypeLoadException: Could not load type 
'FsToolkit.ErrorHandling.TaskResultCE' from assembly 
'FsToolkit.ErrorHandling.TaskResult, Version=4.6.0.0, Culture=neutral, 
PublicKeyToken=null'.
   at NBomber.DomainServices.TestHost.WorkerPlugins.init@16-1.Invoke(Unit 
unitVar)
   at Ply.TplPrimitives.tryWith[u](FSharpFunc`2 continuation, FSharpFunc`2 
catch)'

here is quick fsi repro

#r "nuget: NBomber"
#r "nuget: FsToolkit.ErrorHandling.TaskResult"
#r "nuget: Ply"
open System
open System.Threading.Tasks
open NBomber.FSharp
open NBomber.Contracts
open FsToolkit.ErrorHandling
open Serilog.Events

Scenario.create("load-test", fun ctx -> task {
    do! Task.Delay(100)
    return Response.ok ()
})
|> Scenario.withoutWarmUp
|> Scenario.withLoadSimulations [ KeepConstant(1, TimeSpan.FromSeconds(10)) ]
|> NBomberRunner.registerScenario
|> NBomberRunner.withMinimumLogLevel LogEventLevel.Debug
|> NBomberRunner.run
anpin commented 1 year ago

related to https://github.com/PragmaticFlow/NBomber/pull/576

anpin commented 1 year ago

I have found that simply updating FsToolkit.ErrorHandling.TaskResult to latest version didn't fix the error. I had to also change target framework to netstandard 2.1 (my test project is targeting .net7.0)

AntyaDev commented 1 year ago

Hi @anpin What version of FsToolkit.ErrorHandling.TaskResult did you used? Try 2.13.0

anpin commented 1 year ago

I have to use latest version 4.6.0 as it is transient dependency from another nuget

AntyaDev commented 1 year ago

It may not work. I never tested with version 4.x

AntyaDev commented 1 year ago

Hi @anpin please try this version https://www.nuget.org/packages/NBomber/5.2.1-beta.0

anpin commented 1 year ago

Hi @anpin please try this version https://www.nuget.org/packages/NBomber/5.2.1-beta.0

Thanks, it works!

dotnet fsi ./nbomber.fsx
  _   _   ____                        _                       ____
 | \ | | | __ )    ___    _ __ ___   | |__     ___   _ __    | ___|
 |  \| | |  _ \   / _ \  | '_ ` _ \  | '_ \   / _ \ | '__|   |___ \
 | |\  | | |_) | | (_) | | | | | | | | |_) | |  __/ | |       ___) |
 |_| \_| |____/   \___/  |_| |_| |_| |_.__/   \___| |_|      |____/

12:27:08 [INF] NBomber "5.2.1" started a new session: "2023-08-17_08.27.37_session_97b4bc42"
12:27:08 [INF] NBomber started as single node
12:27:08 [INF] License validation....
12:27:08 [WRN] THIS VERSION IS FREE ONLY FOR PERSONAL USE. You can't use it for an organization.
12:27:08 [INF] Reports folder: "/home/a/.nuget/packages/nbomber/5.2.1-beta.0/lib/netstandard2.1/reports/2023-08-17_08.27.37_session_97b4bc42"
12:27:08 [INF] Plugins: no plugins were loaded
12:27:08 [INF] Reporting sinks: no reporting sinks were loaded
12:27:08 [INF] Starting init...
12:27:08 [INF] Target scenarios: "load-test"
12:27:08 [INF] Init finished
12:27:08 [INF] Starting bombing...
12:27:22 [INF] Stopping scenarios...
12:27:22 [INF] Calculating final statistics...

───────────────────────────────────────────────────────────────────────────────────────────────────── test info ─────────────────────────────────────────────────────────────────────────────────────────────────────

test suite: nbomber_default_test_suite_name
test name: nbomber_default_test_name
session id: 2023-08-17_08.27.37_session_97b4bc42

────────────────────────────────────────────────────────────────────────────────────────────────── scenario stats ───────────────────────────────────────────────────────────────────────────────────────────────────

scenario: load-test
  - ok count: 94
  - fail count: 0
  - all data: 0 MB
  - duration: 00:00:10

load simulations:
  - keep_constant, copies: 1, during: 00:00:10

┌────────────────────┬────────────────────────────────────────────────────────┐
│               step │ ok stats                                               │
├────────────────────┼────────────────────────────────────────────────────────┤
│               name │ global information                                     │
│      request count │ all = 94, ok = 94, RPS = 9.4                           │
│            latency │ min = 99.4, mean = 100.43, max = 106.57, StdDev = 0.79 │
│ latency percentile │ p50 = 100.42, p75 = 100.8, p95 = 101.12, p99 = 101.25  │
└────────────────────┴────────────────────────────────────────────────────────┘

12:27:22 [INF] Reports saved in folder: "/home/a/nbomber-repro/reports/2023-08-17_08.27.37_session_97b4bc42"
12:27:22 [WRN] THIS VERSION IS FREE ONLY FOR PERSONAL USE. You can't use it for an organization.