NBomber
NBomber copied to clipboard
Is it possible to use Steps for Scenario.withInit and Scenario.withClean?
It would be great if it was possible to reuse the actions defined in the Steps for the Scenario.withInit
and Scenario.withClean
functions.
For example, we could have the steps for some CRUD operations. Even though the steps could be tested within the different scenarios independently, it would be helpful if we could test Read step, and use Create step for initialization, and Delete step for cleanup.
It looks like it's not possible at the moment, or am I missing something?
Hi @pavlogrushetsky I see your point and it sounds reasonable. But what to do with TFeed, TClient, IStepContext within Scenario.withInit ?
I have no idea at the moment 😄 I just tried to replicate some of my existing load tests written in k6, and it turned out that it's not possible to re-use the steps logic for initialization/clean-up. To answer your question, I would need to take a closer look at the source code. But it seems to me like such feature would be very helpful, otherwise I would need to duplicate the same logic (for example, sending an http request) between the step (using NBomber.Http) and initialization/clean-up functions.
Are you using Data Feed or some Websocket, SQL connections in k6 ?
Currently we have just the k6 load tests for our web services over HTTP.
Just by curiosity, why do you consider NBomber over k6 then?
Because it's in F#, and we could use our existing request/response models and other logic.
Hello everyone 👋🏽 I have a similar question. Is there a reason why the Client Factory is unavailable in the IScenarioContext & would it be possible to add it ? We face the same issue as we need to clean up remote data using DELETE HTTP requests. We don't necessarily need to use the exact logic of a step, but at least the HTTP client that we have initialized. I would appreciate any feedback. TY 🙏🏽
Hi @billsioros It's a good question. Technically each step can have a different client factory; for example
Step.Create("test_mongo_db", MongoClientFactory.Create(), execute: async context => return Response.Ok());
Step.Create("test_redis", RedisClientFactory.Create(), execute: async context => return Response.Ok());
Which client factory should be passed to Scenario.Clean() ??
I guess we could have passed an array of ClientFactory(s), but then we face another issue - it's a generics limitation over ClientFactory<T>. It's impossible to have ClientFactories<T>[] since T will differ for RedisClient and MongoDBClient.
I think another option could be just to expose public property from ClientFactory itself. For example, MongoClientFactory.Clients: T[] and then you can just get access to it in ScenarioClean
Scenario.WithClean(context => MongoClientFactory.Clients[0].Dispose())
Thank you @AntyaDev for the prompt response! I appreciate it extremely!
For example, MongoClientFactory.Clients: T[] and then you can just get access to it in ScenarioClean
I assume that this should suffice! Is something along those lines planned ? 😄
Hi @billsioros Yes) This week, I will try to release a new version with a real-time stats table for the NBomber console (replacement for progress bars) And after this release, I will start working on this feature.
Hi @billsioros , https://github.com/PragmaticFlow/NBomber/pull/486
You can use ClientFatory.initializedClients: TClient[] inside Scenario.Clean https://github.com/PragmaticFlow/NBomber.Contracts/blob/dev/src/NBomber.Contracts/ClientFactory.fs#L9