Skip to content

Commit 3e669ae

Browse files
committed
Add in the Python port of the old PERL httpd-test framework.
This port achieves 100% parity with the old PERL version. Create a single entry point for both the pyhttpd test suite already here and the new one. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1934933 13f79535-47bb-0310-9956-ffa450edef68
1 parent 354a94e commit 3e669ae

1,065 files changed

Lines changed: 25286 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

test/README

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,96 @@
11
This directory contains useful test code for testing various bits
22
of Apache functionality. This stuff is for the developers only,
33
so we might remove it on public releases.
4+
5+
6+
Python / pytest test suites
7+
===========================
8+
9+
There are two complementary Python (pytest) test suites in this directory.
10+
Both run against an already-built httpd; they are independent of each other.
11+
12+
pyhttpd / modules/ httpd's own test framework. Covers HTTP/2, mod_md
13+
(ACME), HTTP/1, proxy and core behaviour. Drives the
14+
server with external clients (curl, nghttp, h2load) and
15+
is configured via pyhttpd/config.ini (generated by
16+
httpd's configure). Framework code lives in pyhttpd/;
17+
tests live in modules/{core,http1,http2,md,proxy}/.
18+
19+
pytest_suite/ A self-contained port of the classic Perl Apache::Test
20+
suite (core HTTP, per-module tests, security/CVE
21+
regressions, SSL/TLS, PHP). Drives the server with an
22+
in-process Python HTTP client (httpx) and raw sockets.
23+
It is fully self-contained: it ships its own conf
24+
templates, document root, C test modules and helper
25+
framework under pytest_suite/, and reads nothing outside
26+
that directory. See pytest_suite/README.md for details,
27+
including how to add new tests.
28+
29+
The two suites coexist: pytest_suite/ has its own conftest.py and
30+
pyproject.toml, so pytest treats it as its own rootdir and does NOT pick up
31+
this directory's pyhttpd conftest.py. Run pytest_suite from inside
32+
pytest_suite/ (or via the unified runner below) -- do not point pytest at the
33+
top-level test/ directory expecting to run both at once.
34+
35+
36+
Unified runner: run-all-tests.sh
37+
---------------------------------
38+
39+
run-all-tests.sh runs BOTH suites against the same built httpd and reports a
40+
combined result. pytest_suite runs first, then the pyhttpd modules/ tests.
41+
42+
./run-all-tests.sh # run both suites (pytest_suite first)
43+
./run-all-tests.sh --only=pysuite # only the pytest_suite tests
44+
./run-all-tests.sh --only=pyhttpd # only the pyhttpd modules/ tests
45+
./run-all-tests.sh --apxs /path/to/apxs # point at a specific httpd build
46+
./run-all-tests.sh -k status -v # flags pass through to BOTH suites
47+
48+
How it finds the httpd build:
49+
* pytest_suite is located via apxs -- from --apxs, the $APXS environment
50+
variable, the "prefix" in pyhttpd/config.ini, or apxs on $PATH.
51+
* the pyhttpd tests use pyhttpd/config.ini (built by httpd's configure), via
52+
the system "pytest".
53+
54+
Selecting tests:
55+
* Flag arguments (-v, -k NAME, -x, ...) are passed to both suites.
56+
* Positional test paths are passed only to pytest_suite (they are
57+
pytest_suite paths). Select pyhttpd tests with the PYHTTPD_TARGETS
58+
environment variable, e.g.
59+
PYHTTPD_TARGETS="modules/http2" ./run-all-tests.sh --only=pyhttpd
60+
By default the pyhttpd side runs every modules/* directory whose conftest
61+
imports successfully in your environment; a directory whose optional
62+
dependency is missing (e.g. modules/md needs pyOpenSSL) is skipped with a
63+
note rather than aborting the run.
64+
65+
Environment overrides:
66+
APXS path to apxs (default: pyhttpd/config.ini prefix, else PATH)
67+
PHP_FPM path to a php-fpm binary; enables pytest_suite's PHP tests
68+
PYHTTPD_TARGETS pyhttpd test path(s) to run (default: auto-detected modules/*)
69+
70+
The runner exits non-zero if either suite has failures.
71+
72+
73+
Running a suite directly
74+
------------------------
75+
76+
pytest_suite (from its own directory; it creates its own virtualenv):
77+
78+
cd pytest_suite
79+
uv sync # one-time: create the venv
80+
./runtests.sh --apxs /path/to/apxs # all tests
81+
./runtests.sh --php-fpm /path/to/php-fpm tests/t/php # PHP tests
82+
./runtests.sh -k rewrite -v # any pytest args pass through
83+
84+
pyhttpd tests (need pyhttpd/config.ini from httpd's configure, plus curl,
85+
nghttp2/h2load, and -- for modules/md -- pyOpenSSL and an ACME test server):
86+
87+
pytest modules/http2 # all HTTP/2 tests
88+
pytest modules/core -k test_001 # a subset
89+
90+
91+
Other contents
92+
--------------
93+
94+
unit/ C-based unit tests (libcheck / httpdunit).
95+
clients/ helper client programs used by the tests.
96+
*.c small standalone C test programs.

test/pytest_suite/.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Python environment / caches
2+
.venv/
3+
.env
4+
__pycache__/
5+
*.pyc
6+
.pytest_cache/
7+
.ruff_cache/
8+
9+
# C-module build artifacts (regenerated by apxs at run time)
10+
c-modules/apache_httpd_test.h
11+
c-modules/Makefile
12+
c-modules/*/.libs/
13+
c-modules/*/Makefile
14+
c-modules/*/*.slo
15+
c-modules/*/*.lo
16+
c-modules/*/*.la
17+
c-modules/*/*.o
18+
19+
# Generated httpd config (produced from t/conf/*.conf.in at run time)
20+
t/conf/*.conf
21+
t/conf/mime.types
22+
t/conf/cacheroot/
23+
t/conf/apache_test_config.pm
24+
25+
# Generated SSL CA / certs and passphrase helper
26+
t/conf/ssl/ca/
27+
t/conf/ssl/*.conf
28+
t/conf/ssl/*.pl
29+
30+
# Generated helper scripts (produced from t/htdocs/**/*.PL at run time)
31+
t/htdocs/**/*.pl
32+
t/htdocs/modules/access/htaccess/.htaccess
33+
34+
# Runtime state / logs (server pid, error_log, cgid socket, php-fpm, ...)
35+
t/logs/
36+
t/state/
37+
t/php-fpm/log/
38+
t/php-fpm/run/
39+
t/php-fpm/var/

0 commit comments

Comments
 (0)