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.07k stars 131 forks source link

Add Single-file deployment support #629

Closed AndreyFedorovIID closed 8 months ago

AndreyFedorovIID commented 11 months ago

When you need to run a complex test on a client's computer, it would be convenient to be able to publish the test application in a single file (https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli). I tried to do this, but the application immediately crashed because it could not get the path to the executable assembly (GetExecutingAssembly().Location returns null probably):

https://github.com/PragmaticFlow/NBomber/blob/9df197c486566a168e91a03450a8fa1f34665133/src/NBomber/DomainServices/Reports/ReportHelper.fs#L17-L21

It is not difficult to fix this by adding a more flexible configuration.

Perhaps there are some other reasons why such a publication will not work.

Think about adding such a feature, please.

I tried to use

WithReportFolder(Path.Combine(AppContext.BaseDirectory, "reports"))

but it didn't help.

Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
   at System.IO.Path.Combine(String path1, String path2)
   at NBomber.DomainServices.Reports.ReportHelper.getFullReportsFolderPath(SessionArgs sessionArgs)
   at NBomber.DomainServices.TestHost.TestHostConsole.printContextInfo(IGlobalDependency dep, SessionArgs sessionArgs)
   at <StartupCode$NBomber>.$TestHost.StartInit@147.MoveNext()
   at <StartupCode$NBomber>.$TestHost.RunSession@263.MoveNext()
   at NBomber.DomainServices.Runners.SingleNodeRunner.run@22-6.MoveNext()
   at NBomber.DomainServices.NBomberRunner.task@19.MoveNext()
   at NBomber.DomainServices.NBomberRunner.task@37-1.MoveNext()
   at NBomber.DomainServices.NBomberRunner.run(Boolean disposeLogger, NBomberContext context)
   at NBomber.FSharp.NBomberRunner.runWithResult(IEnumerable`1 args, NBomberContext context)
   at NBomber.FSharp.NBomberRunner.run(NBomberContext context)
   at NBomber.CSharp.NBomberRunner.Run(NBomberContext context)
AntyaDev commented 11 months ago

Hi @AndreyFedorovIID

What version of NBomber did you use?

AndreyFedorovIID commented 11 months ago
    <PackageVersion Include="NBomber" Version="5.2.2"/>
    <PackageVersion Include="NBomber.Http" Version="5.0.0"/>
AntyaDev commented 11 months ago

Does this request come from the Business license or Enterprise? I need this information to prioritize this work item.

AndreyFedorovIID commented 11 months ago

I'm choosing a library for testing for the company I work for. We have not yet made a decision to purchase a license. We are currently at the stage of choosing a library.

I decided to just share an idea for improvement, which would be nice to see.

The task can be simply closed if the developers do not see any benefit.

AntyaDev commented 11 months ago

Don't get me wrong, but your task is relevant, and we are willing to include it in our release. We needed this info about the company to understand how we should prioritize it.

En3Tho commented 10 months ago

Just stumbled upon this too

You should use Process.GetCurrentProcess().MainModule.FileName instead

It is technically not a blocking issue but self-contained apps are better in a sense that you don't have to install anything to run the app. Binary is huge but it works.

AntyaDev commented 10 months ago

Thanks @En3Tho , It's beneficial and we will try to integrate with it.

AntyaDev commented 8 months ago

Hi @En3Tho , @AndreyFedorovIID Is this task is still relevant for you?

En3Tho commented 8 months ago

Hello, @AntyaDev For now I've resorted to manually make tar.gz archive with all the data to make copying via ssh faster. In theory single file bundle has similar size and should be easier to use.

Ideally I would rather see work done towards Making NBomber AOT-compatible (I don't know if it is now, but last time I've checked it threw at run time due to serilog missing some things that were trimmed away). I think that would be the best option. Smallest size, faster startup, similar perf for a load utility.

AntyaDev commented 8 months ago

Hi @En3Tho I made the changes that you requested.

Can you please try: https://www.nuget.org/packages/NBomber/5.5.0-beta.1

I tried to build using a single-file deployment, and it worked for me

AntyaDev commented 8 months ago

@En3Tho, @AndreyFedorovIID did you try? If it works for you, I will close this request.

En3Tho commented 8 months ago

Hello, @AntyaDev ! So far I haven't tried that because I'm on vacation now. I will certainly try it out in 1-2 weeks when I get back to work.

AndreyFedorovIID commented 8 months ago

Hi. I was on vacation too.

I just checked tests with 5.2.2 and 5.5.0-beta.1. 5.2.2 crashes as before, and 5.5.0-beta.1 works (<SelfContained>false</SelfContained> (\~12 MB) and <SelfContained>true</SelfContained> (\~74 MB) on windows). I didn't make any code changes. I don't have any tasks for stress tests right now, so I can't give you a more detailed analysis, since I can't spare the time for this. Sorry.

I do not know if all the problems have been fixed, as there may be other effects from combining assemblies into one file. It's not difficult to add tests for this, I think.

As I said earlier, you can close the issue without my response. Since it was not a request, but a suggestion for improvement. (I don't know English very well, maybe I misunderstood or I'm writing incorrectly.)