Skip to content

Commit

Permalink
tests: sync mod_http2 tests with mod_h2 and 2.4.x version checks
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1910701 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
icing committed Jun 30, 2023
1 parent 4751490 commit 236ea15
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
6 changes: 4 additions & 2 deletions test/modules/http2/test_003_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ def test_h2_003_70(self, env):

# produce an error during response body
def test_h2_003_71(self, env, repeat):
pytest.skip("needs fix in core protocol handling")
if env.httpd_is_at_least('2.5.0'):
pytest.skip("needs fix in core protocol handling")
url = env.mkurl("https", "cgi", "/h2test/error?body_error=timeout")
r = env.curl_get(url)
assert r.exit_code != 0, f"{r}"
Expand All @@ -261,7 +262,8 @@ def test_h2_003_71(self, env, repeat):

# produce an error, fail to generate an error bucket
def test_h2_003_72(self, env, repeat):
pytest.skip("needs fix in core protocol handling")
if env.httpd_is_at_least('2.5.0'):
pytest.skip("needs fix in core protocol handling")
url = env.mkurl("https", "cgi", "/h2test/error?body_error=timeout&error_bucket=0")
r = env.curl_get(url)
assert r.exit_code != 0, f"{r}"
21 changes: 9 additions & 12 deletions test/modules/http2/test_004_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ class TestPost:
@pytest.fixture(autouse=True, scope='class')
def _class_scope(self, env):
TestPost._local_dir = os.path.dirname(inspect.getfile(TestPost))
conf = H2Conf(env)
conf.add_vhost_cgi(proxy_self=True, h2proxy_self=True).install()
conf = H2Conf(env, extras={
f'cgi.{env.http_tld}': [
f'<Directory {env.server_docs_dir}/cgi/xxx>',
' RewriteEngine On',
' RewriteRule .* /proxy/echo.py [QSA]',
'</Directory>',
]
})
conf.add_vhost_cgi(proxy_self=True).install()
assert env.apache_restart() == 0

def local_src(self, fname):
Expand Down Expand Up @@ -183,16 +190,6 @@ def post_and_verify(fname, options=None):

def test_h2_004_41(self, env):
# reproduce PR66597, double chunked encoding on redirects
conf = H2Conf(env, extras={
f'cgi.{env.http_tld}': [
f'<Directory {env.server_docs_dir}/cgi/xxx>',
' RewriteEngine On',
' RewriteRule .* /proxy/echo.py [QSA]',
'</Directory>',
]
})
conf.add_vhost_cgi(proxy_self=True).install()
assert env.apache_restart() == 0
url = env.mkurl("https", "cgi", "/xxx/test.json")
r = env.curl_post_data(url, data="0123456789", options=[])
assert r.exit_code == 0
Expand Down
2 changes: 1 addition & 1 deletion test/modules/http2/test_106_shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_h2_106_02(self, env):
r = env.curl_get(url, options=['-v'])
# requests should succeed, but rarely connections get closed
# before the response is received
if r.exit_code == 55:
if r.exit_code in [16, 55]:
# curl send error
assert r.response is None
else:
Expand Down
4 changes: 4 additions & 0 deletions test/modules/http2/test_401_early_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class TestEarlyHints:

@pytest.fixture(autouse=True, scope='class')
def _class_scope(self, env):
if not env.httpd_is_at_least('2.4.58'):
pytest.skip(f'needs httpd 2.4.58')
H2Conf(env).start_vhost(domains=[f"hints.{env.http_tld}"],
port=env.https_port, doc_root="htdocs/test1"
).add("""
Expand Down Expand Up @@ -67,6 +69,8 @@ def test_h2_401_33(self, env, repeat):

# H2EarlyHints enabled, no PUSH, check that it works for H2EarlyHint
def test_h2_401_34(self, env, repeat):
if not env.httpd_is_at_least('2.4.58'):
pytest.skip(f'needs httpd 2.4.58')
url = env.mkurl("https", "hints", "/006-early-no-push.html")
r = env.nghttp().get(url)
assert r.response["status"] == 200
Expand Down
8 changes: 5 additions & 3 deletions test/modules/http2/test_600_h2proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ def test_h2_600_30(self, env):

# produce an error during response body
def test_h2_600_31(self, env, repeat):
pytest.skip("needs fix in core protocol handling")
if env.httpd_is_at_least('2.5.0'):
pytest.skip("needs fix in core protocol handling")
conf = H2Conf(env)
conf.add_vhost_cgi(h2proxy_self=True)
conf.install()
Expand All @@ -163,11 +164,12 @@ def test_h2_600_31(self, env, repeat):
# depending on when the error is detect in proxying, if may RST the
# stream (exit_code != 0) or give a 503 response.
if r.exit_code == 0:
assert r.response['status'] == 503
assert r.response['status'] == 502

# produce an error, fail to generate an error bucket
def test_h2_600_32(self, env, repeat):
pytest.skip("needs fix in core protocol handling")
if env.httpd_is_at_least('2.5.0'):
pytest.skip("needs fix in core protocol handling")
conf = H2Conf(env)
conf.add_vhost_cgi(h2proxy_self=True)
conf.install()
Expand Down
6 changes: 6 additions & 0 deletions test/modules/http2/test_601_h2proxy_twisted.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def test_h2_601_02_echo_delayed(self, env, name):
"data-1k", "data-10k", "data-100k", "data-1m",
])
def test_h2_601_03_echo_fail_early(self, env, name):
if not env.httpd_is_at_least('2.4.58'):
pytest.skip(f'needs httpd 2.4.58')
fpath = os.path.join(env.gen_dir, name)
url = env.mkurl("https", "cgi", "/h2proxy/h2test/echo?fail_after=512")
r = env.curl_upload(url, fpath, options=[])
Expand All @@ -55,13 +57,17 @@ def test_h2_601_03_echo_fail_early(self, env, name):
"data-1k", "data-10k", "data-100k", "data-1m",
])
def test_h2_601_04_echo_fail_late(self, env, name):
if not env.httpd_is_at_least('2.4.58'):
pytest.skip(f'needs httpd 2.4.58')
fpath = os.path.join(env.gen_dir, name)
url = env.mkurl("https", "cgi", f"/h2proxy/h2test/echo?fail_after={os.path.getsize(fpath)}")
r = env.curl_upload(url, fpath, options=[])
# 92 is curl's CURLE_HTTP2_STREAM
assert r.exit_code == 92 or r.response["status"] == 502

def test_h2_601_05_echo_fail_many(self, env):
if not env.httpd_is_at_least('2.4.58'):
pytest.skip(f'needs httpd 2.4.58')
if not env.curl_is_at_least('8.0.0'):
pytest.skip(f'need at least curl v8.0.0 for this')
count = 200
Expand Down

0 comments on commit 236ea15

Please sign in to comment.