]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
sync test code with mod-h2
authorStefan Eissing <icing@apache.org>
Wed, 10 Jul 2024 10:55:23 +0000 (10:55 +0000)
committerStefan Eissing <icing@apache.org>
Wed, 10 Jul 2024 10:55:23 +0000 (10:55 +0000)
- shutdown server at end of h2 tests
- adapt minimum httpd versions for some tests
- add test_700_20 for load on blocked connections,
  disabled for now until mpm_event improves
- build websocket client automatically

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1919087 13f79535-47bb-0310-9956-ffa450edef68

test/modules/http2/conftest.py
test/modules/http2/env.py
test/modules/http2/test_103_upgrade.py
test/modules/http2/test_600_h2proxy.py
test/modules/http2/test_700_load_get.py
test/modules/http2/test_800_websockets.py
test/pyhttpd/env.py

index c6f8ddee7119eea38018dbdf76d4eafd1477506d..118cef1a9501578826e2afefece306c67d4a563d 100644 (file)
@@ -35,3 +35,5 @@ def _h2_package_scope(env):
         'AH10400',  # warning that 'enablereuse' has not effect in certain configs
         'AH00045',  # child did not exit in time, SIGTERM was sent
     ])
+    yield
+    assert env.apache_stop() == 0
index bac1a841be468fc5b86c7984d421e7b2157e1492..b2443e003b658fc3207587934492ae1918f6c5eb 100644 (file)
@@ -2,6 +2,7 @@ import inspect
 import logging
 import os
 import subprocess
+from shutil import copyfile
 from typing import Dict, Any
 
 from pyhttpd.certs import CertificateSpec
@@ -52,6 +53,12 @@ class H2TestSetup(HttpdTestSetup):
         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}")
+        test1_docs = os.path.join(self.env.server_docs_dir, 'test1')
+        self.env.mkpath(test1_docs)
+        for fname in ["data-1k", "data-10k", "data-100k", "data-1m"]:
+            src = os.path.join(self.env.gen_dir, fname)
+            dest = os.path.join(test1_docs, fname)
+            copyfile(src, dest)
 
 
 class H2TestEnv(HttpdTestEnv):
index 2fa7d1d68a2e2ee59484d01a925104a7cddeb79b..1542450df9371b02f1e3529027ed027f7fda7d2f 100644 (file)
@@ -90,6 +90,9 @@ class TestUpgrade:
         url = env.mkurl("http", "test1", "/index.html")
         r = env.nghttp().get(url, options=["-u"])
         assert r.response["status"] == 200
+        # check issue #272
+        assert 'date' in r.response["header"], f'{r.response}'
+        assert r.response["header"]["date"] != 'Sun, 00 Jan 1900 00:00:00 GMT', f'{r.response}'
 
     # upgrade to h2c for a request where http/1.1 is preferred, but the clients upgrade
     # wish is honored nevertheless
index d175bbdf3b3fb586b1017d80271c0eacf34dc288..18a528e9c959aeef8c9a4c306847295123473822 100644 (file)
@@ -79,7 +79,7 @@ class TestH2Proxy:
         assert env.apache_restart() == 0
         url = env.mkurl("https", "cgi", f"/h2proxy/{env.http_port}/hello.py")
         # httpd 2.5.0 disables reuse, not matter the config
-        if enable_reuse == "on" and not env.httpd_is_at_least("2.5.0"):
+        if enable_reuse == "on" and not env.httpd_is_at_least("2.4.60"):
             # reuse is not guaranteed for each request, but we expect some
             # to do it and run on a h2 stream id > 1
             reused = False
@@ -132,7 +132,7 @@ class TestH2Proxy:
         assert int(r.json[0]["port"]) == env.http_port
         assert r.response["status"] == 200
         exp_port = env.http_port if enable_reuse == "on" \
-                                    and not env.httpd_is_at_least("2.5.0")\
+                                    and not env.httpd_is_at_least("2.4.60")\
             else env.http_port2
         assert int(r.json[1]["port"]) == exp_port
 
