]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
*) test: capture and parse output from nghttp more reliably.
authorStefan Eissing <icing@apache.org>
Mon, 14 Feb 2022 13:52:55 +0000 (13:52 +0000)
committerStefan Eissing <icing@apache.org>
Mon, 14 Feb 2022 13:52:55 +0000 (13:52 +0000)
     add repeat param to certain proxy tests.

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

test/modules/http2/test_500_proxy.py
test/pyhttpd/nghttp.py

index b626fdc88a7688dcab5b3f787d9a88c163978ad6..e38cf3fdda9a65d5324ac0c20883466ec48d0528 100644 (file)
@@ -10,12 +10,11 @@ class TestProxy:
 
     @pytest.fixture(autouse=True, scope='class')
     def _class_scope(self, env):
-        TestProxy._local_dir = os.path.dirname(inspect.getfile(TestProxy))
         H2Conf(env).add_vhost_cgi(proxy_self=True).install()
         assert env.apache_restart() == 0
 
     def local_src(self, fname):
-        return os.path.join(TestProxy._local_dir, fname)
+        return os.path.join(os.path.dirname(inspect.getfile(TestProxy)), fname)
 
     def setup_method(self, method):
         print("setup_method: %s" % method.__name__)
@@ -28,10 +27,10 @@ class TestProxy:
         r = env.curl_get(url, 5)
         assert r.response["status"] == 200
         assert "HTTP/1.1" == r.response["json"]["protocol"]
-        assert "" == r.response["json"]["https"]
-        assert "" == r.response["json"]["ssl_protocol"]
-        assert "" == r.response["json"]["h2"]
-        assert "" == r.response["json"]["h2push"]
+        assert r.response["json"]["https"] == ""
+        assert r.response["json"]["ssl_protocol"] == ""
+        assert r.response["json"]["h2"] == ""
+        assert r.response["json"]["h2push"] == ""
 
     # upload and GET again using curl, compare to original content
     def curl_upload_and_verify(self, env, fname, options=None):
@@ -47,9 +46,9 @@ class TestProxy:
         assert r2.response["status"] == 200
         with open(self.local_src(fpath), mode='rb') as file:
             src = file.read()
-        assert src == r2.response["body"]
+        assert r2.response["body"] == src
 
-    def test_h2_500_10(self, env):
+    def test_h2_500_10(self, env, repeat):
         self.curl_upload_and_verify(env, "data-1k", ["--http2"])
         self.curl_upload_and_verify(env, "data-10k", ["--http2"])
         self.curl_upload_and_verify(env, "data-100k", ["--http2"])
@@ -64,15 +63,20 @@ class TestProxy:
         assert 200 <= r.response["status"] < 300
         with open(self.local_src(fpath), mode='rb') as file:
             src = file.read()
-        assert src == r.response["body"]
-
-    def test_h2_500_20(self, env):
+        if r.response["body"] != src:
+            with open(os.path.join(env.gen_dir, "nghttp.out"), 'w') as fd:
+                fd.write(r.outraw)
+                fd.write("\nstderr:\n")
+                fd.write(r.stderr)
+            assert r.response["body"] == src
+
+    def test_h2_500_20(self, env, repeat):
         self.nghttp_post_and_verify(env, "data-1k", [])
         self.nghttp_post_and_verify(env, "data-10k", [])
         self.nghttp_post_and_verify(env, "data-100k", [])
         self.nghttp_post_and_verify(env, "data-1m", [])
 
-    def test_h2_500_21(self, env):
+    def test_h2_500_21(self, env, repeat):
         self.nghttp_post_and_verify(env, "data-1k", ["--no-content-length"])
         self.nghttp_post_and_verify(env, "data-10k", ["--no-content-length"])
         self.nghttp_post_and_verify(env, "data-100k", ["--no-content-length"])
index bc10600a6e58f927f8edaceee46a77ab845d0a5c..3927bc34ff3c56397a418a593284619d5128f00a 100644 (file)
@@ -84,11 +84,12 @@ class Nghttp:
             if len(l) == 0:
                 body += '\n'
                 continue
-            m = re.match(r'\[.*] recv \(stream_id=(\d+)\) (\S+): (\S*)', l)
+            m = re.match(r'(.*)\[.*] recv \(stream_id=(\d+)\) (\S+): (\S*)', l)
             if m:
-                s = self.get_stream(streams, m.group(1))
-                hname = m.group(2)
-                hval = m.group(3)
+                body += m.group(1)
+                s = self.get_stream(streams, m.group(2))
+                hname = m.group(3)
+                hval = m.group(4)
                 print("stream %d header %s: %s" % (s["id"], hname, hval))
                 header = s["header"]
                 if hname in header: 
@@ -98,9 +99,10 @@ class Nghttp:
                 body = ''
                 continue
 
-            m = re.match(r'\[.*] recv HEADERS frame <.* stream_id=(\d+)>', l)
+            m = re.match(r'(.*)\[.*] recv HEADERS frame <.* stream_id=(\d+)>', l)
             if m:
-                s = self.get_stream(streams, m.group(1))
+                body += m.group(1)
+                s = self.get_stream(streams, m.group(2))
                 if s:
                     print("stream %d: recv %d header" % (s["id"], len(s["header"]))) 
                     response = s["response"]
@@ -123,8 +125,8 @@ class Nghttp:
             
             m = re.match(r'(.*)\[.*] recv DATA frame <length=(\d+), .*stream_id=(\d+)>', l)
             if m:
-                s = self.get_stream(streams, m.group(3))
                 body += m.group(1)
+                s = self.get_stream(streams, m.group(3))
                 blen = int(m.group(2))
                 if s:
                     print("stream %d: %d DATA bytes added" % (s["id"], blen))
@@ -140,9 +142,10 @@ class Nghttp:
                 skip_indents = True
                 continue
                 
-            m = re.match(r'\[.*] recv PUSH_PROMISE frame <.* stream_id=(\d+)>', l)
+            m = re.match(r'(.*)\[.*] recv PUSH_PROMISE frame <.* stream_id=(\d+)>', l)
             if m:
-                s = self.get_stream(streams, m.group(1))
+                body += m.group(1)
+                s = self.get_stream(streams, m.group(2))
                 if s:
                     # headers we have are request headers for the PUSHed stream
                     # these have been received on the originating stream, the promised
@@ -283,7 +286,7 @@ Content-Transfer-Encoding: binary
     def _run(self, args) -> ExecResult:
         print(("execute: %s" % " ".join(args)))
         start = datetime.now()
-        p = subprocess.run(args, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+        p = subprocess.run(args, capture_output=True, text=False)
         return ExecResult(args=args, exit_code=p.returncode,
                           stdout=p.stdout, stderr=p.stderr,
                           duration=datetime.now() - start)