summaryrefslogtreecommitdiffstats
path: root/test/modules/http2/test_106_shutdown.py
blob: b119292b72d0f0325fecc8a4e5f2db9ba3cacdba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
# mod-h2 test suite
# check HTTP/2 timeout behaviour
#
import time
from threading import Thread

import pytest

from .env import H2Conf, H2TestEnv
from pyhttpd.result import ExecResult


@pytest.mark.skipif(condition=H2TestEnv.is_unsupported, reason="mod_http2 not supported here")
class TestShutdown:

    @pytest.fixture(autouse=True, scope='class')
    def _class_scope(self, env):
        conf = H2Conf(env)
        conf.add_vhost_cgi()
        conf.install()
        assert env.apache_restart() == 0

    def test_h2_106_01(self, env):
        url = env.mkurl("https", "cgi", "/necho.py")
        lines = 100000
        text = "123456789"
        wait2 = 1.0
        self.r = None
        def long_request():
            args = ["-vvv",
                    "-F", f"count={lines}",
                    "-F", f"text={text}",
                    "-F", f"wait2={wait2}",
                    ]
            self.r = env.curl_get(url, 5, options=args)

        t = Thread(target=long_request)
        t.start()
        time.sleep(0.5)
        assert env.apache_reload() == 0
        t.join()
        # noinspection PyTypeChecker
        time.sleep(1)
        r: ExecResult = self.r
        assert r.exit_code == 0
        assert r.response, f"no response via {r.args} in {r.stderr}\nstdout: {len(r.stdout)} bytes"
        assert r.response["status"] == 200, f"{r}"
        assert len(r.response["body"]) == (lines * (len(text)+1)), f"{r}"

    def test_h2_106_02(self, env):
        # PR65731: invalid GOAWAY frame at session start when
        # MaxRequestsPerChild is reached
        # Create a low limit and only 2 children, so we'll encounter this easily
        conf = H2Conf(env, extras={
            'base': [
                "ServerLimit 2",
                "MaxRequestsPerChild 3"
            ]
        })
        conf.add_vhost_test1()
        conf.install()
        assert env.apache_restart() == 0
        url = env.mkurl("https", "test1", "/index.html")
        for i in range(7):
            r = env.curl_get(url, options=['-vvv'])
            assert r.exit_code == 0, f"failed on {i}. request: {r.stdout} {r.stderr}"
            assert r.response["status"] == 200
            assert "HTTP/2" == r.response["protocol"]