'Asynchronous behavioral tests in python (behave)

Description of problem:

I need to write load tests that will fire API calls upon my system, executing multiple asynchronous scenarios. This should be repeated with adjustable "cadency" for a certain period of time simulating the expected system load (data acquisitions, probe messages, client's request ...) and measuring request time, response accuracy, scalability of the system as a whole.

I would like to use BDD semantics so that customer care can write those scenarios while having the option to run multiple scenarios in parallel (asynchronously) either by using some framework or by writing my own scenario launcher (scenario spawner).

Questions:

  • is there any framework that supports this already (ideally in Python)
  • is this solvable by repurposing some of the current framework base (e.g; behave, lettuce ...)

Detailed vision:

Example of scenarios:

Scenario: Unauthorized user requests data
    Given "random_name" is not in DB # checks that the user is not in DB (user is randomly generated hash)
    Try to access data as "random_name"
    We get a "404" response and log the result # checks the response and logs the outcome

Scenario: Authorized user requests small data
    Given "random_name_2" is in DB # inserts user to DB
    Given "data_small" is in DB # checks if data are in DB or create data
    When we try to access "data_small" as "random_name_2"
    We get a "200" response within "0.1" seconds and log the result # checks the response and logs the outcome

Scenario: Authorized user requests large data
    Given "random_name_3" is in DB
    Given "data_large" is in DB
    When we try to access "data_large" as "random_name_3"
    We get a "200" response within "0.5" seconds and log the result

Example of the functionality:

For 25 seconds, run scenarios "Authorized user requests large data", "Authorized user requests small data" with a cadency of 20 scenarios per second



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source