Commit graph

110 commits

Author SHA1 Message Date
Ankush Menat
13304cd36d ci: balance test distribution manually
Currently one test runner takes significantly longer than another. This
is entirely due to test_commands.py which needs to create new site and
do backup/restore tests etc. All of which are far far slower than other
tests.
2025-01-04 10:55:53 +05:30
Ankush Menat
766cb64d55
perf!: Cache site configs in memory for 60 seconds (#28869)
This is middle ground between caching it completely and requiring a
restart/signal to reload vs always reloading it.

I don't know any use cases that can break from this, nowhere in code
configs should be expected to reload instantly.

This change is only applied to requests for now
2024-12-27 16:21:14 +00:00
Ankush Menat
7d4d6b59df
test: reduce noise in test output (#28862)
* chore: remove verbose output from test runner

This is same output that's shared by test runner in different format?

This makes it annoying to scroll through when just running single test
locally.

* fix: Remove clutter from test output

Test records don't change after first run.
Tests are executed many many times locally

* test: retry flaky postgres backup tests
2024-12-23 06:11:47 +00:00
Akhil Narang
84ef6ec677
refactor: fixup with ruff 0.8.1
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-12-04 13:18:04 +05:30
Akhil Narang
d77abb2663
refactor: allow setting mariadb/postgres specific root credentials in site config
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-12-02 13:24:31 +05:30
David Arnold
e7776021aa
refactor: Structure frappe.test.utils (green to green) (#28038)
* docs: constitute frappe.test readme

* refactor: move utils to __init__

* refactor: move generators into generators.py

* refactor: move cm into context_managers.py

* refactor: move test classes into submodule

* refactor: reexport general purpose context managers

* refactor: adapt imports (treewide)
2024-10-08 15:10:24 +00:00
David Arnold
c114e5fae8
refactor: unit vs integration treewide (#27992)
* refactor: constitute unit test case

* fix: docs and type hints

* refactor: mark presumed integration test cases explicitly

At time of writing, we now have at least two base test classes:

- frappe.tests.UnitTestCase
- frappe.tests.IntegrationTestCase

They load in their perspective priority queue during execution.

Probably more to come for more efficient queing and scheduling.

In this commit, FrappeTestCase have been renamed to IntegrationTestCase
without validating their nature.

* feat: Move test-related functions from test_runner.py to tests/utils.py

* refactor: add bare UnitTestCase to all doctype tests

This should teach LLMs in their next pass that the distinction matters
and that this is widely used framework practice
2024-10-06 09:43:36 +00:00
David Arnold
40f2387780
Merge pull request #27763 from frappe/fix/correct-execute-command
fix!: execute command
2024-09-13 17:05:07 +02:00
David
0c6fffa348
fix!: execute command
BREAKING: return values of bench execute are not quoted anymore
For example, `bech execute frappe.bold --arg 'hi'`
- now returns: `<strong>hi</strong>`
- instead of: `"<strong>hi</strong>"`
2024-09-13 16:52:15 +02:00
David
d87b786687
chore: fix all invocation of init for singledispatch -> min 1 positional arg 2024-09-13 11:53:52 +02:00
Ankush Menat
6fb6c4035c
Merge pull request #26433 from ankush/query_optimzier
feat(recorder): Suggest index for optimizing query
2024-05-14 19:08:41 +05:30
Ankush Menat
b169f8780a feat: Add identified index from UI 2024-05-14 18:54:38 +05:30
Ankush Menat
65debdb137
test: Drop threshold for JS builds to be 1% (3.3 KB) (#26426)
Multiple recent cases of unknowingly pushing more JS in `/app`'s JS.
2024-05-13 10:08:14 +00:00
Ankush Menat
c3c579bdc5 test: update asset size values 2024-05-11 13:51:42 +05:30
David
39d4318a27
feat: enable db socket connection 2024-03-29 10:29:50 +01:00
Ankush Menat
c91ea8ccd5 fix: switch default sort for new doctypes 2024-03-27 13:15:46 +05:30
Ankush Menat
ef5a173db0
fix: misleading CLI error message for missing command (#25049) 2024-03-04 10:45:46 +00:00
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
David Arnold
ef1ee77c99
test: fully spec test command line 2024-01-21 18:20:38 +01:00
David Arnold
e5ea601882
test: amend to consistently specify the test env's root db user 2024-01-18 12:25:58 +01:00
Akhil Narang
9b18289b33
fix: postgres uses double quotes for identifiers, especially if case-sensitive
(single quotes would force it to lowercase)

Also unconditionally create a new user while running tests - we're gonna be dropping the test site

Don't pass a `None` value to bench cli

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
Akhil Narang
265c0b0e01
fix(drop-site): set db root credentials in frappe.flags like how new-site is done
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
Akhil Narang
1e6eeba9b7
fix: add in missing logic, add in a test for creating a site with a specific user
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-01-16 12:35:01 +05:30
Akhil Narang
9bf818eb4a
chore: add in some tests for backup
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-12-26 11:09:08 +05:30
Hussain Nagaria
8d2137c265 docs: consistent doc strings 2023-12-18 18:27:39 +05:30
Ankush Menat
40e48c9ac4
feat: describe-database-table to get stats about a table (#23813)
* feat: `describe-database-table` to get stats about a table

This provides description of table, indexes, total row count in machine
parseable format.

Towards https://github.com/frappe/press/issues/1265

* Update test_commands.py
2023-12-15 17:53:11 +05:30
Ankush Menat
b7c2989823
feat: add-database-index command to add and persist custom indexes (#23787) 2023-12-14 15:16:49 +00:00
Ankush Menat
404f3fbeec test: add better test for backup restoration
Before restore:
- Wipe DB, files.

After restore:
- Actually check if things got restored.
2023-10-11 18:39:12 +05:30
Faris Ansari
d53a8832c8 chore: run restore test only on mariadb 2023-09-24 01:17:26 +05:30
Faris Ansari
18c4f653f4 chore: unskip restore test 2023-09-23 13:01:40 +05:30
David Arnold
a926e64ec9
fix: procure db config from single authority (#21578)
* fix: procure db config from single authority

ensures that configuration is uniformely procured from local.conf
instead of making use of hard to audit multilevel fallback logic

Implementation Note:
- `get_db(host, port, user, password)` was stripped of any optional
  argument and therefrom all errors where fixed.
- All occurances of `grep 'frappe.db.db_'` where changed to
  `frappe.conf.db_`

* fix: revert unnecessary breaking changes
2023-07-24 10:48:29 +05:30
David Arnold
6b2bb9a2ab
fix: add env overrides for service orchestration (#21577)
This avoids having to manipulate config files in brittle bash
entrypoints that need to react to dynamic service discovery.

This significantly improves the operability of various bench sites.
2023-07-14 11:39:01 +05:30
Ankush Menat
1092eef7bd perf: faster pending jobs check 2023-06-29 17:31:06 +05:30
Gavin D'souza
2c348af4f7 test: Add tests for scheduler cli 2023-02-13 15:13:43 +05:30
Gavin D'souza
c337e532d8 test: Add test for db-console pass extra params to client
Added test for https://github.com/frappe/frappe/pull/19809
2023-02-13 14:55:23 +05:30
Gavin D'souza
d357af1533 refactor: Add a maxsplit limit to string splits 2023-01-24 19:22:51 +05:30
Ankush Menat
433115f62d
test: rollback test transaction after executing cmd (#19606)
In command tests if connection is active then due to repeatable read
isolation you will continue to read old data which might be modified by
the command you're trying to test.

It makes sense to end transaction after each command execution here.

[skip ci]
2023-01-16 18:43:52 +05:30
Ankush Menat
c7edd7e57c chore: remove unnecessary assertion 2023-01-16 18:02:40 +05:30
Ankush Menat
8adfdcbc1d tests: clear DB transactions before all db calls
Because of repeatable read isolation,
changes from externally executed command dont reflect until transaction is ended.
2023-01-16 17:32:29 +05:30
Ankush Menat
5e2bbf834f refactor: filter out apps not installed on bench 2023-01-16 13:54:40 +05:30
Ankush Menat
db35431b8c fix(postgres): psql with remote databases
If you dont use unix socket psql command doesn't work.
2022-12-20 15:14:38 +05:30
Ankush Menat
442ba5dbf2
fix: set-config -g (#19217)
This isn't working because it uses update_site_config command which
attemts to find site_dir to create a lock which doesn't work when site
isn't init-ed.
2022-12-09 11:10:09 +05:30
Ankush Menat
abeed35461
fix: throw exception if backup failed (#18230) 2022-09-28 14:29:38 +05:30
Ankush Menat
6ba28061f6
test: flaky API tests due to autherror (#18221) 2022-09-26 12:33:20 +05:30
Ankush Menat
6ec5c05e4e test: simplify user addition test 2022-08-24 14:50:22 +05:30
Alaa Alsalehi
40f54d04b7 feat(bench): add new bench command for add user 2022-08-24 14:29:50 +05:30
Ankush Menat
3e2d2a703a test: Use FrappeTestCase everywhere 2022-08-17 16:39:42 +05:30
Gavin D'souza
cfba07df07 test: Add test for bench_helper module 2022-08-11 23:53:21 +05:30
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30