Commit graph

58 commits

Author SHA1 Message Date
Andrei Zeliankou
c183bd8749 Tests: get rid of classes in test files.
Class usage came from the unittest framework and it was always redundant
after migration to the pytest.  This commit removes classes from files
containing tests to make them more readable and understandable.
2023-06-14 18:20:09 +01:00
Andrei Zeliankou
ce2405ec3d Tests: prerequisites checking reworked.
Prerequisites check moved to the module level to simplify class structure.
Discovery and prerequisites checks functions moved to the separate files.
Introduced "require" fixture to provide per-test requirements check.
2023-06-12 14:16:59 +01:00
Andrei Zeliankou
31ff94add9 Tests: more fixtures.
Common methods from applications/proto.py converted to the fixtures.
sysctl check moved to the specific file where it is using.
Some options moved to the constructor to have early access.
2023-05-29 16:45:49 +01:00
Andrei Zeliankou
3e4fa1e202 Tests: removed unused variables. 2023-05-25 14:26:12 +01:00
Andrei Zeliankou
7934dcabbc Tests: switched to using f-strings.
Previously, it was necessary to support older versions of Python for
compatibility.  F-strings were released in Python 3.6.  Python 3.5 was
marked as unsupported by the end of 2020, so now it's possible to start
using f-strings safely for better readability and performance.
2023-02-21 17:21:29 +00:00
OutOfFocus4
6dae517ebd Python: Added "prefix" to configuration.
This patch gives users the option to set a `"prefix"` attribute
for Python applications, either at the top level or for specific
`"target"`s. If the attribute is present, the value of `"prefix"`
must be a string beginning with `"/"`. If the value of the `"prefix"`
attribute is longer than 1 character and ends in `"/"`, the
trailing `"/"` is stripped.

The purpose of the `"prefix"` attribute is to set the `SCRIPT_NAME`
context value for WSGI applications and the `root_path` context
value for ASGI applications, allowing applications to properly route
requests regardless of the path that the server uses to expose the
application.

The context value is only set if the request's URL path begins with
the value of the `"prefix"` attribute. In all other cases, the
`SCRIPT_NAME` or `root_path` values are not set. In addition, for
WSGI applications, the value of `"prefix"` will be stripped from
the beginning of the request's URL path before it is sent to the
application.

