From 0ecb9153ce1bb0159642efa70c9c3f80b5cd7d24 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Mon, 8 Nov 2021 12:33:46 +0000 Subject: [PATCH] * test: just general cleanup and separation - base modules loaded minimized - h2's htdocs/cgi setup now in test/modules/http2 - less args to constructors, more methods git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1894832 13f79535-47bb-0310-9956-ffa450edef68 --- test/modules/core/conftest.py | 11 +- test/modules/core/env.py | 18 - test/modules/core/test_001_encoding.py | 4 +- test/modules/http2/conftest.py | 3 +- test/modules/http2/env.py | 60 +- .../http2}/htdocs/cgi/echo.py | 0 .../http2}/htdocs/cgi/echohd.py | 0 .../http2}/htdocs/cgi/env.py | 0 .../http2}/htdocs/cgi/files/empty.txt | 0 .../http2}/htdocs/cgi/hecho.py | 0 .../http2}/htdocs/cgi/hello.py | 0 .../http2}/htdocs/cgi/mnot164.py | 0 .../http2}/htdocs/cgi/necho.py | 0 .../http2}/htdocs/cgi/upload.py | 0 .../http2}/htdocs/noh2/alive.json | 0 .../http2}/htdocs/noh2/index.html | 0 test/modules/http2/test_001_httpd_alive.py | 2 +- test/modules/http2/test_002_curl_basics.py | 2 +- test/modules/http2/test_003_get.py | 4 +- test/modules/http2/test_004_post.py | 16 +- test/modules/http2/test_006_assets.py | 2 +- test/modules/http2/test_100_conn_reuse.py | 2 +- test/modules/http2/test_101_ssl_reneg.py | 2 +- test/modules/http2/test_102_require.py | 2 +- test/modules/http2/test_103_upgrade.py | 2 +- test/modules/http2/test_104_padding.py | 2 +- test/modules/http2/test_105_timeout.py | 2 +- test/modules/http2/test_200_header_invalid.py | 2 +- .../http2/test_201_header_conditional.py | 2 +- test/modules/http2/test_202_trailer.py | 2 +- test/modules/http2/test_300_interim.py | 2 +- test/modules/http2/test_400_push.py | 2 +- test/modules/http2/test_401_early_hints.py | 2 +- test/modules/http2/test_500_proxy.py | 14 +- .../http2/test_501_proxy_serverheader.py | 2 +- test/modules/http2/test_600_h2proxy.py | 3 +- test/modules/http2/test_700_load_get.py | 2 +- .../http2/test_710_load_post_static.py | 3 +- test/modules/http2/test_711_load_post_cgi.py | 3 +- test/modules/http2/test_712_buffering.py | 1 - test/modules/md/conftest.py | 3 +- test/modules/md/md_acme.py | 2 +- test/modules/md/md_env.py | 45 +- test/modules/md/test_502_acmev2_drive.py | 2 +- test/pyhttpd/conf.py | 2 - test/pyhttpd/env.py | 178 +- .../htdocs/test1/apache.org-files/ant.jpg | Bin 6437 -> 0 bytes .../test1/apache.org-files/asf_logo.png | Bin 29982 -> 0 bytes .../test1/apache.org-files/async-ads.js | 278 -- .../test1/apache.org-files/async-ads.js.br | Bin 50272 -> 0 bytes .../htdocs/test1/apache.org-files/cse.js | 0 .../htdocs/test1/apache.org-files/css.css | 0 .../htdocs/test1/apache.org-files/default.css | 676 ----- .../test1/apache.org-files/defaulten.css | 2284 ----------------- .../test1/apache.org-files/defaulten.js | 674 ----- .../htdocs/test1/apache.org-files/jquery-2.js | 4 - .../htdocs/test1/apache.org-files/jsapi.js | 0 .../htdocs/test1/apache.org-files/min.css | 1 - .../htdocs/test1/apache.org-files/min.css.br | Bin 10116 -> 0 bytes .../htdocs/test1/apache.org-files/mrunit.jpg | Bin 4460 -> 0 bytes .../apache.org-files/search_box_icon.png | Bin 1018 -> 0 bytes .../test1/apache.org-files/small-logo.png | Bin 1499 -> 0 bytes .../htdocs/test1/apache.org-files/styles.css | 131 - .../htdocs/test1/apache.org-files/synapse.jpg | Bin 4396 -> 0 bytes test/pyhttpd/htdocs/test1/apache.org.html | 899 ------- 65 files changed, 199 insertions(+), 5154 deletions(-) delete mode 100644 test/modules/core/env.py rename test/{pyhttpd => modules/http2}/htdocs/cgi/echo.py (100%) rename test/{pyhttpd => modules/http2}/htdocs/cgi/echohd.py (100%) rename test/{pyhttpd => modules/http2}/htdocs/cgi/env.py (100%) rename test/{pyhttpd => modules/http2}/htdocs/cgi/files/empty.txt (100%) rename test/{pyhttpd => modules/http2}/htdocs/cgi/hecho.py (100%) rename test/{pyhttpd => modules/http2}/htdocs/cgi/hello.py (100%) rename test/{pyhttpd => modules/http2}/htdocs/cgi/mnot164.py (100%) rename test/{pyhttpd => modules/http2}/htdocs/cgi/necho.py (100%) rename test/{pyhttpd => modules/http2}/htdocs/cgi/upload.py (100%) rename test/{pyhttpd => modules/http2}/htdocs/noh2/alive.json (100%) rename test/{pyhttpd => modules/http2}/htdocs/noh2/index.html (100%) delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/ant.jpg delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/asf_logo.png delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/async-ads.js delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/async-ads.js.br delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/cse.js delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/css.css delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/default.css delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/defaulten.css delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/defaulten.js delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/jquery-2.js delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/jsapi.js delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/min.css delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/min.css.br delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/mrunit.jpg delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/search_box_icon.png delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/small-logo.png delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/styles.css delete mode 100644 test/pyhttpd/htdocs/test1/apache.org-files/synapse.jpg delete mode 100644 test/pyhttpd/htdocs/test1/apache.org.html diff --git a/test/modules/core/conftest.py b/test/modules/core/conftest.py index bc2540f7173..439cd22e171 100644 --- a/test/modules/core/conftest.py +++ b/test/modules/core/conftest.py @@ -4,25 +4,26 @@ import os import pytest import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) +from pyhttpd.env import HttpdTestEnv -from .env import CoreTestEnv +sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) def pytest_report_header(config, startdir): - env = CoreTestEnv(setup_dirs=False) + env = HttpdTestEnv() return f"core [apache: {env.get_httpd_version()}, mpm: {env.mpm_module}, {env.prefix}]" @pytest.fixture(scope="package") -def env(pytestconfig) -> CoreTestEnv: +def env(pytestconfig) -> HttpdTestEnv: level = logging.INFO console = logging.StreamHandler() console.setLevel(level) console.setFormatter(logging.Formatter('%(levelname)s: %(message)s')) logging.getLogger('').addHandler(console) logging.getLogger('').setLevel(level=level) - env = CoreTestEnv(pytestconfig=pytestconfig) + env = HttpdTestEnv(pytestconfig=pytestconfig) + env.setup_httpd() env.apache_access_log_clear() env.httpd_error_log.clear_log() return env diff --git a/test/modules/core/env.py b/test/modules/core/env.py deleted file mode 100644 index 9b09e90c617..00000000000 --- a/test/modules/core/env.py +++ /dev/null @@ -1,18 +0,0 @@ -import inspect -import logging -import os - -from pyhttpd.env import HttpdTestEnv, HttpdTestSetup - -log = logging.getLogger(__name__) - - -class CoreTestEnv(HttpdTestEnv): - - def __init__(self, pytestconfig=None, setup_dirs=True): - super().__init__(pytestconfig=pytestconfig, - local_dir=os.path.dirname(inspect.getfile(CoreTestEnv))) - if setup_dirs: - self._setup = HttpdTestSetup(env=self) - self._setup.make() - self.issue_certs() diff --git a/test/modules/core/test_001_encoding.py b/test/modules/core/test_001_encoding.py index 5eac78e4b85..b7ffbaa8429 100644 --- a/test/modules/core/test_001_encoding.py +++ b/test/modules/core/test_001_encoding.py @@ -18,7 +18,7 @@ class TestEncoding: """, f"test2.{env.http_tld}": "AllowEncodedSlashes on", - f"cgi.{env.http_tld}": f"ScriptAlias /cgi-bin/ {env.gen_dir}", + f"test1.{env.http_tld}": f"ScriptAlias /cgi-bin/ {env.gen_dir}", }) conf.add_vhost_test1() conf.add_vhost_test2() @@ -73,7 +73,7 @@ class TestEncoding: ["/cgi-bin/%25%32%65%25%32%65/%25%32%65%25%32%65/h2_env.py", 404], ]) def test_core_001_04(self, env, path, status): - url = env.mkurl("https", "cgi", path) + url = env.mkurl("https", "test1", path) r = env.curl_get(url) assert r.response["status"] == status if status == 400: diff --git a/test/modules/http2/conftest.py b/test/modules/http2/conftest.py index 0cfa7cb4dc4..806777439ea 100644 --- a/test/modules/http2/conftest.py +++ b/test/modules/http2/conftest.py @@ -10,7 +10,7 @@ from .env import H2TestEnv def pytest_report_header(config, startdir): - env = H2TestEnv(setup_dirs=False) + env = H2TestEnv() return f"mod_h2 [apache: {env.get_httpd_version()}, mpm: {env.mpm_module}, {env.prefix}]" @@ -36,6 +36,7 @@ def env(pytestconfig) -> H2TestEnv: logging.getLogger('').addHandler(console) logging.getLogger('').setLevel(level=level) env = H2TestEnv(pytestconfig=pytestconfig) + env.setup_httpd() env.apache_access_log_clear() env.httpd_error_log.clear_log() return env diff --git a/test/modules/http2/env.py b/test/modules/http2/env.py index 7923d90f257..d6d96d50a3f 100644 --- a/test/modules/http2/env.py +++ b/test/modules/http2/env.py @@ -16,15 +16,19 @@ class H2TestSetup(HttpdTestSetup): def __init__(self, env: 'HttpdTestEnv'): super().__init__(env=env) + self.add_source_dir(os.path.dirname(inspect.getfile(H2TestSetup))) + self.add_modules(["http2", "proxy_http2", "cgid", "autoindex"]) def make(self): - super().make(add_modules=["http2", "proxy_http2"]) + super().make() self._add_h2test() + self._setup_data_1k_1m() def _add_h2test(self): + local_dir = os.path.dirname(inspect.getfile(H2TestSetup)) p = subprocess.run([self.env.apxs, '-c', 'mod_h2test.c'], capture_output=True, - cwd=os.path.join(self.env.local_dir, 'mod_h2test')) + cwd=os.path.join(local_dir, 'mod_h2test')) rv = p.returncode if rv != 0: log.error(f"compiling md_h2test failed: {p.stderr}") @@ -33,20 +37,34 @@ class H2TestSetup(HttpdTestSetup): modules_conf = os.path.join(self.env.server_dir, 'conf/modules.conf') with open(modules_conf, 'a') as fd: # load our test module which is not installed - fd.write(f"LoadModule h2test_module \"{self.env.local_dir}/mod_h2test/.libs/mod_h2test.so\"\n") + fd.write(f"LoadModule h2test_module \"{local_dir}/mod_h2test/.libs/mod_h2test.so\"\n") + + def _setup_data_1k_1m(self): + s90 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678\n" + with open(os.path.join(self.env.gen_dir, "data-1k"), 'w') as f: + for i in range(10): + f.write(f"{i:09d}-{s90}") + with open(os.path.join(self.env.gen_dir, "data-10k"), 'w') as f: + for i in range(100): + f.write(f"{i:09d}-{s90}") + with open(os.path.join(self.env.gen_dir, "data-100k"), 'w') as f: + for i in range(1000): + f.write(f"{i:09d}-{s90}") + with open(os.path.join(self.env.gen_dir, "data-1m"), 'w') as f: + for i in range(10000): + f.write(f"{i:09d}-{s90}") class H2TestEnv(HttpdTestEnv): - def __init__(self, pytestconfig=None, setup_dirs=True): - super().__init__(pytestconfig=pytestconfig, - local_dir=os.path.dirname(inspect.getfile(H2TestEnv)), - add_base_conf=[ + def __init__(self, pytestconfig=None): + super().__init__(pytestconfig=pytestconfig) + self.add_httpd_conf([ "H2MinWorkers 1", "H2MaxWorkers 64", "Protocols h2 http/1.1 h2c", - ], - interesting_modules=["http2", "proxy_http2", "h2test"]) + ]) + self.add_httpd_log_modules(["http2", "proxy_http2", "h2test"]) self.add_cert_specs([ CertificateSpec(domains=[ f"push.{self._http_tld}", @@ -74,27 +92,8 @@ class H2TestEnv(HttpdTestEnv): re.compile(r'.*:tls_process_client_certificate:.*'), ]) - if setup_dirs: - self._setup = H2TestSetup(env=self) - self._setup.make() - self.issue_certs() - self.setup_data_1k_1m() - - - def setup_data_1k_1m(self): - s90 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678\n" - with open(os.path.join(self.gen_dir, "data-1k"), 'w') as f: - for i in range(10): - f.write(f"{i:09d}-{s90}") - with open(os.path.join(self.gen_dir, "data-10k"), 'w') as f: - for i in range(100): - f.write(f"{i:09d}-{s90}") - with open(os.path.join(self.gen_dir, "data-100k"), 'w') as f: - for i in range(1000): - f.write(f"{i:09d}-{s90}") - with open(os.path.join(self.gen_dir, "data-1m"), 'w') as f: - for i in range(10000): - f.write(f"{i:09d}-{s90}") + def setup_httpd(self, setup: HttpdTestSetup = None): + super().setup_httpd(setup=H2TestSetup(env=self)) class H2Conf(HttpdConf): @@ -135,4 +134,3 @@ class H2Conf(HttpdConf): def add_vhost_test2(self): return super().add_vhost_test2() - diff --git a/test/pyhttpd/htdocs/cgi/echo.py b/test/modules/http2/htdocs/cgi/echo.py similarity index 100% rename from test/pyhttpd/htdocs/cgi/echo.py rename to test/modules/http2/htdocs/cgi/echo.py diff --git a/test/pyhttpd/htdocs/cgi/echohd.py b/test/modules/http2/htdocs/cgi/echohd.py similarity index 100% rename from test/pyhttpd/htdocs/cgi/echohd.py rename to test/modules/http2/htdocs/cgi/echohd.py diff --git a/test/pyhttpd/htdocs/cgi/env.py b/test/modules/http2/htdocs/cgi/env.py similarity index 100% rename from test/pyhttpd/htdocs/cgi/env.py rename to test/modules/http2/htdocs/cgi/env.py diff --git a/test/pyhttpd/htdocs/cgi/files/empty.txt b/test/modules/http2/htdocs/cgi/files/empty.txt similarity index 100% rename from test/pyhttpd/htdocs/cgi/files/empty.txt rename to test/modules/http2/htdocs/cgi/files/empty.txt diff --git a/test/pyhttpd/htdocs/cgi/hecho.py b/test/modules/http2/htdocs/cgi/hecho.py similarity index 100% rename from test/pyhttpd/htdocs/cgi/hecho.py rename to test/modules/http2/htdocs/cgi/hecho.py diff --git a/test/pyhttpd/htdocs/cgi/hello.py b/test/modules/http2/htdocs/cgi/hello.py similarity index 100% rename from test/pyhttpd/htdocs/cgi/hello.py rename to test/modules/http2/htdocs/cgi/hello.py diff --git a/test/pyhttpd/htdocs/cgi/mnot164.py b/test/modules/http2/htdocs/cgi/mnot164.py similarity index 100% rename from test/pyhttpd/htdocs/cgi/mnot164.py rename to test/modules/http2/htdocs/cgi/mnot164.py diff --git a/test/pyhttpd/htdocs/cgi/necho.py b/test/modules/http2/htdocs/cgi/necho.py similarity index 100% rename from test/pyhttpd/htdocs/cgi/necho.py rename to test/modules/http2/htdocs/cgi/necho.py diff --git a/test/pyhttpd/htdocs/cgi/upload.py b/test/modules/http2/htdocs/cgi/upload.py similarity index 100% rename from test/pyhttpd/htdocs/cgi/upload.py rename to test/modules/http2/htdocs/cgi/upload.py diff --git a/test/pyhttpd/htdocs/noh2/alive.json b/test/modules/http2/htdocs/noh2/alive.json similarity index 100% rename from test/pyhttpd/htdocs/noh2/alive.json rename to test/modules/http2/htdocs/noh2/alive.json diff --git a/test/pyhttpd/htdocs/noh2/index.html b/test/modules/http2/htdocs/noh2/index.html similarity index 100% rename from test/pyhttpd/htdocs/noh2/index.html rename to test/modules/http2/htdocs/noh2/index.html diff --git a/test/modules/http2/test_001_httpd_alive.py b/test/modules/http2/test_001_httpd_alive.py index d922b44001e..557d17a453f 100644 --- a/test/modules/http2/test_001_httpd_alive.py +++ b/test/modules/http2/test_001_httpd_alive.py @@ -3,7 +3,7 @@ import pytest from .env import H2Conf -class TestStore: +class TestBasicAlive: @pytest.fixture(autouse=True, scope='class') def _class_scope(self, env): diff --git a/test/modules/http2/test_002_curl_basics.py b/test/modules/http2/test_002_curl_basics.py index dfe39c53db4..bb03bd84f3d 100644 --- a/test/modules/http2/test_002_curl_basics.py +++ b/test/modules/http2/test_002_curl_basics.py @@ -3,7 +3,7 @@ import pytest from .env import H2Conf -class TestStore: +class TestCurlBasics: @pytest.fixture(autouse=True, scope='class') def _class_scope(self, env): diff --git a/test/modules/http2/test_003_get.py b/test/modules/http2/test_003_get.py index a62da2acb25..3fbaa081afd 100644 --- a/test/modules/http2/test_003_get.py +++ b/test/modules/http2/test_003_get.py @@ -4,7 +4,7 @@ import pytest from .env import H2Conf -class TestStore: +class TestGet: @pytest.fixture(autouse=True, scope='class') def _class_scope(self, env): @@ -92,7 +92,7 @@ class TestStore: Index of /006 -My Header Title +

Index of /006