Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/qc_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
update: true
- name: Check types
run: |
ty check --python ${Python_ROOT_DIR}/bin/python3
ty check --python ${Python_ROOT_DIR}/bin/python3 src/backend

mkdocs:
name: Style [Documentation]
Expand Down Expand Up @@ -324,6 +324,16 @@ jobs:
cd ${WRAPPER_NAME}
invoke check-server
coverage run -m unittest discover -s test/
- name: Prepare environment for performance tests
run: |
pip uninstall pytest-django -y
cd ${WRAPPER_NAME}
pip install .
- name: Performance Reporting
uses: CodSpeedHQ/action@972e3437949c89e1357ebd1a2dbc852fcbc57245 # pin@v4
with:
mode: simulation
run: pytest ./src/performance --codspeed

coverage:
name: Tests - DB [SQLite] + Coverage ${{ matrix.python_version }}
Expand Down
1 change: 1 addition & 0 deletions src/backend/InvenTree/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def main():
'available on your PYTHONPATH environment variable? Did you '
'forget to activate a virtual environment?'
) from exc

execute_from_command_line(sys.argv)


Expand Down
90 changes: 90 additions & 0 deletions src/performance/tests.py
Original file line number Diff line number Diff line change
@@ -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
Loading