Reviewed-by: Andrei Zeliankou <zelenkov@nginx.com>
Reviewed-by: Artem Konev <artem.konev@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-12-14 11:30:30 +01:00
Andrei Zeliankou
c65e04682e Tests: minor fixes. 2022-09-07 01:11:04 +01:00
Andrei Zeliankou
d1cb8ab2bb Tests: added tests with abstract UNIX sockets. 2022-08-25 15:50:49 +01:00
Andrei Zeliankou
39adb292d5 Tests: style. 2021-10-18 01:10:11 +01:00
Andrei Zeliankou
bc84992075 Tests: address configuration tests reworked. 2021-07-03 19:15:04 +01:00
Andrei Zeliankou
b86891c4ef Tests: renamed share to static.
Also minor style changes.
2021-06-28 22:05:40 +01:00
Andrei Zeliankou
2f0cca2e2b Tests: added test to check port release. 2021-05-18 16:35:54 +01:00
Andrei Zeliankou
6c97a1a069 Tests: style. 2021-04-05 14:03:05 +01:00
Andrei Zeliankou
6dc9c47ccd Tests: style. 2021-01-13 06:22:43 +00:00
Andrei Zeliankou
b2e767819f Tests: skip_alert() converted to the fixture. 2020-12-08 14:37:33 +00:00
Andrei Zeliankou
6ec0ff3596 Tests: minor fixes. 2020-10-07 23:18:43 +01:00
Andrei Zeliankou
d5e9159340 Tests: migrated to the pytest. 2020-09-16 21:31:15 +01:00
Tiago Natel de Moura
479fdff39d Tests: set root by unprivilaged user. 2020-08-13 12:17:15 +01:00
Max Romanov
496f41c134 Tests: reducing the number of generated applications.
Each application initializes a shared port with 2 file descriptors, so the test
fails because the router reaches the open files limit.
2020-08-11 19:20:25 +03:00
Andrei Zeliankou
ce4a2bbd05 Tests: style. 2020-05-15 04:20:56 +01:00
Andrei Zeliankou
6a9a4fe0d4 Tests: introduced module version specification in prerequisites. 2020-04-24 05:08:56 +01:00
Andrei Zeliankou
8532cf6ae6 Tests: added tests for comments in JSON. 2020-03-25 19:40:08 +00:00
Andrei Zeliankou
2e4ad9fbc0 Tests: UTF-8 BOM test. 2020-03-25 19:31:42 +00:00
Andrey Zelenkov
486b202cc1 Tests: default port number used. 2019-10-08 00:28:40 +03:00
Andrey Zelenkov
65ca2d7b19 Tests: refactored prerequisites model. 2019-09-14 14:44:35 +03:00
Andrey Zelenkov
90c5d3f5c0 Tests: adjusted skipping tests. 2019-05-30 16:46:04 +03:00
Valentin Bartenev
c1a3b06d03 Tests: using "pass" option instead of deprecated "application". 2019-04-22 18:20:53 +03:00
Andrey Zelenkov
af24e4dec4 Tests: simplified module checking. 2019-04-09 16:14:42 +03:00
Andrey Zelenkov
19eba1730a Tests: unit module refactoring. 2019-03-28 18:43:13 +03:00
Andrey Zelenkov
281899fcef Tests: style. 2019-03-26 23:38:30 +03:00
Max Romanov
b96e5fd848 Turning off port read event state after main process fork.
Master port stores two file descriptors and works as a read port on the master
process side.  After a fork, the port switches into write mode and the read
socket closes, but the same event structure is used for the write socket.
However, the inherited structure remained in read state, telling the epoll
engine to use MOD operation instead of ADD.  The patch resets read event
state, so the engine may write using proper ADD operation.
2019-03-25 14:49:28 +03:00
Max Romanov
e1c4568680 Introducing one more large config test, but without sockets. 2019-03-05 15:38:52 +03:00
Andrey Zelenkov
ea844a4444 Tests: skip more alerts. 2019-03-01 18:58:16 +03:00
Andrey Zelenkov
499096a55a Tests: one more alert skipped in test_json_application_many. 2019-02-20 20:46:23 +03:00
Andrey Zelenkov
955050aea3 Tests: skip sendmsg()/recvmsg() alerts for all tests.
Currently, these alerts may appear in the log when any application exits.
2019-02-20 20:28:29 +03:00
Andrey Zelenkov
ac10bf8c7b Tests: fixed ports range. 2019-02-20 20:19:55 +03:00
Andrey Zelenkov
d60fbc6d44 Tests: large configuration tests. 2019-01-28 17:17:23 +03:00
Andrey Zelenkov
eff760bd2b Tests: added command line arguments parsing in tests.
Added the following command line arguments:

  -d, --detailed: Show detailed output for tests

    Usage examples:

    ./test/run.py --detailed
    python3 test/test_access_log.py --detailed
    python3 test/test_access_log.py -d TestUnitAccessLog.test_access_log_ipv6


  -l, --log: Save unit.log after the test execution

    Usage examples:

    ./test/run.py -l
    python3 test/test_access_log.py -l
    python3 test/test_access_log.py --log TestUnitAccessLog.test_access_log_ipv6
2018-11-15 21:26:15 +03:00
Andrey Zelenkov
511a0fa760 Tests: used relative path for configuration. 2018-09-06 20:18:33 +03:00
Andrey Zelenkov
b82954a5af Tests: empty configuration. 2018-07-11 19:35:23 +03:00
Andrey Zelenkov
1583d659ab Tests: change alert skip in test_listeners_empty after RPC fixes. 2018-04-02 18:37:45 +03:00
Andrey Zelenkov
30a32c2f09 Tests: detect alerts and Sanitizer errors. 2018-03-06 16:58:47 +03:00
Andrey Zelenkov
6aa00fa8d0 Tests: more configuration tests. 2018-02-26 20:18:24 +03:00
Andrey Zelenkov
ee39da0e00 Tests: removed unused code in unit.py. 2018-02-14 17:14:16 +03:00
Andrey Zelenkov
3faa154223 Tests: adjusted check_version()'s. 2018-02-05 15:39:11 +03:00
Max Romanov
9cd4fdbdb7 Introducing extended app process management.
- Pre-fork 'processes.spare' application processes;
- fork more processes to keep 'processes.spare' idle processes;
- fork on-demand up to 'processes.max' count;
- scale down idle application processes above 'processes.spare' after
  'processes.idle_timeout';
- number of concurrently started application processes also limited by
  'processes.spare' (or 1, if spare is 0).
2018-01-29 16:17:36 +03:00
Andrey Zelenkov
9f48f2b3e7 Tests: added methods to manage unit configuration. 2018-01-30 16:16:52 +03:00
Andrey Zelenkov
f115cb7032 Tests: small fixes. 2018-01-30 16:16:42 +03:00
Andrey Zelenkov
cb80be00a5 Tests: fixed test for listener without port.
Broken after 879868522dbf.
2018-01-30 16:16:26 +03:00
Andrey Zelenkov
331514fcf7 Tests: using "expectedFailure" decorator instead of assertTry(). 2018-01-24 15:43:04 +03:00