2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-01-11 13:48:02 +00:00

feat (backend): Add more performance tests (#11080)

* Matmair/issue10740 (#497)

* reduce noise in docker

* refactor path infos

* add more info during local frontend build

* add frontend info during release build

* Revert "Matmair/issue10740 (#497)" (#498)

This reverts commit 415c52813b.

* add more performance tests (dummy)

* dummy change

* disable debug for a more realistic test

* revert debug change

* add "real" tests

* fix style

* specify backend for type check

* add setup prep step

* fix uninstall command

* fix install?

* fix instanciation

* fix test

* fix format

* disable tests

* add auth test

* fix test
This commit is contained in:
Matthias Mair
2026-01-06 04:41:01 +01:00
committed by GitHub
parent 97ea76a955
commit 75d6cbf729
3 changed files with 102 additions and 1 deletions

90
src/performance/tests.py Normal file
View File

@@ -0,0 +1,90 @@
"""Performance benchmarking tests for InvenTree using the module."""
import json
import os
import pytest
from inventree.api import InvenTreeAPI
server = os.environ.get('INVENTREE_PYTHON_TEST_SERVER', 'http://127.0.0.1:12345')
user = os.environ.get('INVENTREE_PYTHON_TEST_USERNAME', 'testuser')
pwd = os.environ.get('INVENTREE_PYTHON_TEST_PASSWORD', 'testpassword')
api_client = InvenTreeAPI(
server,
username=user,
password=pwd,
timeout=30,
token_name='python-test',
use_token_auth=True,
)
@pytest.mark.benchmark
def test_api_auth_performance():
"""Benchmark the API authentication performance."""
client = InvenTreeAPI(
server,
username=user,
password=pwd,
timeout=30,
token_name='python-test',
use_token_auth=True,
)
assert client
@pytest.mark.benchmark
@pytest.mark.parametrize(
'url',
[
'/api/part/',
'/api/part/category/',
'/api/stock/',
'/api/stock/location/',
'/api/company/',
'/api/build/',
#'/api/build/line/',
'/api/build/item/',
'/api/order/so/',
'/api/order/so/shipment/',
#'/api/order/po/',
#'/api/order/po-line/',
'/api/user/roles/',
'/api/parameter/',
'/api/parameter/template/',
],
)
def test_api_list_performance(url):
"""Benchmark the API list request performance."""
result = api_client.get(url)
assert result
assert len(result) > 0
@pytest.mark.benchmark
@pytest.mark.parametrize(
'url',
[
'/api/part/',
'/api/part/category/',
'/api/stock/location/',
'/api/company/',
'/api/build/',
'/api/build/line/',
'/api/build/item/',
'/api/order/so/',
'/api/order/so/shipment/',
'/api/order/po/',
'/api/order/po-line/',
'/api/user/roles/',
'/api/parameter/',
'/api/parameter/template/',
],
)
def test_api_options_performance(url):
"""Benchmark the API OPTIONS request performance."""
response = api_client.request(url, method='OPTIONS')
result = json.loads(response.text)
assert result
assert 'actions' in result
assert len(result['actions']) > 0