nyankiyoshi / pytest-django-queries Goto Github PK
View Code? Open in Web Editor NEWGenerate performance reports from your django database performance tests.
Home Page: https://pytest-django-queries.readthedocs.io/
License: MIT License
Generate performance reports from your django database performance tests.
Home Page: https://pytest-django-queries.readthedocs.io/
License: MIT License
Is your feature request related to a problem? Please describe.
Some users might want to count queries on all their tests without implementing new test cases for checks. So we could include an option for that.
Describe the solution you'd like
We could put a option --queries-count-all
or such.
Describe alternatives you've considered
None.
Additional context
None.
This will compare a given file with the latest one. As follows.
django-queries diff ...files
With 1 <= len(files) <= 2
Is your feature request related to a problem? Please describe.
Users might get confused by the left
and right
label, because those labels might make sense for some users but not to all of them. What is left? What is right?
Describe the solution you'd like
As it might be considered as a major change to actually rename those fields, it would be just easier to let the user decide what they want as label using environment variables.
DJ_QUERIES_LEFT_LABEL = "before"
DJ_QUERIES_RIGHT_LABEL = "after"
Describe the solution you'd like
To be able to see if a test improves or get worst in execution time, e.g. missing indexes.
Describe alternatives you've considered
There is pytest-benchmark.
Describe the bug
In pytest-xdist 2.0 they dropped the slave
terminology to worker
: pytest-dev/pytest-xdist@de3e54f#diff-ef40a8ca3f5a941cc38cb73ed8ae83ad
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Be compatible with latest major version of pytest-xdist: 2.0 and 2.1 but as well as the previous minor version.
pytest -v -m count_queries
The cli parameters are missing help texts. We should add them.
Is your feature request related to a problem? Please describe.
We would like to be able to record a bench session to generate snapshot files to be able to compare diffs and analyze SQL queries and query count.
Describe the solution you'd like
Generate a snapshot per test per module. This would be in a YAML format in order to make it more readable (human-friendly) for pull request reviewers but also for developers locally.
We would also include EXPLAIN queries, as part of #41.
We would include:
Which would look something like:
count: 12
duplicates: 8
queries:
- sql: >
SELECT foo FROM bar WHERE id IN (?, ?, ?, ?, ?, ?)
"Humanizing" the texts should also clean up any word separated by dots, e.g. tests.api.test_homepage_bench
.
Is your feature request related to a problem? Please describe.
We would like to be able to quickly analyze and detect issues against queries. Whether a missing index, optimize query, etc.
Describe the solution you'd like
A possibility would be to intercept QuerySets or SQL queries using django's connection wrapper feature. We would run EXPLAIN
and save/append into a file or snapshot.
Possible issue to investigate: MySQL seems to trigger an infinite recursion when doing this–make sure it works on all RDBMS through travis-ci.
We also need to make sure we are not adding overhead or running queries multiple times–especially writes and we also allow return of values, e.g.:
UPDATE foo SET bar = 1 RETURNING id;
So the user doesn't have an mv
or operations to do to compare tests.
--django-backup-queries
...
...
Is your feature request related to a problem? Please describe.
I run a standard pre-commit
lint which checks for a trailing newline in all files. When the .pytest-queries
file is updated the trailing newline is stripped and must be manually added afterwards
Describe the solution you'd like
Appending a trailing newline to the output
Describe alternatives you've considered
Files can be excluded from the lint, but I'd prefer to avoid special-casing where possible
Additional context
The lint which flags this file is recommended by the pre-commit
project, so will probably affect a fair number of users
show
and html
options (#3)backup
command in cli to make it faster to backup (#29)pytest-xdist
(multi-workers tests - #36)Should be release as rc3 is. If everything goes correctly.
Describe the bug
Only one worker is actually saving the data when running multiple workers through pytest-xdist
.
To Reproduce
Steps to reproduce the behavior:
pytest-xdist
-n 2
)Expected behavior
To have all the results.
Additional context
pytest_sessionstart/finish
is ran on each worker, not on the whole pytest instance.
We will need to have the plugin registered into pytest to actually make it work properly over the workers.
Describe the bug
If we do something like this:
@pytest.mark.django_db
@pytest.mark.count_queries
def test_get_payment_token(api_client):
pass
It will generate queries from the django_db
fixture.
The solution is:
def test_get_payment_token(db, api_client, count_queries):
pass
But then we lose the ability to filter tests by markers.
Is your feature request related to a problem? Please describe.
Users might want to know what is there coverage over the queries.
Describe the solution you'd like
To have a coverage rapport over all the executed code.
Describe alternatives you've considered
We could use coverage.py
and only include the marked tests.
We need some kind of standard style in the future. We will use and require the black style and impose the flake8 checks.
In addition, we will provide a pre-commit
configuration, an installation guide and a usage guide.
Useful to quickly find issues when a diff occurs.
Is your feature request related to a problem? Please describe.
In the HTML results, we could use a row to sum the results per section.
Describe alternatives you've considered
None.
Additional context
None.
Will just act as #24 but would be way faster for the user to actually backup stuff than writing pytest --django-queries-backup
which is way too long but required for pytest
to avoid conflicts. It's more IDE friendly as well which would be way better (e.g. users can do quick runs).
Is your feature request related to a problem? Please describe.
It seems like show
is hard to read as it has too many things on it.
Describe the solution you'd like
We could take example on coverage.py
Name Stmts Miss Cover Missing
-------------------------------------------------------
my_program.py 20 4 80% 33-35, 39
my_other_module.py 56 6 89% 17-23
-------------------------------------------------------
TOTAL 76 10 87%
Describe alternatives you've considered
The HTML export, but it doesn't sum things.
Additional context
None.
To make it more user friendly in CIs we should add a --queries-report=path
option in addition of the variable environment.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.