Hi,
I way wondering if there is any way to load test my dash app with a set of simulated users so that I can find out, how many users my app can handle for computational heavy tasks.
The only thing I found so far is this thread about JMeter.
For end-to-end tests I am using the playwright plugin for pytest which does not seem to contain any option to run tests in parallel besides --numprocesses which is not what I am looking as it is made for speeding up testing and not multi-user tests.
This is my minimal setup:
- App:
from dash import Dash, html, callback
from dash.dependencies import Input, Output
import dash_bootstrap_components as dbc
from time import sleep
app = Dash(__name__)
app.layout = html.Div([
dbc.Button('Click me', id='button'),
html.Div(id='output')
])
@callback(
Output('output', 'children'),
Input('button', 'n_clicks')
)
def click_and_sleep(n_clicks):
sleep(1)
return f'Button clicked {n_clicks} times'
if __name__ == '__main__':
app.run_server(debug=True, port=8000)
- pytest.playwright test:
from playwright.sync_api import Page, expect
def test_app(page: Page):
page.goto("http://localhost:8000/")
page.wait_for_selector("#output")
for n in range(3):
page.click("#button")
expect(page.locator("#output")).to_have_text(f"Button clicked {n+1} times")