• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

modules/H09-Mar-2022-13,35110,485

pyhttpd/H09-Mar-2022-3,8943,545

.indent.proH A D21-Nov-2004701 5554

Makefile.inH A D14-Dec-2021569 2612

READMEH A D21-Nov-2004173 43

README.pytestH A D18-Dec-20214.9 KiB140107

README.travisH A D13-Dec-20213.7 KiB11678

check_chunkedH A D11-Jul-20061.7 KiB5921

cls.cH A D11-Jul-20064.5 KiB183140

conftest.pyH A D14-Dec-2021287 137

make_sni.shH A D21-Feb-202012.2 KiB397253

test-writev.cH A D11-Jul-20063.1 KiB10260

test_find.cH A D11-Jul-20062.2 KiB7938

test_limits.cH A D21-Feb-20205.8 KiB201125

test_parser.cH A D11-Jul-20062.1 KiB7636

test_select.cH A D11-Jul-20061.4 KiB4719

test_travis_conditions.shH A D07-Mar-20221.3 KiB4333

time-sem.cH A D24-Feb-202214.5 KiB594427

travis_Dockerfile_slapdH A D17-Jun-2020556 109

travis_Dockerfile_slapd.centos7H A D20-Apr-2021238 65

travis_before_linux.shH A D13-Dec-20214.3 KiB151107

travis_run_linux.shH A D13-Jan-20227.7 KiB252176

README

1This directory contains useful test code for testing various bits
2of Apache functionality.  This stuff is for the developers only,
3so we might remove it on public releases.
4

README.pytest

1Apache httpd pytest suite
2=========================
3Using pytest (<https://docs.pytest.org/en/6.2.x/>) and a Python >= 3.8
4for a more flexible testing of Apache httpd.
5
6Install
7-------
8If not already installed, you will need to install 'pytest' and 'OpenSSL' for
9python:
10> apt install python3-pip
11> pip install -U pytest
12> pip install -U pyopenssl
13
14And for 'h2load':
15> apt install nghttp2-client
16
17
18Usage
19-----
20In your httpd source checkout, do:
21
22> make install
23> pytest
24
25and all tests defined run on the installed executable and modules.
26> pytest test/modules/core
27runs all the core tests. You can run tests also by name selection:
28> pytest -k test_core
29runs all test cases starting with 'test_core'. Similar:
30> pytest -k test_core_001_04
31runs the test cases starting with that.
32
33Test output gets more verbose, by adding one or several '-v'. This
34also raises the error log level of the tested modules.
35> pytest -vvv -k test_h2_004_01
36run the specific test with mod_http2 at log level TRACE2.
37
38By default, test cases will configure httpd with mpm_event. You
39can change that with the invocation:
40> MPM=worker pytest test/modules/http2
41
42Some tests rely on additional tools installed in your environment
43and will 'skip' if those are not present. In a non-verbose run,
44these will appear as 's' in the output. If you run pytest more
45verbose, the skipped test cases will mention a reason for why
46they are disabled.
47
48For example, most tests in test/modules/md require an installation
49of 'pebble', an ACME test server, and look for it in $PATH.
50
51
52Workings
53--------
54All tests start httpd on their own and try hard to shut it down
55afterwards. You can abort tests with ^C and they clean up.
56
57httpd is started/stopped repeatedly in testing as configurations
58for individual test cases are changed. This is a main difference to
59the Perl test framework which starts the server with all possible
60combinations configured that are needed by tests.
61
62In test/gen/apache a server root is created with config, logs and htdocs
63directories. test/gen/apache/logs/error_log will be the log.
64Configs start in test/gen/apache/conf/httpd.conf. modules.conf is
65dynamically created for the list of modules that a test suite needs.
66
67Test cases write their specific setup in test.conf and reload/restart
68the httpd process. This makes for a small configuration in a test case.
69
70
71Development
72-----------
73
74Adding a test in an existing file is done by adding a method. Its name
75must start with 'test_' and the common practise is to have the name
76of the test suite there as well. All http2 tests start with 'test_h2_'.
77
78Following this can be any characters. If you make test cases of a
79certain feature with a common prefix, it is easier to invoke just
80them using the '-k' selector on the command line.
81
82You can also add just a new file to a test suite, if you do a new
83range of test cases that do not fit anywhere else. A very simple
84one is found in test/modules/http2/test_001_httpd_alive.py.
85
86There is a python class defined with 2 methods. One is the test
87method itself and the other one ' is
88
89    @pytest.fixture(autouse=True, scope='class')
90    def _class_scope(self, env):
91        code
92
93is marked as a pytest 'fixture'. This is some pytest magic.
94'autouse=True' means that this fixture is run, even though
95no test case uses it directly. scope='class' means that it
96is run once for all test cases in this class.
97
98As you see, this fixture gets a parameter named 'env' and
99that is the name of another pytest fixture, defined in the
100file 'conftest.py' in the same directory.
101
102    @pytest.fixture(scope="package")
103    def env(pytestconfig) -> H2TestEnv:
104        code
105
106This one runs one time per 'package', meaning for all test
107cases in this directory. And it gets the 'pytestconfig'
108as parameter which is a standard pytest fixture.
109
110So, when you run 'pytest -k test_h2_004', pytest will look
111at _all_ test cases defined and collect those with that
112prefix. For each directory with test cases found, it will
113process the 'conftest.py', boot-strapping the 'env' fixture,
114and the process the files with active test cases.
115
116As a result, if you invoke just a single test case, only
117the fixtures needed for that test case are created. This
118gives good turn around times when debugging a test case.
119
120If you want to add a new test suite, create a new directory.
121Add the files '__init__.py', 'conftest.py' and a first
122'test_suitename_something.py'. test/modules/core is the
123simplest example. 'test/modules/http2' shows how you load
124other modules. 'test/modules/md' checks and starts external
125processes (an ACME test server).
126
127
128Infrastructure
129--------------
130The test cases rely on the classes provided in 'test/pyhttpd'
131for common code in managing a httpd test instance and do
132provide some base setups:
133- a small set of virtual hosts with some files
134- access to paths and definitions (env fixture)
135- start/stop httpd and inspect the error log
136- run clients like curl and nghttp
137- create certificates for your hosts and make curl use
138  the root certs (so no --insecure calls by curl).
139
140

README.travis

1
2Variables
3---------
4
5The Travis scripts use the following environment variables:
6
7* APR_VERSION - if set, APR of this version is built and installed in
8  $HOME/root/apr-$APR_VERSION - a value of "trunk" means trunk is
9  used, "*.x" means a branch, otherwise a tagged version is implied.
10
11* APR_CONFIG - arguments to pass when running APR's configure script
12  if APR_VERSION is set
13
14* APU_VERSION - if set, APR-util of this version is built and
15  installed in $HOME/root/apr-util-$APU_VERSION - a value of "*.x"
16  means a branch, otherwise a tagged version is implied.  (Since there
17  is no "trunk" for apr-util, that value cannot be used here.)
18
19* APU_CONFIG - arguments to pass when running APR-util's configure
20  script if APU_VERSION is set
21
22* CONFIG - arguments to pass to httpd's configure script.
23
24* BUILDCONFIG - arguments to pass when running httpd's ./buildconf script
25
26* MFLAGS - arguments to pass when running "make" for httpd.
27
28* SKIP_TESTING - if set, the Perl test framework is not run for the
29  build.
30
31* TEST_UBSAN - set for job using UBSan ("Undefined Behaviour Sanitizer")
32
33* TEST_MALLOC - set for job using enhanced malloc debugging.
34
35* TEST_INSTALL - set for job testing "make install"
36
37* TEST_VPATH - set for job testing srcdir!=builddir
38
39* TEST_LDAP - set for job with slapd, running LDAP tests
40
41* TEST_SSL - set for job with SSL/TLS testing variants
42
43* TESTS - a list of Perl framework tests to run
44
45* TEST_ARGS - arguments to pass to ./t/TEST in the Perl test framework
46
47Caching
48-------
49
50Perl modules installed in $HOME/perl5 are cached.
51
52Anything installed into the $HOME/root directory is cached - notably,
53versions of APR/APR-util are installed here and cached across httpd
54build jobs without needing to be rebuilt every time.
55
56TODO list
57---------
58
59* MacOS build
60* Windows build
61* clang-on-Linux build
62* Use containers for non-Ubuntu-based Linux testing
63* sanity checks for use of APLOGNO() - empty arguments, accidental duplicates, etc.
64 - not sure how exactly
65* Known test failures
66 - "apt-get install" timeout/fails - workaround by moving apt install to before_script phase?
67
68Testing from a Feature Branch
69-----------------------------
70
71An SVN branch off trunk should be mirrored to github, and will be
72tested in the same way that trunk is in Travis, so this workflow is
73available for those familiar with using Subversion and the standard
74ASF/httpd repository layout.
75
76Tested branches are listed at: https://travis-ci.org/github/apache/httpd/branches
77
78Travis will also run the tests for a PR filed against the httpd Github
79repository at https://github.com/apache/httpd or from a fork of this
80repository if enabled for the Travis user.
81
82A workflow to enable testing would be as follows, substituting
83$USERNAME for your github username:
84
85  $ git clone https://github.com/apache/httpd
86  $ cd httpd
87  $ git remote add $USERNAME git@github.com:$USERNAME/httpd.git
88  $ git checkout -b my-feature origin/trunk
89  ... do some work ...
90  $ git commit ...
91  $ git push -u $USERNAME my-feature:my-feature
92
93To enable testing for a fork, visit the settings page at
94https://travis-ci.org/$USERNAME/httpd/settings - you may need to sync
95your account via https://travis-ci.org/account/repositories for a
96freshly created fork.
97
98To create a Pull Request, go to a URL like:
99https://github.com/apache/httpd/compare/trunk...$USERNAME:trunk
100
101Once a PR has been created, travis will run the tests and link the
102results from a PR comment. All tested PRs are listed here:
103https://travis-ci.org/github/apache/httpd/pull_requests
104
105To merge from github back to SVN trunk, create a patch from e.g.:
106
107  $ git diff origin/trunk..my-feature
108
109and then apply it in SVN.  To rebase a feature once trunk has
110diverged, from a feature branch run:
111
112  $ git pull
113  $ git rebase -i origin/trunk
114
115and follow the standard rebase steps.
116