index 78760fbf8cbf11f19390c89ea1c061b476249dbd..138e74ce8588e7f5b63f46c06a202c25cae01e66 100644 (file)
@@ -61,3 +61,37 @@ class TestLoadGet:
                 args.append(env.mkurl("https", "cgi", ("/mnot164.py?count=%d&text=%s" % (start+(n*chunk)+i, text))))
             r = env.run(args)
             self.check_h2load_ok(env, r, chunk)
+
+    # test window sizes, connection and stream
+    @pytest.mark.parametrize("connbits,streambits", [
+        [10, 16],  # 1k connection window, 64k stream windows
+        [10, 30],  # 1k connection window, huge stream windows
+        [30, 8],  # huge conn window, 256 bytes stream windows
+    ])
+    @pytest.mark.skip('awaiting mpm_event improvements')
+    def test_h2_700_20(self, env, connbits, streambits):
+        if not env.httpd_is_at_least("2.5.0"):
+            pytest.skip(f'need at least httpd 2.5.0 for this')
+        conf = H2Conf(env, extras={
+            'base': [
+                'StartServers 1',
+            ]
+        })
+        conf.add_vhost_cgi().add_vhost_test1().install()
+        assert env.apache_restart() == 0
+        assert env.is_live()
+        n = 2000
+        conns = 50
+        parallel = 10
+        args = [
+            env.h2load,
+            '-n', f'{n}', '-t', '1',
+            '-c', f'{conns}', '-m', f'{parallel}',
+            '-W', f'{connbits}',  # connection window bits
+            '-w', f'{streambits}',  # stream window bits
+            f'--connect-to=localhost:{env.https_port}',
+            f'--base-uri={env.mkurl("https", "test1", "/")}',
+            "/data-100k"
+        ]
+        r = env.run(args)
+        self.check_h2load_ok(env, r, n)
\ No newline at end of file
index 14567675351439978debe834f31afe646b42028d..c0fc0c23dcb3ad593e170e7988139e3523d96683 100644 (file)
@@ -84,8 +84,8 @@ def ws_run(env: H2TestEnv, path, authority=None, do_input=None, inbytes=None,
 
 
 @pytest.mark.skipif(condition=H2TestEnv.is_unsupported, reason="mod_http2 not supported here")
-@pytest.mark.skipif(condition=not H2TestEnv().httpd_is_at_least("2.5.0"),
-                    reason=f'need at least httpd 2.5.0 for this')
+@pytest.mark.skipif(condition=not H2TestEnv().httpd_is_at_least("2.4.60"),
+                    reason=f'need at least httpd 2.4.60 for this')
 @pytest.mark.skipif(condition=ws_version < ws_version_min,
                     reason=f'websockets is {ws_version}, need at least {ws_version_min}')
 class TestWebSockets:
index 78c3a649ecd39eabbccb8c33cad33b51825548a2..8a20d928432d226c821f79ded09ff42baaa9de24 100644 (file)
@@ -93,6 +93,7 @@ class HttpdTestSetup:
         self._make_modules_conf()
         self._make_htdocs()
         self._add_aptest()
+        self._build_clients()
         self.env.clear_curl_headerfiles()
 
     def _make_dirs(self):
@@ -196,6 +197,16 @@ class HttpdTestSetup:
             # load our test module which is not installed
             fd.write(f"LoadModule aptest_module   \"{local_dir}/mod_aptest/.libs/mod_aptest.so\"\n")
 
+    def _build_clients(self):
+        clients_dir = os.path.join(
+            os.path.dirname(os.path.dirname(inspect.getfile(HttpdTestSetup))),
+            'clients')
+        p = subprocess.run(['make'], capture_output=True, cwd=clients_dir)
+        rv = p.returncode
+        if rv != 0:
+            log.error(f"compiling test clients failed: {p.stderr}")
+            raise Exception(f"compiling test clients failed: {p.stderr}")
+
 
 class HttpdTestEnv: